Example #1
0
        public NavigationRootPage()
        {
            this.InitializeComponent();

            _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl);

            SetDeviceFamily();
            AddNavigationMenuItems();
            Current   = this;
            RootFrame = rootFrame;

            this.GotFocus += (object sender, RoutedEventArgs e) =>
            {
                // helpful for debugging focus problems w/ keyboard & gamepad
                if (FocusManager.GetFocusedElement() is FrameworkElement focus)
                {
                    Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")");
                }
            };

            Gamepad.GamepadAdded   += OnGamepadAdded;
            Gamepad.GamepadRemoved += OnGamepadRemoved;

            Window.Current.SetTitleBar(AppTitleBar);

            CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(s);

            _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent);
        }
Example #2
0
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            try
            {
                // Install the VCD.
                StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"ConferenceRoomCommands.xml");

                await Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);
            }
            catch (Exception ex)
            {
                //If you are not seeing your VCD in your personal Cortana-powered apps list, check to see if
                //there is an error.
                Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString());
            }

            if (rootFrame == null)
            {
                rootFrame                 = new Frame();
                App.NavigationService     = new NavigationService(rootFrame);
                rootFrameNavigationHelper = new RootFrameNavigationHelper(rootFrame);

                rootFrame.NavigationFailed += OnNavigationFailed;
                Window.Current.Content      = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(View.RaleighDemo), "");
            }

            Window.Current.Activate();
        }
Example #3
0
 public MainPage()
 {
     this.InitializeComponent();
     _navHelper = new RootFrameNavigationHelper(ContentFrame);
     mainVM     = (MainViewModel)this.DataContext;
     mainVM.business.EventoPeliculaSeleccionada += Business_EventoPeliculaSeleccionada;
 }
Example #4
0
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
            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();
                App.NavigationService = new NavigationService(rootFrame);

                // Use the RootFrameNavigationHelper to respond to keyboard and mouse shortcuts.
                this.rootFrameNavigationHelper = new RootFrameNavigationHelper(rootFrame);

                rootFrame.NavigationFailed += OnNavigationFailed;

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

            if (rootFrame.Content == null)
            {
                // Determine if we're being activated normally, or with arguments from Cortana.
                if (string.IsNullOrEmpty(e.Arguments))
                {
                    // Launching normally.
                    rootFrame.Navigate(typeof(View.LightListView), "");
                }
                else
                {
                    // Launching with arguments. We assume, for now, that this is likely
                    // to be in the form of "room=<location>" from activation via Cortana.
                    rootFrame.Navigate(typeof(View.LightDetails), e.Arguments);
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();

            try
            {
                // Install the main VCD. Since there's no simple way to test that the VCD has been imported, or that it's your most recent
                // version, it's not unreasonable to do this upon app load.
                StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"ListenAppCommands.xml");

                await Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);

                // Update phrase list.
                ViewModel.ViewModelLocator locator = App.Current.Resources["ViewModelLocator"] as ViewModel.ViewModelLocator;

                if (locator != null)
                {
                    await locator.LightViewModel.UpdateRoomPhraseList();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString());
            }
        }
Example #5
0
 public MainPage()
 {
     this.InitializeComponent();
     navigationHelper      = new RootFrameNavigationHelper(RootFrame, NavigationViewControl);
     RootFrame.Navigating += RootFrame_Navigating;
     RootFrame.Navigated  += RootFrame_Navigated;
 }
 public NavigationRootPage()
 {
     this.InitializeComponent();
     this.rootFrameNavigationHelper = new RootFrameNavigationHelper(rootFrame);
     LoadGroups();
     Current   = this;
     RootFrame = rootFrame;
 }
Example #7
0
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                rootFrame         = new Frame();
                NavigationService = new NavigationService(rootFrame);

                // Singleton for Usersettings
                UserSettings = new UserSettings();

                rootFrameNavigationHelper   = new RootFrameNavigationHelper(rootFrame);
                rootFrame.NavigationFailed += OnNavigationFailed;

                SetUpIocContainers();
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                //Check if manual or Cortana activation
                if (string.IsNullOrEmpty(e.Arguments))
                {
                    // Launching normally
                    rootFrame.Navigate(typeof(MainPage), "");
                }
                else
                {
                    // Cortana launching
                    rootFrame.Navigate(typeof(SettingPage), e.Arguments);
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();

            try
            {
                // Load Vcd Storage File
                StorageFile vcd = await Package.Current.InstalledLocation.GetFileAsync(@"MirrorCommands.xml");

                // Install Voice commands from file
                await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcd);

                await UpdatePhraseList();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString());
            }
        }
Example #8
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 async void OnLaunched(LaunchActivatedEventArgs e)
        {
            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();
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                // Use the RootFrameNavigationHelper to respond to keyboard and mouse shortcuts.
                this.rootFrameNavigationHelper = new RootFrameNavigationHelper(rootFrame);

                rootFrame.NavigationFailed += OnNavigationFailed;

                // If this is not the first time the app is run, then restore from the previous session.
                StorageFile file;
                try
                {
                    file = await ApplicationData.Current.LocalFolder.GetFileAsync(sessionStateFilename);
                }
                catch (Exception)
                {
                    file = null;
                }

                if (file != null)
                {
                    //Load state from previously suspended application
                    await SuspensionManager.RestoreAsync();
                }

                // 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();
        }
Example #9
0
        public NavigationRootPage()
        {
            this.InitializeComponent();

            // Workaround for VisualState issue that should be fixed
            // by https://github.com/microsoft/microsoft-ui-xaml/pull/2271
            NavigationViewControl.PaneDisplayMode = muxc.NavigationViewPaneDisplayMode.Left;

            _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl);

            SetDeviceFamily();
            AddNavigationMenuItems();
            Current   = this;
            RootFrame = rootFrame;

            this.GotFocus += (object sender, RoutedEventArgs e) =>
            {
                // helpful for debugging focus problems w/ keyboard & gamepad
                if (FocusManager.GetFocusedElement() is FrameworkElement focus)
                {
                    Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")");
                }
            };

            Gamepad.GamepadAdded   += OnGamepadAdded;
            Gamepad.GamepadRemoved += OnGamepadRemoved;

            Window.Current.SetTitleBar(AppTitleBar);

            CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(s);

            _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent);


            // remove the solid-colored backgrounds behind the caption controls and system back button
            // This is done when the app is loaded since before that the actual theme that is used is not "determined" yet
            Loaded += delegate(object sender, RoutedEventArgs e)
            {
                ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
                titleBar.ButtonBackgroundColor         = Colors.Transparent;
                titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            };

            NavigationViewControl.RegisterPropertyChangedCallback(muxc.NavigationView.PaneDisplayModeProperty, new DependencyPropertyChangedCallback(OnPaneDisplayModeChanged));
        }
        public NavigationRootPage()
        {
            this.InitializeComponent();
            this.rootFrameNavigationHelper = new RootFrameNavigationHelper(rootFrame);
            LoadGroups();
            Current   = this;
            RootFrame = rootFrame;

            this.GotFocus += (object sender, RoutedEventArgs e) =>
            {
                // helpful for debugging focus problems w/ keyboard & gamepad
                FrameworkElement focus = FocusManager.GetFocusedElement() as FrameworkElement;
                if (focus != null)
                {
                    Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")");
                }
            };
        }
        public NavigationRootPage()
        {
            this.InitializeComponent();

            _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl);

            SetDeviceFamily();
            AddNavigationMenuItems();
            Current   = this;
            RootFrame = rootFrame;

            this.GotFocus += (object sender, RoutedEventArgs e) =>
            {
                // helpful for debugging focus problems w/ keyboard & gamepad
                if (FocusManager.GetFocusedElement() is FrameworkElement focus)
                {
                    Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")");
                }
            };

            this.Loaded += (s, e) =>
            {
                // This is to work around a bug in the NavigationView header that hard-codes the header content to a 48 pixel height.
                var headerContentControl = NavigationViewControl.GetDescendantsOfType <ContentControl>().Where(c => c.Name == "HeaderContent").FirstOrDefault();

                if (headerContentControl != null)
                {
                    headerContentControl.Height = double.NaN;
                }
            };

            Gamepad.GamepadAdded   += OnGamepadAdded;
            Gamepad.GamepadRemoved += OnGamepadRemoved;

            Window.Current.CoreWindow.SizeChanged += (s, e) => UpdateAppTitle();
            CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle();

            _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent);
        }
Example #12
0
        public NavigationRootPage()
        {
            this.InitializeComponent();

            _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl);

            SetDeviceFamily();
            AddNavigationMenuItems();
            Current   = this;
            RootFrame = rootFrame;

            this.GotFocus += (object sender, RoutedEventArgs e) =>
            {
                // helpful for debugging focus problems w/ keyboard & gamepad
                if (FocusManager.GetFocusedElement() is FrameworkElement focus)
                {
                    Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")");
                }
            };

            Gamepad.GamepadAdded   += OnGamepadAdded;
            Gamepad.GamepadRemoved += OnGamepadRemoved;

            //Window.Current.SetTitleBar(AppTitleBar);

            CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(s);

            _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent);


            // remove the solid-colored backgrounds behind the caption controls and system back button
            // This is done when the app is loaded since before that the actual theme that is used is not "determined" yet
            Loaded += delegate(object sender, RoutedEventArgs e)
            {
                ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
                titleBar.ButtonBackgroundColor         = Colors.Transparent;
                titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

                var  currentTheme = App.RootTheme.ToString();
                bool darkTheme    = false;

                switch (currentTheme)
                {
                case "Dark":
                    darkTheme = true;
                    break;

                case "Default":
                    if (Application.Current.RequestedTheme == ApplicationTheme.Dark)
                    {
                        darkTheme = true;
                    }
                    break;
                }
                if (darkTheme)
                {
                    titleBar.ButtonForegroundColor = Colors.White;
                }
                else
                {
                    titleBar.ButtonForegroundColor = Colors.Black;
                }
            };
        }