Exemple #1
0
        /// <summary>
        /// This method will return a new HostControlInfo object populated with the information passed as parameter
        /// Basically this method store the information coming from Step and search the UIElement in the main WPF VisualTree
        /// </summary>
        /// <param name="jsonStepInfo">Step that contains all the info deserialized from the Json file</param>
        /// <returns></returns>
        private HostControlInfo CreateHostControl(HostControlInfo jsonHostControlInfo)
        {
            //We use the HostControlInfo copy construtor
            var popupInfo = new HostControlInfo(jsonHostControlInfo, mainRootElement);

            //If the CutOff area was defined in the json file then a section of the background overlay will be removed
            if (jsonHostControlInfo.CutOffRectArea != null)
            {
                popupInfo.CutOffRectArea = new CutOffArea()
                {
                    WidthBoxDelta  = jsonHostControlInfo.CutOffRectArea.WidthBoxDelta,
                    HeightBoxDelta = jsonHostControlInfo.CutOffRectArea.HeightBoxDelta
                };
            }

            //If the Highlight area was defined in the json file then a rectangle will be highlighted in the Overlay
            if (jsonHostControlInfo.HighlightRectArea != null)
            {
                //We use the HighlightArea copy construtor
                popupInfo.HighlightRectArea = new HighlightArea(jsonHostControlInfo.HighlightRectArea);
            }

            //The host_ui_element read from the json file need to exists otherwise the host will be null
            UIElement hostUIElement = Guide.FindChild(mainRootElement, popupInfo.HostUIElementString);

            if (hostUIElement != null)
            {
                popupInfo.HostUIElement = hostUIElement;
            }

            return(popupInfo);
        }
Exemple #2
0
 /// <summary>
 /// Step constructor
 /// </summary>
 /// <param name="host">The host and popup information in which the popup will be shown</param>
 /// <param name="width">Popup Width</param>
 /// <param name="height">Popup Height</param>
 public Step(HostControlInfo host, double width, double height)
 {
     HostPopupInfo = host;
     Width         = width;
     Height        = height;
     UIAutomation  = new List <StepUIAutomation>();
     CreatePopup();
 }
Exemple #3
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);
            }
        }
Exemple #4
0
        /// <summary>
        /// The Tooltip constructor
        /// </summary>
        /// <param name="host">Host control (of the TreeView) in which the tooltip will be shown</param>
        /// <param name="width">Tooltip width</param>
        /// <param name="height">Tooltip height</param>
        /// <param name="direction">The pointer direction of the tooltip</param>
        public Tooltip(HostControlInfo host, double width, double height, PointerDirection direction, double verticalTooltipOffset)
            : base(host, width, height)
        {
            SetPointerDirection(direction);

            //The offset represent the distance vertically from the top/bottom for showing the tooltip pointer (a triangle)
            PointerVerticalOffset   = (Height / 8) + verticalTooltipOffset;
            PointerHorizontalOffset = (Width / 8);
            DrawPointerDirection(direction);
        }
Exemple #5
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="copyInstance"></param>
 /// <param name="MainWindow"></param>
 internal HostControlInfo(HostControlInfo copyInstance, UIElement MainWindow)
 {
     PopupPlacement        = copyInstance.PopupPlacement;
     HostUIElementString   = copyInstance.HostUIElementString;
     HostUIElement         = MainWindow;
     VerticalPopupOffSet   = copyInstance.VerticalPopupOffSet;
     HorizontalPopupOffSet = copyInstance.HorizontalPopupOffSet;
     HtmlPage          = copyInstance.HtmlPage;
     WindowName        = copyInstance.WindowName;
     DynamicHostWindow = copyInstance.DynamicHostWindow;
 }
Exemple #6
0
        /// <summary>
        /// Creates a new Step with the information passed as parameter (the only extra-information calculated is the TotalTooltips, the Text for Title and Content and other properties like the Suvey.RatingTextTitle
        /// </summary>
        /// <param name="jsonStepInfo">Step that contains all the info deserialized from the Json file</param>
        /// <param name="hostControlInfo">Information of the host read previously</param>
        /// <param name="totalTooltips">Total number of tooltips, calculated once we deserialized all the steps from json</param>
        /// <returns></returns>
        private Step CreateStep(Step jsonStepInfo, HostControlInfo hostControlInfo, int totalTooltips)
        {
            Step newStep = null;
            //This section will retrive the strings from the Resources.resx file
            var formattedText = Res.ResourceManager.GetString(jsonStepInfo.StepContent.FormattedText);
            var title         = Res.ResourceManager.GetString(jsonStepInfo.StepContent.Title);

            switch (jsonStepInfo.StepType)
            {
            case Step.StepTypes.TOOLTIP:
                newStep = new Tooltip(hostControlInfo, jsonStepInfo.Width, jsonStepInfo.Height, jsonStepInfo.TooltipPointerDirection, jsonStepInfo.PointerVerticalOffset)
                {
                    Name          = jsonStepInfo.Name,
                    Sequence      = jsonStepInfo.Sequence,
                    TotalTooltips = totalTooltips,
                    StepType      = jsonStepInfo.StepType,
                    ShowLibrary   = jsonStepInfo.ShowLibrary,
                    StepContent   = new Content()
                    {
                        FormattedText = formattedText,
                        Title         = title
                    }
                };
                break;

            case Step.StepTypes.SURVEY:
                newStep = new Survey(hostControlInfo, jsonStepInfo.Width, jsonStepInfo.Height)
                {
                    Sequence        = jsonStepInfo.Sequence,
                    ContentWidth    = 300,
                    RatingTextTitle = formattedText.ToString(),
                    StepType        = Step.StepTypes.SURVEY,
                    IsRatingVisible = dynamoViewModel.Model.PreferenceSettings.IsADPAnalyticsReportingApproved,
                    StepContent     = new Content()
                    {
                        FormattedText = formattedText,
                        Title         = title
                    }
                };

                //Due that the RatingTextTitle property is just for Survey then we need to set the property using reflection
                foreach (var extraContent in jsonStepInfo.StepExtraContent)
                {
                    // Get the Type object corresponding to Step.
                    Type myType = typeof(Survey);
                    // Get the PropertyInfo object by passing the property name.
                    PropertyInfo myPropInfo = myType.GetProperty(extraContent.Property);
                    if (myPropInfo != null)
                    {
                        //Retrieve the string value from the Resources.resx file
                        var valueStr = Res.ResourceManager.GetString(extraContent.Value);
                        myPropInfo.SetValue(newStep, valueStr);
                    }
                }
                break;

            case Step.StepTypes.WELCOME:
                newStep = new Welcome(hostControlInfo, jsonStepInfo.Width, jsonStepInfo.Height)
                {
                    Sequence    = jsonStepInfo.Sequence,
                    StepType    = Step.StepTypes.WELCOME,
                    StepContent = new Content()
                    {
                        FormattedText = formattedText,
                        Title         = title
                    }
                };
                break;
            }//StepType

            return(newStep);
        }
Exemple #7
0
 public Welcome(HostControlInfo host, double width, double height)
     : base(host, width, height)
 {
     //In the Welcome constructor we call the base constructor passing the host information and the popup width and height
 }