private void btnNext_Clicked(object sender, EventArgs e) { if ((!currentStep.IsSingleComplete || currentStep.Status != StepStatus.Complete) && !currentStep.Complete(this)) { return; } StepBase next = currentStep.GetNextStep(allSteps); if (next != null) { int curIndex = steps.IndexOf(currentStep); StepBase availNext = null; if (curIndex >= 0 && curIndex < steps.Count - 1) { availNext = steps [curIndex + 1]; } if (ReferenceEquals(availNext, next)) { SetActiveStep(next); } else { AppendStep(next); } } else { Finish(); } }
private void AppendStep(StepBase step) { int curIndex = steps.IndexOf(currentStep); for (int i = steps.Count - 1; i > curIndex; i--) { StepTag t = tags [curIndex]; hboSteps.Remove(t); tags.RemoveAt(i); StepBase s = steps [i]; s.StatusChanged -= step_StatusChanged; steps.RemoveAt(i); } steps.Add(step); step.Assistant = this; step.StatusChanged += step_StatusChanged; StepTag tag = new StepTag(step); tag.Show(); tag.Toggled += Tag_Toggled; hboSteps.PackStart(tag, false, true, 0); tags.Add(tag); SetActiveStep(step); }
public StepTag(StepBase step) { this.step = step; step.StatusChanged += step_StatusChanged; Relief = ReliefStyle.None; HBox hbo = new HBox { Spacing = 2 }; Add(hbo); algStatus = new Alignment(0.5f, 0.5f, 1f, 1f) { WidthRequest = 16, HeightRequest = 16 }; hbo.PackStart(algStatus, false, true, 0); lblTitle = new Label { Markup = new PangoStyle { Italic = true, Text = step.Title }, Xpad = 4 }; hbo.PackStart(lblTitle, true, true, 0); hbo.ShowAll(); RefreshStatus(); }
public Assistant(AssistType assistType) { this.assistType = assistType; allSteps = StepBase.GetAllSteps(assistType); Initialize(); if (assistType == AssistType.ApplicationSetup) { AppendStep(new StepAppSetup()); } else if (assistType == AssistType.DatabaseSetup) { AppendStep(new StepDBSetup()); } else { throw new ArgumentOutOfRangeException("assistType"); } backgroundWorker = new Thread(delegate() { while (true) { if (backgroundJobs.Count > 0) { BackgroundJob job = backgroundJobs.Dequeue(); try { PresentationDomain.Invoke(() => job.Step.ChangeStatus(StepStatus.InProgress)); job.Action(); PresentationDomain.Invoke(() => job.Step.ChangeStatus(StepStatus.Complete)); } catch (Exception ex) { PresentationDomain.Invoke(() => job.Step.ChangeStatus(StepStatus.Failed)); ErrorHandling.LogException(ex, ErrorSeverity.FatalError); } } else { Thread.Sleep(100); } if (stopBackgroundWorker) { return; } } }) { IsBackground = true, Name = "Setup Assistant Worker" }; backgroundWorker.Start(); }
public static List <StepBase> GetAllSteps(AssistType group) { List <StepBase> allSteps = new List <StepBase> (); foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/Warehouse/Presentation/SetupAssistant/Step")) { object instance = node.CreateInstance(); StepBase step = instance as StepBase; if (step != null) { allSteps.Add(step); } } allSteps.Sort((s1, s2) => Math.Max(-1, Math.Min(1, s1.Ordinal - s2.Ordinal))); return(allSteps.FindAll(s => s.Group == group)); }
public Assistant(StepBase step) { assistType = AssistType.ApplicationSetup; allSteps = new List <StepBase> { step }; Initialize(); AppendStep(step); backgroundWorker = new Thread(delegate() { while (true) { if (backgroundJobs.Count > 0) { BackgroundJob job = backgroundJobs.Dequeue(); try { PresentationDomain.Invoke(() => job.Step.ChangeStatus(StepStatus.InProgress)); job.Action(); PresentationDomain.Invoke(() => job.Step.ChangeStatus(StepStatus.Complete)); } catch (Exception ex) { PresentationDomain.Invoke(() => job.Step.ChangeStatus(StepStatus.Failed)); ErrorHandling.LogException(ex, ErrorSeverity.FatalError); } } else { Thread.Sleep(100); } if (stopBackgroundWorker) { return; } } }) { IsBackground = true, Name = "Setup Assistant Worker" }; backgroundWorker.Start(); }
private void RefreshForwardButtonsSensitivity() { StepBase next = currentStep.GetNextStep(allSteps); btnNext.Sensitive = next != null; foreach (StepBase step in steps) { switch (step.Status) { case StepStatus.Waiting: case StepStatus.InProgress: case StepStatus.Failed: btnFinish.Sensitive = false; return; } } btnFinish.Sensitive = true; }
private void SetActiveStep(StepBase step) { if (algContent.Child != null) { algContent.Remove(algContent.Child); } algContent.Add(step.Body); currentStep = step; int newIndex = steps.IndexOf(step); int totalVisible = 0; for (int i = tags.Count - 1; i >= 0; i--) { StepTag tag = tags [i]; bool visible = i <= newIndex + MAX_VISIBLE_NEXT; if (visible) { totalVisible++; } tag.Visible = visible && totalVisible <= MAX_VISIBLE_TOTAL; if (ReferenceEquals(tag.Step, step)) { tag.Active = true; } } for (int i = newIndex + MAX_VISIBLE_NEXT + 1; i < tags.Count && totalVisible < MAX_VISIBLE_TOTAL; i++) { tags [i].Visible = true; totalVisible++; } btnBack.Visible = newIndex != 0; lblSteps.SetText(string.Format("{0}/{1}", newIndex + 1, allSteps.Count)); dlgAssistant.Resize(OPTIMAL_DIALOG_WIDTH, OPTIMAL_DIALOG_HEIGHT); RefreshForwardButtonsSensitivity(); }
public BackgroundJob(StepBase step) { this.step = step; }