} // constructor private void ConfigForm_Load(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this); selectFolder.Description = Properties.Texts.SelectFolderSaveDescription; openFile.Title = Properties.Texts.OpenFileVlcTitle; openFile.Filter = Properties.Texts.OpenFileVlcFilter; try { DefaultRecordingsSavePath = Installation.GetCurrentUserVideosFolder(); } catch { DefaultRecordingsSavePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } // try-catch wizardControl.Initialization[wizardPageReadme.Name] = PageReadme_Setup; wizardControl.Initialization[wizardPagePrerequisites.Name] = PagePrerequisites_Setup; wizardControl.Initialization[wizardPageFirewall.Name] = PageFirewall_Setup; wizardControl.Initialization[wizardPageBasic.Name] = PageBasic_Setup; wizardControl.Initialization[wizardPageRecordings.Name] = PageRecordings_Setup; wizardControl.SelectedTab = null; wizardControl.Visible = false; } // ConfigForm_Load
} // DialogRecordChannel_Shown #endregion #region Form events implementation private void DialogRecordChannel_Load_Implementation(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this); // Initialize if (Task == null) { if (this.DesignMode) { Task = RecordTask.CreateWithDefaultValues(null); IsNewTask = true; } else { throw new ArgumentNullException(); } // if-else } // if // General InitGeneralData(); // Schedule tab InitScheduleData(); // Duration tab InitDurationData(); // Description tab InitDescriptionData(); // Save tab InitSaveData(); // Advanced tab InitAdvancedData(); } // DialogRecordChannel_Load_Implementation
} // ShowConfigurationForm public static T ShowConfigurationForm <T>(IWin32Window owner, string settingsGuid, T overrideSettings) where T : class, IConfigurationItem { var registration = AppUiConfiguration.Current.ItemsRegistry[new Guid(settingsGuid)]; var data = new ConfigurationItem() { Registration = registration, ExistingData = overrideSettings ?? AppUiConfiguration.Current[registration.DirectIndex] }; var items = new List <ConfigurationItem>(1); items.Add(data); using (var form = new ConfigurationForm()) { BasicGoogleTelemetry.SendScreenHit(form, data.Registration.ItemType.Name); form.ConfigurationItems = items; var dialogResult = form.ShowDialog(owner); if (dialogResult != DialogResult.OK) { return(null); } else { return((T)items[0].NewData); } // if-else } // using } // ShowConfigurationForm
} // ErrorException private void WizardEndDialog_Load(object sender, EventArgs e) { switch (EndResult) { case System.Windows.Forms.DialogResult.OK: BasicGoogleTelemetry.SendScreenHit(this, "Ok"); pictureEndIcon.Image = Properties.Resources.Success_48x48; labelEndTitle.Text = Properties.Texts.WizardEndTitleOk; labelEndText.Text = string.Format(labelEndText.Text, Properties.Texts.WizardEndTextOk); checkRunMainProgram.Visible = true; checkRunMainProgram.Checked = !string.IsNullOrEmpty(Program.AppUiConfig.Folders.Install); checkRunMainProgram.Enabled = checkRunMainProgram.Checked; checkRunMainProgram.Text = string.Format(checkRunMainProgram.Text, Properties.Texts.ProductMainProgramName); break; case System.Windows.Forms.DialogResult.Cancel: BasicGoogleTelemetry.SendScreenHit(this, "Cancel"); pictureEndIcon.Image = Properties.Resources.Warning_48x48; labelEndTitle.Text = Properties.Texts.WizardEndTitleCancel; labelEndText.Text = string.Format(labelEndText.Text, Properties.Texts.WizardEndTextCancel); break; default: BasicGoogleTelemetry.SendScreenHit(this, "Abort"); pictureEndIcon.Image = Properties.Resources.Exclamation_48x48; labelEndTitle.Text = Properties.Texts.WizardEndTitleAbort; labelEndText.Text = string.Format(labelEndText.Text, Properties.Texts.WizardEndTextAbort); linkErrorDetails.Left = checkRunMainProgram.Left; linkErrorDetails.Visible = true; break; } // switch } // WizardEndDialog_Load
} // WizardTabControl_Selected protected override void OnSelecting(TabControlCancelEventArgs e) { bool isAllowed; base.OnSelecting(e); if (DesignMode) { return; } if (e.TabPage == null) { return; } isAllowed = (IsPageAllowed.TryGetValue(e.TabPage.Name, out isAllowed)) ? isAllowed : false; e.Cancel = !isAllowed; if (isAllowed) { Action init; if (Initialization.TryGetValue(e.TabPage.Name, out init)) { Initialization.Remove(e.TabPage.Name); init(); BasicGoogleTelemetry.SendScreenHit(this.FindForm(), e.TabPage.Text); } // if } // if } // OnSelecting
static int Main(string[] arguments) { // set thread name for debugging Thread.CurrentThread.Name = "Program main thread"; //Application.ThreadException += Application_ThreadException; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var appContext = new MyApplicationContext(); Application.Run(appContext); var exitCode = appContext.ExitCode; appContext.Dispose(); BasicGoogleTelemetry.SendScreenHit("ChannelList_Main: End"); BasicGoogleTelemetry.ManageSession(true); BasicGoogleTelemetry.EnsureHitsSents(); // Ensure all background threads end right now (like updating the EPG data with EpgDownloader) // TODO: Don't to this Thread.Sleep(1000); Environment.Exit(exitCode); return(exitCode); } // Main
} // constructor private void PropertiesDialog_Load(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this, Caption); this.Text = Caption; this.labelDescription.Text = (Description ?? Properties.PropertiesDialog.CaptionDefault); this.pictureBoxItemIcon.Image = ItemIcon; } // PropertiesDialog_Load
} // ChannelListForm_Load private void ChannelListForm_Shown(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this, "Shown"); if (SelectedServiceProvider == null) { SafeCall(SelectProvider); } // if } // ChannelListForm_Shown
} // buttonProviderDetails_Click #region Event handlers implemention private void SelectProviderDialog_Load_Implementation(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this); if (SelectedServiceProvider == null) { SelectedIndexChanged(); } // if LoadServiceProviderList(true); } // SelectProviderDialog_Load_Implementation
} // menuItemChannelRefreshList_Click_Implementation private void menuItemChannelVerify_Click_Implementation(object sender, EventArgs e) { int timeout; MulticastScannerOptionsDialog.ScanWhatList list; IEnumerable <UiBroadcastService> whatList; if ((MulticastScanner != null) && (!MulticastScanner.IsDisposed)) { MulticastScanner.Activate(); return; } // if using (var dialog = new MulticastScannerOptionsDialog()) { var result = dialog.ShowDialog(this); BasicGoogleTelemetry.SendScreenHit(this); if (result != DialogResult.OK) { return; } timeout = dialog.Timeout; list = dialog.ScanList; } // using // filter whole list, if asked for switch (list) { case MulticastScannerOptionsDialog.ScanWhatList.ActiveServices: whatList = from service in BroadcastDiscovery.Services where service.IsInactive == false select service; break; case MulticastScannerOptionsDialog.ScanWhatList.DeadServices: whatList = from service in BroadcastDiscovery.Services where service.IsInactive == true select service; break; default: whatList = BroadcastDiscovery.Services; break; } // switch MulticastScanner = new MulticastScannerDialog() { Timeout = timeout, BroadcastServices = whatList, }; MulticastScanner.ChannelScanResult += MulticastScanner_ChannelScanResult; MulticastScanner.Disposed += MulticastScanner_Disposed; MulticastScanner.ScanCompleted += MulticastScanner_ScanCompleted; MulticastScanner.Show(this); } // menuItemChannelVerify_Click_Implementation
} // ShowEpgBasicData private void FormBasicEpgData_Load(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this); pictureChannelLogo.Image = Service.Logo.GetImage(LogoSize.Size48, true); labelChannelName.Text = string.Format("{0}\r\n{1}", Service.DisplayLogicalNumber, Service.DisplayName); EpgProgramBefore.DisplayData(Service, (EpgPrograms != null) ? EpgPrograms[0] : null, ReferenceTime, Properties.Texts.EpgProgramBeforeCaption); EpgProgramNow.DisplayData(Service, (EpgPrograms != null) ? EpgPrograms[1] : null, ReferenceTime, Properties.Texts.EpgProgramNowCaption); EpgProgramThen.DisplayData(Service, (EpgPrograms != null) ? EpgPrograms[2] : null, ReferenceTime, Properties.Texts.EpgProgramThenCaption); } // FormBasicEpgData_Load
} // ShowRtfHelp public static DialogResult ShowPlainTextHelp(IWin32Window owner, string helpText, string caption = null) { using (var dialog = new HelpDialog()) { BasicGoogleTelemetry.SendScreenHit(dialog, caption); dialog.richTextHelp.Text = helpText; if (caption != null) { dialog.Text = caption; } return(dialog.ShowDialog(owner)); } // using dialog } // ShowRtfHelp
} // DisposeForm private void EpgChannelPrograms_Load(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this); pictureChannelLogo.Image = Service.Logo.GetImage(LogoSize.Size48, true); labelChannelName.Text = string.Format("{0} - {1}", Service.DisplayLogicalNumber, Service.DisplayName); BoldListFont = new Font(listPrograms.Font, FontStyle.Bold); ItalicListFont = new Font(listPrograms.Font, FontStyle.Italic); comboBoxDate.SelectedIndex = DaysDelta; buttonDisplayChannel.Enabled = false; buttonRecordChannel.Enabled = false; } // EpgChannelPrograms_Load
} // Implementation_menuItemProviderDetails_Click private void SelectProvider() { using (var dialog = new SelectProviderDialog()) { dialog.SelectedServiceProvider = SelectedServiceProvider; var result = dialog.ShowDialog(this); BasicGoogleTelemetry.SendScreenHit(this); if (result != DialogResult.OK) { return; } SelectedServiceProvider = dialog.SelectedServiceProvider; ServiceProviderChanged(); } // dialog } // SelectProvider
} // constructor public static void ShowBox(IWin32Window owner, string context) { using (var box = new NotImplementedBox()) { if (context == null) { context = owner.GetType().Name; } else { string.Format("{0}/{1}", owner.GetType().Name, context); } // if-else BasicGoogleTelemetry.SendScreenHit(box, context); box.ShowDialog(owner); } // using } // ShowBox
} // BroadcastServicesCount #region Form events private void DialogMulticastServiceScanner_Load(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this); FormatProgressPercentage = labelProgressPercentage.Text; FormatScanningProgress = labelScanning.Text; FormatEllapsedTime = labelEllapsedTime.Text; BroadcastServicesCount = BroadcastServices.Count(); DisplayStats(new Stats() { Total = BroadcastServicesCount }); labelEllapsedTime.Text = null; labelServiceName.Text = null; labelServiceUrl.Text = null; pictureBoxServiceLogo.Visible = false; buttonRequestCancel.Enabled = false; } // DialogMulticastServiceScanner_Load
} // ToString private void RecordTasksDialog_Shown(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this); AsyncResult result; using (var worker = new BackgroundWorkerDialog()) { worker.Options = new BackgroundWorkerOptions() { TaskDescription = TasksTexts.ObtainingListDescription, OutputData = new AsyncResult(), BackgroundTask = AsyncBuildList, AllowAutoClose = true, }; worker.ShowDialog(this); result = worker.Options.OutputData as AsyncResult; if (worker.Options.OutputException != null) { HandleException(new ExceptionEventData(TasksTexts.ObtainingListException, worker.Options.OutputException)); return; } // if if ((worker.DialogResult != DialogResult.OK) || (worker.Options.OutputData == null)) { return; } } // using worker listViewTasks.BeginUpdate(); listViewTasks.Items.AddRange(result.items); listViewTasks.EndUpdate(); if (listViewTasks.Items.Count == 0) { listViewTasks.Enabled = false; textBoxTaskDetails.Text = TasksTexts.ListEmpty; } else { HandleListViewTasksSelectedIndexChanged(); } // if-else } // RecordTasksDialog_Shown
} // ChannelListForm_FormClosing #endregion #region Form event handlers implementation private void ChannelListForm_Load_Implementation(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this, "Load"); this.Text = Properties.Texts.AppCaption; // disable functionality menuItemDvbRecent.Enabled = enable_menuItemDvbRecent; menuItemDvbPackages.Enabled = enable_menuItemDvbPackages; menuItemDvbExport.Enabled = enable_menuItemDvbExport; var settings = UiBroadcastListSettingsRegistration.Settings; ListManager = new UiBroadcastListManager(listViewChannelList, settings, imageListChannels, imageListChannelsLarge, true); ListManager.SelectionChanged += ListManager_SelectionChanged; ListManager.StatusChanged += ListManager_StatusChanged; SetupContextMenuList(); // Empty notifications Notify(null, null, -1); // set-up EPG functionality EpgDatastore = new EpgMemoryDatastore(); enable_Epg = AppUiConfiguration.Current.User.Epg.Enabled; epgMiniGuide.IsDisabled = !enable_Epg; if (epgMiniGuide.IsDisabled) { foreach (ToolStripItem item in menuItemEpg.DropDownItems) { item.Enabled = false; } // foreach } // if // load from cache, if available SelectedServiceProvider = SelectProviderDialog.GetLastUserSelectedProvider(Properties.Settings.Default.LastSelectedServiceProvider); ServiceProviderChanged(); // notify Splash Screeen the form has finished loading and is about to be shown FormLoadCompleted?.Invoke(this, e); } // ChannelListForm_Load_Implementation
} // ApplicationData private void AboutBox_Load(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this, Assembly.GetEntryAssembly().GetName().Name); this.Text = String.Format(this.Text, Assembly.GetEntryAssembly().GetName().Name); if (ApplicationData != null) { if (ApplicationData.LargeIcon != null) { if (logoPictureBox.Image != null) { logoPictureBox.Image.Dispose(); } logoPictureBox.Image = ApplicationData.LargeIcon; } // if labelAppName.Text = string.Format("{0}", ApplicationData.Name); labelAppVersion.Text = string.Format("{0} - {1}", ApplicationData.Version, ApplicationData.Status); if (ApplicationData.LicenseTextRtf != null) { textBoxDescription.Rtf = ApplicationData.LicenseTextRtf; } else { textBoxDescription.Text = ApplicationData.LicenseText; } // if-else } else { labelAppName.Text = AssemblyTitle; labelAppVersion.Text = AssemblyVersion; labelEULA.Visible = false; textBoxDescription.Visible = false; } // if-else labelProductName.Text = AssemblyProduct; labelVersion.Text = String.Format(labelVersion.Text, AssemblyVersion); labelCopyright.Text = AssemblyCopyright; labelCompanyName.Text = AssemblyCompany; } // AboutBox_Load
} // 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
} // constructor #region Event handlers private void EpgBasicGridDialog_Load(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this); EpgPrograms = new IEpgLinkedList[ServicesList.Count]; ChangeSelectedRow(-1); var workerOptions = new BackgroundWorkerOptions() { OutputData = EpgPrograms, BackgroundTask = AsyncGetEpgPrograms, AfterTask = FillGrid, AllowAutoClose = true, TaskDescription = Properties.Texts.EpgDataLoadingList, AllowCancelButton = true, }; var result = BackgroundWorkerDialog.RunWorkerAsync(this, workerOptions); var close = false; if (workerOptions.OutputException != null) { HandleException(new ExceptionEventData(Properties.Texts.ObtainingListException, workerOptions.OutputException)); close = true; } // if if (result != DialogResult.OK) { close = true; } // if if (close) { Visible = false; Close(); } // if } // EpgBasicGridDialog_Load
} // Dialog_Load private void Dialog_Shown(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(TelemetryScreenName); StartDownload(); } // Dialog_Shown
} // ScanList private void MulticastScannerOptionsDialog_Load(object sender, EventArgs e) { BasicGoogleTelemetry.SendScreenHit(this); } // MulticastScannerOptionsDialog_Load
} // GetRedistFileFullPath #endregion #region Firewall installation public static InitializationResult RunSelfForFirewall(string binPath, string vlcPath) { int exitCode; try { BasicGoogleTelemetry.SendScreenHit("FirewallForm"); var arguments = new StringBuilder(); arguments.AppendFormat("/ForceUiCulture:{0}", CultureInfo.CurrentUICulture.Name); arguments.Append(" /firewall"); if (!string.IsNullOrEmpty(binPath)) { arguments.Append(" \""); arguments.AppendFormat("/decoder:{0}", binPath); // this trick is to avoid a nasty 'feature' of .NET (or even Windows) when parsing arguments // The bin path ends with '\' and if followed by '"', then it will be interpreted as '"' // ["/decoder:foo\bar\" "/vlc:C:\Program Files\foo\bar.exe"] is incorrectly interpreted as [/decoder:foo\bar" /vlc:C:\Program] and [Files\foo\bar.exe] // WARNING: be sure to call Path.GetDirectoryName() before using the path to remove '*.exe' arguments.Append("*.exe"); arguments.Append("\""); } // if if (!string.IsNullOrEmpty(vlcPath)) { arguments.Append(" \""); arguments.AppendFormat("/vlc:{0}", vlcPath); arguments.Append("\""); } // if using (var process = new Process()) { process.StartInfo = new ProcessStartInfo() { FileName = Application.ExecutablePath, Arguments = arguments.ToString(), UseShellExecute = true, Verb = "runas", }; process.Start(); process.WaitForExit(); exitCode = process.ExitCode; } // using process } catch (Win32Exception win32) { if (win32.NativeErrorCode == 1223) // operation cancelled by user { BasicGoogleTelemetry.SendScreenHit("FirewallForm: UACancel"); return(new InitializationResult(Texts.FirewallUserCancel)); } else { BasicGoogleTelemetry.SendScreenHit("FirewallForm: Exception"); return(new InitializationResult(win32)); } // if-else } catch (Exception ex) { BasicGoogleTelemetry.SendScreenHit("FirewallForm: Exception"); BasicGoogleTelemetry.SendExtendedExceptionHit(ex, true, "FirewallForm: Execute", "FirewallForm"); return(new InitializationResult(ex)); } // try-catch if (exitCode == 0) { BasicGoogleTelemetry.SendScreenHit("FirewallForm: Ok"); return(new InitializationResult(Texts.FirewallOk) { IsOk = true }); } else if (exitCode > 0) { BasicGoogleTelemetry.SendScreenHit("FirewallForm: Cancel"); return(new InitializationResult(Texts.FirewallUserCancel)); } else { BasicGoogleTelemetry.SendScreenHit("FirewallForm: " + exitCode.ToString()); return(new InitializationResult((string)null)); } // if-else } // RunSelfForFirewall
} // ConfigurationItem public static DialogResult ShowConfigurationForm(IWin32Window owner, bool autoSave = true, IDictionary <Guid, Action> applyChanges = null) { DialogResult result; bool changed; var q = from item in AppUiConfiguration.Current.ItemsRegistry let registration = item.Value where registration.HasEditor orderby registration.EditorPriority select new ConfigurationItem() { Registration = registration, ExistingData = AppUiConfiguration.Current[registration.DirectIndex] }; var items = q.ToList(); using (var form = new ConfigurationForm()) { BasicGoogleTelemetry.SendScreenHit(form, "(default)"); form.ConfigurationItems = items; result = form.ShowDialog(owner); if (result != DialogResult.OK) { return(result); } // if } // using // save new settings changed = false; foreach (var item in items) { var newData = item.NewData; if (newData == null) { continue; } changed = true; AppUiConfiguration.Current[item.Registration.DirectIndex] = newData; } // foreach // autosave if settings changed if ((changed) && (autoSave)) { AppUiConfiguration.Current.Save(); } // if // apply changes if ((changed) && (applyChanges != null) && (applyChanges.Count > 0)) { Action applyChangesMethod; foreach (var item in items) { if (item.NewData == null) { continue; } if (applyChanges.TryGetValue(item.Registration.Id, out applyChangesMethod)) { applyChangesMethod(); } // if } // foreach } // if return(result); } // ShowConfigurationForm