/// <summary> /// Wird beim Starten der Anwendung aufgerufen. /// </summary> /// <param name="sender">Wird ignoriert.</param> /// <param name="e">Die Befehlszeilenparameter.</param> private void Application_Startup(object sender, StartupEventArgs e) { // Check settings var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); if (!version.Equals(RC_Learner.Properties.Settings.Default.Version)) { // Upgrade RC_Learner.Properties.Settings.Default.Upgrade(); RC_Learner.Properties.Settings.Default.Version = version; RC_Learner.Properties.Settings.Default.Save(); } // Apply language UserProfile.ApplyLanguage(); // Check parameters if (e.Args.Length != 1) { Shutdown(); } else { LearnContext = LearnContext.Create(e.Args[0], null); } }
/// <summary> /// Der Einsprungpunkt für einen <i>Card Server</i>. Die Befehlszeilenparameter beschreiben /// die Kommunikationskanäle zum steuernden Client. /// </summary> /// <param name="args">Befehlsparameter für die Kommunikation.</param> public static void Main(string[] args) { // Be safe try { // Always use the configured language UserProfile.ApplyLanguage(); // Set priority Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; // Open the communication channels and attach to the pipe server using (AnonymousPipeClientStream reader = new AnonymousPipeClientStream(PipeDirection.In, args[0])) using (AnonymousPipeClientStream writer = new AnonymousPipeClientStream(PipeDirection.Out, args[1])) using (ServerImplementation server = ServerImplementation.CreateInMemory()) for (Request request; null != (request = Request.ReceiveRequest(reader));) { // Process it Response response = request.Execute(server); // Send the response response.SendResponse(writer); } } catch (Exception e) { // Report error Logging.Log(EventLogEntryType.Error, e.ToString()); } }
public static void Main(string[] args) { // Set user language according to preferrences UserProfile.ApplyLanguage(); // Prepare GUI Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new ReaderMain(args)); }
public static void Main() { // Activate DVB.NET language settings UserProfile.ApplyLanguage(); // Prepare UI Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Start the form Application.Run(new AnalyserMain()); }
/// <summary> /// Startet das Hauptprogramm. /// </summary> /// <param name="args">Befehlszeilenparameter.</param> public static void Main(string[] args) { // Load the language UserProfile.ApplyLanguage(); // Standard stuff Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Force dialog to open UserProfile.ShowDialog(); }
public static void Main(string[] args) { // Check settings var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); if (!version.Equals(Properties.Settings.Default.Version)) { // Upgrade Properties.Settings.Default.Upgrade(); Properties.Settings.Default.Version = version; Properties.Settings.Default.Save(); } // Use the user language UserProfile.ApplyLanguage(); // Standard stuff Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new AdminMain()); }
/// <summary> /// Führt die eintreffenden Aufträge aus. /// </summary> private void WorkerThread(object reset) { // Always use the configured language UserProfile.ApplyLanguage(); // Use hardware manager using (HardwareManager.Open()) { // Device to use Hardware device; // Try to attach profile try { // Open it device = HardwareManager.OpenHardware(Profile); // Should reset if ((bool)reset) { device.ResetWakeupDevice(); } // Report success ActionDone(null, null); } catch (Exception e) { // Report error ActionDone(e, null); // Did it return; } // Loop for (var lastIdle = DateTime.UtcNow; m_Running;) { // Wait for new item to process m_Trigger.WaitOne(); // Load operation var operation = m_Operation; // Clear m_Operation = null; // Process if (m_Running) { if (operation != null) { try { // Process var result = operation(device); // See if there is at least one active source with a program guide running var withGuide = Streams.Values.FirstOrDefault(stream => stream.IsProgamGuideActive.GetValueOrDefault(false)); // Check for service parser operation if (m_ServiceParser == null) { // Can be activated it at least one source with active program guide if (withGuide != null) { try { // Create m_ServiceParser = new ServiceParser(Profile, withGuide.Manager.Source); } catch { // Ignore any error m_ServiceParser = null; } } } else { // Only allowed if there is at least one source with active program guide if (withGuide == null) { DisableServiceParser(); } } // Done if (!ReferenceEquals(result, DelayedOperationTag)) { ActionDone(null, result); } } catch (Exception e) { // Report ActionDone(e, null); } } } // See if idle processing should be started if (m_Running) { if ((DateTime.UtcNow - lastIdle).TotalSeconds >= 5) { // Run OnIdle(device); // Reset lastIdle = DateTime.UtcNow; } } } // Reset EPG flag EPGProgress = null; // Clear EPG list to preserve memory m_EPGItems.Clear(); // Reset PSI scan flag using (var scanner = m_Scanner) { // Forget all m_ScanProgress = -1; m_Scanner = null; } // Just be safe try { // Final cleanup RemoveAll(); } catch { // Ignore any error } } }
/// <summary> /// Analysiert die aktuelle Konfiguration des Suchlaufs auf Basis /// der DVB <i>Network Information Table (NIT)</i> Informationen. /// </summary> private void AnalyserThread() { // Be safe try { // Configure language UserProfile.ApplyLanguage(); // Uses hardware manager using (HardwareManager.Open()) { // Attach to the hardware itself Hardware device = HardwareManager.OpenHardware(Profile); // Reset counters TotalLocations = m_Locations.Count; CurrentLocation = 0; // Last inversion used SpectrumInversions lastInversion = SpectrumInversions.On; // Process all transponders foreach (GroupLocation location in m_Locations) { // Update counter ++CurrentLocation; // Reset CurrentLocationGroupsPending = 0; CurrentLocationGroup = 0; // Check caller if (!LocationStart(location)) { return; } // Groups found on this location Dictionary <SourceGroup, bool> found = new Dictionary <SourceGroup, bool>(); // Groups with valid network information - only those are considered List <SourceGroup> nitAvailable = new List <SourceGroup>(); // Load counter CurrentLocationGroupsPending = location.Groups.Count; // Process all groups foreach (SourceGroup group in location.Groups) { // Get the expected type Type groupType = group.GetType(); // Clone the group SourceGroup newGroup = SourceGroup.FromString <SourceGroup>(group.ToString()); // Count up --CurrentLocationGroupsPending; ++CurrentLocationGroup; // See if this is already processed if (null != found.Keys.FirstOrDefault(p => p.CompareTo(newGroup, true))) { continue; } // Check for external termination if (null == m_Worker) { return; } // Not supported if (!Profile.SupportsGroup(newGroup) || !device.CanHandle(newGroup)) { // Remember m_UnhandledGroups.Add(newGroup); // Next continue; } // Check caller if (!GroupStart(location, newGroup)) { return; } // Attach to the group if (null != SelectGroup(device, location, newGroup, ref lastInversion)) { // See if we are a cable group CableGroup cableGroup = newGroup as CableGroup; // Attach to the NIT var nit = device.GetLocationInformation(15000); if (null != nit) { // Remember nitAvailable.Add(newGroup); // Process foreach (SourceGroup other in nit.Groups) { if (other.GetType() == groupType) { // See if this is a cable group CableGroup otherCable = other as CableGroup; // Update inversion if (null != otherCable) { // Other must be cable, too if (null == cableGroup) { continue; } // Use same parameters otherCable.SpectrumInversion = cableGroup.SpectrumInversion; otherCable.Bandwidth = cableGroup.Bandwidth; } // Report if (ScannerTraceSwitch.Level >= TraceLevel.Info) { Trace.WriteLine(string.Format(Properties.Resources.Trace_Scanner_NIT, other), ScannerTraceSwitch.DisplayName); } // Mark it found[other] = true; } } } } // Check caller if (!GroupDone(location, newGroup)) { return; } } // Create a brand new scan location ScanLocation scan = location.ToScanLocation(); // Try to update foreach (SourceGroup group in nitAvailable) { // Try to find the full qualified name SourceGroup nitGroup = found.Keys.FirstOrDefault(p => p.CompareTo(group, true)); // Update if (null == nitGroup) { scan.Groups.Add(group); } else { scan.Groups.Add(nitGroup); } } // Just remember m_AnalyseResult[location] = scan; // Check caller if (!LocationDone(location)) { return; } } } } catch (Exception e) { // Remember m_ThreadException = e; } }
/// <summary> /// Führt den eigentlichen Sendersuchlauf aus. /// </summary> private void ScannerThread() { // Be safe try { // Configure language UserProfile.ApplyLanguage(); // Uses hardware manager using (HardwareManager.Open()) { // Attach to the hardware itself var device = HardwareManager.OpenHardware(Profile); // Tell it that we only do a scan device.PrepareSourceScan(); // Start loading location result list foreach (var location in m_Locations) { m_ScanResults.Add(location.Clone()); } // Reset counters TotalLocations = m_Locations.Count; // Last successfull inversion var lastInversion = SpectrumInversions.On; // Process all transponders for (CurrentLocation = 0; CurrentLocation < m_Locations.Count;) { // Get new and old var location = m_Locations[CurrentLocation]; var newLocation = m_ScanResults[CurrentLocation]; // Count ++CurrentLocation; // Reset CurrentLocationGroupsPending = 0; CurrentLocationGroup = 0; // Check caller if (!LocationStart(location)) { return; } // Allow NIT scan on... var enableNIT = new List <SourceGroup>(); var foundInfo = new List <SourceGroup>(); // Startup and load the groups from the configuration foreach (SourceGroup group in location.Groups) { enableNIT.Add(group); } // All we have to process var process = new List <SourceGroup>(enableNIT); // Allowed group type var groupType = (process.Count > 0) ? process[0].GetType() : null; // All we did so far var done = new HashSet <SourceGroup>(); // Process all groups while (process.Count > 0) { // Take the first one var group = process[0]; // Remove it process.RemoveAt(0); // Reset counter CurrentLocationGroupsPending = process.Count; // Count what we did ++CurrentLocationGroup; // Already done if (done.Contains(group)) { continue; } // Found group information on equivalent group if (foundInfo.FirstOrDefault(g => g.CompareTo(group, true)) != null) { continue; } // Mark as done done.Add(group); // Check for external termination if (m_Worker == null) { return; } // Not supported if (!Profile.SupportsGroup(group) || !device.CanHandle(group)) { // Remember m_UnhandledGroups.Add(group); // Next continue; } // Read the configuration var filter = Profile.GetFilter(group); // See if this should be skiped if (filter != null) { if (filter.ExcludeFromScan) { // Remember m_GroupsExcluded.Add(group); // Next continue; } } // Check caller if (!GroupStart(location, group)) { return; } // See if we should process the NIT var checkNIT = enableNIT.Contains(group); // See if we should process if (checkNIT || group.IsComplete) { // Clone the group - may change group = SourceGroup.FromString <SourceGroup>(group.ToString()); // Attach to the group var info = SelectGroup(device, location, group, ref lastInversion); // Mark as done again - group may be updated for DVB-C and if unchanged this is simply a no-operation done.Add(group); // Read the configuration again - actually for DVB-C it may change filter = Profile.GetFilter(group); // See if this should be skiped if (filter != null) { if (filter.ExcludeFromScan) { // Remember m_GroupsExcluded.Add(group); // Next continue; } } // Remember that we found a group information - transponder is not dead if (info != null) { foundInfo.Add(group); } // See if NIT update is allowed if (checkNIT) { if (info != null) { // See if we are a cable group var cableGroup = group as CableGroup; // Try load var nit = device.GetLocationInformation(15000); if (nit != null) { foreach (SourceGroup other in nit.Groups) { if (other.GetType() == groupType) { // See if this is a cable group var otherCable = other as CableGroup; // Disable NIT scan on the group as is enableNIT.RemoveAll(g => g.CompareTo(other, true)); process.RemoveAll(g => g.CompareTo(other, true)); // Set inversion if (otherCable != null) { if (cableGroup != null) { // Use same parameters otherCable.SpectrumInversion = cableGroup.SpectrumInversion; otherCable.Bandwidth = cableGroup.Bandwidth; // Disable NIT scan on the group which may be DVB-C corrected enableNIT.RemoveAll(g => g.CompareTo(otherCable, true)); process.RemoveAll(g => g.CompareTo(otherCable, true)); } } // Report if (ScannerTraceSwitch.Level >= TraceLevel.Info) { Trace.WriteLine(string.Format(Properties.Resources.Trace_Scanner_NIT, other), ScannerTraceSwitch.DisplayName); } // Add for processing process.Insert(0, other); } } } } } // Reset counter - may be updated if a new NIT was processed CurrentLocationGroupsPending = process.Count; // Skip if a legacy template group if (group.IsComplete) { // Merge newLocation.Groups.Add(group); // Process this group if (info == null) { m_Protocol.Add(new ProtocolRecord { Mode = ProtocolRecordMode.EmptyGroup, Location = location, Group = group }); } else { foreach (var source in info.Sources) { // Only stations var station = source as Station; if (station == null) { continue; } // Attach to the filter var modifiers = Profile.GetFilter(source); if (modifiers != null) { if (modifiers.ExcludeFromScan) { continue; } else { modifiers.ApplyTo(station); } } // Remember group.Sources.Add(station); // Get the count int foundOfType; if (!SourcesFound.TryGetValue(station.SourceType, out foundOfType)) { foundOfType = 0; } // Update SourcesFound[station.SourceType] = ++foundOfType; // Ask user if (!StationFound(location, group, station)) { return; } } } } } // Check caller if (!GroupDone(location, group)) { return; } } // Check caller if (!LocationDone(location)) { return; } } } } catch (Exception e) { // Remember m_ThreadException = e; } }
static void Main(string[] args) { // Be safe try { // Check settings var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); if (!version.Equals(Properties.Settings.Default.Version)) { // Upgrade Properties.Settings.Default.Upgrade(); Properties.Settings.Default.Version = version; Properties.Settings.Default.Save(); } // Prepare Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Force priority Process.GetCurrentProcess().PriorityClass = Properties.Settings.Default.Priority; // Check start mode string startMode = ((null == args) || (args.Length < 1)) ? null : args[0]; // Apply language UserProfile.ApplyLanguage(); // See how we should work if (Equals(startMode, "/Reset")) { // Ask user if (DialogResult.Yes != MessageBox.Show(Properties.Resources.ResetSettings, Properties.Resources.Confirmation, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)) { return; } // Process Properties.Settings.Default.Reset(); Properties.Settings.Default.Save(); } if (Equals(startMode, "/LearnRC")) { // Run RC configuration RCSettings.Edit(RCSettings.ConfigurationFile).Dispose(); } else { // Check OSD mode if (Properties.Settings.Default.ManualOSDLegacyMode) { OverlayWindow.UseLegacyOverlay = Properties.Settings.Default.OSDLegacyMode; } // Form to start ViewerMain form = null; // Test parameter if (!string.IsNullOrEmpty(startMode)) { if (Equals(startMode, "/VCR")) { // Create in VCR LIVE / CURRENT mode form = new ViewerMain(StartupModes.RemoteVCR); } else if (startMode.ToLower().StartsWith("dvbnet://")) { // Start with the server part startMode = startMode.Substring(9); // See if this is a regular start using the URL protocol bool startedByProtocol = !startMode.StartsWith("*"); // Must be the control center if (startedByProtocol) { // Prepare for special decoding byte[] tmp = new byte[startMode.Length]; // Copy by byte for (int i = tmp.Length; i-- > 0;) { tmp[i] = (byte)startMode[i]; } // Retrieve startMode = Encoding.UTF8.GetString(tmp); } else { // Just cut off the control character startMode = startMode.Substring(1); } // Just correct for URL stuff startMode = Uri.UnescapeDataString(startMode.Replace('+', ' ')); // See if this is a file replay int file = startMode.ToLower().IndexOf("/play="); if (file < 0) { // Create in VCR CURRENT mode form = new ViewerMain(StartupModes.WatchOrTimeshift, startMode); } else { // Get server and file name string server = startMode.Substring(0, file); string path = startMode.Substring(file + 6); // Replay form = new ViewerMain(StartupModes.PlayRemoteFile, path, server); } } else if (startMode.StartsWith("/VCR=")) { // Create in VCR REPLY mode form = new ViewerMain(StartupModes.PlayRemoteFile, startMode.Substring(5), null); } else if (startMode.StartsWith("/TCP=")) { // Create in STREAMING SLAVE mode form = new ViewerMain(StartupModes.ConnectTCP, startMode.Substring(5)); } else if (startMode.StartsWith("/FILE=")) { // Create in LOCAL REPLAY mode form = new ViewerMain(StartupModes.PlayLocalFile, startMode.Substring(6)); } } // Local mode if (form != null) { // Run the application Application.Run(form); } else { // Ask for the profile var profile = UserProfile.Profile; if (profile != null) { using (HardwareManager.Open()) Application.Run(new ViewerMain(profile)); } } } } catch (Exception e) { // Report as is MessageBox.Show(e.ToString()); // Terminate Environment.Exit(1); } // If we are running as the users shell log off using (var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Winlogon")) if (key != null) { try { // Load shell var shell = key.GetValue("Shell") as string; if (shell != null) { // Remove quotes if (shell.Length >= 2) { if (shell.StartsWith("\"")) { if (shell.EndsWith("\"")) { shell = shell.Substring(1, shell.Length - 2).Replace("\"\"", "\""); } } } // Clip shell = shell.Trim(); // See what's left if (!string.IsNullOrEmpty(shell)) { // Attach to file var file1 = new FileInfo(shell); var file2 = new FileInfo(Application.ExecutablePath); // Check if (string.Equals(file1.FullName, file2.FullName, StringComparison.InvariantCultureIgnoreCase)) { ExitWindowsEx(0x10, 0); } } } } catch { // Ignore any error } } }