Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Zooming (Read 3657 times)
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Zooming
Oct 28th, 2010 at 2:15pm
Print Post  
Hello, Stoyo. I have a fun problem. I have the Diagram object into the Ruler. And when I zoom diagram by method ZoomIn() and diagram can't be shown (I see only a part of the diagram) at the visible window area I can't sroll it. What I need to do to allow scrolling.
P.S.: scroll bars are enabled.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zooming
Reply #1 - Oct 28th, 2010 at 2:55pm
Print Post  
Hi, What are the Ruler and Diagram.Bounds sizes?
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Zooming
Reply #2 - Oct 29th, 2010 at 5:50am
Print Post  
I didn't set fixed bounds. But I set the event handler for ruler SizeChanged event. The code is following:
Code
Select All
private void OnRuler_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (m_Diagram.Bounds.Width < e.NewSize.Width)
            {
                Rect newBounds = new Rect(m_Diagram.Bounds.X, m_Diagram.Bounds.Y,
                    e.NewSize.Width, m_Diagram.Bounds.Height);
                m_Diagram.Bounds = newBounds;
            }
        }
 


And the XAML of the my user control is shown below:
Code
Select All
<UserControl x:Class="Technologist.TPDEDiagram"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mf="clr-namespace:MindFusion.Diagramming.Wpf;assembly=MindFusion.Diagramming.Wpf"
    xmlns:cmds="clr-namespace:Technologist.InterfaceCommands"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:navigation="http://schemas.actiprosoftware.com/winfx/xaml/navigation"
    xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
    HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
    HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="0"/>
        </Grid.RowDefinitions>
        <mf:Ruler Name="m_Ruler" Margin="0,0,0,2" VerticalScaleVisible="Collapsed"
            HorizontalScaleVisible="Collapsed" SizeChanged="OnRuler_SizeChanged">
            <mf:Ruler.Document>
                <mf:Diagram Name="m_Diagram"
                        ShowDisabledHandles="false"
                        ModificationStart="AutoHandles"
                        SnapToAnchor="OnCreateOrModify"
                        LinkHitDistance="3"
                        ShowGrid="False"
                        AlignToGrid="True"
                        AllowSelfLoops="False"
                        AllowDrop="True"
                        AllowSplitLinks="True"
                        AllowUnanchoredLinks ="False"
                        AllowUnconnectedLinks="False"
                        AutoScroll="True"
                        GridStyle="Points"
                        LinkShape="Cascading"
                        AllowLinkCursor="Arrow"
                        AutoResize="RightAndDown"
                        InplaceEditAcceptOnEnter="False"
                        InplaceEditCancelOnEsc="True"
                        AllowInplaceEdit="False"
                        DragDrop.DragOver="OnDiagram_DragOver"
                        DragDrop.Drop="OnDiagram_Drop"
                        LinkCreated="OnDiagram_LinkCreated"
                        LinkCreating="OnDiagram_LinkCreating"
                        LinkModifying="OnDiagram_LinkModifying"
                        LinkModified="OnDiagram_LinkModified"
                        LinkActivated="OnDiagram_LinkActivated"
                        LinkDeactivated="OnDiagram_LinkDeactivated"
                        SelectionChanged="OnDiagram_SelectionChanged"
                        ContextMenuOpening="OnDiagram_ContextMenuOpening"
                        KeyDown="OnDiagram_KeyDown"
                        EnterInplaceEditMode="OnDiagram_EnterInplaceEditMode"
                        LeaveInplaceEditMode="OnDiagram_LeaveInplaceEditMode"
                        NodeModified="OnDiagram_NodeModified"
                        NodeDeleted="OnDiagram_NodeDeleted"
                        NodeCreated="OnDiagram_NodeCreated"
                        NodeDeleting="OnDiagram_NodeDeleting"
                        NodeActivated="OnDiagram_NodeActivated"
                        NodeDeactivated="OnDiagram_NodeDeactivated"
                        NodeDoubleClicked="OnDiagram_NodeDoubleClicked"
                        NodeModifying="OnDiagram_NodeModifying"
                        ZoomFactorChanged="OnDiagram_ZoomFactorChanged"
                        DirtyChanged="OnDiagram_DirtyChanged">
                </mf:Diagram>
            </mf:Ruler.Document>
        </mf:Ruler>
        <StackPanel Grid.Row="1" Visibility="Collapsed" Orientation="Vertical">
            <Label Content="{Resx ResxName=Technologist.TPDEDiagram,
                                    Key=BreadcrumbInitTitle}" Visibility="Collapsed"/>
        </StackPanel>
    </Grid>
</UserControl>

 

  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Zooming
Reply #3 - Oct 29th, 2010 at 5:54am
Print Post  
And this is the code for ZoomFactorChanged event:
Code
Select All
	  private void OnDiagram_ZoomFactorChanged(object sender, EventArgs e)
	  {
		Rect newBounds = new Rect(m_Diagram.Bounds.X, m_Diagram.Bounds.Y,
		    m_Ruler.ActualWidth * 100 / m_Diagram.ZoomFactor,
		    m_Ruler.ActualHeight * 100 / m_Diagram.ZoomFactor);
		m_Diagram.Bounds = newBounds;
	  }
 

  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Zooming
Reply #4 - Oct 29th, 2010 at 6:33am
Print Post  
Probably I have found the problem. It must be:
Code
Select All
	  private void OnDiagram_ZoomFactorChanged(object sender, EventArgs e)
	  {
		Rect newBounds = new Rect();
		if (m_Diagram.ZoomFactor >= 100)
		    newBounds = new Rect(m_Diagram.Bounds.X, m_Diagram.Bounds.Y,
			  m_Ruler.ActualWidth / (100 / m_Diagram.ZoomFactor),
			  m_Ruler.ActualHeight / (100 / m_Diagram.ZoomFactor));
		else
		    newBounds = new Rect(m_Diagram.Bounds.X, m_Diagram.Bounds.Y,
			  m_Ruler.ActualWidth * (100 / m_Diagram.ZoomFactor),
			  m_Ruler.ActualHeight * (100 / m_Diagram.ZoomFactor));
		m_Diagram.Bounds = newBounds;
	  }
 


Is it correct?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zooming
Reply #5 - Oct 29th, 2010 at 8:18am
Print Post  
Hi. So you are trying to ensure that the diagram's scrollable area is never smaller than the ruler size, but allow it to become larger when there are many items?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint