コード例 #1
0
        void LoadFile()
        {
            string filename = Utils.GetFile();

            if (filename.Length < 1)
            {
                return;
            }

            FileIsLoading = true;

            try
            {
                worker = new BackgroundWorker();
                worker.WorkerReportsProgress = true;

                DataRepository repository
                    = new DataRepository(filename, DataSourceType.CSV);


                repository.FileOpening += new DataRepository.FileProgressEventHandler(repository_UpdateProgress);
                repository.FileLoading += new DataRepository.FileProgressEventHandler(repository_UpdateProgress);
                repository.FileLoaded  += new DataRepository.FileProgressEventHandler(repository_UpdateProgress);


                worker.DoWork += delegate(object sender, DoWorkEventArgs args)
                {
                    DataTable data = repository.GetAllData();

                    SessionColumnCollection collection = new SessionColumnCollection(data);
                    if (!sessionCollections.Contains(collection))
                    {
                        sessionCollections.Add(collection);
                    }
                    //need a better way to convert this collection to multithreaded oibservable
                    ObservableCollection <ISessionColumn> colClxn = new MultiThreadObservableCollection <ISessionColumn>();
                    foreach (SessionColumn sc in collection.Columns)
                    {
                        colClxn.Add(sc);
                    }
                    collection.Columns = colClxn;
                    if (MainWorkSpace != null)
                    {
                        this.Dispatcher.Invoke(DispatcherPriority.DataBind, new Action
                                               (
                                                   delegate()
                        {
                            MainWorkSpace = new ProcessingViewModel(sessionCollections);
                        }));
                    }

                    FileIsLoading = false;
                };

                worker.RunWorkerAsync();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #2
0
 public FileViewModel()
 {
     MainWorkSpace = new ProcessingViewModel();
 }
コード例 #3
0
        void ShowProcessingView()
        {
            ProcessingViewModel processingview = new ProcessingViewModel();

            MainWorkSpace = processingview;
        }