Beispiel #1
0
        private static void AddToQATCanExecute(object sender, CanExecuteRoutedEventArgs args)
        {
            DependencyObject thatCanBeAddedToQat = MyRibbon.FindElementThatCanBeAddedToQAT(args.OriginalSource as DependencyObject);

            if (thatCanBeAddedToQat == null || RibbonControlService.GetQuickAccessToolBarId(thatCanBeAddedToQat) == null || RibbonHelper.ExistsInQAT(thatCanBeAddedToQat))
            {
                return;
            }
            args.CanExecute = true;
        }
Beispiel #2
0
        private static void AddToQATExecuted(object sender, ExecutedRoutedEventArgs args)
        {
            var    ribbon0 = (MyRibbon)sender;
            object model   = AttachedProperties.GetModel(ribbon0);

            if ((model is PrimaryRibbonModel primary))
            {
                if (!(MyRibbon.FindElementThatCanBeAddedToQAT((DependencyObject)(args.OriginalSource as UIElement)) is UIElement thatCanBeAddedToQat))
                {
                    return;
                }
                RibbonQuickAccessToolBarCloneEventArgs barCloneEventArgs = new RibbonQuickAccessToolBarCloneEventArgs(thatCanBeAddedToQat);
                thatCanBeAddedToQat.RaiseEvent((RoutedEventArgs)barCloneEventArgs);
                MyRibbon ribbon = RibbonControlService.GetRibbon((DependencyObject)thatCanBeAddedToQat) as MyRibbon;
                if (barCloneEventArgs.CloneInstance == null)
                {
                    return;
                }
                primary.QuickAccessToolBar.Items.Add((object)barCloneEventArgs.CloneInstance);
                args.Handled = true;
            }
        }