void ITransformProvider.Resize(double width, double height)
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            UIElement owner = GetWrapper();

            if (owner == null)
            {
                throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
            }

            RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;

            if (menuItemOwner == null)
            {
                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
            }

            if (!((ITransformProvider)this).CanResize || width <= 0 || height <= 0)
            {
                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
            }

            if (!menuItemOwner.ResizePopupInternal(width, height))
            {
                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.ResizeParametersNotValid));
            }
        }
        ///
        void IExpandCollapseProvider.Collapse()
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            UIElement owner = GetWrapper();

            if (owner == null)
            {
                throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
            }

            RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;

            if (menuItemOwner != null)
            {
                MenuItemRole role = menuItemOwner.Role;

                if ((role != MenuItemRole.TopLevelHeader && role != MenuItemRole.SubmenuHeader) ||
                    !menuItemOwner.HasItems)
                {
                    throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
                }

                menuItemOwner.IsSubmenuOpen = false;
            }
            else
            {
                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
            }
        }
        private void RibbonSplitButton_DropDownOpened(object sender, EventArgs e)
        {
            if (GisEditor.ActiveMap != null)
            {
                editingLayerMenuItem.Visibility = (GisEditor.ActiveMap.FeatureLayerEditOverlay != null &&
                                                   GisEditor.ActiveMap.FeatureLayerEditOverlay.EditTargetLayer != null) ? Visibility.Visible : Visibility.Collapsed;

                foreach (var item in needToRemove)
                {
                    ribbonSplitButton.Items.Remove(item);
                }
                needToRemove.Clear();

                var visibleInMemoryLayers = GisEditor.ActiveMap.GetFeatureLayers(true).OfType <InMemoryFeatureLayer>().ToList();
                if (visibleInMemoryLayers.Count > 0)
                {
                    RibbonSeparator ribbonSeparator = new RibbonSeparator();
                    needToRemove.Add(ribbonSeparator);
                    ribbonSplitButton.Items.Add(ribbonSeparator);

                    foreach (var item in visibleInMemoryLayers)
                    {
                        RibbonMenuItem ribbonMenuItem = new RibbonMenuItem();
                        ribbonMenuItem.Header = item.Name;
                        ribbonMenuItem.Tag    = item;
                        ribbonMenuItem.Click += new RoutedEventHandler(CopyToExistingLayerRibbonMenuItem_Click);
                        ribbonSplitButton.Items.Add(ribbonMenuItem);
                        needToRemove.Add(ribbonMenuItem);
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Initializes the acquisition module.
        /// </summary>
        /// <param name="manager">The manager.</param>
        private void InitializeAcquireAcquisitionModule(ViewROIManager manager)
        {
            this.MainViewModel.AcquireAcquisitionVM.GetFileName.RegisterHandler(
                async interaction =>
            {
                string filename = await this.utilities.GetFileName();
                interaction.SetOutput(filename);
            });

            this.MainViewModel.AcquireAcquisitionVM.GetSaveFileName.RegisterHandler(
                async interaction =>
            {
                string filename = await this.utilities.GetFileNameToSave();
                interaction.SetOutput(filename);
            });

            RibbonMenuItem acquisitionMenuItem = new RibbonMenuItem()
            {
                Name   = "AcquireAcquisitionItem",
                Header = "Acquire Acquisition"
            };

            acquisitionMenuItem.Click += this.AcquireAcquisitionRibbonItem_Click;
            this.UtilitiesTab.Items.Add(acquisitionMenuItem);

            this.BindAcquireAcquisitionControls(manager);

            this.InitializeAcquireCalibrationModule(manager);
        }
コード例 #5
0
        private static RibbonMenuItem GenerateQATPlacementMenuItem(RibbonContextMenu contextMenu)
        {
            RibbonMenuItem qatPlacementItem = new RibbonMenuItem()
            {
                CanAddToQuickAccessToolBarDirectly = false
            };

            Binding headerBinding = new Binding("PlacementTarget")
            {
                Source = contextMenu
            };

            headerBinding.Converter = new PlacementTargetToQATPositionConverter(PlacementTargetToQATPositionConverter.ConverterMode.Header);
            qatPlacementItem.SetBinding(RibbonMenuItem.HeaderProperty, headerBinding);

            Binding commandBinding = new Binding("PlacementTarget")
            {
                Source = contextMenu
            };

            commandBinding.Converter = new PlacementTargetToQATPositionConverter(PlacementTargetToQATPositionConverter.ConverterMode.Command);
            qatPlacementItem.SetBinding(RibbonMenuItem.CommandProperty, commandBinding);

            Binding placementTargetBinding = new Binding("PlacementTarget")
            {
                Source = contextMenu
            };

            qatPlacementItem.SetBinding(RibbonMenuItem.CommandTargetProperty, placementTargetBinding);

            return(qatPlacementItem);
        }
コード例 #6
0
        private static RibbonMenuItem GenerateAddToOrRemoveFromQATItem(bool controlIsInQAT, RibbonContextMenu contextMenu)
        {
            RibbonMenuItem addToOrRemoveFromQATItem = new RibbonMenuItem()
            {
                CanAddToQuickAccessToolBarDirectly = false
            };

            if (controlIsInQAT)
            {
                addToOrRemoveFromQATItem.Header  = RemoveFromQATText;
                addToOrRemoveFromQATItem.Command = RibbonCommands.RemoveFromQuickAccessToolBarCommand;
            }
            else
            {
                addToOrRemoveFromQATItem.Header  = AddToQATText;
                addToOrRemoveFromQATItem.Command = RibbonCommands.AddToQuickAccessToolBarCommand;
            }

            Binding placementTargetBinding = new Binding("PlacementTarget")
            {
                Source = contextMenu
            };

            addToOrRemoveFromQATItem.SetBinding(RibbonMenuItem.CommandTargetProperty, placementTargetBinding);

            return(addToOrRemoveFromQATItem);
        }
コード例 #7
0
        public override object GetPattern(PatternInterface patternInterface)
        {
            object           result = null;
            FrameworkElement owner  = GetWrapper();

            if (owner != null)
            {
                RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;
                if (menuItemOwner == null)
                {
                    AutomationPeer wrapperPeer = GetWrapperPeer();
                    if (wrapperPeer != null)
                    {
                        result = wrapperPeer.GetPattern(patternInterface);
                    }
                }
                else
                {
                    MenuItemRole role = menuItemOwner.Role;
                    if (patternInterface == PatternInterface.ExpandCollapse)
                    {
                        if ((role == MenuItemRole.TopLevelHeader || role == MenuItemRole.SubmenuHeader) &&
                            menuItemOwner.HasItems)
                        {
                            result = this;
                        }
                    }
                    else if (patternInterface == PatternInterface.Toggle)
                    {
                        result = this;
                    }
                    else if (patternInterface == PatternInterface.Invoke)
                    {
                        if ((role == MenuItemRole.TopLevelItem || role == MenuItemRole.SubmenuItem) &&
                            !menuItemOwner.HasItems)
                        {
                            result = this;
                        }
                    }
                    else if (patternInterface == PatternInterface.Transform)
                    {
                        if (menuItemOwner.IsSubmenuOpen && (menuItemOwner.CanUserResizeHorizontally || menuItemOwner.CanUserResizeVertically))
                        {
                            result = this;
                        }
                    }
                    else
                    {
                        AutomationPeer wrapperPeer = GetWrapperPeer();
                        if (wrapperPeer != null)
                        {
                            result = wrapperPeer.GetPattern(patternInterface);
                        }
                    }
                }
            }

            return(result);
        }
コード例 #8
0
        void item_Click(object sender, RoutedEventArgs e)
        {
            RibbonMenuItem item = sender as RibbonMenuItem;
            string         name = item.ToolTip.ToString();

            Core.settings.removeSavePath(name);
            populateAltPaths();
            askRefreshGames("RefreshForRemovedSavePath");
        }
コード例 #9
0
        private static RibbonContextMenu GetGalleryContextMenu()
        {
            if (_galleryContextMenu == null)
            {
                _galleryContextMenu = new RibbonContextMenu();
                RibbonMenuItem addGalleryToQATItem = GenerateAddGalleryToQATItem(_galleryContextMenu);
                _galleryContextMenu.Items.Add(addGalleryToQATItem);
            }

            return(_galleryContextMenu);
        }
コード例 #10
0
 private void populateAltPaths()
 {
     AltSaveButton.Items.Clear();
     AltSaveButton.Items.Add(AddAltSaveFolder);
     foreach (AltPathHolder alt in Core.settings.save_paths)
     {
         RibbonMenuItem item = new RibbonMenuItem();
         item.Header  = Strings.GetLabelString("RemoteAltSavePath", alt.path);
         item.ToolTip = alt.path;
         item.Click  += new RoutedEventHandler(item_Click);
         AltSaveButton.Items.Add(item);
     }
 }
コード例 #11
0
        public static void PropertyChangedCallback(DependencyObject depObj, DependencyPropertyChangedEventArgs args)
        {
            RibbonMenuItem     listview    = depObj as RibbonMenuItem;
            ColorPickerPalette colorpicker = depObj as ColorPickerPalette;

            if (listview != null)
            {
                listview.Click += listview_Click;
            }
            if (colorpicker != null)
            {
                colorpicker.MoreColorWindowOpening += Colorpicker_MoreColorWindowOpening;
            }
        }
コード例 #12
0
        private static void listview_Click(object sender, RoutedEventArgs e)
        {
            RibbonMenuItem listview = sender as RibbonMenuItem;

            if (listview != null)
            {
                ICommand command = listview.GetValue(CommandProperty) as ICommand;

                if (command != null)
                {
                    command.Execute(listview.Header);
                }
            }
        }
コード例 #13
0
        private void CreateFormatMenuItems()
        {
            foreach (var formatOption in viewModel.SupportedFormattingOptions)
            {
                RibbonMenuItem ribbonMenuItem = new RibbonMenuItem()
                {
                    Header = formatOption.GetFriendlyString(),
                    Name   = formatOption.ToString(),
                };

                ribbonMenuItem.Click += RibbonMenuItemAddFormatOption_Click;

                RibbonMenuButtonFormat.Items.Add(ribbonMenuItem);
            }
        }
コード例 #14
0
        private void CreateSpecialKeyMenuItems()
        {
            foreach (var specialKey in viewModel.SupportedSpecialKeys)
            {
                RibbonMenuItem ribbonMenuItem = new RibbonMenuItem()
                {
                    Header = specialKey.GetFriendlyString(),
                    Name   = specialKey.ToString(),
                };

                ribbonMenuItem.Click += RibbonMenuItemAddSpecialKeyMacroTask_Click;

                RibbonMenuButtonSpecialKeys.Items.Add(ribbonMenuItem);
            }
        }
コード例 #15
0
        private static RibbonMenuItem GenerateAddGalleryToQATItem(RibbonContextMenu contextMenu)
        {
            RibbonMenuItem addGalleryToQATItem = new RibbonMenuItem();

            addGalleryToQATItem.Header = _addGalleryToQATText;

            // Even for galleries in QAT, this menu item always binds the "add to QAT" command.
            addGalleryToQATItem.Command = RibbonCommands.AddToQuickAccessToolBarCommand;

            Binding placementTargetBinding = new Binding("PlacementTarget")
            {
                Source = contextMenu
            };

            addGalleryToQATItem.SetBinding(RibbonMenuItem.CommandTargetProperty, placementTargetBinding);

            return(addGalleryToQATItem);
        }
コード例 #16
0
        private static RibbonMenuItem GetRibbonMenuItem(ImageToImageSourceConverter converter, MenuItem menuItem)
        {
            RibbonMenuItem ribbonMenuItem = new RibbonMenuItem();

            ribbonMenuItem.Header           = menuItem.Header;
            ribbonMenuItem.Command          = menuItem.Command;
            ribbonMenuItem.CommandParameter = menuItem.CommandParameter;
            if (menuItem.Icon != null)
            {
                ribbonMenuItem.ImageSource = (ImageSource)converter.Convert(menuItem.Icon, null, null, null);
            }
            if (menuItem.Items.Count > 0)
            {
                foreach (var item in menuItem.Items.OfType <MenuItem>())
                {
                    ribbonMenuItem.Items.Add(GetRibbonMenuItem(converter, item));
                }
            }
            return(ribbonMenuItem);
        }
コード例 #17
0
        protected override void OnIsItemsHostChanged(bool oldIsItemsHost, bool newIsItemsHost)
        {
            base.OnIsItemsHostChanged(oldIsItemsHost, newIsItemsHost);

            ItemsControl     itemsControl     = ParentItemsControl;
            RibbonMenuButton menuButtonParent = itemsControl as RibbonMenuButton;
            RibbonMenuItem   menuItemParent   = itemsControl as RibbonMenuItem;

            // ParentItemsControl should be either RibbonMenuButton or RibbonMenuItem
            if (menuButtonParent != null || menuItemParent != null)
            {
                if (newIsItemsHost)
                {
                    IItemContainerGenerator generator = itemsControl.ItemContainerGenerator as IItemContainerGenerator;
                    if (generator != null && generator.GetItemContainerGeneratorForPanel(this) == generator)
                    {
                        if (menuButtonParent != null)
                        {
                            menuButtonParent.InternalItemsHost = this;
                        }
                        else if (menuItemParent != null)
                        {
                            menuItemParent.InternalItemsHost = this;
                        }
                    }
                }
                else
                {
                    if (menuButtonParent != null && menuButtonParent.InternalItemsHost == this)
                    {
                        menuButtonParent.InternalItemsHost = null;
                    }
                    else if (menuItemParent != null && menuItemParent.InternalItemsHost == this)
                    {
                        menuItemParent.InternalItemsHost = null;
                    }
                }
            }
        }
コード例 #18
0
ファイル: QatHelper.cs プロジェクト: mingslogar/dimension4
        private bool IsLeaf(object element)
        {
            if ((element is RibbonButton) ||
                (element is RibbonToggleButton) ||
                (element is RibbonRadioButton) ||
                (element is RibbonCheckBox) ||
                (element is RibbonTextBox) ||
                (element is RibbonSeparator))
            {
                return(true);
            }

            RibbonMenuItem menuItem = element as RibbonMenuItem;

            if (menuItem != null &&
                menuItem.Items.Count == 0)
            {
                return(true);
            }

            return(false);
        }
        void IInvokeProvider.Invoke()
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            UIElement owner = GetWrapper();

            if (owner == null)
            {
                throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
            }

            RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;

            if (menuItemOwner == null)
            {
                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
            }

            menuItemOwner.ClickItemInternal();
        }
コード例 #20
0
        private void BookmarkList_DropDownOpened(object sender, EventArgs e)
        {
            ((BookmarkRibbonGroupViewModel)DataContext).SyncBookmarkMenuItems();

            bookmarkList.Items.Clear();
            if (GisEditor.ActiveMap != null && ((BookmarkRibbonGroupViewModel)DataContext).Bookmarks.ContainsKey(GisEditor.ActiveMap.Name))
            {
                foreach (var bookmark in ((BookmarkRibbonGroupViewModel)DataContext).Bookmarks[GisEditor.ActiveMap.Name])
                {
                    bookmarkList.Items.Add(bookmark);
                }
            }

            bookmarkList.Items.Add(new RibbonSeparator());
            var menuItem = new RibbonMenuItem
            {
                Header      = GisEditor.LanguageManager.GetStringResource("BookmarkRibbonGroupAddLabel"),
                ImageSource = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/addbookmark.png", UriKind.RelativeOrAbsolute)),
                Command     = ((BookmarkRibbonGroupViewModel)DataContext).AddBookmarkCommand
            };

            bookmarkList.Items.Add(menuItem);
        }
        private void CopyToExistingLayerRibbonMenuItem_Click(object sender, RoutedEventArgs e)
        {
            RibbonMenuItem ribbonMenuItem = sender as RibbonMenuItem;

            if (ribbonMenuItem != null)
            {
                InMemoryFeatureLayer inMemoryFeatureLayer = ribbonMenuItem.Tag as InMemoryFeatureLayer;
                if (inMemoryFeatureLayer != null)
                {
                    Collection <FeatureLayer> selectedFeatureLayers = new Collection <FeatureLayer>();
                    foreach (FeatureLayer layer in GisEditor.ActiveMap.GetFeatureLayers())
                    {
                        Collection <Feature> features = GisEditor.SelectionManager.GetSelectedFeatures(layer);
                        if (features.Count > 0)
                        {
                            selectedFeatureLayers.Add(layer);
                        }
                    }

                    HighlightedFeaturesHelper.CopyToExistingLayer(selectedFeatureLayers, inMemoryFeatureLayer);
                }
            }
        }
        void IToggleProvider.Toggle()
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            UIElement owner = GetWrapper();

            if (owner == null)
            {
                throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
            }

            RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;

            if (menuItemOwner == null || !menuItemOwner.IsCheckable)
            {
                throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
            }

            menuItemOwner.IsChecked = !menuItemOwner.IsChecked;
        }
コード例 #23
0
        private static RibbonMenuItem GenerateMinimizeTheRibbonItem(RibbonContextMenu contextMenu)
        {
            RibbonMenuItem minimizeTheRibbonItem = new RibbonMenuItem()
            {
                CanAddToQuickAccessToolBarDirectly = false
            };

            minimizeTheRibbonItem.Header = MinimizeTheRibbonText;

            PropertyPath path = new PropertyPath("(0).(1).(2)");

            path.PathParameters.Add(ContextMenuService.PlacementTargetProperty);
            path.PathParameters.Add(RibbonControlService.RibbonProperty);
            path.PathParameters.Add(Ribbon.IsMinimizedProperty);

            Binding isCheckedBinding = new Binding()
            {
                Source = contextMenu, Path = path
            };

            minimizeTheRibbonItem.SetBinding(RibbonMenuItem.IsCheckedProperty, isCheckedBinding);
            Binding isMinimizedBinding = new Binding()
            {
                Source = contextMenu, Path = path
            };

            isMinimizedBinding.Converter = new IsMinimizedToMinimizeOrMaximizeCommandConverter();
            minimizeTheRibbonItem.SetBinding(RibbonMenuItem.CommandProperty, isMinimizedBinding);
            Binding placementTargetBinding = new Binding("PlacementTarget")
            {
                Source = contextMenu
            };

            minimizeTheRibbonItem.SetBinding(RibbonMenuItem.CommandTargetProperty, placementTargetBinding);
            return(minimizeTheRibbonItem);
        }
コード例 #24
0
        private void InitializeComponents()
        {
            base.Id = Id;
            Title   = "OPTIMARCH";
            Panels.Add(new RibbonPanel
            {
                Source = new RibbonPanelSource
                {
                    Title = "发布"
                }
            });



            var list = new RibbonMenuButton();
            var a0   = new RibbonMenuItem
            {
                Text     = "A0",
                ShowText = true,
            };

            list.Items.Add(a0);
            Panels[0].Source.Items.Add(list);
        }
コード例 #25
0
 protected override void OnPreviewKeyDown(KeyEventArgs e)
 {
     if (e.Handled)
     {
         return;
     }
     if (e.Key == Key.Down)
     {
         DependencyObject element = e.OriginalSource as DependencyObject;
         if (element != null)
         {
             UIElement footerPaneHost = FooterPaneHost;
             if (footerPaneHost != null &&
                 footerPaneHost.IsKeyboardFocusWithin &&
                 TreeHelper.IsVisualAncestorOf(footerPaneHost, element))
             {
                 DependencyObject nextFocus = RibbonHelper.PredictFocus(element, FocusNavigationDirection.Down);
                 if (nextFocus == null ||
                     nextFocus == element)
                 {
                     // If the focus is on the last element of footer pane,
                     // then try moving focus into items pane and then into
                     // auxiliary pane if needed.
                     if (ItemsPaneMoveFocus(FocusNavigationDirection.First) ||
                         AuxiliaryPaneMoveFocus(FocusNavigationDirection.First))
                     {
                         e.Handled = true;
                     }
                 }
             }
         }
     }
     else if (e.Key == Key.Up)
     {
         UIElement popupChild = _popup.TryGetChild();
         if (popupChild != null &&
             !popupChild.IsKeyboardFocusWithin)
         {
             // If the popup does not have focus with in then try moving focus to
             // last element of FooterPane and then to the last element of
             // auxiliary pane if needed.
             if (FooterPaneMoveFocus(FocusNavigationDirection.Last) ||
                 AuxiliaryPaneMoveFocus(FocusNavigationDirection.Last))
             {
                 e.Handled = true;
             }
         }
         else
         {
             DependencyObject element = e.OriginalSource as DependencyObject;
             if (element != null)
             {
                 UIElement auxilaryPaneHost = AuxiliaryPaneHost;
                 if (auxilaryPaneHost != null &&
                     auxilaryPaneHost.IsKeyboardFocusWithin &&
                     TreeHelper.IsVisualAncestorOf(auxilaryPaneHost, element))
                 {
                     DependencyObject nextFocus = RibbonHelper.PredictFocus(element, FocusNavigationDirection.Up);
                     if (nextFocus == null ||
                         nextFocus == element)
                     {
                         // If the focus is on last first element of auxiliary pane,
                         // then try moving focus to last element of Items Pane and
                         // then to last element of FooterPane if needed.
                         if (ItemsPaneMoveFocus(FocusNavigationDirection.Last) ||
                             FooterPaneMoveFocus(FocusNavigationDirection.Last))
                         {
                             e.Handled = true;
                         }
                     }
                 }
             }
         }
     }
     else if (e.Key == Key.Left ||
              e.Key == Key.Right)
     {
         DependencyObject element = e.OriginalSource as DependencyObject;
         if (element != null)
         {
             if ((e.Key == Key.Left) == (FlowDirection == FlowDirection.LeftToRight))
             {
                 UIElement auxilaryPaneHost = AuxiliaryPaneHost;
                 if (auxilaryPaneHost != null &&
                     auxilaryPaneHost.IsKeyboardFocusWithin &&
                     TreeHelper.IsVisualAncestorOf(auxilaryPaneHost, element))
                 {
                     // If the effective key is left and the focus is on left most element
                     // of auxiliary pane, then move focus to nearest element to the left of
                     // auxiliarypane.
                     DependencyObject nextFocus = RibbonHelper.PredictFocus(element, FocusNavigationDirection.Last);
                     if (nextFocus != null &&
                         !TreeHelper.IsVisualAncestorOf(auxilaryPaneHost, nextFocus))
                     {
                         if (RibbonHelper.Focus(nextFocus))
                         {
                             e.Handled = true;
                         }
                     }
                 }
             }
             else if (e.Key == Key.Left)
             {
                 ScrollViewer subMenuScrollViewer = SubMenuScrollViewer;
                 if (subMenuScrollViewer != null &&
                     subMenuScrollViewer.IsKeyboardFocusWithin &&
                     TreeHelper.IsVisualAncestorOf(subMenuScrollViewer, element))
                 {
                     // If the flow direction is RightToLeft and the key is Left,
                     // and the focus is in items pane, move the the focus outside teh
                     // items pane if needed.
                     RibbonMenuItem menuItem = element as RibbonMenuItem;
                     if (menuItem == null)
                     {
                         menuItem = TreeHelper.FindVisualAncestor <RibbonMenuItem>(element);
                     }
                     if (menuItem != null &&
                         !menuItem.CanOpenSubMenu)
                     {
                         DependencyObject nextFocus = menuItem.PredictFocus(FocusNavigationDirection.Right);
                         if (nextFocus != null)
                         {
                             if (RibbonHelper.Focus(nextFocus))
                             {
                                 e.Handled = true;
                             }
                         }
                     }
                 }
             }
         }
     }
     base.OnPreviewKeyDown(e);
 }
コード例 #26
0
        /// <summary>
        /// Метод проверка всех комбинаций быстрых кнопок при нажатии
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        private bool CheckAllWindowHotKey(ref System.Windows.Input.KeyEventArgs e)
        {
            Key    PressedKey;
            bool   Shift;
            bool   Control;
            Hotkey hk;

            if (/*Bindings.GrantedAccess.HasFlag(AccessRoles.Full)*/ true)
            {
                Shift   = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;
                Control = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
                bool flag = (Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt;
                PressedKey = e.Key;
                hk         = Hotkeys.FirstOrDefault <Hotkey>(p => ((p.HotKey == PressedKey) && !(Shift ^ p.Shift)) && (Control == p.Control));
                if ((hk != null) && !string.IsNullOrEmpty(hk.Command))
                {
                    RibbonButton button = FindLogicalChildren <RibbonButton>(RibbonWin).FirstOrDefault <RibbonButton>(p => (p.Label != null) && (p.Label.ToString().ToLower() == hk.Command.ToLower()));
                    if (button != null)
                    {
                        if ((button.Command != null) && button.Command.CanExecute(button.CommandParameter))
                        {
                            button.Command.Execute(button.CommandParameter);
                        }
                        if (button.IsEnabled && (button.Visibility == Visibility.Visible))
                        {
                            button.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Primitives.ButtonBase.ClickEvent));
                        }
                    }
                    else
                    {
                        RibbonMenuItem item = FindLogicalChildren <RibbonMenuItem>(RibbonWin).FirstOrDefault <RibbonMenuItem>(p => (p != null) && (p.Header.ToString().ToLower() == hk.Command.ToLower()));
                        if ((item.Command != null) && item.Command.CanExecute(item.CommandParameter))
                        {
                            item.Command.Execute(item.CommandParameter);
                        }
                        if (((item != null) && item.IsEnabled) && (item.Visibility == Visibility.Visible))
                        {
                            item.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.MenuItem.ClickEvent));
                        }
                    }
                    e.Handled = true;
                    return(true);
                }
                switch (e.Key)
                {
                case Key.F1:
                    listBox.SelectedItem = lbiHelp;
                    e.Handled            = true;
                    return(true);

                case Key.F:
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                    {
                        listBox.SelectedItem = listBoxItemSearchCVZ;
                        Dispatcher.Invoke(() => { TextBoxSearch.Focus(); });
                        e.Handled = true;
                    }

                    return(true);

                //case Key.F2:
                //    if (this.DiagnosticsAndSettingsTab.IsEnabled)
                //    {
                //        this.RibbonWin.SelectedIndex = 1;
                //    }
                //    e.Handled = true;
                //    return true;

                //case Key.F3:
                //    if (this.NetworkTab.IsEnabled)
                //    {
                //        this.RibbonWin.SelectedIndex = 2;
                //    }
                //    e.Handled = true;
                //    return true;

                case Key.F4:
                    DSList.Properties.Settings.Default.ProvInfoExpanded = !Properties.Settings.Default.ProvInfoExpanded;
                    e.Handled = true;
                    return(true);

                case Key.F5:
                    Dispatcher.Invoke(async() => { await PingSelectedTT(false); });
                    e.Handled = true;
                    return(true);

                case Key.Escape:
                    this.ClearSearch();
                    e.Handled = true;
                    return(true);
                }
            }
            return(false);
        }
コード例 #27
0
        /// <summary>
        /// Sự kiện hot key
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tlbHotKey_Click(object sender, RoutedEventArgs e)
        {
            // Truongnx
            string strTinhNang = "";

            if (sender is RibbonButton)
            {
                RibbonButton tlb = (RibbonButton)sender;
                strTinhNang = tlb.Name.Substring(3, tlb.Name.Length - 3);
            }
            else if (sender is RibbonMenuItem)
            {
                RibbonMenuItem tlb = (RibbonMenuItem)sender;
                strTinhNang = tlb.Name.Substring(3, tlb.Name.Length - 3);
            }

            if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.NHAP_DU_LIEU)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.THEM)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.LUU)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.SUA)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XOA)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.NHAN_BAN)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.LUU_TAM)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TRINH_DUYET)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.BANG_KE)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.DUYET)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TU_CHOI_DUYET)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.THOAI_DUYET)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XEM_TRUOC)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XEM)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.XUAT_DU_LIEU)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TIM_KIEM)))
            {
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.TRO_GIUP)))
            {
                onHelp();
            }
            else if (strTinhNang.Equals(DatabaseConstant.getValue(DatabaseConstant.Action.DONG)))
            {
                CustomControl.CommonFunction.CloseUserControl(this);
            }
        }
コード例 #28
0
 /// <summary>
 ///   Initialize Automation Peer for RibbonMenuItem
 /// </summary>
 public RibbonMenuItemAutomationPeer(RibbonMenuItem owner)
     : base(owner)
 {
 }
コード例 #29
0
        public MainWindow()
        {
            InitializeComponent();
            grdMain.Background = new LinearGradientBrush(
                Color.FromArgb(255, 0xDF, 0xE9, 0xF5),
                Color.FromArgb(255, 0xB9, 0xC9, 0xDA),
                90);

            foreach (CultureInfo ci in LanguageExtension.CultureList)
            {
                RibbonMenuItem rmi = new RibbonMenuItem();
                rmi.Header = ci.EnglishName;
                rmi.Tag    = ci;
                rmi.Click += (s, e) =>
                {
                    Thread.CurrentThread.CurrentUICulture = rmi.Tag as CultureInfo;

                    MainWindow win = new MainWindow();
                    win.Show();

                    this.Close();
                };

                rmiLanguage.Items.Add(rmi);
            }

            manager.RedoListChanged += (s, e) =>
            {
                if (manager.CanRedo)
                {
                    btnQuickRedo.ToolTip = "Redo: " + manager.LastRedoActionName;
                    btnRedo.ToolTip      = manager.LastRedoActionName;
                }
                else
                {
                    btnQuickRedo.ToolTip = "Redo";
                    btnRedo.ToolTip      = "";
                }
            };
            manager.UndoListChanged += (s, e) =>
            {
                if (manager.CanUndo)
                {
                    btnQuickUndo.ToolTip = "Undo: " + manager.LastUndoActionName;
                    btnUndo.ToolTip      = manager.LastUndoActionName;
                }
                else
                {
                    btnQuickUndo.ToolTip = "Undo";
                    btnUndo.ToolTip      = "";
                }
            };

            openDlg             = new System.Windows.Forms.OpenFileDialog();
            openDlg.Filter      = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|Portable Network Graphic (*.png)|*.png";
            openDlg.DefaultExt  = "bmp|jpg|png";
            openDlg.FilterIndex = 2;
            openDlg.Multiselect = true;

            saveDlg             = new System.Windows.Forms.SaveFileDialog();
            saveDlg.Filter      = openDlg.Filter;
            saveDlg.DefaultExt  = openDlg.DefaultExt;
            saveDlg.FilterIndex = openDlg.FilterIndex;

            UpdateHistoryList();
            UpdateEffectList();
            UpdateRendererList();
        }
コード例 #30
0
        private void TargetLayerSelected(object sender, RoutedEventArgs e)
        {
            RibbonMenuItem menuItem = (RibbonMenuItem)sender;

            var gisEditorTrackOverlay = GisEditor.ActiveMap.TrackOverlay as GisEditorTrackInteractiveOverlay;

            if (gisEditorTrackOverlay != null)
            {
                gisEditorTrackOverlay.EditOverlay          = EditingToolsViewModel.Instance.EditOverlay;
                gisEditorTrackOverlay.IsDirty              = true;
                gisEditorTrackOverlay.GeographyUnit        = GisEditor.ActiveMap.MapUnit;
                gisEditorTrackOverlay.SnappingDistanceUnit = viewModel.SnappingDistanceUnit;
                gisEditorTrackOverlay.SnappingDistance     = viewModel.SnappingDistance;
            }

            var dataContext = (CheckableItemViewModel <FeatureLayer>)menuItem.DataContext;

            if (dataContext.Value == null && !dataContext.IsChecked)
            {
                viewModel.SnappingLayers.Clear();
                if (gisEditorTrackOverlay != null)
                {
                    gisEditorTrackOverlay.SnappingLayers.Clear();
                }
            }
            else if (dataContext.IsChecked && dataContext.Value != null && viewModel.SnappingLayers.Contains(dataContext.Value))
            {
                viewModel.SnappingLayers.Remove(dataContext.Value);
                if (gisEditorTrackOverlay != null)
                {
                    gisEditorTrackOverlay.SnappingLayers.Remove(dataContext.Value);;
                }
            }
            else if (dataContext.Value != null)
            {
                viewModel.SnappingLayers.Add(dataContext.Value);

                //var gisEditorTrackOverlay = GisEditor.ActiveMap.TrackOverlay as GisEditorTrackInteractiveOverlay;
                if (gisEditorTrackOverlay != null)
                {
                    //gisEditorTrackOverlay.Layer = EditingToolsViewModel.Instance.SelectedLayer.Value;
                    //gisEditorTrackOverlay.SnappingLayers = viewModel.SnappingLayers;


                    gisEditorTrackOverlay.SnappingLayers.Add(dataContext.Value);

                    GisEditor.ActiveMap.CurrentExtentChanged -= new System.EventHandler <CurrentExtentChangedWpfMapEventArgs>(ActiveMap_CurrentExtentChanged);
                    GisEditor.ActiveMap.CurrentExtentChanged += new System.EventHandler <CurrentExtentChangedWpfMapEventArgs>(ActiveMap_CurrentExtentChanged);
                }
            }

            if (viewModel.SnappingLayers.Count == 0)
            {
                viewModel.TargetLayers.Where(l => l.Value == null).First().IsChecked = true;
            }
            else
            {
                viewModel.TargetLayers.ForEach(l =>
                {
                    if (l.Value == null)
                    {
                        l.IsChecked = false;
                    }
                    else if (viewModel.SnappingLayers.Contains(l.Value))
                    {
                        l.IsChecked = true;
                    }
                });
            }

            viewModel.EditOverlay.Refresh();
        }