public SettingsDlg(Settings inbound) { InitializeComponent(); Settings = inbound; if (!Utils.Empty(Settings.HDHRPath)) hdhrInstallPath.Text = Settings.HDHRPath; else hdhrInstallPath.Text = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles) + @"\Silicondust\HDHomeRun\hdhomerun_config.exe"; if (!Utils.Empty(Settings.MC2XMLPath)) mc2xmlInstallPath.Text = Settings.MC2XMLPath; else mc2xmlInstallPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); if (!Utils.Empty(Settings.TVGuidePath)) tvguideInstallPath.Text = Settings.TVGuidePath; else { string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\addon_data\script.tvguide\source.db"; if (new FileInfo(path).Exists) tvguideInstallPath.Text = path; else tvguideInstallPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); } if (!Utils.Empty(Settings.StrmFilePath)) strmFileDirectory.Text = Settings.StrmFilePath; else strmFileDirectory.Text = new DirectoryInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory)).Parent.FullName; if (!Utils.Empty(Settings.PseudoTVSettingsPath)) pseudotvSettingsPath.Text = Settings.PseudoTVSettingsPath; else { string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\addon_data\script.pseudotv\settings2.xml"; if (new FileInfo(path).Exists) pseudotvSettingsPath.Text = path; else pseudotvSettingsPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); } if (!Utils.Empty(Settings.HDHRDMS)) hdhrDmsDevice.Text = Settings.HDHRDMS; else { hdhrDmsDevice.Text = ""; } ignoreAllEncrypted.Checked = Settings.IgnoreAllEncrypted; ignoreZeroProgram.Checked = Settings.IgnoreZeroProgram; }
private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult dr = new DialogResult(); SettingsDlg settingsDlg = new SettingsDlg(settings); dr = settingsDlg.ShowDialog(); if (dr == DialogResult.OK) { if (settings == null) { settings = new Settings(); } settings.HDHRPath = settingsDlg.HDHRInstallPath; settings.HDHRDMS = settingsDlg.HDHRDMS; settings.MC2XMLPath = settingsDlg.MC2XMLInstallPath; settings.TVGuidePath = settingsDlg.TVGuideInstallPath; settings.IgnoreAllEncrypted = settingsDlg.IgnoreAllEncrypted; settings.IgnoreZeroProgram = settingsDlg.IgnoreZeroProgram; settings.StrmFilePath = settingsDlg.StrmFilePath; settings.PseudoTVSettingsPath = settingsDlg.PseudoTVSettingsPath; CacheSettings(); } }
public bool OpenCachedSettings() { try { string settingsJson = System.IO.File.ReadAllText(Path.GetDirectoryName(Application.ExecutablePath) + @"\settings.json"); settings = JsonConvert.DeserializeObject<Settings>(settingsJson); tuner_cb.Text = settings.Tuner; device_tb.Text = settings.Device; } catch (Exception e) { return false; } if (settings.HDHRPath != "") return true; else return false; }