Example #1
0
        } // Write

        #endregion

        #region Copy
        // -------------------------------------------------------------------------
        /// <summary>
        /// Helper method that copies all the properties from reading the properties
        /// file into the local instance methods;
        /// </summary>
        /// <param name="properties">The instance variable to copy from.</param>
        // -------------------------------------------------------------------------
        private void Copy(CeresProperties properties)
        {
            mainWindow.size.Width  = properties.mainWindow.size.Width;
            mainWindow.size.Height = properties.mainWindow.size.Height;

            mainWindow.serialPortProperties.SerialPort = properties.mainWindow.serialPortProperties.SerialPort;
            mainWindow.serialPortProperties.BaudRate   = properties.mainWindow.serialPortProperties.BaudRate;
            mainWindow.serialPortProperties.DataBits   = properties.mainWindow.serialPortProperties.DataBits;
            mainWindow.serialPortProperties.Parity     = properties.mainWindow.serialPortProperties.Parity;
            mainWindow.serialPortProperties.StopBits   = properties.mainWindow.serialPortProperties.StopBits;
            mainWindow.serialPortProperties.Handshake  = properties.mainWindow.serialPortProperties.Handshake;

            mainWindow.outTextBox.Font      = properties.mainWindow.outTextBox.Font;
            mainWindow.outTextBox.ForeColor = properties.mainWindow.outTextBox.ForeColor;
            mainWindow.outTextBox.BackColor = properties.mainWindow.outTextBox.BackColor;

            mainWindow.inTextBox.Font      = properties.mainWindow.inTextBox.Font;
            mainWindow.inTextBox.ForeColor = properties.mainWindow.inTextBox.ForeColor;
            mainWindow.inTextBox.BackColor = properties.mainWindow.inTextBox.BackColor;
        } // Copy
Example #2
0
        // -------------------------------------------------------------------------
        /// <summary>
        /// Read the properties from the propertes file.
        /// </summary>
        // -------------------------------------------------------------------------
        public void Read()
        {
            string inputFileName = Path.Combine(propertyFilePath, propertyFileName);

            try
            {
                using (StreamReader file = File.OpenText(inputFileName))
                {
                    string          data       = file.ReadToEnd();
                    CeresProperties properties = JsonConvert.DeserializeObject <CeresProperties>(data);

                    // copy the data
                    Copy(properties);
                }
            }
            catch (Exception ex)
            {
                // ignore file not found. Will be created on Write
                //throw ex; // TODO - remove
            }
        } // Read