Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Zindex problem in new version. (Read 8838 times)
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Zindex problem in new version.
Apr 19th, 2013 at 12:01pm
Print Post  
Hi stoyo,

I am using new version of minfussion and working with diagram. I can insert three type of diagram node which are media Chanel , clock and shape node control. For media channel, I have written class which is inherit from "shapenode" class and for clock which is belongs to "ControlNode" and third is diagram shape node. My requirement is zindex of shape node is always less than of zindex media channel and clock control, and media Chanel and clock control maintain zindex automatically as they inserted. I have done it in it's previous version, using this code, when insert shape node in diagram. code is here:-

diagramNode.ZIndex -= diagram.Nodes.Where(Function(x) TypeOf x Is MultimediaControl OrElse TypeOf x Is ControlNode).Count and i am saving all node database by making xml string in which Zindex of node is stored respectively.

this code is automatically maintain the zindex of all node, which is available in diagram because of zindex is unique. But I have analysed it in new version,if media chanel and clock placed at the diagram before shape node and insert shape node in diagram, then shape node is come above of all media chanel and clock control.

How to overcome from this issue, please suggest me something. so that i can meet my requirement.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zindex problem in new version.
Reply #1 - Apr 19th, 2013 at 1:17pm
Print Post  
Hi,

The new version allows items to have same ZIndex value and no longer imposes the requirement ZIndex values to be in the range 0..items-1, so it won't reset all items' ZIndex to consecutive integers when you change an item's ZIndex.

If you simply need all ShapeNodes to be displayed behind all media and clock nodes, you could use the new layers feature. E.g. add two layers to diagram.Layers, set the LayerIndex property of ShapeNodes to 0, and the LayerIndex of clock and media nodes to 1. That should ensure ShapeNodes are always in the back, regardless of ZIndex values.

If you were using ZIndex as some kind of database identifier, use Id instead, and assign consecutive values to it for each new node created.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Re: Zindex problem in new version.
Reply #2 - Apr 19th, 2013 at 2:20pm
Print Post  
Hi Stoyo,

Thanks for replying back. Your solution is working. Shape node is always behind the media Chanel or clock control. But in my project, There are 4 buttons named "Bring To Front", "Bring Forward" , "Send Backward" and "Send To Back". It's means media Chanel go back to or come front of another media Chanel or clock control and same condition applied for clock control. I maintained through Zindex of Node. So i am using new version now, in new version, layer concept is there. I want to maintain this condition in new version i.e media Chanel go back to or come front of another media Chanel or clock control but not behind the shape node.

How can i do it ? Please suggest me something....

Thanks in advance Smiley

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zindex problem in new version.
Reply #3 - Apr 22nd, 2013 at 6:41am
Print Post  
Hi,

Try calling items' ZBottom, ZTop, ZLevelDown, ZLevelUp methods, with their keepInLayer argument set to true.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Re: Zindex problem in new version.
Reply #4 - Apr 24th, 2013 at 6:11am
Print Post  
Hi Stoyo,

Thanks to reply back. Yes your solution working fine. I am creating New bound with 2 layer. code is here:-

BGBounds = New Rect(0, 0, 1024, 768)
BGNode = diagram.Factory.CreateContainerNode(BGBounds)
Dim lc As New MindFusion.Diagramming.Layer
Dim lc1 As New MindFusion.Diagramming.Layer
diagram.Layer.Add(lc)
diagram.Layer.Add(lc1)


and whenever i place any node in diagram and set LayerIndex of node. For media Chanel and clock , set LayerIndex to 1 and Shape Node is 0. shape node is always behind the media and clock chenel. But i can cut, copy and paste node by code. here is code


For Lop = 0 To CopyNodeList.Count - 1
Dim NewNode As Object
NewNode = CloneControl(CopyNodeList.Item(Lop))
If NewNode IsNot Nothing Then
With NewNode

If X >= 0 Or Y >= 0 Then
Dim r As Rect
r = NewNode.GetBounds
r.X = X
r.Y = Y
NewNode.SetBounds(r, True)

Dim node As ShapeNode
Select Case NewNode.GetType.ToString
Case ShapeTypeName
.Id = "Shape#" & Trim(Str(NodeCountID))
.Name = GetNextValidNodeName("Shape ")
node = CopyNodeList.Item(Lop)
Dim MS As ImageSource = node.Image
.Image = MS

Case ControlTypeName
Dim SplitSt() As String
SplitSt = Split(.ID, "#")
If UBound(SplitSt) < 2 Then ReDim Preserve SplitSt(2)
.Id = "DateTime#" & Trim(Str(NodeCountID)) & "#" & SplitSt(2)
.Name = GetNextValidNodeName("Date & Time ")
'Tag Pos 2
SplitSt = Split(.ID, "#")
Select Case Val(SplitSt(2))
Case 0
Dim CTL As New CTLDigitalClock
.Control = CTL
Case 1
Dim CTL As New CTLAnalogClock
.Control = CTL
End Select

Case AppName & ".MultimediaControl"
.Id = "Media#" & Trim(Str(NodeCountID))
.Name = GetNextValidNodeName("Media ")

Select Case .SubType
Case "Media"
.Image = New BitmapImage(New Uri("/local;component/Content/Images/Office/multimedia.png", UriKind.RelativeOrAbsolute))
End Select
End Select


End With

If Not (TypeOf NewNode Is MultimediaControl OrElse TypeOf NewNode Is ControlNode OrElse TypeOf NewNode Is ControlNodeEx) Then
NewNode.LayerIndex = 0
Else
NewNode.LayerIndex = 1
End If

BGNode.Children.Add(NewNode)
diagram.Nodes.Add(NewNode)


Node:- CopyNodeList is the list which hold all copied node.
after paste node shape node come above of media chenel and clock. i have analyst i.e LayerIndex of Shape node is 0. what i can do? Please suggest me something ......

Thanks in advanced. Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zindex problem in new version.
Reply #5 - Apr 24th, 2013 at 12:57pm
Print Post  
Hi,

Check if it works better if you assign to LayerIndex after adding the new node to the diagram. The LayerIndex setter might be updating the visual Z order only if the item knows it's parent diagram at that time.

Stoyan
  
Back to top
 
IP Logged
 
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Re: Zindex problem in new version.
Reply #6 - Apr 25th, 2013 at 12:03pm
Print Post  
Hi syoyo,

Thanks for reply. I have done same task but it didn't worked. Please suggest me another solution.

Thanks in advanced.  Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zindex problem in new version.
Reply #7 - Apr 25th, 2013 at 2:21pm
Print Post  
I can't see any problems with setting LayerIndex either before or after adding the nodes. Check if you are not resetting it to a different value later.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint