示例#1
0
        void CreatePages()
        {
            var DesignPageVM = new DesignPageViewModel(_dataProvider, _neuralNetwork);
            var TrainingPageVM = new TrainingPageViewModel(_dataProvider, _neuralNetwork);
            var TestingPageVM = new TestingPageViewModel(_dataProvider, _neuralNetwork);
            var CalculatePageVM = new CalculatePageViewModel(_dataProvider, _neuralNetwork);

            var pages = new List<PageViewModelBase>();

            pages.Add(DesignPageVM);
            pages[0].CommandToolBar = DesignPageVM.CommandToolBar;
            pages.Add(TrainingPageVM);
            pages[1].CommandToolBar = TrainingPageVM.CommandToolBar;
            pages.Add(TestingPageVM);
            pages[2].CommandToolBar = TestingPageVM.CommandToolBar;
            pages.Add(CalculatePageVM);
            pages[3].CommandToolBar = CalculatePageVM.CommandToolBar;

            _pages = new ReadOnlyCollection<PageViewModelBase>(pages);
        }
        private void OnViewModelPageChange(object sender, EventArgs e)
        {
            Debug.WriteLine("OnViewModelPageChange"+ ": " + pageViewModel.CurrentPage.DisplayName.ToString());

            switch (pageViewModel.CurrentPage.DisplayName)
            {
                case "Training":
                    if (learningPageViewModel == null)
                    {
                        learningPageViewModel = MainView.PageContentControl.Content as TrainingPageViewModel;
                        learningPageViewModel.Start += this.OnViewModelStart;
                        learningPageViewModel.Stop += this.OnViewModelStop;
                        learningPageViewModel.Editor += this.OnViewModelEditor;
                    }

                    (MainView.DataContext as PageViewModel).CommandToolBar[0].IsEnabled = true;
                    (MainView.DataContext as PageViewModel).CommandToolBar[1].IsEnabled = false;
                    (MainView.DataContext as PageViewModel).CommandToolBar[2].IsEnabled = true;
                    break;

                case "Testing":
                    if (testingPageViewModel == null)
                    {
                        testingPageViewModel = MainView.PageContentControl.Content as TestingPageViewModel;
                        testingPageViewModel.Start += this.OnViewModelStart;
                        testingPageViewModel.Stop += this.OnViewModelStop;
                    }

                    (MainView.DataContext as PageViewModel).CommandToolBar[0].IsEnabled = true;
                    (MainView.DataContext as PageViewModel).CommandToolBar[1].IsEnabled = false;

                    if (testingPageViewModel.SelectedTabIndex == -1)
                        testingPageViewModel.SelectedTabIndex = 0;
                    break;

                case "Calculate":
                    if (calculatePageViewModel == null)
                    {
                        calculatePageViewModel = MainView.PageContentControl.Content as CalculatePageViewModel;
                        calculatePageViewModel.Calculate  += this.OnViewModelCalculate;
                    }

                    (MainView.DataContext as PageViewModel).CommandToolBar[0].IsEnabled = true;

                    if (calculatePageViewModel.SelectedTabIndex == -1)
                        calculatePageViewModel.SelectedTabIndex = 0;
                    break;

                case "Design":
                    if (designPageViewModel == null)
                        designPageViewModel = MainView.PageContentControl.Content as DesignPageViewModel;

                    if (needRefreshWeightsView)
                        RefreshWeightsView();

                    if (designPageViewModel.SelectedTabIndex == -1)
                        designPageViewModel.SelectedTabIndex = 0;
                    break;
            }
        }