Exemplo n.º 1
0
        /// <summary>
        /// Add one single MenuItem (and all needed Parents)
        /// </summary>
        /// <param name="item"></param>
        /// <param name="parts"></param>
        public static void AddMenuItem(ref SimPe.Events.ChangedResourceEvent ev, ToolStripItemCollection parent, ToolMenuItemExt item, string[] parts)
        {
            System.Reflection.Assembly a = typeof(LoadFileWrappersExt).Assembly;

            for (int i = 0; i < parts.Length - 1; i++)
            {
                string            name = SimPe.Localization.GetString(parts[i]);
                ToolStripMenuItem mi   = null;
                //find an existing Menu Item
                if (parent != null)
                {
                    foreach (ToolStripMenuItem oi in parent)
                    {
                        if (oi.Text.ToLower().Trim() == name.ToLower().Trim())
                        {
                            mi = oi;
                            break;
                        }
                    }
                }
                if (mi == null)
                {
                    mi = new ToolStripMenuItem(name);

                    if (parent != null)
                    {
                        System.IO.Stream imgstr = a.GetManifestResourceStream("SimPe." + parts[i] + ".png");
                        if (imgstr != null)
                        {
                            mi.Image = System.Drawing.Image.FromStream(imgstr);
                        }
                        parent.Insert(0, mi);
                    }
                }

                parent = mi.DropDownItems;
            }

            if (item.ToolExt != null)
            {
                LoadFileWrappersExt.SetShurtcutKey(item, item.ToolExt.Shortcut);
                item.Image = item.ToolExt.Icon;
                //item.ToolTipText = item.ToolExt.ToString();
            }

            parent.Add(item);
            ev += new SimPe.Events.ChangedResourceEvent(item.ChangeEnabledStateEventHandler);
            item.ChangeEnabledStateEventHandler(item, new SimPe.Events.ResourceEventArgs(null));
        }
Exemplo n.º 2
0
        private void InternalBuildMenu(ToolStripItemCollection items, string id)
        {
            items.Clear();
            ToolStripMenuItem defaultItem = null;

            foreach (var item in PanelItems[id].ContextMenu)
            {
                if (item.IsSeparator)
                {
                    items.Add(new ToolStripSeparator());
                }
                else
                {
                    var menuItem = new ToolStripMenuItem();
                    menuItem.Tag  = item;
                    menuItem.Text = App.TR.Translate(item.Text);
                    menuItem.ShortcutKeyDisplayString = item.ShortcutKeys;
                    menuItem.Click += MenuItemOnClick;
                    if (item.ProgramValue != null)
                    {
                        menuItem.Image = item.ProgramValue.ProgramImage;
                    }
                    menuItem.Enabled = item.Enabled;
                    // lookup last default menuItem
                    if (item.Default)
                    {
                        defaultItem = menuItem;
                    }
                    items.Add(menuItem);
                }
            }
            if (defaultItem != null)
            {
                defaultItem.Font = new Font(defaultItem.Font, FontStyle.Bold);
            }
        }
Exemplo n.º 3
0
 public static void Populate(ToolStripItemCollection strips, List <OptionBase> options, Action <OptionBase> onOptionChanged = null, bool skipChildOptions = true)
 {
     using (new log.GroupDEBUG(g.IssueFinder, "Populate popup menu", false))
     {
         strips.Clear();
         var menus = Convert(options, onOptionChanged, skipChildOptions);
         foreach (var menu in menus)
         {
             if (menu != null)
             {
                 strips.Add(menu);
             }
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 添加子菜单
        /// </summary>
        /// <param name="text">要显示的文字,如果为 - 则显示为分割线</param>
        /// <param name="cms">要添加到的子菜单集合</param>
        /// <param name="callback">点击时触发的事件</param>
        /// <returns>生成的子菜单,如果为分隔条则返回null</returns>

        ToolStripMenuItem AddContextMenu(string text, ToolStripItemCollection cms, EventHandler callback)
        {
            if (text == "-")
            {
                ToolStripSeparator tsp = new ToolStripSeparator();
                cms.Add(tsp);
                return(null);
            }
            else if (!string.IsNullOrEmpty(text))
            {
                ToolStripMenuItem tsmi = new ToolStripMenuItem(text);
                tsmi.Tag   = text + "TAG";
                tsmi.Image = ImageHelper.GetImage(System.Environment.CurrentDirectory + "\\ICon\\y1.ico");
                if (callback != null)
                {
                    tsmi.Click += callback;
                }
                cms.Add(tsmi);

                return(tsmi);
            }

            return(null);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加子菜单
        /// </summary>
        /// <param name="text">要显示的文字,如果为 - 则显示为分割线</param>
        /// <param name="cms">要添加到的子菜单集合</param>
        /// <param name="callback">点击时触发的事件</param>
        /// <returns>生成的子菜单,如果为分隔条则返回null</returns>
        ToolStripMenuItem AddContextMenu(string text, DbDataInfo info, ToolStripItemCollection cms, EventHandler callback)
        {
            if (text == "-")
            {
                ToolStripSeparator tsp = new ToolStripSeparator();
                cms.Add(tsp);

                return(null);
            }
            else if (!string.IsNullOrEmpty(text))
            {
                ToolStripMenuItem tsmi = new ToolStripMenuItem(text);
                tsmi.Tag = info;
                if (callback != null)
                {
                    tsmi.Click += callback;
                }
                cms.Add(tsmi);

                return(tsmi);
            }

            return(null);
        }
Exemplo n.º 6
0
        public override bool Initialize(IPluginHost host)
        {
            m_host = host;
            //EntryContextMenu tsMenu =
            ToolStripItemCollection menuItemCollection = m_host.MainWindow.EntryContextMenu.Items;
            //System.Drawing.Image image = new System.Drawing.Bitmap("tmp");

            ToolStripMenuItem cmenuItem = new ToolStripMenuItem();

            cmenuItem.Text   = "Zugangsdaten drucken";
            cmenuItem.Click += CmenuItem_Click;
            menuItemCollection.Add(cmenuItem);

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 添加子菜单
        /// </summary>
        /// <param name="text">要显示的文字,如果为 - 则显示为分割线</param>
        /// <param name="collection">要添加到的子菜单集合</param>
        /// <param name="callback">点击时触发的事件</param>
        /// <returns>生成的子菜单,如果为分隔条则返回null</returns>

        private ToolStripMenuItem AddContextMenu(string text, ToolStripItemCollection collection, EventHandler callback)
        {
            if (!string.IsNullOrEmpty(text))
            {
                ToolStripMenuItem tsmi = new ToolStripMenuItem(text);
                tsmi.Tag = text;
                if (callback != null)
                {
                    tsmi.Click += callback;
                }
                collection.Add(tsmi);
                return(tsmi);
            }
            return(null);
        }
Exemplo n.º 8
0
        public static void Load(object object_0, ToolStripItemCollection toolStripItemCollection_0, string string_0)
        {
            Class120 class2 = PlugInTree.smethod_5(string_0);

            if (class2 != null)
            {
                foreach (object obj2 in class2.method_2(object_0, false))
                {
                    if (obj2 is ToolStripItem)
                    {
                        toolStripItemCollection_0.Add((ToolStripItem)obj2);
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Add template to a specific list
        /// </summary>
        /// <param name="collection">List, where to add template</param>
        /// <param name="template">Template to add</param>
        /// <param name="onClick">Click handlers</param>
        public static void InsertTemplate(ToolStripItemCollection collection, MoneyDataSet.TransactionTemplatesRow template, EventHandler onClick)
        {
            Image image = null;

            if (template.ID.Equals(MoneyDataSet.IDs.TransactionTemplates.Transfer))
            {
                image = Properties.Resources.table_relationship;
            }
            ToolStripMenuItem tsmiFromTemplate = new ToolStripMenuItem(template.Title, image, onClick);

            tsmiFromTemplate.Tag         = template;
            tsmiFromTemplate.ToolTipText = template.Message;

            collection.Add(tsmiFromTemplate);
        }
Exemplo n.º 10
0
        // ReSharper disable once UnusedMethodReturnValue.Local
        private static ToolStripSeparator AddMenuSeparator(ToolStripItemCollection itemsCollection, bool insertToTop = false)
        {
            var separator = new ToolStripSeparator();

            if (insertToTop)
            {
                itemsCollection.Insert(0, separator);
            }
            else
            {
                itemsCollection.Add(separator);
            }

            return(separator);
        }
Exemplo n.º 11
0
        void SyncRecentFilesUI()
        {
            // Synchronize menu items.
            this.parent.Enabled = true;
            this.addingFile     = true;

            try
            {
                ToolStripItemCollection ic = this.parent.DropDownItems;
                ic.Clear();

                // Add most recent files first.
                for (int i = this.recentFiles.Count - 1, j = 0; i >= 0 && j < maxRecentMenuFiles; i--, j++)
                {
                    Uri           uri  = this.recentFiles[i];
                    ToolStripItem item = new ToolStripMenuItem();
                    item.Click += new EventHandler(OnRecentFile);
                    ic.Add(item);
                    item.Text = uri.IsFile ? uri.LocalPath : uri.AbsoluteUri;
                    item.Tag  = uri;
                }

                // Synchronize combo-box items
                this.location.Items.Clear();
                for (int i = this.recentFiles.Count - 1; i >= 0; i--)
                {
                    Uri uri = this.recentFiles[i];
                    this.location.Items.Add(new ComboFileItem(uri));
                }

                if (this.location.Items.Count > 0)
                {
                    this.location.SelectedIndex = 0;
                }

                // sync autocompletion list
                this.location.AutoCompleteCustomSource.Clear();
                for (int i = 0; i < this.location.Items.Count; i++)
                {
                    ComboFileItem item = (ComboFileItem)this.location.Items[i];
                    this.location.AutoCompleteCustomSource.Add(item.ToString());
                }
            }
            finally
            {
                this.addingFile = false;
            }
        }
Exemplo n.º 12
0
        private void addNotifyIconButton(Button button)
        {
            var tsButton = new ToolStripMenuItem();

            tsButton.Text          = button.Text;
            tsButton.Enabled       = button.Enabled;
            button.EnabledChanged += (sender, e) =>
            {
                tsButton.Enabled = button.Enabled;
            };
            tsButton.Click += (sender, e) =>
            {
                button.PerformClick();
            };
            currentToolStripItemCollection.Add(tsButton);
        }
Exemplo n.º 13
0
        public static void AddColorGradientDropDownItems(ToolStripItemCollection itemCollection, EventHandler onClick)
        {
            itemCollection.Clear();
            Array values = Enum.GetValues(typeof(ColorGradientEnum));

            foreach (ColorGradientEnum colorGradient in values)
            {
                Bitmap            bitmap   = GradientBitmap.GenerateBitmap16x16(colorGradient);                  // bitmap implements IDisposable
                ToolStripMenuItem menuItem = new ToolStripMenuItem(colorGradient.GetShowName(), bitmap, onClick) // menuItem implements IDisposable
                {
                    ImageScaling = ToolStripItemImageScaling.None,
                    Tag          = colorGradient
                };
                itemCollection.Add(menuItem);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Adds the element to drop down button.
        /// </summary>
        /// <param name="elementsToList">The elements to list.</param>
        /// <param name="list">The list.</param>
        private static void AddElementToToolStripItemCollection <T>(IEnumerable <Lazy <T, IMetadata> > elementsToList, ToolStripItemCollection list)
        {
            foreach (var contract in elementsToList)
            {
                var name    = contract.Metadata.Name;
                var version = contract.Metadata.Version;
                var id      = contract.Metadata.Id;

                var item = list.Add(name);
                item.ToolTipText = String.Format("{0} {1}", name, version);
                item.Tag         = id;

                // TODO: if there is more than one version, pick the latest
                // TODO: alternatively, if there is more than one version, create a sub menu
            }
        }
Exemplo n.º 15
0
        private ToolStripMenuItem AddItem(ToolStripItemCollection items, Icon icon, string text, object tag)
        {
            ToolStripMenuItem item = new ToolStripMenuItem(text);

            if (icon != null &&
                !_isTerminalServicesSession)
            {
                item.Image        = icon.ToBitmap();
                item.ImageScaling = ToolStripItemImageScaling.None;
            }
            item.Size   = new Size(_menuWidth, 22);
            item.Tag    = tag;
            item.Click += new EventHandler(item_Click);
            items.Add(item);
            return(item);
        }
Exemplo n.º 16
0
        public static ToolStripMenuItem GetSubItem(this ToolStripItemCollection strip, string key)
        {
            ToolStripMenuItem item;

            foreach (ToolStripItem fsjkl in strip)
            {
                if (fsjkl.Name == key && fsjkl is ToolStripMenuItem result)
                {
                    return(result);
                }
            }

            item = new ToolStripMenuItem(key);
            strip.Add(item);
            return(item);
        }
Exemplo n.º 17
0
        public static void AddRangeAbove(this ToolStripItemCollection @self, ToolStripItem[] toolStripItems)
        {
            ContextMenuStrip baseMenu = new ContextMenuStrip();

            while (@self.Count > 0)
            {
                baseMenu.Items.Add(@self[0]);
            }

            @self.Clear();
            @self.AddRange(toolStripItems);
            while (baseMenu.Items.Count > 0)
            {
                @self.Add(baseMenu.Items[0]);
            }
        }
Exemplo n.º 18
0
        private void AddCustomNode(MenuAction <TNode> node, ToolStripItemCollection tsic)
        {
            EventHandler OnClick = (s, e) =>
            {
                Point p = ToGraphSpace(MenuPosition);
                m_mouseController.ForClickedOn(p, n => node.NodeAction(n, p)(), n => node.TransitionAction(n, p), (c, b) => { }, n => node.GroupAction(n, p), () => node.EmptySpaceAction(p));
            };
            ToolStripMenuItem a = new ToolStripMenuItem(node.Name, null, OnClick);

            tsic.Add(a);
            foreach (var n in node.Children)
            {
                AddCustomNode(n, a.DropDownItems);
            }
            m_menuActions[node] = a;
        }
        private ToolStripMenuItem GetParentMenuItem(string nameBefore, ToolStripItemCollection collection)
        {
            var tsiParent = collection.Cast <ToolStripMenuItem>().FirstOrDefault(tsiItem =>
                                                                                 string.Compare(tsiItem.Text, nameBefore, StringComparison.OrdinalIgnoreCase) == 0);

            if (tsiParent != null)
            {
                return(tsiParent);
            }
            tsiParent = new ToolStripMenuItem {
                Text = nameBefore
            };
            collection.Add(tsiParent);

            return(tsiParent);
        }
Exemplo n.º 20
0
        //--------------------------------------------------------------------------------
        private void AddMenuCategorie(CCategorieGED cat, ToolStripItemCollection items)
        {
            ToolStripMenuItem menuCategorie = new ToolStripMenuItem(cat.Libelle);

            menuCategorie.Tag        = cat;
            menuCategorie.MouseDown += new MouseEventHandler(menuCategorie_MouseDown);
            items.Add(menuCategorie);
            if (cat.CategoriesFilles.Count > 0)
            {
                menuCategorie.ToolTipText = I.T("Right clic to affect to @1|20870", cat.Libelle);
            }
            foreach (CCategorieGED subCat in cat.CategoriesFilles)
            {
                AddMenuCategorie(subCat, menuCategorie.DropDownItems);
            }
        }
Exemplo n.º 21
0
        // Ensures that submenus exist to hold command
        private ToolStripItemCollection BuildSubMenus(ToolStripItemCollection commands, CommandInfo info)
        {
            string menuText = info.MenuText;

            string[] segments;
            if (menuText[0] == '@')
            {
                segments = new[] { menuText.Substring(1, menuText.Length - 1) }
            }
            ;
            else
            {
                segments = menuText.Split(s_pathDelimiters, 8);
            }

            for (int i = 0; i < segments.Length - 1; i++)
            {
                string            segment = segments[i];
                ToolStripMenuItem subMenu = null;
                for (int j = 0; j < commands.Count; j++)
                {
                    if (segment == commands[j].Text)
                    {
                        subMenu = commands[j] as ToolStripMenuItem;
                        if (subMenu != null)
                        {
                            break;
                        }
                    }
                }
                if (subMenu == null)
                {
                    subMenu      = new ToolStripMenuItem(segment);
                    subMenu.Name = segment;
                    commands.Add(subMenu);

                    MaintainSeparateGroups(commands, subMenu, info.GroupTag);
                }


                subMenu.BackColor = m_mainMenuStrip.BackColor;
                subMenu.ForeColor = m_mainMenuStrip.ForeColor;
                commands          = subMenu.DropDownItems;
            }

            return(commands);
        }
Exemplo n.º 22
0
        public override bool Loaded()
        {
            but        = new ToolStripMenuItem("Vault Test");
            but.Click += but_Click;
            ToolStripItemCollection col = Host.FDMenuMap.Items;

            col.Add(but);

            vehicle_name          = "GigaRotor 6 v1";
            vehicle_configuration = Host.config["MPConfigDesc", "Default"];
            if (vehicle_configuration?.Length == 0)
            {
                vehicle_configuration = "Default";
            }

            return(true);
        }
Exemplo n.º 23
0
        public virtual void AddBarItem(IWindowsBarItem item, GetPriorityHandler getPriority)
        {
            // Add the item to the sorted list
            BarItemComparer newBarItemComparer = new BarItemComparer(item, getPriority);

            _sortedBarItems.Add(newBarItemComparer, item);
            int index = _sortedBarItems.IndexOfKey(newBarItemComparer) + _reservedItems;

            if (index > _items.Count)
            {
                _items.Add(((IToolStripItemContainer)item).Item);
            }
            else
            {
                _items.Insert(index, ((IToolStripItemContainer)item).Item);
            }
        }
Exemplo n.º 24
0
    public override bool Loaded()
    {
        /* Register with Device Change event */
        Host.DeviceChanged += deviceChanged;
        /* Add to Flight Planner Map Menu */
        ToolStripMenuItem trkrHome = new ToolStripMenuItem(Strings.TrackerHome)
        {
            Name = "trkrHomeMenuItem"
        };
        ToolStripMenuItem obtainFrmMod = new ToolStripMenuItem(Strings.ObtainFromModule);

        obtainFrmMod.Click += setTrackerHomeFromModule;
        ToolStripMenuItem setAtLoc = new ToolStripMenuItem(Strings.SetHere);

        setAtLoc.Click += setFromPlannerLocation;

        trkrHome.DropDownItems.AddRange(new ToolStripItem[] { obtainFrmMod, setAtLoc });

        ToolStripItemCollection col = Host.FPMenuMap.Items;
        int index = col.Count;

        foreach (ToolStripItem item in col)
        {
            if (item.Text.Equals(Strings.TrackerHome))
            {
                index = col.IndexOf(item);
                col.Remove(item);
                break;
            }
        }
        if (index != col.Count)
        {
            col.Insert(index, trkrHome);
        }
        else
        {
            col.Add(trkrHome);
        }

        if (getDevice() != null)
        {
            _Available = true;
        }

        return(true);
    }
Exemplo n.º 25
0
        /// <summary>
        /// 添加子菜单
        /// </summary>
        /// <param name="toolStripItemCollection">要添加到的子菜单集合</param>
        /// <param name="Menutext">菜单按钮显示的文字</param>
        /// <param name="menuClicked">点击时触发的事件</param>
        /// <param name="MenuTag">按钮的Tag属性值,格式:窗体/字段/中文字段名/表名/权限值 </param>
        /// <returns>生成的子菜单,如果为分隔条则返回null</returns>
        public ToolStripMenuItem AddContextMenu(ToolStripItemCollection toolStripItemCollection, string Menutext, EventHandler menuClicked = null, string MenuTag = null)
        {
            if (!string.IsNullOrEmpty(Menutext))
            {
                ToolStripMenuItem tsmi = new ToolStripMenuItem(Menutext);
                if (menuClicked != null)
                {
                    tsmi.Click  += menuClicked;
                    tsmi.Enabled = false;//设置不可点击
                }
                toolStripItemCollection.Add(tsmi);
                tsmi.Tag = MenuTag;

                return(tsmi);
            }
            return(null);
        }
Exemplo n.º 26
0
        private void AudioAnalyzerForm_Load(object sender, EventArgs e)
        {
            GlobalInfo.CreateInstance(this);
            _globalInfo = GlobalInfo.GetInstance();
            _globalInfo.AppStateMachine.RefreshAudioForm();
            Dictionary <string, string> analyzerInfo           = AnalyzerPanelFactory.GetAllAnalyzerNameAndLabel();
            ToolStripItemCollection     analyzerItemCollection = toolStripDropDownButton_selectAnalyzer.DropDownItems;

            foreach (string analyzerClass in analyzerInfo.Keys)
            {
                ToolStripMenuItem analyzerItem = new ToolStripMenuItem(analyzerInfo[analyzerClass]);
                analyzerItem.Tag    = analyzerClass;
                analyzerItem.Click += Analyzer_ToolStripMenuItem_Click;
                analyzerItemCollection.Add(analyzerItem);
            }
            Control.CheckForIllegalCrossThreadCalls = false;
        }
Exemplo n.º 27
0
        public static void AddHandlerToItem(this ToolStripItemCollection strip, string key, Action handler)
        {
            ToolStripItem item;

            foreach (ToolStripItem fsjkl in strip)
            {
                if (fsjkl.Name == key)
                {
                    item = fsjkl;
                    goto skipNew;
                }
            }
            item = new ToolStripMenuItem(key);
            strip.Add(item);
skipNew:
            item.Click += (_, __) => handler();
        }
Exemplo n.º 28
0
        /// <summary>
        /// 递归创建菜单。
        /// </summary>
        /// <param name="menus">WinShellMenu对象列表。</param>
        /// <param name="dropDownItems">菜单列表。</param>
        private void CreateChildMenu(List <WinShellMenu> menus,
                                     ToolStripItemCollection dropDownItems)
        {
            ToolStripMenuItem item;

            foreach (var menu in menus)
            {
                item = (ToolStripMenuItem)dropDownItems.Add(menu.Text,
                                                            LoadImage(menu.Application.Bundle, menu.Icon), MenuClicked);

                // 将WinShellMenu保存到ToolStripMenuItem.Tag中
                item.Tag         = menu;
                item.ToolTipText = menu.Tooltip;

                CreateChildMenu(menu.Children, item.DropDownItems);
            }
        }
Exemplo n.º 29
0
        private void CreateContextMenu()
        {
            _notifyIcon.ContextMenuStrip =
                new ContextMenuStrip();
            _notifyIcon.ContextMenuStrip.Items.Add("Add Reminder").Click += (s, e) => ShowMainWindow();
            ToolStripItem           dropdown     = _notifyIcon.ContextMenuStrip.Items.Add("Add Quick Reminder", null);
            ToolStripItemCollection dropdownItem = (dropdown as ToolStripMenuItem).DropDownItems;

            dropdownItem.Add("5 minutes").Click  += (s, e) => QuickNotification(5);
            dropdownItem.Add("10 minutes").Click += (s, e) => QuickNotification(10);
            dropdownItem.Add("15 minutes").Click += (s, e) => QuickNotification(15);
            dropdownItem.Add("20 minutes").Click += (s, e) => QuickNotification(20);
            dropdownItem.Add("30 minutes").Click += (s, e) => QuickNotification(30);
            dropdownItem.Add("45 minutes").Click += (s, e) => QuickNotification(45);
            dropdownItem.Add("1 hour").Click     += (s, e) => QuickNotification(60);
            dropdownItem.Add("2 hours").Click    += (s, e) => QuickNotification(120);
            _notifyIcon.ContextMenuStrip.Items.Add("Settings").Click += (s, e) => ShowSettings();
            _notifyIcon.ContextMenuStrip.Items.Add("Exit").Click     += (s, e) => ExitApplication();
        }
Exemplo n.º 30
0
        public override bool Loaded()
        {
            var rootbut = new ToolStripMenuItem("Herelink Video");
            //rootbut.Click += but_Click;
            ToolStripItemCollection col = Host.FDMenuHud.Items;

            col.Add(rootbut);

            var but = new ToolStripMenuItem("Connect v1");

            but.Click += but3_Click;
            rootbut.DropDownItems.Add(but);


            but        = new ToolStripMenuItem("Set Video stream 1 v1");
            but.Click += but1_Click;
            rootbut.DropDownItems.Add(but);

            but        = new ToolStripMenuItem("Set Video stream 2 v1");
            but.Click += but2_Click;
            rootbut.DropDownItems.Add(but);

            but        = new ToolStripMenuItem("Connect stream 1 v2");
            but.Click += but7_Click;
            rootbut.DropDownItems.Add(but);

            but        = new ToolStripMenuItem("Connect stream 2 v2");
            but.Click += but8_Click;
            rootbut.DropDownItems.Add(but);


            but        = new ToolStripMenuItem("Connect air 1 v2");
            but.Click += but5_Click;
            rootbut.DropDownItems.Add(but);

            but        = new ToolStripMenuItem("Connect air 2 v2");
            but.Click += but6_Click;
            rootbut.DropDownItems.Add(but);

            but        = new ToolStripMenuItem("Reset Baud");
            but.Click += but9_Click;
            rootbut.DropDownItems.Add(but);

            return(true);
        }
Exemplo n.º 31
0
            private void AddMenuItems(int currGroupIndex, ref int currentListIndex, ToolStripItemCollection currNodes, string prevGroupByField)
            {
                IList innerList = this.m_currencyManager.List;
                System.ComponentModel.PropertyDescriptor pdPrevGroupBy = null;
                string prevGroupByValue = null;

                SPTreeNodeGroup currGroup;

                if (prevGroupByField != "")
                {
                    pdPrevGroupBy = this.m_currencyManager.GetItemProperties()[prevGroupByField];
                }

                currGroupIndex++;

                if (treeGroups.Count > currGroupIndex)
                {
                    currGroup = (SPTreeNodeGroup) (treeGroups[currGroupIndex]);
                    PropertyDescriptor pdGroupBy = null;
                    PropertyDescriptor pdValue = null;
                    PropertyDescriptor pdDisplay = null;

                    pdGroupBy = this.m_currencyManager.GetItemProperties()[currGroup.GroupBy];
                    pdValue = this.m_currencyManager.GetItemProperties()[currGroup.ValueMember];
                    pdDisplay = this.m_currencyManager.GetItemProperties()[currGroup.DisplayMember];

                    string currGroupBy = null;

                    if (innerList.Count > currentListIndex)
                    {
                        if (pdPrevGroupBy != null)
                        {
                            prevGroupByValue = pdPrevGroupBy.GetValue(innerList[currentListIndex]).ToString();
                        }

                        SPMenuStripItem myFirstNode = null;
                        object currObject = null;

                        while ((currentListIndex < innerList.Count) && (pdPrevGroupBy != null) && (pdPrevGroupBy.GetValue(innerList[currentListIndex]).ToString() == prevGroupByValue))
                        {
                            currObject = innerList[currentListIndex];
                            if (pdGroupBy.GetValue(currObject).ToString() != currGroupBy)
                            {
                                currGroupBy = pdGroupBy.GetValue(currObject).ToString();

                                myFirstNode = new SPMenuStripItem(currGroup.Name, pdDisplay.GetValue(currObject).ToString(), currObject, pdValue.GetValue(innerList[currentListIndex]), currGroup.ImageIndex, currentListIndex);

                                currNodes.Add(myFirstNode);
                            }
                            else
                            {
                                AddMenuItems(currGroupIndex, ref currentListIndex, this.Items, currGroup.GroupBy);
                            }
                        }
                    }
                }
                else
                {
                    SPMenuStripItem myNewLeafNode;
                    object currObject = this.m_currencyManager.List[currentListIndex];

                    if ((this.DisplayMember != null) && (this.ValueMember != null) && (this.DisplayMember != "") && (this.ValueMember != ""))
                    {
                        PropertyDescriptor pdDisplayloc = this.m_currencyManager.GetItemProperties()[this.DisplayMember];
                        PropertyDescriptor pdValueloc = this.m_currencyManager.GetItemProperties()[this.ValueMember];

                        if (this.Tag == null)
                        {
                            myNewLeafNode = new SPMenuStripItem("", pdDisplayloc.GetValue(currObject).ToString(), currObject, pdValueloc.GetValue(currObject), currentListIndex);
                        }
                        else
                        {
                            myNewLeafNode = new SPMenuStripItem(this.Tag.ToString(), pdDisplayloc.GetValue(currObject).ToString(), currObject, pdValueloc.GetValue(currObject), currentListIndex);
                        }
                    }
                    else
                    {
                        myNewLeafNode = new SPMenuStripItem("", currentListIndex.ToString(), currObject, currObject, currentListIndex, currentListIndex);
                    }

                    currNodes.Add(myNewLeafNode);
                    currentListIndex++;
                }
            }