Пример #1
0
        }// Command

        //-------------------------------------------------------
        // Stuff for IExtendPropertySheet2 - This will only be
        // called for stuff in the scope view
        //-------------------------------------------------------

        //-------------------------------------------------
        // CreatePropertyPages
        //
        // MMC calls this function when it wants a property
        // page for a specified node.
        //-------------------------------------------------
        public int CreatePropertyPages(IPropertySheetCallback lpProvider, IntPtr handle, IDataObject lpIDataObject)
        {
            // This is really a CDO in disguise
            CDO victim = (CDO)lpIDataObject;

            // See if I really need to do this....
            if (m_ucsole != null)
            {
                IPropertySheetProvider psp = (IPropertySheetProvider)m_ucsole;

                if (psp.FindPropertySheet(victim.Node.Cookie, null, victim) == HRESULT.S_OK)
                {
                    return(HRESULT.S_FALSE);
                }
            }
            // Let's see if this node has property pages
            if (victim.Node != null && victim.Node.HavePropertyPagesCreate)
            {
                // If we've fired up a wizard, then that command has already been
                // logged (either from the menu command or the history list command.
                // We don't need to record this any further.
                if (!(victim.Node is CWizard))
                {
                    CCommandHistory.CommandExecuted(victim, -1);
                }
                victim.Node.CreatePropertyPages(lpProvider, handle);

                return(HRESULT.S_OK);
            }
            // We don't have any property pages, let's return false
            else
            {
                return(HRESULT.S_FALSE);
            }
        }// CreatePropertyPages
Пример #2
0
        }// SelectScopeItem

        static internal int FindPropertyPage(CDO cdo)
        {
            // Need to make this a pointer
            IntPtr pCDO = Marshal.GetIUnknownForObject(cdo);

            return((int)SendMessage(m_hMessageWnd, WM_FINDPROPPAGE, pCDO, IntPtr.Zero));
        }// FindPropertyPage
Пример #3
0
        }// CompareObjects

        //-------------------------------------------------------
        // Methods to extend IContextMenu
        //-------------------------------------------------------

        //-------------------------------------------------
        // AddMenuItems
        //
        // This function allows us to add items to the context menus
        //-------------------------------------------------
        public void AddMenuItems(IDataObject piDataObject, IContextMenuCallback piCallback, ref int pInsertionAllowed)
        {
            // The piDataObject is really a CDO is disguise....
            CDO item = (CDO)piDataObject;

            item.Node.AddMenuItems(ref piCallback, ref pInsertionAllowed, item.Data);
        }// AddMenuItems
Пример #4
0
        }// AddMenuItems

        //-------------------------------------------------
        // Command
        //
        // This function is called whenever an item that we
        // added to the context menus is called
        //-------------------------------------------------
        public void Command(int lCommandID, IDataObject piDataObject)
        {
            CDO item = (CDO)piDataObject;

            // Tell our command history about this
            CCommandHistory.CommandExecuted(item, lCommandID);
            item.Node.MenuCommand(lCommandID, item.Data);
        }// Command
Пример #5
0
        }// IgnoreCommandForHistory

        static internal void CommandExecuted(CDO cdo, int iMenuCommand)
        {
            // See if we actually care about this command
            if (IgnoreCommandForHistory(iMenuCommand))
            {
                return;
            }

            // If this is a command on a result item, but we don't have an
            // index number, then we can't create a shortcut for this item
            if (cdo.Data != null && !(cdo.Data is int))
            {
                return;
            }


            // Pull the data we need out of the CDO interface
            CNode node       = cdo.Node;
            int   iResultNum = cdo.Data == null?-1:(int)cdo.Data;

            // Let's build the string of what the user actually did
            String sAction = TranslateMenuCommandToString(node, iResultNum, iMenuCommand);

            if (sAction == null)
            {
                // We don't know how to represent this command as a string... let's bail
                return;
            }

            // IncrementCommand will return false if we don't know about this command.
            if (!IncrementCommand(sAction))
            {
                // We need to add this command
                CommandHistory ch = new CommandHistory();
                ch.scPathToNode = BuildPathToNode(cdo.Node);
                ch.iNumHits     = 3;
                ch.iMenuCommand = iMenuCommand;
                ch.sCommand     = sAction;

                // Let's get the result item name
                ch.scResultItem = new StringCollection();
                if (iResultNum != -1)
                {
                    // We're dealing with a result item here
                    IColumnResultView crv = (IColumnResultView)node;
                    int iNumCols          = crv.getNumColumns();

                    // iResultNum needs to be zero-based
                    for (int i = 0; i < iNumCols; i++)
                    {
                        ch.scResultItem.Add(crv.getValues(iResultNum - 1, i));
                    }
                }

                m_olCommands.Add(ch);
            }
        }// CommandExecuted
Пример #6
0
        }// Destroy

        //-------------------------------------------------
        // QueryDataObject
        //
        // When MMC wants a data object for a specific cookie,
        // this function will be called.
        //-------------------------------------------------
        public void QueryDataObject(int cookie, uint type, out IDataObject ppDataObject)
        {
            CNode node = CNodeManager.GetNode(cookie);

            if (node == null)
            {
                node = m_rn;
            }
            ppDataObject = new CDO(node);
        }// QueryDataObject
        }// doAcceptPaste

        internal override int Paste(IDataObject ido)
        {
            CDO cdo = (CDO)ido;

            // See if this is coming from the Shared Assemblies node
            if (cdo.Node is CSharedAssemblies)
            {
                AddAssembly((AssemInfo)cdo.Data);
            }

            return(HRESULT.S_OK);
        }// Paste
Пример #8
0
        }// onSelect

        internal override int doAcceptPaste(IDataObject ido)
        {
            // Only accept a CSingleCodeGroup Node
            if (ido is CDO)
            {
                CDO cdo = (CDO)ido;
                if (cdo.Node is CSingleCodeGroup && cdo.Node != this)
                {
                    return(HRESULT.S_OK);
                }
            }
            return(HRESULT.S_FALSE);
        }// doAcceptPaste
        }// TurnCodebaseToFilename

        internal override int onDoubleClick(Object o)
        {
            if (o != null)
            {
                AssemInfo ai  = (AssemInfo)o;
                CDO       cdo = new CDO(this);
                cdo.Data = o;

                OpenMyResultPropertyPage(ai.Name, cdo);
                return(HRESULT.S_OK);
            }
            return(HRESULT.S_FALSE);
        }// onDoubleClick
Пример #10
0
        }// FreePropertySheetNotifyHandle

        internal void ShowMyPropertyPageIfOpen()
        {
            // We can't do this if the HTML page is refreshing itself
            if (m_fStartResultRefresh)
            {
                m_fWantToMakePropertyPageVisible = true;
            }
            else
            {
                CDO cdo = new CDO(this);
                OpenPropertyPage(DisplayName, cdo, CNodeManager.Data, 1, false);
                m_fWantToMakePropertyPageVisible = false;
            }
        }// ShowMyPropertyPageIfOpen
Пример #11
0
        }// AddMenuItems

        //-------------------------------------------------
        // Command
        //
        // This function is called whenever an item that we
        // added to the context menus is called
        //-------------------------------------------------
        public void Command(int lCommandID, IDataObject piDataObject)
        {
            CDO item = (CDO)piDataObject;

            CCommandHistory.CommandExecuted(item, lCommandID);
            if (item.Data != null)
            {
                item.Node.MenuCommand(lCommandID, item.Data);
            }
            else
            {
                item.Node.MenuCommand(lCommandID);
            }
        }// Command
Пример #12
0
        }// doAcceptPaste

        internal override int Paste(IDataObject ido)
        {
            // Make sure the permission set is ok to use....
            if (ido is CDO)
            {
                CDO cdo = (CDO)ido;
                if (cdo.Node is CSinglePermissionSet)
                {
                    CSinglePermissionSet sps = (CSinglePermissionSet)cdo.Node;

                    AddPermissionSet(sps.PSet.Copy(sps.PSet.Name));
                }
            }
            return(HRESULT.S_OK);
        }// Paste
Пример #13
0
        }// OpenMyResultPropertyPage

        private void OpenPropertyPage(String sTitle, CDO cdo, Object o, int nScopeItem, bool fReallyOpen)
        {
            if (CNodeManager.FindPropertyPage(cdo) != HRESULT.S_OK && fReallyOpen)

            {
                // Note, doing this stuff will only work if called from the main MMC thread.
                // If it needs to be called from a helper thread or from a property page
                // thread then marshalling should be set up using the framework provided
                // in CNodeManager
                IPropertySheetProvider psp = (IPropertySheetProvider) new NodeManager();

                psp.CreatePropertySheet(sTitle, 1, Cookie, cdo, 0);
                psp.AddPrimaryPages(o, 1, 0, nScopeItem);
                psp.Show(IntPtr.Zero, 0);
            }
        }// OpenPropertyPage
Пример #14
0
        }// TaskPadTaskNotify

        internal override int doAcceptPaste(IDataObject ido)
        {
            // Only accept a CSingleCodeGroup Node
            if (ido is CDO)
            {
                CDO cdo = (CDO)ido;
                if (cdo.Node is CSinglePermissionSet)
                {
                    // Check to make sure it's not one of our permission sets...
                    if (cdo.Node.ParentHScopeItem != HScopeItem)
                    {
                        return(HRESULT.S_OK);
                    }
                }
            }
            return(HRESULT.S_FALSE);
        }// doAcceptPaste
Пример #15
0
        }// Init

        //---------------------------------------------------------------------------
        //  This is our hidden window which is just used for handling messages.  We
        //  go to all this trouble so that we don't ever pass interface pointers or
        //  other objects across threads.
        //
        static internal IntPtr NodeManagerMessageProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam)
        {
            SCOPEDATAITEM sdi;

            switch (uMsg)
            {
            case WM_NAMESPACEEXPAND:
                CNamespace.Expand((int)wParam);
                break;

            case WM_INSERTITEM:
                sdi = (SCOPEDATAITEM)Marshal.PtrToStructure(wParam, typeof(SCOPEDATAITEM));
                CNamespace.InsertItem(ref sdi);
                return((IntPtr)sdi.ID);

            case WM_SETITEM:
                sdi = (SCOPEDATAITEM)Marshal.PtrToStructure(wParam, typeof(SCOPEDATAITEM));
                CNamespace.SetItem(ref sdi);
                break;

            case WM_SELECTSCOPEITEM:
                CNodeManager.Console.SelectScopeItem((int)wParam);
                break;

            case WM_FINDPROPPAGE:
                IPropertySheetProvider psp = (IPropertySheetProvider) new NodeManager();
                CDO cdo = (CDO)Marshal.GetObjectForIUnknown(wParam);
                return((IntPtr)psp.FindPropertySheet(cdo.Node.Cookie, Component, cdo));

            case WM_SETCONSOLEICON:
                IImageList il = null;
                Console.QueryScopeImageList(out il);
                if (il != null)
                {
                    il.ImageListSetIcon(wParam, (int)lParam);
                }
                break;


            default:
                return(DefWindowProc(hWnd, uMsg, wParam, lParam));
            }
            return(IntPtr.Zero);
        }// NodeManagerMessageProc
Пример #16
0
        }// CreateComponent

        //-------------------------------------------------
        // Notify
        //
        // This notify function is much less complex than
        // the notify function found in CComponent.
        // Its main responsiblity is to insert data items into
        // the console namespace when requested.
        //-------------------------------------------------
        public int Notify(IDataObject lpDataObject, uint aevent, IntPtr arg, IntPtr param)
        {
            try
            {
                CDO test = (CDO)lpDataObject;

                switch (aevent)
                {
                // If a data item is expanding, we need to tell MMC about it's children.
                // Note, this case doesn't necessarily mean the data item is expanding
                // visually.... MMC is just requesting information about it.
                case MMCN.EXPAND:

                    // See if we're expanding the item (as opposed to collapsing it)
                    if ((int)arg > 0)
                    {
                        test.Node.onExpand((int)param);
                    }
                    break;

                case MMCN.RENAME:
                    return(test.Node.onRename(Marshal.PtrToStringUni(param)));

                case MMCN.DELETE:
                    return(test.Node.onDelete(null));


                default:
                    // We don't support any other messages
                    return(HRESULT.S_FALSE);
                }
            }
            catch (Exception)
            {
                // There's some sort of failure here. Rather than letting MMC
                // deal with the error (which could mean a crash) let's just swallow
                // the exception and cross our fingers.
            }


            return(HRESULT.S_OK);
        }// Notify
Пример #17
0
        }// GetListPadInfo

        //-------------------------------------------------------
        // Stuff for IExtendPropertySheet2 - This will only be called
        // on Property sheets in the result view
        //-------------------------------------------------------

        //-------------------------------------------------
        // CreatePropertyPages
        //
        // MMC calls this function when it wants a property
        // page for a specified node.
        //-------------------------------------------------
        public int CreatePropertyPages(IPropertySheetCallback lpProvider, IntPtr handle, IDataObject lpIDataObject)
        {
            // This is really a CDO in disguise
            CDO victim = (CDO)lpIDataObject;

            // See if we're asking for property pages based on a result item
            if (victim.Data != null && victim.Node.DoesResultHavePropertyPage(victim.Data))
            {
                CCommandHistory.CommandExecuted(victim, -1);
                victim.Node.CreateResultPropertyPages(lpProvider, handle, victim.Data);
            }
            // We don't have any property pages, let's return false
            else
            {
                MessageBox(0, "Got a false positive", "", 0);
                return(HRESULT.S_FALSE);
            }

            return(HRESULT.S_OK);
        }// CreatePropertyPages
        }// TaskPadTaskNotify

        internal override int doAcceptPaste(IDataObject ido)
        {
            // Only accept an assembly from the Shared Assemblies Node
            if (!ReadOnly && ido is CDO)
            {
                CDO cdo = (CDO)ido;
                if (cdo.Node is CSharedAssemblies)
                {
                    // Make sure we're looking at a result item
                    if (cdo.Data != null)
                    {
                        // Make sure we're not trying to drag this on ourselves
                        if (cdo.Node != this)
                        {
                            return(HRESULT.S_OK);
                        }
                    }
                }
            }
            return(HRESULT.S_FALSE);
        }// doAcceptPaste
        }// MenuCommand

        internal override int onDoubleClick(Object o)
        {
            if (o != null)
            {
                // If it's a read-only permission set, show the permission dialog
                if (ReadOnly)
                {
                    MenuCommand(COMMANDS.VIEW_PERMISSION, o);
                }
                else // Bring up the property page
                {
                    int iResultItem = (int)o;
                    CDO cdo         = new CDO(this);
                    cdo.Data = iResultItem;

                    OpenMyResultPropertyPage(getValues(iResultItem - 1, 0), cdo);
                }
                return(HRESULT.S_OK);
            }
            return(HRESULT.S_FALSE);
        }// onDoubleClick
Пример #20
0
        }// doAcceptPaste

        internal override int Paste(IDataObject ido)
        {
            // We have two different things we have to do. We need to remove this CodeGroup
            // from it's current parent and parent it to this codegroup

            CDO cdo = (CDO)ido;
            CSingleCodeGroup scg = (CSingleCodeGroup)cdo.Node;

            AddCodeGroup(scg.m_cg.Copy(), !(scg.m_pl == m_pl), scg.m_pl);

            // If we're moving codegroups between policy levels, don't remove
            // the codegroup. If we're moving the codegroup within the same policy
            // level, then remove it
            if (scg.m_pl == m_pl)
            {
                scg.RemoveThisCodegroup();
                SecurityPolicyChanged();
            }
            Showing();

            // Now expand with our new things...
            //CNodeManager.CNamespace.Expand(HScopeItem);
            return(HRESULT.S_OK);
        }// Paste
Пример #21
0
        }// isRepeatBindingRedirInfo

        internal override int Paste(IDataObject ido)
        {
            CDO cdo = (CDO)ido;
            BindingRedirInfo bri = new BindingRedirInfo();

            // See if this is coming from the Shared Assemblies node
            if (cdo.Node is CSharedAssemblies)
            {
                CSharedAssemblies shared = (CSharedAssemblies)(cdo.Node);
                if (cdo.Data is AssemInfo)
                {
                    AddAssemInfo((AssemInfo)cdo.Data);
                }
                // This is an array list... with bunches of stuff in it
                else
                {
                    ArrayList al = (ArrayList)cdo.Data;
                    for (int i = 0; i < al.Count; i++)
                    {
                        AddAssemInfo(shared.GetAssemInfo((int)al[i] - 1));
                    }
                }
            }
            else if (cdo.Node is CApplicationDepends)
            {
                CApplicationDepends appDepends = (CApplicationDepends)(cdo.Node);
                if (cdo.Data is int)
                {
                    AddAssemInfo(appDepends.GetAssemInfo((int)cdo.Data - 1));
                }
                // This is an array list... with bunches of stuff in it
                else
                {
                    ArrayList al = (ArrayList)cdo.Data;
                    for (int i = 0; i < al.Count; i++)
                    {
                        AddAssemInfo(appDepends.GetAssemInfo((int)al[i] - 1));
                    }
                }
            }
            // This is coming from another Version Policy Node
            // We'll copy over all the binding policy this node has
            else
            {
                ArrayList      alStuff = new ArrayList();
                CVersionPolicy verpol  = (CVersionPolicy)(cdo.Node);


                if (cdo.Data is BindingRedirInfo)
                {
                    alStuff.Add(cdo.Data);
                }
                else
                {
                    // Run through and change all the indexes to BindingRedirInfos
                    ArrayList alIndexes = (ArrayList)cdo.Data;
                    for (int i = 0; i < alIndexes.Count; i++)
                    {
                        alStuff.Add(verpol.GetBindRedirInfo((int)alIndexes[i] - 1));
                    }
                }

                bool fSkipWarningDialog = false;
                for (int i = 0; i < alStuff.Count; i++)
                {
                    bri = (BindingRedirInfo)alStuff[i];

                    // Let's see if we have this item
                    bool fHaveItem = isRepeatBindingRedirInfo(bri);

                    bool fAddItem = !fHaveItem;
                    if (fHaveItem && !fSkipWarningDialog)
                    {
                        String sMessageText = "";
                        if (alStuff.Count == 1)
                        {
                            sMessageText = String.Format(CResourceStore.GetString("CVersionPolicy:ConfigInfoExistsForOneAssem"), bri.Name);
                        }
                        else
                        {
                            sMessageText = CResourceStore.GetString("CVersionPolicy:ConfigInfoExists");
                        }

                        int hr = MessageBox(sMessageText,
                                            CResourceStore.GetString("CVersionPolicy:ConfigInfoExistsTitle"),
                                            MB.ICONQUESTION | MB.YESNO);
                        if (hr == MB.IDYES)
                        {
                            fAddItem = true;
                        }
                        fSkipWarningDialog = fAddItem;
                    }

                    if (fAddItem)
                    {
                        // Set up some strings we need
                        String sFirstPartOfBinding  = "BindingPolicyFor" + bri.Name + "," + bri.PublicKeyToken;
                        String sFirstPartOfCodebase = "CodeBasesFor" + bri.Name + "," + bri.PublicKeyToken;
                        String sFirstPartOfPubPol   = "PublisherPolicyFor" + bri.Name + "," + bri.PublicKeyToken;

                        // If we are getting and writing this to an App config file,
                        // let's add that info
                        String sSecondPartOnIncoming = "";
                        if (verpol.m_sConfigFile != null)
                        {
                            sSecondPartOnIncoming = "," + verpol.m_sConfigFile;
                        }

                        String sSecondPartOnDest = "";
                        if (m_sConfigFile != null)
                        {
                            sSecondPartOnDest += "," + m_sConfigFile;
                        }

                        AddConfiguredAssembly(bri);

                        //--------------------------------------------
                        // First, read the stuff from the config store
                        //--------------------------------------------
                        // First get the binding policy
                        String        sGetSettingString = sFirstPartOfBinding + sSecondPartOnIncoming;
                        BindingPolicy bp = (BindingPolicy)CConfigStore.GetSetting(sGetSettingString);

                        // Now get the codebase info
                        sGetSettingString = sFirstPartOfCodebase + sSecondPartOnIncoming;
                        CodebaseLocations cbl = (CodebaseLocations)CConfigStore.GetSetting(sGetSettingString);

                        sGetSettingString = sFirstPartOfPubPol + sSecondPartOnIncoming;
                        bool fPubPolicy = (bool)CConfigStore.GetSetting(sGetSettingString);


                        //---------------------------------------------
                        // Now let's write this stuff to our config file
                        //---------------------------------------------

                        // First write the binding policy
                        String sSetSettingString = sFirstPartOfBinding + sSecondPartOnDest;
                        if (!CConfigStore.SetSetting(sSetSettingString, bp))
                        {
                            return(HRESULT.S_FALSE);
                        }

                        // Now Set the codebase info
                        sSetSettingString = sFirstPartOfCodebase + sSecondPartOnDest;
                        if (!CConfigStore.SetSetting(sSetSettingString, cbl))
                        {
                            return(HRESULT.S_FALSE);
                        }

                        sSetSettingString = sFirstPartOfPubPol + sSecondPartOnDest;
                        if (!CConfigStore.SetSetting(sSetSettingString, fPubPolicy))
                        {
                            return(HRESULT.S_FALSE);
                        }
                    }
                } // for loop
            }     // coming from another version policy node


            return(HRESULT.S_OK);
        }// Paste
Пример #22
0
        }// Destroy

        //-------------------------------------------------
        // QueryDataObject
        //
        // When MMC wants a data object for a specific cookie,
        // this function will be called.
        //-------------------------------------------------
        public void QueryDataObject(int cookie, uint type, out IDataObject ppDataObject)
        {
            // Our cookies for results are a little bit 'munged'
            // The low word is the actual cookie, while the high word is
            // the row # of the result item (1-based)

            // Crap.... we have a multi-selection to worry about
            if (cookie == MMC.MULTI_SELECT_COOKIE)
            {
                IResultData ResultData     = (IResultData)m_ucsole;
                ArrayList   al             = new ArrayList();
                bool        isLastSelected = false;
                int         nGoodCookie    = -1;
                int         nIndex         = -1;

                while (!isLastSelected)
                {
                    RESULTDATAITEM rdi = new RESULTDATAITEM();
                    rdi.mask   = RDI.STATE;
                    rdi.nCol   = 0;
                    rdi.nIndex = nIndex;
                    rdi.nState = LVIS.SELECTED;

                    ResultData.GetNextItem(ref rdi);

                    if (rdi.nIndex != -1)
                    {
                        al.Add((int)((rdi.lParam & 0xFFFF0000) >> 16));
                        nGoodCookie = rdi.lParam;
                        nIndex      = rdi.nIndex;
                    }
                    else
                    {
                        isLastSelected = true;
                    }
                }
                if (nGoodCookie != -1)
                {
                    int   iRealCookie = nGoodCookie & 0x0000FFFF;
                    CNode node        = CNodeManager.GetNode(iRealCookie);
                    CDO   cdo         = new CDO(node);
                    cdo.Data     = al;
                    ppDataObject = cdo;
                }
                else
                {
                    ppDataObject = null;
                }
            }
            else
            {
                int    iRealCookie = cookie & 0x0000FFFF;
                CNode  node        = CNodeManager.GetNode(iRealCookie);
                CDO    cdo         = new CDO(node);
                Object o;
                if (node.ResultQDO(cookie, out o))
                {
                    cdo.Data = o;
                }
                else
                {
                    cdo.Data = (int)((cookie & 0xFFFF0000) >> 16);
                }

                ppDataObject = cdo;
            }
        }// QueryDataObject
Пример #23
0
        }// ControlbarNotify

        //-------------------------------------------------------
        // Methods for IExtendTaskPad
        //-------------------------------------------------------

        //-------------------------------------------------
        // TaskNotify
        //
        // This function is called from the ActiveX control
        // on the HTML page in the result pane. We direct
        // whatever message was sent to the appropriate node.
        //-------------------------------------------------
        public void TaskNotify(IDataObject pdo, ref Object arg, ref Object param)
        {
            CDO data = (CDO)pdo;

            data.Node.BaseTaskPadTaskNotify(arg, param, m_ucsole, m_Data);
        }// TaskNotify
Пример #24
0
        }// TaskNotify

        //-------------------------------------------------
        // EnumTasks
        //
        // This function can be called either by MMC or by
        // the ActiveX control on our webpage. Again, we
        // route it to the appropiate node.
        //-------------------------------------------------
        public void EnumTasks(IDataObject pdo, String szTaskGroup, out IEnumTASK ppEnumTASK)
        {
            CDO data = (CDO)pdo;

            ppEnumTASK = data.Node.GetIEnumTASK(szTaskGroup);
        }// EnumTasks
Пример #25
0
        }// Initialize

        //-------------------------------------------------
        // Notify
        //
        // This is where most of the interesting stuff happens.
        // Whenever MMC needs something from the snapin, it will
        // send a message to Notify, and notify is responsible
        // to take care (or delegate) whatever MMC wants
        //-------------------------------------------------
        public int Notify(IntPtr lpDataObject, uint aevent, IntPtr arg, IntPtr param)
        {
            // We don't handle any of the special data objects here
            if (lpDataObject == (IntPtr)DOBJ.CUSTOMOCX || lpDataObject == (IntPtr)DOBJ.CUSTOMWEB)
            {
                return(HRESULT.S_FALSE);
            }

            IDataObject ido = null;

            if (lpDataObject != (IntPtr)0)
            {
                ido = (IDataObject)Marshal.GetObjectForIUnknown(lpDataObject);
            }

            CDO Data; // This will hold the object MMC wants action performed on

            // lpDataObject is just a CDO... we're going to obtain the CDO interface.
            // if lpDataObject is null, then there needs to be action performed on the root
            // node.
            if (ido != null)
            {
                Data = (CDO)ido;
            }
            else
            {
                CNode node = CNodeManager.GetNode(CNodeManager.RootNodeCookie);
                Data = new CDO(node);
            }

            switch (aevent)
            {
            // The user clicked the 'forward' or 'back' button on the MMC browser.
            // We need to sync up our node to the new result view
            case MMCN.RESTORE_VIEW:
                return(Data.Node.onRestoreView((MMC_RESTORE_VIEW)Marshal.PtrToStructure(arg, typeof(MMC_RESTORE_VIEW)), param));


            // We're being asked if we will accept an item to be pasted
            // (Used here to tell MMC if this node is a valid drag-and-drop
            // location)
            case MMCN.QUERY_PASTE:
                // See if it's asking about result items or scope items
                return(Data.Node.doAcceptPaste((IDataObject)Marshal.GetObjectForIUnknown((IntPtr)arg)));

            // We're being given an item to paste. (Used here to tell MMC that
            // something is being dropped here from a drag and drop operation)
            case MMCN.PASTE:
                return(Data.Node.Paste((IDataObject)Marshal.GetObjectForIUnknown((IntPtr)arg)));

            // The selected item needs to show something in the result pane
            case MMCN.SHOW:
                // If we're selecting this item
                if ((uint)arg == 1)
                {
                    CNodeManager.SelectedNode = Data.Node;
                }
                Data.Node.onShow(m_ucsole, arg, param);
                break;

            // If an item is selected, we should set flags for verbs available
            // for the item (from the dropdown menu)
            case MMCN.SELECT:

                bool fEnablePropPages = false;
                // See if this is selected from the result view
                if (((uint)arg & 0x0000FFFF) == 0)
                {
                    // See if we selected it or de-selected it
                    if (((uint)arg & 0xFFFF0000) == 0)
                    {
                        Data.Node.ResultItemUnSelected(m_ucsole, Data.Data);
                    }
                    else
                    {
                        Data.Node.ResultItemSelected(m_ucsole, Data.Data);
                    }


                    // Let's see if this result item has a property page
                    if (Data.Node.DoesResultHavePropertyPage(Data.Data))
                    {
                        fEnablePropPages = true;
                    }
                }
                // This item was selected in the scope view
                else
                if (Data.Node.HavePropertyPages)
                {
                    fEnablePropPages = true;
                }


                IConsoleVerb icv;
                // Get the IConsoleVerb interface from MMC
                m_ucsole.QueryConsoleVerb(out icv);

                // See if we need to enable then property sheets item on the popup menu
                if (fEnablePropPages)
                {
                    icv.SetVerbState(MMC_VERB.PROPERTIES, MMC_BUTTON_STATE.ENABLED, 1);
                }
                else
                {
                    icv.SetVerbState(MMC_VERB.PROPERTIES, MMC_BUTTON_STATE.ENABLED, 0);
                }


                // We'll only call this onSelect method if the user selected the
                // scope item
                if (((uint)arg & 0x0000FFFF) > 0 && ((uint)arg & 0xFFFF0000) > 0)
                {
                    icv.SetVerbState(MMC_VERB.PASTE, MMC_BUTTON_STATE.ENABLED, 1);
                    Data.Node.onSelect(icv);
                }
                break;

            // This is to add images for the result pane
            case MMCN.ADD_IMAGES:
                // arg actually contains the IImageList interface. We need to tell
                // C# that it is a Object and not a integer.

                IImageList il = (IImageList)Marshal.GetObjectForIUnknown((IntPtr)arg);

                // param contains the HScopeItem. Let's get the node it represents
                CNode nLuckyGuy = CNodeManager.GetNodeByHScope((int)param);

                il.ImageListSetIcon(nLuckyGuy.IconHandle, CResourceStore.GetIconCookie(nLuckyGuy.IconHandle));

                // Now add all the children images
                CNode nChild = null;
                for (int i = 0; i < nLuckyGuy.NumChildren; i++)
                {
                    nChild = CNodeManager.GetNode(nLuckyGuy.Child[i]);
                    il.ImageListSetIcon(nChild.IconHandle, CResourceStore.GetIconCookie(nChild.IconHandle));
                }

                // Now add any images that the node might have for it's listview
                if (nLuckyGuy.m_oResults != null && nLuckyGuy.m_oResults is IColumnResultView)
                {
                    ((IColumnResultView)nLuckyGuy.m_oResults).AddImages(ref il);
                }

                break;

            // The user double clicked on something
            case MMCN.DBLCLICK:
                return(Data.Node.onDoubleClick(Data.Data));

            case MMCN.DELETE:
                return(Data.Node.onDelete(Data.Data));

            default:
                // We don't support the Notification message we got
                return(HRESULT.S_FALSE);
            }
            return(HRESULT.S_OK);
        }// Notify
Пример #26
0
        }// FireOffCommand(int)

        static private bool ExecuteCommand(CommandHistory chCommand, bool fActuallyExecute)
        {
            // Ok, let's run through the nodes until we find the node we want
            CNode node       = CNodeManager.GetNode(CNodeManager.RootNodeCookie);
            int   iTreeLevel = chCommand.scPathToNode.Count - 1;

            while (node != null && iTreeLevel >= 0)
            {
                // Expand this node
                node = GetChild(node, chCommand.scPathToNode[iTreeLevel]);
                iTreeLevel--;
            }

            // Ok, now let's see if we were just trying to figure out if this command existed...
            if (!fActuallyExecute)
            {
                // Yes, this command will work
                if (node != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }


            if (node != null)
            {
                int iResultNum = GetResultNum(node, chCommand.scResultItem);

                // We have the node. Let's do something to it
                // If it was a property page, let's fire that off
                if (chCommand.iMenuCommand == -1)
                {
                    // See if we're just opening up the node's property page
                    if (iResultNum == -1)
                    {
                        node.OpenMyPropertyPage();
                    }
                    else
                    {
                        CDO cdo = new CDO(node);
                        // Make sure the result num is 1-based
                        cdo.Data = iResultNum + 1;
                        node.OpenMyResultPropertyPage(node.DisplayName, cdo);
                    }
                }
                // It was some sort of menu command. Let's fire that off
                else
                {
                    if (iResultNum == -1)
                    {
                        node.MenuCommand(chCommand.iMenuCommand);
                    }
                    else // This is a result item's command
                         // Make sure we make the result number 1-based
                    {
                        node.MenuCommand(chCommand.iMenuCommand, iResultNum + 1);
                    }
                }


                // Last but not least, let's go visit that node.
                CNodeManager.Console.SelectScopeItem(node.HScopeItem);


                return(true);
            }
            return(false);
        }// ExecuteCommand(int, bool)
Пример #27
0
        }// ShowMyPropertyPageIfOpen

        internal void OpenMyPropertyPage()
        {
            CDO cdo = new CDO(this);

            OpenPropertyPage(DisplayName, cdo, CNodeManager.Data, 1, true);
        }// OpenMyPropertyPage
Пример #28
0
        }// OpenMyPropertyPage

        internal void OpenMyResultPropertyPage(String sTitle, CDO cdo)
        {
            OpenPropertyPage(sTitle, cdo, CNodeManager.Component, 0, true);
        }// OpenMyResultPropertyPage