private static MenuFlyoutItem GetRegularItem(MenuItemViewModel viewModel)
        {
            var item = new MenuFlyoutItem();

            item.SetBinding(MenuFlyoutItem.TextProperty, new Binding
            {
                Source = viewModel,
                Path   = new PropertyPath(nameof(MenuItemViewModelBase.Text)),
                Mode   = BindingMode.OneWay
            });

            item.SetBinding(ToolTipService.ToolTipProperty, new Binding
            {
                Source = viewModel,
                Path   = new PropertyPath(nameof(MenuItemViewModelBase.Description)),
                Mode   = BindingMode.OneWay
            });

            item.SetBinding(MenuFlyoutItem.IconProperty, new Binding
            {
                Source    = viewModel,
                Path      = new PropertyPath(nameof(MenuItemViewModelBase.Icon)),
                Converter = IconConverter,
                Mode      = BindingMode.OneWay
            });

            item.SetBinding(MenuFlyoutItem.CommandProperty, new Binding
            {
                Source = viewModel,
                Path   = new PropertyPath(nameof(MenuItemViewModel.Command)),
                Mode   = BindingMode.OneTime
            });

            if (viewModel.KeyBinding != null)
            {
                if (viewModel.KeyBinding.IsExtendedVirtualKey)
                {
                    if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 6))
                    {
                        item.KeyboardAcceleratorTextOverride = viewModel.KeyBinding.GetOverrideText();
                    }
                }
                else
                {
                    item.KeyboardAccelerators?.Add(new KeyboardAccelerator
                    {
                        Key       = (VirtualKey)viewModel.KeyBinding.Key,
                        Modifiers = (VirtualKeyModifiers)viewModel.KeyBinding.KeyModifiers,
                        IsEnabled = true
                    });
                }
            }

            return(item);
        }
Пример #2
0
        public DiagramBuilder1()
        {
            this.InitializeComponent();

#if SyncfusionFramework4_5_1
            MenuFlyout menu = new MenuFlyout();
            Binding    bind = new Binding {
                Path = new PropertyPath("SelectedDiagram.Export")
            };
            List <string> formats = new List <string> {
                "Png", "Jpeg", "Gif", "Tiff", "Jpegxr"
            };
            foreach (var item in formats)
            {
                MenuFlyoutItem menuItem = new MenuFlyoutItem
                {
                    Text             = item,
                    CommandParameter = item
                };
                menuItem.SetBinding(MenuFlyoutItem.CommandProperty, bind);
                menu.Items.Add(menuItem);
            }
            export.Flyout = menu;
#endif
        }
Пример #3
0
        private void InitializeEmojiMenu()
        {
            var commandBinding = new Binding
            {
                Path           = new PropertyPath(nameof(this.Command)),
                RelativeSource = new RelativeSource {
                    Mode = RelativeSourceMode.TemplatedParent
                }
            };

            this.EmojiMenu.Items.Clear();
            foreach (var emoji in EmojiReference.KnownCodes)
            {
                var code = emoji.Key.EndsWith("D", StringComparison.Ordinal) ?
                           emoji.Key :
                           emoji.Key.ToLowerInvariant();

                var menuFlyoutItem = new MenuFlyoutItem
                {
                    Text             = emoji.Value + " " + code,
                    CommandParameter = code,
                };
                menuFlyoutItem.SetBinding(MenuFlyoutItem.CommandProperty, commandBinding);

                this.EmojiMenu.Items.Add(menuFlyoutItem);
            }
        }
        private static MenuFlyoutItem GetRegularItem(MenuItemViewModel viewModel)
        {
            var item = new MenuFlyoutItem();

            item.SetBinding(MenuFlyoutItem.TextProperty, new Binding
            {
                Source = viewModel,
                Path   = new PropertyPath(nameof(MenuItemViewModelBase.Text)),
                Mode   = BindingMode.OneWay
            });

            item.SetBinding(ToolTipService.ToolTipProperty, new Binding
            {
                Source = viewModel,
                Path   = new PropertyPath(nameof(MenuItemViewModelBase.Description)),
                Mode   = BindingMode.OneWay
            });

            item.SetBinding(MenuFlyoutItem.IconProperty, new Binding
            {
                Source    = viewModel,
                Path      = new PropertyPath(nameof(MenuItemViewModelBase.Icon)),
                Converter = IconConverter,
                Mode      = BindingMode.OneWay
            });

            item.SetBinding(MenuFlyoutItem.CommandProperty, new Binding
            {
                Source = viewModel,
                Path   = new PropertyPath(nameof(MenuItemViewModel.Command)),
                Mode   = BindingMode.OneTime
            });

            if (viewModel.KeyBinding != null)
            {
                item.KeyboardAccelerators?.Add(new KeyboardAccelerator
                {
                    Key       = (VirtualKey)viewModel.KeyBinding.Key,
                    Modifiers = (VirtualKeyModifiers)viewModel.KeyBinding.KeyModifiers,
                    IsEnabled = true
                });
            }

            return(item);
        }
Пример #5
0
        void SetupMenuItems(MenuFlyout flyout)
        {
            foreach (MenuItem item in Cell.ContextActions)
            {
                var flyoutItem = new MenuFlyoutItem();
                flyoutItem.SetBinding(MenuFlyoutItem.TextProperty, "Text");
                flyoutItem.Command     = new MenuItemCommand(item);
                flyoutItem.DataContext = item;

                flyout.Items.Add(flyoutItem);
            }
        }
Пример #6
0
        public FrameStudio()
        {
            this.InitializeComponent();
            TitleBackground = GetColorFromHexa("#3e3f42");

            MenuFlyout menu = new MenuFlyout();
            Binding    bind = new Binding {
                Path = new PropertyPath("SelectedDiagram.Export")
            };
            List <string> formats = new List <string> {
                "Png", "Jpeg", "Gif", "Tiff", "Jpegxr"
            };

            foreach (var item in formats)
            {
                MenuFlyoutItem menuItem = new MenuFlyoutItem
                {
                    Text             = item,
                    CommandParameter = item
                };
                menuItem.SetBinding(MenuFlyoutItem.CommandProperty, bind);
                menu.Items.Add(menuItem);
            }
            // exportbutton.Flyout = menu;
            Window.Current.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;
            Keys            = new List <VirtualKey>();
            NewPage         = new Command(OnNewPageCommand);
            ClonePage       = new Command(OnClonePageCommand);
            Save            = new Command(OnSaveCommand);
            SaveAs          = new Command(OnSaveAsCommand);
            Open            = new Command(OnOpenCommand);
            RulerVisibility = new Command(OnRulerVisibilityCommand);
            SmartGuide      = new Command(OnSmartGuideCommand);
            GridLines       = new Command(OnGridLinesCommand);
            Lock            = new Command(OnLockCommand);
            UnLock          = new Command(OnUnLockCommand);
            UnSelect        = new Command(OnUnSelectCommand);
            Pan             = new Command(OnPanCommand);
            Library         = new Command(OnLibraryCommand);
            Copy            = new Command(OnCopyCommand);
            Paste           = new Command(OnPasteCommand);
        }
Пример #7
0
		void SetupMenuItems(MenuFlyout flyout)
		{
			foreach (MenuItem item in Cell.ContextActions)
			{
				var flyoutItem = new MenuFlyoutItem();
				flyoutItem.SetBinding(MenuFlyoutItem.TextProperty, "Text");
				flyoutItem.Command = new MenuItemCommand(item);
				flyoutItem.DataContext = item;

				flyout.Items.Add(flyoutItem);
			}
		}