}// onRestoreView internal override void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { if ((int)arg == 1) { CConfigStore.SetSetting("ShowHTMLForSharedAssem", (bool)param?"yes":"no"); m_fShowHTMLPage = (bool)param; // We'll change the result object but we won't refresh our result view // because the user doesn't necesarily want that to happen. However, // the next time the user visits this node, they will see the new result // view m_oResults = m_fShowHTMLPage?(Object)m_taskPad:(Object)this; } else if ((int)arg == 0) { m_oResults = this; RefreshResultView(); } else if ((int)arg == 2) { MenuCommand(COMMANDS.ADD_GACASSEMBLY, null); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(this), COMMANDS.ADD_GACASSEMBLY); } }// TaskPadTaskNotify
}// CComponent //------------------------------------------------- // Initialize // // This is where we'll get the interfaces for // IConsole2 and IDisplayHelp //------------------------------------------------- public void Initialize(Object pConsole) { // Let's query for the interfaces needed m_ucsole = (IConsole2)pConsole; m_DisplayHelp = (IDisplayHelp)pConsole; CNodeManager.CConsole = m_ucsole; }// Initialize
}// PSet internal override void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { if ((int)arg == 0) { m_oResults = this; RefreshResultView(); } else if ((int)arg == 1) { MenuCommand(COMMANDS.ADD_PERMISSIONS); } else if ((int)arg == 2) { OpenMyPropertyPage(); } else if ((int)arg == 3) { CConfigStore.SetSetting("ShowHTMLForPermissionSet", (bool)param?"yes":"no"); m_fShowHTMLPage = (bool)param; // We'll change the result object but we won't refresh our result view // because the user doesn't necesarily want that to happen. However, // the next time the user visits this node, they will see the new result // view m_oResults = m_fShowHTMLPage?(Object)m_taskpad:(Object)this; } }// TaskPadTaskNotify
}// MenuCommand internal override void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { // We want to browse this apps properties if ((int)arg == 0) { OpenMyPropertyPage(); } // We want to browse the Assembly Dependencies else if ((int)arg == 1) { CNode node = FindChild("Assembly Dependencies"); CNodeManager.SelectScopeItem(node.HScopeItem); node.MenuCommand(COMMANDS.SHOW_LISTVIEW); } // We want to Configure Assemblies else if ((int)arg == 2) { CNode node = FindChild("Configured Assemblies"); CNodeManager.SelectScopeItem(node.HScopeItem); } // We want to go to remoting node else if ((int)arg == 3) { CNode node = FindChild("Remoting Services"); CNodeManager.SelectScopeItem(node.HScopeItem); node.OpenMyPropertyPage(); } else if ((int)arg == 4) { MenuCommand(COMMANDS.FIX_APPLICATION); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(this), COMMANDS.FIX_APPLICATION); } }// TaskPadTaskNotify
}// CIntroTaskPad internal override void Notify(Object arg, Object param, IConsole2 con, CData com) { String sNodeToOpen = null; // We want to browse the shared assemblies if ((int)arg == 1) { sNodeToOpen = "Assembly Cache"; } // We want to Configure Assemblies else if ((int)arg == 2) { sNodeToOpen = "Configured Assemblies"; } // We want to set Security Policy else if ((int)arg == 3) { sNodeToOpen = "Runtime Security Policy"; } // We want to go to remoting node else if ((int)arg == 4) { CNode node = m_myNode.FindChild("Remoting Services"); CNodeManager.SelectScopeItem(node.HScopeItem); node.OpenMyPropertyPage(); } // We want to go to the applications node else if ((int)arg == 5) { sNodeToOpen = "Applications"; } // This is a CommandHistory item else if ((int)arg >= 100) { CCommandHistory.FireOffCommand((int)arg); } else { MessageBox(0, "Error in web page! I don't know what to do!", "", 0); } if (sNodeToOpen != null) { CNode node = m_myNode.FindChild(sNodeToOpen); // This node must have a shared assemblies node... if it doesn't, then the // node hasn't added it's children yet. We'll force it to do that, and try // again if (node == null) { m_myNode.CreateChildren(); node = m_myNode.FindChild(sNodeToOpen); } CNodeManager.Console.SelectScopeItem(node.HScopeItem); } }// Notify
}// CRemoting internal override void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { if ((int)arg == 0) { // We need to pop up this node's property page OpenMyPropertyPage(); } }// TaskPadTaskNotify
}// 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
}// MenuCommand internal override void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { if ((int)arg == 0) { // We need to pop up the Create New Permission Set wizard MenuCommand(COMMANDS.NEW_PERMISSIONSET); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(this), COMMANDS.NEW_PERMISSIONSET); } }// TaskPadTaskNotify
}// 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
}// TaskPadTaskNotify internal virtual void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { if (m_oResults is CTaskPad) { CTaskPad padinfo = (CTaskPad)m_oResults; padinfo.Notify(arg, param, con, com); } else { throw new Exception("I don't have a taskpad!"); } }// TaskPadTaskNotify
}// MenuCommand internal override void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { if ((int)arg == 1) { OpenMyPropertyPage(); } else if ((int)arg == 2) { // We want to Add a child code group to this codegroup MenuCommand(COMMANDS.CREATE_CODEGROUP); } }// TaskPadTaskNotify
}// 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
}// Init internal override void Notify(Object arg, Object param, IConsole2 con, CData com) { if ((int)arg == 1) { // We want to add a code condition for this machine } else if ((int)arg == 2) { // We want to edit a code condition for this machine } else if ((int)arg == 3) { // We want to Add a code condition for a specific user } else if ((int)arg == 4) { // We want to edit a code condition for a specific user } else if ((int)arg == 5) { // We want to add a permission set for a specific machine } else if ((int)arg == 6) { // We want to edit a permission set for a specific machine } else if ((int)arg == 7) { // We want to add a permission set for a specific user } else if ((int)arg == 8) { // We want to edit a permission set for a specific user } else if ((int)arg == 9) { // We want to add permissions } else if ((int)arg == 10) { // We want to remove permissions } else if ((int)arg == 11) { } else { base.Notify(arg, param, con, com); } }// Notify
// Methods to implement IEnumTask internal void BaseTaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { // Check to see if this is a HTML page telling us that it finished // loading.... if (arg is int && (int)arg == 100) { m_fStartResultRefresh = false; if (m_fWantToMakePropertyPageVisible) { ShowMyPropertyPageIfOpen(); } } TaskPadTaskNotify(arg, param, con, com); }// TaskPadTaskNotify
}// CGenAppTaskPad internal override void Notify(Object arg, Object param, IConsole2 con, CData com) { if ((int)arg == 1) { // We need to fire up the Add application wizard. m_myNode.MenuCommand(COMMANDS.ADD_APPLICATION); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(m_myNode), COMMANDS.ADD_APPLICATION); } else if ((int)arg == 2) { m_myNode.MenuCommand(COMMANDS.FIX_APPLICATION); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(m_myNode), COMMANDS.FIX_APPLICATION); } }// Notify
}// onDelete internal override void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { if ((int)arg == 1) { CConfigStore.SetSetting("ShowHTMLForFullTrustAssem", (bool)param?"yes":"no"); m_fShowHTMLPage = (bool)param; // We'll change the result object but we won't refresh our result view // because the user doesn't necesarily want that to happen. However, // the next time the user visits this node, they will see the new result // view m_oResults = m_fShowHTMLPage?(Object)m_taskPad:(Object)this; } else if ((int)arg == 0) { m_oResults = this; RefreshResultView(); } }// TaskPadTaskNotify
}// 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
protected bool IsUseSmallIcons() { IConsole2 console = Snapin.ResultViewConsole; if (console != null) { IResultData resultdata = console as IResultData; if (resultdata != null) { int viewType = 0; resultdata.GetViewMode(out viewType); return(viewType != 0); } } // Default to small icons. return(true); }
}// CheckCurrentPermissions internal override void TaskPadTaskNotify(Object arg, Object param, IConsole2 con, CData com) { if ((int)arg == 0) { // We need to pop up the "Trust an App Wizard" MenuCommand(COMMANDS.TRUST_ASSEMBLY); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(this), COMMANDS.TRUST_ASSEMBLY); } if ((int)arg == 1) { // We need to pop up the "Adjust Security Settings Wizard" MenuCommand(COMMANDS.ADJUST_SECURITYPOLICY); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(this), COMMANDS.ADJUST_SECURITYPOLICY); } if ((int)arg == 2) { // We need to pop up the "Evaluate Assembly" MenuCommand(COMMANDS.EVALUATE_ASSEMBLY); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(this), COMMANDS.EVALUATE_ASSEMBLY); } if ((int)arg == 3) { // We need to pop up the "Create Deployment Package Wizard" MenuCommand(COMMANDS.CREATE_MSI); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(this), COMMANDS.CREATE_MSI); } if ((int)arg == 4) { // We need to do the reset thing MenuCommand(COMMANDS.RESET_POLICY); // Inform our Command History that we did this CCommandHistory.CommandExecuted(new CDO(this), COMMANDS.RESET_POLICY); } }// TaskPadTaskNotify
//------------------------------------------------- // CData - Constructor // // The constructor is responsible for constructing // the nodes that will be displayed in the snapin //------------------------------------------------- public CData() { if (m_rn != null) { throw new Exception(CResourceStore.GetString("CData::OnlyOneInstanceofSnapin")); } // First, null out all the member variables m_Component = new ArrayList(); m_ucsole = null; m_ucsoleNameSpace = null; m_rn = new CRootNode(); // Register ourselves with the Node Manager CNodeManager.Data = this; // Let's generate our own computer node CNodeManager.Init(); CNodeManager.RootNodeCookie = CNodeManager.AddNode(ref m_rn); }// CData
}// CData //------------------------------------------------- // Initialize // // This function is responsible for recieving the // MMC Console interface, and I also have it inserting // all the images MMC will need to display the snapin //------------------------------------------------- public void Initialize(Object pUnknown) { try { m_ucsole = (IConsole2)pUnknown; m_ucsoleNameSpace = (IConsoleNameSpace2)pUnknown; } catch (Exception) { // If this fails, it's because we're not on MMC 1.2 or later MessageBox(0, CResourceStore.GetString("CData:RequireVersionofMMC"), CResourceStore.GetString("CData:RequireVersionofMMCTitle"), MB.ICONEXCLAMATION); return; } CNodeManager.Console = m_ucsole; IntPtr hWnd; m_ucsole.GetMainWindow(out hWnd); CNodeManager.MMChWnd = hWnd; CNodeManager.CNamespace = m_ucsoleNameSpace; // Now we'll add the images we need for the snapin IImageList il = null; m_ucsole.QueryScopeImageList(out il); // ALL icons that need to be displayed in the lefthand pane MUST be // 'registered' here if (il != null) { il.ImageListSetIcon(CResourceStore.GetHIcon("NETappicon_ico"), CResourceStore.GetIconCookie("NETappicon_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("mycomputer_ico"), CResourceStore.GetIconCookie("mycomputer_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("configassemblies_ico"), CResourceStore.GetIconCookie("configassemblies_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("enterprisepolicy_ico"), CResourceStore.GetIconCookie("enterprisepolicy_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("machinepolicy_ico"), CResourceStore.GetIconCookie("machinepolicy_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("userpolicy_ico"), CResourceStore.GetIconCookie("userpolicy_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("codegroups_ico"), CResourceStore.GetIconCookie("codegroups_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("singlecodegroup_ico"), CResourceStore.GetIconCookie("singlecodegroup_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("customcodegroup_ico"), CResourceStore.GetIconCookie("customcodegroup_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("permissionsets_ico"), CResourceStore.GetIconCookie("permissionsets_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("permissionset_ico"), CResourceStore.GetIconCookie("permissionset_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("policyassemblies_ico"), CResourceStore.GetIconCookie("policyassemblies_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("assemblies_ico"), CResourceStore.GetIconCookie("assemblies_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("sharedassemblies_ico"), CResourceStore.GetIconCookie("sharedassemblies_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("remoting_ico"), CResourceStore.GetIconCookie("remoting_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("security_ico"), CResourceStore.GetIconCookie("security_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("applications_ico"), CResourceStore.GetIconCookie("applications_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("application_ico"), CResourceStore.GetIconCookie("application_ico")); il.ImageListSetIcon(CResourceStore.GetHIcon("readonlypolicy_ico"), CResourceStore.GetIconCookie("readonlypolicy_ico")); } }// Initialize
}// GetIColumnResultView //------------------------------------------------- // onShow // // This function will be used only if a column view is // to be presented in the result pane. //------------------------------------------------- internal void onShow(IConsole2 Console, IntPtr arg, IntPtr param) { if ((int)arg == 0) { Leaving(); } // Let's make sure we do have a list view item to display if ((int)arg > 0 && m_oResults != null && m_oResults is IColumnResultView) { IColumnResultView crv = (IColumnResultView)m_oResults; // If we're here then we have stuff to add to the result // view (beyond the standard view) // Query the Conole for a couple interfaces to use IHeaderCtrl HeaderCtrl = (IHeaderCtrl)Console; IResultData ResultData = (IResultData)Console; // Add/Remove Multi-Select ability if (m_fAllowMultiSelectResults) { ResultData.ModifyViewStyle(0, MMC.SINGLESEL); } else { ResultData.ModifyViewStyle(MMC.SINGLESEL, 0); } // Let's put in the column titles and find out how wide // each column should be int iNumCols = crv.getNumColumns(); int iNumRows = crv.getNumRows(); for (int i = 0; i < iNumCols; i++) { int iMaxLength = crv.getColumnTitles(i).Length; for (int j = 0; j < iNumRows; j++) { if (crv.getValues(j, i) != null) { int iTempLength = crv.getValues(j, i).Length; if (iTempLength > iMaxLength) { iMaxLength = iTempLength; } } } int nWidth = GetColumnWidth(i, iMaxLength); HeaderCtrl.InsertColumn(i, crv.getColumnTitles(i), LVCFMT.LEFT, nWidth); } RESULTDATAITEM rdi = new RESULTDATAITEM(); for (int n = 0; n < iNumRows; n++) { rdi.mask = RDI.STR | RDI.PARAM; rdi.nImage = crv.GetImageIndex(n); // If we have a valid image, tell MMC to display it. if (rdi.nImage != -1) { rdi.mask |= RDI.IMAGE; } rdi.str = (IntPtr)(-1); rdi.nCol = 0; // We're doing the lParam a little differently. The low word contains the cookie // for this node, while the high word contains the row number + 1 we're inserting rdi.lParam = m_iCookie | ((n + 1) << 16); ResultData.InsertItem(ref rdi); } } }// onShow
}// HaveGroup internal virtual void Notify(Object arg, Object param, IConsole2 con, CData com) { throw new Exception("I don't support his notification"); }// Notify
}// ResultItemSelected internal virtual void ResultItemUnSelected(IConsole2 con, Object oResults) { }// ResultItemUnSelected