public ProcessingViewModel() { WorkSpace = new AllConfigsViewModel(); SingleConfigViewModel scvm = new SingleConfigViewModel(null); WorkSpace.Configs.Add(scvm); }
void OnWorkspaceRequestClose(object sender, EventArgs e) { SingleConfigViewModel workspace = sender as SingleConfigViewModel; workspace.Dispose(); this.Configs.Remove(workspace); }
public AllConfigsViewModel(List <SessionColumnCollection> Collections) { foreach (SessionColumnCollection collection in Collections) { SingleConfigViewModel sccv = new SingleConfigViewModel(collection); if (!Configs.Contains(sccv)) { Configs.Add(sccv); } } }
void LoadFile() { Filename = WindART.Utils.GetFile(); if (Filename.Length < 1) { return; } FileIsLoading = true; if (AllConfigsVM == null) { AllConfigsVM = new AllConfigsViewModel(); } Workspace = AllConfigsVM; 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(); SingleConfigViewModel thisConfig = new SingleConfigViewModel(new SessionColumnCollection(data), data); thisConfig.DisplayName = Path.GetFileNameWithoutExtension(Filename); this.Dispatcher.Invoke(DispatcherPriority.DataBind, new Action ( delegate() { AllConfigsVM.Configs.Add(thisConfig); })); //need a better way to convert this collection to multithreaded oibservable ObservableCollection <ISessionColumn> colClxn = new MultiThreadObservableCollection <ISessionColumn>(); foreach (SessionColumn sc in thisConfig.ColumnCollection.Columns) { colClxn.Add(sc); } //add to an observable collection thisConfig.LiveCollection = colClxn; FileIsLoading = false; }; worker.RunWorkerAsync(); } catch (Exception e) { throw e; } }