Inheritance: UserControl, IPage, IPageOverrides
Exemplo n.º 1
0
        public static void AddBottomAppBar(Page myPage)
        {
            var commandBar = new CommandBar();
            var searchButton = new AppBarButton
            {
                Label = "Поиск",
                Icon = new SymbolIcon(Symbol.Find),
            };

            var aboutButton = new AppBarButton
            {
                Label = "О прилож.",
                Icon = new SymbolIcon(Symbol.Help),
            };

            if (RootFrame != null)
            {
                searchButton.Click += SearchButtonClick;
                aboutButton.Click += AboutButtonClick;
            }

            commandBar.PrimaryCommands.Add(searchButton);
            commandBar.PrimaryCommands.Add(aboutButton);
            myPage.BottomAppBar = commandBar;
        }
        public NavigationHelper(Page page)
        {
            this.Page = page;

            this.Page.Loaded += (sender, e) =>
            {
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width)
                {
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;

                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
            };

            this.Page.Unloaded += (sender, e) =>
            {
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
            };
        }
Exemplo n.º 3
0
 static public void Save(Page inputFrame)
 {
     // Keep values of authentication fields.
     baseUri = (inputFrame.FindName("ServiceAddressField") as TextBox).Text;
     user = (inputFrame.FindName("UserNameField") as TextBox).Text;
     password = (inputFrame.FindName("PasswordField") as PasswordBox).Password;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化 <see cref="NavigationHelper"/> 類別的新執行個體。
        /// </summary>
        /// <param name="page">巡覽所使用之目前頁面的參考。 
        /// 這項參考允許進行框架操作及確保鍵盤
        /// 巡覽要求只有在頁面佔用整個視窗時才會發生。</param>
        public NavigationHelper(Page page)
        {
            this.Page = page;

            // 當這個頁面是視覺化樹狀結構的一部分時,執行兩項變更: 
            // 1) 將應用程式檢視狀態對應到頁面的視覺狀態
            // 2) 處理鍵盤和滑鼠巡覽要求
            this.Page.Loaded += (sender, e) =>
            {
                // 只有佔用整個視窗時才適用鍵盤和滑鼠巡覽
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width)
                {
                    // 直接接聽視窗,所以不需要焦點
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
            };

            // 當頁面不再可見時,復原相同的變更
            this.Page.Unloaded += (sender, e) =>
            {
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
            };
        }
Exemplo n.º 5
0
 public NavigatingEventArgs(DeferralManager manager, NavigatingCancelEventArgs e, Page page, object parameter) : this(manager)
 {
     NavigationMode = e.NavigationMode;
     PageType = e.SourcePageType;
     Page = page;
     Parameter = parameter;
 }
Exemplo n.º 6
0
 static public void Restore(Page inputFrame)
 {
     // Set authentication fields.
     (inputFrame.FindName("ServiceAddressField") as TextBox).Text = baseUri;
     (inputFrame.FindName("UserNameField") as TextBox).Text = user;
     (inputFrame.FindName("PasswordField") as PasswordBox).Password = password;
 }
Exemplo n.º 7
0
        public async Task<AppHubViewModel> Start(Page page)
        {
            this.Page = page;
            UpgradeLicense = await new InAppPurchaseHelper("HideAds").Setup();

            LoadData_Runtime();
            this.PropertyChanged += async (s, e) =>
            {
                if (e.PropertyName.Equals("Selected") && this.Selected != null)
                {
                    if (this.Selected is AdvertRecord)
                        await new Windows.UI.Popups.MessageDialog("Advertisement!").ShowAsync();
                    else
                        Services.Navigation.GotoDetail(this.Selected.Id);
                    this.Selected = null;
                }
            };

            UpgradeLicense.LicenseChanged += async (s, e) =>
            {
                if (UpgradeLicense.IsPurchased)
                {
                    await page.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                     {
                         // remove advertisements (if any)
                         foreach (var parent in Groups4Landscape.Union(Groups4Portrait.Union(Groups4Snapview)).Where(x => x.Children.Any(y => y is AdvertRecord)))
                         {
                             foreach (var advert in parent.Children.Where(x => x is AdvertRecord).ToArray())
                                 parent.Children.Remove(advert);
                         }
                     });
                }
            };
            return this;
        }
Exemplo n.º 8
0
        /// <summary>
        /// <see cref="NavigationHelper"/> 클래스의 새 인스턴스를 초기화합니다.
        /// </summary>
        /// <param name="page">탐색에 사용되는 현재 페이지에 대한 참조입니다.  
        ///  이 참조는 프레임 조작을 가능하게 하고 키보드 
        /// 탐색 요청이 페이지가 전체 창을 차지했을 경우에만 발생하도록 합니다.</param>
        public NavigationHelper(Page page)
        {
            this.Page = page;

            // 이 페이지가 시각적 트리의 일부인 경우 두 가지를 변경합니다.:
            // 1) 응용 프로그램 뷰 상태를 페이지의 시각적 상태에 매핑
            // 2) 키보드 및 마우스 탐색 요청 처리
            this.Page.Loaded += (sender, e) =>
            {
                // 키보드 및 마우스 탐색은 전체 창 크기인 경우에만 적용됩니다.
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width)
                {
                    // 포커스가 필요하지 않도록 창을 직접 수신합니다.
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
            };

            // 페이지가 더 이상 표시되지 않는 경우 동일한 변경을 취소합니다.
            this.Page.Unloaded += (sender, e) =>
            {
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
            };
        }
        /// <summary>
        /// Will hide application bar if current page reference is passged
        /// If you don't want that, pass null
        /// </summary>
        /// <param name="valueofoverlay"></param>
        /// <param name="basePage"></param>
        public void Show(string valueofoverlay, Page basePage)
        {
            if (basePage != null)
            {
                _basePage = basePage;
                if (_basePage != null && _basePage.BottomAppBar != null)
                    _basePage.BottomAppBar.IsOpen = false;
            }
            this.textBlockStatus.Text = valueofoverlay;
            if (this.ChildWindowPopup == null)
            {
                this.ChildWindowPopup = new Popup();

                try
                {
                    this.ChildWindowPopup.Child = this;
                }
                catch (ArgumentException)
                {
                    throw new InvalidOperationException("The control is already shown.");
                }
            }

            if (this.ChildWindowPopup != null)
            {
                // Show popup
                this.ChildWindowPopup.IsOpen = true;
            }
        }
Exemplo n.º 10
0
        public NavigationHelper(Page page)
        {
            if (page == null) throw new ArgumentNullException(nameof(page));

            mPage = page;
            mPage.Loaded += (sender, e) =>
            {
            #if WINDOWS_PHONE_APP
                HardwareButtons.BackPressed += OnHardwareButtonBackPressed;
            #else
                if (mPage.ActualHeight == Window.Current.Bounds.Height && mPage.ActualWidth == Window.Current.Bounds.Width)
                {
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += OnAcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed += OnPointerPressed;
                }
            #endif
            };

            mPage.Unloaded += (sender, e) =>
            {
            #if WINDOWS_PHONE_APP
                HardwareButtons.BackPressed -= OnHardwareButtonBackPressed;
            #else
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= OnAcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -= OnPointerPressed;
            #endif
            };
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initialise une nouvelle instance de la classe <see cref="NavigationHelper"/>.
        /// </summary>
        /// <param name="page">Référence à la page active utilisée pour la navigation.  
        /// Cette référence permet de manipuler le frame et de garantir que le clavier 
        /// les requêtes de navigation ont lieu uniquement lorsque la page occupe toute la fenêtre.</param>
        public NavigationHelper(Page page)
        {
            this.Page = page;

            // Lorsque cette page fait partie de l'arborescence d'éléments visuels, effectue deux modifications :
            // 1) Mappe l'état d'affichage de l'application à l'état visuel pour la page
            // 2) Traite les requêtes de navigation à l'aide du clavier ou de la souris
            this.Page.Loaded += (sender, e) =>
            {
                // La navigation à l'aide du clavier et de la souris s'applique uniquement lorsque la totalité de la fenêtre est occupée
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width)
                {
                    // Écoute directement la fenêtre, ce qui ne requiert pas le focus
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
            };

            // Annule les mêmes modifications lorsque la page n'est plus visible
            this.Page.Unloaded += (sender, e) =>
            {
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
            };
        }
Exemplo n.º 12
0
        public static void InitializeSkiInputService(this Page _)
        {
            var window = CoreWindow.GetForCurrentThread();

            SkiInputService.Instance.CalculateNumberOfMousePointersFunc = () =>
                                                                          PointerDevice
                                                                          .GetPointerDevices()
                                                                          .Count(pointer => pointer.PointerDeviceType == PointerDeviceType.Mouse);

            SkiInputService.Instance.IsInputViewFocusedFunc = () => FocusManager.GetFocusedElement() is TextBox;

            window.Dispatcher.AcceleratorKeyActivated += (sender, args) =>
            {
                var intKey        = (int)args.VirtualKey;
                var skiVirtualKey = (SkiVirtualKey)intKey;
                var keyState      = window.GetKeyState(args.VirtualKey);

                if (keyState.HasFlag(CoreVirtualKeyStates.Down))
                {
                    SkiInputService.Instance.OnKeyDown(skiVirtualKey);
                }
                else
                {
                    SkiInputService.Instance.OnKeyUp(skiVirtualKey);
                }
            };
        }
Exemplo n.º 13
0
 public NavigatedEventArgs(NavigationEventArgs e, Page page)
 {
     this.Page = page;
     this.PageType = e.SourcePageType;
     this.Parameter = e.Parameter;
     this.NavigationMode = e.NavigationMode;
 }
Exemplo n.º 14
0
        public async void CriarAba(Page page, string titulo)
        {
            try
            {
                var aba = new AbaDado
                {
                    titulo = titulo,
                    pagina = page,
                };

               

                listaAbas.Add(aba);
                abasListView.SelectedItem = aba;

               

                TotalAbas = listaAbas.Count;

            }
            catch (Exception ex)
            {
                MessageDialog dialog = new MessageDialog(
                    "Dificuldade ao criar aba\n\nERRO:" + ex.Message, "Dificuldade");
                await dialog.ShowAsync();
            }
        }
Exemplo n.º 15
0
        internal Platform(Windows.UI.Xaml.Controls.Page page)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            _page = page;

            _container = new Canvas
            {
                Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["RootContainerStyle"]
            };

            _page.Content = _container;

            _container.SizeChanged += OnRendererSizeChanged;

            MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) =>
            {
                Windows.UI.Xaml.Controls.ProgressBar indicator = GetBusyIndicator();
                indicator.Visibility = enabled ? Visibility.Visible : Visibility.Collapsed;
            });

            _toolbarTracker.CollectionChanged += OnToolbarItemsChanged;

            UpdateBounds();

            InitializeStatusBar();

            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
        }
        /// <summary>
        /// Инициализирует новый экземпляр класса <see cref="NavigationHelper"/>.
        /// </summary>
        /// <param name="page">Ссылка на текущую страницу, используемая для навигации.  
        /// Эта ссылка позволяет осуществлять различные действия с кадрами и гарантировать, что клавиатура 
        /// запросы навигации происходят, только когда страница занимает все окно.</param>
        public NavigationHelper(Page page)
        {
            this.Page = page;

            // Если данная страница является частью визуального дерева, возникают два изменения:
            // 1) Сопоставление состояния просмотра приложения с визуальным состоянием для страницы.
            // 2) Обработка запросов навигации с помощью мыши и клавиатуры.
            this.Page.Loaded += (sender, e) =>
            {
                // Навигация с помощью мыши и клавиатуры применяется, только если страница занимает все окно
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width)
                {
                    // Непосредственное прослушивание окна, поэтому фокус не требуется
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
            };

            // Отмена тех же изменений, когда страница перестает быть видимой
            this.Page.Unloaded += (sender, e) =>
            {
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
            };
        }
        public NavigationHelper(Page page)
        {
            this.Page = page;

            this.Page.Loaded += (sender, e) => {
            #if WINDOWS_PHONE_APP
                Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
            #else
                // Keyboard and mouse navigation only apply when occupying the entire window
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width) {
                    // Listen to the window directly so focus isn't required
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
            #endif
            };

            this.Page.Unloaded += (sender, e) => {
            #if WINDOWS_PHONE_APP
                Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
            #else
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
            #endif
            };
        }
Exemplo n.º 18
0
        /// <summary>
        /// <see cref="NavigationHelper"/> クラスの新しいインスタンスを初期化します。
        /// </summary>
        /// <param name="page">ナビゲーションに使用される現在のページへの参照。
        /// この参照ではフレームの操作が許可され、ページでウィンドウ全体を使用している場合にのみ
        /// キーボードのナビゲーション要求が発生するようにすることができます。</param>
        public NavigationHelper(Page page)
        {
            this.Page = page;

            // このページがビジュアル ツリーの一部である場合、次の 2 つの変更を行います:
            // 1) アプリケーションのビューステートをページの表示状態にマップする
            // 2) キーボードおよびマウスのナビゲーション要求を処理する
            this.Page.Loaded += (sender, e) =>
            {
                // キーボードおよびマウスのナビゲーションは、ウィンドウ全体を使用する場合のみ適用されます
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width)
                {
                    // ウィンドウで直接待機するため、フォーカスは不要です
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
            };

            // ページが表示されない場合、同じ変更を元に戻します
            this.Page.Unloaded += (sender, e) =>
            {
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
            };
        }
Exemplo n.º 19
0
 public NavigatingEventArgs(NavigatingCancelEventArgs e, Page page)
 {
     this.Page = page;
     this.NavigationMode = e.NavigationMode;
     this.PageType = e.SourcePageType;
     this.Parameter = e.Parameter?.ToString();
 }
Exemplo n.º 20
0
 public NavigatingEventArgs(NavigatingCancelEventArgs e, Page page)
 {
     NavigationMode = e.NavigationMode;
     PageType = e.SourcePageType;
     Parameter = e.Parameter;
     Page = page;
 }
Exemplo n.º 21
0
        internal Platform(Windows.UI.Xaml.Controls.Page page)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            _page = page;

            _container = new Canvas
            {
                Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["RootContainerStyle"]
            };

            _page.Content = _container;

            _container.SizeChanged += OnRendererSizeChanged;

            MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) =>
            {
                Windows.UI.Xaml.Controls.ProgressBar indicator = GetBusyIndicator();
                indicator.Visibility = enabled ? Visibility.Visible : Visibility.Collapsed;
            });

            _toolbarTracker.CollectionChanged += OnToolbarItemsChanged;

#if !WINDOWS_UWP // UWP gets subscribed in Forms.Init
            SubscribeAlertsAndActionSheets();
#endif
            UpdateBounds();

#if WINDOWS_UWP
            InitializeStatusBar();
#endif
        }
Exemplo n.º 22
0
        public async Task NavedFromAsync(object viewmodel, NavigationMode mode, Page sourcePage, Type sourceType, object sourceParameter, Page targetPage, Type targetType, object targetParameter, bool suspending)
        {
            Services.NavigationService.NavigationService.DebugWrite();

            if (sourcePage == null)
            {
                return;
            }
            else if (viewmodel == null)
            {
                return;
            }
            else if (viewmodel is Classic.INavigatedAwareAsync)
            {
                var vm = viewmodel as Classic.INavigatedAwareAsync;
                await vm?.OnNavigatedFromAsync(PageState(sourcePage), suspending);
            }
            else if (viewmodel is Portable.INavigatedAware)
            {
                var vm = viewmodel as Portable.INavigatedAware;
                var parameters = new Portable.NavigationParameters();
                vm?.OnNavigatedFrom(parameters);
            }
            else if (viewmodel is Portable.INavigatedAwareAsync)
            {
                var vm = viewmodel as Portable.INavigatedAwareAsync;
                var parameters = new Portable.NavigationParameters();
                await vm?.OnNavigatedFromAsync(parameters);
            }
        }
    /// <summary>
    ///   Initializes a new instance of the <see cref="NavigationHelper"/> class.
    /// </summary>
    /// <param name="page">
    ///   A reference to the current page used for navigation.
    ///   This reference allows for frame manipulation and to ensure that keyboard
    ///   navigation requests only occur when the page is occupying the entire window.
    /// </param>
    public NavigationHelper(Page page) {
      Page = page;

      // When this page is part of the visual tree make two changes:
      // 1) Map application view state to visual state for the page
      // 2) Handle keyboard and mouse navigation requests
      Page.Loaded += (sender, e) => {
        // Keyboard and mouse navigation only apply when occupying the entire window
        if (Page.ActualHeight == Window.Current.Bounds.Height &&
            Page.ActualWidth == Window.Current.Bounds.Width) {
          // Listen to the window directly so focus isn't required
          Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
            CoreDispatcher_AcceleratorKeyActivated;
          Window.Current.CoreWindow.PointerPressed +=
            CoreWindow_PointerPressed;
        }
      };

      // Undo the same changes when the page is no longer visible
      Page.Unloaded += (sender, e) => {
        Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
          CoreDispatcher_AcceleratorKeyActivated;
        Window.Current.CoreWindow.PointerPressed -=
          CoreWindow_PointerPressed;
      };
    }
        private void Authenticate(Xamarin.Auth._MobileServices.Helpers.OAuth1 oauth1)
        {
            OAuth1Authenticator auth = new OAuth1Authenticator
                                       (
                consumerKey: oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                consumerSecret: oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret,
                requestTokenUrl: oauth1.OAuth1_UriRequestToken,
                authorizeUrl: oauth1.OAuth_UriAuthorization,
                accessTokenUrl: oauth1.OAuth_UriAccessToken_UriRequestToken,
                callbackUrl: oauth1.OAuth_UriCallbackAKARedirect
                                       );

            auth.AllowCancel = oauth1.AllowCancel;

            // If authorization succeeds or is canceled, .Completed will be fired.
            auth.Completed         += Auth_Completed;
            auth.Error             += Auth_Error;
            auth.BrowsingCompleted += Auth_BrowsingCompleted;

            //Uri uri = auth.GetUI();
            Type page_type = auth.GetUI();

            // For Xamarin.Forms refactoring
            Windows.UI.Xaml.Controls.Page this_page = this;
            this_page.Frame.Navigate(page_type, auth);

            return;
        }
Exemplo n.º 25
0
        public void SetPage(Page page)
        {
            NavigationService.Current.NavigationModel.Push(page, null);
            SetCurrentPage(page);
            page.NavigationProxy.Inner = NavigationService.Current;

        }
Exemplo n.º 26
0
        /// <summary>
        /// <see cref="NavigationHelper"/> クラスの新しいインスタンスを初期化します。
        /// </summary>
        /// <param name="page">ナビゲーションに使用される現在のページへの参照。
        /// この参照ではフレームの操作が許可され、ページでウィンドウ全体を使用している場合にのみ
        /// キーボードのナビゲーション要求が発生するようにすることができます。</param>
        public NavigationHelper(Page page) {
            this.Page = page;

            // このページがビジュアル ツリーの一部である場合、次の 2 つの変更を行います:
            // 1) アプリケーションのビューステートをページの表示状態にマップする
            // 2) ハードウェアのナビゲーション要求を処理する
            this.Page.Loaded += (sender, e) => {
#if WINDOWS_PHONE_APP
                Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
#else
                // キーボードおよびマウスのナビゲーションは、ウィンドウ全体を使用する場合のみ適用されます
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width) {
                    // ウィンドウで直接待機するため、フォーカスは不要です
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
#endif
            };

            // ページが表示されない場合、同じ変更を元に戻します
            this.Page.Unloaded += (sender, e) => {
#if WINDOWS_PHONE_APP
                Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
#else
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
#endif
            };
        }
 /// <summary>
 /// Возобновление.
 /// </summary>
 /// <param name="sender">Страница.</param>
 /// <param name="o">Объект.</param>
 protected async override void OnResume(Page sender, object o)
 {
     if (StatusBarHelper.IsStatusBarPresent)
     {
         await StatusBarHelper.StatusBar.ProgressIndicator.HideAsync();
     }
 }
Exemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationHelper"/> class.
        /// </summary>
        /// <param name="page">A reference to the current page used for navigation.  
        /// This reference allows for frame manipulation and to ensure that keyboard 
        /// navigation requests only occur when the page is occupying the entire window.</param>
        public NavigationHelper(Page page) {
            this.Page = page;

            // When this page is part of the visual tree make two changes:
            // 1) Map application view state to visual state for the page
            // 2) Handle hardware navigation requests
            this.Page.Loaded += (sender, e) => {
#if WINDOWS_PHONE_APP
                Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
#else
                // Keyboard and mouse navigation only apply when occupying the entire window
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width) {
                    // Listen to the window directly so focus isn't required
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
#endif
            };

            // Undo the same changes when the page is no longer visible
            this.Page.Unloaded += (sender, e) => {
#if WINDOWS_PHONE_APP
                Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
#else
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
#endif
            };
        }
 /// <summary>
 /// Произошёл заход на страницу.
 /// </summary>
 /// <param name="sender">Страница.</param>
 /// <param name="e">Событие.</param>
 protected override async void OnNavigatedTo(Page sender, NavigationEventArgs e)
 {
     if (StatusBarHelper.IsStatusBarPresent)
     {
         await StatusBarHelper.StatusBar.ProgressIndicator.HideAsync();
     }
 }
Exemplo n.º 30
0
		public TabSelectedEventArgs(Page tab)
		{
			if (tab == null)
				throw new ArgumentNullException("tab");

			Tab = tab;
		}
Exemplo n.º 31
0
        /// <summary>Call this method in Loaded event as the event will be automatically 
        /// deregistered when the FrameworkElement has been unloaded. </summary>
        public static void RegisterBackKey(Page page)
        {
            var callback = new TypedEventHandler<CoreDispatcher, AcceleratorKeyEventArgs>(
                delegate(CoreDispatcher sender, AcceleratorKeyEventArgs args)
                {
                    if (!args.Handled && args.VirtualKey == VirtualKey.Back &&
                        (args.EventType == CoreAcceleratorKeyEventType.KeyDown || 
                            args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown))
                    {
                        var element = FocusManager.GetFocusedElement();
                        if (element is FrameworkElement && PopupHelper.IsInPopup((FrameworkElement)element))
                            return;

                        if (element is TextBox || element is PasswordBox || element is WebView)
                            return; 

                        if (page.Frame.CanGoBack)
                        {
                            args.Handled = true;
                            page.Frame.GoBack();
                        }
                    }
                });

            page.Dispatcher.AcceleratorKeyActivated += callback;

            SingleEvent.RegisterEvent(page,
                (p, h) => p.Unloaded += h,
                (p, h) => p.Unloaded -= h,
                (o, a) => { page.Dispatcher.AcceleratorKeyActivated -= callback; });
        }
        /// <summary>
        /// 初始化 <see cref="NavigationHelper"/> 类的新实例。
        /// </summary>
        /// <param name="page">对当前页面的引用,用于导航。 
        /// 此引用可操纵帧,并确保
        /// 仅在页面占用整个窗口时产生导航请求。</param>
        public NavigationHelper(Page page)
        {
            this.Page = page;

            // 当此页是可视化树的一部分时,进行两个更改: 
            // 1) 将应用程序视图状态映射到页的可视状态
            // 2) 处理键盘和鼠标导航请求
            this.Page.Loaded += (sender, e) =>
            {
                // 仅当占用整个窗口时,键盘和鼠标导航才适用
                if (this.Page.ActualHeight == Window.Current.Bounds.Height &&
                    this.Page.ActualWidth == Window.Current.Bounds.Width)
                {
                    // 直接侦听窗口,因此无需焦点
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        this.CoreWindow_PointerPressed;
                }
            };

            // 当页不再可见时,撤消相同更改
            this.Page.Unloaded += (sender, e) =>
            {
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
            };
        }
Exemplo n.º 33
0
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。
        /// 此参数通常用于配置页。</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Button btn = new Button();
            btn.Content = "Right";
            btn.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right;

            Page page = new Page();
        }
 private void _textBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     _page = _page ?? _textBox.Ancestor<Page>();
     var field = _page.GetType().GetTypeInfo().GetDeclaredField("Bindings");
     var bindings = field?.GetValue(_page);
     var update = bindings?.GetType().GetRuntimeMethod("Update", new Type[] { });
     //update?.Invoke(bindings, null);
 }
Exemplo n.º 35
0
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            var window    = Windows.UI.Xaml.Window.Current;
            var shellView = new Windows.UI.Xaml.Controls.Page();

            window.Content = shellView;

            window.Activate();
        }
Exemplo n.º 36
0
 public Platform(Windows.UI.Xaml.Controls.Page page)
 {
     _page                  = page;
     _renderer              = new Canvas();
     _renderer.SizeChanged += renderer_SizeChanged;
     NavigationService.Current.OnNewPage += Current_OnNewPage;
     _tracker = new ToolbarTracker();
     _tracker.CollectionChanged += (s, e) => UpdateAppBar();
 }
Exemplo n.º 37
0
        internal Platform(Windows.UI.Xaml.Controls.Page page)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            _page = page;

            _container = new Canvas {
                Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["RootContainerStyle"]
            };

            _page.Content = _container;

            _container.SizeChanged += OnRendererSizeChanged;

            MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) =>
            {
                Windows.UI.Xaml.Controls.ProgressBar indicator = GetBusyIndicator();
                indicator.Visibility = enabled ? Visibility.Visible : Visibility.Collapsed;
            });

            _toolbarTracker.CollectionChanged += OnToolbarItemsChanged;

            MessagingCenter.Subscribe <Page, AlertArguments>(this, Page.AlertSignalName, OnPageAlert);
            MessagingCenter.Subscribe <Page, ActionSheetArguments>(this, Page.ActionSheetSignalName, OnPageActionSheet);

            UpdateBounds();

#if WINDOWS_UWP
            StatusBar statusBar = MobileStatusBar;
            if (statusBar != null)
            {
                statusBar.Showing += (sender, args) => UpdateBounds();
                statusBar.Hiding  += (sender, args) => UpdateBounds();

                // UWP 14393 Bug: If RequestedTheme is Light (which it is by default), then the
                // status bar uses White Foreground with White Background.
                // UWP 10586 Bug: If RequestedTheme is Light (which it is by default), then the
                // status bar uses Black Foreground with Black Background.
                // Since the Light theme should have a Black on White status bar, we will set it explicitly.
                // This can be overriden by setting the status bar colors in App.xaml.cs OnLaunched.

                if (statusBar.BackgroundColor == null && statusBar.ForegroundColor == null && Windows.UI.Xaml.Application.Current.RequestedTheme == ApplicationTheme.Light)
                {
                    statusBar.BackgroundColor   = Colors.White;
                    statusBar.ForegroundColor   = Colors.Black;
                    statusBar.BackgroundOpacity = 1;
                }
            }
#endif
        }
Exemplo n.º 38
0
        internal Platform(Windows.UI.Xaml.Controls.Page page)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            _page = page;

            var current = Windows.UI.Xaml.Application.Current;

            if (!current.Resources.ContainsKey("RootContainerStyle"))
            {
                Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(Forms.GetTabletResources());
            }

#if UWP_16299
            if (!current.Resources.ContainsKey(ShellRenderer.ShellStyle))
            {
                var myResourceDictionary = new Windows.UI.Xaml.ResourceDictionary();
                myResourceDictionary.Source = new Uri("ms-appx:///Xamarin.Forms.Platform.UAP/Shell/ShellStyles.xbf");
                Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
            }
#endif

            _container = new Canvas
            {
                Style = (Windows.UI.Xaml.Style)current.Resources["RootContainerStyle"]
            };

            _page.Content = _container;

            _container.SizeChanged += OnRendererSizeChanged;

            MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) =>
            {
                Windows.UI.Xaml.Controls.ProgressBar indicator = GetBusyIndicator();
                indicator.Visibility = enabled ? Visibility.Visible : Visibility.Collapsed;
            });

            _toolbarTracker.CollectionChanged += OnToolbarItemsChanged;

            UpdateBounds();

            InitializeStatusBar();

            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
            Windows.UI.Xaml.Application.Current.Resuming += OnResumingAsync;
        }
        private void Authenticate(Xamarin.Auth._MobileServices.Helpers.OAuth2 oauth2)
        {
            OAuth2Authenticator auth = null;

            if (oauth2.OAuth_UriAccessToken_UriRequestToken == null || string.IsNullOrEmpty(oauth2.OAuth_SecretKey_ConsumerSecret_APISecret))
            {
                auth = new OAuth2Authenticator
                       (
                    clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                    scope: oauth2.OAuth2_Scope,
                    authorizeUrl: oauth2.OAuth_UriAuthorization,
                    redirectUrl: oauth2.OAuth_UriCallbackAKARedirect
                       );
            }
            else
            {
                auth = new OAuth2Authenticator
                       (
                    clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                    clientSecret: "93e7f486b09bd1af4c38913cfaacbf8a384a50d2",
                    scope: oauth2.OAuth2_Scope,
                    authorizeUrl: oauth2.OAuth_UriAuthorization,
                    redirectUrl: oauth2.OAuth_UriCallbackAKARedirect,
                    accessTokenUrl: oauth2.OAuth_UriAccessToken_UriRequestToken
                       );
            }

            auth.AllowCancel = oauth2.AllowCancel;

            // If authorization succeeds or is canceled, .Completed will be fired.
            auth.Completed         += Auth_Completed;
            auth.Error             += Auth_Error;
            auth.BrowsingCompleted += Auth_BrowsingCompleted;

            //Uri uri = auth.GetUI();
            Type page_type = auth.GetUI();

            // For Xamarin.Forms refactoring
            Windows.UI.Xaml.Controls.Page this_page = this;
            this_page.Frame.Navigate(page_type, auth);

            return;
        }
Exemplo n.º 40
0
        internal Platform(Windows.UI.Xaml.Controls.Page page)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            _page = page;

            _container = new Canvas {
                Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["RootContainerStyle"]
            };

            _page.Content = _container;

            _container.SizeChanged += OnRendererSizeChanged;

            MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) =>
            {
                Windows.UI.Xaml.Controls.ProgressBar indicator = GetBusyIndicator();
                indicator.Visibility = enabled ? Visibility.Visible : Visibility.Collapsed;
            });

            _toolbarTracker.CollectionChanged += OnToolbarItemsChanged;

            MessagingCenter.Subscribe <Page, AlertArguments>(this, Page.AlertSignalName, OnPageAlert);
            MessagingCenter.Subscribe <Page, ActionSheetArguments>(this, Page.ActionSheetSignalName, OnPageActionSheet);

            UpdateBounds();


#if WINDOWS_UWP
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                StatusBar statusBar = StatusBar.GetForCurrentView();
                statusBar.Showing += (sender, args) => UpdateBounds();
                statusBar.Hiding  += (sender, args) => UpdateBounds();
            }
#endif
        }
Exemplo n.º 41
0
        internal void UnfocusControl(Control control)
        {
            if (control == null || !control.IsEnabled || !control.IsTabStop)
            {
                return;
            }

            // "Unfocusing" doesn't really make sense on Windows; for accessibility reasons,
            // something always has focus. So forcing the unfocusing of a control would normally
            // just move focus to the next control, or leave it on the current control if no other
            // focus targets are available. This is what happens if you use the "disable/enable"
            // hack. What we *can* do is set the focus to the Page which contains Control;
            // this will cause Control to lose focus without shifting focus to, say, the next Entry

            if (_containingPage == null)
            {
                // Work our way up the tree to find the containing Page
                DependencyObject parent = Control as Control;
                while (parent != null && !(parent is Windows.UI.Xaml.Controls.Page))
                {
                    parent = VisualTreeHelper.GetParent(parent);
                }
                _containingPage = parent as Windows.UI.Xaml.Controls.Page;
            }

            if (_containingPage != null)
            {
                // Cache the tabstop setting
                var wasTabStop = _containingPage.IsTabStop;

                // Controls can only get focus if they're a tabstop
                _containingPage.IsTabStop = true;
                _containingPage.Focus(FocusState.Programmatic);

                // Restore the tabstop setting; that may cause the Page to lose focus,
                // but it won't restore the focus to Control
                _containingPage.IsTabStop = wasTabStop;
            }
        }
Exemplo n.º 42
0
 private void ShellFrame_Navigated(object sender, NavigationEventArgs e)
 {
     this.CurrentPage = e.Content as Windows.UI.Xaml.Controls.Page;
 }
Exemplo n.º 43
0
        private void SetupUserInterface()
        {
            IsChangesMade = false;
            mPdfViewCtrl  = new PDFViewCtrl();
            string path = Path.Combine(Windows.Storage.ApplicationData.Current.TemporaryFolder.Path, "sample.pdf");
            PDFDoc doc  = new PDFDoc(path);

            mPdfViewCtrl.SetDoc(doc);
            mPdfViewCtrl.SetPagePresentationMode(pdftron.PDF.PDFViewCtrlPagePresentationMode.e_single_page);

            mToolManager = new pdftron.PDF.Tools.ToolManager(mPdfViewCtrl);
            mToolManager.EnablePopupMenuOnLongPress = true;
            mToolManager.IsPopupMenuEnabled         = true;
            mToolManager.PanToolTextSelectionMode   = pdftron.PDF.Tools.ToolManager.TextSelectionBehaviour.AlwaysPan;
            mToolManager.TextMarkupAdobeHack        = true;

            mToolManager.AnnotationAdded           += MToolManager_AnnotationAdded;
            mToolManager.AnnotationEdited          += MToolManager_AnnotationEdited;
            mToolManager.AnnotationGroupAdded      += MToolManager_AnnotationGroupAdded;
            mToolManager.AnnotationGroupEdited     += MToolManager_AnnotationGroupEdited;
            mToolManager.AnnotationGroupPreEdited  += MToolManager_AnnotationGroupPreEdited;
            mToolManager.AnnotationGroupPreRemoved += MToolManager_AnnotationGroupPreRemoved;
            mToolManager.AnnotationGroupRemoved    += MToolManager_AnnotationGroupRemoved;
            mToolManager.AnnotationPreRemoved      += MToolManager_AnnotationPreRemoved;
            mToolManager.AnnotationRemoved         += MToolManager_AnnotationRemoved;

            mAnnotationToolbar = new pdftron.PDF.Tools.Controls.AnnotationCommandBar(mToolManager);

            var stackPanel           = new StackPanel();
            var horizontalStackPanel = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            closeButton = new Button()
            {
                Content = "Close"
            };

            resavePageButton = new Button()
            {
                Content = "Resave first page"
            };

            addNewPageButton = new Button()
            {
                Content = "New Page"
            };

            horizontalStackPanel.Children.Add(closeButton);
            horizontalStackPanel.Children.Add(resavePageButton);
            horizontalStackPanel.Children.Add(addNewPageButton);

            stackPanel.Children.Add(horizontalStackPanel);
            stackPanel.Children.Add(mAnnotationToolbar);
            stackPanel.Children.Add(mPdfViewCtrl);
            closeButton.Click      += CloseButton_Click;
            resavePageButton.Click += resavePageButton_Click;
            addNewPageButton.Click += AddNewPageButton_Click;

            page         = new Windows.UI.Xaml.Controls.Page();
            page.Content = stackPanel;
        }