Example #1
0
        /// <summary>
        /// This method will create all the Guide and add them to the Guides List based in the deserialized info gotten from the json file passed as parameter
        /// </summary>
        /// <param name="jsonFile">Full path of the json file location containing information about the Guides and Steps</param>
        private void CreateGuideSteps(string jsonFile)
        {
            int totalTooltips = 0;

            foreach (Guide guide in GuidesManager.ReadGuides(jsonFile))
            {
                Guide newGuide = new Guide()
                {
                    Name = guide.Name,
                };

                totalTooltips = (from step in guide.GuideSteps
                                 where step.StepType == Step.StepTypes.TOOLTIP ||
                                 step.StepType == Step.StepTypes.SURVEY
                                 select step).GroupBy(x => x.Sequence).Count();

                foreach (Step step in guide.GuideSteps)
                {
                    HostControlInfo hostControlInfo = CreateHostControl(step.HostPopupInfo);
                    Step            newStep         = CreateStep(step, hostControlInfo, totalTooltips);
                    newStep.GuideName = guide.Name;

                    //If the UI Automation info was read from the json file then we create an StepUIAutomation instance containing all the info for each automation entry
                    if (step.UIAutomation != null)
                    {
                        foreach (var automation in step.UIAutomation)
                        {
                            newStep.UIAutomation.Add(automation);
                        }
                    }

                    //If PreValidationInfo != null means that was deserialized correctly from the json file
                    if (step.PreValidationInfo != null)
                    {
                        newStep.PreValidationInfo = new PreValidation(step.PreValidationInfo);
                    }

                    if (newStep != null)
                    {
                        //Passing the DynamoViewModel to each step so we can execute the Pre Validation methods
                        newStep.DynamoViewModelStep = dynamoViewModel;

                        newStep.StepGuideBackground = guideBackgroundElement;
                        newStep.MainWindow          = mainRootElement;

                        newStep.ExitGuide = step.ExitGuide;

                        //The step is added to the new Guide being created
                        newGuide.GuideSteps.Add(newStep);

                        //We subscribe the handler to the StepClosed even, so every time the popup is closed then this method will be called.
                        newStep.StepClosed += Popup_StepClosed;
                    }
                }
                Guides.Add(newGuide);
            }
        }