Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Aspect ration is not working. (Read 3307 times)
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Aspect ration is not working.
Jan 22nd, 2013 at 6:52am
Print Post  
I am working with mindfussion.diagramming diagram. I can increase width and height diagram node using numeric buttons. Named spnwidth, spnHeight  here is code.


r = diagram.Selection.Items(0).GetRect

For Lop = 0 To diagram.Nodes.Count - 1
                If diagram.Nodes(Lop).Selected = True Then
                    Updated = True
                    Select Case sender.name
                        Case "spnLeft"
                            r.X = CDbl(spnLeft.Value) 'Control move Left or right side depend on spnLeft value
                        Case "spnTop"
                            r.Y = CDbl(spnTop.Value) 'Control move Up or Down side depend on spnTop value
                        Case "spnWidth"
                            r.Width = CDbl(spnWidth.Value) 'Control Width will Increse/Decrease
                        Case "spnHeight"
                            r.Height = CDbl(spnHeight.Value) 'Control Height will Increse/Decrease
                    End Select
                    diagram.Nodes(Lop).SetBounds(r, True)
                End If
                If Updated = True Then Exit Sub Sad
            Next Lop
        End If


I have toggle button for aspect ratio, and while I checked this code as

Dim Lop As Long
        For Lop = 0 To diagram.Nodes.Count - 1
            If diagram.Nodes(Lop).Selected = True Then
                diagram.Nodes(Lop).Constraints.KeepRatio = IIf(cmdAspect.IsChecked, True, False)
            End If
        Next Lop


it is working fine when i increase width or height from mouse but if it is checked and increase the value of height or width numeric button so it doesnn't work.  help me.

Thanks in advance  Sad
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Aspect ration is not working.
Reply #1 - Jan 22nd, 2013 at 6:59am
Print Post  
Constraints values are applied only during user interaction. The control doesn't constrain anything when you are setting node.Bounds from code. So you will have to preserve the ratio yourself:

Code
Select All
var r = node.Bounds;
var a = r.Width / r.Height;

r.Width = newValue;
r.Height = newValue / a;

// or

// r.Height = newValue;
// r.Width = newValue * a;

node.Bounds = r; 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint