Hi Support!
I did a class to draw my object: A Decision image, with a image inside… With 4 ports to link decision object, and a centered label outside that can´t change decision object width and height.
How can I do it? I am sending my class that generate this first image… and I would like to do the second image example:
//GatewayProcessItem Class: Gateway
[Serializable]
public class GatewayItem : GoTextNode
{
//Variables
private Color mfirst_color = Color.White;
private Color msecond_color = Color.White;
private ProcessItemImage mProcessItemImage;
//Constructor with parameter to create Gateway Item
public GatewayItem(ItemKind prcItemKind)
{
mfirst_color = Color.FromArgb(159, 232, 0);
msecond_color = Color.White;
ConfigureGatewayItem();
}
//This property is for convenience in accessing the Process Item Image class
public ProcessItemImage ProcessImage
{
get { return mProcessItemImage; }
}
//Adjust port positions for certain background shapes
public override void LayoutChildren(GoObject childchanged)
{
base.LayoutChildren(childchanged);
//Get Process Image
ProcessItemImage dec = this.ProcessImage;
//Check if image exists and Rectangle as background
if (dec != null && this.Background != null)
{
//Set image position
PointF pt = new PointF(this.Background.Center.X, this.Background.Center.Y);
if (dec.Image != null)
{
dec.Image.SetSpotLocation(Middle, pt);
}
}
}
//When the mouse passes over a node, display all of its ports.All ports on all nodes are hidden when the mouse hovers over the background.
public override bool OnMouseOver(GoInputEventArgs evt, GoView view)
{
ProcessView v = view as ProcessView;
if (v != null)
{
foreach (GoPort p in this.Ports)
{
p.Style = GoPortStyle.Ellipse;
}
}
return false;
}
protected override GoPort CreatePort(int spot)
{
GoPort p = base.CreatePort(spot);
p.Brush = null;
return p;
}
private void UpdatePorts(String t, String r, String b, String l)
{
//TopPort, RightPort, BottomPort, LeftPort
if (t == "")
{
this.TopPort = null;
}
else
{
if (this.TopPort == null) this.TopPort = CreatePort(MiddleTop);
if (this.TopPort != null)
{
this.TopPort.IsValidFrom = t.IndexOf('o') > -1;
this.TopPort.IsValidTo = t.IndexOf('i') > -1;
}
}
if (r == "")
{
this.RightPort = null;
}
else
{
if (this.RightPort == null) this.RightPort = CreatePort(MiddleRight);
if (this.RightPort != null)
{
this.RightPort.IsValidFrom = r.IndexOf('o') > -1;
this.RightPort.IsValidTo = r.IndexOf('i') > -1;
}
}
if (b == "")
{
this.BottomPort = null;
}
else
{
if (this.BottomPort == null) this.BottomPort = CreatePort(MiddleBottom);
if (this.BottomPort != null)
{
this.BottomPort.IsValidFrom = b.IndexOf('o') > -1;
this.BottomPort.IsValidTo = b.IndexOf('i') > -1;
}
}
if (l == "")
{
this.LeftPort = null;
}
else
{
if (this.LeftPort == null) this.LeftPort = CreatePort(MiddleLeft);
if (this.LeftPort != null)
{
this.LeftPort.IsValidFrom = l.IndexOf('o') > -1;
this.LeftPort.IsValidTo = l.IndexOf('i') > -1;
}
}
}
//if the Label is not visible or if the view has a small DocScale,it's handy to be able to see the name of the lane
public override String GetToolTip(GoView view)
{
return this.Text;
}
//Configure each Gateway process item
private void ConfigureGatewayItem()
{
//Insert Image
ProcessItemImage m_PocessItemImage = new ProcessItemImage();
mProcessItemImage = m_PocessItemImage;
InsertBefore(this.Background, m_PocessItemImage);
this.Background = new GoDrawing(GoFigure.Decision);
this.Shape.FillShapeHighlight(first, second);
this.TopLeftMargin = new SizeF(35, 20);
this.BottomRightMargin = new SizeF(35, 20);
this.Editable = true;
this.Shadowed = false;
this.Label.Wrapping = true;
this.Label.Editable = true;
this.Label.Alignment = BottomCenter;
UpdatePorts("io", "io", "io", "io");
}
}
//This simple group just create image in ProcessItem
[Serializable]
public class ProcessItemImage: GoGroup
{
public ProcessItemImage(ItemKind ProcessItemKind)
{
this.Selectable = false;
GoImage image = new GoImage();
image.Selectable = false;
string imageName = "";
//Load Stream from Assembly
System.Reflection.Assembly ExecAssembly = System.Reflection.Assembly.GetExecutingAssembly();
imageName = "Images.XX.png";
//Add image
if (imageName != "")
{
//Set image
Stream stImage = ExecAssembly.GetManifestResourceStream(imageName);
image.Image = System.Drawing.Image.FromStream(stImage);
stImage.Close();
Add(image);
}
}
//Return image
public GoImage Image
{
get
{
if (this.Count > 0)
{
return (GoImage)this[0];
}
else
{
return null;
}
}
set { ((GoImage)this[0]).Image = value.Image; }
}
}