public View(IImport dl, IDeclineData d, IMethod m, IChart c, IExport e) { dataImport = dl; declineData = d; method = m; chart = c; dataExport = e; dataView = new SortedDictionary <DateTime, double>(); }
private void buttonImportData_Click(object sender, EventArgs e) { //clear past plots if there is Clear(); //protection from fool EnableControls(false); string importDir = "D:\\MyYandexDisk\\YandexDisk\\CUSUM\\Practice2017\\" + textBoxImportFileName.Text; string exportDir = "D:\\MyYandexDisk\\YandexDisk\\CUSUM\\Practice2017\\" + textBoxExportFileName.Text; IDeclineData declineDataC = null; IDeclineData declineDataP = null; bool IsOpenExportFile = checkBoxOpenExportFile.Checked; double N = Convert.ToDouble(labelN.Text); double b = Convert.ToDouble(labelB.Text); int k = Convert.ToInt32(textBoxParamK.Text); IMethod methodCusum = new MethodCusum(N, b, k); //add noise if need if (checkBoxNoise.Checked) { declineDataC = new NoiseDecline(); declineDataP = new NoiseDecline(); } viewCusum = new View(new ImportExcel(importDir), declineDataC, methodCusum, new ChartOxiPlot(this, new Point(520, 40), new Point(500, 400), methodCusum.NameForSeries), new ExportExcel(exportDir, IsOpenExportFile)); viewPressure = new View(new ImportExcel(importDir), declineDataP, null, new ChartOxiPlot(this, new Point(10, 40), new Point(500, 400), null), new ExportExcel(exportDir, IsOpenExportFile)); //for not blocking UI-thread Task[] tasksView = new Task[2] { new Task(() => { viewPressure.ShowResults(); }), new Task(() => { viewCusum.ShowResults(); }), }; foreach (var item in tasksView) { item.Start(); } //wait ending work tasks Task taskWait = new Task(() => { Task.WaitAll(tasksView); EnableControls(true); }); taskWait.Start(); }