Esempio n. 1
0
 //---------------------------------------------------------------------
 private void txt_OnSelectedObjectChanged(object sender, EventArgs args)
 {
     if (OnSelectObject != null)
     {
         OnSelectObject(this, new CObjetDonneeEventArgs(TextBoxSelection.SelectedObject));
         if (AutoClose)
         {
             try
             {
                 ToolStripItem parent = OwnerItem;
                 while (parent != null && parent.OwnerItem != null)
                 {
                     parent = parent.OwnerItem;
                 }
                 ToolStripDropDownMenu menu = parent != null ?parent.Owner as ToolStripDropDownMenu:null;
                 if (menu == null)
                 {
                     menu = Owner as ToolStripDropDownMenu;
                 }
                 if (menu != null)
                 {
                     menu.Close();
                 }
             }
             catch { }
         }
     }
 }
Esempio n. 2
0
        public void InvokeAction(object Sender, string ActionName)
        {
            //close the menu
            // For some reason, if we don't explicitly close the menus they remain open,
            // and on top of other windows.
            if (Sender is ContextMenuStrip)
            {
                ((ContextMenuStrip)Sender).Close();
            }
            else if (Sender is ToolStripDropDownMenu)
            {
                ToolStripDropDownMenu Menu = (ToolStripDropDownMenu)Sender;
                if ((Menu.OwnerItem != null) && (Menu.OwnerItem.Owner != null) && Menu.OwnerItem.Owner is ContextMenuStrip)
                {
                    ((ContextMenuStrip)Menu.OwnerItem.Owner).Close();
                }
                Menu.Close();
            }

            //call the method to carry out the action
            XmlNode ActionInvoke = XmlHelper.Find(ActionFile, "/Folder/Actions/" + ActionName + "/OnInvoke/Call");

            //look up the <class> and <method> for the action in the Actions.xml
            if ((ActionInvoke != null))
            {
                List <object> Arguments = new List <object>();
                Arguments.Add(this);
                //pass the Controller as a parameter to the method
                CallDll.CallMethodOfClass(ActionInvoke, Arguments);
                //parameters for this are an XmlNode (with a <class> and <method> tag) and a list of Objects (which are the paramters for the method specified in the XmlNode)
            }
        }