示例#1
0
        private void OpenNewDialogWindowCallback(NavigationArgs args)
        {
            var newWindow = CreateNewWindow(args.View, Application.Current.MainWindow);

            _curOpenWindows.Add(args.ViewModelID, new OpenWindowElement(newWindow));
            newWindow.ShowDialog();
        }
示例#2
0
        /// <summary>
        /// Navigation From
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Frame_Navigating(object sender, NavigatingCancelEventArgs e)
        {
            var frame = sender as Windows.UI.Xaml.Controls.Frame;

            if (frame == null)
            {
                return;
            }
            var naviArgs = new NavigationArgs
            {
                Content        = frame.Content,
                NavigationMode =
                    (Models.NavigationMode)Enum.Parse(typeof(Models.NavigationMode), e.NavigationMode.ToString()),
                Parameter = e.SourcePageType,
                Uri       = frame.BaseUri
            };

            if (StaticFunctions.BaseContext != null)
            {
                StaticFunctions.InvokeIfRequiredAsync(StaticFunctions.BaseContext,
                                                      para => _eventAggregator.GetEvent <NavigatingEvent>().Publish(naviArgs), null);
            }
            else
            {
                _eventAggregator.GetEvent <NavigatingEvent>().Publish(naviArgs);
            }
        }
示例#3
0
 /// <summary>
 /// 关闭窗口
 /// </summary>
 /// <param name="args">参数</param>
 public void SendNavigationMsgForCloseWindow(NavigationArgs args)
 {
     GalaSoft.MvvmLight.Threading.DispatcherHelper.CheckBeginInvokeOnUI(() =>
     {
         GalaSoft.MvvmLight.Messaging.Messenger.Default.Send <NavigationArgs>(args, SystemKeys.SystemKeys.CloseWindow);
     });
 }
示例#4
0
 //关闭窗口
 private void CloseWindowCallback(NavigationArgs args)
 {
     if (_curOpenWindows.ContainsKey(args.ViewModelID))
     {
         _curOpenWindows[args.ViewModelID].CurOpenWindow.Close();
     }
 }
示例#5
0
 public override void HandleEnter(NavigationArgs args)
 {
     Animate(72f);
     content.HandleEnter(args?.current is BlueprintTypeButton button
         ? Vector2.down * (button.order > order).To1()
         : Vector2.zero);
 }
示例#6
0
        //打开新窗口
        private void OpenNewWindowCallback(NavigationArgs args)
        {
            var newWindow = CreateNewWindow(args.View);

            _curOpenWindows.Add(args.ViewModelID, new OpenWindowElement(newWindow));
            newWindow.Show();
        }
示例#7
0
        public virtual void OnNavigatedTo(NavigationArgs e, string parametersKey)
        {
            // Load parameters only the first time you arrive on the view
            if (e.Mode == NavigationArgs.NavigationMode.New)
            {
                NavigationParameters = NavigationService.GetParameters(parametersKey);

                if (NavigationParameters != null)
                {
                    //Process auto navigation parameters property
                    foreach (PropertyInfo property in GetType().GetRuntimeProperties().Where(x => x.GetCustomAttribute <NavigationParameterAttribute>(true) != null))
                    {
                        NavigationParameterAttribute attribute = property.GetCustomAttribute <NavigationParameterAttribute>(true);

                        string parameterName = attribute.Name ?? property.Name;
                        if (attribute.Mode == NavigationParameterMode.Required && !NavigationParameters.Has(parameterName))
                        {
                            throw new ArgumentOutOfRangeException(string.Format("Missing required navigation parameter {0}", parameterName));
                        }

                        if (NavigationParameters.Has(parameterName))
                        {
                            object keyValue = NavigationParameters.Get <object>(parameterName);

                            property.SetValue(this, keyValue);
                        }
                    }
                }
            }
        }
示例#8
0
        private bool Submit(string url = null, HtmlElement clickedElement = null)
        {
            NavigationArgs navigation = new NavigationArgs();

            navigation.Uri         = url ?? this.Action;
            navigation.Method      = this.Method;
            navigation.ContentType = FormEncoding.FormUrlencode;
            foreach (var entry in Elements.SelectMany(e =>
            {
                bool isClicked = false;
                if (clickedElement != null && clickedElement.Element == e.Element)
                {
                    isClicked = true;
                }
                return(e.ValuesToSubmit(isClicked));
            }
                                                      ))
            {
                // This call to Remove() guarantees that for each element with a duplicate name
                // only the last element on the form is submitted.
                navigation.UserVariables.Remove(entry.Name);
                navigation.UserVariables.Add(entry.Name, entry.Value);
            }
            if (this.EncType == FormEncoding.MultipartForm && this.Method.ToUpper() == "POST")
            {
                // create postdata according to multipart specs
                Guid token = Guid.NewGuid();
                navigation.UserVariables = null;
                StringBuilder post = new StringBuilder();
                foreach (var element in this.Elements)
                {
                    if (element is IHasRawPostData)
                    {
                        post.AppendFormat("--{0}\r\n", token);
                        string filename = new FileInfo(element.Value).Name;
                        post.AppendFormat("Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n{2}\r\n", element.Name, filename, ((IHasRawPostData)element).GetPostData());
                    }
                    else
                    {
                        bool isClickedElement = false;
                        if (clickedElement != null)
                        {
                            isClickedElement = element.Element == clickedElement.Element;
                        }
                        var values = element.ValuesToSubmit(isClickedElement);
                        foreach (var value in values)
                        {
                            post.AppendFormat("--{0}\r\n", token);
                            post.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", value.Name, value.Value);
                        }
                    }
                }
                post.AppendFormat("--{0}\r\n", token);
                navigation.PostData    = post.ToString();
                navigation.ContentType = FormEncoding.MultipartForm + "; boundary=" + token;
            }
            return(RequestNavigation(navigation));
        }
示例#9
0
        /// <summary>
        /// Navigates to the given page.
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="state"></param>
        public void Navigate(Uri uri, NavigationArgs state = null)
        {
            this.NavigationState = state;

            if (this.OnNavigateRequest != null)
            {
                this.OnNavigateRequest(uri);
            }
        }
示例#10
0
        public void PublishTabSelected(TableVM table)
        {
            var navObject = new NavigationArgs {
                Sender = Tabs.Tables, Destination = Tabs.Menu, Data = table
            };

            OrderInfo.Instance.eventHanlder.GetEvent <Notifications>().Publish(navObject);
            TabChangeds(new NavigationEventArgs(this, navObject));
        }
        /// <summary>
        /// This event will trigger when the user clicks on any of the main navigation buttons.S
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainNavigation_Click(object sender, NavigationArgs e)
        {
            // Removes any templates that might be in the active panel.
            RemoveActivePanelControls();

            // Load the pages that correspond to the clicked button
            switch (e.MainTag)
            {
            case MainNavigationTag.Dashboard:
                topHandleBarModel.Update("N/A", "N/A", "N/A");
                ShowPage(Pages.Dashboard);
                break;

            case MainNavigationTag.KPA:
                if (e.SectionTag == SectionNavigationTag.Overall)
                {
                    // Load the KPA overall template
                    LoadOverallTemplate(Performances.Performance.KPA);
                }
                else
                {
                    // Load the section template the user would like to view
                    LoadKpaSectionPage(e);
                }
                break;

            case MainNavigationTag.KPI:
                if (e.SectionTag == SectionNavigationTag.Overall)
                {
                    // Load teh KPI overall template
                    LoadOverallTemplate(Performances.Performance.KPI);
                }
                else
                {
                    // Load the section template the user would like to view
                    LoadKpiSectionPage(e);
                }
                break;

            case MainNavigationTag.Correlation:
                CreateCorrelationWindow();
                break;

            case MainNavigationTag.Filters:
                // Set the model indicating that there is currently no KPA or KPI being viewed.
                topHandleBarModel.Update("N/A", "N/A", "N/A");
                ShowPage(Pages.Filters);
                break;

            case MainNavigationTag.Reports:
                CreateReportPage();
                break;

            default:
                break;
            }
        }
示例#12
0
        /// <summary>
        /// 通过消息关闭View
        /// </summary>
        public void CloseView()
        {
            NavigationArgs args = new NavigationArgs(this.ViewModelID);

            //发送关闭View消息
            MsgAggregation.Instance.SendNavigationMsgForCloseWindow(args);
            //注销所有消息
            MsgAggregation.Instance.UnRegisterMsgAll(this);
        }
示例#13
0
        private bool Submit(string url = null, HtmlElement clickedElement = null)
        {
            NavigationArgs navigation = new NavigationArgs();
            navigation.Uri = url ?? this.Action;
            navigation.Method = this.Method;
            navigation.ContentType = FormEncoding.FormUrlencode;
            foreach (var entry in Elements.SelectMany(e =>
                    {
                        bool isClicked = false;
                        if (clickedElement != null && clickedElement.Element == e.Element) isClicked = true;
                        return e.ValuesToSubmit(isClicked);
                    }
                    ))
            {
                // This call to Remove() guarantees that for each element with a duplicate name
                // only the last element on the form is submitted.
                navigation.UserVariables.Remove(entry.Name);
                navigation.UserVariables.Add(entry.Name, entry.Value);
            }
            navigation.EncodingType = this.EncType;
            if (this.EncType == FormEncoding.MultipartForm)
            {
                // create postdata according to multipart specs
                Guid token = Guid.NewGuid();
                navigation.UserVariables = null;
                StringBuilder post = new StringBuilder();
                foreach (var element in this.Elements)
                {
                    if (element is IHasRawPostData)
                    {
                        post.AppendFormat("--{0}\n", token);
                        string filename = new FileInfo(element.Value).Name;
                        post.AppendFormat("Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\n{2}\n", element.Name, filename, ((IHasRawPostData)element).GetPostData());
                    }
                    else
                    {
                        bool isClickedElement = false;
                        if (clickedElement != null)
                        {
                            isClickedElement = element.Element == clickedElement.Element;
                        }
                        var values = element.ValuesToSubmit(isClickedElement);
                        foreach (var value in values)
                        {
                            post.AppendFormat("--{0}\n", token);
                            post.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\n\n{1}\n", value.Name, value.Value);
                        }
                    }
                }
                post.AppendFormat("--{0}\n", token);
                navigation.PostData = post.ToString();
                navigation.ContentType = FormEncoding.MultipartForm + "; boundary=" + token;

            }
            return RequestNavigation(navigation);
        }
示例#14
0
 /// <summary>
 /// 主界面导航
 /// </summary>
 /// <param name="args">参数</param>
 public void SendNavigationMsgForMainView(NavigationArgs args)
 {
     if (args.IsSuccess)
     {
         GalaSoft.MvvmLight.Threading.DispatcherHelper.CheckBeginInvokeOnUI(() =>
         {
             GalaSoft.MvvmLight.Messaging.Messenger.Default.Send <NavigationArgs>(args, SystemKeys.SystemKeys.MainUcNavigation);
         });
     }
 }
        /// <summary>
        /// Loads the KPI section pages request by the user
        /// </summary>
        /// <param name="e">The navigation args aquired from the navigation view</param>
        private void LoadKpiSectionPage(NavigationArgs e)
        {
            // Remove and Performance panel from the active panel view
            RemoveActivePanelControls();

            // Update the top handle bar to notify the user they are viewing KPI information
            topHandleBarModel.Performance = "KPI";


            switch (e.SectionTag)
            {
            case SectionNavigationTag.Plan:
                CreateKpiPlanTemplate();
                break;

            case SectionNavigationTag.Purch:
                CreateKpiPurchTemplate();
                break;

            case SectionNavigationTag.FollowUp:
                CreateKpiFollowUpTemplate();
                break;

            case SectionNavigationTag.PlanII:
                CreateKpiPlanTwoTemplate();
                break;

            case SectionNavigationTag.PurchII:
                CreateKpiPurchTwoTemplate();
                break;

            case SectionNavigationTag.FollowUpTwo:
                CreateKpiFollowUpTwoTemplate();
                break;

            case SectionNavigationTag.PurchSub:
                CreateKpiPurchSubTemplate();
                break;

            case SectionNavigationTag.PurchTotal:
                CreateKpiPurchTotalTemplate();
                break;

            case SectionNavigationTag.PurchPlan:
                CreateKpiPurchPlanTemplate();
                break;

            case SectionNavigationTag.Other:
                CreateKpiOtherTemplate();
                break;

            default:
                break;
            }
        }
示例#16
0
 protected virtual async Task <bool> RequestNavigation(NavigationArgs args)
 {
     if (NavigationRequested != null)
     {
         return(await NavigationRequested(args));
     }
     else
     {
         return(false);
     }
 }
示例#17
0
 protected virtual bool RequestNavigation(NavigationArgs args)
 {
     if (NavigationRequested != null)
     {
         return(NavigationRequested(args));
     }
     else
     {
         return(false);
     }
 }
示例#18
0
        private bool Submit(string url = null, HtmlElement clickedElement = null)
        {
            NavigationArgs navigation = new NavigationArgs();

            navigation.Uri         = url ?? this.Action;
            navigation.Method      = this.Method;
            navigation.ContentType = FormEncoding.FormUrlencode;
            List <string> valuePairs = new List <string>();

            foreach (var entry in Elements.SelectMany(e =>
            {
                bool isClicked = false;
                if (clickedElement != null && clickedElement.Element == e.Element)
                {
                    isClicked = true;
                }
                return(e.ValuesToSubmit(isClicked));
            }
                                                      ))
            {
                navigation.UserVariables.Add(entry.Name, entry.Value);
            }
            navigation.EncodingType = this.EncType;
            if (this.EncType == FormEncoding.MultipartForm)
            {
                // create postdata according to multipart specs
                Guid token = Guid.NewGuid();
                navigation.UserVariables = null;
                StringBuilder post = new StringBuilder();
                foreach (var element in this.Elements)
                {
                    if (element is IHasRawPostData)
                    {
                        post.AppendFormat("--{0}\n", token);
                        string filename = new FileInfo(element.Value).Name;
                        post.AppendFormat("Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\n{2}\n", element.Name, filename, ((IHasRawPostData)element).GetPostData());
                    }
                    else
                    {
                        var values = element.ValuesToSubmit(element == clickedElement);
                        foreach (var value in values)
                        {
                            post.AppendFormat("--{0}\n", token);
                            post.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\n\n{1}\n", value.Name, value.Value);
                        }
                    }
                }
                post.AppendFormat("--{0}\n", token);
                navigation.PostData    = post.ToString();
                navigation.ContentType = FormEncoding.MultipartForm + "; boundary=" + token;
            }
            return(RequestNavigation(navigation));
        }
示例#19
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);

            NavigationArgs args = NavigationHelper.FromArgs(e);
            ViewModelBase  vm   = DataContext as ViewModelBase;

            if (vm != null)
            {
                vm.OnNavigatedFrom(args);
            }
        }
        /// <summary>
        /// Loads the KPA section pages requested by the user
        /// </summary>
        /// <param name="e">The navigation args aquired by the navigation view</param>
        private void LoadKpaSectionPage(NavigationArgs e)
        {
            // Remove and Performance panel from the active panel view
            RemoveActivePanelControls();

            // Update the top handle bar to notify the user they are viewing KPA information
            topHandleBarModel.Performance = "KPA";

            switch (e.SectionTag)
            {
            case SectionNavigationTag.Plan:
                CreateKpaPlanTemplate();
                break;

            case SectionNavigationTag.Purch:
                CreateKpaPurchTemplate();
                break;

            case SectionNavigationTag.PurchSub:
                CreateKpaPurchSubTemplate();
                break;

            case SectionNavigationTag.PurchTotal:
                CreateKpaPurchTotalTemplate();
                break;

            case SectionNavigationTag.FollowUp:
                CreatekpaFollowUpTemplate();
                break;

            case SectionNavigationTag.HotJobs:
                CreateKpaHotJobsTemplate();
                break;

            case SectionNavigationTag.ExcessStockStock:
                CreateKpaExcessStockStockTemplate();
                break;

            case SectionNavigationTag.ExcessStockOpenOrders:
                CreateKpaExcessStockOpenOrdersTemplate();
                break;

            case SectionNavigationTag.CurrentPlanVsActual:
                CreateKpaCurrPlanActualTemplate();
                break;

            default:
                break;
            }
        }
示例#21
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            NavigationArgs args          = NavigationHelper.FromArgs(e);
            string         parametersKey = null;

            if (NavigationContext.QueryString.ContainsKey("key"))
            {
                parametersKey = NavigationContext.QueryString["key"];
            }
            ViewModelBase vm = DataContext as ViewModelBase;

            if (vm != null)
            {
                vm.OnNavigatedTo(args, parametersKey);
            }
        }
示例#22
0
        //主界面导航回调
        private void MainNavigationCallback(NavigationArgs args)
        {
            //首页需要重置界面状态
            if (args.MsgToken == ExportKeys.HomePageView)
            {
                CollapsedCaseNameRow();
            }
            else if (args.MsgToken == ExportKeys.CaseCreationView && !IsShowCurCaseNameRow)
            {
                IsShowCurCaseNameRow = true;
            }
            else if (args.MsgToken == ExportKeys.DeviceSelectView && !IsShowDeviceListRow)
            {
                IsShowDeviceListRow = true;
            }

            CurMainView = args.View;
        }
示例#23
0
        /// <summary>
        /// Navigation To
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Frame_Navigated(object sender, NavigationEventArgs e)
        {
            var naviArgs = new NavigationArgs
            {
                Content        = e.Content,
                NavigationMode =
                    (Models.NavigationMode)Enum.Parse(typeof(Models.NavigationMode), e.NavigationMode.ToString()),
                Parameter = e.Parameter,
                Uri       = e.Uri
            };

            //프레임의 세션 스테이트 값 복구
            var frameState = SuspensionManager.SessionStateForFrame(_frame);
            var pageKey    = PAGE + _frame.BackStackDepth;

            if (naviArgs.NavigationMode == Models.NavigationMode.New)
            {
                // Clear existing state for forward navigation when adding a new page to the
                // navigation stack
                var nextPageKey   = pageKey;
                var nextPageIndex = _frame.BackStackDepth;
                while (frameState.Remove(nextPageKey))
                {
                    nextPageIndex++;
                    nextPageKey = PAGE + nextPageIndex;
                }
                _frameSessionState  = new Dictionary <string, object>();
                frameState[pageKey] = _frameSessionState;
            }
            else
            {
                _frameSessionState = (Dictionary <String, Object>)frameState[pageKey];
            }

            if (StaticFunctions.BaseContext != null)
            {
                StaticFunctions.InvokeIfRequiredAsync(StaticFunctions.BaseContext,
                                                      para => _eventAggregator.GetEvent <NavigatedEvent>().Publish(naviArgs), null);
            }
            else
            {
                _eventAggregator.GetEvent <NavigatedEvent>().Publish(naviArgs);
            }
        }
示例#24
0
        private void NavigationStarting(NavigationArgs args)
        {
            string authCode = string.Empty;

            if (args.Uri.IndexOfCaseInsensitive(RedirectUri) == 0)
            {
                string codeKey        = "code=";
                int    codeStartIndex = args.Uri.IndexOfCaseInsensitive(codeKey);

                if (codeStartIndex > 0)
                {
                    codeStartIndex += codeKey.Length;
                    var segments = args.Uri.Substring(codeStartIndex).Split('&');
                    authCode = segments[0];

                    IsLoading   = false;
                    args.Cancel = true;

                    InitializeApp(authCode);
                }
            }
        }
示例#25
0
        /// <summary>
        /// Perform a click action on the label element.
        /// </summary>
        /// <returns>The <see cref="ClickResult"/> of the operation.</returns>
        public override ClickResult Click()
        {
            base.Click();
            var match = postbackRecognizer.Match(this.Href);
            if (match.Success)
            {
                var name = match.Groups[1].Value;
                var eventTarget = this.OwningBrowser.Select("input[name=__EVENTTARGET]");

                // IIS does browser sniffing. If using the default SimpleBrowser user agent string,
                // IIS will not render the hidden __EVENTTARGET input. If, for whatever reason,
                // the __EVENTTARGET input is not present, create it.
                if (!eventTarget.Exists)
                {
                    var elt = new XElement("input");
                    elt.SetAttributeCI("type", "hidden");
                    elt.SetAttributeCI("name", "__EVENTTARGET");
                    elt.SetAttributeCI("id", "__EVENTTARGET");
                    elt.SetAttributeCI("value", name);

                    this.XElement.AddBeforeSelf(elt);
                    eventTarget = this.OwningBrowser.Select("input[name=__EVENTTARGET]");
                }

                if (!eventTarget.Exists)
                {
                    // If the element is still not found abort.
                    return ClickResult.Failed;
                }

                eventTarget.Value = name;

                if (this.SubmitForm())
                {
                    return ClickResult.SucceededNavigationComplete;
                }
                else
                {
                    return ClickResult.Failed;
                }
            }

            string url = this.Href;
            string target = this.Target;
            string queryStringValues = null;

            if ((OwningBrowser.KeyState & (KeyStateOption.Ctrl | KeyStateOption.Shift)) != KeyStateOption.None)
            {
                target = Browser.TARGET_BLANK;
            }

            if (url != null)
            {
                string[] querystring = url.Split(new[] { '?' });
                if (querystring.Length > 1)
                {
                    queryStringValues = querystring[1];
                }
            }

            NavigationArgs navArgs = new NavigationArgs()
            {
                Uri = url,
                Target = target,
                UserVariables = StringUtil.MakeCollectionFromQueryString(queryStringValues)
            };

            if (this.Rel == "noreferrer")
            {
                navArgs.NavigationAttributes.Add("rel", "noreferrer");
            }

            if (this.RequestNavigation(navArgs))
            {
                return ClickResult.SucceededNavigationComplete;
            }
            else
            {
                return ClickResult.SucceededNavigationError;
            }
        }
示例#26
0
        /// <summary>
        /// Perform a click action on the anchor element.
        /// </summary>
        /// <returns>The <see cref="ClickResult"/> of the operation.</returns>
        public override ClickResult Click()
        {
            base.Click();
            var match = postbackRecognizer.Match(this.Href);

            if (match.Success)
            {
                var name        = match.Groups[1].Value;
                var eventTarget = this.OwningBrowser.Select("input[name=__EVENTTARGET]");

                // IIS does browser sniffing. If using the default SimpleBrowser user agent string,
                // IIS will not render the hidden __EVENTTARGET input. If, for whatever reason,
                // the __EVENTTARGET input is not present, create it.
                if (!eventTarget.Exists)
                {
                    var elt = new XElement("input");
                    elt.SetAttributeCI("type", "hidden");
                    elt.SetAttributeCI("name", "__EVENTTARGET");
                    elt.SetAttributeCI("id", "__EVENTTARGET");
                    elt.SetAttributeCI("value", name);

                    this.XElement.AddBeforeSelf(elt);
                    eventTarget = this.OwningBrowser.Select("input[name=__EVENTTARGET]");
                }

                if (!eventTarget.Exists)
                {
                    // If the element is still not found abort.
                    return(ClickResult.Failed);
                }

                eventTarget.Value = name;

                if (this.SubmitForm())
                {
                    return(ClickResult.SucceededNavigationComplete);
                }
                else
                {
                    return(ClickResult.Failed);
                }
            }

            string url               = this.Href;
            string target            = this.Target;
            string queryStringValues = null;

            if ((OwningBrowser.KeyState & (KeyStateOption.Ctrl | KeyStateOption.Shift)) != KeyStateOption.None)
            {
                target = Browser.TARGET_BLANK;
            }

            if (url != null)
            {
                string[] querystring = url.Split(new[] { '?' });
                if (querystring.Length > 1)
                {
                    queryStringValues = querystring[1];
                }
            }

            NavigationArgs navArgs = new NavigationArgs()
            {
                Uri           = url,
                Target        = target,
                UserVariables = StringUtil.MakeCollectionFromQueryString(queryStringValues)
            };

            if (this.Rel == "noreferrer")
            {
                navArgs.NavigationAttributes.Add("rel", "noreferrer");
            }

            if (this.RequestNavigation(navArgs))
            {
                return(ClickResult.SucceededNavigationComplete);
            }
            else
            {
                return(ClickResult.SucceededNavigationError);
            }
        }
示例#27
0
        /// <summary>
        /// Submits the form
        /// </summary>
        /// <param name="url">Optional. If specified, the url to submit the form. Overrides the form action.</param>
        /// <param name="clickedElement">Optional. The element clicked, resulting in form submission.</param>
        /// <returns>True, if the form submitted successfully, false otherwise.</returns>
        private bool Submit(string url = null, HtmlElement clickedElement = null)
        {
            NavigationArgs navigation = new NavigationArgs();
            navigation.Uri = url ?? this.Action;
            navigation.Method = this.Method;
            navigation.ContentType = FormEncoding.FormUrlencode;
            foreach (var entry in this.Elements.SelectMany(e =>
                    {
                        bool isClicked = false;
                        if (clickedElement != null && clickedElement.Element == e.Element)
                        {
                            isClicked = true;
                        }

                        return e.ValuesToSubmit(isClicked);
                    }))
            {
                navigation.UserVariables.Add(entry.Name, entry.Value);
            }

            if (this.EncType == FormEncoding.MultipartForm && this.Method.Equals("POST", StringComparison.OrdinalIgnoreCase))
            {
                // create postdata according to multipart specs
                Guid token = Guid.NewGuid();
                navigation.UserVariables = null;
                StringBuilder post = new StringBuilder();
                foreach (var element in this.Elements)
                {
                    if (element is IHasRawPostData)
                    {
                        post.AppendFormat("--{0}\r\n", token);
                        post.AppendFormat(
                            "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n{2}\r\n",
                            element.Name,
                            new FileInfo(element.Value).Name,
                            ((IHasRawPostData)element).GetPostData());
                    }
                    else
                    {
                        bool isClickedElement = false;
                        if (clickedElement != null)
                        {
                            isClickedElement = element.Element == clickedElement.Element;
                        }

                        var values = element.ValuesToSubmit(isClickedElement);
                        foreach (var value in values)
                        {
                            post.AppendFormat("--{0}\r\n", token);
                            post.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", value.Name, value.Value);
                        }
                    }
                }

                post.AppendFormat("--{0}--\r\n", token);
                navigation.PostData = post.ToString();
                navigation.ContentType = FormEncoding.MultipartForm + "; boundary=" + token;
            }

            return this.RequestNavigation(navigation);
        }
示例#28
0
        /// <summary>
        /// Submits the form
        /// </summary>
        /// <param name="url">Optional. If specified, the url to submit the form. Overrides the form action.</param>
        /// <param name="clickedElement">Optional. The element clicked, resulting in form submission.</param>
        /// <returns>True, if the form submitted successfully, false otherwise.</returns>
        private bool Submit(string url = null, HtmlElement clickedElement = null)
        {
            string action  = this.Action;
            string method  = this.Method;
            string enctype = this.EncType;
            string target  = this.Target;

            this.Validate = true;

            if (clickedElement != null)
            {
                string clickedElementAction = clickedElement.GetAttributeValue("formaction");
                if (!string.IsNullOrWhiteSpace(clickedElementAction))
                {
                    action = clickedElementAction;
                }

                string clickedElementEncType = clickedElement.GetAttributeValue("formenctype");
                if (!string.IsNullOrWhiteSpace(clickedElementEncType))
                {
                    enctype = clickedElementEncType;
                }

                string clickedElementMethod = clickedElement.GetAttributeValue("formmethod");
                if (!string.IsNullOrWhiteSpace(clickedElementMethod))
                {
                    method = clickedElementMethod;
                }

                string clickedElementTarget = clickedElement.GetAttributeValue("formtarget");
                if (!string.IsNullOrWhiteSpace(clickedElementTarget))
                {
                    target = clickedElementTarget;
                }

                if (clickedElement.XElement.HasAttributeCI("formnovalidate"))
                {
                    this.Validate = false;
                }
            }

            NavigationArgs navigation = new NavigationArgs
            {
                Uri          = url ?? action,
                Method       = method,
                ContentType  = FormEncoding.FormUrlencode,
                EncodingType = enctype,
                Target       = target
            };

            try
            {
                foreach (UserVariableEntry entry in this.Elements.SelectMany(e =>
                {
                    bool isClicked = false;
                    if (clickedElement != null && clickedElement.Element == e.Element)
                    {
                        isClicked = true;
                    }

                    return(e.ValuesToSubmit(isClicked, this.Validate));
                }))
                {
                    navigation.UserVariables.Add(entry.Name, entry.Value);
                }
            }
            catch (FormElementValidationException formElementValidationException)
            {
                base.OwningBrowser.Log(formElementValidationException.Message, LogMessageType.Error);
                return(false);
            }

            if (navigation.EncodingType == FormEncoding.MultipartForm && navigation.Method.Equals("POST", StringComparison.OrdinalIgnoreCase))
            {
                // create postdata according to multipart specs
                Guid token = Guid.NewGuid();
                navigation.UserVariables = null;
                StringBuilder post = new StringBuilder();
                foreach (FormElementElement element in this.Elements)
                {
                    bool isClickedElement = false;
                    if (clickedElement != null)
                    {
                        isClickedElement = element.Element == clickedElement.Element;
                    }

                    IEnumerable <UserVariableEntry> values = element.ValuesToSubmit(isClickedElement, this.Validate);
                    foreach (UserVariableEntry value in values)
                    {
                        post.AppendFormat("--{0}\r\n", token);
                        if (element is FileUploadElement)
                        {
                            post.AppendFormat(
                                "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n{2}\r\n",
                                element.Name,
                                value.Name,
                                value.Value);
                        }
                        else
                        {
                            post.AppendFormat(
                                "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n",
                                value.Name,
                                value.Value);
                        }
                    }
                }

                post.AppendFormat("--{0}--\r\n", token);
                navigation.PostData    = post.ToString();
                navigation.ContentType = FormEncoding.MultipartForm + "; boundary=" + token;
            }

            return(this.RequestNavigation(navigation));
        }
示例#29
0
 public void OnNavigatedTo(NavigationArgs args)
 {
 }
 public NavigationEventArgs(NavigationArgs args)
 {
     Args = args;
 }
示例#31
0
 public override void OnNavigatedTo(NavigationArgs e, string parametersKey)
 {
     base.OnNavigatedTo(e, parametersKey);
 }
示例#32
0
 protected virtual bool RequestNavigation(NavigationArgs args)
 {
     if (NavigationRequested != null)
         return NavigationRequested(args);
     else
         return false;
 }
示例#33
0
 public override void HandleEnter(NavigationArgs args)
 {
     GameSystems.Raycaster.IsRaycasting = false;
     base.HandleEnter(args);
 }
 public void OnReceivedNotification(NavigationArgs notificationArgs)
 {
     SelectedTable = notificationArgs.Data as TableVM;
     Name          = SelectedTable.Name;
 }