public BackButtonManager(Frame frame)
 {
     _frame = frame;
     _navigationManager = SystemNavigationManager.GetForCurrentView();
     _navigationManager.AppViewBackButtonVisibility = frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
     _navigationManager.BackRequested += OnBackRequested;
 }
Esempio n. 2
0
        public NavigationService(Frame frame, ISettingsUtility settingsUtility, IInsightsService insightsService)
        {
            _settingsUtility = settingsUtility;
            _insightsService = insightsService;
            _frame = new NavigationFacade(frame);
            _frame.Navigating += (s, e) => NavigatedFrom(false);

            _currentView = SystemNavigationManager.GetForCurrentView();
        }
        public MainPage()
        {
            InitializeComponent();

            // Use required cache mode so we create only one page
            NavigationCacheMode = Navigation.NavigationCacheMode.Required;
            // Get current view that provides access to the back button
            _currentView = SystemNavigationManager.GetForCurrentView();
            _currentView.BackRequested += OnFrameNavigationRequested;

            HideStatusBar();
            
            Initialize();
        }
        public NavigationService()
        {
            _pages = new Dictionary<PageKey, Type>
            {
                {PageKey.SplashScreenPage, typeof(ExtendedSplashScreen)},
                {PageKey.MainPage, typeof(MainPage)},
                {PageKey.SessionDetailsPage, typeof(SessionDetailsView)},
                {PageKey.VideoCollectionsPage, typeof(VideoCollectionsPage)},
                {PageKey.VideoCollectionDetailsPage, typeof(VideoCollectionDetailsPage)},
                {PageKey.PlayerPage, typeof(PlayerView)}
            };

            SetFrame((Frame)Window.Current.Content);

            _systemNavManager = SystemNavigationManager.GetForCurrentView();
            _systemNavManager.BackRequested += SystemNavManager_BackRequested;
        }
        public void RegisterShellFrame(Frame shellFrame)
        {
            if (shellFrame == null)
                return;

            this.ShellFrame = shellFrame;
            this.shellSystemNavigationManager = SystemNavigationManager.GetForCurrentView();

            // Register root navigation to handle back button
            this.ShellFrame.Navigated += (s, e) =>
                this.shellSystemNavigationManager.AppViewBackButtonVisibility =
                    this.ShellFrame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;

            this.RootFrame.NavigationFailed += OnNavigationFailed;

            this.shellSystemNavigationManager.BackRequested += OnBackRequestedFromShellFrame;
        }
Esempio n. 6
0
 /// <summary>
 /// Updates the current state of the back button
 /// </summary>
 private void UpdateBackButton()
 {
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = CanGoBack() ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
 }
Esempio n. 7
0
 /// <summary>
 /// Action qui se passe lorsqu'on change de page.
 /// </summary>
 /// <param name="e"></param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
     SystemNavigationManager.GetForCurrentView().BackRequested += Courbes_BackRequested;
 }
Esempio n. 8
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     SystemNavigationManager.GetForCurrentView().BackRequested -= OnBackRequested;
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
         AppViewBackButtonVisibility.Disabled;
 }
Esempio n. 9
0
        public MainPage(object Parameter)
        {
            InitializeComponent();
            ThisPage = this;
            Window.Current.SetTitleBar(TitleBar);
            Application.Current.FocusVisualKind = FocusVisualKind.Reveal;
            Loaded += MainPage_Loaded;
            Loaded += MainPage_Loaded1;
            Window.Current.Activated += MainPage_Activated;
            Application.Current.EnteredBackground += Current_EnteredBackground;
            Application.Current.LeavingBackground += Current_LeavingBackground;
            SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += MainPage_CloseRequested;
            SystemNavigationManager.GetForCurrentView().BackRequested         += MainPage_BackRequested;

            BackgroundController.Current.SetAcrylicEffectPresenter(CompositorAcrylicBackground);

            if (Package.Current.IsDevelopmentMode)
            {
                AppName.Text += " (Development Mode)";
            }

            FullTrustProcessController.Current.AuthorityModeChanged += async(s, e) =>
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    if (FullTrustProcessController.Current.RuningInAdministratorMode)
                    {
                        AppName.Text += $" ({Globalization.GetString("RunningInAdminModeTip")})";
                    }
                });
            };

            if (Parameter is Tuple <Rect, string> RSParamter)
            {
                string[] Paras = RSParamter.Item2.Split("||");

                switch (Paras[0])
                {
                case "PathActivate":
                {
                    IsPathActivate = true;
                    ActivatePath   = Paras[1];
                    break;
                }
                }

                if (WindowsVersionChecker.IsNewerOrEqual(WindowsVersionChecker.Version.Windows10_1903) && !AnimationController.Current.IsDisableStartupAnimation && !IsPathActivate)
                {
                    EntranceEffectProvider = new EntranceAnimationEffect(this, Nav, RSParamter.Item1);
                    EntranceEffectProvider.PrepareEntranceEffect();
                }
            }
            else if (Parameter is Rect RectParameter)
            {
                if (WindowsVersionChecker.IsNewerOrEqual(WindowsVersionChecker.Version.Windows10_1903) && !AnimationController.Current.IsDisableStartupAnimation && !IsPathActivate)
                {
                    EntranceEffectProvider = new EntranceAnimationEffect(this, Nav, RectParameter);
                    EntranceEffectProvider.PrepareEntranceEffect();
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Initializes a new instance of the AppShell, sets the static 'Current' reference,
        /// adds callbacks for Back requests and changes in the SplitView's DisplayMode, and
        /// provide the nav menu list with the data to display.
        /// </summary>
        public AppShell()
        {
            this.InitializeComponent();

            NavigationCacheMode = NavigationCacheMode.Enabled;

            this.Loaded += (sender, args) =>
            {
                Current = this;

                this.CheckTogglePaneButtonSizeChanged();

                var titleBar = Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().TitleBar;
                titleBar.IsVisibleChanged += TitleBar_IsVisibleChanged;
            };

            this.RootSplitView.RegisterPropertyChangedCallback(
                SplitView.DisplayModeProperty,
                (s, a) =>
            {
                // Ensure that we update the reported size of the TogglePaneButton when the SplitView's
                // DisplayMode changes.
                this.CheckTogglePaneButtonSizeChanged();
            });

            SystemNavigationManager.GetForCurrentView().BackRequested += SystemNavigationManager_BackRequested;
            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;

            System.Threading.Tasks.Task.Factory.StartNew(async() =>
            {
                await AppFrame.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    var categories = await(await ApiHelper.GetApi()).GetCategoriesAsync();

                    if (categories != null)
                    {
                        categories.ForEach(category =>
                        {
                            navlist.Add(new NavMenuItem()
                            {
                                Label     = category.Title,
                                Arguments = category,
                                DestPage  = typeof(RecentPost),
                            });
                        });
                    }

                    for (var i = 0; i < navlist.Count; i++)
                    {
                        var navItem = navlist[i];
                        if (i == 0)
                        {
                            navItem.IsSelected = true;
                        }
                        else
                        {
                            navItem.IsSelected = false;
                        }
                    }
                    NavMenuList.ItemsSource = navlist;

                    this.AppFrame.Navigate(typeof(RecentPost), categories[0], new SuppressNavigationTransitionInfo());
                });
            });
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
     LocalUserVM.Sync();
 }
Esempio n. 12
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            Logger.Info("App activated");

            // Window management
            if (!(Window.Current.Content is Frame rootFrame))
            {
                rootFrame = new Frame();
                Window.Current.Content = rootFrame;
            }

            var currentView = SystemNavigationManager.GetForCurrentView();

            switch (args.Kind)
            {
            case ActivationKind.Protocol:
                var eventArgs = args as ProtocolActivatedEventArgs;

                if (eventArgs.Uri.AbsoluteUri == "files-uwp:")
                {
                    rootFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo());
                }
                else
                {
                    var trimmedPath = eventArgs.Uri.OriginalString.Split('=')[1];
                    rootFrame.Navigate(typeof(InstanceTabsView), @trimmedPath, new SuppressNavigationTransitionInfo());
                }

                // Ensure the current window is active.
                Window.Current.Activate();
                Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;
                currentView.BackRequested += Window_BackRequested;
                return;

            case ActivationKind.CommandLineLaunch:
                var cmdLineArgs    = args as CommandLineActivatedEventArgs;
                var operation      = cmdLineArgs.Operation;
                var cmdLineString  = operation.Arguments;
                var activationPath = operation.CurrentDirectoryPath;

                var parsedCommands = CommandLineParser.ParseUntrustedCommands(cmdLineString);

                if (parsedCommands != null && parsedCommands.Count > 0)
                {
                    foreach (var command in parsedCommands)
                    {
                        switch (command.Type)
                        {
                        case ParsedCommandType.OpenDirectory:
                            rootFrame.Navigate(typeof(InstanceTabsView), command.Payload, new SuppressNavigationTransitionInfo());

                            // Ensure the current window is active.
                            Window.Current.Activate();
                            Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;
                            currentView.BackRequested += Window_BackRequested;
                            return;

                        case ParsedCommandType.OpenPath:

                            try
                            {
                                var det = await StorageFolder.GetFolderFromPathAsync(command.Payload);

                                rootFrame.Navigate(typeof(InstanceTabsView), command.Payload, new SuppressNavigationTransitionInfo());

                                // Ensure the current window is active.
                                Window.Current.Activate();
                                Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;
                                currentView.BackRequested += Window_BackRequested;

                                return;
                            }
                            catch (System.IO.FileNotFoundException ex)
                            {
                                //Not a folder
                                Debug.WriteLine($"File not found exception App.xaml.cs\\OnActivated with message: {ex.Message}");
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine($"Exception in App.xaml.cs\\OnActivated with message: {ex.Message}");
                            }

                            break;

                        case ParsedCommandType.Unknown:
                            rootFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo());
                            // Ensure the current window is active.
                            Window.Current.Activate();
                            Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;
                            currentView.BackRequested += Window_BackRequested;
                            return;
                        }
                    }
                }
                break;
            }

            rootFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo());

            // Ensure the current window is active.
            Window.Current.Activate();
            Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;
        }
Esempio n. 13
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var currentView = SystemNavigationManager.GetForCurrentView();

            currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            currentView.BackRequested += CurrentView_BackRequested;

            param = (string)e.Parameter;

            if (param == "all")
            {
                this.txtPageName.Text = "All Size Types";
            }
            else if (param == "number")
            {
                this.txtPageName.Text = "Number";
            }
            else if (param == "letter")
            {
                this.txtPageName.Text = "Letter";
            }
            else if (param == "metric")
            {
                this.txtPageName.Text = "Metric";
            }
            else if (param == "fractional")
            {
                this.txtPageName.Text = "Fractional Inch";
            }
            else if (param == "named")
            {
                this.txtPageName.Text = "Number / Letter";
            }
            else
            {
                this.txtPageName.Text = "Drills";
            };

            Grid      g         = grid;
            Grid      gh        = gridHdr;
            int       gridIndex = 0;
            Border    b         = null;
            TextBlock tb        = null;

            SolidColorBrush blackBrush     = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0x00, 0x00));
            SolidColorBrush whiteBrush     = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff));
            SolidColorBrush lightGrayBrush = new SolidColorBrush(Color.FromArgb(0xff, 0xc0, 0xc0, 0xc0));
            SolidColorBrush greenBrush     = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0x80, 0x00));
            SolidColorBrush blueBrush      = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0x00, 0xff));


            SolidColorBrush GhostWhite = new SolidColorBrush(Color.FromArgb(0xff, 0xf0, 0xf0, 0xff));

            gh.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(20, GridUnitType.Pixel)
            });

            ColumnDefinition leftMargin = new ColumnDefinition();

            leftMargin.Width = new GridLength(20, GridUnitType.Pixel);
            g.ColumnDefinitions.Add(leftMargin);
            ColumnDefinition col1 = new ColumnDefinition();

            col1.Width = new GridLength(150, GridUnitType.Pixel);
            g.ColumnDefinitions.Add(col1);
            ColumnDefinition col2 = new ColumnDefinition();

            col2.Width = new GridLength(150, GridUnitType.Pixel);
            g.ColumnDefinitions.Add(col2);
            ColumnDefinition col3 = new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star), MinWidth = 500
            };

            col3.Width = new GridLength(100, GridUnitType.Star);
            g.ColumnDefinitions.Add(col3);

            //g.ShowGridLines = false;

            ColumnDefinition leftMarginHdr = new ColumnDefinition();

            leftMarginHdr.Width = new GridLength(20, GridUnitType.Pixel);
            gh.ColumnDefinitions.Add(leftMarginHdr);
            ColumnDefinition col1Hdr = new ColumnDefinition();

            col1Hdr.Width = new GridLength(150, GridUnitType.Pixel);
            gh.ColumnDefinitions.Add(col1Hdr);
            ColumnDefinition col2Hdr = new ColumnDefinition();

            col2Hdr.Width = new GridLength(150, GridUnitType.Pixel);
            gh.ColumnDefinitions.Add(col2Hdr);
            ColumnDefinition col3Hdr = new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star), MinWidth = 500
            };

            col3Hdr.Width = new GridLength(1, GridUnitType.Star);
            gh.ColumnDefinitions.Add(col3Hdr);

            //gh.Height = new GridLength(40, GridUnitType.Pixel);
            //DFS gh.MinHeight = 40.0;
            //gh.ShowGridLines = false;

            string typeName = "Size";

            DrillChartList baselist = new DrillChartList();

            //baselist.GetBaseList();

            List <DrillChartRow> list = null;

            if (param == "all")
            {
                list     = (from p in baselist select p).ToList();
                typeName = "Size";
            }
            else if (param == "number")
            {
                list     = (from p in baselist where p.rowtype == "std4" select p).ToList();
                typeName = "Number";
            }
            else if (param == "letter")
            {
                list     = (from p in baselist where p.rowtype == "std3" select p).ToList();
                typeName = "Letter";
            }
            else if (param == "metric")
            {
                list     = (from p in baselist where p.rowtype == "std2" select p).ToList();
                typeName = "Metric";
            }
            else if (param == "fractional")
            {
                list     = (from p in baselist where p.rowtype == "std1" select p).ToList();
                typeName = "Fractional (in)";
            }
            else if (param == "named")
            {
                list     = (from p in baselist where (p.rowtype == "std3") || (p.rowtype == "std4") select p).ToList();
                typeName = "Name";
            }
            ;


            b             = new Border();
            b.Background  = lightGrayBrush;
            tb            = new TextBlock();
            tb.Text       = "";
            tb.Foreground = blackBrush;
            Grid.SetColumn(b, 0);
            Grid.SetRow(b, 0);
            b.Child = tb;
            gh.Children.Add(b);

            b             = new Border();
            b.Background  = lightGrayBrush;
            tb            = new TextBlock();
            tb.Text       = typeName;
            tb.Foreground = blackBrush;
            Grid.SetColumn(b, 1);
            Grid.SetRow(b, 0);
            b.Child = tb;
            gh.Children.Add(b);

            b             = new Border();
            b.Background  = lightGrayBrush;
            tb            = new TextBlock();
            tb.Text       = "Decimal (in)";
            tb.Foreground = blackBrush;
            Grid.SetColumn(b, 2);
            Grid.SetRow(b, 0);
            b.Child = tb;
            gh.Children.Add(b);

            b             = new Border();
            b.Background  = lightGrayBrush;
            tb            = new TextBlock();
            tb.Text       = "Metric (mm)";
            tb.Foreground = blackBrush;
            Grid.SetColumn(b, 3);
            Grid.SetRow(b, 0);
            b.Child = tb;
            gh.Children.Add(b);


            for (int i = 0; (i < list.Count); i++)
            {
                Brush fg = blackBrush;
                Brush bg = whiteBrush;

                if ((i % 2) != 0)
                {
                    bg = GhostWhite;
                }

                g.RowDefinitions.Add(new RowDefinition());

                if (list[i].rowtype.Equals("std1") && (param == "all"))
                {
                    fg = blueBrush;
                }

                else if (list[i].rowtype.Equals("std4") && (param == "all"))
                {
                    fg = greenBrush;
                }

                else
                {
                    fg = blackBrush;
                }

                b             = new Border();
                b.BorderBrush = bg;
                b.Background  = bg;
                tb            = new TextBlock();
                tb.Text       = "";
                tb.Foreground = fg;
                Grid.SetColumn(tb, 0);
                Grid.SetRow(b, gridIndex);
                b.Child = tb;
                grid.Children.Add(b);

                b             = new Border();
                b.BorderBrush = bg;
                b.Background  = bg;
                tb            = new TextBlock();
                tb.Text       = list[i].size;
                tb.Foreground = fg;
                //tb.Background = bg;
                Grid.SetColumn(b, 1);
                Grid.SetRow(b, gridIndex);
                b.Child = tb;
                grid.Children.Add(b);

                b             = new Border();
                b.BorderBrush = bg;
                b.Background  = bg;
                tb            = new TextBlock();
                tb.Text       = list[i].inches;
                tb.Foreground = fg;
                //tb.Background = bg;
                Grid.SetColumn(b, 2);
                Grid.SetRow(b, gridIndex);
                b.Child = tb;
                grid.Children.Add(b);

                b             = new Border();
                b.BorderBrush = bg;
                b.Background  = bg;
                tb            = new TextBlock();
                tb.Text       = list[i].millimeters;
                tb.Foreground = fg;
                Grid.SetColumn(b, 3);
                Grid.SetRow(b, gridIndex);
                b.Child = tb;
                grid.Children.Add(b);

                gridIndex++;
            }
        }
Esempio n. 14
0
 protected BaseView()
 {
     SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
 }
 public MainSettingsPage()
 {
     this.InitializeComponent();
     SystemNavigationManager.GetForCurrentView().BackRequested += onBackBtnClick;
 }
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     SystemNavigationManager.GetForCurrentView().BackRequested -= onBackBtnClick;
 }
 public MvxWindowsViewPresenter(IMvxWindowsFrame rootFrame)
 {
     _rootFrame = rootFrame;
     SystemNavigationManager.GetForCurrentView().BackRequested += BackButtonOnBackRequested;
 }
 protected virtual void HandleBackButtonVisibility()
 {
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
         _rootFrame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
 }
 public SystemNavigationManagerEvents(SystemNavigationManager This)
 {
     this.This = This;
 }
        /// <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;
                if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
                {
                    Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s, a) =>
                    {
                        if (Frame.CanGoBack)
                        {
                            Frame.GoBack();
                            a.Handled = true;
                        }
                    };
                }
#else
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility    = AppViewBackButtonVisibility.Visible;
                Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s, a) =>
                {
                    if (Frame.CanGoBack)
                    {
                        Frame.GoBack();
                        a.Handled = true;
                    }
                };

                // 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;
                if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
                {
                    Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s, a) =>
                    {
                        if (Frame.CanGoBack)
                        {
                            Frame.GoBack();
                            a.Handled = false;
                        }
                    };
                }
#else
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility    = AppViewBackButtonVisibility.Collapsed;
                Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s, a) =>
                {
                    if (Frame.CanGoBack)
                    {
                        Frame.GoBack();
                        a.Handled = false;
                    }
                };

                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -=
                    CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -=
                    this.CoreWindow_PointerPressed;
#endif
            };
        }
Esempio n. 21
0
 public void RightFrameNavi(Action <Frame> action)
 {
     action(RightFrame);
     RightFrameContentChange?.Invoke(this, true);
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
 }
 public MyProfilePage()
 {
     InitializeComponent();
     SystemNavigationManager.GetForCurrentView().BackRequested += MyProfilePage_BackRequested;
 }
Esempio n. 23
0
        private void NewsListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            NewsList newsItem = new NewsList(((NewsList)e.ClickedItem).ID, ((NewsList)e.ClickedItem).Articleid, ((NewsList)e.ClickedItem).Title, ((NewsList)e.ClickedItem).Head, ((NewsList)e.ClickedItem).Date, ((NewsList)e.ClickedItem).Read, ((NewsList)e.ClickedItem).Content == null ? "加载中..." : ((NewsList)e.ClickedItem).Content, ((NewsList)e.ClickedItem).Content_all == null ? "加载中..." : ((NewsList)e.ClickedItem).Content_all);

            Debug.WriteLine("NewsListgrid.Width" + NewsListgrid.Width);
            if (NewsListgrid.Width == 400)
            {
                //JWBackAppBarButton.Visibility = Visibility.Collapsed;
                SystemNavigationManager.GetForCurrentView().BackRequested -= App_BackRequested;
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
                NewsRefreshAppBarButton.Visibility = Visibility.Visible;
            }
            else
            {
                //JWBackAppBarButton.Visibility = Visibility.Visible;
                SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                NewsRefreshAppBarButton.Visibility = Visibility.Collapsed;
            }
            NewsFrame.Visibility = Visibility.Visible;
            if (((NewsList)e.ClickedItem).Content_all != "")
            {
                JObject newsContentobj = JObject.Parse(((NewsList)e.ClickedItem).Content_all);
                if (Int32.Parse(newsContentobj["state"].ToString()) == 200)
                {
                    JArray AnnexListArray = Utils.ReadJso(newsContentobj["data"].ToString(), "annex");
                    if (AnnexListArray != null)
                    {
                        ObservableCollection <NewsContentList.Annex> annexList = new ObservableCollection <NewsContentList.Annex>();
                        for (int i = 0; i < AnnexListArray.Count; i++)
                        {
                            NewsContentList.Annex annex = new NewsContentList.Annex();
                            annex.GetAttribute((JObject)AnnexListArray[i]);
                            if (annex.name != "")
                            {
                                Uri Anneximg;
                                if (annex.name.IndexOf(".zip") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_zip.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".rar") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_rar.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".pdf") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_pdf.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".doc") != -1 || annex.name.IndexOf(".docx") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_doc.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".xls") != -1 || annex.name.IndexOf(".xlsx") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_xls.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".ppt") != -1 || annex.name.IndexOf(".pptx") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_ppt.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".jpg") != -1 || annex.name.IndexOf(".png") != -1 || annex.name.IndexOf(".gif") != -1 || annex.name.IndexOf(".bmp") != -1 || annex.name.IndexOf(".jpeg") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_image.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".mp4") != -1 || annex.name.IndexOf(".rmvb") != -1 || annex.name.IndexOf(".avi") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_video.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".mp3") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_music.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".apk") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_apk.png", UriKind.Absolute);
                                }
                                else
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_other.png", UriKind.Absolute);
                                }

                                annexList.Add(new NewsContentList.Annex {
                                    name = annex.name, address = annex.address, Anneximg = Anneximg
                                });
                                DownloadAppBarButton.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                DownloadAppBarButton.Visibility = Visibility.Collapsed;
                                break;
                            }
                        }
                        AnnexListView.ItemsSource = annexList;
                    }
                    else
                    {
                        DownloadAppBarButton.Visibility = Visibility.Collapsed;
                    }
                }
            }
            this.NewsFrame.Navigate(typeof(NewsContentPage), newsItem);
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            string launchString = e.Arguments;

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;
                rootFrame.Navigated        += OnNavigated;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;

                // Register a handler for BackRequested events and set the
                // visibility of the Back button
                SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
            }

            var    localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            Object token         = localSettings.Values["token"];

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                //


                if (token == null)
                {
                    rootFrame.Navigate(typeof(Login), e.Arguments);
                }
                else
                {
                    if (String.IsNullOrEmpty(launchString))
                    {
                        rootFrame.Navigate(typeof(MainPage), e.Arguments);
                    }

                    else
                    {
                        rootFrame.Navigate(typeof(QuotationDetails), launchString);
                        rootFrame.BackStack.Add(new PageStackEntry(typeof(MainPage), null, null));
                        // SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                    }
                }
            }
            else
            {
                if (token != null && !String.IsNullOrEmpty(launchString))
                {
                    rootFrame.Navigate(typeof(QuotationDetails), launchString);
                    // rootFrame.BackStack.Add(new PageStackEntry(typeof(MainPage), null, null));
                    // SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                }
            }


            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                rootFrame.CanGoBack ?
                AppViewBackButtonVisibility.Visible :
                AppViewBackButtonVisibility.Collapsed;

            // Ensure the current window is active
            Window.Current.Activate();
        }
Esempio n. 25
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            // How did the app exit the last time it was run (if at all)
            ApplicationExecutionState previousState = e.PreviousExecutionState;

            // What kind of launch is this?
            ActivationKind activationKind = e.Kind;

            //..

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Set the frame navigation state that was serialized as a string when we suspended
                    if (ApplicationData.Current.LocalSettings.Values.ContainsKey("NavigationState"))
                    {
                        rootFrame.SetNavigationState((string)ApplicationData.Current.LocalSettings.Values["NavigationState"]);
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();

            Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;

            // Every time the Frame navigates, set the visibility of the Shell-drawn back button
            // appropriate to whether there is anywhere to go back to
            // COMMENT this out to see the on-canvas smart Back Button on desktop
            rootFrame.Navigated += (s, a) =>
            {
                if (rootFrame.CanGoBack)
                {
                    // Setting this visible is ignored on Mobile and when in tablet mode! 
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                }
                else
                {
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
                }
            };
        }
Esempio n. 26
0
        public FirstView()
        {
            InitializeComponent();

            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
        }
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     base.OnNavigatedFrom(e);
     SystemNavigationManager.GetForCurrentView().BackRequested -= OnHardwareBackRequested;
 }
Esempio n. 28
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
 }
Esempio n. 29
0
 private void UpdateBackButtonVisibility()
 {
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = ViewModel.NavigateBackCommand.CanExecute(null)
         ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
 }
Esempio n. 30
0
 private NavigationService()
 {
     windows = new Dictionary <int, CoreApplicationView>();
     SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequest;
 }
Esempio n. 31
0
 private void UpdateBackButton()
 {
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = SelectionStates.CurrentState == SelectedNarrowState
 ? AppViewBackButtonVisibility.Visible
 : AppViewBackButtonVisibility.Collapsed;
 }
Esempio n. 32
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            await logWriter.InitializeAsync("debug.log");

            Logger.Info("App activated");

            await EnsureSettingsAndConfigurationAreBootstrapped();

            // Window management
            if (!(Window.Current.Content is Frame rootFrame))
            {
                rootFrame              = new Frame();
                rootFrame.CacheSize    = 1;
                Window.Current.Content = rootFrame;
            }

            var currentView = SystemNavigationManager.GetForCurrentView();

            switch (args.Kind)
            {
            case ActivationKind.Protocol:
                var eventArgs = args as ProtocolActivatedEventArgs;

                if (eventArgs.Uri.AbsoluteUri == "files-uwp:")
                {
                    rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo());
                }
                else
                {
                    var parsedArgs     = eventArgs.Uri.Query.TrimStart('?').Split('=');
                    var unescapedValue = Uri.UnescapeDataString(parsedArgs[1]);
                    switch (parsedArgs[0])
                    {
                    case "tab":
                        rootFrame.Navigate(typeof(MainPage), TabItemArguments.Deserialize(unescapedValue), new SuppressNavigationTransitionInfo());
                        break;

                    case "folder":
                        rootFrame.Navigate(typeof(MainPage), unescapedValue, new SuppressNavigationTransitionInfo());
                        break;
                    }
                }

                // Ensure the current window is active.
                Window.Current.Activate();
                Window.Current.CoreWindow.Activated += CoreWindow_Activated;
                return;

            case ActivationKind.CommandLineLaunch:
                var cmdLineArgs    = args as CommandLineActivatedEventArgs;
                var operation      = cmdLineArgs.Operation;
                var cmdLineString  = operation.Arguments;
                var activationPath = operation.CurrentDirectoryPath;

                var parsedCommands = CommandLineParser.ParseUntrustedCommands(cmdLineString);

                if (parsedCommands != null && parsedCommands.Count > 0)
                {
                    foreach (var command in parsedCommands)
                    {
                        switch (command.Type)
                        {
                        case ParsedCommandType.OpenDirectory:
                            rootFrame.Navigate(typeof(MainPage), command.Payload, new SuppressNavigationTransitionInfo());

                            // Ensure the current window is active.
                            Window.Current.Activate();
                            Window.Current.CoreWindow.Activated += CoreWindow_Activated;
                            return;

                        case ParsedCommandType.OpenPath:

                            try
                            {
                                var det = await StorageFolder.GetFolderFromPathAsync(command.Payload);

                                rootFrame.Navigate(typeof(MainPage), command.Payload, new SuppressNavigationTransitionInfo());

                                // Ensure the current window is active.
                                Window.Current.Activate();
                                Window.Current.CoreWindow.Activated += CoreWindow_Activated;

                                return;
                            }
                            catch (System.IO.FileNotFoundException ex)
                            {
                                //Not a folder
                                Debug.WriteLine($"File not found exception App.xaml.cs\\OnActivated with message: {ex.Message}");
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine($"Exception in App.xaml.cs\\OnActivated with message: {ex.Message}");
                            }

                            break;

                        case ParsedCommandType.Unknown:
                            if (command.Payload.Equals("."))
                            {
                                rootFrame.Navigate(typeof(MainPage), activationPath, new SuppressNavigationTransitionInfo());
                            }
                            else
                            {
                                var target = Path.GetFullPath(Path.Combine(activationPath, command.Payload));
                                if (!string.IsNullOrEmpty(command.Payload))
                                {
                                    rootFrame.Navigate(typeof(MainPage), target, new SuppressNavigationTransitionInfo());
                                }
                                else
                                {
                                    rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo());
                                }
                            }

                            // Ensure the current window is active.
                            Window.Current.Activate();
                            Window.Current.CoreWindow.Activated += CoreWindow_Activated;

                            return;
                        }
                    }
                }
                break;

            case ActivationKind.ToastNotification:
                var eventArgsForNotification = args as ToastNotificationActivatedEventArgs;
                if (eventArgsForNotification.Argument == "report")
                {
                    // Launch the URI and open log files location
                    //SettingsViewModel.OpenLogLocation();
                    SettingsViewModel.ReportIssueOnGitHub();
                }
                break;
            }

            rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo());

            // Ensure the current window is active.
            Window.Current.Activate();
            Window.Current.CoreWindow.Activated += CoreWindow_Activated;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RootNavigationHelper"/> class.
        /// </summary>
        /// <param name="rootFrame">A reference to the top-level frame.
        /// This reference allows for frame manipulation and to register navigation handlers.</param>
        public RootFrameNavigationHelper(Frame rootFrame)
        {
            this.Frame = rootFrame;

            // Handle keyboard and mouse navigation requests
            this.systemNavigationManager = SystemNavigationManager.GetForCurrentView();
            systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested;
            UpdateBackButton();

            // Listen to the window directly so we will respond to hotkeys regardless
            // of which element has focus.
            Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                CoreDispatcher_AcceleratorKeyActivated;
            Window.Current.CoreWindow.PointerPressed +=
                this.CoreWindow_PointerPressed;

            // Update the Back button whenever a navigation occurs.
            this.Frame.Navigated += (s, e) => UpdateBackButton();
        }
Esempio n. 34
0
 private void Frame_Navigated(object sender, NavigationEventArgs e)
 {
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = NavigationService.CanGoBack ?
                                                                               AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
 }
		void OnLoaded(object sender, RoutedEventArgs args)
		{
			if (Element == null)
				return;

#if WINDOWS_UWP
			_navManager = SystemNavigationManager.GetForCurrentView();
#endif
			Element.SendAppearing();
			UpdateBackButton();
			UpdateTitleOnParents();
		}
Esempio n. 36
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            SystemNavigationManager.GetForCurrentView().BackRequested += SystemNavigationManagerBackRequested;

            UpdateBackButton();
        }
Esempio n. 37
0
        protected override void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var frameState = SuspensionManager.SessionStateForFrame(this.Frame);
            this._pageKey = "Page-" + this.Frame.BackStackDepth;

            if (e.NavigationMode == NavigationMode.New)
            {
                // Clear existing state for forward navigation when adding a new page to the
                // navigation stack
                var nextPageKey = this._pageKey;
                int nextPageIndex = this.Frame.BackStackDepth;
                while (frameState.Remove(nextPageKey))
                {
                    nextPageIndex++;
                    nextPageKey = "Page-" + nextPageIndex;
                }

                // Pass the navigation parameter to the new page
                if (this.LoadState != null)
                {
                    this.LoadState(this, new LoadStateEventArgs(e.Parameter, null));
                }
            }
            else
            {
                // Pass the navigation parameter and preserved page state to the page, using
                // the same strategy for loading suspended state and recreating pages discarded
                // from cache
                if (this.LoadState != null)
                {
                    this.LoadState(this, new LoadStateEventArgs(e.Parameter, (Dictionary<String, Object>)frameState[this._pageKey]));
                }
            }

            currentView = SystemNavigationManager.GetForCurrentView();

            if (!ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                currentView.AppViewBackButtonVisibility = this.Frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
            }

            currentView.BackRequested += SystemNavigationManager_BackRequested;
        }
Esempio n. 38
0
        private void SetupNavigation()
        {
            this.AppFrame.Navigated += OnNavigated;

            _navigationManager = SystemNavigationManager.GetForCurrentView();
            _navigationManager.BackRequested += OnBackRequested;
        }
Esempio n. 39
0
 private void OnUnloaded(object sender, RoutedEventArgs e)
 {
     SystemNavigationManager.GetForCurrentView().BackRequested -= SystemNavigationManagerBackRequested;
 }
Esempio n. 40
0
 private static SystemNavigationManager GetSystemNavigationManager()
 {
     return(SystemNavigationManager.GetForCurrentView());
 }
        private void MasterDetailViewControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.Unloaded += MasterDetailViewControl_Unloaded;

            this.DataContextChanged += MasterDetailViewControl_DataContextChanged;

            navigationManager = SystemNavigationManager.GetForCurrentView();
            //navigationManager.BackRequested += NavigationManager_BackRequested;

            Window.Current.SizeChanged += Current_SizeChanged;

            EvaluateLayout();
        }