private void DoImage(HttpProcessor oHttpProcessor) { if (DoCacheResponseIfWarranted(oHttpProcessor)) { return; } LoadBinary(oHttpProcessor); string sImagePath = htCachedBinaryPaths[oHttpProcessor.pathParts[1].ToLower()]?.ToString(); if (string.IsNullOrWhiteSpace(sImagePath) || !File.Exists(sImagePath)) { htCachedImageHTML[oHttpProcessor.pathParts[1]] = Properties.Resources.HTML_NoResource .Replace("<!-- SecondsBetweenRefresh -->", (PluginAppSettings.GetInt("SecondsBetweenRefresh")).ToString()) .Replace("<!-- Path -->", sImagePath) .Replace("<!-- Title -->", PluginHelper.StateManager.GetAllSelectedGames()[0].Title) ; htCachedImagePaths[oHttpProcessor.pathParts[1]] = ""; } else if (htCachedImagePaths[oHttpProcessor.pathParts[1].ToLower()]?.ToString() != sImagePath) { htCachedImagePaths[oHttpProcessor.pathParts[1]] = sImagePath; htCachedImageHTML[oHttpProcessor.pathParts[1]] = Properties.Resources.HTML_Marque .Replace("<!-- SecondsBetweenRefresh -->", PluginAppSettings.GetString("SecondsBetweenRefresh")) .Replace("<!-- Base64Image -->", MakeBinarySrcData(sImagePath, (byte[])htCachedBinaries[oHttpProcessor.pathParts[1]])); } WriteImageHTML(oHttpProcessor, htCachedImageHTML[oHttpProcessor.pathParts[1]]?.ToString()); }
private static bool OneAndOnlyOneGameSelected(HttpProcessor oHttpProcessor) { if (PluginHelper.StateManager.GetAllSelectedGames()?.Length == 1) { return(true); } else { WriteImageHTML(oHttpProcessor, Properties.Resources.HTML_NoGame.Replace("<!-- SecondsBetweenRefresh -->", (PluginAppSettings.GetInt("SecondsBetweenRefresh")).ToString())); return(false); } }
private void frmSettings_Load(object sender, EventArgs e) { txtPort.Text = PluginAppSettings.GetInt("Port") == 0 ? "80" : PluginAppSettings.GetInt("Port").ToString(); txtSecurePort.Text = PluginAppSettings.GetInt("SecurePort") == 0 ? "443" : PluginAppSettings.GetInt("SecurePort").ToString(); chkPortEnabled.Checked = PluginAppSettings.GetBoolean("PortEnabled"); chkSecurePortEnabled.Checked = PluginAppSettings.GetBoolean("SecurePortEnabled"); nudSecondsBetweenRefresh.Value = (PluginAppSettings.GetInt("SecondsBetweenRefresh") > 0 && PluginAppSettings.GetInt("SecondsBetweenRefresh") < 1000) ? PluginAppSettings.GetInt("SecondsBetweenRefresh") : 15; cmbAutomaticUpdates.SelectedIndex = cmbAutomaticUpdates.FindString(PluginAppSettings.GetBoolean("AutomaticUpdates") ? "On" : "Off"); SetServerStatus(); btnSave.Enabled = false; btnCheckForUpdates.Enabled = true; }
private void DoManual(HttpProcessor oHttpProcessor) { if (DoCacheResponseIfWarranted(oHttpProcessor) || !OneAndOnlyOneGameSelected(oHttpProcessor)) { return; } LoadBinary(oHttpProcessor); string sManualPath = htCachedBinaryPaths["manual"]?.ToString(); if (!string.IsNullOrWhiteSpace(sManualPath) && (htCachedImagePaths["manual"]?.ToString() != sManualPath) && File.Exists(sManualPath)) { htCachedImagePaths["manual"] = sManualPath; htCachedImageHTML["manual"] = Properties.Resources.HTML_Manual .Replace("<!-- SecondsBetweenRefresh -->", (PluginAppSettings.GetInt("SecondsBetweenRefresh") * 1000).ToString()) .Replace("<!-- BinaryPath -->", "/binary/manual") ; } else { htCachedImageHTML["manual"] = Properties.Resources.HTML_NoResource .Replace("<!-- SecondsBetweenRefresh -->", (PluginAppSettings.GetInt("SecondsBetweenRefresh")).ToString()) .Replace("<!-- Path -->", sManualPath) .Replace("<!-- Title -->", PluginHelper.StateManager.GetAllSelectedGames()[0].Title) ; htCachedImagePaths["manual"] = ""; } WriteImageHTML(oHttpProcessor, htCachedImageHTML["manual"].ToString()); }
private void frmSettings_Load(object sender, EventArgs e) { txtPort.Text = PluginAppSettings.GetInt("Port") == 0 ? "80" : PluginAppSettings.GetInt("Port").ToString(); txtSecurePort.Text = PluginAppSettings.GetInt("SecurePort") == 0 ? "443" : PluginAppSettings.GetInt("SecurePort").ToString(); chkPortEnabled.Checked = PluginAppSettings.GetBoolean("PortEnabled"); chkSecurePortEnabled.Checked = PluginAppSettings.GetBoolean("SecurePortEnabled"); nudSecondsBetweenRefresh.Value = (PluginAppSettings.GetInt("SecondsBetweenRefresh") > 0 && PluginAppSettings.GetInt("SecondsBetweenRefresh") < 1000) ? PluginAppSettings.GetInt("SecondsBetweenRefresh") : 15; cmbAutomaticUpdates.SelectedIndex = cmbAutomaticUpdates.FindString(PluginAppSettings.GetBoolean("AutomaticUpdates") ? "On" : "Off"); chkWriteEnabled.Checked = PluginAppSettings.GetBoolean("WriteEnabled"); SetServerStatus(); btnSave.Enabled = false; btnCheckForUpdates.Enabled = true; lblVersion.Text = PluginAppSettings.GetString("Version"); // The version information in the config file overrides the assembly version. if (string.IsNullOrEmpty(lblVersion.Text)) { lblVersion.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString(); } }
public void StartHttpServices() { MarquesasHttpServerInstance.RunningServer.port = PluginAppSettings.GetBoolean("PortEnabled") ? PluginAppSettings.GetInt("Port") : -1; MarquesasHttpServerInstance.RunningServer.secure_port = PluginAppSettings.GetBoolean("SecurePortEnabled") ? PluginAppSettings.GetInt("SecurePort") : -1; MarquesasHttpServerInstance.RunningServer.Initialize(); MarquesasHttpServerInstance.RunningServer.WarnIfPortsAreNotAvailable(); MarquesasHttpServerInstance.RunningServer.Start(); MarquesasHttpServerInstance.RunningServer.FirstTimeRunCheck(); }