private static string SetLabelValue(DateTime START, DateTime END, int value, string start, string end) { string labelText = ""; string labelString = ""; double ss = 0.0; bool normalLabel = true; double startTick = 0.0; double endTick = 0.0; try { startTick = Double.Parse(start); endTick = Double.Parse(end); } catch (FormatException ex) { ErrorLogger logger = new ErrorLogger(); logger.WriteLog("Exception when Setting Track Bar Value Label : " + ex.Message); normalLabel = false; } double rangeValsInterval = endTick - startTick; double rangeUnit = rangeValsInterval / 1000; double calculatedValue = startTick + (rangeUnit * value); double valTrack = value; double val = valTrack / 1000; double diff = (END - START).TotalMilliseconds; diff = val * diff; int seconds = (Int32)diff / 1000; double milliSeconds = diff % 1000; DateTime labelTimeValue = START; labelTimeValue = labelTimeValue.AddSeconds(seconds); labelTimeValue = labelTimeValue.AddMilliseconds(milliSeconds); int fractionOfMilliSecond = (Int32)(diff * 100) % 100000; int tempss = (Int32)calculatedValue / 1000; ss = tempss; double fff = calculatedValue % 1000; fff = fff * 100; int tempFFF = (Int32)fff; fff = tempFFF; fff = fff / 100; labelString = labelTimeValue.ToString("d/M/yy HH:mm"); if (normalLabel) { ss = (ss * 1000) + fff; labelText = labelString + ":" + ss.ToString(); } else { labelText = labelString; } return(labelText); }
public static bool SyncWithTime(Dictionary <string, RichTextBox> tagMap, out Dictionary <string, Dictionary <string, int> > syncMap, out string startTick, out string endTick) { Cursor.Current = Cursors.WaitCursor; ErrorLogger logger = new ErrorLogger(); syncMap = new Dictionary <string, Dictionary <string, int> >(); bool oldBuild = false; List <double> findStartEndTime = new List <double>(); foreach (var entry in tagMap) { string text = entry.Value.Text; List <string> lines = text.Split('\n').ToList <string>(); string tempLine = ""; string tempTime = ""; bool setSettings = true; Dictionary <string, int> posDict = new Dictionary <string, int>(); foreach (string line in lines) { if (!String.IsNullOrEmpty(line)) { if (line.Contains(",")) { tempLine = line; string time = line.Split(',')[1].Replace('\"', ' ').Trim(); string milliSeconds = line.Split(',')[2].Replace('\"', ' ').Trim(); DateTime parsedTime = new DateTime(); DateTimeParser.Parse(time, out parsedTime); time = parsedTime.ToString("HH:mm") + ":" + milliSeconds; try { findStartEndTime.Add(Double.Parse(milliSeconds)); if (setSettings) { setSettings = false; tempTime = time; } if (!tempTime.Equals(time)) { posDict.Add(tempTime, entry.Value.Find(line)); tempTime = time; } } catch (FormatException ex) { oldBuild = true; logger.WriteLog("Moving to Old Build : Reason: " + ex.Message); } } } } posDict.Add(tempTime, entry.Value.Find(tempLine)); syncMap.Add(entry.Key, posDict); } if (oldBuild) { MessageBox.Show("Old Build Detected : Only Approximate Synchronization Available."); } endTick = findStartEndTime.Max <double>().ToString(); startTick = findStartEndTime.Min <double>().ToString(); Cursor.Current = Cursors.Default; return(oldBuild); }