}// RemoveSpecificChild protected void RemoveSpecificChildByIndex(int nIndex) { // Have this child remove all his children nodes as well ArrayList al = new ArrayList(); al.Add(CNodeManager.GetNode(Child[nIndex])); int i = 0; while (i < al.Count) { // Put all this guy's children in the queue as well CNode node = (CNode)al[i]; for (int j = 0; j < node.NumChildren; j++) { al.Add(CNodeManager.GetNode(node.Child[j])); } i++; } // Start from the bottom and work our way up while (al.Count > 0) { CNode node = (CNode)al[al.Count - 1]; // First, close any property pages associated with it node.CloseAllMyPropertyPages(); // Inform MMC of this removal CNodeManager.CNamespace.DeleteItem(node.HScopeItem, 1); // Remove this node from the list CNodeManager.RemoveNode(node.Cookie); al.RemoveAt(al.Count - 1); } }// RemoveSpecificChildByIndex
}// onTextChange void onBrowse(Object o, EventArgs e) { // Pop up a file dialog so the user can find an assembly OpenFileDialog fd = new OpenFileDialog(); fd.Title = CResourceStore.GetString("CTrustAppWiz2:ChooseAssemFDTitle"); fd.Filter = CResourceStore.GetString("AssemFDMask"); System.Windows.Forms.DialogResult dr = fd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { if (Fusion.isManaged(fd.FileName)) { m_txtFilename.Text = fd.FileName; // Inform our wizard that we have a new assembly for it to try and load CFullTrustWizard wiz = (CFullTrustWizard)CNodeManager.GetNode(m_iCookie); wiz.NewAssembly(); } else { MessageBox(CResourceStore.GetString("isNotManagedCode"), CResourceStore.GetString("isNotManagedCodeTitle"), MB.ICONEXCLAMATION); } } } // onBrowse
}// MenuCommand private CNode CheckForDuplicateApp(AppFiles af) { // Run through this node's children to see if a node with this app file exists int iNumChildren = NumChildren; for (int i = 0; i < iNumChildren; i++) { CNode node = CNodeManager.GetNode(Child[i]); if (node is CApplication) { AppFiles afNode = ((CApplication)node).MyAppInfo; // Check the App file's name if ((af.sAppFile == null && afNode.sAppFile == null) || af.sAppFile.Equals(afNode.sAppFile)) { // Check the App File's config file if ((af.sAppConfigFile == null && afNode.sAppConfigFile == null) || af.sAppConfigFile.Equals(afNode.sAppConfigFile)) { return(node); } } } } // We couldn't find a node with that app info return(null); }// CheckForDuplicateApp
}// QueryDataObject //------------------------------------------------- // GetResultViewType // // This function is called when MMC needs to display // a specific node's information in the result pane. //------------------------------------------------- public int GetResultViewType(int cookie, out IntPtr ppViewType, out uint pViewOptions) { CNode node = CNodeManager.GetNode(cookie); CNodeManager.DisplayedNode = node; node.Showing(); // We never want the "view" menu to appear pViewOptions = MMC_VIEW_OPTIONS.NOLISTVIEWS | MMC_VIEW_OPTIONS.CREATENEW; // CNode.Result can be potientially expensive... make sure // we catch the result here. String res = node.Result; // We don't have a HTML (or taspad) to display, so we'll just show a // standard list view if (res == null) { ppViewType = (IntPtr)0; return(HRESULT.S_FALSE); } // Ok, we're displaying a HTML page or a Taskpad ppViewType = Marshal.StringToCoTaskMemUni(res); return(HRESULT.S_OK); }// GetResultViewType
}// InsertPropSheetPageControls //------------------------------------------------- // PutValuesinPage // // This function put data onto the property page //------------------------------------------------- private void PutValuesinPage() { // Get info that we'll need from the node CNode node = CNodeManager.GetNode(m_iCookie); // This should be ok now, but if we need this functionality // off of different nodes..... CVersionPolicy vp = (CVersionPolicy)node; m_txtAssemName.Text = m_bri.Name; m_txtPublicKeyToken.Text = m_bri.PublicKeyToken; // Figure out the current Publisher Policy Setting String sGetSettingString = "PublisherPolicyFor" + m_bri.Name + "," + m_bri.PublicKeyToken; // If we are getting this from an App config file, let's add that info m_sConfigFile = vp.ConfigFile; if (m_sConfigFile != null) { sGetSettingString += "," + m_sConfigFile; bool fUsePubPolicy = (bool)CConfigStore.GetSetting(sGetSettingString); m_chkPubPolicy.Checked = fUsePubPolicy; } // If this isn't an app config file, we don't want to show the // 'Apply Publisher Policy' Checkbox or description else { m_chkPubPolicy.Visible = false; m_lblPublisherPolicyHelp.Visible = false; } }// PutValuesinPage
}// onDoubleClick internal override int onDelete(Object o) { String sMessage; if (o is ArrayList) { sMessage = CResourceStore.GetString("CVersionPolicy:ConfirmDeleteConfig"); } else { sMessage = String.Format(CResourceStore.GetString("CVersionPolicy:ConfirmDeleteSingleConfig"), ((BindingRedirInfo)o).Name); } int nRes = MessageBox(sMessage, CResourceStore.GetString("CVersionPolicy:ConfirmDeleteConfigTitle"), MB.ICONQUESTION | MB.YESNO); if (nRes == MB.IDYES) { // Let's trace through our parents looking for an Application node CNode node = CNodeManager.GetNode(m_iCookie); // If this node's parent is an Application node, then we know we're // configuring assemblies on a per app basis int iParentHScope = node.ParentHScopeItem; if (iParentHScope != -1) { node = CNodeManager.GetNodeByHScope(iParentHScope); } String sPostFix = ""; // If this is an application node, make sure we tell the config store // about it if (node is CApplication) { sPostFix = "," + ((CApplication)node).AppConfigFile; } if (o is ArrayList) { ArrayList al = (ArrayList)o; int nLen = al.Count; for (int i = 0; i < nLen; i++) { int iResultNum = ((int)al[i]) - 1; CConfigStore.SetSetting("ConfiguredAssembliesDelete" + sPostFix, ((BindingRedirInfo)m_ol[iResultNum])); } } else { CConfigStore.SetSetting("ConfiguredAssembliesDelete" + sPostFix, (BindingRedirInfo)o); } // Now we'll Refresh ourselves RefreshResultView(); } return(HRESULT.S_OK); }// onDelete
}// Location //------------------------------------------------- // Init // // This function is called when we're ready to use // the property page. We pass in the cookie of the // node that this property page belongs to, and we // should do any setup information (with the exception // of creating Winform controls) here. //------------------------------------------------- internal virtual void Init(int iCookie, IntPtr routerhandle) { m_iCookie = iCookie; // We won't cache the node, in case it changes somehow // during the life of the property page CNode node = CNodeManager.GetNode(m_iCookie); m_hIcon = node.IconHandle; m_hPropertyPageRouter = routerhandle; }// Init
}// CanMakeChanges internal void SecurityPolicyChanged() { // Tell our parent node something changed CSecurityNode node = CNodeManager.GetNode(m_iCookie) as CSecurityNode; if (node != null) { node.SecurityPolicyChanged(); } } // SecurityPolicyChanged
}// GetResultViewType //------------------------------------------------- // GetDisplayInfo // // This function is called by MMC whenever it needs to // display a node in the result view. //------------------------------------------------- public void GetDisplayInfo(ref RESULTDATAITEM ResultDataItem) { // The low word in the lParam contains the index of the node // we're interested in. CNode NodeWeWant = CNodeManager.GetNode((int)ResultDataItem.lParam & 0xffff); // We'll let the node take care of its own Result Data NodeWeWant.GetResultDisplayInfo(ref ResultDataItem); }// GetDisplayInfo
}// ApplyData internal void CloseSheet() { if (m_iCookie != -1) { CNodeManager.GetNode(m_iCookie).FreePropertySheetNotifyHandle(); } m_iCookie = -1; PostMessage(GetParent(m_hWnd), WM.COMMAND, 2 /*IDCANCEL*/, 0); // Set focus to the sheet to make sure it goes away. PostMessage(GetParent(m_hWnd), WM.SETFOCUS, 0, 0); }// CloseSheet
}// InsertChildren internal void InsertSpecificChild(int iChild) { SCOPEDATAITEM sdi = new SCOPEDATAITEM(); CNode nChild = CNodeManager.GetNode(iChild); sdi.mask = SDI.STR | SDI.PARAM | SDI.PARENT | SDI.IMAGE | SDI.OPENIMAGE | SDI.CHILDREN; // The image index is going to be the same as the cookie value sdi.nImage = CResourceStore.GetIconCookie(nChild.IconHandle); // The open image is the same as the closed image sdi.nOpenImage = sdi.nImage; sdi.relativeID = m_iHScopeItem; // We set displayname to -1 to initiate a callback for the string // (We need to do it this way... it's an MMCism) sdi.displayname = (IntPtr)(-1); sdi.lParam = nChild.Cookie; // The children field is set to either 0 or 1 (if it has children or not) sdi.cChildren = (nChild.NumChildren == 0)?0:1; // Once the item has been inserted, we're given the HScopeItem value for the node // MMC uses this value to uniquely identify the node. We'll store it for future // use. nChild.HScopeItem = CNodeManager.InsertItem(sdi); // We'll also put in the parent's HScopeItem nChild.m_iParentHScopeItem = HScopeItem; // Also, we can be slick and expand this child's node too // We don't care about perf savings after startup... do the expansion now // Also, if we have a non MMC host, we're not sure how it will behave // if it doesn't have all the nodes. Let's force the expand if we're not // running under MMC if (m_fInitialCreationDone || CNodeManager.Console is INonMMCHost) { // Expand this child CNodeManager.ExpandNodeNamespace(nChild.HScopeItem); } else if (Cookie == 0) { Thread t = new Thread(new ThreadStart(nChild.LazyExpand)); t.Start(); } }// InsertSpecificChild
}// InsertPropSheetPageControls void onSavePolicyClick(Object o, EventArgs e) { CWizard wiz = (CWizard)CNodeManager.GetNode(m_iCookie); if (m_chkSavePolicy.Checked) { wiz.TurnOnNext(true); } else { wiz.TurnOnNext(false); } } // onSavePolicyClick
}// AddMenuItems internal override void MenuCommand(int iCommandID, Object oResultNum) { if (iCommandID == COMMANDS.ADD_ASSEMBLY) { CApplicationDepends appDepends = null; // Let's trace through our parents looking for an Application node CNode node = CNodeManager.GetNode(m_iCookie); // If this node's parent is an Application node, then we know we're // configuring assemblies on a per app basis int iParentHScope = node.ParentHScopeItem; if (iParentHScope != -1) { node = CNodeManager.GetNodeByHScope(iParentHScope); } // If this is an application node, make sure we tell the config store // about it if (node is CApplication) { // Cool, we have a dependent assemblies node appDepends = ((CApplication)node).AppDependsNode; } CConfigAssemWizard wiz = new CConfigAssemWizard(appDepends); wiz.LaunchWizard(Cookie); if (wiz.NewAssembly != null) { if (AddConfiguredAssembly(wiz.NewAssembly)) { onDoubleClick(wiz.NewAssembly); } } } else if (iCommandID == COMMANDS.SHOW_LISTVIEW) { m_oResults = this; RefreshResultView(); m_fShowHTMLPage = false; } else if (iCommandID == COMMANDS.SHOW_TASKPAD) { m_oResults = m_taskPad; m_fShowHTMLPage = true; // The HTML pages comes displayed with this checkbox marked. Make // sure we update the xml setting CConfigStore.SetSetting("ShowHTMLForConfigAssem", "yes"); RefreshResultView(); } }// MenuCommand
}// isForHomeUser void onTextChange(Object o, EventArgs e) { CFullTrustWizard wiz = (CFullTrustWizard)CNodeManager.GetNode(m_iCookie); // The assembly we were looking at changed. wiz.WipeEvidence(); if (m_txtFilename.Text.Length > 0) { wiz.TurnOnNext(true); } else { wiz.TurnOnNext(false); } }// onTextChange
}// InsertSpecificChild internal CNode FindChild(String s) { int iNumChildren = NumChildren; for (int i = 0; i < iNumChildren; i++) { CNode node = CNodeManager.GetNode(Child[i]); if (node.Name.Equals(s)) { return(node); } } // We couldn't find that child return(null); }// FindChild
}// ImportedPermissionSet void onTextChange(Object o, EventArgs e) { CWizard wiz = (CWizard)CNodeManager.GetNode(m_iCookie); if (m_radCreateNew.Checked) { // See if we should turn on the Next button bool fTurnOnNext = m_txtName.Text.Length > 0; wiz.TurnOnNext(fTurnOnNext); } else { // If they have a filename, then we be messing with the finish button bool fTurnOnFinish = m_txtFilename.Text.Length > 0; wiz.TurnOnFinish(fTurnOnFinish); } }// onTextChange
}// onDeleteEntireRow private void PutValuesinPage() { // Get info that we'll need from the node CNode node = CNodeManager.GetNode(m_iCookie); // This should be ok now, but if we need this functionality // off of different nodes..... CVersionPolicy vp = (CVersionPolicy)node; String sGetSettingString = "BindingPolicyFor" + m_bri.Name + "," + m_bri.PublicKeyToken; // If we are getting this from an App config file, let's add that info m_sConfigFile = vp.ConfigFile; if (m_sConfigFile != null) { sGetSettingString += "," + m_sConfigFile; } BindingPolicy bp = (BindingPolicy)CConfigStore.GetSetting(sGetSettingString); int iLen = bp.scBaseVersion.Count; for (int i = 0; i < iLen; i++) { DataRow newRow; newRow = m_dt.NewRow(); newRow["Requested Version"] = bp.scBaseVersion[i]; newRow["New Version"] = bp.scRedirectVersion[i]; m_dt.Rows.Add(newRow); } // We want to have at least 1 row while (m_dt.Rows.Count < 1) { DataRow newRow; newRow = m_dt.NewRow(); newRow["Requested Version"] = ""; newRow["New Version"] = ""; m_dt.Rows.Add(newRow); } m_dg.CurrentCell = new DataGridCell(iLen, 0); }// PutValuesinPage
}// CreateCodegroup private CSingleCodeGroup FindExistingCodegroup(PolicyLevel pl, IMembershipCondition mc) { // If we have an existing one, it should be right under the root node CSingleCodeGroup scgParent = Security.GetRootCodeGroupNode(pl); for (int i = 0; i < scgParent.NumChildren; i++) { CSingleCodeGroup scg = (CSingleCodeGroup)CNodeManager.GetNode(scgParent.Child[i]); // See if we have a matching membership condition and the description // says it's one the wizard created if (scg.MyCodeGroup.MembershipCondition.ToString().Equals(mc.ToString()) && scg.MyCodeGroup.Description.Equals(CResourceStore.GetString("GeneratedCodegroup"))) { return(scg); } } // We weren't able to find one return(null); }// FindExistingCodegroup