protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { if (channel == GH_CanvasChannel.Objects) { GH_Capsule capsule = GH_Capsule.CreateCapsule(this.Bounds, GH_Palette.Normal); capsule.AddOutputGrip(this.OutputGrip.Y); capsule.Render(canvas.Graphics, this.Selected, this.Owner.Locked, this.Owner.Hidden); capsule.Dispose(); int zoomFadeLow = GH_Canvas.ZoomFadeLow; if (zoomFadeLow > 0) { canvas.SetSmartTextRenderingHint(); GH_PaletteStyle impliedStyle = GH_CapsuleRenderEngine.GetImpliedStyle(GH_Palette.Normal, this); Color color = Color.FromArgb(zoomFadeLow, impliedStyle.Text); if (this.NameBounds.Width > 0f) { SolidBrush brush = new SolidBrush(color); graphics.DrawString(this.ownerOfThisAttribute.NickName, GH_FontServer.Standard, brush, this.NameBounds, GH_TextRenderingConstants.CenterCenter); brush.Dispose(); int x = Convert.ToInt32(this.NameBounds.Right); int num3 = Convert.ToInt32(this.NameBounds.Top); int num4 = Convert.ToInt32(this.NameBounds.Bottom); GH_GraphicsUtil.EtchFadingVertical(graphics, num3, num4, x, Convert.ToInt32((double)(0.8 * zoomFadeLow)), Convert.ToInt32((double)(0.3 * zoomFadeLow))); } this.RenderDropDown(canvas, graphics, color); } } }
protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel) { if (channel == GH_CanvasChannel.Objects) { GH_Capsule capsule = GH_Capsule.CreateCapsule(this.Bounds, GH_Palette.Normal); capsule.AddOutputGrip(this.OutputGrip.Y); capsule.Render(canvas.Graphics, this.Selected, this.Owner.Locked, this.Owner.Hidden); capsule.Dispose(); int alpha = GH_Canvas.ZoomFadeLow; if (alpha > 0) { canvas.SetSmartTextRenderingHint(); GH_PaletteStyle style = GH_CapsuleRenderEngine.GetImpliedStyle(GH_Palette.Normal, this); System.Drawing.Color color = System.Drawing.Color.FromArgb(alpha, style.Text); if (this.NameBounds.Width > 0f) { System.Drawing.SolidBrush nameFill = new System.Drawing.SolidBrush(color); graphics.DrawString(this.Owner.NickName, GH_FontServer.Standard, nameFill, this.NameBounds, GH_TextRenderingConstants.CenterCenter); nameFill.Dispose(); int x = System.Convert.ToInt32(this.NameBounds.Right); int y0 = System.Convert.ToInt32(this.NameBounds.Top); int y = System.Convert.ToInt32(this.NameBounds.Bottom); GH_GraphicsUtil.EtchFadingVertical(graphics, y0, y, x, System.Convert.ToInt32(0.8 * (double)alpha), System.Convert.ToInt32(0.3 * (double)alpha)); } // render dropdown only this.RenderDropDown(canvas, graphics, color); } } }
/// <summary> /// Override of the render for create the spiner over the component /// </summary> /// <param name="iCanvas"> GH_Canvas: is the control handles all mouse and paint event for a single loaded document.</param> /// <param name="graphics"> Graphics: Encapsulates a GDI+ drawing surface. This class cannot be inherited.</param> /// <param name="iChannel"> GH_CanvasChannel: Enumerates all the drawing channel that are handled inside the Grasshopper canvas.</param> protected override void Render(GH_Canvas iCanvas, Graphics graphics, GH_CanvasChannel iChannel) { if ((iChannel == GH_CanvasChannel.Objects)) { var pointer = new PointF(Bounds.Location.X, Bounds.Location.Y); //render the sing of TDM Solutions if ((iCanvas.Viewport.IsVisible(ref pointer, 5.0f))) { var pt = new PointF(0.5f * (Bounds.Left + Bounds.Right), Bounds.Top); GH_GraphicsUtil.RenderBalloonTag(iCanvas.Graphics, "TDM solutions", pt, iCanvas.Viewport.VisibleRegion); } //if it's working render the spiner if (((RhinoNest)Owner).IsWorking) { var ptSpinner = new PointF(0.5f * (Bounds.Left + Bounds.Right), Bounds.Top); graphics.DrawArc(new Pen(Color.SteelBlue, SPINNER_THICKNESS), ptSpinner.X - (SPINNER_SIZE / 2), ptSpinner.Y - (Bounds.Height / 2) - SPINNER_SIZE, SPINNER_SIZE, SPINNER_SIZE, 0, _spinnerAngle); if (_spinnerAngle > 360) { _spinnerAngle -= 360; } _spinnerAngle += 10.0f; } } base.Render(iCanvas, graphics, iChannel); }
private static void RenderShape(GH_Canvas canvas, Graphics graphics, PointF[] points, Color color) { int zoomFadeMedium = GH_Canvas.ZoomFadeMedium; float x = points[0].X; float num3 = x; float y = points[0].Y; float num5 = y; int num7 = points.Length - 1; for (int i = 1; i <= num7; i++) { x = Math.Min(x, points[i].X); num3 = Math.Max(num3, points[i].X); y = Math.Min(y, points[i].Y); num5 = Math.Max(num5, points[i].Y); } RectangleF rect = RectangleF.FromLTRB(x, y, num3, num5); rect.Inflate(1f, 1f); LinearGradientBrush brush = new LinearGradientBrush(rect, color, GH_GraphicsUtil.OffsetColour(color, 50), LinearGradientMode.Vertical) { WrapMode = WrapMode.TileFlipXY }; graphics.FillPolygon(brush, points); brush.Dispose(); if (zoomFadeMedium > 0) { Color color2 = Color.FromArgb(Convert.ToInt32((double)(0.5 * zoomFadeMedium)), Color.White); Color color3 = Color.FromArgb(0, Color.White); LinearGradientBrush brush2 = new LinearGradientBrush(rect, color2, color3, LinearGradientMode.Vertical) { WrapMode = WrapMode.TileFlipXY }; Pen pen2 = new Pen(brush2, 3f) { LineJoin = LineJoin.Round, CompoundArray = new float[] { 0f, 0.5f } }; graphics.DrawPolygon(pen2, points); brush2.Dispose(); pen2.Dispose(); } Pen pen = new Pen(color, 1f) { LineJoin = LineJoin.Round }; graphics.DrawPolygon(pen, points); }
private static void RenderShape(GH_Canvas canvas, Graphics graphics, PointF[] points, Color color) { int alpha = GH_Canvas.ZoomFadeMedium; float x0 = points[0].X; float x = x0; float y0 = points[0].Y; float y = y0; int arg_32_0 = 1; int num = points.Length - 1; for (int i = arg_32_0; i <= num; i++) { x0 = Math.Min(x0, points[i].X); x = Math.Max(x, points[i].X); y0 = Math.Min(y0, points[i].Y); y = Math.Max(y, points[i].Y); } RectangleF bounds = RectangleF.FromLTRB(x0, y0, x, y); bounds.Inflate(1f, 1f); LinearGradientBrush fill = new LinearGradientBrush(bounds, color, GH_GraphicsUtil.OffsetColour(color, 50), LinearGradientMode.Vertical); fill.WrapMode = WrapMode.TileFlipXY; graphics.FillPolygon(fill, points); fill.Dispose(); if (alpha > 0) { Color col0 = Color.FromArgb(Convert.ToInt32(0.5 * (double)alpha), Color.White); Color col = Color.FromArgb(0, Color.White); LinearGradientBrush highlightFill = new LinearGradientBrush(bounds, col0, col, LinearGradientMode.Vertical); highlightFill.WrapMode = WrapMode.TileFlipXY; Pen highlightEdge = new Pen(highlightFill, 3f); highlightEdge.LineJoin = LineJoin.Round; highlightEdge.CompoundArray = new float[] { 0f, 0.5f }; graphics.DrawPolygon(highlightEdge, points); highlightFill.Dispose(); highlightEdge.Dispose(); } graphics.DrawPolygon(new Pen(color, 1f) { LineJoin = LineJoin.Round }, points); }
/*******************************************/ private void MessageLabelColours(out Color fill, out Color text, out Color edge) { try { // Define the colour of the render to match the component's borders GH_Palette palette = GH_CapsuleRenderEngine.GetImpliedPalette(this.Owner); if (palette == GH_Palette.Normal && !this.Owner.IsPreviewCapable) { palette = GH_Palette.Hidden; } GH_PaletteStyle style = GH_CapsuleRenderEngine.GetImpliedStyle(palette, this.Selected, this.Owner.Locked, this.Owner.Hidden); edge = style.Edge; fill = style.Edge; if (!Visible) { //If message is warning message, set fill to GH wraning colour. //This is only done if the Prototype label is not already on the component, as extra warning colour is then not needed. CallerValueList owner = (this.Owner as CallerValueList); if (owner != null && owner.IsWarningMessage && !Visible) { if (this.Selected) { fill = Color.FromArgb(210, 230, 25); } else { fill = Color.FromArgb(241, 175, 29); } } } //Set text colour to contrast background colour text = GH_GraphicsUtil.ForegroundColour(fill, 200); } catch { fill = Color.Black; text = Color.White; edge = Color.Black; } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { switch (channel) { case GH_CanvasChannel.Wires: { if (Owner.SourceCount > 0) { RenderIncomingWires(canvas.Painter, Owner.Sources, Owner.WireDisplay); } break; } case GH_CanvasChannel.Objects: { var palette = GH_CapsuleRenderEngine.GetImpliedPalette(Owner); using (var capsule = GH_Capsule.CreateCapsule(Bounds, palette)) { capsule.AddInputGrip(InputGrip.Y); capsule.AddOutputGrip(OutputGrip.Y); capsule.Render(canvas.Graphics, Selected, Owner.Locked, false); } var bounds = Bounds; if (!canvas.Viewport.IsVisible(ref bounds, 10)) { return; } var alpha = GH_Canvas.ZoomFadeLow; if (alpha > 0) { canvas.SetSmartTextRenderingHint(); var style = GH_CapsuleRenderEngine.GetImpliedStyle(palette, this); var textColor = System.Drawing.Color.FromArgb(alpha, style.Text); var captionColor = string.IsNullOrEmpty(Owner.NickName) || !Owner.MutableNickName ? System.Drawing.Color.FromArgb(alpha / 2, style.Text) : textColor; using (var nameFill = new SolidBrush(captionColor)) graphics.DrawString(string.IsNullOrEmpty(Owner.NickName) ? "Filter mask…" : Owner.NickName, GH_FontServer.LargeAdjusted, nameFill, Bounds, GH_TextRenderingConstants.StringFormat(StringAlignment.Center, StringAlignment.Near)); { var clip = ListBounds; clip.Inflate(-2, 0); Brush alternateBrush = null; if (GH_Canvas.ZoomFadeMedium > 0 && Owner.DataType == GH_ParamData.remote) { graphics.FillRectangle(Brushes.White, clip); alternateBrush = Brushes.WhiteSmoke; } else { alternateBrush = new SolidBrush(System.Drawing.Color.FromArgb(70, style.Fill)); } graphics.SetClip(clip); var transform = graphics.Transform; if (!ScrollerBounds.IsEmpty) { graphics.TranslateTransform(0.0f, -((Owner.ListItems.Count * ItemHeight) - clip.Height) * ScrollRatio); } var format = new StringFormat(StringFormatFlags.NoWrap) { LineAlignment = StringAlignment.Center }; var itemBounds = new System.Drawing.Rectangle((int)clip.X, (int)clip.Y, (int)clip.Width, (int)18); int index = 0; foreach (var item in Owner.ListItems) { if (index++ % 2 != 0) { graphics.FillRectangle(alternateBrush, itemBounds); } if (item.Selected) { if (Owner.DataType == GH_ParamData.remote && GH_Canvas.ZoomFadeMedium > 0) { var highlightBounds = itemBounds; highlightBounds.Inflate(-1, -1); GH_GraphicsUtil.RenderHighlightBox(graphics, highlightBounds, 2, true, true); } var markBounds = new RectangleF(itemBounds.X, itemBounds.Y, 22, itemBounds.Height); RenderCheckMark(graphics, markBounds, textColor); } var nameBounds = new RectangleF(itemBounds.X + 22, itemBounds.Y, itemBounds.Width - 22, itemBounds.Height); graphics.DrawString(item.Name, GH_FontServer.StandardAdjusted, Brushes.Black, nameBounds, format); itemBounds.Y += itemBounds.Height; } graphics.Transform = transform; RenderScrollBar(canvas, graphics, style.Text); graphics.ResetClip(); if (GH_Canvas.ZoomFadeMedium > 0 && Owner.DataType == GH_ParamData.remote) { graphics.DrawRectangle(Pens.Black, clip); GH_GraphicsUtil.ShadowHorizontal(graphics, clip.Left, clip.Right, clip.Top); } else { GH_GraphicsUtil.EtchFadingHorizontal(graphics, (int)bounds.Left, (int)bounds.Right, (int)(bounds.Top + 20), (int)(0.8 * alpha), (int)(0.3 * alpha)); GH_GraphicsUtil.EtchFadingHorizontal(graphics, (int)bounds.Left, (int)bounds.Right, (int)(bounds.Bottom - 16), (int)(0.8 * alpha), (int)(0.3 * alpha)); } var footnoteBounds = new RectangleF(bounds.Left, bounds.Bottom - 17, bounds.Width - 3, 17); graphics.DrawString($"{Owner.ListItems.Count} items, {Owner.VolatileDataCount} selected", GH_FontServer.StandardAdjusted, Brushes.Gray, footnoteBounds, GH_TextRenderingConstants.FarCenter); } } return; } } base.Render(canvas, graphics, channel); }
protected void RenderComponentCapsule2(GH_Canvas canvas, Graphics graphics, bool drawComponentBaseBox, bool drawComponentNameBox, bool drawJaggedEdges, bool drawParameterGrips, bool drawParameterNames, bool drawZuiElements) { GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)base.Owner; RectangleF bounds = this.Bounds; this.Bounds = (bounds); if (!canvas.Viewport.IsVisible(ref bounds, 10f)) { return; } GH_Palette val = GH_CapsuleRenderEngine.GetImpliedPalette(base.Owner); if ((int)val == 0 && !base.Owner.IsPreviewCapable) { val = GH_Palette.Hidden; } GH_Capsule val2 = GH_Capsule.CreateCapsule(this.Bounds, val); bool flag = base.Owner.Params.Input .Count == 0; bool flag2 = base.Owner.Params.Output .Count == 0; val2.SetJaggedEdges(flag, flag2); GH_PaletteStyle impliedStyle = GH_CapsuleRenderEngine.GetImpliedStyle(val, this.Selected, base.Owner.Locked, base.Owner.Hidden); if (drawParameterGrips) { foreach (IGH_Param staticInput in gH_SwitcherComponent.StaticData.StaticInputs) { val2.AddInputGrip(staticInput.Attributes.InputGrip.Y); } foreach (IGH_Param dynamicInput in gH_SwitcherComponent.StaticData.DynamicInputs) { val2.AddInputGrip(dynamicInput.Attributes.InputGrip.Y); } foreach (IGH_Param staticOutput in gH_SwitcherComponent.StaticData.StaticOutputs) { val2.AddOutputGrip(staticOutput.Attributes.OutputGrip.Y); } foreach (IGH_Param dynamicOutput in gH_SwitcherComponent.StaticData.DynamicOutputs) { val2.AddOutputGrip(dynamicOutput.Attributes.OutputGrip.Y); } } graphics.SmoothingMode = SmoothingMode.HighQuality; canvas.SetSmartTextRenderingHint(); if (GH_Attributes <IGH_Component> .IsIconMode(base.Owner.IconDisplayMode)) { if (drawComponentBaseBox) { if (base.Owner.Message != null) { val2.RenderEngine.RenderMessage(graphics, base.Owner.Message, impliedStyle); } val2.Render(graphics, impliedStyle); } if (drawComponentNameBox && base.Owner.Icon_24x24 != null) { if (base.Owner.Locked) { val2.RenderEngine.RenderIcon(graphics, (Image)base.Owner.Icon_24x24_Locked, base.m_innerBounds, 0, 0); } else { val2.RenderEngine.RenderIcon(graphics, (Image)base.Owner.Icon_24x24, base.m_innerBounds, 0, 0); } } } else { if (drawComponentBaseBox) { if (base.Owner.Message != null) { val2.RenderEngine.RenderMessage(graphics, base.Owner.Message, impliedStyle); } val2.Render(graphics, impliedStyle); } if (drawComponentNameBox) { GH_Capsule obj = GH_Capsule.CreateTextCapsule(base.m_innerBounds, base.m_innerBounds, GH_Palette.Black, base.Owner.NickName, StandardFont.largeFont(), GH_Orientation.vertical_center, 3, 6); obj.Render(graphics, this.Selected, base.Owner.Locked, false); obj.Dispose(); } } if (drawComponentNameBox && base.Owner.Obsolete && Grasshopper.CentralSettings.CanvasObsoleteTags && (int)canvas.DrawingMode == 0) { GH_GraphicsUtil.RenderObjectOverlay(graphics, Owner, base.m_innerBounds); } if (drawParameterNames) { RenderComponentParameters2(canvas, graphics, base.Owner, impliedStyle); } if (drawZuiElements) { this.RenderVariableParameterUI(canvas, graphics); } val2.Dispose(); }
private static void RenderShape(GH_Canvas canvas, Graphics graphics, PointF[] points, Color color) { int zoomFadeMedium = GH_Canvas.ZoomFadeMedium; float num1 = points[0].X; float num2 = num1; float num3 = points[0].Y; float num4 = num3; int num5 = 1; int num6 = points.Length - 1; for (int index = num5; index <= num6; ++index) { num1 = Math.Min(num1, points[index].X); num2 = Math.Max(num2, points[index].X); num3 = Math.Min(num3, points[index].Y); num4 = Math.Max(num4, points[index].Y); } RectangleF rect = RectangleF.FromLTRB(num1, num3, num2, num4); rect.Inflate(1f, 1f); LinearGradientBrush linearGradientBrush1 = new LinearGradientBrush(rect, color, GH_GraphicsUtil.OffsetColour(color, 50), LinearGradientMode.Vertical); linearGradientBrush1.WrapMode = WrapMode.TileFlipXY; graphics.FillPolygon((Brush)linearGradientBrush1, points); linearGradientBrush1.Dispose(); if (zoomFadeMedium > 0) { Color color1 = Color.FromArgb(Convert.ToInt32(0.5 * (double)zoomFadeMedium), Color.White); Color color2 = Color.FromArgb(0, Color.White); LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical); linearGradientBrush2.WrapMode = WrapMode.TileFlipXY; Pen pen = new Pen((Brush)linearGradientBrush2, 3f); pen.LineJoin = LineJoin.Round; pen.CompoundArray = new float[2] { 0.0f, 0.5f }; graphics.DrawPolygon(pen, points); linearGradientBrush2.Dispose(); pen.Dispose(); } graphics.DrawPolygon(new Pen(color, 1f) { LineJoin = LineJoin.Round }, points); }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { if (channel == GH_CanvasChannel.Wires) { this.RenderIncomingWires(canvas.Painter, (IEnumerable <IGH_Param>)Owner.Sources, Owner.WireDisplay); } if (channel != GH_CanvasChannel.Objects) { return; } GH_Capsule capsule = GH_Capsule.CreateCapsule(Bounds, GH_Palette.White); GH_Capsule ghCapsule1 = capsule; PointF pointF = OutputGrip; double y1 = (double)pointF.Y; ghCapsule1.AddOutputGrip((float)y1); GH_Capsule ghCapsule2 = capsule; pointF = InputGrip; double y2 = (double)pointF.Y; ghCapsule2.AddInputGrip((float)y2); capsule.Render(canvas.Graphics, Selected, Owner.Locked, Owner.Hidden); capsule.Dispose(); int zoomFadeLow = GH_Canvas.ZoomFadeLow; if (zoomFadeLow > 0) { canvas.SetSmartTextRenderingHint(); GH_PaletteStyle impliedStyle = GH_CapsuleRenderEngine.GetImpliedStyle(GH_Palette.White, (IGH_Attributes)this); Color color = Color.FromArgb(zoomFadeLow, impliedStyle.Text); if (NameBounds.Width > 0.0) { SolidBrush solidBrush = new SolidBrush(color); graphics.DrawString(Owner.NickName, GH_FontServer.Standard, (Brush)solidBrush, NameBounds, GH_TextRenderingConstants.CenterCenter); solidBrush.Dispose(); RectangleF nameBounds = NameBounds; int int32_1 = Convert.ToInt32(nameBounds.Right); nameBounds = NameBounds; int int32_2 = Convert.ToInt32(nameBounds.Top); nameBounds = NameBounds; int int32_3 = Convert.ToInt32(nameBounds.Bottom); GH_GraphicsUtil.EtchFadingVertical(graphics, int32_2, int32_3, int32_1, Convert.ToInt32(0.8 * (double)zoomFadeLow), Convert.ToInt32(0.3 * (double)zoomFadeLow)); } switch (Owner.ListMode) { case GH_ValueListMode.CheckList: RenderCheckList(canvas, graphics, color); break; case GH_ValueListMode.DropDown: RenderDropDown(canvas, graphics, color); break; case GH_ValueListMode.Sequence: case GH_ValueListMode.Cycle: RenderSequence(canvas, graphics, color); break; } } }