private void buttonSelect_Click(object sender, EventArgs e) { RichTextBox currFilenameTextbox = rtbFromPath; if (sender == btnFromPathSelect) { currFilenameTextbox = rtbFromPath; } else if (sender == btnToPathSelect) { currFilenameTextbox = rtbToPath; } else if (sender == btnConcurrentDataPathSelect) { currFilenameTextbox = rtbConcurrentDataDir; } else if (sender == btnStatsDirPathSelect) { currFilenameTextbox = rtbGrIxYRGBstatsDir; } FolderBrowserDialog opFD = new FolderBrowserDialog(); opFD.ShowNewFolderButton = true; opFD.SelectedPath = Directory.GetCurrentDirectory(); DialogResult dialogRes = opFD.ShowDialog(); if (dialogRes == DialogResult.OK) { String pathName = opFD.SelectedPath; //FileInfo fInfo = new FileInfo(filename); ThreadSafeOperations.SetTextTB(currFilenameTextbox, pathName, false); } }
private void SendCommandDev2() { currCommand = textBoxCommand2.Text.Trim().Replace("\0", string.Empty); if (currCommand.Length == 0) { return; } ThreadSafeOperations.SetTextTB(textBoxCommand2, "", false); ThreadSafeOperations.SetTextTB(tbResponseLog2, ">>> " + currCommand + Environment.NewLine, true); PerformSendCommand(2); }
private void btnCancelWaitingResponse_Click(object sender, EventArgs e) { currCommand = textBoxCommand1.Text.Trim().Replace("\0", string.Empty); if (currCommand.Length == 0) { return; } ThreadSafeOperations.SetTextTB(textBoxCommand1, "", false); ThreadSafeOperations.SetTextTB(tbResponseLog1, ">>> " + currCommand + Environment.NewLine, true); PerformSendCommand(); }
private void btnSelectVesselNavDataDirectory_Click(object sender, EventArgs e) { RichTextBox currFilenameTextbox = rtbVesselNavDataDirectoryPath; FolderBrowserDialog opFD = new FolderBrowserDialog(); opFD.ShowNewFolderButton = true; opFD.SelectedPath = Directory.GetCurrentDirectory(); DialogResult dialogRes = opFD.ShowDialog(); if (dialogRes == DialogResult.OK) { String pathName = opFD.SelectedPath; ThreadSafeOperations.SetTextTB(currFilenameTextbox, pathName, false); } }
public void Note(string text, TextBox tb2update) { ThreadSafeOperations.SetTextTB(tb2update, text + Environment.NewLine, true); if ((tb2update == tbBcstListeningLog) && (tb2update.Lines.Length > Settings.Default.BroadcastLogHistorySizeLines)) { swapBcstLog(); Note(text, tb2update); } if ((tb2update == tbResponseLog1) && (tb2update.Lines.Length > Settings.Default.BroadcastLogHistorySizeLines)) { swapResponseLog(btnSwapResponseLog1); Note(text, tb2update); } }
private void swapBcstLog() { string filename1; string strtowrite; byte[] info2write; filename1 = Directory.GetCurrentDirectory() + "\\BcstLog-" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + ".log"; FileStream dataFile = new FileStream(filename1, FileMode.Append, FileAccess.Write); strtowrite = tbBcstListeningLog.Text; info2write = new UTF8Encoding(true).GetBytes(strtowrite); dataFile.Write(info2write, 0, info2write.Length); dataFile.Close(); ThreadSafeOperations.SetTextTB(tbBcstListeningLog, "", false); }
private void swapResponseLog(object sender) { string filename1; string strtowrite; byte[] info2write; int curDevID = 1; if (sender == btnSwapResponseLog1) { curDevID = 1; } else if (sender == btnSwapResponseLog2) { curDevID = 2; } filename1 = Directory.GetCurrentDirectory() + "\\ResponseLog-" + "devID" + curDevID + "-" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + ".log"; ServiceTools.logToTextFile(filename1, tbResponseLog1.Text, true); ThreadSafeOperations.SetTextTB(tbResponseLog1, "", false); }
//private bool testAnIpAddress(IPAddress testingIPaddr) //{ // bool retVal = false; // Ping ping; // string retStr = "areyouarduino"; // byte[] ret = System.Text.Encoding.ASCII.GetBytes(retStr); // string returnData = ""; // Socket Skt = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); // Skt.EnableBroadcast = false; // Skt.ReceiveTimeout = 10; // Skt.SendTimeout = 10; // //string testingIP = "192.168.192." + i.ToString();//!!!!!!!!!!!!!!!!!!!!!! определить подсеть по текущему IP и маске // //testingIPaddr = IPAddress.Parse(testingIP); // // ping = new Ping(); // PingReply repl = ping.Send(testingIPaddr, 3, new byte[] { 1 }, new PingOptions(1, true)); // // if ((repl.Status == IPStatus.TtlExpired) || (repl.Status == IPStatus.TimedOut) || (repl.Status == IPStatus.TimeExceeded)) // { // returnData = "ping timeout or not reachable"; // retVal = false; // } // else // { // IPEndPoint test = new IPEndPoint(testingIPaddr, 5555); // int sent = Skt.SendTo(ret, test); // // Blocks until a message returns on this socket from a remote host. // Byte[] receiveBytes = new byte[128]; // IPEndPoint sender_ = new IPEndPoint(IPAddress.Any, 0); // EndPoint senderRemote = (EndPoint)sender_; // // try // { // Skt.ReceiveFrom(receiveBytes, ref senderRemote); // returnData = Encoding.UTF8.GetString(receiveBytes).Trim().Replace("\0", string.Empty); // } // catch (Exception ex) // { // returnData = ex.Message; // //throw; // } // } // // SetTextTB(textBox1, "tested ip " + testingIPaddr.ToString() + ": " + returnData.ToString() + Environment.NewLine, true); // Skt.Close(); // if (returnData.ToString() == "YES") retVal = true; else retVal = false; // // return retVal; //} //private void arduinoBoardSearchingWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) //{ // //SetTextTB(textBox1, "Данные датчиков собраны " + e.ProgressPercentage + " раз" + Environment.NewLine, true); // UpdateProgressBar(progressBar1, e.ProgressPercentage); //} private void Form1_Load(object sender, EventArgs e) { string generalSettingsFilename = Directory.GetCurrentDirectory() + "\\settings\\ArduinoUDPconversationAppGeneralSettings2G.xml"; if (!File.Exists(generalSettingsFilename)) { ip2ListenDevID1 = Settings.Default.ArduinoBoardDefaultIP; port2converse = Settings.Default.ArduinoBoardDefaultUDPport; ThreadSafeOperations.SetTextTB(tbDev1IPstr, ip2ListenDevID1, false); } else { Dictionary <string, object> generalSettings = ServiceTools.ReadDictionaryFromXML(generalSettingsFilename); ip2ListenDevID1 = generalSettings["ArduinoBoardID1DefaultIP"] as string; ip2ListenDevID2 = generalSettings["ArduinoBoardID2DefaultIP"] as string; port2converse = Convert.ToInt32(generalSettings["ArduinoBoardDefaultUDPport"]); portBcstRecvng = Convert.ToInt32(generalSettings["UDPBroadcastDefaultListeningPort"]); ThreadSafeOperations.SetTextTB(tbDev1IPstr, ip2ListenDevID1, false); ThreadSafeOperations.SetTextTB(tbDev2IPstr, ip2ListenDevID2, false); } }
private void readDefaultProperties() { defaultProperties = new Dictionary <string, object>(); defaultPropertiesXMLfileName = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "settings" + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location) + "-Settings.xml"; if (File.Exists(defaultPropertiesXMLfileName)) { defaultProperties = ServiceTools.ReadDictionaryFromXML(defaultPropertiesXMLfileName); } bool bDefaultPropertiesHasBeenUpdated = false; string curDir = Directory.GetCurrentDirectory(); #region ImagesBaseSourcePath if (defaultProperties.ContainsKey("ImagesBaseSourcePath")) { ImagesBaseSourcePath = (string)defaultProperties["ImagesBaseSourcePath"]; } else { ImagesBaseSourcePath = curDir; defaultProperties.Add("ImagesBaseSourcePath", ImagesBaseSourcePath); bDefaultPropertiesHasBeenUpdated = true; } ThreadSafeOperations.SetTextTB(rtbImagesBaseSourcePath, ImagesBaseSourcePath, false); #endregion ImagesBaseSourcePath #region ConcurrentAndStatsXMLfilesDir if (defaultProperties.ContainsKey("ConcurrentAndStatsXMLfilesDir")) { ConcurrentAndStatsXMLfilesDir = (string)defaultProperties["ConcurrentAndStatsXMLfilesDir"]; } else { ConcurrentAndStatsXMLfilesDir = curDir; defaultProperties.Add("ConcurrentAndStatsXMLfilesDir", ConcurrentAndStatsXMLfilesDir); bDefaultPropertiesHasBeenUpdated = true; } ThreadSafeOperations.SetTextTB(rtbConcurrentAndStatsXMLfilesDir, ConcurrentAndStatsXMLfilesDir, false); #endregion ConcurrentAndStatsXMLfilesDir #region ObservedDataCSVfile if (defaultProperties.ContainsKey("ObservedDataCSVfile")) { ObservedDataCSVfile = (string)defaultProperties["ObservedDataCSVfile"]; } else { ObservedDataCSVfile = curDir; defaultProperties.Add("ObservedDataCSVfile", ObservedDataCSVfile); bDefaultPropertiesHasBeenUpdated = true; } ThreadSafeOperations.SetTextTB(rtbObservedDataCSVfile, ObservedDataCSVfile, false); #endregion ObservedDataCSVfile #region DestinationPath if (defaultProperties.ContainsKey("DestinationPath")) { DestinationPath = (string)defaultProperties["DestinationPath"]; } else { DestinationPath = curDir; defaultProperties.Add("DestinationPath", DestinationPath); bDefaultPropertiesHasBeenUpdated = true; } ThreadSafeOperations.SetTextTB(rtbDestinationPath, DestinationPath, false); #endregion DestinationPath #region DateTimeFilterTolerance if (defaultProperties.ContainsKey("DateTimeFilterTolerance")) { DateTimeFilterTolerance = TimeSpan.Parse((string)defaultProperties["DateTimeFilterTolerance"]); } else { defaultProperties.Add("DateTimeFilterTolerance", DateTimeFilterTolerance.ToString()); bDefaultPropertiesHasBeenUpdated = true; } #endregion DateTimeFilterTolerance if (bDefaultPropertiesHasBeenUpdated) { saveDefaultProperties(); } }
private void bgwUDPmessagesParser_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker selfWorker = sender as BackgroundWorker; while (true) { if (selfWorker.CancellationPending && cquArduinoUDPCatchedMessages.Count == 0) { break; } if (cquArduinoUDPCatchedMessages.Count == 0) { Application.DoEvents(); Thread.Sleep(0); continue; } if (cquArduinoUDPCatchedMessages.Count > 0) { IncomingUDPmessageBoundle curMessageBoundle = null; //cquArduinoUDPCatchedMessages.Dequeue(); while (true) { if (cquArduinoUDPCatchedMessages.TryDequeue(out curMessageBoundle)) { break; } else { Application.DoEvents(); Thread.Sleep(0); continue; } } if (curMessageBoundle == null) { continue; } string bcstMessage = curMessageBoundle.udpMessage; int currMessageDevID = curMessageBoundle.devID; bool whetherContinueProcessThisMessage = true; if (curMessageBoundle.isPartOfMessage) { whetherContinueProcessThisMessage = false; IncomingUDPmessagesBoundlesTuple tplSrch = null; List <IncomingUDPmessagesBoundlesTuple> currTuples = new List <IncomingUDPmessagesBoundlesTuple>(cbArduinoMessagesTuples); tplSrch = currTuples.Find( tpl => ((tpl.devID == curMessageBoundle.devID) && (tpl.mID == curMessageBoundle.mID))); //try //{ // tplSrch = cbArduinoMessagesTuples.First(tpl => ((tpl.devID == curMessageBoundle.devID) && (tpl.mID == curMessageBoundle.mID))); //} //catch (Exception ex) //{ // if (ex.GetType() == typeof(InvalidOperationException)) // { // tplSrch = null; // } //} if (tplSrch == null) { tplSrch = new IncomingUDPmessagesBoundlesTuple(curMessageBoundle); cbArduinoMessagesTuples.Add(tplSrch); whetherContinueProcessThisMessage = false; } else { tplSrch = tplSrch + curMessageBoundle; if (tplSrch.IsComplete) { whetherContinueProcessThisMessage = true; curMessageBoundle = tplSrch.CompleteMessage; while (!cbArduinoMessagesTuples.TryTake(out tplSrch)) { Application.DoEvents(); Thread.Sleep(0); } } } } if (!whetherContinueProcessThisMessage) { continue; } if (curMessageBoundle.isReplyMessage) { //bcstMessage = bcstMessage.Substring(6, bcstMessage.Length - 6); if (currMessageDevID == 1) { Note("devID:" + currMessageDevID + " | " + curMessageBoundle.udpMessage, tbResponseLog1); } else if (currMessageDevID == 2) { Note("devID:" + currMessageDevID + " | " + curMessageBoundle.udpMessage, tbResponseLog2); } else { Note(curMessageBoundle.udpMessage); } //udpMessage = bcstMessage; } //else if (curMessageBoundle.isErrorMessage) //{ // if (currMessageDevID == 1) // { // Note("devID:" + currMessageDevID + " | " + "ERROR: " + bcstMessage, tbResponseLog1); // } // else if (currMessageDevID == 2) // { // Note("devID:" + currMessageDevID + " | " + "ERROR: " + bcstMessage, tbResponseLog2); // } // else // { // Note("ERROR: " + bcstMessage); // } //} else if (((curMessageBoundle.udpMessage.Length >= 6) && (curMessageBoundle.udpMessage.Substring(0, 5) == "timer:"))) { if (currMessageDevID > 0) { Note("devID:" + currMessageDevID + " | " + curMessageBoundle.udpMessage, tbBcstListeningLog); } else { Note(curMessageBoundle.udpMessage, tbBcstListeningLog); } } else if (curMessageBoundle.udpMessage == "imarduino") { if ((needsToDiscoverArduinoBoardID1) && (currMessageDevID == 1)) { string addrStr = curMessageBoundle.ipAddrString; ThreadSafeOperations.SetTextTB(tbDev1IPstr, addrStr, false); needsToDiscoverArduinoBoardID1 = false; } if ((needsToDiscoverArduinoBoardID2) && (currMessageDevID == 2)) { string addrStr = curMessageBoundle.ipAddrString; ThreadSafeOperations.SetTextTB(tbDev2IPstr, addrStr, false); needsToDiscoverArduinoBoardID2 = false; } } else { if ((!needsToDiscoverArduinoBoardID1) && (!needsToDiscoverArduinoBoardID2)) { if (currMessageDevID > 0) { Note("devID:" + currMessageDevID + " | " + curMessageBoundle.udpMessage, tbBcstListeningLog); } else { Note(curMessageBoundle.udpMessage, tbBcstListeningLog); } } } } else { Application.DoEvents(); Thread.Sleep(0); } } }
public void Note(string text) { ThreadSafeOperations.SetTextTB(tbResponseLog1, text + Environment.NewLine, true); }
private void readDefaultProperties() { defaultProperties = new Dictionary <string, object>(); defaultPropertiesXMLfileName = Directory.GetCurrentDirectory() + "\\settings\\SeaTripdataAnalysisApp-Settings.xml"; if (!File.Exists(defaultPropertiesXMLfileName)) { defaultProperties = new Dictionary <string, object>(); defaultProperties.Add("DefaultExportDestinationDirectory", Directory.GetCurrentDirectory()); saveDefaultProperties(); } defaultProperties = ServiceTools.ReadDictionaryFromXML(defaultPropertiesXMLfileName); string CurDir = Directory.GetCurrentDirectory(); string currExportDirectoryPath = ""; if (defaultProperties.ContainsKey("DefaultExportDestinationDirectory")) { currExportDirectoryPath = (string)defaultProperties["DefaultExportDestinationDirectory"]; } else { currExportDirectoryPath = CurDir + "\\data-export\\"; } ThreadSafeOperations.SetTextTB(rtbExportDestinationDirectoryPath, currExportDirectoryPath, false); if (defaultProperties.ContainsKey("InitialLogFilesDirectory")) { tbLogFilesPath.Text = (string)defaultProperties["InitialLogFilesDirectory"]; strLogFilesDirectory = (string)defaultProperties["InitialLogFilesDirectory"]; } else { defaultProperties.Add("InitialLogFilesDirectory", ""); saveDefaultProperties(); } if (defaultProperties.ContainsKey("ProcessedDataOutputDirectory")) { tbOutputDirectoryValue.Text = (string)defaultProperties["ProcessedDataOutputDirectory"]; strOutputDirectory = (string)defaultProperties["ProcessedDataOutputDirectory"]; } else { defaultProperties.Add("ProcessedDataOutputDirectory", ""); saveDefaultProperties(); } if (defaultProperties.ContainsKey("SourceDataDirectory")) { tbSourceDirectoryValue.Text = (string)defaultProperties["SourceDataDirectory"]; strSourceDirectory = (string)defaultProperties["SourceDataDirectory"]; } else { defaultProperties.Add("SourceDataDirectory", ""); saveDefaultProperties(); } }
private void btnReadData_Click(object sender, EventArgs e) { strLogFilesDirectory = tbLogFilesPath.Text; if (bgwDataReader != null && bgwDataReader.IsBusy) { bgwDataReader.CancelAsync(); return; } ThreadSafeOperations.ToggleButtonState(btnReadData, true, "CANCEL", true); DoWorkEventHandler currDoWorkHandler = delegate(object currBGWsender, DoWorkEventArgs args) { BackgroundWorker selfworker = currBGWsender as BackgroundWorker; List <double> lTotalDataToAdd = new List <double>(); List <DateTime> lDateTimeList = new List <DateTime>(); DirectoryInfo dInfo = new DirectoryInfo(strLogFilesDirectory); FileInfo[] fInfoArr = dInfo.GetFiles("*AccelerometerDataLog*.nc"); int fInfoCounter = 0; foreach (FileInfo fInfo in fInfoArr) { if (selfworker.CancellationPending) { break; } fInfoCounter++; selfworker.ReportProgress(Convert.ToInt32((double)(fInfoCounter - 1) / (double)fInfoArr.Length)); ThreadSafeOperations.SetText(lblStatusString, "reading " + fInfo.FullName, false); Dictionary <string, object> dictDataLoaded = NetCDFoperations.ReadDataFromFile(fInfo.FullName); string varNameDateTime = "DateTime"; if (dictDataLoaded.Keys.Contains("DateTime")) { varNameDateTime = "DateTime"; } else if (dictDataLoaded.Keys.Contains("Datetime")) { varNameDateTime = "Datetime"; } List <long> currFileDateTimeLongTicksList = new List <long>((dictDataLoaded[varNameDateTime] as long[])); List <DateTime> currFileDateTimeList = currFileDateTimeLongTicksList.ConvertAll(longVal => new DateTime(longVal)); string varNameAccData = "AccelerometerData"; List <AccelerometerData> lAccData = AccelerometerData.OfDenseMatrix(dictDataLoaded[varNameAccData] as DenseMatrix); List <double> lAccDataToAdd = lAccData.ConvertAll <double>(acc => acc.AccMagnitude); lTotalDataToAdd.AddRange(lAccDataToAdd); lDateTimeList.AddRange(currFileDateTimeList); selfworker.ReportProgress(Convert.ToInt32((double)(fInfoCounter) / (double)fInfoArr.Length)); } accSeriaData.AddSubseriaData(lTotalDataToAdd, lDateTimeList); //теперь обработаем считанные данные ThreadSafeOperations.SetText(lblStatusString, "basic acceleration data processing...", false); accSubseries = accSeriaData.SplitWithTimeSpanCondition(dt => dt.TotalMilliseconds >= 1200); accSubseries.RemoveAll(theSeria => theSeria.TotalSeriaDuration.TotalSeconds < 100); List <double> listSeriesStats = accSubseries.ConvertAll(timeseria => timeseria.TotalSeriaDuration.TotalSeconds); DescriptiveStatistics stats = new DescriptiveStatistics(listSeriesStats); string strToShow = "Acceleration data start time: " + accSubseries[0].StartTime.ToString("s") + Environment.NewLine; strToShow += "Acceleration data end time: " + accSubseries[accSubseries.Count - 1].EndTime.ToString("s") + Environment.NewLine; strToShow += "total chunks count: " + accSubseries.Count + Environment.NewLine; strToShow += "mean chunk duration: " + stats.Mean.ToString("0.##e-00") + " s" + Environment.NewLine; strToShow += "min chunk duration: " + stats.Minimum.ToString("0.##e-00") + " s" + Environment.NewLine; strToShow += "max chunk duration: " + stats.Maximum.ToString("0.##e-00") + " s" + Environment.NewLine; strToShow += "StdDev of chunk duration: " + stats.StandardDeviation.ToString("0.##e-00") + " s" + Environment.NewLine; ThreadSafeOperations.SetTextTB(tbReportLog, strToShow, true); List <GPSdata> lTotalGPSDataToAdd = new List <GPSdata>(); List <DateTime> lGPSDateTimeList = new List <DateTime>(); dInfo = new DirectoryInfo(strLogFilesDirectory); fInfoArr = dInfo.GetFiles("*GPSDataLog*.nc"); fInfoCounter = 0; foreach (FileInfo fInfo in fInfoArr) { if (selfworker.CancellationPending) { break; } fInfoCounter++; selfworker.ReportProgress(Convert.ToInt32((double)(fInfoCounter - 1) / (double)fInfoArr.Length)); ThreadSafeOperations.SetText(lblStatusString, "reading " + fInfo.FullName, false); Dictionary <string, object> dictDataLoaded = NetCDFoperations.ReadDataFromFile(fInfo.FullName); string varNameDateTime = "DateTime"; if (dictDataLoaded.Keys.Contains("DateTime")) { varNameDateTime = "DateTime"; } else if (dictDataLoaded.Keys.Contains("Datetime")) { varNameDateTime = "Datetime"; } List <long> currFileDateTimeLongTicksList = new List <long>((dictDataLoaded[varNameDateTime] as long[])); List <DateTime> currFileDateTimeList = currFileDateTimeLongTicksList.ConvertAll(longVal => new DateTime(longVal)); string varNameGPSData = "GPSdata"; List <GPSdata> lGPSData = GPSdata.OfDenseMatrix(dictDataLoaded[varNameGPSData] as DenseMatrix); //List<double> lGPSDataToAdd = lGPSData.ConvertAll<double>(acc => acc.AccMagnitude); lTotalGPSDataToAdd.AddRange(lGPSData); lGPSDateTimeList.AddRange(currFileDateTimeList); selfworker.ReportProgress(Convert.ToInt32((double)(fInfoCounter) / (double)fInfoArr.Length)); } gpsSeriaData.AddSubseriaData(lTotalGPSDataToAdd, lGPSDateTimeList); //теперь обработаем считанные данные ThreadSafeOperations.SetText(lblStatusString, "basic GPS data processing...", false); gpsSeriaData.RemoveValues(gpsDatum => ((gpsDatum.lat == 0.0d) && (gpsDatum.lon == 0.0d))); gpsSeriaData.RemoveDuplicatedTimeStamps(); strToShow = Environment.NewLine + "GPS data start time: " + gpsSeriaData.StartTime.ToString("s") + Environment.NewLine; strToShow += "GPS data end time: " + gpsSeriaData.EndTime.ToString("s") + Environment.NewLine; ThreadSafeOperations.SetTextTB(tbReportLog, strToShow, true); }; RunWorkerCompletedEventHandler currWorkCompletedHandler = delegate(object currBGWCompletedSender, RunWorkerCompletedEventArgs args) { ThreadSafeOperations.ToggleButtonState(btnReadData, true, "Read data", true); }; ProgressChangedEventHandler bgwDataReader_ProgressChanged = delegate(object bgwDataReaderSender, ProgressChangedEventArgs args) { ThreadSafeOperations.UpdateProgressBar(prbReadingProcessingData, args.ProgressPercentage); }; bgwDataReader = new BackgroundWorker(); bgwDataReader.WorkerSupportsCancellation = true; bgwDataReader.WorkerReportsProgress = true; bgwDataReader.DoWork += currDoWorkHandler; bgwDataReader.RunWorkerCompleted += currWorkCompletedHandler; bgwDataReader.ProgressChanged += bgwDataReader_ProgressChanged; object[] BGWargs = new object[] { "", "" }; bgwDataReader.RunWorkerAsync(BGWargs); }
private void readDefaultProperties() { defaultProperties = new Dictionary <string, object>(); defaultPropertiesXMLfileName = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "settings" + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location) + "-Settings.xml"; if (File.Exists(defaultPropertiesXMLfileName)) { defaultProperties = ServiceTools.ReadDictionaryFromXML(defaultPropertiesXMLfileName); } bool bDefaultPropertiesHasBeenUpdated = false; if (defaultProperties.ContainsKey("CopyImagesFrom_Path")) { CopyImagesFrom_Path = (string)defaultProperties["CopyImagesFrom_Path"]; } else { CopyImagesFrom_Path = ""; defaultProperties.Add("CopyImagesFrom_Path", CopyImagesFrom_Path); bDefaultPropertiesHasBeenUpdated = true; } ThreadSafeOperations.SetTextTB(rtbFromPath, CopyImagesFrom_Path, false); if (defaultProperties.ContainsKey("CopyImagesAndDataTo_Path")) { CopyImagesAndDataTo_Path = (string)defaultProperties["CopyImagesAndDataTo_Path"]; } else { CopyImagesAndDataTo_Path = ""; defaultProperties.Add("CopyImagesAndDataTo_Path", CopyImagesAndDataTo_Path); bDefaultPropertiesHasBeenUpdated = true; } ThreadSafeOperations.SetTextTB(rtbToPath, CopyImagesAndDataTo_Path, false); if (defaultProperties.ContainsKey("ConcurrentDataXMLfilesPath")) { ConcurrentDataXMLfilesPath = (string)defaultProperties["ConcurrentDataXMLfilesPath"]; } else { ConcurrentDataXMLfilesPath = ""; defaultProperties.Add("ConcurrentDataXMLfilesPath", ConcurrentDataXMLfilesPath); bDefaultPropertiesHasBeenUpdated = true; } ThreadSafeOperations.SetTextTB(rtbConcurrentDataDir, ConcurrentDataXMLfilesPath, false); if (defaultProperties.ContainsKey("GrIxYRGBstatsXMLfilesPath")) { GrIxYRGBstatsXMLfilesPath = (string)defaultProperties["GrIxYRGBstatsXMLfilesPath"]; } else { GrIxYRGBstatsXMLfilesPath = ""; defaultProperties.Add("GrIxYRGBstatsXMLfilesPath", GrIxYRGBstatsXMLfilesPath); bDefaultPropertiesHasBeenUpdated = true; } ThreadSafeOperations.SetTextTB(rtbGrIxYRGBstatsDir, GrIxYRGBstatsXMLfilesPath, false); if (defaultProperties.ContainsKey("filterTolerance")) { filterTolerance = TimeSpan.Parse((string)defaultProperties["filterTolerance"]); } else { defaultProperties.Add("filterTolerance", filterTolerance.ToString()); bDefaultPropertiesHasBeenUpdated = true; } //TimeSpanForConcurrentDataMappingTolerance if (defaultProperties.ContainsKey("TimeSpanForConcurrentDataMappingTolerance")) { TimeSpanForConcurrentDataMappingTolerance = TimeSpan.Parse((string)defaultProperties["TimeSpanForConcurrentDataMappingTolerance"]); } else { TimeSpanForConcurrentDataMappingTolerance = new TimeSpan(0, 0, 30); defaultProperties.Add("TimeSpanForConcurrentDataMappingTolerance", TimeSpanForConcurrentDataMappingTolerance.ToString()); bDefaultPropertiesHasBeenUpdated = true; } if (bDefaultPropertiesHasBeenUpdated) { saveDefaultProperties(); } }