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();
            }
        }
Esempio n. 2
0
        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, 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);
            }
        }
Esempio n. 4
0
        /// <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)
        {
            if (channel == GH_CanvasChannel.Wires)
            {
                base.Render(canvas, graphics, channel);
            }

            if (channel == GH_CanvasChannel.Objects)
            {
                SolidBrush johnBrush = new SolidBrush(Color.FromArgb(255, 50, 50, 50));

                Pen myPen = new Pen(johnBrush, 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 window", myFont, johnBrush, (int)(Bounds.Location.X + (Bounds.Width / 2)), (int)Bounds.Location.Y - 6, format);

                format.Dispose();

                base.Render(canvas, graphics, channel);
            }
        }
Esempio n. 5
0
            protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
            {
                base.Render(canvas, graphics, channel);
                if (channel == GH_CanvasChannel.Objects)
                {
                    StringFormat format = new StringFormat();
                    format.Alignment     = StringAlignment.Center;
                    format.LineAlignment = StringAlignment.Center;
                    format.Trimming      = StringTrimming.EllipsisCharacter;

                    GH_Capsule radio = GH_Capsule.CreateCapsule(radio_rec, GH_Palette.White, 2, 0);
                    radio.Render(graphics, Selected, Owner.Locked, false); radio.Dispose();

                    GH_Capsule radio_1 = GH_Capsule.CreateCapsule(radio_rec_1, GH_Palette.Black, 5, 5);
                    radio_1.Render(graphics, Selected, Owner.Locked, false); radio_1.Dispose();
                    graphics.FillEllipse(c1, radio_rec_1);
                    graphics.DrawString("X", GH_FontServer.Standard, Brushes.Black, text_rec_1);

                    GH_Capsule radio_2 = GH_Capsule.CreateCapsule(radio_rec_2, GH_Palette.Black, 5, 5);
                    radio_2.Render(graphics, Selected, Owner.Locked, false); radio_2.Dispose();
                    graphics.FillEllipse(c2, radio_rec_2);
                    graphics.DrawString("Y", GH_FontServer.Standard, Brushes.Black, text_rec_2);

                    GH_Capsule radio_3 = GH_Capsule.CreateCapsule(radio_rec_3, GH_Palette.Black, 5, 5);
                    radio_3.Render(graphics, Selected, Owner.Locked, false); radio_3.Dispose();
                    graphics.FillEllipse(c3, radio_rec_3);
                    graphics.DrawString("Z", GH_FontServer.Standard, Brushes.Black, text_rec_3);
                }
            }
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            if (channel != GH_CanvasChannel.Objects)
            {
                base.Render(canvas, graphics, channel);
                return;
            }


            GH_Skin.palette_hidden_standard  = Hds.Normal;
            GH_Skin.palette_hidden_selected  = Hds.Selected;
            GH_Skin.palette_warning_standard = Hds.Warning;
            GH_Skin.palette_warning_selected = Hds.Selected;
            GH_Skin.palette_error_standard   = Hds.Error;
            GH_Skin.palette_error_selected   = Hds.Selected;

            base.Render(canvas, graphics, channel);


            GH_Skin.palette_hidden_standard  = Hds.StyleStandard;
            GH_Skin.palette_hidden_selected  = Hds.StyleStyleSelected;
            GH_Skin.palette_warning_standard = Hds.StyleWStandard;
            GH_Skin.palette_warning_selected = Hds.StyleWSelected;
            GH_Skin.palette_error_standard   = Hds.StyleEStandard;
            GH_Skin.palette_error_selected   = Hds.StyleESelected;
        }
        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)
        {
            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();
                    }
                }
            }
        }
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            switch (channel)
            {
            case GH_CanvasChannel.Wires:
                graphics.FillEllipse(Brushes.HotPink, Bounds);
                foreach (IModifiable mod in Owner.TargetObjects())
                {
                    if (mod == null)
                    {
                        continue;
                    }

                    IGH_DocumentObject obj = mod as IGH_DocumentObject;
                    if (obj == null)
                    {
                        continue;
                    }

                    DrawTargetArrow(graphics, obj.Attributes.Bounds);
                }
                break;

            case GH_CanvasChannel.Objects:
                GH_Capsule capsule = GH_Capsule.CreateCapsule(InnerBounds, GH_Palette.Normal, InnerRadius, 0);
                capsule.Render(graphics, Selected, Owner.Locked, true);
                capsule.Dispose();

                string text = string.Format("{0:0.00}", Owner.Factor);
                Grasshopper.GUI.GH_GraphicsUtil.RenderCenteredText(graphics, text, GH_FontServer.Large, Color.Black, Pivot);
                break;
            }
        }
Esempio n. 10
0
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            if (channel != GH_CanvasChannel.Objects)
            {
                base.Render(canvas, graphics, channel);
            }
            else
            {
                GH_Skin.palette_hidden_standard  = Runway_Interface.Hds.Normal;
                GH_Skin.palette_hidden_selected  = Runway_Interface.Hds.Selected;
                GH_Skin.palette_warning_standard = Runway_Interface.Hds.Warning;
                GH_Skin.palette_warning_selected = Runway_Interface.Hds.Selected;
                GH_Skin.palette_error_standard   = Runway_Interface.Hds.Error;
                GH_Skin.palette_error_selected   = Runway_Interface.Hds.Selected;
                RenderComponentCapsule(canvas, graphics, true, false, false, true, false, false);
                GH_Skin.palette_hidden_standard  = Runway_Interface.Hds.StyleStandard;
                GH_Skin.palette_hidden_selected  = Runway_Interface.Hds.StyleStyleSelected;
                GH_Skin.palette_warning_standard = Runway_Interface.Hds.StyleWStandard;
                GH_Skin.palette_warning_selected = Runway_Interface.Hds.StyleWSelected;
                GH_Skin.palette_error_standard   = Runway_Interface.Hds.StyleEStandard;
                GH_Skin.palette_error_selected   = Runway_Interface.Hds.StyleESelected;



                if (GH_Canvas.ZoomFadeLow > 0)
                {
                    graphics.DrawImage(CanvasImage, imagefarame);
                }
                if (GH_Canvas.ZoomFadeLow < 0.90)
                {
                    graphics.DrawImage(Runway.Properties.Resources.RunwayImage, imagefarame);
                }
            }
        }
Esempio n. 11
0
        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);
                }
            }
        }
Esempio n. 12
0
        /// <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);
        }
Esempio n. 13
0
 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();
     }
 }
Esempio n. 14
0
 protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
 {
     if (channel == GH_CanvasChannel.Overlay)
     {
         DrawLegend(graphics);
     }
 }
Esempio n. 15
0
 /// <summary>
 /// Render to canvas to raise up.
 /// </summary>
 /// <param name="canvas">canvas from render in component.</param>
 /// <param name="graphics">graphics from render in component.</param>
 /// <param name="channel">channel from render in component.</param>
 public void RenderToCanvas(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
 {
     if (IsRender(canvas, graphics, RenderLittleZoom))
     {
         Render(canvas, graphics, channel);
     }
 }
Esempio n. 16
0
        /// <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);
        }
        /// <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)
            {
                if (channel == GH_CanvasChannel.Objects && !Owner.Locked && Owner is TransactionalComponent component)
                {
                    if (component.Status != DB.TransactionStatus.RolledBack && component.Status != DB.TransactionStatus.Uninitialized)
                    {
                        var palette = GH_CapsuleRenderEngine.GetImpliedPalette(Owner);
                        if (palette == GH_Palette.Normal && !Owner.IsPreviewCapable)
                        {
                            palette = GH_Palette.Hidden;
                        }

                        // Errors and warnings should be refelected in Canvas
                        if (palette == GH_Palette.Normal || palette == GH_Palette.Hidden)
                        {
                            var style = GH_CapsuleRenderEngine.GetImpliedStyle(palette, Selected, Owner.Locked, Owner.Hidden);
                            var fill  = style.Fill;
                            var edge  = style.Edge;
                            var text  = style.Text;

                            switch (component.Status)
                            {
                            case DB.TransactionStatus.Uninitialized: palette = GH_Palette.Grey; break;

                            case DB.TransactionStatus.Started: palette = GH_Palette.White; break;

                            case DB.TransactionStatus.RolledBack: /*palette = GH_Palette.Normal;*/ break;

                            case DB.TransactionStatus.Committed: palette = GH_Palette.Black; break;

                            case DB.TransactionStatus.Pending: palette = GH_Palette.Blue; break;

                            case DB.TransactionStatus.Error: palette = GH_Palette.Pink; break;

                            case DB.TransactionStatus.Proceed: palette = GH_Palette.Brown; break;
                            }
                            var replacement = GH_CapsuleRenderEngine.GetImpliedStyle(palette, Selected, Owner.Locked, Owner.Hidden);

                            try
                            {
                                style.Edge = replacement.Edge;
                                style.Fill = replacement.Fill;
                                style.Text = replacement.Text;

                                base.Render(canvas, graphics, channel);
                            }
                            finally
                            {
                                style.Fill = fill;
                                style.Edge = edge;
                                style.Text = text;
                            }

                            return;
                        }
                    }
                }

                base.Render(canvas, graphics, channel);
            }
Esempio n. 19
0
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            if (channel == GH_CanvasChannel.Wires)
            {
                base.Render(canvas, graphics, channel);
            }

            if (channel == GH_CanvasChannel.Objects)
            {
                // 1. Component Render
                base.Render(canvas, graphics, channel);

                // 2. Canvas Segmentation
                //graphics.DrawLine(Pens.Black, 0, 0, 0, -100000);
                //graphics.DrawLine(Pens.Black, 0, 0, -100000, 0);
                //graphics.FillEllipse(Brushes.Black, -2, -2, 4, 4);

                Font         ubuntuFont = new Font("ubuntu", 8);
                StringFormat format     = new StringFormat();
                format.Alignment     = StringAlignment.Near;
                format.LineAlignment = StringAlignment.Center;
                format.Trimming      = StringTrimming.EllipsisCharacter;

                graphics.DrawString(MyOwner.sliderValues.Count + " designs", ubuntuFont, Brushes.Black, (int)Bounds.Location.X, (int)Bounds.Location.Y - 8, format);

                //GH_Palette palette = GH_Palette.Pink;

                //Color myColor = Color.LightGray;

                //switch (Owner.RuntimeMessageLevel)
                //{
                //    case GH_RuntimeMessageLevel.Warning:
                //        myColor = Color.Orange;
                //        break;

                //    case GH_RuntimeMessageLevel.Error:
                //        myColor = Color.Red;
                //        break;
                //}

                //if (Owner.Hidden) myColor = Color.Gray;
                //if (Owner.Locked) myColor = Color.DarkGray;

                //Rectangle myRect = new Rectangle((int)Bounds.Location.X, (int)Bounds.Location.Y-20, (int)Bounds.Size.Width, 10);
                //Pen myPen = new Pen(Brushes.Black, 1);
                //graphics.DrawRectangle(myPen, myRect);
                //GH_Capsule capsule = GH_Capsule.CreateCapsule(myRect, palette, 10, 0);

                //capsule.Render(graphics, myColor);
                //capsule.Dispose();
                //capsule = null;
                //base.RenderComponentCapsule(canvas, graphics, false, false, false, true, true, false);
                //PointF iconLocation = new PointF(ContentBox.X-4, ContentBox.Y+70);
                //graphics.DrawImage(Owner.Icon_24x24, iconLocation);
                //
                //format.Dispose();
            }
        }
Esempio n. 20
0
            protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
            {
                base.Render(canvas, graphics, channel);
                if (channel == GH_CanvasChannel.Objects)
                {
                    StringFormat format = new StringFormat();
                    format.Alignment     = StringAlignment.Center;
                    format.LineAlignment = StringAlignment.Center;
                    format.Trimming      = StringTrimming.EllipsisCharacter;

                    GH_Capsule radio = GH_Capsule.CreateCapsule(radio_rec, GH_Palette.White, 2, 0);
                    radio.Render(graphics, Selected, Owner.Locked, false); radio.Dispose();

                    GH_Capsule radio2 = GH_Capsule.CreateCapsule(radio_rec2, GH_Palette.White, 2, 0);
                    radio2.Render(graphics, Selected, Owner.Locked, false); radio2.Dispose();

                    GH_Capsule radio_1 = GH_Capsule.CreateCapsule(radio_rec_1, GH_Palette.Black, 5, 5);
                    radio_1.Render(graphics, Selected, Owner.Locked, false); radio_1.Dispose();
                    graphics.FillEllipse(c1, radio_rec_1);
                    graphics.DrawString("+X", GH_FontServer.Standard, Brushes.Black, text_rec_1);

                    GH_Capsule radio_2 = GH_Capsule.CreateCapsule(radio_rec_2, GH_Palette.Black, 5, 5);
                    radio_2.Render(graphics, Selected, Owner.Locked, false); radio_2.Dispose();
                    graphics.FillEllipse(c2, radio_rec_2);
                    graphics.DrawString("+Y", GH_FontServer.Standard, Brushes.Black, text_rec_2);

                    GH_Capsule radio_3 = GH_Capsule.CreateCapsule(radio_rec_3, GH_Palette.Black, 5, 5);
                    radio_3.Render(graphics, Selected, Owner.Locked, false); radio_3.Dispose();
                    graphics.FillEllipse(c3, radio_rec_3);
                    graphics.DrawString("+45", GH_FontServer.Standard, Brushes.Black, text_rec_3);

                    GH_Capsule radio_4 = GH_Capsule.CreateCapsule(radio_rec_4, GH_Palette.Black, 5, 5);
                    radio_4.Render(graphics, Selected, Owner.Locked, false); radio_4.Dispose();
                    graphics.FillEllipse(c4, radio_rec_4);
                    graphics.DrawString("+135", GH_FontServer.Standard, Brushes.Black, text_rec_4);

                    GH_Capsule radio_5 = GH_Capsule.CreateCapsule(radio_rec_5, GH_Palette.Black, 5, 5);
                    radio_5.Render(graphics, Selected, Owner.Locked, false); radio_5.Dispose();
                    graphics.FillEllipse(c5, radio_rec_5);
                    graphics.DrawString("-X", GH_FontServer.Standard, Brushes.Black, text_rec_5);

                    GH_Capsule radio_6 = GH_Capsule.CreateCapsule(radio_rec_6, GH_Palette.Black, 5, 5);
                    radio_6.Render(graphics, Selected, Owner.Locked, false); radio_6.Dispose();
                    graphics.FillEllipse(c6, radio_rec_6);
                    graphics.DrawString("-Y", GH_FontServer.Standard, Brushes.Black, text_rec_6);

                    GH_Capsule radio_7 = GH_Capsule.CreateCapsule(radio_rec_7, GH_Palette.Black, 5, 5);
                    radio_7.Render(graphics, Selected, Owner.Locked, false); radio_7.Dispose();
                    graphics.FillEllipse(c7, radio_rec_7);
                    graphics.DrawString("-45", GH_FontServer.Standard, Brushes.Black, text_rec_7);

                    GH_Capsule radio_8 = GH_Capsule.CreateCapsule(radio_rec_8, GH_Palette.Black, 5, 5);
                    radio_8.Render(graphics, Selected, Owner.Locked, false); radio_8.Dispose();
                    graphics.FillEllipse(c8, radio_rec_8);
                    graphics.DrawString("-135", GH_FontServer.Standard, Brushes.Black, text_rec_8);
                }
            }
Esempio n. 21
0
 protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
 {
     if (channel == GH_CanvasChannel.Objects)
     {
         DrawTextBox(graphics, this.Bounds,
                     this.RenderSet.BackGroundColor, this.RenderSet.BoundaryColor, this.ShowName, this.RenderSet.Font,
                     this.RenderSet.TextColor, this.RenderSet.BoundaryWidth, this.RenderSet.ColorChange, this.RenderSet.CornerRadius, this.RenderSet.InflateMode);
     }
 }
            protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
            {
                GH_Capsule capsule = GH_Capsule.CreateCapsule(Bounds, GH_Palette.Normal, 100, 0);

                capsule.AddOutputGrip(OutputGrip.Y);
                capsule.Render(graphics, Selected, Owner.Locked, true);
                capsule.Dispose();
                capsule = null;
            }
Esempio n. 23
0
            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;
                }
            }
Esempio n. 24
0
            protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
            {
                base.Render(canvas, graphics, channel);
                if (channel == GH_CanvasChannel.Objects)
                {
                    StringFormat format = new StringFormat();
                    format.Alignment     = StringAlignment.Center;
                    format.LineAlignment = StringAlignment.Center;
                    format.Trimming      = StringTrimming.EllipsisCharacter;

                    GH_Capsule title = GH_Capsule.CreateCapsule(title_rec, GH_Palette.Pink, 2, 0);
                    title.Render(graphics, Selected, Owner.Locked, false);
                    title.Dispose();

                    RectangleF textRectangle = title_rec;
                    textRectangle.Height = 20;
                    graphics.DrawString("Display Option", GH_FontServer.Standard, Brushes.White, textRectangle, format);

                    GH_Capsule radio = GH_Capsule.CreateCapsule(radio_rec, GH_Palette.White, 2, 0);
                    radio.Render(graphics, Selected, Owner.Locked, false); radio.Dispose();

                    GH_Capsule radio_11 = GH_Capsule.CreateCapsule(radio_rec_11, GH_Palette.Black, 5, 5);
                    radio_11.Render(graphics, Selected, Owner.Locked, false); radio_11.Dispose();
                    graphics.FillEllipse(c11, radio_rec_11);
                    graphics.DrawString("BaseShape", GH_FontServer.Standard, Brushes.Black, text_rec_11);

                    GH_Capsule radio_13 = GH_Capsule.CreateCapsule(radio_rec_13, GH_Palette.Black, 5, 5);
                    radio_13.Render(graphics, Selected, Owner.Locked, false); radio_13.Dispose();
                    graphics.FillEllipse(c13, radio_rec_13);
                    graphics.DrawString("No", GH_FontServer.Standard, Brushes.Black, text_rec_13);

                    GH_Capsule radio_21 = GH_Capsule.CreateCapsule(radio_rec_21, GH_Palette.Black, 5, 5);
                    radio_21.Render(graphics, Selected, Owner.Locked, false); radio_21.Dispose();
                    graphics.FillEllipse(c21, radio_rec_21);
                    graphics.DrawString("Width", GH_FontServer.Standard, Brushes.Black, text_rec_21);

                    GH_Capsule radio_22 = GH_Capsule.CreateCapsule(radio_rec_22, GH_Palette.Black, 5, 5);
                    radio_22.Render(graphics, Selected, Owner.Locked, false); radio_22.Dispose();
                    graphics.FillEllipse(c22, radio_rec_22);
                    graphics.DrawString("Thick", GH_FontServer.Standard, Brushes.Black, text_rec_22);

                    GH_Capsule radio_23 = GH_Capsule.CreateCapsule(radio_rec_23, GH_Palette.Black, 5, 5);
                    radio_23.Render(graphics, Selected, Owner.Locked, false); radio_23.Dispose();
                    graphics.FillEllipse(c23, radio_rec_23);
                    graphics.DrawString("N/A", GH_FontServer.Standard, Brushes.Black, text_rec_23);

                    GH_Capsule radio2 = GH_Capsule.CreateCapsule(radio_rec2, GH_Palette.White, 2, 0);
                    radio2.Render(graphics, Selected, Owner.Locked, false); radio2.Dispose();

                    GH_Capsule radio2_1 = GH_Capsule.CreateCapsule(radio_rec2_1, GH_Palette.Black, 5, 5);
                    radio2_1.Render(graphics, Selected, Owner.Locked, false); radio2_1.Dispose();
                    graphics.FillEllipse(c2, radio_rec2_1);
                    graphics.DrawString("PDF OUTPUT", GH_FontServer.Standard, Brushes.Black, text_rec2_1);
                    ///******************************************************************************************
                }
            }
Esempio n. 25
0
 protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
 {
     if (channel == GH_CanvasChannel.Objects)
     {
         GH_PaletteStyle style = GH_Skin.palette_hidden_standard;
         GH_Skin.palette_hidden_standard = new GH_PaletteStyle(Color.DeepPink, Color.Teal, Color.PapayaWhip);
         base.Render(canvas, graphics, channel);
         GH_Skin.palette_hidden_standard = style;
     }
 }
        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, "Param Refresh", 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)
     {
         StringFormat format = new StringFormat();
         format.Alignment     = StringAlignment.Center;
         format.LineAlignment = StringAlignment.Center;
         Brush brush = new SolidBrush(this.Enable ? ColorExtension.OffColor : ColorExtension.UnableColor);
         graphics.DrawString(WholeToString(), GH_FontServer.StandardAdjusted, brush, this.Bounds, format);
     }
 }
 protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
 {
     //flag = Math.Pow(this.Bounds.X + this.Bounds.Width / 2, 2) + Math.Pow(this.Bounds.Y + this.Bounds.Height / 2, 2) > Math.Pow(3, 2);
     if (channel == GH_CanvasChannel.Groups && IsNotFirstRender)
     {
         GH_Capsule gH_Capsule = GH_Capsule.CreateCapsule(this.Bounds, GH_Palette.Pink, this.Radius, 0);
         gH_Capsule.Render(graphics, this.Color);
         gH_Capsule.Dispose();
     }
     IsNotFirstRender = true;
 }
        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, GH_Palette.Black, btnText, 2, 0);
                button.Render(graphics, Selected, Owner.Locked, false);
                button.Dispose();
            }
        }
Esempio n. 30
0
 protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
 {
     if (channel == GH_CanvasChannel.Wires)
     {
         base.Render(canvas, graphics, channel);
     }
     if (channel == GH_CanvasChannel.Objects)
     {
         AttributeUtil.RenderComponentBounds(graphics);
         AttributeUtil.CompoundRender(graphics, canvas);
     }
 }
Esempio n. 31
0
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            //paramAttributes.RenderBounds(canvas, graphics);

            base.Render(canvas, graphics, channel);

            if (channel.Equals(GH_CanvasChannel.Objects))
            {
                var paramAttributes = (NeuralNetTrainerParamAttributes)Owner.Params.Input[0].Attributes;
                paramAttributes.RenderCustomGrip(canvas, graphics);
            }
        }
Esempio n. 32
0
            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();
                }
            }
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            base.Render(canvas, graphics, channel);

            var demBounds =
                (RectangleF)
                    GH_Convert.ToRectangle(new RectangleF(new PointF(this.Pivot.X + 60, this.Pivot.Y),
                        (SizeF) new Size(W - 60 - 80, H)));

            GH_Palette palette = GH_Palette.White;
            GH_Capsule capsule = GH_Capsule.CreateCapsule(demBounds, palette);
            capsule.Render(graphics, Selected, Owner.Locked, true);

            capsule.Dispose();
            capsule = null;

            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Near;
            format.LineAlignment = StringAlignment.Center;
            format.Trimming = StringTrimming.EllipsisCharacter;

            // Content rectangle
            RectangleF textRectangle = demBounds;
            textRectangle.Height = 20;
            for (int i = 0; i < BimVisualiserData.Instance.NameList.Count; i++)
            {
                _boundingBoxes.Insert(i, textRectangle);

                // Max entries value (it would be nice extending the Bounds if more)
                if (i == 25)
                    break;
                if (i == BimVisualiserData.Instance.Selected)
                    graphics.DrawString(BimVisualiserData.Instance.NameList[i], GH_FontServer.Standard,
                        Brushes.DodgerBlue, textRectangle, format);
                else
                    graphics.DrawString(BimVisualiserData.Instance.NameList[i], GH_FontServer.Standard, Brushes.Black,
                        textRectangle, format);
                format.Alignment = StringAlignment.Near;
                //textRectangle.Inflate(-5, 0);
                textRectangle.Y += 20;
            }
            // Always dispose of any GDI+ object that implement IDisposable.
            format.Dispose();
        }
        protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel)
        {
            base.Render(canvas, graphics, channel);

              if (m_form == null || m_form.IsDisposed) return;

              if (channel == GH_CanvasChannel.Overlay &&
              (canvas.DrawingMode == GH_CanvasMode.Export ||
              canvas.DrawingMode == GH_CanvasMode.Control)
            )
              {
            Rectangle targetRectangle;
            if (canvas.DrawingMode == GH_CanvasMode.Export)
            {
              System.Windows.Forms.Control editorControl = m_form.m_texteditor;
              if (editorControl == null) return;
              targetRectangle = editorControl.ClientRectangle;
              targetRectangle = m_form.RectangleToScreen(targetRectangle);
            }
            else
            {
              targetRectangle = m_form.DesktopBounds;
            }

            RectangleF windowOnCanvas;
            {
              targetRectangle.Inflate(-1, -1);

              var desktopForm = canvas.RectangleToClient(targetRectangle);
              windowOnCanvas = canvas.Viewport.UnprojectRectangle(desktopForm);
            }

            var transparent = Color.Transparent;

            var desk_tl = new PointF(windowOnCanvas.Left, windowOnCanvas.Top);
            var desk_tr = new PointF(windowOnCanvas.Right, windowOnCanvas.Top);
            var desk_bl = new PointF(windowOnCanvas.Left, windowOnCanvas.Bottom);
            var desk_br = new PointF(windowOnCanvas.Right, windowOnCanvas.Bottom);

            var comp_tl = new PointF(Bounds.Left, Bounds.Top);
            var comp_tr = new PointF(Bounds.Right, Bounds.Top);
            var comp_bl = new PointF(Bounds.Left, Bounds.Bottom);
            var comp_br = new PointF(Bounds.Right, Bounds.Bottom);

            if (Bounds.Top < windowOnCanvas.Top)
              BoxSide(graphics, Color.FromArgb(155,255,255,255), transparent, desk_tl, desk_tr, comp_tl, comp_tr);
            if (Bounds.Right > windowOnCanvas.Right)
              BoxSide(graphics, Color.FromArgb(155, 240, 240, 240), transparent, desk_tr, desk_br, comp_tr, comp_br);
            if (Bounds.Bottom > windowOnCanvas.Bottom)
              BoxSide(graphics, Color.FromArgb(155, 120, 120, 120), transparent, desk_bl, desk_br, comp_bl, comp_br);
            if (Bounds.Left < windowOnCanvas.Left)
              BoxSide(graphics, Color.FromArgb(155, 240, 240, 240), transparent, desk_tl, desk_bl, comp_tl, comp_bl);

            BoxEdge(graphics, Color.Black, Color.Transparent, 1, desk_tl, comp_tl, AnchorStyles.Top | AnchorStyles.Left);
            BoxEdge(graphics, Color.Black, Color.Transparent, 1, desk_tr, comp_tr, AnchorStyles.Top | AnchorStyles.Right);
            BoxEdge(graphics, Color.Black, Color.Transparent, 1, desk_br, comp_br, AnchorStyles.Bottom | AnchorStyles.Right);
            BoxEdge(graphics, Color.Black, Color.Transparent, 1, desk_bl, comp_bl, AnchorStyles.Bottom | AnchorStyles.Left);

            if (canvas.DrawingMode == GH_CanvasMode.Export)
            {
              System.Windows.Forms.Control editorControl = m_form.m_texteditor;
              if (editorControl == null) return;

              using (var bitmap = new Bitmap(editorControl.Width, editorControl.Height))
              {
            editorControl.DrawToBitmap(bitmap, editorControl.Bounds);

            var ot = graphics.Transform;
            var loc = canvas.Viewport.ProjectPoint(windowOnCanvas.Location);

            graphics.ResetTransform();

            graphics.DrawImage(bitmap,
              (int)loc.X, (int)loc.Y,
              editorControl.Width, editorControl.Height);

            graphics.Transform = ot;
              }
            }
              }
        }
        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, Graphics graphics, GH_CanvasChannel channel)
        {
            if (channel == GH_CanvasChannel.Wires)
            {
                base.Render(canvas, graphics, channel);
                Layout();
            }
            if (channel == GH_CanvasChannel.Objects)
            {
                //debug
                /*
                //base.Render(canvas, graphics, channel);
                graphics.DrawRectangle(new Pen(Color.Yellow, 3f), GH_Convert.ToRectangle(Bounds));

                graphics.DrawRectangle(new Pen(Color.Blue, 2f), GH_Convert.ToRectangle(componentBox));

                foreach (var param in Owner.Params.Input)
                {
                    graphics.DrawRectangle(new Pen(Color.Green, 2f), GH_Convert.ToRectangle(param.Attributes.Bounds));
                }
                foreach (var param in Owner.Params.Output)
                {
                    graphics.DrawRectangle(new Pen(Color.Green, 2f), GH_Convert.ToRectangle(param.Attributes.Bounds));
                }

                graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle((int)(Bounds.X), (int)(Bounds.Y), (int)(Bounds.Width), (int)(titleheight)));
                */

                //background
                if (Owner.Attributes.Selected) graphics.FillRectangle(new SolidBrush(bgcolour_selected), Bounds);
                else graphics.FillRectangle(new SolidBrush(bgcolour), Bounds);

                //title
                graphics.FillRectangle(new SolidBrush(titlebgcolour), titleBox);
                float titlewidth = GH_FontServer.StringWidth(Owner.Name, titlefont);
                graphics.DrawString(Owner.Name, titlefont, Brushes.White, new PointF((float)(titleBox.Left + 0.5 * titleBox.Width - 0.5 * titlewidth), titleBox.Top));

                //params
                foreach (var param in Owner.Params.Input)
                {
                    graphics.FillRectangle(new SolidBrush(parambgcolour), param.Attributes.Bounds);
                    graphics.DrawString(param.Name, paramfont, new SolidBrush(paramfontcolour), new PointF(param.Attributes.Bounds.X, param.Attributes.Bounds.Y + parammargin));
                }
                //params
                foreach (var param in Owner.Params.Output)
                {
                    graphics.FillRectangle(new SolidBrush(parambgcolour), param.Attributes.Bounds);
                    int textwidth = GH_FontServer.StringWidth(param.Name, paramfont);
                    graphics.DrawString(param.Name, paramfont, new SolidBrush(paramfontcolour), new PointF(param.Attributes.Bounds.X, param.Attributes.Bounds.Y + parammargin));
                }

                //message
                graphics.DrawString(Owner.Message, messagefont, Brushes.Gray, componentBox.Location);

            }
        }
 protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
 {
     base.Render(canvas, graphics, channel);
 }
        /*
        public override void ExpireLayout()
        {
            base.ExpireLayout();
            //手动释放layout 和layout写在一起
        }
        protected override void Layout()
        {
            //初始化
            this.m_innerBounds = new RectangleF(this.Pivot, new SizeF(100f, 100f));
            LayoutInputParams(this.Owner, this.m_innerBounds);
            LayoutOutputParams(this.Owner, this.m_innerBounds);
            this.Bounds = LayoutBounds(this.Owner, this.m_innerBounds);
        }
        */
        //决定电池显示内容的。可以在这里修改决定是否显示物体
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            if (channel == GH_CanvasChannel.Wires)
            {
                base.Render(canvas, graphics, channel);
                // 显示连线的,可以修改,默认设置如上
            }
            if (channel == GH_CanvasChannel.Objects)
            {
                //修改显示电池主体的代码
                SolidBrush brush=new SolidBrush(Color.White);
                SolidBrush brush2 = new SolidBrush(Color.White);
                Pen pen = new Pen(Color.Black); Pen pen2 = new Pen(Color.Black);
                pen.Width = 2;
                switch (Owner.RuntimeMessageLevel)
                {
                    case GH_RuntimeMessageLevel.Warning:
                        brush2.Color = Color.Orange;
                        break;
                    case GH_RuntimeMessageLevel.Error:
                        brush2.Color = Color.Red;
                        break;
                    case GH_RuntimeMessageLevel.Blank:
                        brush2.Color = Color.White;
                        break;
                }
                 //graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                GH_Structure<GH_String> volatileData = (GH_Structure<GH_String>)base.Owner.Params.Input[0].VolatileData;
                foreach (IGH_Param param in this.Owner.Params.Input)
                {
                    graphics.FillEllipse(brush, param.Attributes.InputGrip.X - 6.2f, param.Attributes.InputGrip.Y - 4f, 8f, 8f);
                    graphics.DrawEllipse(pen, param.Attributes.InputGrip.X - 6.2f, param.Attributes.InputGrip.Y - 4f, 8f, 8f);
                }
                if (!volatileData.IsEmpty)
                {
                    Bitmap bitmap;
                    string myPath = volatileData.get_DataItem(0).Value;
                    try
                    {
                        bitmap = new Bitmap(myPath);
                    }
                    catch
                    {
                        base.Owner.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Path must be a valid location");
                        brush2.Color = Color.Red;

                        graphics.FillRectangle(brush2, Rectangle.Round(this.Bounds));
                        graphics.DrawRectangle(pen2, Rectangle.Round(this.Bounds));
                        return;
                    }
                    this.Bounds = new RectangleF(new PointF(this.Bounds.Location.X, this.Bounds.Location.Y), new SizeF(bitmap.Size.Width-1f, bitmap.Size.Height-1f));

                    graphics.DrawImage(bitmap, new RectangleF(new PointF(this.Bounds.Location.X, this.Bounds.Location.Y), new SizeF(bitmap.Size.Width, bitmap.Size.Height)));
                    graphics.DrawRectangle(pen2, Rectangle.Round(this.Bounds));
                    bitmap.Dispose();
                }
                else
                {
                    graphics.FillRectangle(brush2, Rectangle.Round(this.Bounds));
                    graphics.DrawRectangle(pen2, Rectangle.Round(this.Bounds));
                }
            }
        }
Esempio n. 39
0
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            // Render all the wires that connect the Owner to all its Sources.
            if (channel == GH_CanvasChannel.Wires) base.Render(canvas, graphics, channel);

            // Render the parameter capsule and any additional text on top of it.
            if (channel == GH_CanvasChannel.Objects)
            {
                Dhr_HeatmapComponent realOwner = (Dhr_HeatmapComponent)Owner;

                // Define the default palette.
                GH_Palette palette = GH_Palette.Normal;
                switch (Owner.RuntimeMessageLevel)
                {
                    case GH_RuntimeMessageLevel.Warning:
                        palette = GH_Palette.Warning;
                        break;
                    case GH_RuntimeMessageLevel.Error:
                        palette = GH_Palette.Error;
                        break;
                }

                // Create a new Capsule without text or icon.
                GH_Capsule capsulein = GH_Capsule.CreateCapsule(new RectangleF(Bounds.X, Bounds.Y, param_size.Width, Bounds.Height), palette, new int[] { 6, 2, 2, 6 }, 5);
                GH_Capsule capsuleout = GH_Capsule.CreateCapsule(new RectangleF(Bounds.X + Bounds.Width - param_size.Width, Bounds.Y, param_size.Width, Bounds.Height), palette, new int[] { 2, 6, 6, 2 }, 5);

                foreach (IGH_Param p in Owner.Params.Input) capsulein.AddInputGrip(p.Attributes.InputGrip.Y);
                foreach (IGH_Param p in Owner.Params.Output) capsuleout.AddOutputGrip(p.Attributes.OutputGrip.Y);

                capsulein.Render(graphics, Selected, Owner.Locked, true);
                capsuleout.Render(graphics, Selected, Owner.Locked, true);
                capsulein.Dispose();
                capsuleout.Dispose();
                capsulein = null;
                capsuleout = null;

                // draw text labels for inputs and outputs
                StringFormat format = new StringFormat
                {
                    Alignment = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center,
                    Trimming = StringTrimming.EllipsisCharacter
                };
                foreach (IGH_Param p in Owner.Params.Input) graphics.DrawString(p.NickName, GH_FontServer.Standard, Brushes.Black, p.Attributes.Bounds, format);
                foreach (IGH_Param p in Owner.Params.Output) graphics.DrawString(p.NickName, GH_FontServer.Standard, Brushes.Black, p.Attributes.Bounds, format);

                RectangleF imgBounds = new RectangleF(new PointF(Bounds.X + param_size.Width + buffer, Bounds.Y), img_size);

                //Bitmap bmp = Properties.Resources.Component;
                //if (realOwner.isPlotable) bmp = makeHeatmapImage(realOwner);
                //graphics.DrawImage(bmp, imgBounds);
                if (realOwner.isPlotable) drawHeatmapImage(realOwner, graphics, imgBounds);
                else graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 255, 255, 255)), imgBounds);

                // draw lines
                //graphics.DrawLine(new Pen(Color.White), new PointF(imgBounds.Left, imgBounds.Top), new PointF(imgBounds.Right, imgBounds.Top));
                //graphics.DrawLine(new Pen(Color.White), new PointF(imgBounds.Left, imgBounds.Bottom), new PointF(imgBounds.Right, imgBounds.Bottom));

            }
        }