} // LoadSavedProperties private void mnuProperties_Click(object sender, EventArgs e) { dlgProperties = new TerminalSettings(); dlgProperties.StartPosition = FormStartPosition.CenterParent; if (dlgProperties.ShowDialog() == DialogResult.OK) { InitializeSerialPort(); } SaveCurrentProperties(); dlgProperties = null; } // mnuProperties
} // SaveCurrentProperties private void LoadSavedProperties() { string strProperties = ""; string strPath = Globals.SiteRootDirectory + @"Data\Simple Terminal.stx"; if (File.Exists(strPath)) { strProperties = File.ReadAllText(strPath); } else { dlgProperties = new TerminalSettings(); dlgProperties.ShowDialog(); SaveCurrentProperties(); dlgProperties = null; } var objTextString = new StringReader(strProperties); do { string strLine = objTextString.ReadLine(); if (string.IsNullOrEmpty(strLine)) { break; } var strTokens = strLine.Split(' '); if (strTokens.Length > 1) { var switchExpr = strTokens[0]; switch (switchExpr) { case "Port": { strPort = strTokens[1]; break; } case "BaudRate": { intBaudRate = Convert.ToInt32(strTokens[1]); break; } case "DataBits": { intDataBits = Convert.ToInt32(strTokens[1]); break; } case "StopBits": { intStopBits = Convert.ToInt32(strTokens[1]); break; } case "Parity": { intParity = Convert.ToInt32(strTokens[1]); break; } case "Handshake": { intHandshake = Convert.ToInt32(strTokens[1]); break; } case "WriteTimeout": { intWriteTimeout = Convert.ToInt32(strTokens[1]); break; } case "RTSEnable": { blnRTSEnable = Convert.ToBoolean(strTokens[1]); break; } case "DTREnable": { blnDTREnable = Convert.ToBoolean(strTokens[1]); break; } case "LocalEcho": { blnLocalEcho = Convert.ToBoolean(strTokens[1]); break; } case "WordWrap": { blnWordWrap = Convert.ToBoolean(strTokens[1]); break; } case "BufferType": { enmBufferType = (BufferType)Enum.Parse(typeof(BufferType), strTokens[1]); break; } case "Top": { Top = Convert.ToInt32(strTokens[1]); break; } case "Left": { Left = Convert.ToInt32(strTokens[1]); break; } case "Width": { Width = Convert.ToInt32(strTokens[1]); break; } case "Height": { Height = Convert.ToInt32(strTokens[1]); break; } } } }while (true); objTextString.Dispose(); } // LoadSavedProperties