Exemplo n.º 1
0
        private ToolStripButton CreateButton(GuiPresenter presenter, ToolbarItemDef itemDef)
        {               //****************************************
            var MyButton = new ToolStripButton();

            //****************************************

            new WinCommand(itemDef.Command).AttachTo(presenter, MyButton);

            //****************************************

            return(MyButton);
        }
Exemplo n.º 2
0
        private ToolStripDropDownButton CreateDropDownButton(GuiPresenter presenter, ToolbarItemDef itemDef)
        {               //****************************************
            var MyButton = new ToolStripDropDownButton();

            //****************************************

            foreach (ToolbarItemDef MyItemDef in itemDef.Children)
            {
                MyButton.DropDownItems.Add(CreateToolbarItem(presenter, MyItemDef));
            }

            //****************************************

            return(MyButton);
        }
Exemplo n.º 3
0
        private ToolStripSplitButton CreateSplitButton(GuiPresenter presenter, ToolbarItemDef itemDef)
        {               //****************************************
            var MyButton = new ToolStripSplitButton();

            //****************************************

            new WinCommand(itemDef.Command).AttachTo(presenter, MyButton);

            foreach (ToolbarItemDef MyItemDef in itemDef.Children)
            {
                MyButton.DropDownItems.Add(CreateToolbarItem(presenter, MyItemDef));
            }

            //****************************************

            return(MyButton);
        }
Exemplo n.º 4
0
        private ToolStripItem CreateToolbarItem(GuiPresenter presenter, ToolbarItemDef itemDef)
        {               //****************************************
            ToolStripItem MyItem;

            //****************************************

            if (itemDef.Children != null)
            {
                if (!string.IsNullOrEmpty(itemDef.Command))                 // Item has children and is clickable, use a Split Button
                {
                    MyItem = CreateSplitButton(presenter, itemDef);
                }
                else                 // Children, but not clickable, use a Drop Down
                {
                    MyItem = CreateDropDownButton(presenter, itemDef);
                }
            }
            else
            {
                if (itemDef.Style == null)                 // No style, use a Separator
                {
                    MyItem = new ToolStripSeparator();
                }
                else if (!string.IsNullOrEmpty(itemDef.Command))                 // Clickable, use a Button
                {
                    MyItem = CreateButton(presenter, itemDef);
                }
                else                 // Not clickable, styled, use a Label
                {
                    MyItem = new ToolStripLabel();
                }
            }

            //****************************************

            if (itemDef.Style != null)
            {
                if (itemDef.Style.Icon != null)
                {
                    MyItem.Image      = itemDef.Style.Icon;
                    MyItem.ImageAlign = ContentAlignment.MiddleLeft;
                    if (itemDef.HasText)
                    {
                        MyItem.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                    }
                    else
                    {
                        MyItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
                    }
                }
                else
                {
                    MyItem.DisplayStyle = ToolStripItemDisplayStyle.Text;
                }
            }

            switch (itemDef.Align)
            {
            case ToolbarItemAlign.Left:
                MyItem.Alignment = ToolStripItemAlignment.Left;
                break;

            case ToolbarItemAlign.Right:
                MyItem.Alignment = ToolStripItemAlignment.Right;
                break;
            }

            //****************************************

            return(MyItem);
        }
        //****************************************

        internal WinToolItem(ToolbarItemDef itemDef, object target)
        {
            /*
             * //****************************************
             * bool HasClick = !(itemDef.Widget is DudWidget);
             * bool ShowText = itemDef.ShowText;
             * WinToolItem NewItem;
             *
             * ToolStripDropDownItem MyDropdown;
             * //****************************************
             */
            _Children = new List <WinToolItem>();
            _Item     = new ToolStripButton();

            /*
             * if (itemDef.Children.Count == 0)
             * {
             *      if (HasClick)
             *              _Item = new ToolStripButton();
             *      else
             *      {
             *              _Item = new ToolStripLabel();
             *
             *              ShowText = true; // Labels should always show text
             *      }
             * }
             * else
             * {
             *      if (HasClick)
             *              MyDropdown = new ToolStripSplitButton();
             *      else
             *              MyDropdown = new ToolStripDropDownButton();
             *
             *      // Add child items
             *
             *      _Item = MyDropdown;
             *
             *      foreach(ToolbarItemDef ChildItem in itemDef.Children)
             *      {
             *              if (ChildItem == null || ChildItem.Widget == null)
             *              {
             *                      MyDropdown.DropDownItems.Add(new ToolStripSeparator());
             *
             *                      continue;
             *              }
             *
             *              NewItem = new WinToolItem(ChildItem, target);
             *
             *              _Children.Add(NewItem);
             *
             *              MyDropdown.DropDownItems.Add(NewItem.Item);
             *      }
             * }
             *
             * // Bind click event
             * if (HasClick)
             *      _Item.Click += itemDef.Widget.Connect(target);
             *
             * // Set up appearance
             * if (itemDef.Widget.Icon == null)
             *      _Item.DisplayStyle = ToolStripItemDisplayStyle.Text;
             * else if (ShowText)
             *      _Item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
             * else
             *      _Item.DisplayStyle = ToolStripItemDisplayStyle.Image;
             *
             * if (itemDef.Align == ToolbarItemAlign.Left)
             *      _Item.Alignment = ToolStripItemAlignment.Left;
             * else
             *      _Item.Alignment = ToolStripItemAlignment.Right;
             */
        }