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();
                    }
                }
            }
        }
Esempio n. 2
0
        public override bool Equals(object obj)
        {
            ToolbarSettingItem item = obj as ToolbarSettingItem;

            return((item != null) && Key.Equals(item.Key));
        }