Beispiel #1
0
        /// <summary>
        /// Loads the class from the specified filname.
        /// </summary>
        /// <param name="filname">The filname.</param>
        /// <remarks>Documented by Dev05, 2007-08-03</remarks>
        public void Load(string filname)
        {
            Stream inputStream = File.OpenRead(filname);
            XmlSerializer serializer = new XmlSerializer(typeof(Settings));
            Settings tmpSettings;
            try
            {
                tmpSettings = (Settings)serializer.Deserialize(inputStream);

                ActualCard = tmpSettings.ActualCard;
                Dictionary = tmpSettings.Dictionary;
                FontSize = tmpSettings.FontSize;

                Side = tmpSettings.Side;
                Sentence = tmpSettings.Sentence;
                RecordingOrder = tmpSettings.RecordingOrder;
                ActualStep = tmpSettings.ActualStep;

                RecordQuestion = tmpSettings.RecordQuestion;
                RecordQuestionExample = tmpSettings.RecordQuestionExample;
                RecordAnswer = tmpSettings.RecordAnswer;
                RecordAnswerExample = tmpSettings.RecordAnswerExample;

                StartDelay = tmpSettings.StartDelay;
                StopDelay = tmpSettings.StopDelay;
                DelaysActive = tmpSettings.DelaysActive;

                CodecSettings = tmpSettings.CodecSettings;
                SelectedEncoder = tmpSettings.SelectedEncoder;
                SamplingRate = tmpSettings.SamplingRate;
                Channels = tmpSettings.Channels;

                AdvancedView = tmpSettings.AdvancedView;
                KeyboardLayout = tmpSettings.KeyboardLayout;
                AskLayoutAtStartup = tmpSettings.AskLayoutAtStartup;
                PresenterActivated = tmpSettings.PresenterActivated;

                AllowMultipleAssignment = tmpSettings.AllowMultipleAssignment;

                NumLockSwitchSleepTime = tmpSettings.NumLockSwitchSleepTime;

                foreach (KeyValuePair<Keys, Function> keyValuePair in tmpSettings.KeyFunctions)
                    KeyFunctions[keyValuePair.Key] = keyValuePair.Value;
                foreach (KeyValuePair<Keys, Function> keyValuePair in tmpSettings.KeyboardFunctions)
                    KeyboardFunctions[keyValuePair.Key] = keyValuePair.Value;

                if (tmpSettings.PresenterKeyFunctions.Count > 0)
                {
                    PresenterKeyFunctions.Clear();
                    foreach (KeyValuePair<Keys, Function> keyValuePair in tmpSettings.PresenterKeyFunctions)
                        PresenterKeyFunctions.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                inputStream.Close();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Loads the class from the specified filname.
        /// </summary>
        /// <param name="filname">The filname.</param>
        /// <remarks>Documented by Dev05, 2007-08-03</remarks>
        public void Load(string filname)
        {
            Stream        inputStream = File.OpenRead(filname);
            XmlSerializer serializer  = new XmlSerializer(typeof(Settings));
            Settings      tmpSettings;

            try
            {
                tmpSettings = (Settings)serializer.Deserialize(inputStream);

                ActualCard = tmpSettings.ActualCard;
                Dictionary = tmpSettings.Dictionary;
                FontSize   = tmpSettings.FontSize;

                Side           = tmpSettings.Side;
                Sentence       = tmpSettings.Sentence;
                RecordingOrder = tmpSettings.RecordingOrder;
                ActualStep     = tmpSettings.ActualStep;

                RecordQuestion        = tmpSettings.RecordQuestion;
                RecordQuestionExample = tmpSettings.RecordQuestionExample;
                RecordAnswer          = tmpSettings.RecordAnswer;
                RecordAnswerExample   = tmpSettings.RecordAnswerExample;

                StartDelay   = tmpSettings.StartDelay;
                StopDelay    = tmpSettings.StopDelay;
                DelaysActive = tmpSettings.DelaysActive;

                CodecSettings   = tmpSettings.CodecSettings;
                SelectedEncoder = tmpSettings.SelectedEncoder;
                SamplingRate    = tmpSettings.SamplingRate;
                Channels        = tmpSettings.Channels;

                AdvancedView       = tmpSettings.AdvancedView;
                KeyboardLayout     = tmpSettings.KeyboardLayout;
                AskLayoutAtStartup = tmpSettings.AskLayoutAtStartup;
                PresenterActivated = tmpSettings.PresenterActivated;

                AllowMultipleAssignment = tmpSettings.AllowMultipleAssignment;

                NumLockSwitchSleepTime = tmpSettings.NumLockSwitchSleepTime;

                foreach (KeyValuePair <Keys, Function> keyValuePair in tmpSettings.KeyFunctions)
                {
                    KeyFunctions[keyValuePair.Key] = keyValuePair.Value;
                }
                foreach (KeyValuePair <Keys, Function> keyValuePair in tmpSettings.KeyboardFunctions)
                {
                    KeyboardFunctions[keyValuePair.Key] = keyValuePair.Value;
                }

                if (tmpSettings.PresenterKeyFunctions.Count > 0)
                {
                    PresenterKeyFunctions.Clear();
                    foreach (KeyValuePair <Keys, Function> keyValuePair in tmpSettings.PresenterKeyFunctions)
                    {
                        PresenterKeyFunctions.Add(keyValuePair.Key, keyValuePair.Value);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                inputStream.Close();
            }
        }