internal static void RenderTo(FlowElement el, RenderAttributes re, bool selected) { int ex = (int)(el.X * re.Zoom); int ey = (int)(el.Y * re.Zoom); int ew = (int)(el.Width * re.Zoom); int eh = (int)(el.Height * re.Zoom); int eiw = (int)Math.Floor(el.ImageWidth * re.Zoom); int eih = (int)Math.Floor(el.ImageHeight * re.Zoom); int etx = (int)((el.X + 4) * re.Zoom); int ety = (int)((el.Y + 4) * re.Zoom); re.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; re.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; re.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; re.Graphics.FillRectangle(selected ? m_TitleHighlight : SystemBrushes.Control, ex, ey, ew - 1 * re.Zoom, eh - 1 * re.Zoom); re.Graphics.DrawRectangle(Pens.Black, ex, ey, ew - 1 * re.Zoom, eh - 1 * re.Zoom); re.Graphics.DrawString(el.Name, re.Font, SystemBrushes.ControlText, new PointF(etx, ety)); Image img = el.Image; if (img != null) { re.Graphics.DrawImage(img, ex + 1 * re.Zoom, ey + 21 * re.Zoom, eiw, eih); } foreach (FlowConnector fl in el.OutputConnectors) { FlowConnector.RenderTo(fl, re); } foreach (FlowConnector fl in el.InputConnectors) { FlowConnector.RenderTo(fl, re); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.FillRectangle(SystemBrushes.ControlDark, e.ClipRectangle); // Render each flow element. RenderAttributes re = new RenderAttributes { Graphics = e.Graphics, Zoom = this.Zoom, Font = new Font(SystemFonts.DefaultFont.FontFamily, SystemFonts.DefaultFont.Size * this.Zoom) }; foreach (FlowElement el in this.m_Elements) { FlowElement.RenderTo(el, re, this.m_SelectedElement == el); } // Render the active connection line. if (this.m_ActiveConnection != null) { e.Graphics.DrawLine(new Pen(Color.Red, 3), this.m_ActiveConnection.Center, this.m_MouseActiveConnectionLocation ); } }
internal static void RenderTo(FlowConnector el, RenderAttributes re) { re.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; re.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; // If we are input, we draw on the left hand side of the flow element. int idx = FlowElement.GetConnectorIndex(el.Owner, el); int sx = (int)Math.Ceiling(re.Graphics.MeasureString(el.Name, re.Font).Width); float xx = (el.IsInput ? el.Owner.X - CONNECTOR_PADDING : el.Owner.X + el.Owner.Width + CONNECTOR_PADDING) * re.Zoom; float yy = (el.Owner.Y + idx * (CONNECTOR_SIZE + CONNECTOR_PADDING)) * re.Zoom; if (el.IsInput) { re.Graphics.DrawString(el.Name, re.Font, SystemBrushes.ControlText, new PointF(xx - sx + CONNECTOR_PADDING * re.Zoom, yy)); } else { re.Graphics.DrawString(el.Name, re.Font, SystemBrushes.ControlText, new PointF(xx, yy)); } el.InvalidationWidth = sx; el.m_CenterZoomAdjustment = re.Zoom; sx += CONNECTOR_PADDING; re.Graphics.DrawRectangle(Pens.Black, xx + (el.IsInput ? -sx : sx), yy, CONNECTOR_SIZE * re.Zoom, CONNECTOR_SIZE * re.Zoom); if (el.IsInput && el.ConnectedTo != null) { foreach (FlowConnector ct in el.ConnectedTo) { try { re.Graphics.DrawLine(Pens.Blue, el.Center.Apply(re.Zoom), ct.Center.Apply(re.Zoom)); } catch (OverflowException) { } } } }