/// <summary> /// Render the component /// </summary> /// <param name="canvas"></param> /// <param name="graphics"></param> /// <param name="channel"></param> protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { Grasshopper.GUI.Canvas.GH_PaletteStyle styleStandard = null; if (channel == GH_CanvasChannel.Objects) { // Cache the current styles. styleStandard = GH_Skin.palette_normal_standard; GH_Skin.palette_normal_standard = new GH_PaletteStyle(Color.FromArgb(255, 13, 138), Color.Black, Color.Black); Pen myPen = new Pen(Brushes.Black, 1); GraphicsPath path = RoundedRectangle.Create((int)(Bounds.Location.X), (int)Bounds.Y - 13, (int)Bounds.Width, 24, 3); graphics.DrawPath(myPen, path); Font myFont = new Font(Grasshopper.Kernel.GH_FontServer.Standard.FontFamily, 5, FontStyle.Italic); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; format.Trimming = StringTrimming.EllipsisCharacter; graphics.DrawString("doubleclick icon to launch (v" + Friends.VerionInfo() + ")", myFont, Brushes.Black, (int)(Bounds.Location.X + (Bounds.Width / 2)), (int)Bounds.Location.Y - 6, format); format.Dispose(); } base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { // Restore the cached styles. GH_Skin.palette_normal_standard = styleStandard; } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { Grasshopper.GUI.Canvas.GH_PaletteStyle styleGray = null; if (channel == GH_CanvasChannel.Wires) { List <Color> wireColours = new List <Color> { Color.FromArgb(150, 0, 50), Color.FromArgb(0, 150, 50), Color.FromArgb(0, 150, 50) }; for (int i = 0; i < 3; i++) { foreach (IGH_Param source in Owner.Params.Input[i].Sources) { // First we need to determine the shape of the wire. GraphicsPath path = GH_Painter.ConnectionPath(source.Attributes.OutputGrip, Owner.Params.Input[i].Attributes.InputGrip, GH_WireDirection.right, GH_WireDirection.left); if ((path == null)) { continue; } if (Owner.Attributes.Selected) { Pen pen = new Pen(wireColours[i], 3); graphics.DrawPath(pen, path); pen.Dispose(); path.Dispose(); } else { Pen pen = new Pen(Color.FromArgb(50, wireColours[i]), 1); graphics.DrawPath(pen, path); pen.Dispose(); path.Dispose(); } } } return; } if (channel == GH_CanvasChannel.Objects) { // Cache the current styles. styleGray = GH_Skin.palette_hidden_standard; GH_Skin.palette_hidden_standard = new GH_PaletteStyle(Color.FromArgb(70, 72, 84), Color.FromArgb(253, 112, 80), Color.FromArgb(253, 112, 80)); } // Allow the base class to render itself. base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { // Restore the cached styles. GH_Skin.palette_hidden_standard = styleGray; } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { Grasshopper.GUI.Canvas.GH_PaletteStyle styleStandard = null; Grasshopper.GUI.Canvas.GH_PaletteStyle styleSelected = null; Grasshopper.GUI.Canvas.GH_PaletteStyle styleStandard_Hidden = null; Grasshopper.GUI.Canvas.GH_PaletteStyle styleSelected_Hidden = null; if (channel == GH_CanvasChannel.Objects) { // Cache the current styles. styleStandard = GH_Skin.palette_normal_standard; styleSelected = GH_Skin.palette_normal_selected; styleStandard_Hidden = GH_Skin.palette_hidden_standard; styleSelected_Hidden = GH_Skin.palette_hidden_selected; if (this.type == 0) { GH_Skin.palette_normal_standard = new GH_PaletteStyle(Color.Black, Color.Black, Color.Chartreuse); GH_Skin.palette_normal_selected = new GH_PaletteStyle(Color.Chartreuse, Color.Red, Color.Black); GH_Skin.palette_hidden_standard = new GH_PaletteStyle(Color.Black, Color.Gray, Color.Chartreuse); GH_Skin.palette_hidden_selected = new GH_PaletteStyle(Color.Chartreuse, Color.Red, Color.Black); } if (this.type == 1) { GH_Skin.palette_normal_standard = new GH_PaletteStyle(Color.Black, Color.Black, Color.DarkGray); GH_Skin.palette_normal_selected = new GH_PaletteStyle(Color.DarkGray, Color.Red, Color.Black); GH_Skin.palette_hidden_standard = new GH_PaletteStyle(Color.Black, Color.Gray, Color.DarkGray); GH_Skin.palette_hidden_selected = new GH_PaletteStyle(Color.DarkGray, Color.Red, Color.Black); } if (this.type == 2) { GH_Skin.palette_normal_standard = new GH_PaletteStyle(Color.Black, Color.Black, Color.HotPink); GH_Skin.palette_normal_selected = new GH_PaletteStyle(Color.HotPink, Color.Red, Color.Black); GH_Skin.palette_hidden_standard = new GH_PaletteStyle(Color.Black, Color.Gray, Color.HotPink); GH_Skin.palette_hidden_selected = new GH_PaletteStyle(Color.HotPink, Color.Red, Color.Black); } } // Allow the base class to render itself. base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { // Restore the cached styles. GH_Skin.palette_normal_standard = styleStandard; GH_Skin.palette_normal_selected = styleSelected; GH_Skin.palette_hidden_standard = styleStandard_Hidden; GH_Skin.palette_hidden_selected = styleSelected_Hidden; } }
/// <summary> /// Render the component /// </summary> /// <param name="canvas"></param> /// <param name="graphics"></param> /// <param name="channel"></param> protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { Grasshopper.GUI.Canvas.GH_PaletteStyle styleStandard = null; if (channel == GH_CanvasChannel.Objects) { // Cache the current styles. styleStandard = GH_Skin.palette_normal_standard; GH_Skin.palette_normal_standard = new GH_PaletteStyle(Color.FromArgb(255, 13, 138), Color.Black, Color.Black); } base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { // Restore the cached styles. GH_Skin.palette_normal_standard = styleStandard; } }
// render protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { if (channel != Grasshopper.GUI.Canvas.GH_CanvasChannel.Objects) { return; } RenderIncomingWires(canvas.Painter, Owner.Sources, Owner.WireDisplay); // Define the default palette. GH_Palette palette = GH_Palette.Normal; // Create a new Capsule GH_Capsule capsule = GH_Capsule.CreateCapsule(new RectangleF(this.Pivot, new SizeF(Bounds.Width, 20)), palette); capsule.AddInputGrip(this.InputGrip.Y); capsule.AddOutputGrip(this.OutputGrip.Y); bool validInput = own.getUserInput(); string componentName; if (own.sourceName == "" || own.sourceName == null) { componentName = "Probabilities"; } else { componentName = "Probabilities (" + own.sourceName + " )"; } if (binSelected) { componentName = "Probabilities (" + own.sourceName + " <=" + own.BinRanges[selectedBin][1].ToString() + ")"; } if ((own.evidence == true) && (own.doubleClicked == true)) { Rhino.RhinoApp.WriteLine("db"); componentName = componentName + " = 100%"; } else if ((own.evidence == true) && (own.doubleClicked == false)) { Rhino.RhinoApp.WriteLine("not db"); componentName = componentName + " = custom"; } Grasshopper.GUI.Canvas.GH_PaletteStyle styleStandard = null; Grasshopper.GUI.Canvas.GH_PaletteStyle styleSelected = null; GH_Skin.LoadSkin(); if (channel == GH_CanvasChannel.Objects) { // Cache the current styles. styleStandard = GH_Skin.palette_normal_standard; styleSelected = GH_Skin.palette_normal_selected; if (!own.evidence) { GH_Skin.palette_normal_selected = GH_Skin.palette_normal_standard; } else { GH_Skin.palette_normal_standard = new GH_PaletteStyle(Color.SkyBlue, Color.DarkBlue, Color.Black); GH_Skin.palette_normal_selected = new GH_PaletteStyle(Color.SkyBlue, Color.DarkBlue, Color.Black); } } GH_Capsule message = GH_Capsule.CreateTextCapsule( new RectangleF(new PointF(this.Pivot.X, this.Pivot.Y + 20), new SizeF(Bounds.Width, 20)), new RectangleF(new PointF(this.Pivot.X, this.Pivot.Y + 20), new SizeF(Bounds.Width, 20)), GH_Palette.Normal, componentName ); message.Render(graphics, Selected, Owner.Locked, false); message.Dispose(); message = null; if (channel == GH_CanvasChannel.Objects) { // Restore the cached styles. GH_Skin.palette_normal_standard = styleStandard; GH_Skin.palette_normal_selected = styleSelected; } //Render the capsule using the current Selection, Locked and Hidden states. //Integer parameters are always hidden since they cannot be drawn in the viewport. capsule.Render(graphics, Selected, Owner.Locked, true); //Always dispose of a GH_Capsule when you're done with it. capsule.Dispose(); capsule = null; //Bounds = _extraBounds; int width = GH_FontServer.StringWidth(Owner.NickName, GH_FontServer.Standard); PointF p = new PointF(this.Pivot.X + width + 19, this.Pivot.Y - 7); List <double> probs = own.Probabilities; PointF[] pts = getHistoPts(own.Probabilities); if (own.draw_flag == "s") { pts = getPts(probs); } PointF maxPt = new PointF(0, 0); float ptY = pts[0].Y; int index_max = 0; for (int i = 0; i < pts.Length; i++) { if (pts[i].Y < ptY) { ptY = pts[i].Y; index_max = i; } } maxPt = pts[index_max]; // Create Pens System.Drawing.Pen pen2 = new System.Drawing.Pen(Brushes.Red, 2); System.Drawing.Pen pen = new System.Drawing.Pen(Brushes.Black, 2); System.Drawing.Pen pen3 = new System.Drawing.Pen(Brushes.GhostWhite, 1); // Create Gradient Brush System.Drawing.Drawing2D.LinearGradientBrush lb = new System.Drawing.Drawing2D.LinearGradientBrush (new PointF(maxPt.X, maxPt.Y), new PointF(maxPt.X, this.Pivot.Y), Color.FromArgb(255, 0, 0), Color.FromArgb(255, 255, 255)); System.Drawing.SolidBrush sb = new System.Drawing.SolidBrush(Color.FromArgb(70, 255, 255, 255)); // Rui // render background bins RectangleF[] backgroundBins = getBackgroundBins(own.Probabilities); graphics.DrawRectangles(pen3, backgroundBins); graphics.FillRectangles(sb, backgroundBins); backgroundBinBounds = backgroundBins; //Draw Polygon ouline and fill graphics.DrawPolygon(pen, pts); graphics.FillPolygon(lb, pts); // draw text capsules RectangleF[] textholderBounds = getTextholder(own.Probabilities); GH_Capsule[] textCapsules = new GH_Capsule[textholderBounds.Length]; int numbins = textCapsules.Length; if (own.BinRanges != null) { for (int i = 0; i < numbins; i++) { //textCapsules[i] = GH_Capsule.CreateTextCapsule(textholderBounds[i], textholderBounds[i], GH_Palette.Normal, "<=" + own.BinRanges[numbins - 1 - i][1], 3, 0); textCapsules[i] = GH_Capsule.CreateTextCapsule(textholderBounds[i], textholderBounds[i], GH_Palette.Normal, Math.Round(own.BinRanges[numbins - 1 - i][0], 2) + "<" + Math.Round(own.BinRanges[numbins - 1 - i][1], 2), 3, 0); textCapsules[i].Render(graphics, Selected, Owner.Locked, false); } } }