Ejemplo n.º 1
0
        private static void InitializeWizardPipeline(XmlElement element)
        {
            using (new ProfileSection("Initialize wizard pipeline", typeof(WizardPipelineManager)))
            {
                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");
                }
            }
        }
Ejemplo n.º 2
0
        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".FormatWith(name), typeof(WizardPipelineManager));
            using (new ProfileSection("Start wizard", typeof(WizardPipelineManager)))
            {
                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 ?? !AppSettings.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");
        }
      }
    }