Example #1
0
        public void SaveSettings(string fileName)
        {
            EchoTubeSettings settings = new EchoTubeSettings
            {
                StartCutOff         = StartCutOff,
                EndCutOff           = EndCutOff,
                Alpha               = EnvelopeAlpha,
                UpperTouchThreshold = (int)UpperTouchThreshold,
                LowerTouchThreshold = (int)LowerTouchThreshold,
                SingleTouch         = NumberOfTouchPoints == 1
            };

            SettingsFileHandler.SaveSettings(fileName, settings);
        }
Example #2
0
        public void LoadSettings(string fileName)
        {
            EchoTubeSettings settings = SettingsFileHandler.LoadSettings(fileName);

            if (settings != null)
            {
                StartCutOff         = settings.StartCutOff;
                EndCutOff           = settings.EndCutOff;
                EnvelopeAlpha       = settings.Alpha;
                UpperTouchThreshold = settings.UpperTouchThreshold;
                LowerTouchThreshold = settings.LowerTouchThreshold;
                NumberOfTouchPoints = settings.SingleTouch ? 1 : 2;
            }
        }
        internal static void SaveSettings(string fileName, EchoTubeSettings settings)
        {
            FileStream   strm   = new FileStream(fileName, FileMode.Create);
            StreamWriter writer = new StreamWriter(strm);

            writer.WriteLine("EchoTube Settings");
            writer.WriteLine("Created: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
            writer.WriteLine("------------------------------------------------------------");
            writer.WriteLine("StartCutOff=" + settings.StartCutOff);
            writer.WriteLine("EndCutOff=" + settings.EndCutOff);
            writer.WriteLine("Alpha=" + settings.Alpha.ToString(Provider));
            writer.WriteLine("UpperThreshold=" + settings.UpperTouchThreshold);
            writer.WriteLine("LowerThreshold=" + settings.LowerTouchThreshold);
            writer.WriteLine("TouchPoints=" + (settings.SingleTouch ? 1 : 2));

            writer.Close();
            writer.Dispose();
            writer = null;

            strm.Close();
            strm.Dispose();
            strm = null;
        }
        internal static EchoTubeSettings LoadSettings(string fileName)
        {
            EchoTubeSettings settings = new EchoTubeSettings();

            FileStream   strm   = new FileStream(fileName, FileMode.Open);
            StreamReader reader = new StreamReader(strm);

            // read the first three lines
            reader.ReadLine();
            reader.ReadLine();
            reader.ReadLine();

            // read the values
            settings.StartCutOff = Convert.ToInt32(reader.ReadLine().Split(
                                                       new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1]);
            settings.EndCutOff = Convert.ToInt32(reader.ReadLine().Split(
                                                     new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1]);
            settings.Alpha = Convert.ToSingle(reader.ReadLine().Split(
                                                  new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1], Provider);
            settings.UpperTouchThreshold = Convert.ToInt32(reader.ReadLine().Split(
                                                               new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1]);
            settings.LowerTouchThreshold = Convert.ToInt32(reader.ReadLine().Split(
                                                               new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1]);
            settings.SingleTouch = Convert.ToInt32(reader.ReadLine().Split(
                                                       new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1]) == 1;

            reader.Close();
            reader.Dispose();
            reader = null;

            strm.Close();
            strm.Dispose();
            strm = null;

            return(settings);
        }