private void LoadConfigurationFile() { System.IO.StreamReader i = null; try { i = new System.IO.StreamReader(configFileName); } catch (Exception) { i = null; } if (i == null) { return; } int savedWidth = 0; int savedHeight = 0; bool screenWasMaximized = false; String nextLine = null; while (true) { try { nextLine = i.ReadLine(); } catch (Exception) { break; } if (nextLine == null) { break; } nextLine = nextLine.Trim(); if ((nextLine.Length < 3) || (nextLine.Substring(0, 2) == "//")) { continue; } String[] fields = nextLine.Split('\t'); if (fields.Length < 2) { continue; } String fieldName = fields[0]; String fieldValue = fields[1]; switch (fieldName) { case "WidthLast": savedWidth = PicesKKStr.StrToInt(fieldValue); break; case "HeightLast": savedHeight = PicesKKStr.StrToInt(fieldValue); break; case "Maximized": screenWasMaximized = (fieldValue.ToUpper() == "YES"); break; case "TimeInterval": timeInterval = (int)PicesKKStr.StrToFloat(fieldValue); if (timeInterval > 0) { TimeInterval.Value = (decimal)timeInterval; } break; case "PlotCruise": plotCruise = PicesKKStr.StrToBool(fieldValue); break; } } i.Close(); if (savedWidth > Screen.PrimaryScreen.Bounds.Width) { savedWidth = Screen.PrimaryScreen.Bounds.Width; } if (savedHeight > Screen.PrimaryScreen.Bounds.Height) { savedHeight = Screen.PrimaryScreen.Bounds.Height; } if (screenWasMaximized) { //savedWidth = Screen.PrimaryScreen.Bounds.Width; //savedHeight = savedHeight = Screen.PrimaryScreen.Bounds.Height; this.WindowState = FormWindowState.Maximized; } else { Height = Math.Max(savedHeight, MinimumSize.Height); Width = Math.Max(savedWidth, MinimumSize.Width); } OnResizeEnd(new EventArgs()); } /* LoadConfigurationFile */
} /* LoadConfigurationPlottedDataSeries */ private void LoadConfigurationDataRow(string[] fields) { string label = ""; int labelIdx = -1; float min = 0.0f; float max = 0.0f; bool plotData = false; bool errorsFound = false; int fieldNum = 0; if (fields[0].ToLower() == "instrumentdata") { fieldNum = 1; } while (fieldNum < fields.Length) { string fieldName = fields[fieldNum].ToLower(); fieldNum++; string fieldValue = ""; if (fieldNum < fields.Length) { fieldValue = fields[fieldNum]; fieldNum++; } if (fieldName == "label") { label = fieldValue; labelIdx = InstrumentData.GetFieldNameIndex(label); } else if ((fieldName == "min") || (fieldName == "minimum")) { min = PicesKKStr.StrToFloat(fieldValue); } else if ((fieldName == "max") || (fieldName == "maximum")) { max = PicesKKStr.StrToFloat(fieldValue); } else if (fieldName == "plotdata") { plotData = PicesKKStr.StrToBool(fieldValue); } } if ((labelIdx < 0) || (labelIdx >= InstrumentData.NumDataFields())) { errorsFound = true; } if (min > max) { errorsFound = true; } if (!errorsFound) { minValues [labelIdx] = min; maxValues [labelIdx] = max; plotDataSeries[labelIdx] = plotData; } } /* LoadConfigurationDataRow */
} /* SetSizeStatistic */ private void LoadConfigurationFile() { System.IO.StreamReader i = null; try { i = new System.IO.StreamReader(configFileName); } catch (Exception) { i = null; } if (i == null) { return; } int savedWidth = 0; int savedHeight = 0; bool screenWasMaximized = false; String nextLine = null; while (true) { try { nextLine = i.ReadLine(); } catch (Exception) { break; } if (nextLine == null) { break; } nextLine = nextLine.Trim(); if ((nextLine.Length < 3) || (nextLine.Substring(0, 2) == "//")) { continue; } String[] fields = nextLine.Split('\t'); if (fields.Length < 2) { continue; } String fieldName = fields[0]; String fieldValue = fields[1]; switch (fieldName) { case "WidthLast": savedWidth = PicesKKStr.StrToInt(fieldValue); break; case "HeightLast": savedHeight = PicesKKStr.StrToInt(fieldValue); break; case "Maximized": screenWasMaximized = (fieldValue.ToUpper() == "YES"); break; case "ClassToPlot": ClassToPlot.Text = fieldValue; break; case "IncludeSubClasses": IncludeSubClasses.Checked = PicesKKStr.StrToBool(fieldValue); break; case "SizeStatistic": SetSizeStatistic(fieldValue); break; case "InitialSize": float initialSize = PicesKKStr.StrToFloat(fieldValue); if ((initialSize <= 0.0) || (initialSize >= 100.0f)) { initialSize = 0.10f; } InitialSizeField.Value = (decimal)initialSize; break; case "MaxSize": float maxSize = PicesKKStr.StrToFloat(fieldValue); if ((maxSize <= 0.0) || (maxSize < (float)InitialSizeField.Value)) { maxSize = Math.Max(1000.0f, (float)InitialSizeField.Value); } MaxSizeField.Value = (decimal)maxSize; break; case "GrowthRate": float growthRate = PicesKKStr.StrToFloat(fieldValue); if (growthRate <= 1.0f) { growthRate = 1.1f; } GrowthRateField.Value = (decimal)growthRate; break; case "LastSaveDirectory": char[] whiteSpaceChars = { '\n', '\r', '\t', ' ' }; lastSaveDirectory = fieldValue.Trim(whiteSpaceChars); break; } } i.Close(); if (savedWidth > Screen.PrimaryScreen.Bounds.Width) { savedWidth = Screen.PrimaryScreen.Bounds.Width; } if (savedHeight > Screen.PrimaryScreen.Bounds.Height) { savedHeight = Screen.PrimaryScreen.Bounds.Height; } if (screenWasMaximized) { //savedWidth = Screen.PrimaryScreen.Bounds.Width; //savedHeight = savedHeight = Screen.PrimaryScreen.Bounds.Height; this.WindowState = FormWindowState.Maximized; } else { Height = Math.Max(savedHeight, MinimumSize.Height); Width = Math.Max(savedWidth, MinimumSize.Width); } if (SizeStatisticField.SelectedItem == null) { SizeStatisticField.SelectedItem = SizeStatisticField.Items[0]; } OnResizeEnd(new EventArgs()); } /* LoadConfigurationFile */
} /* LoadConfiguration */ private void LoadConfigurationPlottedDataSeries(string[] fields) { int idx = -1; string label = ""; int labelIdx = -1; bool plot = false; Color plotColor = Color.Black; int plotColorAlpha = 255; int plotColorRed = 0; int plotColorGreen = 0; int plotColorBlue = 0; bool plotColorKnown = false; bool errorsFound = false; int fieldNum = 0; if (fields[0].ToLower() == "plotteddataseries") { fieldNum = 1; } while (fieldNum < fields.Length) { string fieldName = fields[fieldNum].ToLower(); fieldNum++; string fieldValue = ""; if (fieldNum < fields.Length) { fieldValue = fields[fieldNum]; fieldNum++; } if (fieldName == "plotdataseriesidx") { idx = PicesKKStr.StrToInt(fieldValue); } else if ((fieldName == "label") || (fieldName == "selectedlabel")) { label = fieldValue; labelIdx = InstrumentData.GetFieldNameIndex(label); } else if (fieldName == "plot") { plot = PicesKKStr.StrToBool(fieldValue); } else if ((fieldName == "plotcoloralpha") || (fieldName == "alpha")) { plotColorAlpha = PicesKKStr.StrToInt(fieldValue); plotColorKnown = false; } else if ((fieldName == "plotcolorred") || (fieldName == "red")) { plotColorRed = PicesKKStr.StrToInt(fieldValue); plotColorKnown = false; } else if ((fieldName == "plotcolorgreen") || (fieldName == "green")) { plotColorGreen = PicesKKStr.StrToInt(fieldValue); plotColorKnown = false; } else if ((fieldName == "plotcolorblue") || (fieldName == "blue")) { plotColorBlue = PicesKKStr.StrToInt(fieldValue); plotColorKnown = false; } else if (fieldName == "plotcolor") { plotColorKnown = true; plotColor = Color.FromName(fieldValue); plotColorAlpha = plotColor.A; plotColorRed = plotColor.R; plotColorGreen = plotColor.G; plotColorBlue = plotColor.B; } } if ((idx < 0) || (idx > numDataSeries)) { errorsFound = true; } if (labelIdx < 0) { errorsFound = true; } if (!errorsFound) { fieldIdxs[idx] = labelIdx; if ((plotColorRed == 0) && (plotColorGreen == 0) && (plotColorBlue == 0)) { plotColor = plottedSeries[idx].PlotColor; } else if (!plotColorKnown) { plotColor = Color.FromArgb(plotColorAlpha, plotColorRed, plotColorGreen, plotColorBlue); } plottedSeries[idx].SuspendLayout(); plottedSeries[idx].Enabled = false; plottedSeries[idx].SetParameters(labelIdx, plot, plotColor); plottedSeries[idx].Enabled = true; plottedSeries[idx].ResumeLayout(); plotBrushes[idx] = new SolidBrush(plotColor); } } /* LoadConfigurationPlottedDataSeries */