コード例 #1
0
        private string save_settings()
        {
            string file = select_file("INI Files (*.ini)|*.ini");

            if (file != null)
            {
                INIFile inifile = new INIFile(file);

                Collection<int> selected_tuner_indexes = frequencySelectionControl.selected_tuner_indexes;

                string str_selected_tuner_indexes = "";

                for (int i = 0; i < selected_tuner_indexes.Count;i++ )
                {
                    str_selected_tuner_indexes += string.Format("{0}", selected_tuner_indexes[i]);

                    if (i+1 != selected_tuner_indexes.Count)
                    {
                        str_selected_tuner_indexes += ",";
                    }
                }

                inifile.Write("default", "selected_tuners", str_selected_tuner_indexes);
                inifile.Write("default", "selected_satellite", string.Format("{0}", frequencySelectionControl.selected_satellite_index));
                inifile.Write("default", "selected_frequency", string.Format("{0}", frequencySelectionControl.selected_frequency_index));
                inifile.Write("default", "LNBLowBandFrequency", string.Format("{0}", frequencySelectionControl.LNBLowBandFrequency));
                inifile.Write("default", "LNBHighBandFrequency", string.Format("{0}", frequencySelectionControl.LNBHighBandFrequency));
                inifile.Write("default", "LNBSwitchFrequency", string.Format("{0}", frequencySelectionControl.LNBSwitchFrequency));
                inifile.Write("default", "DiseqC", frequencySelectionControl.DiseqcSwitch);

                inifile.Write("default", "UseSignalPresent", frequencySelectionControl.UseSignalPresent ? bool.TrueString : bool.FalseString);
                inifile.Write("default", "SwitchAfterPlay", frequencySelectionControl.SwitchAfterPlay ? bool.TrueString : bool.FalseString);
                inifile.Write("default", "RepeatDiseqc", frequencySelectionControl.RepeatDiseqc ? bool.TrueString : bool.FalseString);
                inifile.Write("default", "SignalLockTimeout", string.Format("{0}", (int)nudSignalLockTimeout.Value));
                inifile.Write("default", "DataCollectionTimeout", string.Format("{0}", (int)nudDataCollectionTimeout.Value));
                inifile.Write("default", "PidList", tbPidList.Text);

                inifile.Write("default", "before_recording_complete_script_path", before_recording_complete_script_path.Text);
                inifile.Write("default", "after_recording_complete_script_path", after_recording_complete_script_path.Text);
                inifile.Write("default", "start_hour", start_hour_textbox.Text);
                inifile.Write("default", "output_path", txtOutputFile.Text);

                MessageBox.Show(string.Format("Settings successfully save to {0}", file));

            }

            return file;
        }
コード例 #2
0
        private bool load_settings()
        {
            string file = select_file( "INI Files (*.ini)|*.ini");

            if (file != null)
            {
                try
                {
                        INIFile inifile = new INIFile(file);

                        string str_selected_tuner_indexes = inifile.Read("default", "selected_tuners");

                        string[] parts = str_selected_tuner_indexes.Split(',');
                        Collection<int> selected_tuner_indexes = new Collection<int>();
                        foreach (string part in parts)
                        {
                                selected_tuner_indexes.Add(Int32.Parse(part, NumberStyles.Integer));
                        }

                        frequencySelectionControl.selected_tuner_indexes = selected_tuner_indexes;
                        frequencySelectionControl.selected_satellite_index = Int32.Parse(inifile.Read("default", "selected_satellite"), NumberStyles.Integer);
                        frequencySelectionControl.selected_frequency_index = Int32.Parse(inifile.Read("default", "selected_frequency"), NumberStyles.Integer);
                        frequencySelectionControl.LNBLowBandFrequency = Int32.Parse(inifile.Read("default", "LNBLowBandFrequency"), NumberStyles.Integer);
                        frequencySelectionControl.LNBHighBandFrequency = Int32.Parse(inifile.Read("default", "LNBHighBandFrequency"), NumberStyles.Integer);
                        frequencySelectionControl.LNBSwitchFrequency = Int32.Parse(inifile.Read("default", "LNBSwitchFrequency"), NumberStyles.Integer);
                        frequencySelectionControl.DiseqcSwitch = inifile.Read("default", "DiseqC");
                        frequencySelectionControl.UseSignalPresent = bool.Parse(inifile.Read("default", "UseSignalPresent"));
                        frequencySelectionControl.SwitchAfterPlay = bool.Parse(inifile.Read("default", "SwitchAfterPlay"));
                        frequencySelectionControl.RepeatDiseqc = bool.Parse(inifile.Read("default", "RepeatDiseqc"));
                        nudSignalLockTimeout.Value = Int32.Parse(inifile.Read("default", "SignalLockTimeout"));
                        nudDataCollectionTimeout.Value = Int32.Parse(inifile.Read("default", "DataCollectionTimeout"));
                        tbPidList.Text = inifile.Read("default", "PidList");

                        before_recording_complete_script_path.Text = inifile.Read("default", "before_recording_complete_script_path");
                        after_recording_complete_script_path.Text = inifile.Read("default", "after_recording_complete_script_path");
                        start_hour_textbox.Text = inifile.Read("default", "start_hour" );
                        txtOutputFile.Text = inifile.Read("default", "output_path");

                   // MessageBox.Show("Settings loaded successfully");
                } catch(Exception e)
                {
                    return false;
                }
                return true;
            }

            return false;
        }