Esempio n. 1
0
 public void SetCommandName(Component component, MfcCommand value)
 {
     if (value == MfcCommand.None)
     {
         m_ComandsTable.Remove(component);
     }
     else
     {
         m_ComandsTable[component] = value;
     }
 }
Esempio n. 2
0
        private void OnClick(object sender, EventArgs e)
        {
            MfcCommand id   = GetCommandName(sender as Component);
            bool       bRes = m_WndManager.MfcAppAdapter.OnCmdMsg((int)id);

            //if (bRes && (id == MfcCommand.FILE_NEW
            //|| id == MfcCommand.FILE_OPEN
            //|| id == MfcCommand.WINDOW_NEW
            //|| (id >= MfcCommand.FILE_MRU_FIRST && id < MfcCommand.FILE_MRU_LAST)))
            //{
            //    AttachCreatedView();
            //}
        }
Esempio n. 3
0
        // Assigned command would be update some UI properties of ToolStripMenuItem and ToolStripButton.
        private void OnUpdateUI(object sender, EventArgs e)
        {
            bool IsRecentUpdated = false;

            ToolStripMenuItem item = sender as ToolStripMenuItem;

            if (item != null)
            {
                MfcCommand nID = GetCommandName(item);
                if (nID >= MfcCommand.FILE_MRU_FIRST && nID < MfcCommand.FILE_MRU_LAST)                 // Update Recent menu items
                {
                    // one time UpdateRecentItems
                    if (IsRecentUpdated == false)
                    {
                        UpdateRecentItems(item);
                        IsRecentUpdated = true;
                    }
                }
                // we set state of VIEW_TOOLBAR item externally
                else if (nID == MfcCommand.VIEW_TOOLBAR)
                {
                }
                else
                {
                    // update menu item in MFC application
                    m_WndManager.MfcAppAdapter.OnUpdateCmdMsg((int)nID, new MenuItemCmdUI(item));
                }
            }
            else                // sender Application.Idle
            {
                IEnumerator iter = m_ComandsTable.Keys.GetEnumerator();
                while (iter.MoveNext() && iter.Current != null)
                {
                    if (iter.Current is ToolStripButton)
                    {
                        ToolStripButton pToolStripButton = (ToolStripButton)iter.Current;

                        // update ToolStripButton in MFC application
                        m_WndManager.MfcAppAdapter.OnUpdateCmdMsg((int)GetCommandName(pToolStripButton), new ButtonCmdUI(pToolStripButton));
                    }
                }
            }
        }
Esempio n. 4
0
        private void UpdateRecentItems(ToolStripMenuItem item)
        {
            ToolStripMenuItem parent = (ToolStripMenuItem)item.OwnerItem;
            int first_index          = parent.DropDownItems.IndexOf(item);

            // remove old recent items
            int collection_index = first_index;

            for (collection_index = first_index; collection_index < parent.DropDownItems.Count;)
            {
                MfcCommand RemoveId = GetCommandName(parent.DropDownItems[collection_index]);

                if (RemoveId == MfcCommand.None)
                {
                    break;
                }

                if (RemoveId >= MfcCommand.FILE_MRU_FIRST && RemoveId < MfcCommand.FILE_MRU_LAST)
                {
                    // remove menu item from m_ComandsTable
                    SetCommandName(parent.DropDownItems[collection_index], MfcCommand.None);
                    // remove menu item from PopUp menu
                    parent.DropDownItems.RemoveAt(collection_index);
                }
                else
                {
                    break;
                }
            }

            // add new recent items
            collection_index = first_index;
            MfcCommand tmpID = MfcCommand.FILE_MRU_FILE1;

            // update recent items in MFC application
            m_WndManager.MfcAppAdapter.OnUpdateCmdMsg((int)tmpID, new MenuItemCmdUI(item));

            while (true)
            {
                string sRecentFile = m_WndManager.MfcAppAdapter.GetMfcMenuString((int)tmpID);
                if (sRecentFile == "")
                {
                    break;
                }
                ToolStripMenuItem RecentMenuItem = new ToolStripMenuItem(sRecentFile);

                RecentMenuItem.Click += new EventHandler(OnClick);

                // add menu item to m_ComandsTable
                SetCommandName(RecentMenuItem, tmpID);

                if (RecentMenuItem.Text == "Recent File")
                {
                    RecentMenuItem.Enabled = false;
                }

                // add menu item to PopUp menu
                parent.DropDownItems.Insert(collection_index++, RecentMenuItem);
                tmpID++;
            }
        }