protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_PaletteStyle myStyle = new GH_PaletteStyle(System.Drawing.ColorTranslator.FromHtml(Base.EnableRemoteControl ? "#147DE9" : "#B3B3B3"), System.Drawing.ColorTranslator.FromHtml("#FFFFFF"), System.Drawing.ColorTranslator.FromHtml(Base.EnableRemoteControl ? "#ffffff" : "#4C4C4C")); GH_PaletteStyle myTransparentStyle = new GH_PaletteStyle(System.Drawing.Color.FromArgb(0, 0, 0, 0)); var streamIdCapsule = GH_Capsule.CreateTextCapsule(box: StreamIdBounds, textbox: StreamIdBounds, palette: Base.EnableRemoteControl ? GH_Palette.Black : GH_Palette.Transparent, text: Base.EnableRemoteControl ? "Remote Controller" : "ID: " + Base.mySender.StreamId, highlight: 0, radius: 5); streamIdCapsule.Render(graphics, myStyle); streamIdCapsule.Dispose(); var streamNameCapsule = GH_Capsule.CreateTextCapsule(box: StreamNameBounds, textbox: StreamNameBounds, palette: GH_Palette.Black, text: "(S) " + Base.NickName, highlight: 0, radius: 5); streamNameCapsule.Render(graphics, myStyle); streamNameCapsule.Dispose(); if (Base.ManualMode) { var pushStreamButton = GH_Capsule.CreateCapsule(PushStreamButtonRectangle, GH_Palette.Pink, 2, 0); pushStreamButton.Render(graphics, true ? Properties.Resources.play25px : Properties.Resources.pause25px, myTransparentStyle); } } }
protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { /* //okay, so let's render the background * RectangleF capsuleBox = new RectangleF(this.Bounds.Location, this.Bounds.Size); * GH_Capsule capsule = GH_Capsule.CreateCapsule(capsuleBox, GH_Palette.Normal); * // but when we have a warning, change colors appropriately * if (Owner.RuntimeMessageLevel == GH_RuntimeMessageLevel.Error || * Owner.RuntimeMessageLevel == GH_RuntimeMessageLevel.Warning) * { * capsule.Render(graphics, this.Selected, Owner.Locked, true); * } * else * { * capsule.Render(graphics, Color.FromArgb(188, 157, 202)); * } * capsule.Dispose(); */ button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, GH_Palette.Pink, "(Re)load Cluster", 2, 0); button.Render(graphics, Selected, Owner.Locked, false); button.Dispose(); } }
protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { var component = Owner as Generator; // Options var optionTitle = GH_Capsule.CreateTextCapsule(CapsuleBounds[0], CapsuleBounds[0], GH_Palette.Grey, "Options", 0, 1); graphics.DrawString((component.PrintLabel ? "☒" : "☐") + " Print label", optionTitle.Font, System.Drawing.Brushes.Black, CapsuleBounds[1].Location); graphics.DrawString((component.Collision ? "☒" : "☐") + " Collision", optionTitle.Font, System.Drawing.Brushes.Black, CapsuleBounds[2].Location); optionTitle.Render(graphics, Selected, Owner.Locked, false); optionTitle.Dispose(); // Annotation var annotationTitle = GH_Capsule.CreateTextCapsule(CapsuleBounds[3], CapsuleBounds[3], GH_Palette.Grey, "Annotation", 0, 1); graphics.DrawString((component.AnnotateRods ? "☒" : "☐") + " Rods", annotationTitle.Font, System.Drawing.Brushes.Black, CapsuleBounds[4].Location); graphics.DrawString((component.AnnotateJoints ? "☒" : "☐") + " Joints", annotationTitle.Font, System.Drawing.Brushes.Black, CapsuleBounds[5].Location); graphics.DrawString((component.AnnotateJointArms ? "☒" : "☐") + " Joint arms", annotationTitle.Font, System.Drawing.Brushes.Black, CapsuleBounds[6].Location); annotationTitle.Render(graphics, Selected, Owner.Locked, false); annotationTitle.Dispose(); } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_Capsule button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, xColor, "X", 3, 0); button.Render(graphics, Selected, false, false); button.Dispose(); } if (channel == GH_CanvasChannel.Objects) { GH_Capsule button2 = GH_Capsule.CreateTextCapsule(ButtonBounds2, ButtonBounds2, yColor, "Y", 2, 0); button2.Render(graphics, Selected, Owner.Locked, false); button2.Dispose(); } if (channel == GH_CanvasChannel.Objects) { GH_Capsule button3 = GH_Capsule.CreateTextCapsule(ButtonBounds3, ButtonBounds3, zColor, "Z", 2, 0); button3.Render(graphics, Selected, Owner.Locked, false); button3.Dispose(); } if (channel == GH_CanvasChannel.Objects) { GH_Capsule button4 = GH_Capsule.CreateTextCapsule(ButtonBounds4, ButtonBounds4, rxColor, "Fix Rotation", 2, 0); button4.Render(graphics, Selected, Owner.Locked, false); button4.Dispose(); } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { if (channel == GH_CanvasChannel.Objects) { GH_CapsuleRenderEngine.RenderOutputGrip(graphics, canvas.Viewport.Zoom, OutputGrip, true); for (int col = 0; col < 3; col++) { for (int row = 0; row < 3; row++) { int value = Value(col, row); Rectangle button = Button(col, row); GH_Palette palette = GH_Palette.White; if (value == Owner.Value) { palette = GH_Palette.Blue; } GH_Capsule capsule = GH_Capsule.CreateTextCapsule(button, button, palette, value.ToString(), 0, 0); capsule.Render(graphics, Selected, Owner.Locked, true); capsule.Dispose(); } } } }
public override void Layout() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) float num = base.CanvasPivot.Y + TopMargin + TopInnerMargin + (float)PanelRadius; float y = base.CanvasPivot.Y; int num2 = 0; foreach (GH_Attr_Widget control in _controls) { if (num2++ > 0) { num += (float)Space; } PointF transform = new PointF(base.CanvasPivot.X + LeftMargin + LeftInnerMargin + (float)PanelRadius, num); control.UpdateBounds(transform, EffectiveWidth); control.Style = base.Style; control.Palette = base.Palette; control.Layout(); float height = control.Height; num += height; } num += (float)PanelRadius + BottomMargin + BottomInnerMargin; base.Height = num - y; RectangleF rectangleF = GH_Attr_Widget.Shrink(base.CanvasBounds, LeftMargin, RightMargin, TopMargin, BottomMargin); _menu = GH_Capsule.CreateTextCapsule(rectangleF, rectangleF, base.Palette, "", new Font(new FontFamily("Arial"), 8f, FontStyle.Bold), 0, PanelRadius, 8); }
protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel) { // Draw base component. base.Render(canvas, graphics, channel); // Add custom elements. if (channel == GH_CanvasChannel.Objects) { // Add button to connect/disconect. GH_Capsule button = GH_Capsule.CreateTextCapsule(this.BoundsButton, this.BoundsButton, GH_Palette.Black, this.component.status ? "Disconnect" : "Connect", 2, 0); button.Render(graphics, this.Selected, this.Owner.Locked, false); button.Dispose(); // Add list of Found Devices. // IPAddress ipv4Addresse = Array.FindLast(Dns.GetHostEntry(string.Empty).AddressList, // a => a.AddressFamily == AddressFamily.InterNetwork); string message = "Devices: "; if (HoloConnect.deviceFinder.devices.Count > 0) { foreach (HoloDevice device in HoloConnect.deviceFinder.devices.Values) { message += "\n" + device.ToString(); } } else { message += "(not found)"; } graphics.DrawString(message, GH_FontServer.NewFont(FontFamily.GenericMonospace, 6, FontStyle.Regular), Brushes.Black, this.BoundsText, GH_TextRenderingConstants.CenterCenter); } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_PaletteStyle myStyle = new GH_PaletteStyle(System.Drawing.ColorTranslator.FromHtml("#B3B3B3"), System.Drawing.ColorTranslator.FromHtml("#FFFFFF"), System.Drawing.ColorTranslator.FromHtml("#4C4C4C")); GH_PaletteStyle myTransparentStyle = new GH_PaletteStyle(System.Drawing.Color.FromArgb(0, 0, 0, 0)); var streamIdCapsule = GH_Capsule.CreateTextCapsule(box: StreamIdBounds, textbox: StreamIdBounds, palette: GH_Palette.Transparent, text: "ID: " + Base.StreamId, highlight: 0, radius: 5); streamIdCapsule.Render(graphics, myStyle); streamIdCapsule.Dispose(); var streamNameCapsule = GH_Capsule.CreateTextCapsule(box: StreamNameBounds, textbox: StreamNameBounds, palette: GH_Palette.Black, text: "(R) " + Base.NickName + (Base.Paused ? " (Paused)" : ""), highlight: 0, radius: 5); streamNameCapsule.Render(graphics, myStyle); streamNameCapsule.Dispose(); //var pauseStreamingButton = GH_Capsule.CreateTextCapsule(PauseButtonBounds, PauseButtonBounds, GH_Palette.Black, ""); //pauseStreamingButton.Text = Base.Paused ? "Paused" : "Streaming"; //pauseStreamingButton.Render(graphics, myStyle); var pauseStreamingButton = GH_Capsule.CreateCapsule(PauseButtonBounds, GH_Palette.Transparent, 30, 0); pauseStreamingButton.Render(graphics, Base.Paused ? Properties.Resources.play25px : Properties.Resources.pause25px, myTransparentStyle); } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_Capsule buttonCapsule = GH_Capsule.CreateTextCapsule(buttonRectangle, buttonRectangle, GH_Palette.Grey, ButtonText); buttonCapsule.Render(graphics, Selected, attributeOwner.Locked, false); buttonCapsule.Dispose(); StringFormat format = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center, Trimming = StringTrimming.EllipsisCharacter }; if (GH_FontServer.StringWidth(TextLine.Long, this.TextFont) < Bounds.Width) { graphics.DrawString(TextLine.Long, TextFont, Brushes.Black, textRectangle, format); } else { graphics.DrawString(TextLine.Short, TextFont, Brushes.Black, textRectangle, format); } format.Dispose(); } }
public RoomInstanceAttributes(RoomInstance param) : base(param) { if (RoomArea == null) { RoomArea = GH_Capsule.CreateTextCapsule(new Rectangle(), new Rectangle(), GH_Palette.Black, param.RoomArea.ToString()); } RoomName = GH_Capsule.CreateTextCapsule(new Rectangle(), new Rectangle(), GH_Palette.Black, param.RoomName); roomBrush = Brushes.Gray; }
protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_Capsule button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, GH_Palette.Black, "Generate!", 2, 0); button.Render(graphics, Selected, Owner.Locked, false); button.Dispose(); } }
protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); SlimeComponent comp = Owner as SlimeComponent; if (channel == GH_CanvasChannel.Objects) { GH_Capsule button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, comp.Run == true ? GH_Palette.Grey : GH_Palette.Transparent, "RESET", 2, 0); button.Render(graphics, Selected, Owner.Locked, false); button.Dispose(); } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); Print comp = Owner as Print; if (channel == GH_CanvasChannel.Objects) { GH_Capsule button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, comp.toggle ? GH_Palette.Grey : GH_Palette.Black, "Print", 2, 0); button.Render(graphics, Selected, Owner.Locked, false); button.Dispose(); } }
public RoomInstanceAttributes(RoomInstance param) : base(param) { // RoomAreaRectangle = new Rectangle(new System.Drawing.Point((int)Bounds.Location.X, (int)Bounds.Location.Y + 40), new Size(60, 20)); // RoomNameRectangle = new Rectangle(new System.Drawing.Point((int)Bounds.Location.X, (int)Bounds.Location.Y + 40), new Size(60, 20)); if (RoomArea == null) { RoomArea = GH_Capsule.CreateTextCapsule(new Rectangle(), new Rectangle(), GH_Palette.Black, param.RoomArea.ToString()); } RoomName = GH_Capsule.CreateTextCapsule(new Rectangle(), new Rectangle(), GH_Palette.Black, param.RoomName); roomBrush = Brushes.Gray; }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { //Bounds = new RectangleF(Pivot.X - OuterComponentRadius, Pivot.Y - OuterComponentRadius, 2 * OuterComponentRadius, 2 * OuterComponentRadius); // Bounds = InnerComponentBounds; // base.Render(canvas, graphics, channel); if (Owner is HouseInstance houseInstance) { if (channel == GH_CanvasChannel.Objects) { graphics.FillRectangle(houseBrush, OuterComponentBounds); base.Render(canvas, graphics, channel); // Bounds = InnerComponentBounds; // GH_Capsule.CreateCapsule(Bounds, GH_Palette.Grey).Render(graphics, Color.Gray); // Bounds = new RectangleF(Pivot.X - OuterComponentRadius, Pivot.Y - 2 * OuterComponentRadius, 2 * OuterComponentRadius, OuterComponentRadius); // Layout(); // GH_ComponentAttributes.RenderComponentParameters(canvas, graphics, Owner, new GH_PaletteStyle(Color.Brown)); // Bounds = new RectangleF(Pivot.X - OuterComponentRadius, Pivot.Y - OuterComponentRadius, 2 * OuterComponentRadius, 2 * OuterComponentRadius); // foreach (IGH_DocumentObject obj in roomInstancesList) // DrawTargetArrow(graphics, obj.Attributes.Bounds); // GH_Capsule capsule = GH_Capsule.CreateCapsule(InnerComponentBounds, GH_Palette.Normal, InnerComponentRadius, 0); // capsule.Render(graphics, Selected, Owner.Locked, true); // capsule.Dispose(); // graphics.DrawString("A:", SystemFonts.IconTitleFont, Brushes.Black, new RectangleF(new System.Drawing.Point((int)Bounds.Location.X + 30, (int)Bounds.Location.Y + 77), new Size(20, 20))); HouseName = GH_Capsule.CreateTextCapsule(HouseNameRectangle, InflateRect(HouseNameRectangle, InflateAmount, InflateAmount), GH_Palette.Pink, houseInstance.HouseName); // HouseName.Render(graphics, GH_Skin.palette_grey_standard); HouseName.Dispose(); FloorName = GH_Capsule.CreateTextCapsule(FloorNameRectangle, InflateRect(FloorNameRectangle, InflateAmount, InflateAmount), GH_Palette.Pink, houseInstance.FloorName.ToString()); // FloorName.Render(graphics, GH_Skin.palette_white_standard); FloorName.Dispose(); } else { // foreach (IGH_DocumentObject obj in roomInstancesList) // DrawTargetArrow(graphics, obj.Attributes.Bounds); base.Render(canvas, graphics, channel); } } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { var prototype = GH_FontServer.StandardAdjusted; var font = GH_FontServer.NewFont(prototype, 6f / GH_GraphicsUtil.UiScale); var radius = 3; var highlight = !_mouseDown ? 8 : 0; using var button = GH_Capsule.CreateTextCapsule(_buttonBounds, _buttonBounds, GH_Palette.Black, _label, font, radius, highlight); button.Render(graphics, false, Owner.Locked, false); } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel != GH_CanvasChannel.Objects) { return; } var btnBounds = Bounds; btnBounds.Width = Bounds.Width - 50; var btn = GH_Capsule.CreateTextCapsule(btnBounds, btnBounds, GH_Palette.Blue, Owner.NickName); btn.Render(graphics, Selected, Owner.Locked, true); btn.Dispose(); }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_PaletteStyle myStyle = new GH_PaletteStyle(System.Drawing.ColorTranslator.FromHtml("#B3B3B3"), System.Drawing.ColorTranslator.FromHtml("#FFFFFF"), System.Drawing.ColorTranslator.FromHtml("#4C4C4C")); GH_PaletteStyle myTransparentStyle = new GH_PaletteStyle(System.Drawing.Color.FromArgb(0, 0, 0, 0)); var streamIdCapsule = GH_Capsule.CreateTextCapsule(box: StreamIdBounds, textbox: StreamIdBounds, palette: GH_Palette.Transparent, text: "ID: " + Base.mySender.StreamId, highlight: 0, radius: 5); streamIdCapsule.Render(graphics, myStyle); streamIdCapsule.Dispose(); var streamNameCapsule = GH_Capsule.CreateTextCapsule(box: StreamNameBounds, textbox: StreamNameBounds, palette: GH_Palette.Black, text: "(S) " + Base.NickName, highlight: 0, radius: 5); streamNameCapsule.Render(graphics, myStyle); streamNameCapsule.Dispose(); } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); ImageViewerComponent component = Owner as ImageViewerComponent; GH_Capsule dimensionButtom = GH_Capsule.CreateTextCapsule(buttonBounds, buttonBounds, GH_Palette.Transparent, component.resolution); dimensionButtom.Render(graphics, Color.LightGray); GH_Capsule dpiButton = GH_Capsule.CreateTextCapsule(dpiBounds, dpiBounds, GH_Palette.Transparent, component.dpi); dpiButton.Render(graphics, Color.LightGray); GH_Capsule ratioButton = GH_Capsule.CreateTextCapsule(ratioBounds, ratioBounds, GH_Palette.Transparent, component.ratio); ratioButton.Render(graphics, Color.LightGray); ////////////////////////////// Rectangle frameRec1 = new Rectangle((int)imgBounds.X, (int)imgBounds.Y, (int)imgBounds.Width, (int)imgBounds.Height); Rectangle frameRec2 = new Rectangle((int)imgBounds.X, (int)imgBounds.Y, (int)imgBounds.Width, (int)imgBounds.Height); Pen b = new Pen(Color.Black); graphics.DrawRectangle(b, frameRec1); Brush w = Brushes.White; graphics.FillRectangle(w, frameRec2); if (component.m_image != null) { graphics.DrawImage(component.m_image, imgBounds); } dimensionButtom.Dispose(); dpiButton.Dispose(); ratioButton.Dispose(); }
/// <summary> /// RENDERING LAYOUT /// </summary> /// <param name="canvas"></param> /// <param name="graphics"></param> /// <param name="channel"></param> protected override void Render(Grasshopper.GUI.Canvas.GH_Canvas canvas, System.Drawing.Graphics graphics, Grasshopper.GUI.Canvas.GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == Grasshopper.GUI.Canvas.GH_CanvasChannel.Objects) { button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, GH_Palette.Transparent, "", new int[] { 0, 0, 0, 5 }, 0); button.Render(graphics, Selected, Owner.Locked, false); button.Render(graphics, Color.FromArgb(255, 50, 100, 150)); button2 = GH_Capsule.CreateTextCapsule(ButtonBounds2, ButtonBounds2, GH_Palette.Transparent, "", new int[] { 0, 0, 5, 0 }, 0); button2.Render(graphics, Selected, Owner.Locked, false); button2.Render(graphics, Color.FromArgb(255, 230, 200, 10)); if (Globals.OpenThisShell[thisIndex2] == true) { System.Drawing.Drawing2D.LinearGradientBrush lgb = new System.Drawing.Drawing2D.LinearGradientBrush( rec0.Location, pythonRect.Location, System.Drawing.Color.FromArgb(255, 0, 200, 0), // Opaque red System.Drawing.Color.FromArgb(255, 0, 200, 0)); // Opaque blue); System.Drawing.Pen p = new System.Drawing.Pen(Color.Black, 1); p.DashCap = System.Drawing.Drawing2D.DashCap.Round; p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; Rectangle r5 = rec0; r5.Inflate(5, 5); // graphics.DrawLine(p, rec0.Location, pythonRect.Location); graphics.DrawPath(p, RoundedRect(r5, 3)); //graphics.DrawRectangle(p, rec0); } StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; format.Trimming = StringTrimming.EllipsisCharacter; Brush gg = new SolidBrush(Color.FromArgb(255, 50, 100, 150)); graphics.DrawString(Owner.NickName, GH_FontServer.Standard, gg, new PointF(rec0.Left, rec0.Bottom + 5)); button.Dispose(); } }
protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_Capsule button1 = GH_Capsule.CreateTextCapsule(Button1Bounds, Button1Bounds, GH_Palette.Black, "Build Model", 2, 0); button1.Render(graphics, Selected, Owner.Locked, false); button1.Dispose(); GH_Capsule button2 = GH_Capsule.CreateTextCapsule(Button2Bounds, Button2Bounds, GH_Palette.Black, "Update PDs", 2, 0); button2.Render(graphics, Selected, Owner.Locked, false); button2.Dispose(); GH_Capsule button3 = GH_Capsule.CreateTextCapsule(Button3Bounds, Button3Bounds, GH_Palette.Black, "Reset All PDs", 2, 0); button3.Render(graphics, Selected, Owner.Locked, false); button3.Dispose(); } }
protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_Capsule button; if (((SelectComponent)Owner).inputLock) { button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, GH_Palette.Black, "Locked", 2, 0); } else { button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, GH_Palette.Black, "Select", 2, 0); } button.Render(graphics, Selected, Owner.Locked, false); button.Dispose(); } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { if (channel == GH_CanvasChannel.Objects) { //Render output grip. GH_CapsuleRenderEngine.RenderOutputGrip(graphics, canvas.Viewport.Zoom, OutputGrip, true); //Render capsules. for (int col = 0; col < 3; col++) { Rectangle button = Button(col); GH_Capsule capsule = Value(col) ? GH_Capsule.CreateTextCapsule(button, button, palWhite, "1", 0, 0) : GH_Capsule.CreateTextCapsule(button, button, palBlack, "0", 0, 0); capsule.Render(graphics, Selected, Owner.Locked, false); capsule.Dispose(); } } }
//private Rectangle ButtonBounds2 { get; set; } //private Rectangle ButtonBounds3 { get; set; } protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_Capsule button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, xColor, "Run", 3, 0); button.Render(graphics, Selected, false, false); button.Dispose(); } //if (channel == GH_CanvasChannel.Objects) //{ // GH_Capsule button2 = GH_Capsule.CreateTextCapsule(ButtonBounds2, ButtonBounds2, yColor, "Run Test", 2, 0); // button2.Render(graphics, Selected, Owner.Locked, false); // button2.Dispose(); //} //if (channel == GH_CanvasChannel.Objects) //{ // GH_Capsule button3 = GH_Capsule.CreateTextCapsule(ButtonBounds3, ButtonBounds3, zColor, "AboveLimit", 2, 0); // button3.Render(graphics, Selected, Owner.Locked, false); // button3.Dispose(); //} }
/// <summary> /// Render the component each time after the canvas got invalid. /// The custom button will be rendered according the mouse position and events. /// </summary> protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel != GH_CanvasChannel.Objects) { return; } var impliedStyle = GH_CapsuleRenderEngine.GetImpliedStyle(GH_Palette.Transparent, Selected, Owner.Locked, true); var textCapsule = GH_Capsule.CreateTextCapsule(_buttonRectangleF, _buttonRectangleF, GH_Palette.Normal, _buttonName, GH_FontServer.Small, 1, 9); //Define 2 colors that are the background for the color depending if the mouse hovers over or not. textCapsule.RenderEngine.RenderBackground_Alternative(graphics, _mouseHoverInside ? Color.FromArgb(100, Color.DarkOrange) : Color.FromArgb(100, Color.DarkCyan), false); if (_mouseClickInside) { textCapsule.RenderEngine.RenderHighlight(graphics); } textCapsule.RenderEngine.RenderOutlines(graphics, canvas.Viewport.Zoom, impliedStyle); textCapsule.RenderEngine.RenderText(graphics, Color.DarkSlateGray); textCapsule.Dispose(); }
public override void Layout() { SizeF menuHeadTextSize = GetMenuHeadTextSize(); PointF canvasPivot = base.CanvasPivot; float x = canvasPivot.X; canvasPivot = base.CanvasPivot; _headBounds = new RectangleF(x, canvasPivot.Y, base.Width, menuHeadTextSize.Height); canvasPivot = base.CanvasPivot; float x2 = canvasPivot.X; canvasPivot = base.CanvasPivot; _contentBounds = new RectangleF(x2, canvasPivot.Y + menuHeadTextSize.Height, base.Width, base.Height - menuHeadTextSize.Height); Rectangle rectangle = new Rectangle((int)_headBounds.X + 1, (int)_headBounds.Y + 1, (int)_headBounds.Width - 2, (int)_headBounds.Height - 2); _menu = GH_Capsule.CreateTextCapsule(rectangle, rectangle, GH_Palette.Black, name, WidgetServer.Instance.MenuHeaderFont, 0, 2, 5); float num = menuHeadTextSize.Height; if (_expanded) { canvasPivot = base.CanvasPivot; float x3 = canvasPivot.X; canvasPivot = base.CanvasPivot; PointF transform = new PointF(x3, canvasPivot.Y + menuHeadTextSize.Height); foreach (GH_Attr_Widget control in _controls) { control.UpdateBounds(transform, base.Width); control.Transform = transform; control.Style = style; control.Palette = palette; control.Layout(); num += control.Height; } } base.Height = num; }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { if (channel == GH_CanvasChannel.Objects) { bool num = !string.IsNullOrEmpty(base.Owner.NickName); GH_Capsule gH_Capsule = (!num) ? GH_Capsule.CreateCapsule(Bounds, GH_Palette.White, 3, 0) : GH_Capsule.CreateTextCapsule(Bounds, TextBound, GH_Palette.White, base.Owner.NickName, 3, 0); GH_PaletteStyle impliedStyle = GH_CapsuleRenderEngine.GetImpliedStyle(GH_Palette.White, Selected, base.Owner.Locked, hidden: true); gH_Capsule.RenderEngine.RenderOutlines(graphics, canvas.Viewport.Zoom, impliedStyle); GH_CapsuleRenderEngine.RenderOutputGrip(graphics, canvas.Viewport.Zoom, OutputGrip, full: true); if (num) { gH_Capsule.RenderEngine.RenderText(graphics, impliedStyle.Text); } gH_Capsule.Dispose(); GH_Capsule gH_Capsule2 = GH_Capsule.CreateCapsule(m_button, GH_Palette.Black, 3, 0); gH_Capsule2.TextOrientation = GH_Orientation.horizontal_center; gH_Capsule2.Font = GH_FontServer.ConsoleAdjusted; gH_Capsule2.Text = "Get"; gH_Capsule2.Render(graphics, Color.LightGray); gH_Capsule2.Dispose(); } }
// 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); } } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); if (channel == GH_CanvasChannel.Objects) { GH_Capsule button; if (startDef == false) { button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, displayed, "Hidden", 3, 0); button.Render(graphics, Selected, Owner.Locked, false); button.Dispose(); } else { button = GH_Capsule.CreateTextCapsule(ButtonBounds, ButtonBounds, displayed, "Displayed", 3, 0); button.Render(graphics, Selected, Owner.Locked, false); button.Dispose(); } if (setColor == true) { GH_Capsule button2 = GH_Capsule.CreateTextCapsule(ButtonBounds1, ButtonBounds1, setcolor, "Colored", 2, 0); button2.Render(graphics, Selected, Owner.Locked, false); button2.Dispose(); } else { GH_Capsule button2 = GH_Capsule.CreateTextCapsule(ButtonBounds1, ButtonBounds1, setcolor, "Uncolored", 2, 0); button2.Render(graphics, Selected, Owner.Locked, false); button2.Dispose(); } if (setColor == true) { GH_Capsule button3 = GH_Capsule.CreateTextCapsule(ButtonBounds2, ButtonBounds2, xColor, "X Stresses", 2, 0); button3.Render(graphics, Selected, Owner.Locked, false); button3.Dispose(); } if (setColor == true) { GH_Capsule button4 = GH_Capsule.CreateTextCapsule(ButtonBounds3, ButtonBounds3, yColor, "Y Stresses", 2, 0); button4.Render(graphics, Selected, Owner.Locked, false); button4.Dispose(); } if (setColor == true) { GH_Capsule button5 = GH_Capsule.CreateTextCapsule(ButtonBounds4, ButtonBounds4, VonMisesColor, "Von Mises", 2, 0); button5.Render(graphics, Selected, Owner.Locked, false); button5.Dispose(); } if (setColor == true) { GH_Capsule button6 = GH_Capsule.CreateTextCapsule(ButtonBounds5, ButtonBounds5, rxColor, "RX Stresses", 2, 0); button6.Render(graphics, Selected, Owner.Locked, false); button6.Dispose(); } if (setColor == true) { GH_Capsule button7 = GH_Capsule.CreateTextCapsule(ButtonBounds6, ButtonBounds6, ryColor, "RY Stresses", 2, 0); button7.Render(graphics, Selected, Owner.Locked, false); button7.Dispose(); } } }
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) { Bounds = baseRect; base.Render(canvas, graphics, channel); //Show Top Text if (channel == GH_CanvasChannel.Overlay && Owner.ShowLabel) { float size = (float)Owner.LabelSize / Grasshopper.Instances.ActiveCanvas.Viewport.Zoom; string showMessage = (Owner.ShowFrame ? "Frame:" + Owner.RightFrame.ToString() + " " : "") + (Owner.ShowTime ? "Time:" + Owner.RightTime.ToString("f2") + "s " : "") + (Owner.ShowPercent ? Owner.PercentStr : "") + (Owner.ShowRemain ? Owner.RemainStr : ""); graphics.DrawString(showMessage, GH_FontServer.NewFont(GH_FontServer.Script, size, FontStyle.Regular), new SolidBrush(ShareData.ThemeColor), Grasshopper.Instances.ActiveCanvas.Viewport.VisibleRegion.X, Grasshopper.Instances.ActiveCanvas.Viewport.VisibleRegion.Y); } //Render Button if (channel == GH_CanvasChannel.Objects) { GH_Palette pale = Owner.Locked ? GH_Palette.Locked : GH_Palette.Normal; GH_Capsule PlayCapsule = GH_Capsule.CreateTextCapsule(PlayButtonRect, PlayButtonRect, pale, "Play"); if (Owner.Play) { PlayCapsule.Render(graphics, ShareData.ThemeColor); } else { PlayCapsule.Render(graphics, this.Selected, Owner.Locked, Owner.Hidden); } PlayCapsule.Dispose(); GH_Capsule ShootCapsule = GH_Capsule.CreateTextCapsule(ShootButtonRect, ShootButtonRect, pale, "Shoot"); if (Owner.shoot) { ShootCapsule.Render(graphics, ShareData.ThemeColor); } else { ShootCapsule.Render(graphics, this.Selected, Owner.Locked, Owner.Hidden); } ShootCapsule.Dispose(); if (Owner.ShowGraph && Owner.FrameObject != null) { if (Owner.FrameObject.OnPingDocument() == Owner.OnPingDocument()) { float PtXStart; float PtY; GoButtons = new List <RectangleF>(); ToEventButton = new List <List <RectangleF> >(); Frame.Component = Frame.Component ?? Owner; PtXStart = Owner.Attributes.Bounds.X + Owner.Attributes.Bounds.Width / 2 - Frame.Component.SliderWidth / 2 + 10 + 40; PtY = Owner.Attributes.Bounds.Y - 20; foreach (EventOperation eveOperation in Owner.ClearComponent) { if (!eveOperation.ShowGraphOnSlider) { continue; } List <RectangleF> relayDict = new List <RectangleF>(); RenderCanvas.DrawGraph(graphics, eveOperation.keyPoints, PtXStart, PtY, eveOperation.GraphHeight, eveOperation.eventThing, out relayDict, out maxRect); ToEventButton.Add(relayDict); RectangleF buttonRect = new RectangleF(PtXStart - 80, PtY - eveOperation.GraphHeight - ShareData.GraphCurveThickness, 60, eveOperation.GraphHeight + ShareData.GraphCurveThickness); GoButtons.Add(buttonRect); if (this.maxRect != new RectangleF()) { maxRect = RectangleF.Union(maxRect, buttonRect); } PtY -= ShareData.GraphDistance + eveOperation.GraphHeight; //Split String int maxlen = (int)((float)buttonRect.Width / 3.75f); string[] listArray = eveOperation.NickName.Split(' '); string showTxt = listArray[0]; string joinStr = ""; for (int n = 1; n < listArray.Length; n++) { if (listArray[n].Length > maxlen) { if (joinStr.Length > 0) { showTxt += "\n" + joinStr; } showTxt += "\n" + listArray[n]; joinStr = ""; } else if (listArray[n].Length + joinStr.Length > maxlen) { showTxt += "\n" + joinStr; joinStr = listArray[n]; } else { joinStr += " " + listArray[n]; } } if (joinStr.Length > 0) { showTxt += "\n" + joinStr; } int deep = (int)((float)buttonRect.Height / 3); GH_Capsule gH_Capsule = GH_Capsule.CreateTextCapsule(buttonRect, buttonRect, GH_Palette.Blue, showTxt, GH_FontServer.NewFont(GH_FontServer.Script, 6, FontStyle.Regular), GH_Orientation.horizontal_center, 5, deep); gH_Capsule.Render(graphics, ShareData.ThemeColor); gH_Capsule.Dispose(); } } if (this.maxRect != new RectangleF()) { thisRect = RectangleF.Union(new RectangleF(this.baseRect.X, this.baseRect.Y, this.baseRect.Width, this.baseRect.Height + 30), this.maxRect); } else { thisRect = new RectangleF(this.baseRect.X, this.baseRect.Y, this.baseRect.Width, this.baseRect.Height + 30); } } } if (channel == GH_CanvasChannel.First && Owner.FrameObject != null) { Rectangle rect = GH_Convert.ToRectangle(Owner.FrameObject.Attributes.Bounds); rect.Inflate(ShareData.FrameWidth, ShareData.FrameWidth); GH_Capsule gH_Capsule = GH_Capsule.CreateCapsule(rect, GH_Palette.Pink, ShareData.FrameWidth, 5); gH_Capsule.Render(graphics, ShareData.ThemeColor); gH_Capsule.Dispose(); } this.Bounds = this.thisRect; }