コード例 #1
0
        }// CTrustedAssemblies

        internal override void ResultItemSelected(IConsole2 con, Object oResults)
        {
            IConsoleVerb icv;

            // Get the IConsoleVerb interface from MMC
            con.QueryConsoleVerb(out icv);
            // Turn on the delete verb for the result data items
            icv.SetVerbState(MMC_VERB.DELETE, MMC_BUTTON_STATE.ENABLED, ReadOnly?0:1);
        }// ResultItemSelected
コード例 #2
0
        }// GenerateDependentAssemblies

        internal override void ResultItemSelected(IConsole2 con, Object oResults)
        {
            IConsoleVerb icv;

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

            // We want to enable drag-drop actions
            icv.SetVerbState(MMC_VERB.COPY, MMC_BUTTON_STATE.ENABLED, 1);
            icv.SetVerbState(MMC_VERB.PASTE, MMC_BUTTON_STATE.ENABLED, 1);
        }// ResultItemSelected
コード例 #3
0
        }// onSelect

        internal override void ResultItemSelected(IConsole2 con, Object oResults)
        {
            // Only care about this if this isn't a read-only permission set
            if (!ReadOnly)
            {
                IConsoleVerb icv;
                // Get the IConsoleVerb interface from MMC
                con.QueryConsoleVerb(out icv);

                // We want to enable drag-drop actions
                icv.SetVerbState(MMC_VERB.DELETE, MMC_BUTTON_STATE.ENABLED, 1);
            }
        }// ResultItemSelected
コード例 #4
0
        }// CSharedAssemblies

        internal override void ResultItemSelected(IConsole2 con, Object oResults)
        {
            IConsoleVerb icv;

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

            icv.SetVerbState(MMC_VERB.DELETE, MMC_BUTTON_STATE.ENABLED, 1);

            if (oResults is AssemInfo)
            {
                AssemInfo ai = (AssemInfo)oResults;

                // We only want to user to be able to copy this item if it is a GAC Assembly

                if (ai.nCacheType == ASM_CACHE.GAC)
                {
                    icv.SetVerbState(MMC_VERB.COPY, MMC_BUTTON_STATE.ENABLED, 1);
                }
            }
            else if (oResults is ArrayList)
            {
                // Run through the array list. If everything is from the GAC, then
                // we'll enable the copy verb
                ArrayList al        = (ArrayList)oResults;
                bool      fFoundZap = false;
                int       nIndex    = 0;
                while (!fFoundZap && nIndex < al.Count)
                {
                    if (((AssemInfo)m_olAssems[(int)(al[nIndex]) - 1]).nCacheType != ASM_CACHE.GAC)
                    {
                        fFoundZap = true;
                    }
                    nIndex++;
                }
                if (!fFoundZap)
                {
                    icv.SetVerbState(MMC_VERB.COPY, MMC_BUTTON_STATE.ENABLED, 1);
                }
            }

            icv.SetVerbState(MMC_VERB.CUT, MMC_BUTTON_STATE.ENABLED, 0);
        }// ResultItemSelected
コード例 #5
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