コード例 #1
0
        private void AddCustomCommandEntry(ToolStripMenuItem tsi, ICommand cmd)
        {
            var icon = CommandIconCache.GetStandardCommandIcon(cmd.ImageURL);

            if (icon == null)
            {
                icon = Properties.Resources.question;
            }

            ToolStripMenuItem mi = new ToolStripMenuItem(cmd.Name, icon, new EventHandler(OnAddCustomCommand));

            mi.Text = cmd.Name;
            //Reg property listener
            PropertyChangedEventHandler handler = (sender, e) =>
            {
                if (e.PropertyName == "Name")
                {
                    mi.Text = cmd.Name;
                }
            };

            _customCommandListeners[mi] = handler;
            cmd.PropertyChanged        += WeakEventHandler.Wrap(handler, (eh) => cmd.PropertyChanged -= eh);
            mi.Tag = cmd;
            tsi.DropDown.Items.Add(mi);
        }
コード例 #2
0
        public System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            if (treePath.IsEmpty())
            {
                foreach (var item in _menu.Items)
                {
                    if (item.Function == UIItemFunctionType.Command)
                    {
                        var ci  = (ICommandItem)item;
                        var cmd = _wl.GetCommandByName(ci.Command);
                        Debug.Assert(cmd != null);

                        yield return(new CommandItem(ci, CommandIconCache.GetStandardCommandIcon(cmd.ImageURL)));
                    }
                    else if (item.Function == UIItemFunctionType.Flyout)
                    {
                        yield return(new FlyoutItem((IFlyoutItem)item));
                    }
                    else
                    {
                        yield return(new SeparatorItem((ISeparatorItem)item));
                    }
                }
            }
            else
            {
                var flyout = treePath.LastNode as FlyoutItem;
                if (flyout != null)
                {
                    foreach (var item in flyout.SubItem)
                    {
                        if (item.Function == UIItemFunctionType.Command)
                        {
                            var ci  = (ICommandItem)item;
                            var cmd = _wl.GetCommandByName(ci.Command);
                            Debug.Assert(cmd != null);

                            yield return(new CommandItem(ci, CommandIconCache.GetStandardCommandIcon(cmd.ImageURL)));
                        }
                        else if (item.Function == UIItemFunctionType.Flyout)
                        {
                            yield return(new FlyoutItem((IFlyoutItem)item));
                        }
                        else
                        {
                            yield return(new SeparatorItem((ISeparatorItem)item));
                        }
                    }
                }
                else
                {
                    yield break;
                }
            }
        }
コード例 #3
0
 private void InitBuiltinCommandMenu()
 {
     foreach (BuiltInCommandType type in Enum.GetValues(typeof(BuiltInCommandType)))
     {
         ToolStripMenuItem mi = new ToolStripMenuItem(type.ToString(), CommandIconCache.GetStandardCommandIcon(type), new EventHandler(OnAddBuiltInCommand));
         mi.Tag = type;
         mnuBuiltin.DropDown.Items.Add(mi);
     }
     //Need to make sure MapTip is available for v2.4 onwards
     if (_wl.ResourceVersion >= new Version(2, 4, 0))
     {
         ToolStripMenuItem mi = new ToolStripMenuItem(BasicCommandActionType.MapTip.ToString(), null, new EventHandler(OnAddBuiltInCommand));
         mi.Tag = BasicCommandActionType.MapTip;
         mnuBuiltin.DropDown.Items.Add(mi);
     }
 }
コード例 #4
0
        private void txtDisabledIcon_TextChanged(object sender, EventArgs e)
        {
            var img = CommandIconCache.GetStandardCommandIcon(txtDisabledIcon.Text);

            if (img != null)
            {
                imgDisabled.Image = img;
            }
            else
            {
                imgDisabled.Image = Properties.Resources.cross_circle_frame;
            }

            if (!_init)
            {
                return;
            }
            _cmd.DisabledImageURL = txtDisabledIcon.Text;
        }