/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="hInfo"></param>
        public SurveyPopupWindow(SurveyPopupViewModel viewModel, HostControlInfo hInfo)
        {
            InitializeComponent();
            if (viewModel != null)
            {
                surveyViewModel = viewModel;
            }

            DataContext = surveyViewModel;

            //Setting the host over which the popup will appear and the placement mode
            PlacementTarget = hInfo.HostUIElement;
            Placement       = hInfo.PopupPlacement;

            //When setting a value for offset it will move the popup taking as a initial position the host control position in which the popup is shown
            HorizontalOffset = hInfo.HorizontalPopupOffSet;
            VerticalOffset   = hInfo.VerticalPopupOffSet;
        }
Esempio n. 2
0
        public WebBrowserWindow(PopupWindowViewModel viewModel, HostControlInfo hInfo)
        {
            InitializeComponent();

            webBrowser.Width = viewModel.Width;
            //The height is subtracted by a const that sums the height of the header and footer of the popup
            webBrowser.Height = viewModel.Height - headerAndFooterCompensation;

            //Setting the host over which the popup will appear and the placement mode
            PlacementTarget = hInfo.HostUIElement;
            Placement       = hInfo.PopupPlacement;

            //Horizontal offset plus 10 is to compensate the tooltip size
            HorizontalOffset = hInfo.HorizontalPopupOffSet + tooltipOffset;
            //Vertical offset plus 50 is to compensate the header size
            VerticalOffset = hInfo.VerticalPopupOffSet + headerOffset;

            LoadWebBrowser(hInfo.HtmlPage);
        }
Esempio n. 3
0
        public PopupWindow(PopupWindowViewModel viewModel, HostControlInfo hInfo)
        {
            InitializeComponent();

            hostControlInfo = hInfo;

            if (viewModel != null)
            {
                popupViewModel = viewModel;
            }

            DataContext = popupViewModel;

            //Due that we are drawing the Direction pointers on left and right side of the Canvas (10 width each one) then we need to add 20
            RootLayout.Width = popupViewModel.Width + (popupBordersOffSet * 2);
            //Also a shadow of 10 pixels in top and 10 pixels at the bottom will be shown then we need to add 20
            RootLayout.Height = popupViewModel.Height + (popupBordersOffSet * 2);

            //The BackgroundRectangle represent the tooltip background rectangle that is drawn over a Canvas
            //Needs to be moved 10 pixels over the X axis to show the direction pointers (Height was already increased above)
            //Needs to be moved 10 pixels over the Y axis to show the shadow at top and bottom.
            BackgroundRectangle.Rect = new Rect(popupBordersOffSet, popupBordersOffSet, popupViewModel.Width, popupViewModel.Height);

            //Setting the host over which the popup will appear and the placement mode
            PlacementTarget = hInfo.HostUIElement;
            Placement       = hInfo.PopupPlacement;

            //The CustomRichTextBox has a margin of 10 in left and 10 in right, also there is a indentation for drawing the PointerDirection of 10 of each side so that's why we are subtracting 40.
            ContentRichTextBox.Width = popupViewModel.Width - (popupBordersOffSet * 4);
            HorizontalOffset         = hInfo.HorizontalPopupOffSet;
            VerticalOffset           = hInfo.VerticalPopupOffSet;

            Opened += PopupWindow_Opened;
            Closed += PopupWindow_Closed;

            isClosingTour = false;

            EnsureStandardPopupAlignment();
        }
Esempio n. 4
0
        /// <summary>
        /// This method will execute a javascript function located in library.hmtl using reflection.
        /// due that we cannot include a reference to LibraryViewExtensionMSWebBrowser then we need to use reflection to get the types
        /// </summary>
        /// <param name="MainWindow">MainWindow in which the LibraryView is located</param>
        /// <param name="popupInfo">Popup Information about the Step </param>
        /// <param name="parametersInvokeScript">Parameters for the WebBrowser.InvokeScript() function</param>
        internal static object ExecuteJSFunction(UIElement MainWindow, HostControlInfo popupInfo, object[] parametersInvokeScript)
        {
            const string webBrowserString     = "Browser";
            const string invokeScriptFunction = "InvokeScript";
            object       resultJSHTML         = null;

            //Try to find the grid that contains the LibraryView
            var sidebarGrid = (MainWindow as Window).FindName(popupInfo.HostUIElementString) as Grid;

            if (sidebarGrid == null)
            {
                return(null);
            }

            //We need to iterate every child in the grid due that we need to apply reflection to get the Type and find the LibraryView (a reference to LibraryViewExtensionMSWebBrowser cannot be added).
            foreach (var child in sidebarGrid.Children)
            {
                Type type = child.GetType();
                if (type.Name.Equals(popupInfo.WindowName))
                {
                    var libraryView = child as UserControl;
                    //get the WebBrowser instance inside the LibraryView
                    var browser = libraryView.FindName(webBrowserString);
                    if (browser == null)
                    {
                        return(null);
                    }

                    Type typeBrowser = browser.GetType();
                    //Due that there are 2 methods with the same name "InvokeScript", then we need to get the one with 2 parameters
                    MethodInfo methodInvokeScriptInfo = typeBrowser.GetMethods().Single(m => m.Name == invokeScriptFunction && m.GetParameters().Length == 2);
                    //Invoke the JS method located in library.html
                    resultJSHTML = methodInvokeScriptInfo.Invoke(browser, parametersInvokeScript);
                    break;
                }
            }
            return(resultJSHTML);
        }