gInk.Root.ReadOptions C# (CSharp) Method

ReadOptions() public method

public ReadOptions ( string file ) : void
file string
return void
		public void ReadOptions(string file)
		{
			if (!File.Exists(file))
			{
				return;
			}

			FileStream fini = new FileStream(file, FileMode.Open);
			StreamReader srini = new StreamReader(fini);
			string sLine = "";
			string sName = "", sPara = "";
			while (sLine != null)
			{
				sLine = srini.ReadLine();
				if
				(
					sLine != null &&
					sLine != "" &&
					sLine.Substring(0, 1) != "-" &&
					sLine.Substring(0, 1) != "%" &&
					sLine.Substring(0, 1) != "'" &&
					sLine.Substring(0, 1) != "/" &&
					sLine.Substring(0, 1) != "!" &&
					sLine.Substring(0, 1) != "[" &&
					sLine.Substring(0, 1) != "#" &&
					sLine.Contains("=") &&
					!sLine.Substring(sLine.IndexOf("=") + 1).Contains("=")
				)
				{
					sName = sLine.Substring(0, sLine.IndexOf("="));
					sName = sName.Trim();
					sName = sName.ToUpper();
					sPara = sLine.Substring(sLine.IndexOf("=") + 1);
					sPara = sPara.Trim();

					int o;
					switch (sName)
					{
						case "PEN1_RED":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen1.Color = Color.FromArgb(int.Parse(sPara), Pen1.Color.G, Pen1.Color.B);
							break;
						case "PEN1_GREEN":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen1.Color = Color.FromArgb(Pen1.Color.R, int.Parse(sPara), Pen1.Color.B);
							break;
						case "PEN1_BLUE":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen1.Color = Color.FromArgb(Pen1.Color.R, Pen1.Color.G, int.Parse(sPara));
							break;
						case "PEN2_RED":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen2.Color = Color.FromArgb(int.Parse(sPara), Pen2.Color.G, Pen2.Color.B);
							break;
						case "PEN2_GREEN":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen2.Color = Color.FromArgb(Pen2.Color.R, int.Parse(sPara), Pen2.Color.B);
							break;
						case "PEN2_BLUE":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen2.Color = Color.FromArgb(Pen2.Color.R, Pen2.Color.G, int.Parse(sPara));
							break;
						case "PEN3_RED":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen3.Color = Color.FromArgb(int.Parse(sPara), Pen3.Color.G, Pen3.Color.B);
							break;
						case "PEN3_GREEN":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen3.Color = Color.FromArgb(Pen3.Color.R, int.Parse(sPara), Pen3.Color.B);
							break;
						case "PEN3_BLUE":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen3.Color = Color.FromArgb(Pen3.Color.R, Pen3.Color.G, int.Parse(sPara));
							break;
						case "PEN4_RED":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen4.Color = Color.FromArgb(int.Parse(sPara), Pen4.Color.G, Pen4.Color.B);
							break;
						case "PEN4_GREEN":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen4.Color = Color.FromArgb(Pen4.Color.R, int.Parse(sPara), Pen4.Color.B);
							break;
						case "PEN4_BLUE":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen4.Color = Color.FromArgb(Pen4.Color.R, Pen4.Color.G, int.Parse(sPara));
							break;
						case "PEN5_RED":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen5.Color = Color.FromArgb(int.Parse(sPara), Pen5.Color.G, Pen5.Color.B);
							break;
						case "PEN5_GREEN":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen5.Color = Color.FromArgb(Pen5.Color.R, int.Parse(sPara), Pen5.Color.B);
							break;
						case "PEN5_BLUE":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen5.Color = Color.FromArgb(Pen5.Color.R, Pen5.Color.G, int.Parse(sPara));
							break;

						case "PEN1_ALPHA":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen1.Transparency = (byte)(255 - o);
							break;
						case "PEN2_ALPHA":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen2.Transparency = (byte)(255 - o);
							break;
						case "PEN3_ALPHA":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen3.Transparency = (byte)(255 - o);
							break;
						case "PEN4_ALPHA":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen4.Transparency = (byte)(255 - o);
							break;
						case "PEN5_ALPHA":
							if (int.TryParse(sPara, out o) && o >= 0 && o <= 255)
								Pen5.Transparency = (byte)(255 - o);
							break;

						case "PEN1_WIDTH":
							if (int.TryParse(sPara, out o) && o > 30 && o <= 3000)
								Pen1.Width = o;
							break;
						case "PEN2_WIDTH":
							if (int.TryParse(sPara, out o) && o > 30 && o <= 3000)
								Pen2.Width = o;
							break;
						case "PEN3_WIDTH":
							if (int.TryParse(sPara, out o) && o > 30 && o <= 3000)
								Pen3.Width = o;
							break;
						case "PEN4_WIDTH":
							if (int.TryParse(sPara, out o) && o > 30 && o <= 3000)
								Pen4.Width = o;
							break;
						case "PEN5_WIDTH":
							if (int.TryParse(sPara, out o) && o > 30 && o <= 3000)
								Pen5.Width = o;
							break;

						case "HOTKEY":
							sPara = sPara.ToUpper();
							if (sPara.Contains("CONTROL"))
								Hotkey_Control = true;
							else
								Hotkey_Control = false;
							if (sPara.Contains("ALT"))
								Hotkey_Alt = true;
							else
								Hotkey_Alt = false;
							if (sPara.Contains("SHIFT"))
								Hotkey_Shift = true;
							else
								Hotkey_Shift = false;
							if (sPara.Contains("WIN"))
								Hotkey_Win = true;
							else
								Hotkey_Win = false;
							if (sPara.Length > 0)
								Hotkey = sPara.Substring(sPara.Length - 1).ToCharArray()[0];
							break;
						case "ENABLEAUTOSCROLL":
							sPara = sPara.ToUpper();
							if (sPara.Contains("TRUE"))
								AutoScroll = true;
							else
								AutoScroll = false;
							break;
						case "WHITETRAYICON":
							sPara = sPara.ToUpper();
							if (sPara.Contains("TRUE"))
								WhiteTrayIcon = true;
							else
								WhiteTrayIcon = false;
							break;
						case "SNAPSHOTPATH":
							SnapshotBasePath = sPara;
							if (!SnapshotBasePath.EndsWith("/") && !SnapshotBasePath.EndsWith("\\"))
								SnapshotBasePath += "/";
							break;
					}
				}
			}
			fini.Close();
		}