Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Container Node (Read 6140 times)
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Container Node
Jul 9th, 2009 at 12:44pm
Print Post  
Hi

I have diagram with few container nodes and each container node has some shape nodes with unique id property. when user pick one shape node from one container (for exampe uniqueid=1) to the another container node which has the same unique id 1 already, i should not allow to drop into that container and return it back to its original container node. and if that shape node with same unique id is not exist then ill allow user to drop into the second container.


How can i do this?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Container Node
Reply #1 - Jul 9th, 2009 at 2:47pm
Print Post  
Handle NodeModifying, and if GetNodeAt(mousePosition) returns a container with the same id, set e.Cancel = true.

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


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Container Node
Reply #2 - Jul 9th, 2009 at 3:39pm
Print Post  
Yes perfectly it works fine and now i have another Question related to container node. i use the custom class which you gave me before for rounded corder container node. in which am trying to add an image as background for that container , please gothru the coding that am using image object and Texturebrush to implement this features, but what am getting is the image is tiled one after another in the container instead of stretching to the size of the container node.


Public Overloads Overrides Sub Draw(ByVal graphics As MindFusion.Drawing.IGraphics, ByVal options As RenderOptions)
If Not ShouldRender() Then
Exit Sub
End If




Dim brushBounds As Rect = GetBounds()
Dim fillBrush As Brush = IIf(options.EnableInterior, Brush.CreateGdiBrush(brushBounds, -brushBounds.X, -brushBounds.Y), New SolidBrush(Color.FromArgb(0, 255, 255, 255)))


'Dim img As Image = frmConfirm_EMP_INS_Allocation.imgContainers.Images(imageIndex)
'Dim fBrush As New System.Drawing.TextureBrush(img)
'Dim fillBrush As Brush = IIf(options.EnableBackgroundImage, fBrush, Brush.CreateGdiBrush(brushBounds, -brushBounds.X, -brushBounds.Y))



Dim borderPen As Pen = Pen.CreateGdiPen()

' draw the container frame
Dim rect As Rect = GetBounds()

Dim roundRect As GraphicsPath = InternalUtils.GetRoundRect(rect.X, rect.Y, rect.Width, rect.Height, 3)
graphics.FillPath(fillBrush, roundRect)
graphics.DrawPath(borderPen, roundRect)
roundRect.Dispose()

If CaptionHeight > 0 Then
' draw the caption
If options.Scale > 1 AndAlso Caption.Length > 0 AndAlso options.EnableText Then
' create a hyperlink
Dim setLink As Boolean = Not String.IsNullOrEmpty(HyperLink) AndAlso options.HyperLinkStyle <> HyperLinkStyle.None
If setLink Then
graphics.BeginHyperLink(HyperLink, options.HyperLinkTarget)
End If

' draw the caption text
Dim captionBrush As Brush = New SolidBrush(CaptionColor)
graphics.DrawString(Caption, Font, captionBrush, GetCaptionRect(), CaptionFormat)
captionBrush.Dispose()

' close the hyperlink tag
If setLink Then
graphics.EndHyperLink()
End If
End If

' Draw the caption divider line
If rect.Top + CaptionHeight < rect.Bottom Then
graphics.DrawLine(borderPen, New Point(rect.Left, rect.Top + CaptionHeight), New Point(rect.Right, rect.Top + CaptionHeight))
End If
End If

' Draw the fold button
DrawManipulators(graphics, False)

' Cleanup
borderPen.Dispose()
fillBrush.Dispose()
End Sub
  
Back to top
 
IP Logged
 
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Container Node
Reply #3 - Jul 9th, 2009 at 3:46pm
Print Post  
I commented those texture brush image lines in the pervious post and also the images are not very clear seen it looks like dark blue area in the image.

here am pasting the 3lines of code without comment.


Dim img As Image = frmConfirm_EMP_INS_Allocation.imgContainers.Images(imageIndex)
Dim fBrush As New System.Drawing.TextureBrush(img)
Dim fillBrush As Brush = IIf(options.EnableBackgroundImage, fBrush, Brush.CreateGdiBrush(brushBounds, -brushBounds.X, -brushBounds.Y))






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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Container Node
Reply #4 - Jul 10th, 2009 at 6:46am
Print Post  
Hi,

Is there any reason for not drawing the image directly to the target graphics? As in replacing the FillPath line in your code with the following:

Code
Select All
graphics.DrawImage(img, rect) 


You also might want to set a clip before drawing the image to avoid drawing outside of the rounded corners.

Regards,
Meppy
  
Back to top
 
IP Logged
 
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Container Node
Reply #5 - Jul 10th, 2009 at 12:10pm
Print Post  
Thank you.

Actually what i need to do is i have container controls in my diagram view some of the the container ill be having image attached as a bacground, now as you said i draw the image to graphics directly but the broblem is if the user resize the container the image is not resizing to the container size it remains the same size.
Secondly some containers i dont need to attache images where as i use rounded corner with some gradient coloring within the container. for these two type of Containers now am using two different user classes that inherits the container class.

Could you pls help to resolve the class using image that is not resizing to its container size.

Thanks
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Container Node
Reply #6 - Jul 10th, 2009 at 12:54pm
Print Post  
Are you using the Graphics.DrawImage method to render the background of the container? I am using this method and the results are as expected - the image always stretches to fill the bounds of its container.

Regards,
Meppy
  
Back to top
 
IP Logged
 
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Container Node
Reply #7 - Jul 10th, 2009 at 1:21pm
Print Post  
Yes i am using Graphics.DrawImage method here is the entire class

Imports System.Drawing
Imports MindFusion
Imports MindFusion.Diagramming

Imports Point = System.Drawing.PointF
Imports Rect = System.Drawing.RectangleF
Imports System.Drawing.Drawing2D

Public Class TrashAdapter
Inherits ContainerNode

Public imageIndex As Integer = -1

Public Overloads Overrides Sub Draw(ByVal graphics As MindFusion.Drawing.IGraphics, ByVal options As RenderOptions)
If Not ShouldRender() Then
Exit Sub
End If

Dim brushBounds As Rect = GetBounds()
Dim img As Image = frmFinalResourceAllocation.imgContainers.Images(imageIndex)

Dim borderPen As Pen = Pen.CreateGdiPen()

' draw the container frame
Dim rect As Rect = GetBounds()
Dim roundRect As GraphicsPath = InternalUtils.GetRoundRect(rect.X, rect.Y, rect.Width, rect.Height, 3)
graphics.DrawImage(img, New PointF(rect.X - 5, rect.Y - 10))
graphics.DrawPath(borderPen, roundRect)
roundRect.Dispose()

If CaptionHeight > 0 Then
' draw the caption
If options.Scale > 1 AndAlso Caption.Length > 0 AndAlso options.EnableText Then
' create a hyperlink
Dim setLink As Boolean = Not String.IsNullOrEmpty(HyperLink) AndAlso options.HyperLinkStyle <> HyperLinkStyle.None
If setLink Then
graphics.BeginHyperLink(HyperLink, options.HyperLinkTarget)
End If

' draw the caption text
Dim captionBrush As Brush = New SolidBrush(CaptionColor)
graphics.DrawString(Caption, Font, captionBrush, GetCaptionRect(), CaptionFormat)
captionBrush.Dispose()

' close the hyperlink tag
If setLink Then
graphics.EndHyperLink()
End If
End If

' Draw the caption divider line
If rect.Top + CaptionHeight < rect.Bottom Then
graphics.DrawLine(borderPen, New Point(rect.Left, rect.Top + CaptionHeight), New Point(rect.Right, rect.Top + CaptionHeight))
End If
End If

' Draw the fold button
DrawManipulators(graphics, False)

' Cleanup
borderPen.Dispose()
End Sub

Public Overloads Overrides Sub DrawShadow(ByVal graphics As MindFusion.Drawing.IGraphics, ByVal options As RenderOptions)
If Not ShouldRender() Then
Exit Sub
End If

Dim fillBrush As Brush = New SolidBrush(ShadowColor)

' draw the container frame
Dim rect As Rect = GetBounds()

Dim roundRect As GraphicsPath = InternalUtils.GetRoundRect(rect.X, rect.Y, rect.Width, rect.Height, 3)
graphics.FillPath(fillBrush, roundRect)

roundRect.Dispose()
fillBrush.Dispose()
End Sub

''' <summary>
''' Calculates the caption rectangle, excluding the fold
''' button if the container is foldable.
''' </summary>
'''
Private Function GetCaptionRect() As Rect
Dim rect As Rect = Utilities.NormalizeRect(Bounds)
rect.Height = CaptionHeight
If Foldable Then
rect.Width -= CaptionHeight
End If

Return rect
End Function

End Class
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Container Node
Reply #8 - Jul 10th, 2009 at 1:56pm
Print Post  
Hi,

Replace the line:

Code
Select All
graphics.DrawImage(img, New PointF(rect.X - 5, rect.Y - 10)) 


with the line:

Code
Select All
graphics.DrawImage(img, rect.X, rect.Y, rect.Width, rect.Height) 


The first line draws the image in its original size disregarding the size of the container.

Regards,
Meppy
  
Back to top
 
IP Logged
 
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Container Node
Reply #9 - Jul 10th, 2009 at 2:56pm
Print Post  
Thanks it perfectly working and i have another problem that the image i am using is not able to see as its original color, what i can see is a darkblue(navy) color filled in the image.
what should i do to see the actual image color.
Thanks
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Container Node
Reply #10 - Jul 10th, 2009 at 3:10pm
Print Post  
Can you e-mail the image to me (meppy@mindfusion.eu) so that I can test what might be wrong with it?

Regards,
Meppy
  
Back to top
 
IP Logged
 
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Container Node
Reply #11 - Jul 10th, 2009 at 3:39pm
Print Post  
yes i sent now
  
Back to top
 
IP Logged
 
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Container Node
Reply #12 - Jul 10th, 2009 at 5:59pm
Print Post  
Hi meppy

is there a way to arrange the shapenodes of the container to fit (attached nodes is not fitting inside by default) within the container node.
For example i have shape node of user and his name as attached node at the bottom, here the name(text) the bottom of the user node is (visible to) outside of the container node.

How can i fix this?


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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Container Node
Reply #13 - Jul 13th, 2009 at 11:22am
Print Post  
Try setting the FollowMasterContainment property on all subordinate items to true.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Container Node
Reply #14 - Jul 14th, 2009 at 7:39am
Print Post  
Hi,

After attaching the items to their master node, set masterNode.SubordinateGroup.FollowMasterContainment = true.

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