public CSVConnectorWelcomePage(WizardData wizardData) { if (wizardData == null) { throw new ArgumentNullException("wizardData"); } InitializeComponent(); this.DataContext = wizardData; this.csvConnectorWizardData = this.DataContext as CSVConnectorWizardData; this.Title = "Before You Begin"; this.FinishButtonText = "Create"; }
public CSVConnectorConfigurationPage(WizardData wizardData) { if (wizardData == null) { throw new ArgumentNullException("wizardData"); } InitializeComponent(); this.DataContext = wizardData; this.csvConnectorWizardData = this.DataContext as CSVConnectorWizardData; this.Title = "Configure the CSV Connector"; this.FinishButtonText = "Create"; }
public CSVConnectorResultPage(WizardData wizardData) { if (wizardData == null) { throw new ArgumentNullException("wizardData"); } InitializeComponent(); this.DataContext = wizardData; this.csvConnectorWizardData = this.DataContext as CSVConnectorWizardData; this.Title = "Completed"; this.FinishButtonText = "Close"; }
public CSVConnectorSummaryPage(WizardData wizardData) { if (wizardData == null) { throw new ArgumentNullException("wizardData"); } InitializeComponent(); this.DataContext = wizardData; this.csvConnectorWizardData = this.DataContext as CSVConnectorWizardData; this.Title = "Confirmation"; this.FinishButtonText = "Create"; this.IsNextButtonEnabled = false; this.IsFinishButtonEnabled = true; }
public override void ExecuteCommand(IList <NavigationModelNodeBase> nodes, NavigationModelNodeTask task, ICollection <string> parameters) { if (parameters.Contains("Create")) { WizardStory wizard = new WizardStory(); //Set the wizard icon and title bar ResourceManager rm = new ResourceManager("Microsoft.Demo.Connectors.Resources", typeof(Resources).Assembly); Bitmap bitmap = (Bitmap)rm.GetObject("CSVConnector"); IntPtr ptr = bitmap.GetHbitmap(); BitmapSource bitmapsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ptr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); wizard.StoryImage = bitmapsource; wizard.WizardWindowTitle = "Create CSV Connector"; //Create the wizard data WizardData data = new CSVConnectorWizardData(); wizard.WizardData = data; //Add the wizard pages wizard.AddLast(new WizardStep("Welcome", typeof(CSVConnectorWelcomePage), wizard.WizardData)); wizard.AddLast(new WizardStep("Configuration", typeof(CSVConnectorConfigurationPage), wizard.WizardData)); wizard.AddLast(new WizardStep("Summary", typeof(CSVConnectorSummaryPage), wizard.WizardData)); wizard.AddLast(new WizardStep("Results", typeof(CSVConnectorResultPage), wizard.WizardData)); //Create a wizard window and show it WizardWindow wizardwindow = new WizardWindow(wizard); // this is needed so that WinForms will pass messages on to the hosted WPF control System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(wizardwindow); wizardwindow.ShowDialog(); //Update the view when done with the wizard so that the new connector shows if (data.WizardResult == WizardResult.Success) { RequestViewRefresh(); } } else if (parameters.Contains("Edit")) { //Get the server name to connect to and connect to the server String strServerName = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\System Center\\2010\\Service Manager\\Console\\User Settings", "SDKServiceMachine", "localhost").ToString(); EnterpriseManagementGroup emg = new EnterpriseManagementGroup(strServerName); //Get the object using the selected node ID String strID = String.Empty; foreach (NavigationModelNodeBase node in nodes) { strID = node["$Id$"].ToString(); } EnterpriseManagementObject emoCSVConnector = emg.EntityObjects.GetObject <EnterpriseManagementObject>(new Guid(strID), ObjectQueryOptions.Default); //Create a new "wizard" (also used for property dialogs as in this case), set the title bar, create the data, and add the pages WizardStory wizard = new WizardStory(); wizard.WizardWindowTitle = "Edit CSV Connector"; WizardData data = new CSVConnectorWizardData(emoCSVConnector); wizard.WizardData = data; wizard.AddLast(new WizardStep("Configuration", typeof(CSVConnectorConfigurationPage), wizard.WizardData)); //Show the property page PropertySheetDialog wizardWindow = new PropertySheetDialog(wizard); //Update the view when done so the new values are shown bool?dialogResult = wizardWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value) { RequestViewRefresh(); } } else if (parameters.Contains("Delete") || parameters.Contains("Disable") || parameters.Contains("Enable")) { //Get the server name to connect to and create a connection String strServerName = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\System Center\\2010\\Service Manager\\Console\\User Settings", "SDKServiceMachine", "localhost").ToString(); EnterpriseManagementGroup emg = new EnterpriseManagementGroup(strServerName); //Get the object using the selected node ID String strID = String.Empty; foreach (NavigationModelNodeBase node in nodes) { strID = node["$Id$"].ToString(); } EnterpriseManagementObject emoCSVConnector = emg.EntityObjects.GetObject <EnterpriseManagementObject>(new Guid(strID), ObjectQueryOptions.Default); if (parameters.Contains("Delete")) { //Remove the object from the database IncrementalDiscoveryData idd = new IncrementalDiscoveryData(); idd.Remove(emoCSVConnector); idd.Commit(emg); } //Get the rule using the connector ID ManagementPack mpConnectors = emg.GetManagementPack("Microsoft.Demo.Connectors", null, new Version("1.0.0.0")); ManagementPackClass classCSVConnector = mpConnectors.GetClass("Microsoft.Demo.Connectors.CSVConnector"); String strConnectorID = emoCSVConnector[classCSVConnector, "Id"].ToString(); ManagementPackRule ruleConnector = mpConnectors.GetRule(strConnectorID); //Update the Enabled property or delete as appropriate if (parameters.Contains("Delete")) { ruleConnector.Status = ManagementPackElementStatus.PendingDelete; } else if (parameters.Contains("Disable")) { emoCSVConnector[classCSVConnector, "Enabled"].Value = false; ruleConnector.Enabled = ManagementPackMonitoringLevel.@false; ruleConnector.Status = ManagementPackElementStatus.PendingUpdate; } else if (parameters.Contains("Enable")) { emoCSVConnector[classCSVConnector, "Enabled"].Value = true; ruleConnector.Enabled = ManagementPackMonitoringLevel.@true; ruleConnector.Status = ManagementPackElementStatus.PendingUpdate; } //Commit the changes to the connector object and rule emoCSVConnector.Commit(); mpConnectors.AcceptChanges(); //Update the view when done so the item is either removed or the updated Enabled value shows RequestViewRefresh(); } }