private async void Send_Clicked()
        {
            //await PostDatabase.Instance.UpdateItemData(PostContent);
            await NavigationMethod.GoBackAsync();

            EventAggregator.GetEvent <SendMessageEvent>().Publish(PostContent);
        }
예제 #2
0
        /// <summary>
        /// Sets the currently focused element in the specified scope.
        /// </summary>
        /// <param name="scope">The focus scope.</param>
        /// <param name="element">The element to focus. May be null.</param>
        /// <param name="method">The method by which focus was changed.</param>
        /// <param name="keyModifiers">Any key modifiers active at the time of focus.</param>
        /// <remarks>
        /// If the specified scope is the current <see cref="Scope"/> then the keyboard focus
        /// will change.
        /// </remarks>
        public void SetFocusedElement(
            IFocusScope scope,
            IInputElement?element,
            NavigationMethod method   = NavigationMethod.Unspecified,
            KeyModifiers keyModifiers = KeyModifiers.None)
        {
            scope = scope ?? throw new ArgumentNullException(nameof(scope));

            if (_focusScopes.TryGetValue(scope, out var existingElement))
            {
                if (element != existingElement)
                {
                    _focusScopes.Remove(scope);
                    _focusScopes.Add(scope, element);
                }
            }
            else
            {
                _focusScopes.Add(scope, element);
            }

            if (Scope == scope)
            {
                KeyboardDevice.Instance?.SetFocusedElement(element, method, keyModifiers);
            }
        }
예제 #3
0
        /// <summary>
        /// Focuses a control.
        /// </summary>
        /// <param name="control">The control to focus.</param>
        /// <param name="method">The method by which focus was changed.</param>
        /// <param name="modifiers">Any input modifiers active at the time of focus.</param>
        public void Focus(
            IInputElement control,
            NavigationMethod method  = NavigationMethod.Unspecified,
            InputModifiers modifiers = InputModifiers.None)
        {
            if (control != null)
            {
                var scope = GetFocusScopeAncestors(control)
                            .FirstOrDefault();

                if (scope != null)
                {
                    Scope = scope;
                    SetFocusedElement(scope, control, method, modifiers);
                }
            }
            else if (Current != null)
            {
                // If control is null, set focus to the topmost focus scope.
                foreach (var scope in GetFocusScopeAncestors(Current).Reverse().ToList())
                {
                    IInputElement element;

                    if (_focusScopes.TryGetValue(scope, out element))
                    {
                        Focus(element, method);
                        break;
                    }
                }
            }
        }
예제 #4
0
        public void SetFocusedElement(
            IInputElement element, 
            NavigationMethod method,
            InputModifiers modifiers)
        {
            if (element != FocusedElement)
            {
                var interactive = FocusedElement as IInteractive;

                interactive?.RaiseEvent(new RoutedEventArgs
                {
                    RoutedEvent = InputElement.LostFocusEvent,
                });

                FocusedElement = element;
                interactive = element as IInteractive;

                interactive?.RaiseEvent(new GotFocusEventArgs
                {
                    RoutedEvent = InputElement.GotFocusEvent,
                    NavigationMethod = method,
                    InputModifiers = modifiers,
                });
            }
        }
예제 #5
0
        /// <summary>
        /// Focuses a control.
        /// </summary>
        /// <param name="control">The control to focus.</param>
        /// <param name="method">The method by which focus was changed.</param>
        /// <param name="modifiers">Any input modifiers active at the time of focus.</param>
        public void Focus(
            IInputElement control, 
            NavigationMethod method = NavigationMethod.Unspecified,
            InputModifiers modifiers = InputModifiers.None)
        {
            if (control != null)
            {
                var scope = GetFocusScopeAncestors(control)
                    .FirstOrDefault();

                if (scope != null)
                {
                    Scope = scope;
                    SetFocusedElement(scope, control, method, modifiers);
                }
            }
            else if (Current != null)
            {
                // If control is null, set focus to the topmost focus scope.
                foreach (var scope in GetFocusScopeAncestors(Current).Reverse().ToList())
                {
                    IInputElement element;

                    if (_focusScopes.TryGetValue(scope, out element))
                    {
                        Focus(element, method);
                        break;
                    }
                }
            }
        }
        public static bool HasAccessToDestinationPage(SubSystem subsystem, NavigationMethod mode)
        {
            var  access = UserData.CurrentAccessRight;
            bool canRead = false, canEdit = false, canDelete = false, canConfirm = false, canLog = false;

            switch (subsystem)
            {
            case SubSystem.Contract:
                canRead    = true; //(bool)UserData.CurrentUser.ManagingPaymentDraft || (bool)access.ContractPermanentWrite || (bool)access.ContractRead || (bool)UserData.CurrentUser.PaymentDraftCommittee ;
                canEdit    = true; //(bool)access.ContractWrite || (bool)UserData.CurrentUser.ManagingPaymentDraft;
                canDelete  = true; //(bool)access.ContractDelete;
                canConfirm = true; //(bool)access.ContractPermanentWrite;
                canLog     = (bool)access.ContractLog;
                break;

            case SubSystem.Regulation:
                canRead    = (bool)access.RegulationRead;
                canEdit    = (bool)access.RegulationWrite;
                canDelete  = (bool)access.RegulationDelete;
                canConfirm = (bool)access.RegulationPermanentWrite;
                canLog     = (bool)access.RegulationLog;
                break;

            case SubSystem.Tendering:
                canRead    = (bool)access.TenderingRead;
                canEdit    = (bool)access.TenderingWrite;
                canDelete  = (bool)access.TenderingDelete;
                canConfirm = (bool)access.TenderingPermanentWrite;
                canLog     = (bool)access.TenderingLog;
                break;

            case SubSystem.TenderingArchive:
                canRead   = (bool)access.TenderingArchiveRead;
                canEdit   = (bool)access.TenderingArchiveWrite;
                canDelete = (bool)access.TenderingArchiveDelete;
                canLog    = (bool)access.TenderingArchiveLog;
                break;
            }

            if (subsystem == SubSystem.UserManagement)
            {
                if (UserData.CurrentAccessRight.CreatingUser == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            if (mode == NavigationMethod.NewMode || mode == NavigationMethod.EditMode)
            {
                return(canEdit);
            }
            if (mode == NavigationMethod.ViewMode)
            {
                return(canRead);
            }
            return(true);
        }
        private async void Button_Clicked()
        {
            bool loggedIn = false;

            Settings.RememberMe = _rememberMe;

            if (_rememberMe)
            {
                Settings.Username = _username;

                if (Settings.Password == Settings.DefaultPassword)
                {
                    Settings.Password = _password;
                }
            }
            else
            {
                Settings.Username = _username;
                if (Settings.Password == _password)
                {
                    Settings.Password = Settings.DefaultPassword;
                    loggedIn          = true;
                }
                Settings.Username = string.Empty;
            }

            if (loggedIn || (Settings.Password == _password))
            {
                await NavigationMethod.NavigateAsync(nameof(Home));
            }
            else
            {
                await DialogService.DisplayAlertAsync("Alert", "Invalid Password", "OK");
            }
        }
예제 #8
0
        /// <summary>
        /// Sets the currently focused element in the specified scope.
        /// </summary>
        /// <param name="scope">The focus scope.</param>
        /// <param name="element">The element to focus. May be null.</param>
        /// <param name="method">The method by which focus was changed.</param>
        /// <param name="keyModifiers">Any key modifiers active at the time of focus.</param>
        /// <remarks>
        /// If the specified scope is the current <see cref="Scope"/> then the keyboard focus
        /// will change.
        /// </remarks>
        public void SetFocusedElement(
            IFocusScope scope,
            IInputElement element,
            NavigationMethod method   = NavigationMethod.Unspecified,
            KeyModifiers keyModifiers = KeyModifiers.None)
        {
            Contract.Requires <ArgumentNullException>(scope != null);

            if (_focusScopes.TryGetValue(scope, out IInputElement existingElement))
            {
                if (element != existingElement)
                {
                    _focusScopes.Remove(scope);
                    _focusScopes.Add(scope, element);
                }
            }
            else
            {
                _focusScopes.Add(scope, element);
            }

            if (Scope == scope)
            {
                KeyboardDevice.Instance?.SetFocusedElement(element, method, keyModifiers);
            }
        }
예제 #9
0
        /// <summary>
        /// Focuses a control.
        /// </summary>
        /// <param name="control">The control to focus.</param>
        /// <param name="method">The method by which focus was changed.</param>
        /// <param name="keyModifiers">Any key modifiers active at the time of focus.</param>
        public void Focus(
            IInputElement control,
            NavigationMethod method   = NavigationMethod.Unspecified,
            KeyModifiers keyModifiers = KeyModifiers.None)
        {
            if (control != null)
            {
                var scope = GetFocusScopeAncestors(control)
                            .FirstOrDefault();

                if (scope != null)
                {
                    Scope = scope;
                    SetFocusedElement(scope, control, method, keyModifiers);
                }
            }
            else if (Current != null)
            {
                // If control is null, set focus to the topmost focus scope.
                foreach (var scope in GetFocusScopeAncestors(Current).Reverse().ToList())
                {
                    IInputElement element;

                    if (_focusScopes.TryGetValue(scope, out element) && element != null)
                    {
                        Focus(element, method);
                        return;
                    }
                }

                // Couldn't find a focus scope, clear focus.
                SetFocusedElement(Scope, null);
            }
        }
예제 #10
0
        public void SetFocusedElement(IInputElement element, NavigationMethod method)
        {
            if (element != FocusedElement)
            {
                var interactive = FocusedElement as IInteractive;

                if (interactive != null)
                {
                    interactive.RaiseEvent(new RoutedEventArgs
                    {
                        RoutedEvent = InputElement.LostFocusEvent,
                    });
                }

                FocusedElement = element;
                interactive = element as IInteractive;

                if (interactive != null)
                {
                    interactive.RaiseEvent(new GotFocusEventArgs
                    {
                        RoutedEvent = InputElement.GotFocusEvent,
                        NavigationMethod = method,
                    });
                }
            }
        }
예제 #11
0
        public void SetFocusedElement(
            IInputElement element,
            NavigationMethod method,
            InputModifiers modifiers)
        {
            if (element != FocusedElement)
            {
                var interactive = FocusedElement as IInteractive;

                if (interactive != null)
                {
                    interactive.RaiseEvent(new RoutedEventArgs
                    {
                        RoutedEvent = InputElement.LostFocusEvent,
                    });
                }

                FocusedElement = element;
                interactive    = element as IInteractive;

                if (interactive != null)
                {
                    interactive.RaiseEvent(new GotFocusEventArgs
                    {
                        RoutedEvent      = InputElement.GotFocusEvent,
                        NavigationMethod = method,
                        InputModifiers   = modifiers,
                    });
                }
            }
        }
예제 #12
0
        public void SetFocusedElement(
            IInputElement element,
            NavigationMethod method,
            KeyModifiers keyModifiers)
        {
            if (element != FocusedElement)
            {
                var interactive = FocusedElement as IInteractive;
                FocusedElement = element;

                interactive?.RaiseEvent(new RoutedEventArgs
                {
                    RoutedEvent = InputElement.LostFocusEvent,
                });

                interactive = element as IInteractive;

                interactive?.RaiseEvent(new GotFocusEventArgs
                {
                    RoutedEvent      = InputElement.GotFocusEvent,
                    NavigationMethod = method,
                    KeyModifiers     = keyModifiers,
                });
            }
        }
예제 #13
0
        private async void Button_Clicked()
        {
            await NavigationMethod.NavigateAsync(nameof(ChooseGamePage));

            Players[_turn].Turn = true;

            EventAggregator.GetEvent <MessageSentEvent>().Publish(Players);
        }
예제 #14
0
        private async void ChangeColor_Clicked()
        {
            await NavigationMethod.GoBackAsync();

            if (BackgroundColor != null)
            {
                EventAggregator.GetEvent <SendMessageEvent>().Publish(BackgroundColor);
            }
        }
        public void PushAndGo(NavigationMethod method, string page)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            if (path.Count == 0 || !Request.Url.Equals(path.Peek()))
            {
                path.Push(Request.Url);
            }

            Navigate(method, page);
        }
예제 #16
0
        /// <summary>
        /// Sets the currently focused element in the specified scope.
        /// </summary>
        /// <param name="scope">The focus scope.</param>
        /// <param name="element">The element to focus. May be null.</param>
        /// <param name="method">The method by which focus was changed.</param>
        /// <remarks>
        /// If the specified scope is the current <see cref="Scope"/> then the keyboard focus
        /// will change.
        /// </remarks>
        public void SetFocusedElement(
            IFocusScope scope,
            IInputElement element,
            NavigationMethod method = NavigationMethod.Unspecified)
        {
            Contract.Requires <ArgumentNullException>(scope != null);

            _focusScopes[scope] = element;

            if (Scope == scope)
            {
                KeyboardDevice.Instance.SetFocusedElement(element, method);
            }
        }
        private void PerformPop(NavigationMethod method, int count, string message)
        {
            try
            {
                if (count <= 0)
                {
                    throw new ArgumentException("Must be greater than zero", "count");
                }

                string url = null;
                while (count-- >= 0 && path.Count > 0)
                {
                    url = Convert.ToString(path.Pop());
                }

                if (String.IsNullOrEmpty(url))
                {
                    if (!String.IsNullOrEmpty(nextPopFallback))
                    {
                        Navigate(method, nextPopFallback, message);
                    }
                    else
                    {
                        GoHome(method, message);
                    }
                }
                else
                {
                    Navigate(method, url, message);
                }
            }
            catch (Exception ex)
            {
                if (ex is ThreadAbortException)
                {
                    throw;
                }
                else
                {
                    throw new NavigationException();
                }
            }
            finally
            {
                nextPopFallback = null;
            }
        }
        public void Navigate(NavigationMethod method, string page, string message)
        {
            switch (method)
            {
            case NavigationMethod.Redirect:
                Response.Redirect(page);
                break;

            case NavigationMethod.RedirectJS:
                WebUtil.JavascriptRedirect(page, message);
                break;

            case NavigationMethod.Transfer:
                Server.Transfer(page);
                break;
            }
        }
        private async void Next_Page(object obj)
        {
            string[] preferences = new string[4];

            if (LikeXamarin == true)
            {
                preferences[0] = FavColor;
                preferences[0] = FavBand;
                preferences[0] = "true";
            }
            else
            {
                preferences[0] = FavColor;
                preferences[0] = FavBand;
                preferences[0] = "false";
            }

            await NavigationMethod.NavigateAsync(nameof(MainPage));

            EventAggregator.GetEvent <SendMessageEvent>().Publish(preferences);
        }
예제 #20
0
        public void SetFocusedElement(
            IInputElement?element,
            NavigationMethod method,
            KeyModifiers keyModifiers)
        {
            if (element != FocusedElement)
            {
                var interactive = FocusedElement as IInteractive;

                if (FocusedElement != null &&
                    (!FocusedElement.IsAttachedToVisualTree ||
                     _focusedRoot != element?.VisualRoot as IInputRoot) &&
                    _focusedRoot != null)
                {
                    ClearChildrenFocusWithin(_focusedRoot, true);
                }

                SetIsFocusWithin(FocusedElement, element);
                _focusedElement = element;
                _focusedRoot    = _focusedElement?.VisualRoot as IInputRoot;

                interactive?.RaiseEvent(new RoutedEventArgs
                {
                    RoutedEvent = InputElement.LostFocusEvent,
                });

                interactive = element as IInteractive;

                interactive?.RaiseEvent(new GotFocusEventArgs
                {
                    RoutedEvent      = InputElement.GotFocusEvent,
                    NavigationMethod = method,
                    KeyModifiers     = keyModifiers,
                });

                _textInputManager.SetFocusedElement(element);
                RaisePropertyChanged(nameof(FocusedElement));
            }
        }
 public void SetFocusedElement(IInputElement element, NavigationMethod method, InputModifiers modifiers)
 {
     throw new System.NotImplementedException();
 }
		public void PushAndGo(NavigationMethod method, string page)
		{
			if (page == null)
				throw new ArgumentNullException("page");

			if (path.Count == 0 || !Request.Url.Equals(path.Peek()))
				path.Push(Request.Url);

			Navigate(method, page);
		}
		private void PerformPop(NavigationMethod method, int count, string message)
		{
			try
			{
				if (count <= 0)
					throw new ArgumentException("Must be greater than zero", "count");

				string url = null;
				while (count-- >= 0 && path.Count > 0)
					url = Convert.ToString(path.Pop());

				if (String.IsNullOrEmpty(url))
				{
					if (!String.IsNullOrEmpty(nextPopFallback))
						Navigate(method, nextPopFallback, message);
					else
						GoHome(method, message);
				}
				else
					Navigate(method, url, message);
			}
			catch (Exception ex)
			{
				if (ex is ThreadAbortException)
					throw;
				else
					throw new NavigationException();
			}
			finally
			{
				nextPopFallback = null;
			}
		}
 public void GoHome(NavigationMethod method, string message)
 {
     Navigate(method, home ?? cfg.DefaultHome, message);
 }
예제 #25
0
 /// <summary>
 ///     Sets focus on either the previous tab stop or the next tab stop of the sink.
 /// </summary>
 /// <param name="navigationMethod">
 ///     Specifies whether the focus should be set no the previous or the next
 ///     tab stop relative to this one.
 /// </param>
 protected virtual void TabOutCore(NavigationMethod navigationMethod)
 {
 }
		public void Navigate(NavigationMethod method, string page)
		{
			Navigate(method, page, null);
		}
 public void Navigate(NavigationMethod method, string page)
 {
     Navigate(method, page, null);
 }
예제 #28
0
 /// <summary>
 ///     Sets focus on either the first tab stop or the last tab stop of the sink.
 /// </summary>
 /// <param name="navigationMethod">
 ///     Specifies whether focus should be set to the first or the last tab stop.
 /// </param>
 /// <returns>
 ///     <b>True</b> if the focus has been set as requested.
 ///     <b>False</b>, if there are no tab stops.
 /// </returns>
 /// <remarks>
 ///     You can get <see cref="FocusNavigationDirection.Previous"/> for
 ///     the last native control (means Shift+Tab was pressed), or
 ///     <see cref="FocusNavigationDirection.Next"/> for the first
 ///     native control (means Tab was pressed).
 /// </remarks>
 protected virtual bool TabIntoCore(NavigationMethod navigationMethod)
 {
     return(false);
 }
 public void GoHome(NavigationMethod method)
 {
     GoHome(method, null);
 }
		public void GoLogin(NavigationMethod method, string message)
		{
			Navigate(method, cfg.Login, message);
		}
		public void Pop(NavigationMethod method)
		{
			Pop(method, 1);
		}
		public void Navigate(NavigationMethod method, string page, string message)
		{
			switch (method)
			{
				case NavigationMethod.Redirect:
					Response.Redirect(page);
					break;
				case NavigationMethod.RedirectJS:
					WebUtil.JavascriptRedirect(page, message);
					break;
				case NavigationMethod.Transfer:
					Server.Transfer(page);
					break;
			}
		}
		public void GoHome(NavigationMethod method)
		{
			GoHome(method, null);
		}
        public static void NavigateToPageWithMode(Page currentPage, Page destination, NavigationMethod mode, SubSystem subSystem, bool keepCurrentAlive = false)
        {
            currentPage.KeepAlive = keepCurrentAlive;
            if (!HasAccessToDestinationPage(subSystem, mode))
            {
                ErrorHandler.ShowErrorMessage("در حال حاضر دسترسی به این صفحه امکان پذیر نیست");
                return;
            }
            try
            {
                switch (mode)
                {
                case NavigationMethod.ViewMode:
                    destination.Loaded += new RoutedEventHandler(destination_Loaded_View);
                    break;

                case NavigationMethod.EditMode:
                    destination.Loaded += new RoutedEventHandler(destination_Loaded_Edit);
                    break;

                case NavigationMethod.NewMode:
                    destination.Loaded += new RoutedEventHandler(destination_Loaded_New);
                    break;
                }
                currentPage.Dispatcher.BeginInvoke((Action) delegate
                {
                    currentPage.NavigationService.Navigate(destination);
                }, DispatcherPriority.Normal);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("System encountered problem during navigation\n" + ex.Message);
            }
        }
 public void GoLogin(NavigationMethod method, string message)
 {
     Navigate(method, cfg.Login, message);
 }
예제 #36
0
 bool IKeyboardInputSink.TabInto(NavigationMethod navigationMethod)
 {
     return(TabIntoCore(navigationMethod));
 }
예제 #37
0
        /// <summary>
        /// Sets the currently focused element in the specified scope.
        /// </summary>
        /// <param name="scope">The focus scope.</param>
        /// <param name="element">The element to focus. May be null.</param>
        /// <param name="method">The method by which focus was changed.</param>
        /// <param name="modifiers">Any input modifiers active at the time of focus.</param>
        /// <remarks>
        /// If the specified scope is the current <see cref="Scope"/> then the keyboard focus
        /// will change.
        /// </remarks>
        public void SetFocusedElement(
            IFocusScope scope,
            IInputElement element,
            NavigationMethod method = NavigationMethod.Unspecified,
            InputModifiers modifiers = InputModifiers.None)
        {
            Contract.Requires<ArgumentNullException>(scope != null);

            _focusScopes[scope] = element;

            if (Scope == scope)
            {
                KeyboardDevice.Instance.SetFocusedElement(element, method, modifiers);
            }
        }
예제 #38
0
 void IKeyboardInputSink.TabOut(NavigationMethod navigationMethod)
 {
     TabOutCore(navigationMethod);
 }
 public void GoLogin(NavigationMethod method)
 {
     GoLogin(method, null);
 }
예제 #40
0
 /// <summary>
 /// Instantiates a new NavigationInfo with the given parameters.
 /// </summary>
 /// <param name="method">Navigation method.</param>
 /// <param name="itemId">Season/Tune/Type id based on navigation method.</param>
 public NavigationInfo(NavigationMethod method, int itemId)
 {
     Method = method;
     ItemId = itemId;
 }
예제 #41
0
 private async void ImageButton_Clicked()
 {
     await NavigationMethod.NavigateAsync(nameof(Post));
 }
		public void GoHome(NavigationMethod method, string message)
		{
			Navigate(method, home ?? cfg.DefaultHome, message);
		}
		public void Pop(NavigationMethod method, int count)
		{
			PerformPop(method, count, null);
		}
		public void GoLogin(NavigationMethod method)
		{
			GoLogin(method, null);
		}
예제 #45
0
        /// <summary>
        /// Sets the currently focused element in the specified scope.
        /// </summary>
        /// <param name="scope">The focus scope.</param>
        /// <param name="element">The element to focus. May be null.</param>
        /// <param name="method">The method by which focus was changed.</param>
        /// <remarks>
        /// If the specified scope is the current <see cref="Scope"/> then the keyboard focus
        /// will change.
        /// </remarks>
        public void SetFocusedElement(
            IFocusScope scope,
            IInputElement element,
            NavigationMethod method = NavigationMethod.Unspecified)
        {
            Contract.Requires<ArgumentNullException>(scope != null);

            this.focusScopes[scope] = element;

            if (this.Scope == scope)
            {
                KeyboardDevice.Instance.SetFocusedElement(element, method);
            }
        }