Beispiel #1
0
        // ToClientLanuage()
        //       -  Change Language of the form' Text to Client Language
        // Return Value
        //       -  True / False
        // Arguments
        //       -  ByVal mnuItems As Menu.MenuItemCollection
        //
        public static bool ToClientLanguage(Menu.MenuItemCollection mnuItems)
        {
            try
            {
                MenuItem mnuItem;

                foreach (MenuItem tempLoopVar_mnuItem in mnuItems)
                {
                    mnuItem = tempLoopVar_mnuItem;
                    if (mnuItem.Text != "")
                    {
                        mnuItem.Text = FindLanguage(mnuItem.Text, 2);
                    }
                }
            }
            catch (Exception ex)
            {
                CmnFunction.ShowMsgBox("modLanguageFunction.ToClientLanguage()" + "\r\n" + ex.Message, "FMB Client", MessageBoxButtons.OK, 1);
                return(false);
            }

            return(true);
        }
        public void MenuItemCollection_Add_IndexMenuItem_Success()
        {
            var menu       = new SubMenu(new MenuItem[0]);
            var collection = new Menu.MenuItemCollection(menu);

            var menuItem1 = new MenuItem("text1");

            Assert.Equal(0, collection.Add(0, menuItem1));
            Assert.Same(menuItem1, Assert.Single(collection));
            Assert.Equal(menu, menuItem1.Parent);
            Assert.Equal(0, menuItem1.Index);

            var menuItem2 = new MenuItem("text1");

            Assert.Equal(0, collection.Add(0, menuItem2));
            Assert.Equal(2, collection.Count);
            Assert.Same(menuItem2, collection[0]);
            Assert.Same(menuItem1, collection[1]);
            Assert.Equal(menu, menuItem1.Parent);
            Assert.Equal(1, menuItem1.Index);
            Assert.Equal(menu, menuItem2.Parent);
            Assert.Equal(0, menuItem2.Index);
        }
Beispiel #3
0
        /// <summary>
        /// Recursive add method to handle nesting of menu items.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="mi"></param>
        private static void AddMenuItem(Menu.MenuItemCollection parent, SymbologyMenuItem mi)
        {
            MenuItem m;

            if (mi.Icon != null)
            {
                m = new IconMenuItem(mi.Name, mi.Icon, mi.ClickHandler);
            }
            else if (mi.Image != null)
            {
                m = new IconMenuItem(mi.Name, mi.Image, mi.ClickHandler);
            }
            else
            {
                m = new IconMenuItem(mi.Name, mi.ClickHandler);
            }

            parent.Add(m);
            foreach (SymbologyMenuItem child in mi.MenuItems)
            {
                AddMenuItem(m.MenuItems, child);
            }
        }
Beispiel #4
0
        public void MenuItemCollection_Insert_IListInvoke_Success()
        {
            var   menu       = new SubMenu(new MenuItem[0]);
            IList collection = new Menu.MenuItemCollection(menu);

            var menuItem1 = new MenuItem("text1");

            collection.Insert(0, menuItem1);
            Assert.Same(menuItem1, Assert.Single(collection));
            Assert.Equal(menu, menuItem1.Parent);
            Assert.Equal(0, menuItem1.Index);

            var menuItem2 = new MenuItem("text1");

            collection.Insert(0, menuItem2);
            Assert.Equal(2, collection.Count);
            Assert.Same(menuItem2, collection[0]);
            Assert.Same(menuItem1, collection[1]);
            Assert.Equal(menu, menuItem1.Parent);
            Assert.Equal(1, menuItem1.Index);
            Assert.Equal(menu, menuItem2.Parent);
            Assert.Equal(0, menuItem2.Index);
        }
 public override void CreateContextMenu(Menu.MenuItemCollection mnu, EventHandler handler)
 {
     if (_children != null && _children.Count > 0)
     {
         Form    caller = null;
         WebPage wpage  = this.RootPointer.ObjectInstance as WebPage;
         if (wpage != null)
         {
             if (wpage.Parent != null)
             {
                 caller = wpage.Parent.FindForm();
             }
             else
             {
                 caller = wpage;
             }
         }
         for (int i = 0; i < _children.Count; i++)
         {
             HtmlElement_menubar.AddMenuItemHandler(_children[i], mnu, handler, caller);
         }
     }
 }
Beispiel #6
0
        private void menuSortLoop(Menu.MenuItemCollection mc)
        {
            if (mc == null)
            {
                return;
            }
            for (var i = 0; i < mc.Count; i++)
            {
                menuSortLoop(mc[i].MenuItems);
            }
            var mis = new ArrayList();

            foreach (MenuItem mi in mc)
            {
                mis.Add(mi);
            }
            mis.Sort(new Sorter(_menuorder));
            mc.Clear();
            for (var i = 0; i < mis.Count; i++)
            {
                mc.Add((MenuItem)mis[i]);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Populate the Documents dropdown list.
        /// </summary>
        private void PopulateDocuments()
        {
            Menu.MenuItemCollection items =
                documentsMenu.MenuItems;
            foreach (MenuItem item in items)
            {
                item.Click -= new EventHandler(DocumentClick);
            }
            items.Clear();

            foreach (Control ctl in Panel1.Controls)
            {
                if (ctl is WinPart)
                {
                    MenuItem item = new MenuItem();
                    item.Text   = ((WinPart)ctl).ToString();
                    item.Tag    = ctl;
                    item.Click += new EventHandler(DocumentClick);
                    items.Add(item);
                }
            }

            DocumentsToolStripDropDownButton.Update();
        }
Beispiel #8
0
        public static void AddLogMenuItems(Menu.MenuItemCollection pParent, AemInstance pInstance)
        {
            List <MenuItem> menuItems = new List <MenuItem>();
            MenuItem        item;

            // show dynamic list of current logfiles
            item        = new MenuItem();
            item.Text   = "Open logfile...";
            item.Popup += LogFilesItem_Popup;
            item.MenuItems.Add(new MenuItem("-- No logfiles --"));
            menuItems.Add(item);

            item        = new MenuItem();
            item.Text   = "Console window";
            item.Click += new EventHandler(ShowConsoleWindow);
            menuItems.Add(item);

            foreach (MenuItem i in menuItems)
            {
                i.Tag = pInstance;
            }

            pParent.AddRange(menuItems.ToArray());
        }
Beispiel #9
0
        /* ****************************************************
        *	I need a search function to modify a NiceMenu item
        *  at runtime (for Context menu)
        * ****************************************************/
        public NiceMenu SearchContextNiceMenuItem(string ContextNiceMenuText)
        {
            contModifyContext = 0;
repeat:
            // ---------------------------------------
            if (myModifyContextNiceMenu[contModifyContext].Text
                == ContextNiceMenuText)
            {
                return(myModifyContextNiceMenu[contModifyContext]);
            }
            // --------------------------------------------
            IList myMenuList = new Menu.MenuItemCollection(myModifyContextNiceMenu[contModifyContext]);

            foreach (NiceMenu myMenuItem in myMenuList)
            {
                if (myMenuItem.Text == ContextNiceMenuText)
                {
                    contModifyContext++;
                    return(myMenuItem);
                }
            }
            contModifyContext++;
            goto repeat;
        }
Beispiel #10
0
        public static void AddSeparator(this Menu.MenuItemCollection items)
        {
            var item = new MenuItem("-");

            items.Add(item);
        }
Beispiel #11
0
        private void AddMenuItems(MobileRemoteUI parentForm, Bitmap expand, Bitmap menuDown, Bitmap menuUp, Font font, List <ImageLabel> labels, int y, Menu.MenuItemCollection menuItems, IList container)
        {
            _clickedButton = null;
            foreach (MenuItem menuItem in menuItems)
            {
                // TODO: handle disabled menu items
                ImageLabel label = new ImageLabel(this);
                label.Height         = (int)(60 * MobileRemoteUI.ScaleFactor.Height);
                label.Width          = this.Width + 4;
                label.Anchor         = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                label.Location       = new Point(-2, y);
                label.Click         += new EventHandler(label_Click);
                label.Text           = menuItem.Text.Replace("&", "");
                label.Font           = font;
                label.MenuItem       = menuItem;
                label.SelectedImage  = menuDown;
                label.RegularImage   = menuUp;
                label.ExpandImage    = expand;
                label.ItemActivated += new EventHandler(label_ItemActivated);
                label.Tag            = menuItem;

                labels.Add(label);

                if (labels != container)
                {
                    container.Add(label);
                }

                y += label.Height + 1;
            }
        }
Beispiel #12
0
        /* ***********************************************************
        *		BuildMenuTree (IList myMenu, MenuItem parentMenu)
        * -----------------------------------------------------------
        *		build the new submenu item
        * ***********************************************************/
        private void BuildMenuTree(IList myMenu, MenuItem parentMenu, NiceMenuClickEvent yourClickFunction)
        {
            foreach (MenuItem myMenuItem in myMenu)
            {
                // Declaration
                NiceMenu newSubMenu;

                string IndexImage   = "";
                bool   AddMenuImage = false;

                /* If in the first two characters of the menu item text
                 * there is a number I set AddMenuImage = true and the
                 * IndexImage to get the icon in the image list control. */
                if (myMenuItem.Text.Length > 2)
                {
                    IndexImage = myMenuItem.Text.Substring(0, 2);
                    if (Char.IsNumber(IndexImage, 1) == true)
                    {
                        AddMenuImage = true;
                        // I have to delete first two characters
                        myMenuItem.Text = myMenuItem.Text.Substring(2);
                    }
                }
                if (AddMenuImage == true)
                {
                    newSubMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut, MenuImages.Images[Convert.ToInt32(IndexImage)]);
                }
                else
                {
                    newSubMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut);
                }
                // I add the new menu item to its parent
                parentMenu.MenuItems.Add(newSubMenu);
                // Checked
                if (myMenuItem.Checked == true)
                {
                    newSubMenu.Checked = true;
                }
                // RadioCheck
                if (myMenuItem.RadioCheck == true)
                {
                    if (myMenuItem.Checked == true)
                    {
                        newSubMenu.RadioCheck = true;
                    }
                }
                // DefaultItem
                if (myMenuItem.DefaultItem == true)
                {
                    newSubMenu.DefaultItem = true;
                }
                // Enabled
                if (myMenuItem.Enabled == false)
                {
                    newSubMenu.Enabled = false;
                }
                // If this menu item contains child menu items
                if (myMenuItem.IsParent == true)
                {
                    IList mySubMenu = new Menu.MenuItemCollection(myMenuItem);
                    BuildMenuTree(mySubMenu, newSubMenu, yourClickFunction);
                }
            }
        }
Beispiel #13
0
        private void m_CreateMenuInfo(Menu owner)
        {
            m_Language        = m_GetLanguageFromCulture(eAntForm.preferences.GetString("Language"));
            m_ShowAllLanguage = eAntForm.preferences.GetBool("ShowAllLanguages", true);
            m_Owner           = owner;
            Actions           = new Hashtable();
            MenuItems         = new Menu.MenuItemCollection(owner);
            MenuItem menu;

            try
            {
                ShowAllLanguageMenuItem             = new MenuItem(eAntForm.Globalization["LBL_SHOW_ALL_LANGUAGES"], new EventHandler(ShowAllLanguageMenuItem_Click));
                ShowAllLanguageMenuItem.DefaultItem = true;
                ShowAllLanguageMenuItem.Checked     = m_ShowAllLanguage;
                MenuItems.Add(ShowAllLanguageMenuItem);

                menu = new MenuItem("-");
                MenuItems.Add(menu);

                XmlDocument doc = new XmlDocument();
                doc.Load(Application.StartupPath + Path.DirectorySeparatorChar + "webSearchs.xml");
                XmlNodeList nodes = doc.DocumentElement["Searchs"].ChildNodes;
                foreach (XmlElement el in nodes)
                {
                    if (el.Name == "Search")
                    {
                        if ((el.Attributes.Count > 2) &&
                            (el.Attributes["SiteName"].InnerText != "") &&
                            (el.Attributes["URL"].InnerText != "") &&
                            (el.Attributes["Language"].InnerText != ""))
                        {
                            String NodeLanguage = el.Attributes["Language"].InnerText;
                            if (!m_ShowAllLanguage && NodeLanguage != m_Language && NodeLanguage != "All")
                            {
                                m_DisplayBar = false;
                            }
                            else
                            {
                                m_DisplayBar = true;
                                menu         = new MenuItem(el.Attributes["SiteName"].InnerText + "\t(" + el.Attributes["Language"].InnerText + ")", new EventHandler(OnItemClicked));
                                MenuItems.Add(menu);
                                Actions.Add(menu, el.Attributes["URL"].InnerText);
                            }
                        }
                        else if (m_DisplayBar && el.Attributes["SiteName"].InnerText == "-")
                        {
                            menu = new MenuItem("-");
                            MenuItems.Add(menu);
                        }
                    }
                }

                if (MenuItems[MenuItems.Count - 1].Text == "-")
                {
                    MenuItems.RemoveAt(MenuItems.Count - 1);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
        private void FormBugSubmissions_Load(object sender, EventArgs e)
        {
            SetFilterControlsAndAction(() => FillSubGrid(),
                                       textDevNoteFilter, textPatNums, textStackFilter, textMsgText, textCategoryFilters, listShowHideOptions);
            switch (_viewMode)
            {
            case FormBugSubmissionMode.AddBug:
                dateRangePicker.SetDateTimeFrom(DateTime.Today.AddDays(-60));
                dateRangePicker.SetDateTimeTo(DateTime.Today);
                break;

            case FormBugSubmissionMode.ViewOnly:
                dateRangePicker.SetDateTimeFrom(DateTime.MinValue);
                dateRangePicker.SetDateTimeTo(DateTime.MaxValue.AddDays(-1));                        //Subtract a day for DbHelper.DateTConditionColumn(...)
                butAddJob.Visible = false;
                listShowHideOptions.SetSelected(1, true);
                break;

            case FormBugSubmissionMode.SelectionMode:
                dateRangePicker.SetDateTimeFrom(DateTime.MinValue);
                dateRangePicker.SetDateTimeTo(DateTime.MaxValue.AddDays(-1)); //Subtract a day for DbHelper.DateTConditionColumn(...)
                butAddJob.Text = "OK";                                        //On click the selected rows are saved and this form will close.
                break;

            case FormBugSubmissionMode.ValidationMode:
                dateRangePicker.SetDateTimeFrom(DateTime.MinValue);
                dateRangePicker.SetDateTimeTo(DateTime.MaxValue.AddDays(-1));                        //Subtract a day for DbHelper.DateTConditionColumn(...)
                butAddJob.Text = "OK";
                listShowHideOptions.SetSelected(1, true);
                groupFilters.Enabled = false;
                break;
            }
            bugSubmissionControl.TextDevNoteLeave            += textDevNote_PostLeave;
            bugSubmissionControl.OnGridCustomerSubsCellClick += customerSubsGridClick;
            #region comboGrouping
            comboGrouping.Items.Add("None");
            comboGrouping.Items.Add("RegKey/Ver/Stack");
            comboGrouping.Items.Add("StackTrace");
            comboGrouping.Items.Add("95%");
            comboGrouping.Items.Add("StackSig");
            comboGrouping.Items.Add("StackSimple");
            comboGrouping.Items.Add("Hash");
            switch (_viewMode)
            {
            case FormBugSubmissionMode.AddBug:
                comboGrouping.SelectedIndex = 2;                      //Default to StackTrace.
                break;

            case FormBugSubmissionMode.SelectionMode:
            case FormBugSubmissionMode.ValidationMode:
            case FormBugSubmissionMode.ViewOnly:
                comboGrouping.SelectedIndex = 0;                      //Default to None.
                break;
            }
            #endregion
            #region comboSortBy
            comboSortBy.Items.Add("Vers./Count");
            comboSortBy.SelectedIndex = 0;          //Default to Vers./Count
            #endregion
            #region Right Click Menu
            ContextMenu             gridSubMenu        = new ContextMenu();
            Menu.MenuItemCollection menuItemCollection = new Menu.MenuItemCollection(gridSubMenu);
            List <MenuItem>         listMenuItems      = new List <MenuItem>();
            listMenuItems.Add(new MenuItem(Lan.g(this, "Open Submission"), new EventHandler(gridSubs_RightClickHelper)));
            listMenuItems.Add(new MenuItem(Lan.g(this, "Open Bug"), new EventHandler(gridSubs_RightClickHelper)));          //Enabled by default
            listMenuItems.Add(new MenuItem(Lan.g(this, "Hide"), new EventHandler(gridSubs_RightClickHelper)));
            listMenuItems.Add(new MenuItem(Lan.g(this, "Link Bug"), new EventHandler(gridSubs_RightClickHelper)));
            menuItemCollection.AddRange(listMenuItems.ToArray());
            gridSubMenu.Popup += new EventHandler((o, ea) => {
                int index             = gridSubs.GetSelectedIndex();
                bool isSingleSubRow   = false;
                bool isOpenBugEnabled = false;
                if (index != -1 && gridSubs.SelectedIndices.Count() == 1)
                {
                    BugSubmission bugSub          = ((List <BugSubmission>)gridSubs.ListGridRows[index].Tag).First();
                    isSingleSubRow                = true;
                    isOpenBugEnabled              = (bugSub.BugId != 0);
                    gridSubMenu.MenuItems[2].Text = (bugSub.IsHidden?"Unhide":"Hide");
                    gridSubMenu.MenuItems[3].Text = (isOpenBugEnabled?"UnLink Bug":"Link Bug");
                }
                gridSubMenu.MenuItems[0].Enabled = isSingleSubRow;    //Open Submission
                gridSubMenu.MenuItems[1].Enabled = isOpenBugEnabled;  //Open Bug
                gridSubMenu.MenuItems[2].Enabled = true;              //Hide or Unhide Submissions always an option, even with multiple rows.
                gridSubMenu.MenuItems[3].Enabled = true;              //Link or Unlink bug always an option, even with multiple rows.
            });
            gridSubs.ContextMenu = gridSubMenu;
            #endregion
            FillVersionsFilter();
            FillSubGrid(true);
        }
Beispiel #15
0
        public void MenuItemCollection_IndexOf_IListInvoke_ReturnsExpected(Menu menu, MenuItem value, int expected)
        {
            IList collection = new Menu.MenuItemCollection(menu);

            Assert.Equal(expected, collection.IndexOf(value));
        }
Beispiel #16
0
        private void FormBugSubmissions_Load(object sender, EventArgs e)
        {
            switch (_viewMode)
            {
            case FormBugSubmissionMode.AddBug:
                dateRangePicker.SetDateTimeFrom(DateTime.Today.AddDays(-60));
                dateRangePicker.SetDateTimeTo(DateTime.Today);
                break;

            case FormBugSubmissionMode.ViewOnly:
                dateRangePicker.SetDateTimeFrom(DateTime.MinValue);
                dateRangePicker.SetDateTimeTo(DateTime.MaxValue.AddDays(-1));                        //Subtract a day for DbHelper.DateTConditionColumn(...)
                butAddJob.Visible         = false;
                checkShowAttached.Checked = true;
                break;

            case FormBugSubmissionMode.SelectionMode:
                dateRangePicker.SetDateTimeFrom(DateTime.MinValue);
                dateRangePicker.SetDateTimeTo(DateTime.MaxValue.AddDays(-1)); //Subtract a day for DbHelper.DateTConditionColumn(...)
                butAddJob.Text = "OK";                                        //On click the selected rows are saved and this form will close.
                break;

            case FormBugSubmissionMode.ValidationMode:
                dateRangePicker.SetDateTimeFrom(DateTime.MinValue);
                dateRangePicker.SetDateTimeTo(DateTime.MaxValue.AddDays(-1));                        //Subtract a day for DbHelper.DateTConditionColumn(...)
                butAddJob.Text            = "OK";
                checkShowAttached.Checked = true;
                groupFilters.Enabled      = false;
                break;
            }
            bugSubmissionControl.TextDevNoteLeave += textDevNote_PostLeave;
            #region comboGrouping
            comboGrouping.Items.Add("None");
            comboGrouping.Items.Add("RegKey/Ver/Stack");
            comboGrouping.Items.Add("StackTrace");
            comboGrouping.Items.Add("95%");
            switch (_viewMode)
            {
            case FormBugSubmissionMode.AddBug:
                comboGrouping.SelectedIndex = 2;                      //Default to StackTrace.
                break;

            case FormBugSubmissionMode.SelectionMode:
            case FormBugSubmissionMode.ValidationMode:
            case FormBugSubmissionMode.ViewOnly:
                comboGrouping.SelectedIndex = 0;                      //Default to None.
                break;
            }
            #endregion
            #region comboSortBy
            comboSortBy.Items.Add("Vers./Count");
            comboSortBy.SelectedIndex = 0;          //Default to Vers./Count
            #endregion
            #region Right Click Menu
            ContextMenu             gridSubMenu        = new ContextMenu();
            Menu.MenuItemCollection menuItemCollection = new Menu.MenuItemCollection(gridSubMenu);
            List <MenuItem>         listMenuItems      = new List <MenuItem>();
            listMenuItems.Add(new MenuItem(Lan.g(this, "Open Submission"), new EventHandler(gridClaimDetails_RightClickHelper)));
            listMenuItems.Add(new MenuItem(Lan.g(this, "Open Bug"), new EventHandler(gridClaimDetails_RightClickHelper)));          //Enabled by default
            menuItemCollection.AddRange(listMenuItems.ToArray());
            gridSubMenu.Popup += new EventHandler((o, ea) => {
                int index             = gridSubs.GetSelectedIndex();
                bool isOpenSubEnabled = false;
                bool isOpenBugEnabled = false;
                if (index != -1 && gridSubs.SelectedIndices.Count() == 1)
                {
                    BugSubmission bugSub = ((List <BugSubmission>)gridSubs.Rows[index].Tag).First();
                    isOpenSubEnabled     = true;
                    isOpenBugEnabled     = (bugSub.BugId != 0);
                }
                gridSubMenu.MenuItems[0].Enabled = isOpenSubEnabled;              //Open Submission
                gridSubMenu.MenuItems[1].Enabled = isOpenBugEnabled;              //Open Bug
            });
            gridSubs.ContextMenu = gridSubMenu;
            #endregion
            FillSubGrid(true);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_btnActions_Click(object sender, System.EventArgs e)
        {
            CListeObjetsDonnees listeCheckes = m_panelListe.GetElementsCheckes();

            if (listeCheckes.Count == 0)
            {
                CFormAlerte.Afficher(I.T("No element selected for action execution|1011"), EFormAlerteType.Exclamation);
                return;
            }

            CDonneesActeurUtilisateur user = CUtilSession.GetUserForSession(m_panelListe.ListeObjets.ContexteDonnee);
            bool bIsAdmin = user != null && user.GetDonneeDroit(CDroitDeBaseSC2I.c_droitAdministrationSysteme) != null;

            Hashtable listeActions = new Hashtable();

            using (CWaitCursor curseur = new CWaitCursor())
            {
                bool bFirst = true;
                //Cherche les actions applicables à tous les éléments
                foreach (CObjetDonneeAIdNumerique objet in listeCheckes)
                {
                    IDeclencheurAction[] declencheurs = CRecuperateurDeclencheursActions.GetActionsManuelles(objet, false);
                    Hashtable            newTbl       = new Hashtable();
                    foreach (IDeclencheurAction declencheur in declencheurs)
                    {
                        if (bFirst || listeActions[declencheur] != null)
                        {
                            newTbl[declencheur] = true;
                        }
                    }
                    bFirst = false;
                    if (newTbl.Count == 0 && !bIsAdmin)
                    {
                        CFormAlerte.Afficher(I.T("There is no action to execute on the selected elements|1012"), EFormAlerteType.Exclamation);
                        return;
                    }
                    listeActions = newTbl;
                }
            }
            m_menuActions.MenuItems.Clear();
            foreach (IDeclencheurAction declencheur in listeActions.Keys)
            {
                string strMenu = "";
                if (declencheur is IDeclencheurActionManuelle)
                {
                    strMenu = ((IDeclencheurActionManuelle)declencheur).MenuManuel;
                }
                string[] strMenus = strMenu.Split('/');
                Menu.MenuItemCollection listeSousMenus = m_menuActions.MenuItems;
                if (strMenus.Length > 0)
                {
                    foreach (string strSousMenu in strMenus)
                    {
                        if (strSousMenu.Trim().Length > 0)
                        {
                            MenuItem sousMenu = null;
                            foreach (MenuItem item in listeSousMenus)
                            {
                                if (item.Text == strSousMenu)
                                {
                                    sousMenu = item;
                                    break;
                                }
                            }
                            if (sousMenu == null)
                            {
                                sousMenu = new MenuItem(strSousMenu);
                                listeSousMenus.Add(sousMenu);
                            }
                            listeSousMenus = sousMenu.MenuItems;
                        }
                    }
                }
                CMenuItemDeclencheur itemAction = new CMenuItemDeclencheur(declencheur);
                itemAction.Click += new EventHandler(MenuDeclencheurClick);
                listeSousMenus.Add(itemAction);
            }

            if (bIsAdmin)
            {
                m_menuActions.MenuItems.Add(new MenuItem());
                MenuItem itemApplyFormula = new MenuItem(I.T("Apply formula|20834"));
                m_menuActions.MenuItems.Add(itemApplyFormula);
                itemApplyFormula.Click += new EventHandler(itemApplyFormula_Click);
            }
            m_menuActions.Show(m_btnActions, new Point(0, m_btnActions.Height));
        }
        private void InitializeComponent()
        {
            this.MainMenu1          = new MainMenu();
            this.MenuItem1          = new MenuItem();
            this.MenuDragonPath     = new MenuItem();
            this.MenuDragonFile     = new MenuItem();
            this.MenuItem2          = new MenuItem();
            this.MenuUOLPath        = new MenuItem();
            this.MenuUOLProjectName = new MenuItem();
            this.MenuConv           = new MenuItem();
            this.Label1             = new Label();
            this.DragonPath         = new TextBox();
            this.Label2             = new Label();
            this.DragonImage        = new TextBox();
            this.GroupBox1          = new GroupBox();
            this.Label3             = new Label();
            this.ComboBox1          = new ComboBox();
            this.GroupBox2          = new GroupBox();
            this.Label4             = new Label();
            this.ProjectPath        = new TextBox();
            this.Label5             = new Label();
            this.ProjectName        = new TextBox();
            this.Label7             = new Label();
            this.TerrainFile        = new TextBox();
            this.Label6             = new Label();
            this.AltitudeFile       = new TextBox();
            this.ProgressBar1       = new ProgressBar();
            this.GroupBox1.SuspendLayout();
            this.GroupBox2.SuspendLayout();
            this.SuspendLayout();
            Menu.MenuItemCollection menuItems = this.MainMenu1.get_MenuItems();
            MenuItem[] menuItem1 = new MenuItem[] { this.MenuItem1, this.MenuItem2, this.MenuConv };
            menuItems.AddRange(menuItem1);
            this.MenuItem1.set_Index(0);
            Menu.MenuItemCollection menuItemCollection = this.MenuItem1.get_MenuItems();
            menuItem1 = new MenuItem[] { this.MenuDragonPath, this.MenuDragonFile };
            menuItemCollection.AddRange(menuItem1);
            this.MenuItem1.set_Text("Dragon");
            this.MenuDragonPath.set_Index(0);
            this.MenuDragonPath.set_Text("Select Path");
            this.MenuDragonFile.set_Index(1);
            this.MenuDragonFile.set_Text("Select Map File");
            this.MenuItem2.set_Index(1);
            Menu.MenuItemCollection menuItems1 = this.MenuItem2.get_MenuItems();
            menuItem1 = new MenuItem[] { this.MenuUOLPath, this.MenuUOLProjectName };
            menuItems1.AddRange(menuItem1);
            this.MenuItem2.set_Text("UO Landscaper");
            this.MenuUOLPath.set_Index(0);
            this.MenuUOLPath.set_Text("Select Path");
            this.MenuUOLProjectName.set_Index(1);
            this.MenuUOLProjectName.set_Text("Select Project Name");
            this.MenuConv.set_Index(2);
            this.MenuConv.set_Text("Convert");
            this.Label1.set_AutoSize(true);
            Label label1 = this.Label1;
            Point point  = new Point(8, 16);

            label1.set_Location(point);
            this.Label1.set_Name("Label1");
            Label label = this.Label1;
            Size  size  = new Size(27, 16);

            label.set_Size(size);
            this.Label1.set_TabIndex(0);
            this.Label1.set_Text("Path");
            TextBox dragonPath = this.DragonPath;

            point = new Point(24, 32);
            dragonPath.set_Location(point);
            this.DragonPath.set_Name("DragonPath");
            TextBox textBox = this.DragonPath;

            size = new Size(240, 20);
            textBox.set_Size(size);
            this.DragonPath.set_TabIndex(1);
            this.DragonPath.set_Text("");
            this.Label2.set_AutoSize(true);
            Label label2 = this.Label2;

            point = new Point(8, 56);
            label2.set_Location(point);
            this.Label2.set_Name("Label2");
            Label label21 = this.Label2;

            size = new Size(61, 16);
            label21.set_Size(size);
            this.Label2.set_TabIndex(2);
            this.Label2.set_Text("Map Image");
            TextBox dragonImage = this.DragonImage;

            point = new Point(24, 72);
            dragonImage.set_Location(point);
            this.DragonImage.set_Name("DragonImage");
            TextBox dragonImage1 = this.DragonImage;

            size = new Size(104, 20);
            dragonImage1.set_Size(size);
            this.DragonImage.set_TabIndex(3);
            this.DragonImage.set_Text("");
            this.GroupBox1.get_Controls().Add(this.Label3);
            this.GroupBox1.get_Controls().Add(this.Label1);
            this.GroupBox1.get_Controls().Add(this.DragonPath);
            this.GroupBox1.get_Controls().Add(this.DragonImage);
            this.GroupBox1.get_Controls().Add(this.Label2);
            this.GroupBox1.get_Controls().Add(this.ComboBox1);
            GroupBox groupBox1 = this.GroupBox1;

            point = new Point(8, 8);
            groupBox1.set_Location(point);
            this.GroupBox1.set_Name("GroupBox1");
            GroupBox groupBox = this.GroupBox1;

            size = new Size(272, 144);
            groupBox.set_Size(size);
            this.GroupBox1.set_TabIndex(4);
            this.GroupBox1.set_TabStop(false);
            this.GroupBox1.set_Text("Dragon Image Info");
            this.Label3.set_AutoSize(true);
            Label label3 = this.Label3;

            point = new Point(8, 96);
            label3.set_Location(point);
            this.Label3.set_Name("Label3");
            Label label31 = this.Label3;

            size = new Size(93, 16);
            label31.set_Size(size);
            this.Label3.set_TabIndex(4);
            this.Label3.set_Text("Select MOD Type");
            ComboBox comboBox1 = this.ComboBox1;

            point = new Point(24, 112);
            comboBox1.set_Location(point);
            this.ComboBox1.set_Name("ComboBox1");
            ComboBox comboBox = this.ComboBox1;

            size = new Size(136, 21);
            comboBox.set_Size(size);
            this.ComboBox1.set_TabIndex(7);
            this.GroupBox2.get_Controls().Add(this.Label4);
            this.GroupBox2.get_Controls().Add(this.ProjectPath);
            this.GroupBox2.get_Controls().Add(this.Label5);
            this.GroupBox2.get_Controls().Add(this.ProjectName);
            this.GroupBox2.get_Controls().Add(this.Label7);
            this.GroupBox2.get_Controls().Add(this.TerrainFile);
            this.GroupBox2.get_Controls().Add(this.Label6);
            this.GroupBox2.get_Controls().Add(this.AltitudeFile);
            GroupBox groupBox2 = this.GroupBox2;

            point = new Point(8, 160);
            groupBox2.set_Location(point);
            this.GroupBox2.set_Name("GroupBox2");
            GroupBox groupBox21 = this.GroupBox2;

            size = new Size(272, 184);
            groupBox21.set_Size(size);
            this.GroupBox2.set_TabIndex(5);
            this.GroupBox2.set_TabStop(false);
            this.GroupBox2.set_Text("UO Landscaper Info");
            this.Label4.set_AutoSize(true);
            Label label4 = this.Label4;

            point = new Point(8, 16);
            label4.set_Location(point);
            this.Label4.set_Name("Label4");
            Label label41 = this.Label4;

            size = new Size(31, 16);
            label41.set_Size(size);
            this.Label4.set_TabIndex(35);
            this.Label4.set_Text("Path:");
            TextBox projectPath = this.ProjectPath;

            point = new Point(24, 32);
            projectPath.set_Location(point);
            this.ProjectPath.set_Name("ProjectPath");
            TextBox projectPath1 = this.ProjectPath;

            size = new Size(240, 20);
            projectPath1.set_Size(size);
            this.ProjectPath.set_TabIndex(34);
            this.ProjectPath.set_Text("");
            this.Label5.set_AutoSize(true);
            Label label5 = this.Label5;

            point = new Point(8, 56);
            label5.set_Location(point);
            this.Label5.set_Name("Label5");
            Label label51 = this.Label5;

            size = new Size(73, 16);
            label51.set_Size(size);
            this.Label5.set_TabIndex(51);
            this.Label5.set_Text("Project Name");
            TextBox projectName = this.ProjectName;

            point = new Point(24, 72);
            projectName.set_Location(point);
            this.ProjectName.set_Name("ProjectName");
            TextBox projectName1 = this.ProjectName;

            size = new Size(136, 20);
            projectName1.set_Size(size);
            this.ProjectName.set_TabIndex(52);
            this.ProjectName.set_Text("");
            this.Label7.set_AutoSize(true);
            Label label7 = this.Label7;

            point = new Point(8, 96);
            label7.set_Location(point);
            this.Label7.set_Name("Label7");
            this.Label7.set_TabIndex(57);
            this.Label7.set_Text("Terrain Image Map");
            TextBox terrainFile = this.TerrainFile;

            point = new Point(24, 112);
            terrainFile.set_Location(point);
            this.TerrainFile.set_Name("TerrainFile");
            TextBox terrainFile1 = this.TerrainFile;

            size = new Size(104, 20);
            terrainFile1.set_Size(size);
            this.TerrainFile.set_TabIndex(54);
            this.TerrainFile.set_Text("Terrain.bmp");
            this.Label6.set_AutoSize(true);
            Label label6 = this.Label6;

            point = new Point(8, 136);
            label6.set_Location(point);
            this.Label6.set_Name("Label6");
            Label label61 = this.Label6;

            size = new Size(102, 16);
            label61.set_Size(size);
            this.Label6.set_TabIndex(58);
            this.Label6.set_Text("Altitude Image Map");
            TextBox altitudeFile = this.AltitudeFile;

            point = new Point(24, 152);
            altitudeFile.set_Location(point);
            this.AltitudeFile.set_Name("AltitudeFile");
            TextBox altitudeFile1 = this.AltitudeFile;

            size = new Size(104, 20);
            altitudeFile1.set_Size(size);
            this.AltitudeFile.set_TabIndex(56);
            this.AltitudeFile.set_Text("Altitude.bmp");
            this.ProgressBar1.set_Dock(2);
            ProgressBar progressBar1 = this.ProgressBar1;

            point = new Point(0, 351);
            progressBar1.set_Location(point);
            this.ProgressBar1.set_Name("ProgressBar1");
            ProgressBar progressBar = this.ProgressBar1;

            size = new Size(286, 16);
            progressBar.set_Size(size);
            this.ProgressBar1.set_TabIndex(6);
            size = new Size(5, 13);
            this.set_AutoScaleBaseSize(size);
            this.set_BackColor(Color.FromArgb(224, 224, 224));
            size = new Size(286, 367);
            this.set_ClientSize(size);
            this.get_Controls().Add(this.ProgressBar1);
            this.get_Controls().Add(this.GroupBox2);
            this.get_Controls().Add(this.GroupBox1);
            this.set_FormBorderStyle(2);
            this.set_Menu(this.MainMenu1);
            this.set_Name("DragonConv");
            this.set_Text("Dragon to UO Landscaper Image Convertor");
            this.GroupBox1.ResumeLayout(false);
            this.GroupBox2.ResumeLayout(false);
            this.ResumeLayout(false);
        }
 public MenuItemCollectionWin(Menu.MenuItemCollection menuItemCollection)
 {
     _menuItemCollection = menuItemCollection;
 }
Beispiel #20
0
        //增加右鍵選單的選項
        static public void ADDMENUITEM(string name, string script)
        {
            if (script == "")
            {
                return;
            }


            //如果未有增加過選項, 首先增加分隔線
            if (notifyIcon.ContextMenu.MenuItems.Count == 5)
            {
                notifyIcon.ContextMenu.MenuItems.Add(3, new MenuItem("-"));
            }

            // 處理子選單的語法 A>B
            string[] parsed = name.Split('>');

            //取得上級選單
            Menu.MenuItemCollection parent = notifyIcon.ContextMenu.MenuItems;

            //創建子選單
            bool itemExist = false;

            for (int i = 0; i < parsed.Length - 1; i++)
            {
                itemExist = false;
                foreach (MenuItem item in parent)
                {
                    if (item.Text == Localization.GetMessage(parsed[i], parsed[i]))
                    {
                        parent    = item.MenuItems;
                        itemExist = true;
                        break;
                    }
                }
                if (!itemExist)
                {
                    MenuItem item = new MenuItem(Localization.GetMessage(parsed[i], parsed[i]));
                    if (i == 0)
                    {
                        parent.Add(3, item);
                    }
                    else
                    {
                        parent.Add(item);
                    }
                    parent = item.MenuItems;
                }
            }


            MenuItem itm = new MenuItem(Localization.GetMessage(parsed[parsed.Length - 1], parsed[parsed.Length - 1]));

            itm.Name = script.Replace('.', '_');

            itm.Click += new EventHandler(itm_Click);


            //如果不是子選單選項, 則加在分隔線下
            if (parsed.Length == 1)
            {
                notifyIcon.ContextMenu.MenuItems.Add(3, itm);
            }
            else
            {
                parent.Add(itm);
            }
        }
Beispiel #21
0
 public static void AddActions(this Menu.MenuItemCollection items, params MenuAction[] actions)
 {
     AddActions(items, (IEnumerable <MenuAction>)actions);
 }
Beispiel #22
0
 public MenuActionManager(Menu.MenuItemCollection menuItems, bool disableUnmatchingTypeActions)
 {
     _menuItems = menuItems;
     _disableUnmatchingTypeActions = disableUnmatchingTypeActions;
 }
Beispiel #23
0
        public void MenuItemCollection_Contains_IListInvoke_ReturnsExpected(Menu menu, MenuItem value, bool expected)
        {
            IList collection = new Menu.MenuItemCollection(menu);

            Assert.Equal(expected, collection.Contains(value));
        }
Beispiel #24
0
        /**
         * Fills the menu with actions, depending on the specified context.
         */

        public void FillMenu(IActionContext context)
        {
            if (_persistentMnemonics)
            {
                if (!_mnemonicsAssigned)
                {
                    AssignMnemonics();
                    _mnemonicsAssigned = true;
                }
            }
            else
            {
                ResetUsedMnemonics();
            }
            _lastContext = context;

            MenuActionGroup lastGroup = null;

            MenuItem curSubmenu = null;

            Menu.MenuItemCollection curMenuItems = _menuItems;

            _menuItems.Clear();
            _itemToActionMap.Clear();
            HashSet usedShortcuts = new HashSet();
            int     submenuVisibleActions = 0, submenuEnabledActions = 0;
            bool    haveDefaultAction = false;

            string[] resTypes = context.SelectedResources.GetAllTypes();

            foreach (MenuActionGroup group in _actionGroups)
            {
                if (lastGroup != null && !IsSeparatorSuppressed(group, lastGroup))
                {
                    _menuItems.Add("-");
                }

                if (group.SubmenuName != null)
                {
                    if (lastGroup == null || group.SubmenuName != lastGroup.SubmenuName)
                    {
                        curSubmenu            = _menuItems.Add(group.SubmenuName);
                        curMenuItems          = curSubmenu.MenuItems;
                        submenuVisibleActions = 0;
                        submenuEnabledActions = 0;
                    }
                    else
                    {
                        curMenuItems.Add("-");
                    }
                }
                else
                {
                    if (curSubmenu != null)
                    {
                        if (submenuVisibleActions == 0)
                        {
                            curSubmenu.Visible = false;
                        }
                        else if (submenuEnabledActions == 0)
                        {
                            curSubmenu.Enabled = false;
                        }
                    }
                    curMenuItems = _menuItems;
                    curSubmenu   = null;
                }
                lastGroup = group;

                foreach (MenuAction action in group.Actions)
                {
                    if (action.ResourceType != null)
                    {
                        if (resTypes.Length != 1 || resTypes [0] != action.ResourceType)
                        {
                            if (_disableUnmatchingTypeActions)
                            {
                                MenuItem stubItem = curMenuItems.Add(action.Name);
                                stubItem.Enabled = false;
                                submenuVisibleActions++;
                            }
                            continue;
                        }
                    }

                    MenuItem item = AddActionToMenu(action, curMenuItems, context, usedShortcuts);
                    if (!haveDefaultAction && context.SelectedResources.Count == 1 &&
                        Core.ActionManager.GetDoubleClickAction(context.SelectedResources [0]) == action.Action)
                    {
                        item.DefaultItem  = true;
                        haveDefaultAction = true;
                    }
                    if (item.Visible)
                    {
                        submenuVisibleActions++;
                    }
                    if (item.Enabled)
                    {
                        submenuEnabledActions++;
                    }
                }
            }

            if (curSubmenu != null)
            {
                if (submenuVisibleActions == 0)
                {
                    curSubmenu.Visible = false;
                }
                else if (submenuEnabledActions == 0)
                {
                    curSubmenu.Enabled = false;
                }
            }

            UpdateSeparatorVisibility(_menuItems);
        }
Beispiel #25
0
        /// <summary>
        /// Re-build the context menus.
        /// </summary>
        private void InitializeContextMenus(DirectoryInfo dir)
        {
            var timer = new Stopwatch();

            ++contextMenuCount;

            try
            {
                Menu.MenuItemCollection items = this.form.DirTreeMenu.MenuItems;
                items.Clear();

                List <MenuItem> menuList = new List <MenuItem>();


                if (this.isFtpSite)
                {
                    foreach (IScript script in this.scriptManager.FtpFolderScripts)
                    {
                        MenuItem temp = new MenuItem(script.LongName
                                                     , new EventHandler(this.FolderScriptMenuItemHandler)
                                                     , script.ScriptShortCut);

                        temp.Enabled = script.Active;
                        menuList.Add(temp);
                    }
                }
                else
                {
                    this.form.DirTreeMenu.MenuItems.Clear();
                    this.form.DirTreeMenu.MenuItems.AddRange(

                        this.scriptManager.FolderScripts.Where(fs => (fs.ValidatorFolder == null || fs.ValidatorFolder(dir)))
                        .Select(fs => new MenuItem(fs.LongName, new EventHandler(this.FolderScriptMenuItemHandler), fs.ScriptShortCut)
                    {
                        Enabled = fs.Active
                    })
                        .OrderBy(m => m.Text)
                        .ToArray()
                        );
                }

                timer.Start();
                this.form.FileGridMenuStrip.Items.Clear();

                this.scriptManager.FileScripts.OrderBy(fs => fs.LongName)
                .ToList()
                .ForEach(fs =>
                         this.form.FileGridMenuStrip.Items.Add(fs.LongName)
                         );


                this.form.DataGridView1.KeyPress += new KeyPressEventHandler(DataGridView1_KeyPress);
                //  this.form.DataGridView1.UserDeletingRow += new DataGridViewRowCancelEventHandler(DataGridView1_UserDeletingRow);



                var scripts = new List <IScript>();
                if (isFtpSite)
                {
                    scripts.AddRange(this.scriptManager.FTPFileScripts.ToArray());
                }
                else
                {
                    scripts.AddRange(this.scriptManager.FileScripts.ToArray());
                }

                var x = 1;
            }
            finally
            {
                timer.Stop();
                totalContextTime += timer.ElapsedMilliseconds;

                if (timer.ElapsedMilliseconds > 1500)
                {
                    Console.Out.WriteLine("Build context menu took:"
                                          + timer.ElapsedMilliseconds.ToString()
                                          + " for "
                                          + dir.FullName);
                }
            }
        }
Beispiel #26
0
        /// <summary>
        /// this function will update your Context Menu.
        /// </summary>
        public void UpdateMenu(ContextMenu yourOldMenu, NiceMenuClickEvent yourClickFunction)
        {
            IList myMenuList = new Menu.MenuItemCollection(yourOldMenu);

            BuildMenuTree(myMenuList, yourOldMenu, yourClickFunction);
        }
Beispiel #27
0
        public static void ExecuteGuiCommand(string args)
        {
            if (m_mainForm == null || m_mainForm.IsDisposed)
            {
                throw new MDbgShellException("Gui is closed");
            }
            if (args == null || args.Length == 0)
            {
                throw new MDbgShellException("Illegal usage. Expecting args");
            }
            string[] parts = args.Split('|');
            if (parts.Length <= 0)
            {
                throw new MDbgShellException("Illegal usage. Expecting args");
            }

            MenuItem m = null;

            Menu.MenuItemCollection c = m_mainForm.Menu.MenuItems;

            string lastPart = "<top>";

            foreach (String rawPart in parts)
            {
                string part = StripMenuCommand(rawPart);
                // 'MenuItemCollection.Find' doesn't search on Text property. So we search manually.
                m = null;
                foreach (MenuItem m2 in c)
                {
                    // Do case-insensitive string compare.
                    string menuText = StripMenuCommand(m2.Text);
                    if (String.Compare(menuText, part, true) == 0)
                    {
                        m = m2;
                        break;
                    }
                }
                if (m == null)
                {
                    // No match was found. To be helpful, print out possible matches.
                    if (c.Count == 0)
                    {
                        WriteOutput(MDbgOutputConstants.Ignore, "Menu '" + lastPart + "' has no sub menus.");
                    }
                    else
                    {
                        WriteOutput(MDbgOutputConstants.Ignore, "Menu '" + lastPart + "' only has the following sub menus:");
                        foreach (MenuItem m2 in c)
                        {
                            string name = StripMenuCommand(m2.Text);
                            if (name != "-") // skip separators.
                            {
                                WriteOutput(MDbgOutputConstants.Ignore, "   " + name);
                            }
                        }
                    }

                    throw new MDbgShellException("Can't find item '" + part + "' in '" + args + "'");
                }

                lastPart = part;
                c        = m.MenuItems;
            }
            System.Diagnostics.Debug.Assert(m != null);

            string prefix = "Invoking menu command:";

            WriteOutput(MDbgOutputConstants.StdOutput, prefix + args, prefix.Length, args.Length);
            InvokeMenuItemHelper(m, args);
        }
Beispiel #28
0
        /// <summary>
        /// Populates menu items from the given command collection.
        /// </summary>
        /// <param name="items"></param>
        /// <param name="commands"></param>
        private void PopulateMenuItems(DesktopCommandClickContext context, Menu.MenuItemCollection items, CommandCollection commands)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }
            if (commands == null)
            {
                throw new ArgumentNullException("commands");
            }

            // how many are selected?
            int numSelected = 1;

            if (context.OwnerAsEntityView != null)
            {
                numSelected = context.OwnerAsEntityView.SelectedEntitiesCount;
            }

            // walk...
            foreach (Command command in commands)
            {
                // ok?
                bool ok = true;
                if (numSelected > 1 && command.SingleOnly)
                {
                    ok = false;
                }

                // ok?
                if (ok)
                {
                    // sep?
                    if (command.HasSeparator)
                    {
                        // add a separator...
                        bool sepOk = true;
                        if (items.Count > 0)
                        {
                            string above = items[items.Count - 1].Text;
                            if (above != null && above == "-")
                            {
                                sepOk = false;
                            }
                        }
                        else
                        {
                            sepOk = false;
                        }

                        // add...
                        if (sepOk)
                        {
                            items.Add("-");
                        }
                    }

                    // add...
                    items.Add(new CommandMenuItem(context, command, CommandViewContext.ContextMenu));
                }
            }
        }