Example #1
0
 public void ExportCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     tlbExport.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
 }
Example #2
0
 public void CloseCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     tlbClose.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
 }
Example #3
0
 public void PreviewCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     tlbPreview.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
 }
Example #4
0
 public void SearchCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     tlbSearch.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
 }
Example #5
0
 public void ModifyCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     tlbModify.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
 }
Example #6
0
        //public static IEnumerable<T> FindLogicalChildren<T>(DependencyObject depObj) where T : DependencyObject
        //{
        //    if (depObj != null)
        //    {
        //        foreach (object rawChild in LogicalTreeHelper.GetChildren(depObj))
        //        {
        //            if (rawChild is DependencyObject)
        //            {
        //                DependencyObject child = (DependencyObject)rawChild;
        //                if (child is T)
        //                {
        //                    yield return (T)child;
        //                }

        //                foreach (T childOfChild in FindLogicalChildren<T>(child))
        //                {
        //                    yield return childOfChild;
        //                }
        //            }
        //        }
        //    }
        //}

        private void PopupMenu_Opened(object sender, EventArgs e)
        {
            //Owner.QuickAccessToolBarMainWindow.Items
            this.PopupToolbar.Items.Clear();
            using (IEnumerator <RibbonButton> enumerator = (from b in FindLogicalChildren <RibbonButton>(RibbonWin)
                                                                                                                 //where Owner.RibbonWin.QuickAccessToolBar.Items.Contains(b) /*&& (mainwindow.RibbonWin.QuickAccessToolBar.Items.Count<QuickAccessMenuItem>(c => (c.Target == b)) == 0)*/
                                                            where RibbonWin.QuickAccessToolBar.Items.Contains(b) /*&& (Owner.RibbonWin.QuickAccessToolBar.Items.Count<RibbonButton>(c => (c.tar == b)) == 0)*/

                                                            select b).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    RibbonButton ribbonButton = enumerator.Current;

                    StringReader input   = new StringReader(XamlWriter.Save(ribbonButton));
                    RibbonButton newItem = (RibbonButton)XamlReader.Load(XmlReader.Create(input));


                    //newItem.Size = Fluent.RibbonControlSize.Middle;
                    //newItem.LargeImageSource =
                    if (NewMainWindow.settings.Fields.BigPopupToolbar)
                    {
                        //newItem.LargeImageSource = new BitmapImage(new Uri("pack://application:,,,/Resources/copy_6524.png"));
                        //newItem.
                    }

                    newItem.CanAddToQuickAccessToolBarDirectly = false;
                    newItem.Command = ribbonButton.Command;
                    newItem.Click  += delegate(object o, RoutedEventArgs a)
                    {
                        if ((ribbonButton.IsEnabled && (ribbonButton.Visibility == Visibility.Visible)) && this.PopupAction())
                        {
                            //ribbonButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Primitives.ButtonBase.ClickEvent));
                            ribbonButton.RaiseEvent(new RoutedEventArgs(RibbonButton.ClickEvent));
                        }
                    };
                    this.PopupToolbar.Items.Add(newItem);
                }
            }
            //foreach (RibbonMenuItem item in from b in FindLogicalChildren<RibbonMenuItem>(Owner.RibbonWin)
            //                                where Owner.RibbonWin.QuickAccessToolBar.Items.Contains(b) /*&& (mainwindow.RibbonWin.QuickAccessItems.Count<QuickAccessMenuItem>(c => (c.Target == b)) == 0)*/
            //                                select b)
            //{
            //    RibbonButton button2 = new RibbonButton
            //    {
            //        //SmallImageSource = item.QuickAccessToolBarImageSource,
            //        //Size = Fluent.RibbonControlSize.Middle,
            //        //ToolTip = item.ToolTip,
            //        CanAddToQuickAccessToolBarDirectly = false
            //    };
            //    button2.Click += (o, a) => this.PopupAction();
            //    //button2.ToolTip = item.ToolTip;
            //    button2.Command = item.Command;
            //    button2.CommandParameter = item.CommandParameter;
            //    this.PopupToolbar.Items.Add(button2);
            //}
            if (this.PopupToolbar.Items.Count == 0)
            {
                TextBlock block = new TextBlock
                {
                    Text   = "Отсутствуют добаленные команды.\r\nДобавьте команду в панель быстрого доступа.",
                    Margin = new Thickness(3.0)
                };
                this.PopupToolbar.Items.Add(block);
            }
        }
Example #7
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);
        }