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); int aiw = 0, aih = 0; if (el.m_AdditionalInformation != null) { aiw = (int)Math.Floor(el.m_AdditionalInformation.Width * re.Zoom); aih = (int)Math.Floor(el.m_AdditionalInformation.Height * 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)); var image = el.Image; if (image != null && ex + 1 * re.Zoom + eiw > 0 && ey + 21 * re.Zoom + eih > 0) { re.Graphics.DrawImage(image, ex + 1 * re.Zoom, ey + 21 * re.Zoom, eiw, eih); } var additional = el.m_AdditionalInformation; if (additional != null && ex + 1 * re.Zoom + aiw > 0 && ey + 21 * re.Zoom + eih + aih > 0) { re.Graphics.DrawImage(additional, ex + 1 * re.Zoom, ey + 21 * re.Zoom + eih, aiw, aih); } 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. var 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 || this.m_SelectedElements.Contains(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 ); } if (this.m_Multiselecting) { var r = new Rectangle( this.m_MultiselectStartX, this.m_MultiselectStartY, this.m_MultiselectEndX - this.m_MultiselectStartX, this.m_MultiselectEndY - this.m_MultiselectStartY); r.Fix(); e.Graphics.DrawRectangle( new Pen(Color.Red, 3), r ); } }
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) { } } } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.FillRectangle(SystemBrushes.ControlDark, e.ClipRectangle); // Render each flow element. var 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 || this.m_SelectedElements.Contains(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 ); } if (this.m_Multiselecting) { var r = new Rectangle( this.m_MultiselectStartX, this.m_MultiselectStartY, this.m_MultiselectEndX - this.m_MultiselectStartX, this.m_MultiselectEndY - this.m_MultiselectStartY); r.Fix(); e.Graphics.DrawRectangle( new Pen(Color.Red, 3), r ); } }
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); int aiw = 0, aih = 0; if (el.m_AdditionalInformation != null) { aiw = (int)Math.Floor(el.m_AdditionalInformation.Width * re.Zoom); aih = (int)Math.Floor(el.m_AdditionalInformation.Height * 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)); var image = el.Image; if (image != null && ex + 1 * re.Zoom + eiw > 0 && ey + 21 * re.Zoom + eih > 0) re.Graphics.DrawImage(image, ex + 1 * re.Zoom, ey + 21 * re.Zoom, eiw, eih); var additional = el.m_AdditionalInformation; if (additional != null && ex + 1 * re.Zoom + aiw > 0 && ey + 21 * re.Zoom + eih + aih > 0) re.Graphics.DrawImage(additional, ex + 1 * re.Zoom, ey + 21 * re.Zoom + eih, aiw, aih); foreach (FlowConnector fl in el.OutputConnectors) FlowConnector.RenderTo(fl, re); foreach (FlowConnector fl in el.InputConnectors) FlowConnector.RenderTo(fl, re); }
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) { } } }