public void SetAnchorPoint(int anchor, PointF p) { if (anchor < 0 || anchor >= m_Anchors.Count * 3 - 2) { return; } anchor++; Anchor a = m_Anchors[anchor / 3]; Double angle = 0, length = 0; switch (anchor % 3) { case 0: // input GraphicUtils.CartesianToPolar(new PointF(p.X - a.Origin.X, p.Y - a.Origin.Y), ref angle, ref length); a.InputLength = length; a.Angle = angle - Math.PI; break; case 1: // origin a.Origin = new Point((int)p.X, (int)p.Y); break; case 2: // output GraphicUtils.CartesianToPolar(new PointF(p.X - a.Origin.X, p.Y - a.Origin.Y), ref angle, ref length); a.OutputLength = length; a.Angle = angle; break; } m_Anchors[anchor / 3] = a; }
private void GetBodySize(ref float W, ref float H, ref int RH, ref int ins, ref int outs) { Graphics gr = GraphicUtils.gr(); Process c = m_node.ParentProcess.ParentProject.FindProcess(m_node.Subprocess); Font f = new Font("Arial", 10); if (c == null) { W = 30; H = 30; return; } ins = outs = 0; float inMaxW = 10, outMaxW = 10; foreach (Variable v in c.VarsList) { if (v.IsInput) { ins++; float w = gr.MeasureString(v.Name, f).Width; if (w > inMaxW) { inMaxW = w; } } if (v.IsOutput) { outs++; float w = gr.MeasureString(v.Name, f).Width; if (w > outMaxW) { outMaxW = w; } } } RH = (int)Math.Round(gr.MeasureString("qyZ", f).Height); int rows = Math.Max(ins, outs) + 1; H = 10 + rows * (RH + 10); float namew = gr.MeasureString(c.Name, f).Width; W = Math.Max(inMaxW + outMaxW + 10, namew + 30); }
public override Rectangle BoundingBox() { Graphics gr = GraphicUtils.gr(); int W = 30; int H = 30; Rectangle r = new Rectangle(X - W / 2, Y - H / 2, W, H); Font f = new Font("Arial", 10); SizeF m = gr.MeasureString(Name, f); r = Rectangle.Union(r, new Rectangle((int)(X - m.Width / 2), (int)(Y - H / 2 - m.Height - 2), (int)m.Width, (int)m.Height)); return(r); }
public override Rectangle BoundingBox() { Graphics gr = GraphicUtils.gr(); Font f = new Font("Arial", 10); float W = 0, H = 0; int row_height = 0, ins = 0, outs = 0; GetBodySize(ref W, ref H, ref row_height, ref ins, ref outs); Rectangle r = new Rectangle((int)(X - W / 2), (int)(Y - H / 2), (int)W, (int)H); float nameWidth = gr.MeasureString(Name, f).Width; r = Rectangle.Union(r, new Rectangle((int)(X - nameWidth / 2), (int)(Y + H / 2 + 2), (int)nameWidth, (int)row_height)); return(r); }
public override void AfterChange() { PortsRefresh(GraphicUtils.gr()); }