示例#1
0
            protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
            {
                this.Bounds = baseRect;

                base.Render(canvas, graphics, channel);

                if (channel == GH_CanvasChannel.First && Owner.showGraphics != null)
                {
                    if (Owner.showGraphics.OnPingDocument() == Owner.OnPingDocument())
                    {
                        RenderCanvas.HighLightCom(graphics, Owner.showGraphics, 2);
                    }
                }


                if (channel == GH_CanvasChannel.Objects && Frame.Component != null && Owner.Params.Input[0].SourceCount > 0)
                {
                    finalDict = new List <RectangleF>();

                    if (Owner.GetValue("ShowGraphOnThis", @default: true) && Frame.Component.ShowGraphOnEvent)
                    {
                        float X = Owner.Attributes.Bounds.X + Owner.Attributes.Bounds.Width / 2 - Frame.Component.SliderWidth / 2 + 10;
                        float Y = Owner.Attributes.Bounds.Y - 20;

                        RenderCanvas.DrawGraph(graphics, Owner.keyPoints, X, Y, Owner.GraphHeight, Owner.eventThing, out finalDict, out maxRect);


                        PointF txtLoc = new PointF(X, Y - Owner.GraphHeight - 25);
                        graphics.DrawString(Owner.NickName, GH_FontServer.NewFont(GH_FontServer.Script, 9, FontStyle.Bold), new SolidBrush(ShareData.ThemeColor), txtLoc);
                    }
                    else
                    {
                        PointF txtLoc = new PointF(Owner.Attributes.Bounds.X, Owner.Attributes.Bounds.Y - 15);
                        graphics.DrawString(Owner.NickName, GH_FontServer.NewFont(GH_FontServer.Script, 9, FontStyle.Bold), new SolidBrush(ShareData.ThemeColor), txtLoc);
                    }
                }
                if (maxRect != new RectangleF())
                {
                    thisRect = RectangleF.Union(baseRect, maxRect);
                }
                else
                {
                    thisRect = baseRect;
                }
                this.Bounds = thisRect;
            }
示例#2
0
            protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
            {
                Bounds = baseRect;
                base.Render(canvas, graphics, channel);


                //Show Top Text
                if (channel == GH_CanvasChannel.Overlay && Owner.ShowLabel)
                {
                    float  size        = (float)Owner.LabelSize / Grasshopper.Instances.ActiveCanvas.Viewport.Zoom;
                    string showMessage = (Owner.ShowFrame ? "Frame:" + Owner.RightFrame.ToString() + "  " : "") + (Owner.ShowTime ? "Time:" + Owner.RightTime.ToString("f2") + "s  " : "")
                                         + (Owner.ShowPercent ? Owner.PercentStr : "") + (Owner.ShowRemain ? Owner.RemainStr : "");
                    graphics.DrawString(showMessage, GH_FontServer.NewFont(GH_FontServer.Script, size, FontStyle.Regular),
                                        new SolidBrush(ShareData.ThemeColor), Grasshopper.Instances.ActiveCanvas.Viewport.VisibleRegion.X, Grasshopper.Instances.ActiveCanvas.Viewport.VisibleRegion.Y);
                }

                //Render Button
                if (channel == GH_CanvasChannel.Objects)
                {
                    GH_Palette pale = Owner.Locked ? GH_Palette.Locked : GH_Palette.Normal;

                    GH_Capsule PlayCapsule = GH_Capsule.CreateTextCapsule(PlayButtonRect, PlayButtonRect, pale, "Play");
                    if (Owner.Play)
                    {
                        PlayCapsule.Render(graphics, ShareData.ThemeColor);
                    }
                    else
                    {
                        PlayCapsule.Render(graphics, this.Selected, Owner.Locked, Owner.Hidden);
                    }
                    PlayCapsule.Dispose();

                    GH_Capsule ShootCapsule = GH_Capsule.CreateTextCapsule(ShootButtonRect, ShootButtonRect, pale, "Shoot");
                    if (Owner.shoot)
                    {
                        ShootCapsule.Render(graphics, ShareData.ThemeColor);
                    }
                    else
                    {
                        ShootCapsule.Render(graphics, this.Selected, Owner.Locked, Owner.Hidden);
                    }
                    ShootCapsule.Dispose();

                    if (Owner.ShowGraph && Owner.FrameObject != null)
                    {
                        if (Owner.FrameObject.OnPingDocument() == Owner.OnPingDocument())
                        {
                            float PtXStart;
                            float PtY;
                            GoButtons     = new List <RectangleF>();
                            ToEventButton = new List <List <RectangleF> >();

                            Frame.Component = Frame.Component ?? Owner;

                            PtXStart = Owner.Attributes.Bounds.X + Owner.Attributes.Bounds.Width / 2 - Frame.Component.SliderWidth / 2 + 10 + 40;
                            PtY      = Owner.Attributes.Bounds.Y - 20;

                            foreach (EventOperation eveOperation in Owner.ClearComponent)
                            {
                                if (!eveOperation.ShowGraphOnSlider)
                                {
                                    continue;
                                }

                                List <RectangleF> relayDict = new List <RectangleF>();
                                RenderCanvas.DrawGraph(graphics, eveOperation.keyPoints, PtXStart, PtY, eveOperation.GraphHeight, eveOperation.eventThing, out relayDict, out maxRect);
                                ToEventButton.Add(relayDict);


                                RectangleF buttonRect = new RectangleF(PtXStart - 80, PtY - eveOperation.GraphHeight - ShareData.GraphCurveThickness,
                                                                       60, eveOperation.GraphHeight + ShareData.GraphCurveThickness);

                                GoButtons.Add(buttonRect);

                                if (this.maxRect != new RectangleF())
                                {
                                    maxRect = RectangleF.Union(maxRect, buttonRect);
                                }
                                PtY -= ShareData.GraphDistance + eveOperation.GraphHeight;

                                //Split String
                                int      maxlen    = (int)((float)buttonRect.Width / 3.75f);
                                string[] listArray = eveOperation.NickName.Split(' ');
                                string   showTxt   = listArray[0];
                                string   joinStr   = "";
                                for (int n = 1; n < listArray.Length; n++)
                                {
                                    if (listArray[n].Length > maxlen)
                                    {
                                        if (joinStr.Length > 0)
                                        {
                                            showTxt += "\n" + joinStr;
                                        }
                                        showTxt += "\n" + listArray[n];

                                        joinStr = "";
                                    }
                                    else if (listArray[n].Length + joinStr.Length > maxlen)
                                    {
                                        showTxt += "\n" + joinStr;
                                        joinStr  = listArray[n];
                                    }
                                    else
                                    {
                                        joinStr += " " + listArray[n];
                                    }
                                }
                                if (joinStr.Length > 0)
                                {
                                    showTxt += "\n" + joinStr;
                                }

                                int        deep       = (int)((float)buttonRect.Height / 3);
                                GH_Capsule gH_Capsule = GH_Capsule.CreateTextCapsule(buttonRect, buttonRect, GH_Palette.Blue, showTxt,
                                                                                     GH_FontServer.NewFont(GH_FontServer.Script, 6, FontStyle.Regular), GH_Orientation.horizontal_center, 5, deep);
                                gH_Capsule.Render(graphics, ShareData.ThemeColor);
                                gH_Capsule.Dispose();
                            }
                        }

                        if (this.maxRect != new RectangleF())
                        {
                            thisRect = RectangleF.Union(new RectangleF(this.baseRect.X, this.baseRect.Y, this.baseRect.Width, this.baseRect.Height + 30), this.maxRect);
                        }
                        else
                        {
                            thisRect = new RectangleF(this.baseRect.X, this.baseRect.Y, this.baseRect.Width, this.baseRect.Height + 30);
                        }
                    }
                }

                if (channel == GH_CanvasChannel.First && Owner.FrameObject != null)
                {
                    Rectangle rect = GH_Convert.ToRectangle(Owner.FrameObject.Attributes.Bounds);
                    rect.Inflate(ShareData.FrameWidth, ShareData.FrameWidth);
                    GH_Capsule gH_Capsule = GH_Capsule.CreateCapsule(rect, GH_Palette.Pink, ShareData.FrameWidth, 5);
                    gH_Capsule.Render(graphics, ShareData.ThemeColor);
                    gH_Capsule.Dispose();
                }

                this.Bounds = this.thisRect;
            }