コード例 #1
0
        private static void SaveToolBarsWidthOnLoaded(ToolBarTray toolBarTray)
        {
            ApplySettingsToToolBars(toolBarTray, SetToolBarWidth);

            OverridePropertyOnChanged(toolBarTray, ToolBar.WidthProperty, (sender, args) => SaveSettings(toolBarTray,
                                                                                                         ToolBarSettingsType.Width));
        }
コード例 #2
0
        void AddFileToolBar(ToolBarTray tray, int band, int index)
        {
            ToolBar toolbar = new ToolBar();

            toolbar.Band      = band;
            toolbar.BandIndex = index;
            tray.ToolBars.Add(toolbar);

            RoutedUICommand[] comms = { ApplicationCommands.New, ApplicationCommands.Open, ApplicationCommands.Save };

            string[] strImages = { "new.png", "open.png", "save.png" };

            for (int i = 0; i < 3; i++)
            {
                Button btn = new Button();
                btn.Command = comms[i];
                toolbar.Items.Add(btn);

                Image img = new Image();
                img.Source  = new BitmapImage(new Uri($"pack://application:,,/Images/{strImages[i]}"));
                img.Stretch = Stretch.None;
                btn.Content = img;

                ToolTip tip = new ToolTip();
                tip.Content = comms[i].Text;
                btn.ToolTip = tip;
            }

            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.New, OnNew));
            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, OnOpen));
            this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, OnSave));
        }
コード例 #3
0
 private static void AdjustStyle(ToolBarTray tray, Brush background)
 {
     foreach (var tb in tray.ToolBars)
     {
         AdjustStyle(tb, background);
     }
 }
コード例 #4
0
        protected override void SetUpCore()
        {
            base.SetUpCore();

            ClearEventInfo();

            _workItem       = new TestableWorkItem();
            _commandService = new CommandService();
            _toolBarService = new ToolBarService(_workItem);

            _workItem.OnBuiltUp(null);

            //make sure the work item can adapt menus etc
            var commandAdapterMapService = _workItem.Services.Get <ICommandAdapterMapService>();

            commandAdapterMapService.Register(typeof(UIElement), typeof(UIElementCommandAdapter));

            var uiElementAdapterFactoryCatalog =
                _workItem.Services.Get <IUIElementAdapterFactoryCatalog>();

            uiElementAdapterFactoryCatalog.RegisterFactory(new ItemsControlUIAdapterFactory());
            uiElementAdapterFactoryCatalog.RegisterFactory(new ToolBarTrayUIAdapterFactory());

            //make sure the root tool bar tray exists and is registered in the work item
            _toolBarTray = new ToolBarTray();
            _workItem.UIExtensionSites.RegisterSite(ExtensionSites.ToolBar.Name, _toolBarTray);

            _toolBarService.ToolBarAdded += delegate(object sender, ToolBarEventArgs e) { _toolBarAddedEventArgs = e; };

            _toolBarService.ToolBarRemoved +=
                delegate(object sender, ToolBarEventArgs e) { _toolBarRemovedEventArgs = e; };

            _toolBarService.ToolBarVisibilityChanged +=
                delegate(object sender, ToolBarEventArgs e) { _toolBarVisibilityChangedEventArgs = e; };
        }
コード例 #5
0
        public FormatRichText()
        {
            Title = "Format Rich Text";

            DockPanel dock = new DockPanel();

            Content = dock;

            ToolBarTray tray = new ToolBarTray();

            dock.Children.Add(tray);
            DockPanel.SetDock(tray, Dock.Top);

            txtbox = new RichTextBox();
            txtbox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

            AddFileToolBar(tray, 0, 0);
            AddEditToolBar(tray, 1, 0);
            AddCharToolBar(tray, 2, 0);
            AddParaToolBar(tray, 2, 1);
            AddStatusBar(dock);

            dock.Children.Add(txtbox);
            txtbox.Focus();
        }
コード例 #6
0
        void CreateToolBar()
        {
            ToolBarTray tbartray = new ToolBarTray();
            
            ToolBar tbar = new ToolBar();
            
            Button btn = new Button();
            btn.Content = "File";
            tbar.Items.Add(btn);

            Button btn1 = new Button();
            btn1.Content = "Edit";
            tbar.Items.Add(btn1);
            
            ToolBar tbar1 = new ToolBar();

            Button btn2 = new Button();
            btn2.Content = "Format";
            tbar1.Items.Add(btn2);

            Button btn3 = new Button();
            btn3.Content = "View";
            tbar1.Items.Add(btn3);

            Button btn4 = new Button();
            btn4.Content = "Help";
            tbar1.Items.Add(btn4);
            //<SnippetToolBarTrayToolBars>
            tbartray.ToolBars.Add(tbar);
            tbartray.ToolBars.Add(tbar1);
            //</SnippetToolBarTrayToolBars>

            bd1.Child = tbartray;
        }
コード例 #7
0
ファイル: FormatRichText.cs プロジェクト: mkbiltek2019/refer
        public FormatRichText()
        {
            Title = "Format Rich Text";

            // Create DockPanel as content of window.
            DockPanel dock = new DockPanel();

            Content = dock;

            // Create ToolBarTray docked at top of client area.
            ToolBarTray tray = new ToolBarTray();

            dock.Children.Add(tray);
            DockPanel.SetDock(tray, Dock.Top);

            // Create RichTextBox.
            txtbox = new RichTextBox();
            txtbox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

            // Call methods in other files.
            AddFileToolBar(tray, 0, 0);
            AddEditToolBar(tray, 1, 0);
            AddCharToolBar(tray, 2, 0);
            AddParaToolBar(tray, 2, 1);
            AddStatusBar(dock);

            // Fill rest of client area with RichTextBox and give it focus.
            dock.Children.Add(txtbox);
            txtbox.Focus();
        }
コード例 #8
0
ファイル: SmartBar.cs プロジェクト: IneedHelp/Codist
 /// <summary>
 /// Initializes a new instance of the <see cref="SmartBar"/> class.
 /// </summary>
 /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
 public SmartBar(IWpfTextView view)
 {
     View          = view ?? throw new ArgumentNullException(nameof(view));
     _ToolBarLayer = view.GetAdornmentLayer(nameof(SmartBar));
     View.Selection.SelectionChanged += ViewSelectionChanged;
     View.Closed += ViewClosed;
     ToolBar      = new ToolBar {
         BorderThickness = new Thickness(1), BorderBrush = Brushes.Gray, Band = 1, IsOverflowOpen = false
     }.HideOverflow();
     ToolBar.SetResourceReference(Control.BackgroundProperty, VsBrushes.CommandBarGradientBeginKey);
     ToolBar2 = new ToolBar {
         BorderThickness = new Thickness(1), BorderBrush = Brushes.Gray, Band = 2, IsOverflowOpen = false
     }.HideOverflow();
     ToolBar2.SetResourceReference(Control.BackgroundProperty, VsBrushes.CommandBarGradientBeginKey);
     _ToolBarTray = new ToolBarTray {
         ToolBars   = { ToolBar, ToolBar2 },
         IsLocked   = true,
         Cursor     = Cursors.Arrow,
         Background = Brushes.Transparent,
     };
     _ToolBarTray.MouseEnter += ToolBarMouseEnter;
     _ToolBarTray.MouseLeave += ToolBarMouseLeave;
     _ToolBarTray.DragEnter  += HideToolBar;
     _CreateToolBarTimer      = new Timer(CreateToolBar);
     _ToolBarLayer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, _ToolBarTray, null);
     _ToolBarTray.Visibility = Visibility.Hidden;
 }
コード例 #9
0
        private static void SaveToolBarsBandOnLoaded(ToolBarTray toolBarTray)
        {
            ApplySettingsToToolBars(toolBarTray, SetToolBarBand);

            OverridePropertyOnChanged(toolBarTray, ToolBar.BandProperty, (sender, args) => SaveSettings(toolBarTray,
                                                                                                        ToolBarSettingsType.Band));
        }
コード例 #10
0
        public SearchResultsPad()
        {
            if (instance != null)
            {
                throw new InvalidOperationException("Cannot create multiple instances");
            }
            instance = this;
            toolBar  = new ToolBar();
            ToolBarTray.SetIsLocked(toolBar, true);
            defaultToolbarItems = ToolBarService.CreateToolBarItems(contentPanel, this, "/SharpDevelop/Pads/SearchResultPad/Toolbar");
            foreach (object toolBarItem in defaultToolbarItems)
            {
                toolBar.Items.Add(toolBarItem);
            }

            contentPlaceholder = new ContentPresenter();
            contentPanel       = new Grid {
                Children = { toolBar, contentPlaceholder }
            };

            contentPanel.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            contentPanel.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            Grid.SetRow(contentPlaceholder, 1);
        }
コード例 #11
0
 public static void SetObservedItemsSource(ToolBarTray frameworkElement, IEnumerable <ToolBar> observedItemsSource)
 {
     frameworkElement.SetValue(ObservedItemsSourceProperty, observedItemsSource);
     if (GetObserve(frameworkElement))
     {
         UpdateObservedValuesForFrameworkElement(frameworkElement);
     }
 }
コード例 #12
0
        static ToolBar CreateToolBar(UIElement inputBindingOwner, object owner, AddInTreeNode treeNode, bool showInTray, bool isLocked)
        {
            CoreToolBar tb = (CoreToolBar)CreateToolBar(inputBindingOwner, owner, treeNode);

            tb.ShowInTray = showInTray;
            ToolBarTray.SetIsLocked(tb, isLocked);
            return(tb);
        }
コード例 #13
0
        private static IEnumerable <ToolBar> GetSortedToolBars(ToolBarTray tray)
        {
            var toolBarList = new List <ToolBar>(tray.ToolBars);

            toolBarList.Sort((tb1, tb2) =>
                             tb1.Band == tb2.Band ? tb1.BandIndex.CompareTo(tb2.BandIndex) : tb1.Band.CompareTo(tb2.Band));
            return(toolBarList);
        }
コード例 #14
0
ファイル: Main.cs プロジェクト: aardappel/restructor
    internal static ToolBar ToolBar(ToolBarTray parent)
    {
        var tb = new ToolBar();

        tb.Background = new SolidColorBrush(Color.FromRgb(0xBC, 0xC7, 0xD8));
        parent.ToolBars.Add(tb);
        return(tb);
    }
コード例 #15
0
        static void ShowToolBar(Object obj)
        {
            ToolBarTray tbt = ((MainWindow)obj).tbt;

            tbt.Visibility = tbt.Visibility == Visibility.Visible
                                ? Visibility.Collapsed
                                : Visibility.Visible;
            Settings.Default.ToolbarChecked = tbt.Visibility == Visibility.Visible;
        }
コード例 #16
0
        private static void OverridePropertyOnChanged(ToolBarTray toolBarTray, DependencyProperty property, EventHandler handler)
        {
            PropertyDescriptor propertyDescriptor = DependencyPropertyDescriptor.FromProperty(property, typeof(ToolBar));

            foreach (var toolBar in toolBarTray.ToolBars)
            {
                propertyDescriptor.AddValueChanged(toolBar, handler);
            }
        }
コード例 #17
0
 private void Target_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (unlocked)
     {
         DataObject  capsule = new DataObject("toolBarTray", Target);
         ToolBarTray tbt     = Target;
         DragDrop.DoDragDrop(tbt, capsule, DragDropEffects.Move);
     }
 }
コード例 #18
0
        static ToolBar CreateToolBar(UIElement inputBindingOwner, object owner, AddInTreeNode treeNode)
        {
            ToolBar tb = new CoreToolBar();

            ToolBarTray.SetIsLocked(tb, true);
            tb.ItemsSource = CreateToolBarItems(inputBindingOwner, treeNode.BuildChildItems <ToolbarItemDescriptor>(owner));
            UpdateStatus(tb.ItemsSource);             // setting Visible is only possible after the items have been added
            return(tb);
        }
コード例 #19
0
        private void InitializeMenus(MainWindow mainWindow)
        {
            _windowMenu  = mainWindow.menu;
            _toolBarTray = mainWindow.toolBarTray;
            _statusBar   = mainWindow.statusBar;

            Model.ModulesMgr.MenuGroups.CollectionChanged      += MenuGroups_CollectionChanged;
            Model.ModulesMgr.ToolbarGroups.CollectionChanged   += ToolbarGroups_CollectionChanged;
            Model.ModulesMgr.StatusbarGroups.CollectionChanged += StatusbarGroups_CollectionChanged;
        }
コード例 #20
0
        public void CreateMenu()
        {
            DockPanel DockPanel = new DockPanel();

            DockPanel.Background = Brushes.White;

            ToolBarTray ToolBarTray = new ToolBarTray();

            ToolBarTray.Background = Brushes.White;

            // File
            ToolBar ToolBar = new ToolBar();

            ToolBar.Background = Brushes.White;

            // Buttons
            NewBtn            = new Button();
            NewBtn.Name       = "New";
            NewBtn.Background = Brushes.White;
            NewBtn.Content    = "New";
            NewBtn.Click     += NewBtn_Click;
            ToolBar.Items.Add(NewBtn);

            OpenBtn            = new Button();
            OpenBtn.Name       = "Open";
            OpenBtn.Background = Brushes.White;
            OpenBtn.Content    = "Open";
            ToolBar.Items.Add(OpenBtn);

            SaveBtn            = new Button();
            SaveBtn.Name       = "Save";
            SaveBtn.Background = Brushes.White;
            SaveBtn.Content    = "Save";
            SaveBtn.Click     += SaveBtn_Click;
            ToolBar.Items.Add(SaveBtn);

            //Editor Location
            ToolBar ToolBarEditor = new ToolBar();

            ToolBarEditor.Background = Brushes.White;

            Button NewLanguageBtn = new Button();

            NewLanguageBtn.Name       = "Add_Language";
            NewLanguageBtn.Background = Brushes.White;
            NewLanguageBtn.Content    = "Add Language";
            ToolBarEditor.Items.Add(NewLanguageBtn);

            // set all buttons on toolbar
            ToolBarTray.ToolBars.Add(ToolBar);
            ToolBarTray.ToolBars.Add(ToolBarEditor);
            DockPanel.Children.Add(ToolBarTray);

            this.Grid.Children.Add(DockPanel);
        }
コード例 #21
0
        void AddEditToolBar(ToolBarTray tray, int band, int index)
        {
            // Create Toolbar.
            ToolBar toolbar = new ToolBar();

            toolbar.Band      = band;
            toolbar.BandIndex = index;
            tray.ToolBars.Add(toolbar);

            RoutedUICommand[] comm =
            {
                ApplicationCommands.Cut,   ApplicationCommands.Copy,
                ApplicationCommands.Paste, ApplicationCommands.Delete,
                ApplicationCommands.Undo,  ApplicationCommands.Redo
            };

            string[] strImages =
            {
                "CutHS.png",       "CopyHS.png",
                "PasteHS.png",     "DeleteHS.png",
                "Edit_UndoHS.png", "Edit_RedoHS.png"
            };


            for (int i = 0; i < 6; i++)
            {
                if (i == 4)
                {
                    toolbar.Items.Add(new Separator());
                }

                Button btn = new Button();
                btn.Command = comm[i];
                toolbar.Items.Add(btn);

                Image img = new Image();
                img.Source = new BitmapImage(
                    new Uri("pack://application:,,/Images/" + strImages[i]));
                img.Stretch = Stretch.None;
                btn.Content = img;

                ToolTip tip = new ToolTip();
                tip.Content = comm[i].Text;
                btn.ToolTip = tip;
            }

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste));
            CommandBindings.Add(new CommandBinding(
                                    ApplicationCommands.Delete, OnDelete, CanDelete));

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo));
        }
コード例 #22
0
        public MainWindow()
        {
            InitializeComponent();
            Frame = MainWindowFrame;

            Toolbar  = MainToolbar;
            Username = UsernameTb;
            Email    = EmailTb;

            MainWindowFrame.Navigate(new LoginPage());
        }
コード例 #23
0
ファイル: ToolBarTrayBinder.cs プロジェクト: brobits/ATF
        /// <summary>
        /// Constructor</summary>
        /// <param name="toolBarTray">ToolBarTray</param>
        /// <param name="toolbarModels">Collection of menus</param>
        public ToolBarTrayBinder(ToolBarTray toolBarTray, ObservableCollection <IMenu> toolbarModels)
        {
            m_toolBarTray = toolBarTray;

            foreach (var toolbarModel in toolbarModels)
            {
                AddToolBar(toolbarModel);
            }

            toolbarModels.CollectionChanged += CollectionCollectionChanged;
        }
コード例 #24
0
ファイル: ToolbarManager.cs プロジェクト: raandree/IseStudio
        public ToolbarManager(IseStudio ise)
        {
            this.ise = ise;

            Func <MainWindow> fnc = delegate() { return(Application.Current.Windows.Cast <MainWindow>().FirstOrDefault(wnd => wnd is MainWindow) as MainWindow); };

            iseWindow = Application.Current.Dispatcher.Invoke(fnc) as MainWindow;

            FieldInfo toolBarTrayField = iseWindow.GetType().GetField("toolBarTray", BindingFlags.Instance | BindingFlags.NonPublic);

            toolBarTray = (ToolBarTray)toolBarTrayField.GetValue(iseWindow);
        }
コード例 #25
0
        private void CreateToolBar()
        {
            ToolBarTray1 = new ToolBarTray()
            {
                Background        = app.Resources["BackgroungBrush"] as Brush,
                Name              = "ToolBarTray1",
                Margin            = new Thickness(0, 18, 0, 0),
                VerticalAlignment = VerticalAlignment.Top
            };
            ToolBarTray1.Loaded += FrameworkElementLoaded;
//
            ToolBar1 = new ToolBar()
            {
                Background               = app.Resources["BackgroungBrush"] as Brush,
                HorizontalAlignment      = HorizontalAlignment.Left,
                VerticalContentAlignment = VerticalAlignment.Center
            };
            ButtonSave = CreateToolBarButton
                         (
                CW.Properties.Resources.Save,
                app.Language.Save,
                app.Language.SaveDescription
                         );
            ToolBar1.Items.Add(ButtonSave);
            ButtonPrint = CreateToolBarButton
                          (
                CW.Properties.Resources.Print,
                app.Language.Print,
                app.Language.PrintDescription
                          );
            ToolBar1.Items.Add(ButtonPrint);
            {
                Button ButtonCopy = CreateToolBarButton
                                    (
                    CW.Properties.Resources.Copy,
                    app.Language.Copy,
                    app.Language.CopyDescription
                                    );
                ButtonCopy.Command = ApplicationCommands.Copy;
                ToolBar1.Items.Add(ButtonCopy);
            }
            ButtonClipboardClear = CreateToolBarButton
                                   (
                CW.Properties.Resources.Clear,
                app.Language.Clear,
                app.Language.ClearDescription
                                   );
            ToolBar1.Items.Add(ButtonClipboardClear);
            ToolBarTray1.ToolBars.Add(ToolBar1);
//
            Grid1.Children.Add(ToolBarTray1);
        }
コード例 #26
0
        /// <summary>
        /// The toolbar tray which will be used in the application
        /// </summary>
        private void RefreshToolbar()
        {
            ToolBarTray tray  = new ToolBarTray();
            IAddChild   child = tray;

            foreach (AbstractCommandable node in _toolbarService.Children)
            {
                if (node is AbstractToolbar value)
                {
                    ToolBar tb = new ToolBar();

                    DataTemplateSelector t = FindResource("toolBarItemTemplateSelector") as DataTemplateSelector;
                    tb.SetValue(ItemsControl.ItemTemplateSelectorProperty, t);

                    //Set the necessary bindings
                    Binding bandBinding       = new Binding("Band");
                    Binding bandIndexBinding  = new Binding("BandIndex");
                    Binding visibilityBinding = new Binding("IsChecked")
                    {
                        Converter = btv
                    };

                    bandBinding.Source       = value;
                    bandIndexBinding.Source  = value;
                    visibilityBinding.Source = value;

                    bandBinding.Mode      = BindingMode.TwoWay;
                    bandIndexBinding.Mode = BindingMode.TwoWay;

                    tb.SetBinding(ToolBar.BandProperty, bandBinding);
                    tb.SetBinding(ToolBar.BandIndexProperty, bandIndexBinding);
                    tb.SetBinding(ToolBar.VisibilityProperty, visibilityBinding);

                    tb.ItemsSource = value.Children;
                    child.AddChild(tb);
                }
            }

            // update context menu if available
            tray.ContextMenu = null;
            if (_toolbarService.ContextMenuItems != null && _toolbarService.ContextMenuItems.Children.Count() > 0)
            {
                // Update Context Menu
                tray.ContextMenu = new ContextMenu
                {
                    ItemsSource        = _toolbarService.ContextMenuItems.Children,
                    ItemContainerStyle = FindResource("ToolbarContextMenu") as Style,
                };
            }

            content.Content = tray;
        }
コード例 #27
0
 public static void MakeToolBarTrayPretty(ToolBarTray toolBarTray)
 {
     if (toolBarTray != null)
     {
         foreach (ToolBar ToolBar in toolBarTray.ToolBars)
         {
             RestoreSeparators(ToolBar);
             HideSeparators(ToolBar, FromTop);
             HideSeparators(ToolBar, FromBottom);
             HideDuplicateSeparators(ToolBar);
         }
     }
 }
コード例 #28
0
ファイル: MoveTheToolbar.cs プロジェクト: FallenEvill/WPF2020
        public MoveTheToolbar()
        {
            Title = "Move the Toolbar";

            // Create DockPanel as content of window.
            DockPanel dock = new DockPanel(); // Новая док-панель, содержимое окна

            Content = dock;

            // Create ToolBarTray at top and left of window.
            ToolBarTray trayTop = new ToolBarTray(); // Новая панель инструментов

            dock.Children.Add(trayTop);              // Присоединение панели инструментов к док панели, вверх окна
            DockPanel.SetDock(trayTop, Dock.Top);

            ToolBarTray trayLeft = new ToolBarTray();

            trayLeft.Orientation = Orientation.Vertical;
            dock.Children.Add(trayLeft); // Присоединение панели инструментов к док панели, влево окна
            DockPanel.SetDock(trayLeft, Dock.Left);

            // Create TextBox to fill rest of client area.
            TextBox txtbox = new TextBox(); // Создание текстового блока для заполнения оставшегося пространства

            dock.Children.Add(txtbox);

            // Create six Toolbars...
            for (int i = 0; i < 6; i++) // Создание 6 элементов панели инструментов
            {
                ToolBar toolbar = new ToolBar();
                toolbar.Header = "Toolbar " + (i + 1);

                if (i < 3)
                {
                    trayTop.ToolBars.Add(toolbar); // Добавление элемента в верхнюю панель
                }
                else
                {
                    trayLeft.ToolBars.Add(toolbar);
                }

                // ... with six buttons each.
                for (int j = 0; j < 6; j++) // Создание кнопок для элементов панели инструментов
                {
                    Button btn = new Button();
                    btn.FontSize = 16;
                    btn.Content  = (char)('A' + j); // Содержимое кнопки
                    toolbar.Items.Add(btn);
                }
            }
        }
コード例 #29
0
ファイル: MoveTheToolbar.cs プロジェクト: mkbiltek2019/refer
        public MoveTheToolbar()
        {
            Title = "Move the Toolbar";

            // Create DockPanel as content of window.
            DockPanel dock = new DockPanel();

            Content = dock;

            // Create ToolBarTray at top and left of window.
            ToolBarTray trayTop = new ToolBarTray();

            dock.Children.Add(trayTop);
            DockPanel.SetDock(trayTop, Dock.Top);

            ToolBarTray trayLeft = new ToolBarTray();

            trayLeft.Orientation = Orientation.Vertical;
            dock.Children.Add(trayLeft);
            DockPanel.SetDock(trayLeft, Dock.Left);

            // Create TextBox to fill rest of client area.
            TextBox txtbox = new TextBox();

            dock.Children.Add(txtbox);

            // Create six Toolbars...
            for (int i = 0; i < 6; i++)
            {
                ToolBar toolbar = new ToolBar();
                toolbar.Header = "Toolbar " + (i + 1);

                if (i < 3)
                {
                    trayTop.ToolBars.Add(toolbar);
                }
                else
                {
                    trayLeft.ToolBars.Add(toolbar);
                }

                // ... with six buttons each.
                for (int j = 0; j < 6; j++)
                {
                    Button btn = new Button();
                    btn.FontSize = 16;
                    btn.Content  = (char)('A' + j);
                    toolbar.Items.Add(btn);
                }
            }
        }
コード例 #30
0
        private void BuildToolBarTray()
        {
            //< File tool bar
            var fileToolBar = new ToolBar("File");

            ToolBarTray.AddToolBar(fileToolBar);

            var fileNewCppProjectToolBarItem =
                new CommandToolBarItem <NewCppProjectCommandDefinition>("File.NewCppProject", true);
            var fileNewCppHeaderToolBarItem
                = new CommandToolBarItem <NewCppHeaderCommandDefinition>("File.NewCppHeader", true);
            var fileNewCppSourceToolBarItem
                = new CommandToolBarItem <NewCppSourceCommandDefinition>("File.NewCppSource", true);
            var fileOpenFileToolBarItem    = new CommandToolBarItem <OpenFileCommandDefinition>("File.OpenFile");
            var fileOpenProjectToolBarItme = new CommandToolBarItem <OpenProjectCommandDefinition>("File.OpenProject");
            var fileSaveToolBarItem        = new CommandToolBarItem <SaveFileCommandDefinition>("File.Save");
            var fileSaveAsToolBarItem      = new CommandToolBarItem <SaveFileAsCommandDefinition>("File.SaveAs");

            ToolBarTray.AddToolBarItem(fileToolBar,
                                       fileNewCppProjectToolBarItem,
                                       fileNewCppHeaderToolBarItem,
                                       fileNewCppSourceToolBarItem,
                                       new ToolBarItemSeparator("File.S1"),
                                       fileOpenFileToolBarItem,
                                       fileOpenProjectToolBarItme,
                                       fileSaveToolBarItem,
                                       fileSaveAsToolBarItem);
            //> File tool bar

            //< Run menu
            var runToolBar = new ToolBar("Run");

            ToolBarTray.AddToolBar(runToolBar);

            var runCompileSingleFileToolBarItem =
                new CommandToolBarItem <CompileSingleFileCommandDefinition>("Run.CompileSingleFile");
            var runRunSingleFileToolBar =
                new CommandToolBarItem <RunSingleFileCommandDefinition>("Run.RunSingleFile");
            var runCompileProjectToolBarItem =
                new CommandToolBarItem <CompileProjectCommandDefinition>("Run.CompileProject");
            var runRunProjectToolBarItem =
                new CommandToolBarItem <RunProjectCommandDefinition>("Run.RunProject");

            ToolBarTray.AddToolBarItem(runToolBar,
                                       runCompileSingleFileToolBarItem,
                                       runRunSingleFileToolBar,
                                       new ToolBarItemSeparator("Run.S1"),
                                       runCompileProjectToolBarItem,
                                       runRunProjectToolBarItem);
            //> Run menu
        }