public TaskContext ShowWizard(AbstractController controller, out string message)
        {
            message = string.Empty;

            if (_action == Enumerators.Action.None)
            {
                message = PluginResources.WizardMessage_NoActionSelected;
                return(null);
            }

            var success = CreateWizardContext(controller, out message);

            if (!success)
            {
                return(null);
            }

            _isCancelled          = false;
            _wizardWindow         = new WizardWindow();
            _wizardWindow.Loaded += WizardWindowLoaded;
            _wizardWindow.ShowDialog();

            if (!_isCancelled && _taskContext.Completed)
            {
                if (_action == Enumerators.Action.Import || _action == Enumerators.Action.ImportBackTranslation)
                {
                    _controllers.ProjectsController.RefreshProjects();
                }

                return(_taskContext);
            }

            return(null);
        }
Exemple #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            var window = new WizardWindow(ExampleWizard.Wizard);
            window.ShowDialog();
            var window3 = new WizardWindow(
                new Wizard() { Title = "Test",
                    Pages = new List<WizardPage>{new WizardPage{Header="Test", InputFields=new WizardInputField[]{
                        new WizardFieldDescription{Description = "Test *bold*" },
                    new TextWizardInputField{Text="Value"}}}}});
            window3.ShowDialog();
        }
        public WizardContext ShowWizard(AbstractController controller, out string message)
        {
            message = string.Empty;

            if (_action == Enumerators.Action.None)
            {
                message = PluginResources.WizardMessage_NoActionSelected;
                return(null);
            }

            var success = CreateWizardContext(controller, out message);

            if (!success)
            {
                return(null);
            }

            var documents = _controllers.EditorController.GetDocuments();

            if (documents.Any())
            {
                message = PluginResources.WizardMessage_CloseOpenDocumentsInTheEditor;
                return(null);
            }


            _isCancelled          = false;
            _wizardWindow         = new WizardWindow();
            _wizardWindow.Loaded += WizardWindowLoaded;
            _wizardWindow.ShowDialog();

            if (!_isCancelled && _wizardContext.Completed)
            {
                if (_action == Enumerators.Action.Import)
                {
                    _controllers.ProjectsController.RefreshProjects();
                }

                return(_wizardContext);
            }

            return(null);
        }
Exemple #4
0
        public void RunStarted(
            object automationObject,
            Dictionary<string, string> replacementsDictionary,
            WizardRunKind runKind,
            object[] customParams)
        {
            Validate(ProjectNameToken, TryValidateProjectName, replacementsDictionary);
            Validate(ProjectSolutionDirectory, TryValidateSolutionDirectory, replacementsDictionary);

            var mainWindow = new WizardWindow(_wizard);
            var result = mainWindow.ShowDialog();
            if (result.HasValue && result.Value) {
                foreach (var page in _wizard.Pages)
                    foreach (var inputField in page.InputFields)
                        inputField.AddValue(replacementsDictionary);
            }

            // otherwise, cancel.
            throw new WizardCancelledException();
        }
        /// <summary>
        /// Opens wizard window with ReserveSeats view
        /// Locks selected seats
        /// </summary>
        private void OnReserveSeats()
        {
            if (_wizardWindow == null)
            {
                WizardTitle   = "Создать заказ";
                FirstName     = String.Empty;
                MiddleName    = String.Empty;
                LastName      = String.Empty;
                CustomerEmail = String.Empty;
                CustomerPhone = String.Empty;
                SendSms       = false;

                LockSeats(SelectedSpots.ToArray());
                _wisardStep = WisardStep.Locked;

                _wizardWindow = new WizardWindow {
                    Owner = MetroWindow
                };

                ContentWindow = new ReserveViewModel(Instance);
                _wizardWindow.ShowDialog();
            }
        }
Exemple #6
0
        public ProjectConnectorData CreateProjectConnector()
        {
            try
            {
                WizardStory wizard = new WizardStory();
                //set the SCSM default connector icon here...
                wizard.WizardWindowTitle = ServiceManagerLocalization.GetStringFromManagementPack("strCreateConnector");
                ProjectConnectorData data = new ProjectConnectorData();

                //set the data.
                data.WizardMode   = WizardMode.Wizard;
                wizard.WizardData = data;

                //pages
                //add the connector setup pages here.
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strGeneral"), typeof(GeneralWizardPage), wizard.WizardData));
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strPWAConnectionPage"), typeof(PWAWizardPage), wizard.WizardData));
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strSchedulePage"), typeof(ScheduleWizardPage), wizard.WizardData));
                wizard.AddLast(new WizardStep(ServiceManagerLocalization.GetStringFromManagementPack("strResults"), typeof(ResultsWizardPage), wizard.WizardData));

                WizardWindow wizardWindow = new WizardWindow(wizard);
                ElementHost.EnableModelessKeyboardInterop(wizardWindow);

                //window properties
                wizardWindow.ShowInTaskbar         = true;
                wizardWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                wizardWindow.Icon = BitmapFrame.Create(System.Windows.Application.GetResourceStream(new Uri("pack://application:,,,/Microsoft.EnterpriseManagement.ServiceManager.ProjectServer.ConsoleTasks;component/Icons/Image.Cireson.16x16.ico", UriKind.RelativeOrAbsolute)).Stream);
                wizardWindow.ShowDialog();
                return(data);
            }
            catch (Exception ex)
            {
                ConsoleContextHelper.Instance.ShowErrorDialog(ex, string.Empty, ConsoleJobExceptionSeverity.Error);
                return(null);
            }
        }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            // Store a copy of the replacements dictionary, used later for deleting the project if it was cancelled
            _replacementsDictionary = replacementsDictionary;
            string projectName          = replacementsDictionary["$projectname$"];
            string destinationDirectory = replacementsDictionary["$destinationdirectory$"];

            #region VSTemplate Parsing for NuGet Packages
            // Parse the VSTemplate for nuget package entries, this is the only way AFAIK to make them optional but at the detriment of them having to be downloaded
            // instead of locally available in the VSIX...
            if (customParams.Length > 0)
            {
                var vsTemplate = XDocument.Load((string)customParams[0]);
                IEnumerable <XElement> parsedPackages = vsTemplate.Descendants().Where(x => x.Name.LocalName == "package");

                foreach (XElement parsedPackage in parsedPackages)
                {
                    _nugetPackages.Add(parsedPackage.Attribute("id").Value);
                }
            }
            #endregion

            try
            {
                // Create a new instance of the WizardWindow
                wizardWindow = new WizardWindow();

                if (wizardWindow.ShowDialog().Value == true)
                {
                    // Set up the paths we need for the configuration. & should automatically be escaped with &amp;
                    bannerlordDirectory = wizardWindow.BannerlordDirectory;
                    bannerlordExe       = bannerlordDirectory + @"\bin\Win64_Shipping_Client\Bannerlord.exe";
                    createSubModule     = wizardWindow.IncludeSubModule;
                    createReadme        = wizardWindow.IncludeReadme;
                    addHarmony          = wizardWindow.IncludeHarmony;
                    useLauncherMods     = wizardWindow.UseLauncherMods;

                    // Parse the Bannerlord Launcher to find what modules were last used
                    StringBuilder argumentString = new StringBuilder();
                    List <string> moduleList     = wizardWindow.LauncherMods;

                    if (moduleList != null && moduleList.Count >= 1 && useLauncherMods)
                    {
                        argumentString.Append("/singleplayer _MODULES_*");
                        foreach (string module in moduleList)
                        {
                            argumentString.Append($"{module}*");
                        }
                        argumentString.Append($"{replacementsDictionary["$safeprojectname$"]}*_MODULES_");
                    }
                    else
                    {
                        argumentString.Append($"/singleplayer _MODULES_*Native*SandBoxCore*SandBox*StoryMode*CustomBattle*{replacementsDictionary["$safeprojectname$"]}*_MODULES_");
                    }

                    // Add our custom replacements to the dictionary
                    replacementsDictionary.Add("$BannerlordDirectory$", bannerlordDirectory);
                    replacementsDictionary.Add("$BannerlordExecutable$", bannerlordExe);
                    replacementsDictionary.Add("$BannerlordDebugArgs$", argumentString.ToString());

                    // We should be done now, close the window
                    wizardWindow.Close();
                }
                else
                {
                    // The user clicked cancel or closed the window, throw the exception
                    wizardWindow.Close();
                    throw new WizardBackoutException();
                }
            } catch (Exception ex) {
                if (ex.GetType().IsAssignableFrom(typeof(WizardBackoutException)) || ex.GetType().IsAssignableFrom(typeof(WizardCancelledException)))
                {
                    // Project folder would still have been created, clean it up if the user decided to back out
                    string projectFolder = Path.GetFullPath(Path.Combine(destinationDirectory, @"..\"));

                    if (Directory.Exists(projectFolder))
                    {
                        Directory.Delete(projectFolder, true);
                    }
                    else
                    {
                        Directory.Delete(destinationDirectory, true);
                    }
                    throw;
                }
                else
                {
                    MessageBox.Show($"An error has occurred!\n\nError Message:\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        public override void ExecuteCommand(IList<NavigationModelNodeBase> nodes, NavigationModelNodeTask task, ICollection<string> parameters)
        {
            if (parameters.Contains("Create"))
            {
                WizardStory wizard = new WizardStory();

                //set the icon and title bar
                ResourceManager rm = new ResourceManager("SCSM.Azureautomation.WPF.Connector.Resources", typeof(Resources).Assembly);
                Bitmap bitmap = (Bitmap)rm.GetObject("AzureAutomation2x32");
                IntPtr ptr = bitmap.GetHbitmap();
                BitmapSource bitmapsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ptr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                wizard.StoryImage = bitmapsource;
                wizard.WizardWindowTitle = "Create Azure Automation Connector";

                WizardData data = new AzureAutomationWizardData();
                wizard.WizardData = data;

                //add th pages
                wizard.AddLast(new WizardStep("Welcome", typeof(AzureAutomationWelcomePage), wizard.WizardData));
                wizard.AddLast(new WizardStep("Configuration", typeof(AzureAutomationConfigurationPage), wizard.WizardData));
                wizard.AddLast(new WizardStep("Summary", typeof(AzureAutomationSummaryPage), wizard.WizardData));
                wizard.AddLast(new WizardStep("Results", typeof(AzureAutomationResultPage), 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 emoAAConnector = 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 Azure Automation Connector";
                WizardData data = new AzureAutomationWizardData(emoAAConnector);
                wizard.WizardData = data;
                wizard.AddLast(new WizardStep("Configuration", typeof(AzureAutomationConfigurationPage), 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 emoAAConnector = 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(emoAAConnector);
                    idd.Commit(emg);
                }

                //Get the rule using the connector ID
                ManagementPack mpConnectors = emg.GetManagementPack("SCSM.AzureAutomation", null, new Version("1.0.0.0"));
                ManagementPackClass classAAConnector = mpConnectors.GetClass("SCSM.AzureAutomation.Connector");
                String strConnectorID = emoAAConnector[classAAConnector, "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"))
                {
                    emoAAConnector[classAAConnector, "Enabled"].Value = false;
                    ruleConnector.Enabled = ManagementPackMonitoringLevel.@false;
                    ruleConnector.Status = ManagementPackElementStatus.PendingUpdate;
                }
                else if (parameters.Contains("Enable"))
                {
                    emoAAConnector[classAAConnector, "Enabled"].Value = true;
                    ruleConnector.Enabled = ManagementPackMonitoringLevel.@true;
                    ruleConnector.Status = ManagementPackElementStatus.PendingUpdate;
                }

                //Commit the changes to the connector object and rule
                emoAAConnector.Commit();
                mpConnectors.AcceptChanges();

                //Update the view when done so the item is either removed or the updated Enabled value shows
                RequestViewRefresh();
            }
        }
        public override void ExecuteCommand(IList <NavigationModelNodeBase> nodes, NavigationModelNodeTask task, ICollection <string> parameters)
        {
            if (parameters.Contains("Create"))
            {
                WizardStory wizard = new WizardStory();

                //set the icon and title bar
                ResourceManager rm           = new ResourceManager("SCSM.AzureAutomation.WPF.Connector.Resources", typeof(Resources).Assembly);
                Bitmap          bitmap       = (Bitmap)rm.GetObject("AzureAutomation2x24");
                IntPtr          ptr          = bitmap.GetHbitmap();
                BitmapSource    bitmapsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ptr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                wizard.StoryImage        = bitmapsource;
                wizard.WizardWindowTitle = "Create Azure Automation Connector";

                WizardData data = new AzureAutomationWizardData();
                wizard.WizardData = data;

                //add th pages
                wizard.AddLast(new WizardStep("Welcome", typeof(AzureAutomationWelcomePage), wizard.WizardData));
                wizard.AddLast(new WizardStep("Configuration", typeof(AzureAutomationConfigurationPage), wizard.WizardData));
                wizard.AddLast(new WizardStep("Summary", typeof(AzureAutomationSummaryPage), wizard.WizardData));
                wizard.AddLast(new WizardStep("Results", typeof(AzureAutomationResultPage), 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 emoAAConnector = 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 Azure Automation Connector";
                WizardData data = new AzureAutomationWizardData(emoAAConnector);
                wizard.WizardData = data;
                wizard.AddLast(new WizardStep("Configuration", typeof(AzureAutomationConfigurationPage), 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 emoAAConnector = 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(emoAAConnector);
                    idd.Commit(emg);
                }

                //Get the rule using the connector ID
                ManagementPack      mpConnectors           = emg.GetManagementPack("SCSM.AzureAutomation", "ac1fe0583b6c84af", new Version("1.0.0.0"));
                ManagementPack      mpAAConnectorWorkflows = emg.GetManagementPack("SCSM.AzureAutomation.Workflows", null, new Version("1.0.0.0"));
                ManagementPackClass classAAConnector       = mpConnectors.GetClass("SCSM.AzureAutomation.Connector");
                String             strConnectorID          = emoAAConnector[classAAConnector, "Id"].ToString();
                ManagementPackRule ruleConnector           = mpAAConnectorWorkflows.GetRule(strConnectorID);

                //Update the Enabled property or delete as appropriate
                if (parameters.Contains("Delete"))
                {
                    ruleConnector.Status = ManagementPackElementStatus.PendingDelete;
                }
                else if (parameters.Contains("Disable"))
                {
                    emoAAConnector[classAAConnector, "Enabled"].Value = false;
                    ruleConnector.Enabled = ManagementPackMonitoringLevel.@false;
                    ruleConnector.Status  = ManagementPackElementStatus.PendingUpdate;
                }
                else if (parameters.Contains("Enable"))
                {
                    emoAAConnector[classAAConnector, "Enabled"].Value = true;
                    ruleConnector.Enabled = ManagementPackMonitoringLevel.@true;
                    ruleConnector.Status  = ManagementPackElementStatus.PendingUpdate;
                }

                //Commit the changes to the connector object and rule
                emoAAConnector.Commit();
                mpAAConnectorWorkflows.AcceptChanges();

                //Update the view when done so the item is either removed or the updated Enabled value shows
                RequestViewRefresh();
            }
        }