Ejemplo n.º 1
0
            private static void NavigateModeByShortcut(bool controlKeyPressed, bool shiftKeyPressed, bool altPressed
                                                       , Windows.System.VirtualKey key, ViewMode?toMode)
            {
                var lookupMap = GetCurrentKeyDictionary(controlKeyPressed, shiftKeyPressed, altPressed);

                if (lookupMap != null)
                {
                    var listItems = EqualRange(lookupMap, (MyVirtualKey)key);
                    foreach (var itemRef in listItems)
                    {
                        if (itemRef.Target is MUXC.NavigationView item)
                        {
                            var navView = item;

                            var menuItems = ((List <object>)navView.MenuItemsSource);
                            if (menuItems != null)
                            {
                                var vm = (navView.DataContext as ApplicationViewModel);
                                if (null != vm)
                                {
                                    ViewMode realToMode = toMode.HasValue ? toMode.Value : NavCategoryStates.GetViewModeForVirtualKey(((MyVirtualKey)key));

                                    var nvi = menuItems[NavCategoryStates.GetFlatIndex(realToMode)];
                                    if (CanNavigateModeByShortcut(navView, nvi, vm, realToMode))
                                    {
                                        vm.Mode = realToMode;
                                        navView.SelectedItem = nvi;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
Ejemplo n.º 2
0
        private async Task SetupJumpList()
        {
            try
            {
                var calculatorOptions = NavCategoryStates.CreateCalculatorCategoryGroup();

                var jumpList = await JumpList.LoadCurrentAsync();

                jumpList.SystemGroupKind = JumpListSystemGroupKind.None;
                jumpList.Items.Clear();

                foreach (NavCategory option in calculatorOptions.Categories)
                {
                    if (!NavCategoryStates.IsViewModeEnabled(option.ViewMode))
                    {
                        continue;
                    }
                    ViewMode mode = option.ViewMode;
                    var      item = JumpListItem.CreateWithArguments(((int)mode).ToString(), "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode));
                    item.Description = "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode);
                    item.Logo        = new Uri("ms-appx:///Assets/" + mode.ToString() + ".png");

                    jumpList.Items.Add(item);
                }

                await jumpList.SaveAsync();
            }
            catch
            {
            }
        }
Ejemplo n.º 3
0
 private static bool CanNavigateModeByShortcut(MUXC.NavigationView navView, object nvi
                                               , ApplicationViewModel vm, ViewMode toMode)
 {
     if (nvi != null && nvi is NavCategory navCategory)
     {
         return(navCategory.IsEnabled &&
                navView.Visibility == Visibility.Visible &&
                !vm.IsAlwaysOnTop &&
                NavCategoryStates.IsValidViewMode(toMode));
     }
     return(false);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user. Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            if (args.PrelaunchActivated)
            {
                // If the app got pre-launch activated, then save that state in a flag
                m_preLaunched = true;
            }
            NavCategoryStates.SetCurrentUser(args.User);

            // It takes time to check GraphingMode at the 1st time. So, do it in a background thread
            Task.Run(() => NavCategoryStates.IsViewModeEnabled(ViewMode.Graphing));

            OnAppLaunch(args, args.Arguments);
        }
Ejemplo n.º 5
0
        private void OnVisualStateChanged(object sender, Windows.UI.Xaml.VisualStateChangedEventArgs e)
        {
            var mode = NavCategoryStates.Deserialize(Model.CurrentCategory.GetModelCategoryId());

            TraceLogger.GetInstance().LogVisualStateChanged(mode, e.NewState.Name, false);
        }