예제 #1
0
        protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel)
        {
            if (channel == GH_CanvasChannel.Objects)
            {
                GH_Capsule capsule = GH_Capsule.CreateCapsule(this.Bounds, GH_Palette.Normal);
                capsule.AddOutputGrip(this.OutputGrip.Y);
                capsule.Render(canvas.Graphics, this.Selected, this.Owner.Locked, this.Owner.Hidden);
                capsule.Dispose();
                int alpha = GH_Canvas.ZoomFadeLow;
                if (alpha > 0)
                {
                    canvas.SetSmartTextRenderingHint();
                    GH_PaletteStyle      style = GH_CapsuleRenderEngine.GetImpliedStyle(GH_Palette.Normal, this);
                    System.Drawing.Color color = System.Drawing.Color.FromArgb(alpha, style.Text);
                    if (this.NameBounds.Width > 0f)
                    {
                        System.Drawing.SolidBrush nameFill = new System.Drawing.SolidBrush(color);
                        graphics.DrawString(this.Owner.NickName, GH_FontServer.Standard, nameFill, this.NameBounds, GH_TextRenderingConstants.CenterCenter);
                        nameFill.Dispose();
                        int x  = System.Convert.ToInt32(this.NameBounds.Right);
                        int y0 = System.Convert.ToInt32(this.NameBounds.Top);
                        int y  = System.Convert.ToInt32(this.NameBounds.Bottom);
                        GH_GraphicsUtil.EtchFadingVertical(graphics, y0, y, x, System.Convert.ToInt32(0.8 * (double)alpha), System.Convert.ToInt32(0.3 * (double)alpha));
                    }

                    // render dropdown only
                    this.RenderDropDown(canvas, graphics, color);
                }
            }
        }
        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;
            }
        }
예제 #3
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);
                }
            }
        }
        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, System.Drawing.Graphics graphics, GH_CanvasChannel channel)
        {
            switch (channel)
            {
            case GH_CanvasChannel.Objects:
                base.RenderComponentCapsule(canvas, graphics, true, false, false, true, true, true);

                ComponentWithDirectionLogic comp = Owner as ComponentWithDirectionLogic;

                GH_Capsule btnX = GH_Capsule.CreateCapsule(DirectionX, comp.Direction == FaceDirection.X ? GH_Palette.Black : GH_Palette.White);
                btnX.Render(graphics, this.Selected, Owner.Locked, Owner.Hidden);
                btnX.Dispose();

                GH_Capsule btnY = GH_Capsule.CreateCapsule(DirectionY, comp.Direction == FaceDirection.Y ? GH_Palette.Black : GH_Palette.White);
                btnY.Render(graphics, this.Selected, Owner.Locked, Owner.Hidden);
                btnY.Dispose();

                GH_Capsule btnZ = GH_Capsule.CreateCapsule(DirectionZ, comp.Direction == FaceDirection.Z ? GH_Palette.Black : GH_Palette.White);
                btnZ.Render(graphics, this.Selected, Owner.Locked, Owner.Hidden);
                btnZ.Dispose();

                graphics.DrawString("X", GH_FontServer.Standard, comp.Direction == FaceDirection.X ? Brushes.Gold : Brushes.Black, DirectionX, GH_TextRenderingConstants.CenterCenter);
                graphics.DrawString("Y", GH_FontServer.Standard, comp.Direction == FaceDirection.Y ? Brushes.Gold : Brushes.Black, DirectionY, GH_TextRenderingConstants.CenterCenter);
                graphics.DrawString("Z", GH_FontServer.Standard, comp.Direction == FaceDirection.Z ? Brushes.Gold : Brushes.Black, DirectionZ, GH_TextRenderingConstants.CenterCenter);

                break;

            default:
                base.Render(canvas, graphics, channel);
                break;
            }
        }
예제 #6
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);
                }
            }
        }
예제 #7
0
파일: Wick.cs 프로젝트: strdesigner/OSforGH
            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);
                }
            }
예제 #8
0
        public static void RenderButtonIcon_Obsolete(Graphics graphics, GH_Component Owner, RectangleF bound, bool on, Bitmap onMap, Bitmap offMap, int cornerRadius = 6, GH_Palette normalPalette = GH_Palette.Normal)
        {
            GH_Palette      palette      = Owner.RuntimeMessages(GH_RuntimeMessageLevel.Error).Count > 0 ? GH_Palette.Error : Owner.RuntimeMessages(GH_RuntimeMessageLevel.Warning).Count > 0 ? GH_Palette.Warning : normalPalette;
            GH_PaletteStyle impliedStyle = GH_CapsuleRenderEngine.GetImpliedStyle(palette, Owner.Attributes.Selected, Owner.Locked, Owner.Hidden);
            GH_Capsule      cap          = GH_Capsule.CreateCapsule(bound, palette, cornerRadius, 0);

            cap.Render(graphics, on ? onMap : offMap, impliedStyle);
        }
        private static void doCapsule(Graphics g, RectangleF bounds, GH_Palette palette, Color color)
        {
            GH_Capsule capsule = GH_Capsule.CreateCapsule(bounds, palette, 3, 6);

            capsule.Render(g, color);
            capsule.Dispose();
            capsule = null;
        }
예제 #10
0
        private void DrawIcon(Graphics g)
        {
            RectangleF Bounds  = this.ParamComponent.Attributes.Bounds;
            GH_Capsule Capsule = GH_Capsule.CreateCapsule(Bounds, GH_Palette.Normal);

            Bitmap Bitmap = this.ParamComponent.Locked ? this.ParamComponent.Icon_24x24_Locked : this.ParamComponent.Icon_24x24;

            Capsule.RenderEngine.RenderIcon(g, Bitmap, 0, 0);
        }
            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;
            }
예제 #12
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);
                }
            }
예제 #13
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);
                    ///******************************************************************************************
                }
            }
예제 #14
0
        public static void RenderButtonText_Obsolete(Graphics graphics, GH_Component Owner, RectangleF bound, bool on, string text, Color onColor, Color offColor, Font font, int cornerRadius = 6, GH_Palette normalPalette = GH_Palette.Normal)
        {
            GH_Palette      palette      = Owner.RuntimeMessages(GH_RuntimeMessageLevel.Error).Count > 0 ? GH_Palette.Error : Owner.RuntimeMessages(GH_RuntimeMessageLevel.Warning).Count > 0 ? GH_Palette.Warning : normalPalette;
            GH_PaletteStyle impliedStyle = GH_CapsuleRenderEngine.GetImpliedStyle(palette, Owner.Attributes.Selected, Owner.Locked, Owner.Hidden);
            GH_Capsule      cap          = GH_Capsule.CreateCapsule(bound, palette, cornerRadius, 0);

            cap.Render(graphics, impliedStyle);
            Brush brush = new SolidBrush(on ? onColor : offColor);

            graphics.DrawString(text, font, brush, bound);
        }
예제 #15
0
        public static void HighLightCom(Graphics graphics, GH_Component com, int rowsCount)
        {
            Rectangle relayrect = GH_Convert.ToRectangle(com.Attributes.Bounds);

            relayrect.Inflate(ShareData.FrameWidthGraph, ShareData.FrameWidthGraph);
            Rectangle  rect       = new Rectangle(relayrect.X, relayrect.Y, relayrect.Width, relayrect.Height + rowsCount * 15);
            GH_Capsule gH_Capsule = GH_Capsule.CreateCapsule(rect, GH_Palette.Pink, ShareData.FrameWidth, 5);

            gH_Capsule.Render(graphics, ShareData.ThemeColor);
            gH_Capsule.Dispose();
        }
예제 #16
0
 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);

            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();
        }
예제 #18
0
        public static void ButtonIconRender(Graphics graphics, GH_CanvasChannel channel, IButtonIcon button)
        {
            if (channel == GH_CanvasChannel.Objects)
            {
                graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                GH_Palette      palette      = button.RenderSet.normalPalette;
                GH_PaletteStyle impliedStyle = GetPaletteStype(button, out palette);

                GH_Capsule cap = GH_Capsule.CreateCapsule(button.Bounds, palette, button.RenderSet.CornerRadius, button.RenderSet.HighLight);
                cap.Render(graphics, button.Icon, impliedStyle);
            }
        }
예제 #19
0
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            base.Render(canvas, graphics, channel);

            if (channel == GH_CanvasChannel.Wires)
            {
                var component = (Boa_AlgorithmComponent)Owner;

                if (component.Algorithm.IsBase)
                {
                    RectangleF inflatedBounds = new RectangleF(Bounds.Location, Bounds.Size);
                    //inflatedBounds.Inflate(1, 1);
                    GH_Capsule highlightCapsule = GH_Capsule.CreateCapsule(inflatedBounds, GH_Palette.White);
                    var        outline          = highlightCapsule.OutlineShape;
                    graphics.DrawPath(outlinePen, outline);

                    //inflatedBounds.Inflate(1, 1);
                    highlightCapsule = GH_Capsule.CreateCapsule(inflatedBounds, GH_Palette.White);
                    outline          = highlightCapsule.OutlineShape;
                    graphics.DrawPath(highlightPen, outline);


                    //graphics.DrawRectangle(highlightPen, new Rectangle(
                    //    (int)inflatedBounds.X,
                    //    (int)inflatedBounds.Y,
                    //    (int)inflatedBounds.Width,
                    //    (int)inflatedBounds.Height
                    //    )
                    //    );
                }
            }

            if (channel == GH_CanvasChannel.Objects)
            {
                var    component       = (Boa_AlgorithmComponent)Owner;
                string dimensionString = component.Algorithm.GetDimensionsString();

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

                RectangleF textRectangle = new RectangleF(Bounds.X, Bounds.Y - 20, Bounds.Width, Bounds.Height);
                textRectangle.Height = 20;

                // Draw the Algorithm dimensions in a Standard Grasshopper font.
                graphics.DrawString(dimensionString, GH_FontServer.StandardBold, Brushes.Black, textRectangle, format);

                format.Dispose();
                format = null;
            }
        }
예제 #20
0
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            switch (channel)
            {
            case GH_CanvasChannel.Wires:
                graphics.FillEllipse(Brushes.Bisque, 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}", "F**K YOURSELF");
                Grasshopper.GUI.GH_GraphicsUtil.RenderCenteredText(graphics, text, GH_FontServer.Large, Color.Black, Pivot);
                //Grasshopper.GUI.GH_GraphicsUtil.RenderObjectOverlay(graphics, , Bounds);
                //GH_Capsule.CreateTextCapsule
                RectangleF capsuleRect = new RectangleF(
                    new PointF(InnerBounds.Location.X + 50, InnerBounds.Location.Y + 50), new SizeF(30, 30));
                GH_Capsule capsuleBlue = GH_Capsule.CreateCapsule(capsuleRect, GH_Palette.Blue);
                capsuleBlue.Render(graphics, Selected, Owner.Locked, true);
                capsuleBlue.Dispose();

                /*     var field = new NumberInputTextField(new Param_Number())
                 *   {
                 *       Bounds = GH_Convert.ToRectangle(Bounds)
                 *   };
                 *   var matrix = sender.Viewport.XFormMatrix(GH_Viewport.GH_DisplayMatrix.CanvasToControl);
                 *
                 *   field.ShowTextInputBox(sender, initial, true, true, matrix);
                 */

                break;
            }
        }
예제 #21
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 radio1 = GH_Capsule.CreateCapsule(radio_rec1, GH_Palette.White, 2, 0);
                    radio1.Render(graphics, Selected, Owner.Locked, false); radio1.Dispose();

                    GH_Capsule radio1_1 = GH_Capsule.CreateCapsule(radio_rec1_1, GH_Palette.Black, 5, 5);
                    radio1_1.Render(graphics, Selected, Owner.Locked, false); radio1_1.Dispose();
                    graphics.FillEllipse(c1, radio_rec1_1);
                    graphics.DrawString("Bake", GH_FontServer.Standard, Brushes.Black, text_rec1_1);
                }
            }
        internal override void Render(Graphics graphics, PointF cursorCanvasPosition, bool selected, bool locked, bool hidden)
        {
            //RectangleF rec = new RectangleF(Bounds.X + Offset / 3f, Bounds.Y + Offset / 3f, Bounds.Width - 2 * Offset / 3f, Bounds.Height - 2 * Offset / 3f);

            if (IsSelected)
            {
                GH_Capsule capsule = GH_Capsule.CreateCapsule(Bounds, GH_Palette.Transparent, 2, 0);
                capsule.Render(graphics,
                               (Enabled && !locked)?
                               new GH_PaletteStyle(Color.AntiqueWhite, Color.SlateGray)
                    :
                               new GH_PaletteStyle(Color.Transparent, Color.SlateGray)
                               );
                capsule.Dispose();
                //graphics.DrawRectangle(new Pen(Brushes.Black,2.5f), Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);
            }
            else if (Bounds.Contains(cursorCanvasPosition) && Enabled)
            {
                GH_Capsule capsule = GH_Capsule.CreateCapsule(Bounds, GH_Palette.Transparent, 2, 0);
                capsule.Render(graphics, new GH_PaletteStyle(Color.Transparent));
                capsule.Dispose();
            }


            //graphics.DrawRectangle(new Pen(Brushes.Black), Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);

            if (ShowTitle)
            {
                if (_image != null)
                {
                    graphics.DrawImage(_image, Bounds.X + Offset / 3.0f, Bounds.Y + Offset / 3.0f);
                    graphics.DrawString(Name, SmallFont, this.ActiveBrush(), _image.Width + Bounds.X + 2 * Offset / 3.0f, Bounds.Y + Offset / 3.0f, _format);
                }
                else
                {
                    graphics.DrawString(Name, SmallFont, this.ActiveBrush(), Bounds.X + 2 * Offset / 3.0f, Bounds.Y + Offset / 3.0f, _format);
                }
            }
            else
            {
                if (_image != null)
                {
                    graphics.DrawImage(_image, Bounds.X + Bounds.Width / 2f - _image.Width / 2f, Bounds.Y + Offset / 3.0f);
                }
                else
                {
                    graphics.DrawString(Name, SmallFont, this.ActiveBrush(), Bounds.X + 2 * Offset / 3.0f, Bounds.Y + Offset / 3.0f, _format);
                }
            }
        }
예제 #23
0
 protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
 {
     if ((int)channel == 10)
     {
         foreach (IGH_Param item in Owner.Params.Input)
         {
             item.Attributes.RenderToCanvas(canvas, (GH_CanvasChannel)10);
         }
     }
     else
     {
         if ((int)channel != 20)
         {
             return;
         }
         RectangleF bounds = base.Bounds;
         bool       flag   = canvas.Viewport.IsVisible(ref bounds, 10f);
         Bounds = bounds;
         if (flag)
         {
             GH_Palette      impliedPalette = GH_CapsuleRenderEngine.GetImpliedPalette((IGH_ActiveObject)(object)base.Owner);
             GH_PaletteStyle impliedStyle   = GH_CapsuleRenderEngine.GetImpliedStyle(impliedPalette, Selected, Owner.Locked, Owner.Hidden);
             GH_Capsule      val            = GH_Capsule.CreateCapsule(base.Bounds, impliedPalette, 5, 30);
             foreach (IGH_Param item2 in Owner.Params.Input)
             {
                 val.AddInputGrip(item2.Attributes.InputGrip.Y);
             }
             val.AddOutputGrip(OutputGrip.Y);
             if (Owner.Message != null)
             {
                 val.RenderEngine.RenderMessage(graphics, Owner.Message, impliedStyle);
             }
             val.Render(graphics, Selected, Owner.Locked, true);
             val.Dispose();
             GH_ComponentAttributes.RenderComponentParameters(canvas, graphics, base.Owner, impliedStyle);
             if (base.Owner.Graph == null)
             {
                 RectangleF bounds2 = base.Bounds;
                 bounds2.X     += inputWidth;
                 bounds2.Width -= inputWidth + outputWidth;
                 bounds2.Inflate(-6f, -6f);
                 GH_GraphContainer.Render_GraphBackground(graphics, bounds2, false);
             }
             else
             {
                 base.Owner.Container.Render(graphics, DrawDomainsTags, base.Owner.Samples);
             }
         }
     }
 }
예제 #24
0
        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            if (channel == GH_CanvasChannel.Objects)
            {
                MagnethandsonComponent comp = Owner as MagnethandsonComponent;

                if (comp.flagNum == 0)
                {
                    // Cache the existing style.
                    GH_PaletteStyle style = GH_Skin.palette_hidden_standard;
                    // Swap out palette for normal, unselected components.
                    GH_Skin.palette_hidden_standard = new GH_PaletteStyle(Color.Red, Color.Teal, Color.PapayaWhip);
                    base.Render(canvas, graphics, channel);
                    // Put the original style back.
                    GH_Skin.palette_hidden_standard = style;
                }

                if (comp.flagNum == 1)
                {
                    // Cache the existing style.
                    GH_PaletteStyle style = GH_Skin.palette_hidden_standard;
                    // Swap out palette for normal, unselected components.
                    GH_Skin.palette_hidden_standard = new GH_PaletteStyle(Color.Blue, Color.Teal, Color.PapayaWhip);
                    base.Render(canvas, graphics, channel);
                    // Put the original style back.
                    GH_Skin.palette_hidden_standard = style;
                }



                GH_Capsule buttonSpole = GH_Capsule.CreateCapsule(SpoleBounds, comp.flagNum == 0 ? GH_Palette.Error : GH_Palette.White);
                buttonSpole.Render(graphics, this.Selected, Owner.Locked, Owner.Hidden);
                buttonSpole.Dispose();

                GH_Capsule buttonNpole = GH_Capsule.CreateCapsule(NpoleBounds, comp.flagNum == 1 ? GH_Palette.Blue : GH_Palette.White);
                buttonNpole.Render(graphics, this.Selected, Owner.Locked, Owner.Hidden);
                buttonNpole.Dispose();



                graphics.DrawString("S極", GH_FontServer.Standard, Brushes.Black, SpoleBounds, GH_TextRenderingConstants.CenterCenter);
                graphics.DrawString("N極", GH_FontServer.Standard, Brushes.Black, NpoleBounds, GH_TextRenderingConstants.CenterCenter);
            }
            else
            {
                base.Render(canvas, graphics, channel);
            }
        }
예제 #25
0
        public static void ButtonStringRender(Graphics graphics, GH_CanvasChannel channel, IButtonString owner)
        {
            if (channel == GH_CanvasChannel.Objects)
            {
                graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                GH_Palette      palette      = owner.RenderSet.normalPalette;
                GH_PaletteStyle impliedStyle = GetPaletteStype(owner, out palette);

                GH_Capsule cap = GH_Capsule.CreateCapsule(owner.Bounds, palette, owner.RenderSet.CornerRadius, owner.RenderSet.HighLight);
                cap.Render(graphics, impliedStyle);
                Brush brush = new SolidBrush(owner.RightColor);

                StringFormat format = new StringFormat();
                format.Alignment     = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;
                graphics.DrawString(owner.Name, owner.RenderSet.Font, brush, owner.Bounds, format);
            }
        }
예제 #26
0
        static Bitmap BuildIcon()
        {
            var bitmap = new Bitmap(24, 24);

            using (var graphics = Graphics.FromImage(bitmap))
            {
                var iconBounds = new RectangleF(0.0f, 0.0f, 24.0f, 24.0f);
                iconBounds.Inflate(-0.5f, -0.5f);

                using (var capsule = GH_Capsule.CreateCapsule(iconBounds, GH_Palette.Grey))
                {
                    capsule.Render(graphics, false, false, false);
                    ComponentAttributes.RenderCheckMark(graphics, iconBounds, Color.Black);
                }
            }

            return(bitmap);
        }
예제 #27
0
        private void DrawIcon(Graphics g)
        {
            GH_ComponentAttributes Com_Attributes = this.Component.Attributes as GH_ComponentAttributes;
            RectangleF             BitmapRect;

            if (IsComponent)
            {
                BitmapRect = Com_Attributes.ContentBox;
            }
            else
            {
                BitmapRect = this.Component.Attributes.Bounds;
            }

            GH_Capsule Capsule = GH_Capsule.CreateCapsule(Com_Attributes.ContentBox, GH_Palette.Normal);
            Bitmap     Bitmap  = this.Component.Locked ? this.Component.Icon_24x24_Locked : this.Component.Icon_24x24;

            Capsule.RenderEngine.RenderIcon(g, Bitmap, 0, 0);
        }
예제 #28
0
        public static void HighLightObject(Graphics graphics, IGH_DocumentObject Owner, Color color, int offset = 8, int radius = 8)
        {
            Rectangle relayrect = GH_Convert.ToRectangle(Owner.Attributes.Bounds);

            relayrect.Inflate(offset, offset);

            int height = 0;

            if (Owner is GH_Component)
            {
                GH_Component com = Owner as GH_Component;
                height = MessageBoxHeight(com.Message, (int)Owner.Attributes.Bounds.Width);
            }

            Rectangle  rect       = new Rectangle(relayrect.X, relayrect.Y, relayrect.Width, relayrect.Height + height);
            GH_Capsule gH_Capsule = GH_Capsule.CreateCapsule(rect, GH_Palette.Pink, radius, 0);

            gH_Capsule.Render(graphics, color);
            gH_Capsule.Dispose();
        }
예제 #29
0
        public static void DrawFrame(RectangleF bound, Graphics G, string title, bool selected, bool locked, bool hidden)
        {
            GH_Capsule capsule = GH_Capsule.CreateCapsule(bound, GH_Palette.Transparent, 2, 0);

            capsule.Render(G, selected, locked, hidden);
            if (title == string.Empty)
            {
                capsule.Dispose();
                return;
            }
            using (StringFormat s = new StringFormat()
            {
                Alignment = StringAlignment.Near,
                LineAlignment = StringAlignment.Near,
                Trimming = StringTrimming.EllipsisCharacter
            })

            {
                G.DrawString(
                    title,
                    GHControl.SmallFont,
                    (locked)?Brushes.Gray: Brushes.Black,
                    capsule.Box.Left + capsule.MaxRadius,
                    capsule.Box.Top + capsule.MaxRadius,
                    s);
            }
            if (title != string.Empty)
            {
                using (Pen p = new Pen(Brushes.DimGray, 0.5f))
                {
                    G.DrawLine(
                        p,
                        capsule.Box.Left + 3,
                        capsule.Box.Top + GHControl.SmallFont.Height + 1,
                        capsule.Box.Right - 3,
                        capsule.Box.Top + GHControl.SmallFont.Height + 1);
                }
            }

            capsule.Dispose();
        }
예제 #30
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();

                graphics.DrawString("Min:" + MinMax.min.ToString(), GH_FontServer.Standard, Brushes.Black, text_rec_1);

                graphics.DrawString("Max:" + MinMax.max.ToString(), GH_FontServer.Standard, Brushes.Black, text_rec_2);

                graphics.DrawString("AbsMin:" + MinMax.absmin.ToString(), GH_FontServer.Standard, Brushes.Black, text_rec_3);

                graphics.DrawString("AbsMax:" + MinMax.absmax.ToString(), GH_FontServer.Standard, Brushes.Black, text_rec_4);
            }
        }