public void Dispose()
 {
     DeregisterPageDataContextEvents();
     DeregisterPageEvents();
     DeregisterFrameEvents();
     PageDataContext = null;
     Page = null;
     Frame = null;
 }
 public HamburgerBarPageEntryViewModel(ApplicationFrame frame, Type pageType, string title, FontFamily iconFontFamily, double iconFontSize, string icon)
 {
     Frame = frame;
     PageType = pageType;
     Title = title;
     Icon = icon;
     IconFontFamily = iconFontFamily;
     IconFontSize = iconFontSize;
     Frame.Navigated += Frame_Navigated;
     NavigateCommand = new RelayCommand(TryNavigate);
 }
Пример #3
0
 public OuterFrame(ApplicationFrame frame)
 {
     this.InitializeComponent();
     MainSplitView.Content = frame;
     VM = new OuterFrameViewModel((App)App.Current, frame);
     this.DataContext = VM;
     //VM.PropertyChanged += (s, e) =>
     //{
     //    if (e.PropertyName == "PageDataContext")
     //    {
     //        TitleBarContentPresenter.DataContext = VM.PageDataContext;
     //    }
     //};
     //<ContentTemplate="{Binding TitleControlsTemplate}" TemplateDataContext="{Binding PageDataContext}" Width="{Binding TitleControlsActualWidth}" Visibility="{Binding TitleControlsVisibility}" x:Name="TitleBarContentPresenter"/>
     //TitleBarContentPresenter.SetBinding(ContentPresenter.ContentTemplateProperty, new Binding() { Source = VM, Path = new PropertyPath("TitleControlsTemplate"), Mode = BindingMode.OneWay });
     //TitleBarContentPresenter.DataContext = VM.PageDataContext;
     //TitleBarContentPresenter.SetBinding(ContentPresenter.DataContextProperty, new Binding() { Source = VM, Path = new PropertyPath("PageDataContext"), Mode = BindingMode.OneWay });
     //TitleBarContentPresenter.SetBinding(WidthProperty, new Binding() { Source = VM, Path = new PropertyPath("TitleControlsActualWidth"), Mode = BindingMode.OneWay });
     //TitleBarContentPresenter.SetBinding(VisibilityProperty, new Binding() { Source = VM, Path = new PropertyPath("TitleControlsVisibility"), Mode = BindingMode.OneWay });
 }
        public OuterFrameViewModel(App currentApp, ApplicationFrame frame)
        {
            CurrentApp = currentApp;
            GoBackCommand = new RelayCommand(obj => GoBack(), obj => Frame.CanGoBack || (Page != null && Page.CanGoBack));
            ToggleMenuCommand = new RelayCommand(obj => IsMenuOpen = !IsMenuOpen);
            NavigateBackCommand = new RelayCommand(obj => Frame.GoBack(), obj => Frame.CanGoBack);
            NavigateForwardCommand = new RelayCommand(obj => Frame.GoForward(), obj => Frame.CanGoForward);
            Frame = frame;
            RegisterFrameEvents();
            RefreshPage();
            RefreshWindowWidth();

            Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
            var titleBar = Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().TitleBar;
            titleBar.LayoutMetricsChanged += TitleBar_LayoutMetricsChanged;
            RightControlsInset = titleBar.SystemOverlayRightInset;
            CurrentApp.ContentWidthChanged += CurrentApp_ContentSizeChanged;
            //RefreshTitleElementSizes();

            PageEntries.Add(new HamburgerBarPageEntryViewModel(Frame, typeof(TransitMapPage), "Map", new FontFamily("Segoe UI Symbol"), 20, ""));
        }
Пример #5
0
        private async void StartApp(string args, ApplicationExecutionState previousState)
        {
            MainOuterFrame = Window.Current.Content as _1_1.Views.OuterFrame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (MainOuterFrame == null)
            {
                RootFrame = new ApplicationFrame();
                RootFrame.NavigationFailed += OnNavigationFailed;

                MainOuterFrame = new _1_1.Views.OuterFrame(RootFrame);
                Window.Current.Content = MainOuterFrame;// MainHamburgerBar;
                MainOuterFrame.SizeChanged += (s, e) =>
                {
                    CurrentWidth = e.NewSize.Width;
                    ContentWidthChanged?.Invoke(s, e);
                };
                await Initialize();
                // Create a Frame to act as the navigation context and navigate to the first page
                Common.SuspensionManager.RegisterFrame(RootFrame, "appFrame");

                // Place the frame in the current Window
                //MainHamburgerBar.Content = RootFrame;
                //MainHamburgerBar.SetRootFrame(RootFrame);
                if (previousState == ApplicationExecutionState.Terminated)
                {
                    await Common.SuspensionManager.RestoreAsync();
                }
            }

            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 (BandwidthManager.EffectiveBandwidthOptions == BandwidthOptions.Low)
                //{
                //    switch (SettingsManager.GetSetting<int>("LimitedData.LaunchPage", false, 0))
                //    {
                //        case 0:
                //            RootFrame.Navigate(typeof(BusMapPage), "CurrentLocation");
                //            break;
                //        case 1:
                //            RootFrame.Navigate(typeof(FavoritesPage));
                //            break;
                //        case 2:
                //            RootFrame.Navigate(typeof(RoutesPage));
                //            break;
                //    }
                //}
                //else
                //{
                //    switch (SettingsManager.GetSetting<int>("LaunchPage", false, 0))
                //    {
                //        case 0:
                //            RootFrame.Navigate(typeof(BusMapPage), "CurrentLocation");
                //            break;
                //        case 1:
                //            RootFrame.Navigate(typeof(FavoritesPage));
                //            break;
                //        case 2:
                //            RootFrame.Navigate(typeof(RoutesPage));
                //            break;
                //    }
                //}

                //Test Page
                //RootFrame.Navigate(typeof(_1_1.Views.Pages.TransitMapPage));
                RootFrame.Navigate(typeof(_1_1.Views.Pages.TestPage1));
            }
            Window.Current.Activate();

            Message.ShowMessage(new Message() { ShortSummary = "Public transit data powered by OneBusAway.", Caption = "Welcome!", FullText = "This app uses data provided by the OneBusAway api. OneBusAway also provides its own app for this platform, and is available for free. This app builds on the functions of the official app, and provides additional functionality not available in OneBusAway's own app.", Id = 1 });
            //if (CurrentApp.LicenseInformation.IsTrial)
            //    MainHamburgerBar.ShowAds = true;

            //using (var db = FileManager.GetDatabase())
            //{
            //    db.CreateTable<BusTrip>();
            //    db.Insert(new BusTrip() { Destination = "Federal Way", Route = "187", Shape = "Square" });
            //}
        }