Beispiel #1
0
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                MagnethandsonComponent comp = Owner as MagnethandsonComponent;

                if (SpoleBounds.Contains(e.CanvasLocation))
                {
                    if (comp.flagNum == 0)
                    {
                        return(GH_ObjectResponse.Handled);
                    }
                    comp.RecordUndoEvent("S pole");
                    comp.flagNum = 0;
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }

                if (NpoleBounds.Contains(e.CanvasLocation))
                {
                    if (comp.flagNum == 1)
                    {
                        return(GH_ObjectResponse.Handled);
                    }
                    comp.RecordUndoEvent("N pole");
                    comp.flagNum = 1;
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
 public CustomAttributes(MagnethandsonComponent owner) : base(owner)
 {
 }