예제 #1
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            BarsPositions pos = Properties.Settings.Default.BarsPositions;

            if (pos != null)
            {
                for (int i = 0; i < toolBar.ToolBars.Count; i++)
                {
                    toolBar.ToolBars[i].Band      = pos[i].Band;
                    toolBar.ToolBars[i].BandIndex = pos[i].BandIndex;
                }
            }

            profiles = Properties.Settings.Default.Profiles;
            if (profiles == null)
            {
                CreatePofiles();
            }

            // Создать меню выбора профилей
            CreateSelectMenu();

            document = (Document)FindResource("doc");   // найти документ как ресурс окна
            // применить текущий профиль к документу
            DocumentSetProfile(profiles.CurrentProfile);
        }
예제 #2
0
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            //Удалить события связанные с коллекцией профилей
            profiles.PropertyChanged   -= onProfilesChange;
            profiles.CollectionChanged -= onCollectionChanged;

            //создать новый двоичный форматер
            try
            {
                Properties.Settings.Default.Profiles = profiles;
                BarsPositions pos = new BarsPositions();
                foreach (ToolBar bar in toolBar.ToolBars)
                {
                    pos.Add(new ToolBarPosition(bar.Band, bar.BandIndex));
                }
                Properties.Settings.Default.BarsPositions = pos;
                Properties.Settings.Default.Save();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Properties.Resources.msgSaveProfErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public ToolbarPositionEnumerator(BarsPositions collection)
 {
     this.collection = collection;
     curIndex        = -1;
     curPos          = default(ToolBarPosition);
 }