Exemplo n.º 1
0
        /*
         *  Show Toolbar by:
         *      Check for:
         *          At least one tray exists
         *      Decide Dock
         *      Add Toolbar to tray
         */

        private void ShowToolBar(ToolBar toolBar, Dock dock)
        {
            if (TopToolBarTay == null || LeftToolBarTay == null || RightToolBarTay == null ||
                BottomToolBarTay == null)
            {
                throw new NullReferenceException("Could not find all 4 ToolbarTrays");
            }
            switch (dock)
            {
            case Dock.Top:
                TopToolBarTay.AddToolBar(toolBar);
                break;

            case Dock.Left:
                LeftToolBarTay.AddToolBar(toolBar);
                break;

            case Dock.Right:
                RightToolBarTay.AddToolBar(toolBar);
                break;

            default:
                BottomToolBarTay.AddToolBar(toolBar);
                break;
            }
        }
 private CheckableListBoxItem CreateItem(ToolBar toolBar)
 {
     var item = new CheckableListBoxItem
     {
         Content = toolBar.IdentifierName,
         DataContext = toolBar,
         IsChecked = ToolBarHostViewModel.GetToolBarVisibility(toolBar.IdentifierName),
     };
     item.Checked += OnItemChecked;
     item.Unchecked += OnItemUnchecked;
     return item;
 }
        private CheckableListBoxItem CreateItem(ToolBar toolBar)
        {
            var item = new CheckableListBoxItem
            {
                Content     = toolBar.IdentifierName,
                DataContext = toolBar,
                IsChecked   = ToolBarHostViewModel.GetToolBarVisibility(toolBar.IdentifierName),
            };

            item.Checked   += OnItemChecked;
            item.Unchecked += OnItemUnchecked;
            return(item);
        }
Exemplo n.º 4
0
        /*
         *  This adds a new toolbar by:
         *      Checking for:
         *          Not Null Object
         *          ObjectID not null
         *          Not Existing already
         *      Creating a new ContextMenuItem for it
         *      Adds to Dictionary
         *      If visible param is true
         *          Show Toolbar on screen
         */

        /// <summary>
        /// Adds new Toolbar to HostControl
        /// </summary>
        /// <param name="toolBar">Toolbar object</param>
        /// <param name="visible">Toolbar visibility</param>
        /// <param name="dock">Toolbar orientation</param>
        public void AddToolBar(ToolBar toolBar, bool visible, Dock dock)
        {
            if (toolBar == null)
            {
                throw new ArgumentNullException(nameof(toolBar));
            }
            if (string.IsNullOrEmpty(toolBar.IdentifierName))
            {
                throw new NullReferenceException("Toolbar Id must not be null");
            }
            if (_contextList.ContainsKey(toolBar.IdentifierName))
            {
                throw new ToolBarAlreadyExistsException();
            }
            var item = CreateContextMenuItem(toolBar.IdentifierName);

            _contextList.Add(toolBar.IdentifierName,
                             new Tuple <ToolBar, Dock, bool, ContextMenuGlyphItem>(toolBar, dock, visible, item));
            if (!visible)
            {
                return;
            }
            ShowToolBarByName(toolBar.IdentifierName);
        }
        /*
            Show Toolbar by:
                Check for:
                    At least one tray exists
                Decide Dock
                Add Toolbar to tray
        */

        private void ShowToolBar(ToolBar toolBar, Dock dock)
        {
            if (TopToolBarTay == null || LeftToolBarTay == null || RightToolBarTay == null ||
                BottomToolBarTay == null)
                throw new NullReferenceException("Could not find all 4 ToolbarTrays");
            switch (dock)
            {
                case Dock.Top:
                    TopToolBarTay.AddToolBar(toolBar);
                    break;
                case Dock.Left:
                    LeftToolBarTay.AddToolBar(toolBar);
                    break;
                case Dock.Right:
                    RightToolBarTay.AddToolBar(toolBar);
                    break;
                default:
                    BottomToolBarTay.AddToolBar(toolBar);
                    break;
            }
        }
        /*
            This adds a new toolbar by:
                Checking for:
                    Not Null Object
                    ObjectID not null
                    Not Existing already
                Creating a new ContextMenuItem for it
                Adds to Dictionary
                If visible param is true
                    Show Toolbar on screen
        */

        /// <summary>
        /// Adds new Toolbar to HostControl
        /// </summary>
        /// <param name="toolBar">Toolbar object</param>
        /// <param name="visible">Toolbar visibility</param>
        /// <param name="dock">Toolbar orientation</param>
        public void AddToolBar(ToolBar toolBar, bool visible, Dock dock)
        {
            if (toolBar == null)
                throw new ArgumentNullException(nameof(toolBar));
            if (string.IsNullOrEmpty(toolBar.IdentifierName))
                throw new NullReferenceException("Toolbar Id must not be null");
            if (_contextList.ContainsKey(toolBar.IdentifierName))
                throw new ToolBarAlreadyExistsException();
            var item = CreateContextMenuItem(toolBar.IdentifierName);
            _contextList.Add(toolBar.IdentifierName,
                new Tuple<ToolBar, Dock, bool, ContextMenuGlyphItem>(toolBar, dock, visible, item));
            if (!visible)
                return;
            ShowToolBarByName(toolBar.IdentifierName);
        }
 public void RemoveToolBar(ToolBar toolBar)
 {
     if (!ToolBars.Contains(toolBar))
         return;
     ToolBars.Remove(toolBar);
 }
 public void AddToolBar(ToolBar toolBar)
 {
     if (ToolBars.Contains(toolBar))
         return;
     ToolBars.Add(toolBar);
 }