public static void Load() { string DisplayAdaptationDataLine; string FileName; char[] delimiterChars = { ',', '\t' }; StreamReader MyStreamReader; FileName = @"C:\ASTERIX\ADAPTATION\DisplayAttributes.txt"; if (System.IO.File.Exists(FileName)) { MyStreamReader = System.IO.File.OpenText(FileName); while (MyStreamReader.Peek() >= 0) { DisplayAdaptationDataLine = MyStreamReader.ReadLine(); string[] words = DisplayAdaptationDataLine.Split(delimiterChars); if (words[0][0] != '#') { DisplayAttributes.DisplayAttributesType DisplayAttribute = new DisplayAttributes.DisplayAttributesType(); DisplayAttribute.ItemName = words[0]; DisplayAttribute.TextSize = int.Parse(words[1]); DisplayAttribute.TextFont = new FontFamily(words[2]); DisplayAttribute.TextColor = Color.FromName(words[3]); DisplayAttribute.LineWidth = int.Parse(words[4]); DisplayAttribute.LineColor = Color.FromName(words[5]); DisplayAttribute.LineStyle = DisplayAttributes.GetLineStypefromString(words[6]); DisplayAttribute.AreaPolygonColor = Color.FromName(words[7]); DisplayAttribute.ImageSize = new Size(int.Parse(words[8]), int.Parse((words[9]))); DisplayAttributes.SetDisplayAttribute((DisplayAttributes.DisplayItemsType)Enum.Parse(typeof(DisplayAttributes.DisplayItemsType), DisplayAttribute.ItemName, true), DisplayAttribute); } } } }
public static void Load() { string DisplayAdaptationDataLine; string FileName; char[] delimiterChars = { ',', '\t' }; StreamReader MyStreamReader; FileName = @"C:\ASTERIX\ADAPTATION\LabelAttributes.txt"; if (System.IO.File.Exists(FileName)) { MyStreamReader = System.IO.File.OpenText(FileName); while (MyStreamReader.Peek() >= 0) { DisplayAdaptationDataLine = MyStreamReader.ReadLine(); string[] words = DisplayAdaptationDataLine.Split(delimiterChars); if (words[0][0] != '#') { switch (words[0]) { case "TEXT_COLOR": TextColor = Color.FromName(words[1]); break; case "TEXT_FONT": TextFont = new FontFamily(words[1]); break; case "TEXT_SIZE": TextSize = int.Parse(words[1]); break; case "LINE_COLOR": LineColor = Color.FromName(words[1]); break; case "LINE_STYLE": LineStyle = DisplayAttributes.GetLineStypefromString(words[1]); break; case "LINE_WIDTH": LineWidth = int.Parse(words[1]); break; case "TARGET_COLOR": TargetColor = Color.FromName(words[1]); break; case "TARGET_STYLE": TargetStyle = DisplayAttributes.GetLineStypefromString(words[1]); break; case "TARGET_SIZE": TargetSize = int.Parse(words[1]); break; default: MessageBox.Show("Bad format of LabelAttributes.txt"); break; } } } } }