コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            MainFinishedBlock = new ObservableCollection <IChart>();
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}
            //These commands are used in the main menu stuff.  Its where we are going to stick most of our secondary functions
            StartChartBuilderCommand = new RelayCommand(() => Dialogs.ActivateChartBuilder());

            //These commands and this command pipe is for code relating to loading and parseing charts
            LoadCommand   = new RelayCommand(() => FoundCharts = PipeAssessor.PrePipe.LoadCommand());
            RollCommand   = new RelayCommand(() => MainFinishedBlock = new ObservableCollection <IChart>(PipeAssessor.PrePipe.RollOneCommand(SelectedCharts)));
            LocateCommand = new RelayCommand(() => { PipeAssessor.PrePipe.AddTablesToRepo(); LoadCommand.Execute(null); });
            DeleteCommand = new RelayCommand(() => { PipeAssessor.PrePipe.DeleteTableCommand(SelectedCharts); LoadCommand.Execute(null); });
            OpenContainingFoldersCommand = new RelayCommand(() => PipeAssessor.PrePipe.OpenFileLocation(SelectedCharts));
            OpenFileCommand = new RelayCommand(() => PipeAssessor.PrePipe.OpenFile(SelectedCharts));
            //end of pre commands


            //The Commmands are releated to AFTER we have data and its parsed
            SaveToFileCommand         = new RelayCommand(() => PipeAssessor.PostPipe.SaveChartCommand((Chart)MainFinishedBlock.FirstOrDefault()));
            AddToFileCommand          = new RelayCommand(() => PipeAssessor.PostPipe.AddToChartCommand((Chart)MainFinishedBlock.FirstOrDefault()));
            SaveSelectedToFileCommand = new RelayCommand(() => PipeAssessor.PostPipe.SaveSelectedChartCommand(GetSelected()));
            AddSelectedToFileCommand  = new RelayCommand(() => PipeAssessor.PostPipe.AddSelectedToChartCommand(GetSelected()));
            //end of postcommand pipe

            //When main is populated we want to load up the tables
            LoadCommand.Execute(null);
        }