Exemplo n.º 1
0
        public static void AddMenuItems(MenuItem.MenuItemCollection items, ListView lv, RetrieveVirtualItemEventHandler retrieveVirtualItem)
        {
            MenuItem copyItem = new MenuItem("Copy")
            {
                Tag = new object[]
                {
                    -1, lv, retrieveVirtualItem
                }
            };

            copyItem.Click += ListViewMenuItem_Click;

            items.Add(copyItem);

            foreach (ColumnHeader ch in lv.Columns)
            {
                MenuItem item = new MenuItem("Copy \"" + ch.Text + "\"")
                {
                    Tag = new object[]
                    {
                        ch.Index, lv, retrieveVirtualItem
                    }
                };

                item.Click += ListViewMenuItem_Click;

                items.Add(item);
            }
        }
Exemplo n.º 2
0
        public static void AddMenuItems(MenuItem.MenuItemCollection items, TreeViewAdv tv)
        {
            MenuItem copyItem = new MenuItem("Copy")
            {
                Tag = new object[]
                {
                    -1, tv
                }
            };

            copyItem.Click += TreeViewAdvMenuItem_Click;

            items.Add(copyItem);

            foreach (TreeColumn c in tv.Columns)
            {
                int controlIndex = 0;
                int index        = -1;

                foreach (NodeControl control in tv.NodeControls)
                {
                    if (control is BaseTextControl && control.ParentColumn == c)
                    {
                        index = controlIndex;
                        break;
                    }

                    controlIndex++;
                }

                if (!c.IsVisible || index == -1)
                {
                    continue;
                }

                MenuItem item = new MenuItem("Copy \"" + c.Header + "\"")
                {
                    Tag = new object[]
                    {
                        index, tv
                    }
                };

                item.Click += TreeViewAdvMenuItem_Click;

                items.Add(item);
            }
        }
Exemplo n.º 3
0
        private void Insert(string text, MenuItem item, int offset)
        {
            for (int i = 0; i < _menuItems.Count; i++)
            {
                if (_menuItems[i].Text.Replace("&", "").Equals(text, StringComparison.InvariantCultureIgnoreCase))
                {
                    _menuItems.Add(i + offset, item);
                    return;
                }
            }

            throw new InvalidOperationException("No menu item exists with the specified text.");
        }
Exemplo n.º 4
0
 /// ////////////////////////////////////////////////////
 private void CreateSousMenu(MenuItem.MenuItemCollection wndMenus, CMenuCustom menu)
 {
     wndMenus.Clear();
     foreach (CMenuCustom menuCustom in menu.ListeMenusFils)
     {
         if (ShouldAffiche(menuCustom))
         {
             MenuItem item = new CMenuItemTimos(menuCustom);
             if (menuCustom.ListeMenusFils.Count != 0)
             {
                 CreateSousMenu(item.MenuItems, menuCustom);
             }
             else
             {
                 item.Click += new EventHandler(OnClickSousMenu);
             }
             wndMenus.Add(item);
         }
     }
 }
Exemplo n.º 5
0
        private void RebuildTrayMenu(List <Status> statuses, List <Comment> comments)
        {
            trayIcon.ContextMenu        = new ContextMenu();
            trayIcon.ContextMenu.Popup += OnRefreshGroup;

            MenuItem.MenuItemCollection menuItems = trayIcon.ContextMenu.MenuItems;

            if (IsCurrentGroupSet())
            {
                menuItems.Add(BuildCurrentGroupMenu());
                menuItems.Add("Attending today: " + GetSizeOf(statuses));
                menuItems.Add("-");

                if (statuses != null && statuses.Count > 0)
                {
                    foreach (var status in statuses)
                    {
                        string participant = status.participant;
                        menuItems.Add(participant);
                    }
                    menuItems.Add("-");
                }
                // http://en.wikipedia.org/wiki/Western_Latin_character_sets_(computing)

                menuItems.Add("\u221A  I'm in", OnReplyYes);
                menuItems.Add("\u00D7  I'm out", OnReplyNo);
                menuItems.Add("-");
                menuItems.Add("\u002B Add comment", OnNewComment);
                menuItems.Add("-");

                if (comments != null && comments.Count > 0)
                {
                    foreach (var comment in comments)
                    {
                        string participant = comment.participant;
                        string commentText = comment.comment;
                        string timestamp   = comment.timestamp;
                        string timezone    = comment.timezone;
                        string localTime   = DateUtils.FormatTime(timestamp, timezone);

                        string commentLabel = localTime + " " + participant + ": " + commentText;
                        menuItems.Add(commentLabel, (EventHandler)OnExistingComment);
                    }
                    menuItems.Add("-");
                }
            }

            menuItems.Add(BuildGroupsMenu());
            menuItems.Add(BuildSettingsMenu());

            menuItems.Add("-");
            menuItems.Add("About", OnAbout);
            menuItems.Add("Exit", OnExit);
        }