public static void Start(string name, Window owner, ProcessorArgs args, bool?isAsync, Action <WizardArgs> action, Func <WizardArgs> createWizardArgs) { Log.Info($"Wizard pipeline '{name}' starts"); using (new ProfileSection("Start wizard")) { ProfileSection.Argument("name", name); ProfileSection.Argument("owner", owner); ProfileSection.Argument("args", args); WizardPipeline wizardPipeline = Definitions[name]; var isSync = !(isAsync ?? !WinAppSettings.AppSysIsSingleThreaded.Value); if (isSync) { using (var wizard = CreateWizardWindow(wizardPipeline, args, createWizardArgs)) { WindowHelper.ShowDialog(wizard, owner); if (action != null) { var wizardArgs = wizard.WizardArgs; action(wizardArgs); } } } else { var wizard = CreateWizardWindow(wizardPipeline, args, createWizardArgs); if (action != null && !flag) { flag = true; wizard.Closed += (o, e) => { try { var wizardArgs = wizard.WizardArgs; action(wizardArgs); flag = false; } finally { wizard.Dispose(); } }; } else { wizard.Closed += (obj, e) => wizard.Dispose(); } WindowHelper.ShowWindow(wizard, owner); } } }
private static void InitializeWizardPipeline(XmlElement element) { using (new ProfileSection("Initialize wizard pipeline")) { ProfileSection.Argument("element", element); var name1 = element.Name; try { XmlElement argsElement = element.SelectSingleElement("args"); Type args = argsElement != null ? Type.GetType(argsElement.GetAttribute("type")).IsNotNull( "Cannot find the {0} type".FormatWith(argsElement.GetAttribute("type"))) : null; XmlElement finish = element.SelectSingleElement("finish"); var title = element.GetAttribute("title"); var stepsElement = element.SelectSingleElement("steps").IsNotNull( "Can't find the steps element in the WizardPipelines.config file"); var afterLastStepText = stepsElement.GetAttribute("afterLastStep"); var afterLastStep = !string.IsNullOrWhiteSpace(afterLastStepText) ? (IAfterLastWizardPipelineStep)Activator.CreateInstance(Type.GetType(afterLastStepText)) : null; var steps = stepsElement.ChildNodes.OfType <XmlElement>(). Select( step => new StepInfo(step.GetAttribute("name"), Type.GetType(step.GetAttribute("type")), step.GetAttribute("param"))).ToArray(); var cancelButtonText = element.GetAttribute("cancelButton"); var startButtonText = element.GetAttribute("startButton"); var finishText = element.GetAttribute("finishText"); FinishAction[] finishActions = finish != null?GetFinishActions(finish, args).ToArray() : null; var finishActionHives = GetFinishActionHives(finish, args); WizardPipeline wizardPipeline = new WizardPipeline(name1, title, steps, args, startButtonText, cancelButtonText, finishText, finishActions, finishActionHives, afterLastStep); Definitions.Add(name1, wizardPipeline); ProfileSection.Result("Done"); } catch (Exception ex) { WindowHelper.HandleError("WizardPipelineManager failed to load the {0} pipeline".FormatWith(name1), true, ex); ProfileSection.Result("Failed"); } } }
public static void Start(string name, Window owner, ProcessorArgs args = null, bool?isAsync = null, Action action = null, params object[] wizardArgsParameters) { Log.Info("Wizard pipeline '{0}' starts", name); using (new ProfileSection("Start wizard")) { ProfileSection.Argument("name", name); ProfileSection.Argument("owner", owner); ProfileSection.Argument("args", args); ProfileSection.Argument("wizardArgsParameters", wizardArgsParameters); WizardPipeline wizardPipeline = Definitions[name]; var wizard = CreateWizardWindow(wizardPipeline, args, wizardArgsParameters); var isSync = !(isAsync ?? !WinAppSettings.AppSysIsSingleThreaded.Value); if (isSync) { WindowHelper.ShowDialog(wizard, owner); if (action != null) { action(); } } else { if (action != null && !flag) { flag = true; wizard.Closed += (o, e) => { action(); flag = false; }; } WindowHelper.ShowWindow(wizard, owner); } } }
private static void InitializeWizardPipeline(XmlElement element) { using (new ProfileSection("Initialize wizard pipeline")) { ProfileSection.Argument("element", element); string name1 = element.Name; try { XmlElement argsElement = element.SelectSingleElement("args"); Type args = argsElement != null ? Type.GetType(argsElement.GetAttribute("type")).IsNotNull( "Cannot find the {0} type".FormatWith(argsElement.GetAttribute("type"))) : null; XmlElement finish = element.SelectSingleElement("finish"); string title = element.GetAttribute("title"); var steps = element.SelectSingleElement("steps").IsNotNull( "Can't find the steps element in the WizardPipelines.config file").ChildNodes.OfType<XmlElement>(). Select( step => new StepInfo(step.GetAttribute("name"), Type.GetType(step.GetAttribute("type")), step.GetAttribute("param"))).ToArray(); string cancelButtonText = element.GetAttribute("cancelButton"); string startButtonText = element.GetAttribute("startButton"); string finishText = element.GetAttribute("finishText"); FinishAction[] finishActions = finish != null ? GetFinishActions(finish, args).ToArray() : null; var finishActionHives = GetFinishActionHives(finish, args); WizardPipeline wizardPipeline = new WizardPipeline(name1, title, steps, args, startButtonText, cancelButtonText, finishText, finishActions, finishActionHives); Definitions.Add(name1, wizardPipeline); ProfileSection.Result("Done"); } catch (Exception ex) { WindowHelper.HandleError("WizardPipelineManager failed to load the {0} pipeline".FormatWith(name1), true, ex); ProfileSection.Result("Failed"); } } }