コード例 #1
0
 public void SetSelected(bool Selected, bool Starting = false)
 {
     if (this.Selected != Selected || Starting)
     {
         if (Selected)
         {
             foreach (Widget w in Parent.Widgets)
             {
                 if (!(w is ModeButton))
                 {
                     continue;
                 }
                 ModeButton b = w as ModeButton;
                 if (b.Selected)
                 {
                     b.SetSelected(false);
                 }
             }
         }
         this.Selected = Selected;
         if (!Starting)
         {
             if (Selected)
             {
                 this.OnSelection?.Invoke(new BaseEventArgs());
             }
             if (!Selected)
             {
                 this.OnDeselection?.Invoke(new BaseEventArgs());
             }
         }
         Redraw();
     }
 }
コード例 #2
0
ファイル: ToolBar.cs プロジェクト: Marin-MK/RPG-Studio-MK
        public ToolBar(IContainer Parent) : base(Parent)
        {
            MappingMode = new ModeButton(this, "Maps", 23);
            MappingMode.SetPosition(4, 0);
            MappingMode.SetSelected(true);
            MappingMode.OnSelection += delegate(BaseEventArgs e)
            {
                Editor.SetMode("MAPPING");
            };

            EventingMode = new ModeButton(this, "Events", 24);
            EventingMode.SetPosition(MappingMode.Position.X + MappingMode.Size.Width + 12, 0);
            EventingMode.OnSelection += delegate(BaseEventArgs e)
            {
                Editor.SetMode("EVENTING");
            };

            ScriptingMode = new ModeButton(this, "Scripts", 25);
            ScriptingMode.SetPosition(EventingMode.Position.X + EventingMode.Size.Width + 12, 0);
            ScriptingMode.OnSelection += delegate(BaseEventArgs e)
            {
                Editor.SetMode("SCRIPTING");
            };

            DatabaseMode = new ModeButton(this, "Database", 26);
            DatabaseMode.SetPosition(ScriptingMode.Position.X + ScriptingMode.Size.Width + 12, 0);
            DatabaseMode.OnSelection += delegate(BaseEventArgs e)
            {
                Editor.SetMode("DATABASE");
            };

            ActionContainer = new Container(this);
            ActionContainer.SetPosition(DatabaseMode.Position.X + DatabaseMode.Size.Width + 12, 3);
            ActionContainer.SetSize(83, 28);
            ActionContainer.Sprites["line"] = new Sprite(ActionContainer.Viewport, new SolidBitmap(1, 26, new Color(28, 50, 73)));
            Delete = new IconButton(ActionContainer);
            Delete.SetPosition(6, 0);
            Delete.SetIcon(3, 0);
            Delete.Selectable = false;
            Undo = new IconButton(ActionContainer);
            Undo.SetPosition(30, 0);
            Undo.SetIcon(4, 0);
            Undo.Selectable   = false;
            Undo.OnLeftClick += delegate(MouseEventArgs e)
            {
                Editor.Undo();
            };
            Redo = new IconButton(ActionContainer);
            Redo.SetPosition(54, 0);
            Redo.SetIcon(5, 0);
            Redo.Selectable   = false;
            Redo.OnLeftClick += delegate(MouseEventArgs e)
            {
                Editor.Redo();
            };

            CopyContainer = new Container(this);
            CopyContainer.SetPosition(ActionContainer.Position.X + ActionContainer.Size.Width, 3);
            CopyContainer.SetSize(83, 28);
            CopyContainer.Sprites["line"] = new Sprite(CopyContainer.Viewport, new SolidBitmap(1, 26, new Color(28, 50, 73)));
            Cut = new IconButton(CopyContainer);
            Cut.SetPosition(6, 0);
            Cut.SetIcon(0, 0);
            Cut.Selectable = false;
            Copy           = new IconButton(CopyContainer);
            Copy.SetPosition(30, 0);
            Copy.SetIcon(1, 0);
            Copy.Selectable = false;
            Paste           = new IconButton(CopyContainer);
            Paste.SetPosition(54, 0);
            Paste.SetIcon(2, 0);
            Paste.Selectable = false;

            PlayButton = new PlayButton(this);
            SaveButton = new SaveButton(this);
        }