Beispiel #1
0
        public MainView()
        {
            InitializeComponent();
            DataContext = _viewmodel;

            Loaded += (sender, args) =>
            {
                if (_viewmodel.SettingsTabViewModel.ShowWelcomeTabOnStart)
                {
                    _viewmodel.ShowTab(_viewmodel.WelcomeTabViewModel);
                }
            };

            _viewmodel.ChartTabViewModels.CollectionChanged += ChartTabsCollectionChanged;
            var tabViewSource = CollectionViewSource.GetDefaultView(TabControl.Items);

            tabViewSource.CollectionChanged += (sender, args) =>
            {
                if (args.Action == NotifyCollectionChangedAction.Add)
                {
                    TabControl.SelectedIndex = _viewmodel.Tabs.Count - 1;
                }
            };

            _menuItemBottomMargin = (Thickness)ShowMenu.FindResource("MenuItemBottomMargin");

            _viewmodel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(_viewmodel.TabToSelect))
                {
                    if (TabControl.SelectedItem == _viewmodel.TabToSelect)
                    {
                        BringCurrentTabIntoView();
                    }
                    else
                    {
                        TabControl.SelectedItem = _viewmodel.TabToSelect;
                    }
                }
            };
        }
Beispiel #2
0
        public MainView()
        {
            InitializeComponent();
            DataContext = _viewmodel;
            Loaded     += (sender, args) =>
            {
                if (_viewmodel.SettingsTabViewModel.ShowWelcomeTabOnStart)
                {
                    _viewmodel.ShowTab(_viewmodel.WelcomeTabViewModel);
                }
            };
            _menuItemBottomMargin = (Thickness)ShowMenu.FindResource("MenuItemBottomMargin");

            _viewmodel.PartialUtilityTabViewModels.CollectionChanged += PartialUtilityTabsCollectionChanged;

            var tabViewSource = CollectionViewSource.GetDefaultView(TabControl.Items);

            tabViewSource.CollectionChanged += (sender, args) =>
            {
                if (args.Action == NotifyCollectionChangedAction.Add)
                {
                    TabControl.SelectedIndex = _viewmodel.Tabs.Count - 1;
                }
            };

            _viewmodel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(_viewmodel.TabToSelect))
                {
                    if (TabControl.SelectedItem == _viewmodel.TabToSelect)
                    {
                        BringCurrentTabIntoView();
                    }
                    else
                    {
                        TabControl.SelectedItem = _viewmodel.TabToSelect;
                    }
                }
                else if (e.PropertyName == nameof(_viewmodel.CoefficientAssessmentTabViewModel))
                {
                    CoefficientAssessmentTabPropertyChanged();
                }
            };

            _viewmodel.Results.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName != nameof(_viewmodel.Results.K))
                {
                    return;
                }
                if (_viewmodel.Results.K.HasValue)
                {
                    var width    = ((GridLength)MainViewGrid.FindResource("RightPanelWidth")).Value;
                    var minWidth = (double)MainViewGrid.FindResource("RightPanelMinWidth");
                    MainViewGrid.ColumnDefinitions[4].Width    = new GridLength(width);
                    MainViewGrid.ColumnDefinitions[4].MinWidth = minWidth;
                    TabsResultsGridSplitter.Visibility         = Visibility.Visible;
                    ResultsPanelMenuItem.IsChecked             = true;
                }
                else
                {
                    MainViewGrid.ColumnDefinitions[4].MinWidth = 0;
                    MainViewGrid.ColumnDefinitions[4].Width    = new GridLength(0);
                    TabsResultsGridSplitter.Visibility         = Visibility.Collapsed;
                    ResultsPanelMenuItem.IsChecked             = false;
                }
            };
        }