} // Run private bool Init() { // load configuration var result = AppUiConfiguration.Load(null, Console.WriteLine); if (result.IsError) { Console.WriteLine(result.Message); return(false); } // if // get channels Console.WriteLine("Loading broadcast services"); var providers = AppUiConfiguration.Current.Cache.LoadXml <ProviderDiscoveryRoot>("ProviderDiscovery", AppUiConfiguration.Current.ContentProvider.Bootstrap.MulticastAddress); ServiceProvider = UiProviderDiscovery.GetUiServiceProviderFromKey(providers, "dem_19.imagenio.es"); var downloader = new UiBroadcastDiscoveryDownloader(); BroadcastDiscovery = downloader.Download(null, ServiceProvider, null, true); ParentalGuidanceCodes = new Dictionary <string, string>(); EpgServices = new Dictionary <string, EpgService>(); return(true); } // Init
} // ConfigLoadDisplayProgress private static InitializationResult ValidateConfiguration(AppUiConfiguration config) { string recorderPath; recorderPath = config.Folders.Install; #if !DEBUG var myPath = Application.StartupPath; if (myPath.EndsWith(Properties.InvariantTexts.DebugLocationPath, StringComparison.OrdinalIgnoreCase)) { recorderPath = Path.Combine(myPath, Properties.InvariantTexts.DebugRecorderLauncherPath); recorderPath = Path.GetFullPath(recorderPath); } else { recorderPath = config.Folders.Install; } // if-else #endif // DEBUG var recorderLauncherPath = Path.Combine(recorderPath, Properties.InvariantTexts.ExeRecorderLauncher); if (!File.Exists(recorderLauncherPath)) { return(new InitializationResult() { Message = string.Format(Properties.Texts.MyAppRecorderLauncherNotFound, recorderLauncherPath) }); } // if MyApplication.RecorderLauncherPath = recorderLauncherPath; return(InitializationResult.Ok); } // ValidateConfiguration
} // SetWizardResult static int LaunchWizard() { InitializationResult initResult; bool launchMainProgram = false; int result = 0; WizardEndResult = DialogResult.Abort; AppUiConfig = Installation.LoadRegistrySettings(out initResult); if (AppUiConfig == null) { Program.SetWizardResult(DialogResult.Abort, string.Format("{0}\r\n{1}", initResult.Caption, initResult.Message), initResult.InnerException); goto End; } // if BasicGoogleTelemetry.Init(Properties.Resources.AnalyticsGoogleTrackingId, AppUiConfig.AnalyticsClientId, true, true, true); using (var dlg = new WizardWelcomeDialog()) { switch (dlg.ShowDialog()) { case DialogResult.Cancel: Program.SetWizardResult(DialogResult.Cancel); goto End; } // switch } // using using (var dlg = new ConfigForm()) { dlg.ShowDialog(); } // using dlg End: using (var dlg = new WizardEndDialog()) { dlg.EndResult = WizardEndResult; dlg.ErrorMessage = WizardEndText; dlg.ErrorException = WizardEndException; dlg.ShowDialog(); launchMainProgram = dlg.checkRunMainProgram.Checked; result = (WizardEndResult == DialogResult.OK) ? 0 : -1; } // using if (launchMainProgram) { var message = Installation.Launch(null, AppUiConfig.Folders.Install, Properties.Resources.SuccessExecuteProgram); if (message != null) { MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop); } // if } // if return(result); } // LaunchWizard
} // Is32BitWindow public static AppUiConfiguration LoadRegistrySettings(out InitializationResult initializationResult) { Is32BitWindows = WindowsBitness.Is32BitWindows(); var result = AppUiConfiguration.LoadRegistryAppConfiguration(out initializationResult); #if DEBUG RedistFolder = Path.Combine(result.Folders.Base, "Bin\\Redist"); #else RedistFolder = Path.Combine(result.Folders.Install, "Redist"); #endif return(result); } // LoadRegistrySettings
} // GetMainForm #endregion #region Initialization methods private InitializationResult LoadConfiguration() { InitializationResult result; try { result = AppUiConfiguration.Load(null, ConfigLoadDisplayProgress); if (result.IsError) { return(result); } result = ValidateConfiguration(AppUiConfiguration.Current); if (result.IsError) { return(result); } BasicGoogleTelemetry.Init(Properties.InvariantTexts.AnalyticsGoogleTrackingId, AppUiConfiguration.Current.AnalyticsClientId, AppUiConfiguration.Current.User.Telemetry.Enabled, AppUiConfiguration.Current.User.Telemetry.Usage, AppUiConfiguration.Current.User.Telemetry.Exceptions); BasicGoogleTelemetry.SendScreenHit("SplashScreen"); return(InitializationResult.Ok); } catch (Exception ex) { return(new InitializationResult() { Caption = Properties.Texts.MyAppLoadConfigExceptionCaption, Message = Properties.Texts.MyAppLoadConfigException, InnerException = ex }); } // try-catch } // LoadConfiguration
} // LoadConfiguration private InitializationResult GetConfiguration() { InitializationResult result; try { result = AppUiConfiguration.Load(null, LoadDisplayProgress); if (result.IsError) { return(result); } return(InitializationResult.Ok); } catch (Exception ex) { return(new InitializationResult() { Caption = "Application configuration error", Message = "An unexpected error has occured while loading the application configuration.", InnerException = ex }); } // try-catch } // GetConfiguration
public static bool Create(string vlcPath, string rootSaveLocation, TelemetryConfiguration analytics, EpgConfig epg, bool sdPriority, string xmlConfigPath, out string message) { UserConfig user; try { user = new UserConfig() { Telemetry = analytics, PreferredLanguages = Properties.Texts.DvbIpTv_PreferredLanguages, Record = new RecordConfig() { SaveLocations = new RecordSaveLocation[] { new RecordSaveLocation() { Path = rootSaveLocation }, // RecordSaveLocation new RecordSaveLocation() { Name = Properties.Texts.SaveLocationSeriesName, Path = Path.Combine(rootSaveLocation, Properties.Texts.SaveLocationSeriesFolder) }, // RecordSaveLocation new RecordSaveLocation() { Name = Properties.Texts.SaveLocationMoviesName, Path = Path.Combine(rootSaveLocation, Properties.Texts.SaveLocationMoviesFolder) } // RecordSaveLocation }, // SaveLocations TaskSchedulerFolders = new RecordTaskSchedulerFolder[] { new RecordTaskSchedulerFolder() { Name = Properties.Texts.TaskSchedulerFolderDvbIpTv, Path = "\\IPTViewr" } // RecordTaskSchedulerFolder }, // TaskSchedulerFolders Recorders = new RecorderConfig[] { new RecorderConfig() { Name = "VLC", Path = vlcPath, Arguments = new string[] { "--intf=dummy", "--dummy-quiet", "--demux=dump", "--demuxdump-file={param:OutputFile}", "--meta-title={param:Description.Name}", "{param:Channel.Url}", ":run-time={param:Duration.TotalSeconds}", "vlc://quit", } // Arguments } // RecorderConfig } // Recorders }, // Record Epg = epg, ChannelNumberStandardDefinitionPriority = sdPriority, }; // user foreach (var location in user.Record.SaveLocations) { Directory.CreateDirectory(location.Path); } // foreach var tvPlayers = GetTvPlayers(vlcPath); var movistarPlusIpTvProviderSettings = new IpTvProviderSettings() { ProviderClass = typeof(IpTvProviderMovistarPlus).AssemblyQualifiedName }; var config = AppUiConfiguration.CreateForUserConfig(user); config.RegisterConfiguration(new UiBroadcastListSettingsRegistration(), null, true); config.RegisterConfiguration(new TvPlayersSettingsRegistration(), tvPlayers, false); config.RegisterConfiguration(new NetworkSettingsRegistration(), null, true); config.RegisterConfiguration(new IpTvProviderSettingsRegistration(), movistarPlusIpTvProviderSettings, false); config.Save(xmlConfigPath); message = Properties.Texts.ConfigurationCreateOk; return(true); } catch (Exception ex) { message = string.Format(Properties.Texts.ConfigurationCreateException, ex.ToString()); return(false); } // try-catch } // Create