Creates a simple graph control with some random nodes and connected edges. An event handler allows users to drag nodes around, keeping the edges connected.
상속: UMD.HCIL.Piccolo.PCanvas
예제 #1
0
		public GraphEditorTester() {
			InitializeComponent();

			GraphEditor graphEditor = new GraphEditor(this.ClientSize.Width, this.ClientSize.Height);
			Controls.Add(graphEditor);
			graphEditor.Bounds = this.ClientRectangle;
			graphEditor.Anchor = graphEditor.Anchor | AnchorStyles.Right | AnchorStyles.Bottom;
		}
예제 #2
0
 public SAction(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
     GetVarLinks();
     GetOutputLinks();
     originalX = x;
     originalY = y;
 }
예제 #3
0
 public SObj(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base()
 {
     pcc = p;
     g = grapheditor;
     index = idx;
     comment = new SText(GetComment(index), commentColor, false);
     comment.X = 0;
     comment.Y = 0 - comment.Height;
     comment.Pickable = false;
     this.AddChild(comment);
     this.Pickable = true;
 }
예제 #4
0
 protected SObj(int idx, IMEPackage p, GraphEditor grapheditor)
 {
     pcc = p;
     g = grapheditor;
     index = idx;
     export = pcc.getExport(index);
     comment = new SText(GetComment(), commentColor, false);
     comment.X = 0;
     comment.Y = 0 - comment.Height;
     comment.Pickable = false;
     this.AddChild(comment);
     this.Pickable = true;
 }
예제 #5
0
 public SBox(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
 }
예제 #6
0
 public SVar(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
     string s = pcc.Exports[index].ObjectName;
     s = s.Replace("BioSeqVar_", "");
     s = s.Replace("SFXSeqVar_", "");
     s = s.Replace("SeqVar_", "");
     type = getType(s);
     float w = 60;
     float h = 60;
     shape = PPath.CreateEllipse(0, 0, w, h);
     outlinePen = new Pen(getColor(type));
     shape.Pen = outlinePen;
     shape.Brush = nodeBrush;
     shape.Pickable = false;
     this.AddChild(shape);
     this.Bounds = new RectangleF(0, 0, w, h);
     val = new SText(GetValue());
     val.Pickable = false;
     val.TextAlignment = StringAlignment.Center;
     val.X = w / 2 - val.Width / 2;
     val.Y = h / 2 - val.Height / 2;
     this.AddChild(val);
     List<SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, pcc.Exports[index].Data);
     foreach (SaltPropertyReader.Property prop in props)
     {
         if (prop.Name == "VarName" || prop.Name == "varName")
         {
             SText VarName = new SText(prop.Value.StringValue, Color.Red, false);
             VarName.Pickable = false;
             VarName.TextAlignment = StringAlignment.Center;
             VarName.X = w / 2 - VarName.Width / 2;
             VarName.Y = h;
             this.AddChild(VarName);
             break;
         }
     }
     this.TranslateBy(x, y);
     this.MouseEnter += new PInputEventHandler(OnMouseEnter);
     this.MouseLeave += new PInputEventHandler(OnMouseLeave);
 }
예제 #7
0
 public SEvent(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
     outlinePen = new Pen(Color.FromArgb(214, 30, 28));
     string s = pcc.Exports[index].ObjectName;
     s = s.Replace("BioSeqEvt_", "");
     s = s.Replace("SFXSeqEvt_", "");
     s = s.Replace("SeqEvt_", "");
     s = s.Replace("SeqEvent_", "");
     float starty = 0;
     float w = 15;
     float midW = 0;
     varLinkBox = new PPath();
     GetVarLinks();
     for (int i = 0; i < Varlinks.Count; i++)
     {
         string d = "";
         foreach (int l in Varlinks[i].Links)
             d = d + "#" + l + ",";
         d = d.Remove(d.Length - 1);
         SText t2 = new SText( d + "\n" + Varlinks[i].Desc);
         t2.X = w;
         t2.Y = 0;
         w += t2.Width + 20;
         t2.Pickable = false;
         Varlinks[i].node.TranslateBy(t2.X + t2.Width / 2, t2.Y + t2.Height);
         t2.AddChild(Varlinks[i].node);
         varLinkBox.AddChild(t2);
     }
     if(Varlinks.Count != 0)
         varLinkBox.AddRectangle(0, 0, w, varLinkBox[0].Height);
     varLinkBox.Pickable = false;
     varLinkBox.Pen = outlinePen;
     varLinkBox.Brush = nodeBrush;
     GetOutputLinks();
     outLinkBox = new PPath();
     for (int i = 0; i < Outlinks.Count(); i++)
     {
         SText t2 = new SText(Outlinks[i].Desc);
         if(t2.Width + 10 > midW) midW = t2.Width + 10;
         //t2.TextAlignment = StringAlignment.Far;
         //t2.ConstrainWidthToTextWidth = false;
         t2.X = 0 - t2.Width;
         t2.Y = starty + 3;
         starty += t2.Height + 6;
         t2.Pickable = false;
         Outlinks[i].node.TranslateBy(0, t2.Y + t2.Height / 2);
         t2.AddChild(Outlinks[i].node);
         outLinkBox.AddChild(t2);
     }
     outLinkBox.AddPolygon(new PointF[] { new PointF(0, 0), new PointF(0, starty), new PointF(-0.5f*midW, starty+30), new PointF(0 - midW, starty), new PointF(0 - midW, 0), new PointF(midW/-2, -30) });
     outLinkBox.Pickable = false;
     outLinkBox.Pen = outlinePen;
     outLinkBox.Brush = nodeBrush;
     List<SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, pcc.Exports[index].Data);
     foreach (SaltPropertyReader.Property prop in props)
     {
         if (prop.Name.Contains("EventName") || prop.Name == "sScriptName")
             s += "\n\"" + prop.Value.IntValue + "\"";
         else if (prop.Name == "InputLabel" || prop.Name == "sEvent")
             s += "\n\"" + prop.Value.StringValue + "\"";
     }
     float tW = GetTitleBox(s, w);
     if (tW > w)
     {
         if (midW > tW)
         {
             w = midW;
             titleBox.Width = w;
         }
         else
         {
             w = tW;
         }
         varLinkBox.Width = w;
     }
     float h = titleBox.Height + 1;
     outLinkBox.TranslateBy(titleBox.Width/2 + midW/2, h + 30);
     h += outLinkBox.Height + 1;
     varLinkBox.TranslateBy(0, h);
     h += varLinkBox.Height;
     this.bounds = new RectangleF(0, 0, w, h);
     this.AddChild(titleBox);
     this.AddChild(varLinkBox);
     this.AddChild(outLinkBox);
     this.TranslateBy(x, y);
 }
예제 #8
0
 public ZoomController(GraphEditor graphEditor)
 {
     this.camera = graphEditor.Camera;
     camera.Canvas.ZoomEventHandler = null;
     camera.MouseWheel += OnMouseWheel;
     graphEditor.KeyDown += OnKeyDown;
 }
예제 #9
0
 protected SBox(int idx, IMEPackage p, GraphEditor grapheditor)
     : base(idx, p, grapheditor)
 {
     
 }
예제 #10
0
 public SFrame(int idx, float x, float y, IMEPackage p, GraphEditor grapheditor)
     : base(idx, p, grapheditor)
 {
     string s = export.ObjectName;
     float w = 0;
     float h = 0;
     var props = export.GetProperties();
     foreach (var prop in props)
     {
         if (prop.Name == "SizeX")
         {
             w = (prop as IntProperty);
         }
         if (prop.Name == "SizeY")
         {
             h = (prop as IntProperty);
         }
     }
     MakeTitleBox(s);
     shape = PPath.CreateRectangle(0, -titleBox.Height, w, h + titleBox.Height);
     outlinePen = new Pen(Color.Black);
     shape.Pen = outlinePen;
     shape.Brush = new SolidBrush(Color.Transparent);
     shape.Pickable = false;
     this.AddChild(shape);
     titleBox.TranslateBy(0, -titleBox.Height);
     this.AddChild(titleBox);
     comment.Y -= titleBox.Height;
     this.Bounds = new RectangleF(0, -titleBox.Height, titleBox.Width, titleBox.Height);
     this.TranslateBy(x, y);
 }
예제 #11
0
 public SVar(int idx, float x, float y, IMEPackage p, GraphEditor grapheditor)
     : base(idx, p, grapheditor)
 {
     string s = export.ObjectName;
     s = s.Replace("BioSeqVar_", "");
     s = s.Replace("SFXSeqVar_", "");
     s = s.Replace("SeqVar_", "");
     type = getType(s);
     float w = 60;
     float h = 60;
     shape = PPath.CreateEllipse(0, 0, w, h);
     outlinePen = new Pen(getColor(type));
     shape.Pen = outlinePen;
     shape.Brush = nodeBrush;
     shape.Pickable = false;
     this.AddChild(shape);
     this.Bounds = new RectangleF(0, 0, w, h);
     val = new SText(GetValue());
     val.Pickable = false;
     val.TextAlignment = StringAlignment.Center;
     val.X = w / 2 - val.Width / 2;
     val.Y = h / 2 - val.Height / 2;
     this.AddChild(val);
     var props = export.GetProperties();
     foreach (var prop in props)
     {
         if (prop.Name == "VarName" || prop.Name == "varName")
         {
             SText VarName = new SText((prop as NameProperty).Value, Color.Red, false);
             VarName.Pickable = false;
             VarName.TextAlignment = StringAlignment.Center;
             VarName.X = w / 2 - VarName.Width / 2;
             VarName.Y = h;
             this.AddChild(VarName);
             break;
         }
     }
     this.TranslateBy(x, y);
     this.MouseEnter += OnMouseEnter;
     this.MouseLeave += OnMouseLeave;
 }
예제 #12
0
 public SAction(int idx, float x, float y, IMEPackage p, GraphEditor grapheditor)
     : base(idx, p, grapheditor)
 {
     GetVarLinks();
     GetOutputLinks();
     originalX = x;
     originalY = y;
 }
예제 #13
0
 public SFrame(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
     string s = pcc.Exports[index].ObjectName;
     float w = 0;
     float h = 0;
     List<SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, pcc.Exports[index].Data);
     foreach (SaltPropertyReader.Property prop in props)
     {
         if (prop.Name == "SizeX")
         {
             w = prop.Value.IntValue;
         }
         if (prop.Name == "SizeY")
         {
             h = prop.Value.IntValue;
         }
     }
     MakeTitleBox(s);
     shape = PPath.CreateRectangle(0, -titleBox.Height, w, h + titleBox.Height);
     outlinePen = new Pen(Color.Black);
     shape.Pen = outlinePen;
     shape.Brush = new SolidBrush(Color.Transparent);
     shape.Pickable = false;
     this.AddChild(shape);
     titleBox.TranslateBy(0, -titleBox.Height);
     this.AddChild(titleBox);
     comment.Y -= titleBox.Height;
     this.Bounds = new RectangleF(0, -titleBox.Height, titleBox.Width, titleBox.Height);
     this.TranslateBy(x, y);
 }