public ToolbarPositionSettings(IEventAggregator eventAggregator, IShellToolbarService toolbarService)
        {
            eventAggregator.GetEvent <WindowClosingEvent>().Subscribe(SaveToolbarPositions);
            _toolTray = toolbarService as DefaultToolbar;
            _loadDict = new Dictionary <string, ToolbarSettingItem>();

            if (this.Toolbars != null && this.Toolbars.Count > 0)
            {
                foreach (var setting in this.Toolbars)
                {
                    _loadDict[setting.Key] = setting;
                }

                for (int i = 0; i < _toolTray.Children.Count; i++)
                {
                    DefaultToolbar tb = _toolTray.Children[i] as DefaultToolbar;
                    if (_loadDict.ContainsKey(tb.Key))
                    {
                        ToolbarSettingItem item = _loadDict[tb.Key];
                        tb.Band      = item.Band;
                        tb.BandIndex = item.BandIndex;
                        tb.IsChecked = item.IsChecked;
                        tb.Refresh();
                    }
                }
            }
        }
 private void SaveToolbarPositions(Window window)
 {
     this.Toolbars = new List <ToolbarSettingItem>();
     for (int i = 0; i < _toolTray.Children.Count; i++)
     {
         DefaultToolbar tb = _toolTray.Children[i] as DefaultToolbar;
         Toolbars.Add(new ToolbarSettingItem(tb));
     }
     Save();
 }
        /// <summary>
        /// Adds the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns><c>true</c> if successfully added, <c>false</c> otherwise</returns>
        public override string Add(Commandable item)
        {
            DefaultToolbar tb = item as DefaultToolbar;

            if (tb != null)
            {
                tb.IsCheckable = true;
                tb.IsChecked   = true;
            }
            return(base.Add(item));
        }