Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //AVCS Main Menu GUI-v0.98
- //'Sensor Menu' for AIDA64 and Open Weather Maps VoiceAttack profile
- // by SemlerPDX Mar2022 (see credits in menu)
- // VETERANS-GAMING.COM
- using System;
- using System.Data;
- using System.Drawing;
- using System.Diagnostics;
- using System.Globalization;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Net;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- public class VAInline
- {
- public Icon icon;
- public bool pressedCancel = false;
- public string profileTitle = "AVCS SENS - Sensors Menu";
- [STAThread]
- public void main()
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- try
- {
- if (VA.GetText("AVCS_ICON_PATH") != null)
- {
- icon = Icon.ExtractAssociatedIcon(VA.ParseTokens("{TXT:AVCS_ICON_PATH:}"));
- }
- else
- {
- VA.SetText("AVCS_ICON_PATH", VA.ParseTokens("{VA_DIR}")+@"\voiceattack.ico");
- icon = Icon.ExtractAssociatedIcon(VA.ParseTokens("{TXT:AVCS_ICON_PATH:}"));
- }
- }
- catch
- {
- icon = null;
- }
- // Welcome New Users and teach them about this Main Sensor Menu, how to return to it, etc.
- if (VA.GetBoolean("AVCS_SENS_RETURNING_USER") != true)
- MessageBox.Show("Thank you for checking out my VoiceAttack profile!"+
- "\n\nOn first-time use, the main Sensor Menu will open,"+
- "\nso you can review and set options before trying to use"+
- "\ncommands which require setup, like local weather."+
- "\n\nYou may exit and return at a later time, too."+
- "\n(this pop-up only appears once)"+
- "\n\nSay 'Open the Sensor Menu' anytime to change profile settings."+
- "\n\nCheers!"+
- "\n -SemlerPDX",
- profileTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
- VA.SetBoolean("AVCS_SENS_RETURNING_USER", true);
- //Load User Settings from Config File & Check for Updates (if user's update setting allows)
- Functions.loadUserConfig(VA);
- if (VA.GetBoolean("AVCS_SENS_VersionChecked") != true)
- {
- if (VA.GetInt("AVCS_SENS_UPDATES") != 3)
- VA.Command.Execute("F_SENS_UPDATE", true);
- }
- //Credits to Exergist for his work creating a tutorial example inline function for VA using Windows Forms!
- // Please check out the post: "Alternate 'Get User Input' Method (buttons!)" on the VoiceAttack forums if you're interested
- //Special Global Bool to communicate to SFS that Key was cleared
- //Will tell SFS to delete Key from User Config when Menu closes (after saving other items)
- VA.SetBoolean("AVCS_SENS_ClearKeyNotPressed", true);
- VA.ResetStopFlag();
- // Enable (operating system) visual styles for the application
- Application.EnableVisualStyles();
- // Create an instance of my MainMenuForm (while passing the dynamic VA for use by the form) and an associated message loop
- Application.Run(new MainMenuForm(VA, profileTitle, icon));
- }
- }
- //================================================BEGIN MAIN OPTIONS=================================================================
- public class MainMenuForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public MainMenuForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(10);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => MainMenuForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "AVCS Sensors Main Menu";
- labelHeader.MinimumSize = new Size(300, 0);
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // Set up buttonSnsMonitoring
- Button buttonSnsMonitoring = new Button();
- if (VA.GetBoolean("AVCS_SENS_Logging") != true && VA.GetBoolean("AVCS_SENS_Monitoring") != true)
- {
- buttonSnsMonitoring.Text = " Begin Sensor Monitoring ";
- }
- else
- {
- buttonSnsMonitoring.Text = " Stop Sensor Monitoring ";
- }
- buttonSnsMonitoring.AutoSize = true;
- buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip SnsMonitoringTip = new ToolTip();
- SnsMonitoringTip.SetToolTip(buttonSnsMonitoring,"(monitoring will continue even if this menu is closed)");
- this.Controls.Add(buttonSnsMonitoring);
- buttonSnsMonitoring.MouseHover += new EventHandler((sender, e) => Functions.buttonsSnsMonitoring_MouseHover(sender, e, VA));
- buttonSnsMonitoring.MouseLeave += new EventHandler((sender, e) => Functions.buttonsSnsMonitoring_MouseLeave(sender, e, VA));
- // Set up buttonOwmMonitoring
- Button buttonOwmMonitoring = new Button();
- if (VA.GetBoolean("AVCS_OWM_Monitoring") != true)
- {
- buttonOwmMonitoring.Text = " Begin Weather Monitoring ";
- }
- else
- {
- buttonOwmMonitoring.Text = " Stop Weather Monitoring ";
- }
- buttonOwmMonitoring.AutoSize = true;
- buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip OwmMonitoringTip = new ToolTip();
- OwmMonitoringTip.SetToolTip(buttonOwmMonitoring,"(monitoring will continue even if this menu is closed)");
- this.Controls.Add(buttonOwmMonitoring);
- buttonOwmMonitoring.MouseHover += new EventHandler((sender, e) => Functions.buttonsOwmMonitoring_MouseHover(sender, e, VA));
- buttonOwmMonitoring.MouseLeave += new EventHandler((sender, e) => Functions.buttonsOwmMonitoring_MouseLeave(sender, e, VA));
- // Set up buttonGuide
- Button buttonGuide = new Button();
- buttonGuide.Text = " USER GUIDES ";
- buttonGuide.AutoSize = true;
- buttonGuide.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonGuide.Font = new Font(buttonGuide.Font.FontFamily, FontSizeM);
- buttonGuide.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonGuide);
- buttonGuide.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonGuide.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonGuide.Click += new EventHandler((sender, e) => buttonGuide_Click(sender, e, VA, profileTitle, icon));
- // Set up buttonOptionsMenu
- Button buttonOptionsMenu = new Button();
- buttonOptionsMenu.Text = " OPTIONS ";
- buttonOptionsMenu.AutoSize = true;
- buttonOptionsMenu.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOptionsMenu.Font = new Font(buttonOptionsMenu.Font.FontFamily, FontSizeM);
- buttonOptionsMenu.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonOptionsMenu);
- buttonOptionsMenu.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonOptionsMenu.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonOptionsMenu.Click += new EventHandler((sender, e) => buttonOptionsMenu_Click(sender, e, VA, profileTitle, icon, this, buttonSnsMonitoring, buttonOwmMonitoring));
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonCredits
- Button buttonCredits = new Button();
- buttonCredits.Text = " CREDITS ";
- buttonCredits.AutoSize = true;
- buttonCredits.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonCredits.Font = new Font(buttonCredits.Font.FontFamily, FontSizeM);
- buttonCredits.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonCredits);
- buttonCredits.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonCredits.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonCredits.Click += new EventHandler((sender, e) => buttonCredits_Click(sender, e, VA, profileTitle, icon));
- // Set up buttonExit
- Button buttonExit = new Button();
- buttonExit.Text = " EXIT ";
- buttonExit.AutoSize = true;
- buttonExit.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonExit.Font = new Font(buttonExit.Font.FontFamily, FontSizeM);
- buttonExit.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip buttonCloseTip = new ToolTip();
- buttonCloseTip.SetToolTip(buttonExit,"(monitoring will continue even if this menu is closed)");
- this.Controls.Add(buttonExit);
- buttonExit.MouseHover += new EventHandler((sender, e) => buttonExit_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonExit.MouseLeave += new EventHandler((sender, e) => buttonExit_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonExit.Click += new EventHandler((sender, e) => buttonExit_Click(sender, e, VA));
- this.CancelButton = buttonExit;
- // Footer Label
- Label labelFooter = new Label();
- Functions.addFooterLabel(this, FontSizeS, labelFooter);
- // Event Handlers added last to include buttons temporarily disabled by these button clicks
- buttonSnsMonitoring.Click += new EventHandler((sender, e) => Functions.buttonSnsMonitoring_Click(sender, e, VA, this, ControlSpacing, FontSizeM, buttonOwmMonitoring, buttonGuide, buttonOptionsMenu, buttonCredits, buttonExit, buttonExit, this, buttonSnsMonitoring, false));
- buttonOwmMonitoring.Click += new EventHandler((sender, e) => Functions.buttonOwmMonitoring_Click(sender, e, VA, this, ControlSpacing, FontSizeM, buttonSnsMonitoring, buttonGuide, buttonOptionsMenu, buttonCredits, buttonExit, buttonOptionsMenu, buttonCredits, this, buttonOwmMonitoring, false));
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Open User Guide Form
- private void buttonGuide_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- this.Hide();
- Form FormOptions = new GuideForm(VA, profileTitle, icon);
- FormOptions.ShowDialog();
- this.Show();
- }
- }
- // Open Options Menu Form
- private void buttonOptionsMenu_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonSnsMonitoring, Button buttonOwmMonitoring)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- this.Hide();
- Form FormOptions = new OptionsMenuForm(VA, profileTitle, icon, mainForm, buttonSnsMonitoring, buttonOwmMonitoring);
- FormOptions.ShowDialog();
- this.Show();
- }
- }
- // Open Credits Form
- private void buttonCredits_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- this.Hide();
- Form FormOptions = new CreditsForm(VA, profileTitle, icon);
- FormOptions.ShowDialog();
- this.Show();
- }
- }
- // Functions to recolor buttons and button text on Mouse Hover events
- private void buttonExit_MouseHover(object sender, EventArgs e, int ControlSpacing, int FontSizeM)
- {
- (sender as Button).Text = " GOODBYE! ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(30, 30, 30);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- }
- private void buttonExit_MouseLeave(object sender, EventArgs e, int ControlSpacing, int FontSizeM)
- {
- (sender as Button).Text = " EXIT ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- }
- // Function run when buttonBack is clicked
- private void buttonExit_Click(object sender, EventArgs e, dynamic VA)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- this.Close();
- }
- }
- // Final Exit Options Form Closing
- private void MainMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- // Using modified "function" command from AVCS CORE profile, ambiguous Save File System (SFS) Save/Delete method here:
- //Saving User Settings to User Config File (if changed, or null) - Hide menu now, can take a second or two...
- this.Hide();
- if (VA.GetText("AVCS_SENS_OWMCITY") == null)
- VA.SetText("AVCS_SENS_OWMCITY", "New York, NY, US");
- if (VA.GetText("AVCS_SENS_OWMKEY") == null)
- VA.SetText("AVCS_SENS_OWMKEY", VA.GetText("AVCS_SENS_OWM_DefaultKey"));
- //SFS will accept these requests, and read config - only if values changed will a write occur
- int saveRequests = 1;
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_RETURNING_USER");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), "True");
- saveRequests += 1;
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_UPDATES");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{INT:AVCS_SENS_UPDATES:2}"));
- if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null && VA.GetText("AVCS_SENS_OWMKEY") == VA.GetText("AVCS_SENS_OWM_DefaultKey"))
- {
- if (VA.GetInt("AVCS_SENS_OWM_API_Calls") < 180)
- {
- saveRequests += 1;
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_API_Calls");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), "180");
- }
- }
- else
- {
- saveRequests += 1;
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_API_Calls");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{INT:AVCS_SENS_OWM_API_Calls:180}"));
- }
- saveRequests += 1;
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_UnitMetric");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{BOOL:AVCS_SENS_OWM_UnitMetric:False}"));
- saveRequests += 1;
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_WindMetric");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{BOOL:AVCS_SENS_OWM_WindMetric:False}"));
- saveRequests += 1;
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWMCITY");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{TXT:AVCS_SENS_OWMCITY:New York, NY, US}"));
- if (VA.GetText("AVCS_SENS_OWMKEY") != null && VA.GetText("AVCS_SENS_OWMKEY") != VA.GetText("AVCS_SENS_OWM_DefaultKey"))
- {
- saveRequests += 1;
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWMKEY");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.GetText("AVCS_SENS_OWMKEY"));
- saveRequests += 1;
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_FC_Calls");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{INT:AVCS_SENS_OWM_FC_Calls:86400}"));
- }
- else
- {
- saveRequests += 1;
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 86400);
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_FC_Calls");
- VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), "86400");
- }
- VA.SetInt("AVCS_SENS_SAVED_requests", saveRequests);
- // Ensure path is correct, this SFS can utilize any supplied path (therefore don't trust it was changed back)
- VA.SetText("AVCS_SENS_SaveFilePath", VA.GetText("AVCS_SENS_UserConfigFilePath"));
- // This save system trigger below on 'bool=null' is simply a 'look and feel' thing, to minimize event log writes
- ///// such as 'executing F_SFS_SAVE_CONFIG' when sometimes called twice on menu exit i.e. save + delete OWM key)
- //Setting this bool null will signal already waiting 'F_SFS_SAVE_CONFIG' to write to config file (only if variables changed)
- VA.SetBoolean("AVCS_MAIN_MENU_OPEN", null);
- //If it was stopped, launch it directly from here
- if (VA.Command.Active("F_SFS_SAVE_CONFIG") != true)
- {
- VA.Command.Execute("F_SFS_SAVE_CONFIG", false);
- }
- //Check for OWM Key Clear press, delete user key from file, reset to default key
- if (VA.GetBoolean("AVCS_SENS_ClearKeyNotPressed") != true)
- {
- saveRequests = 0;
- if (VA.GetText("AVCS_SENS_OWMKEY") == VA.GetText("AVCS_SENS_OWM_DefaultKey"))
- {
- //Wait for save to finish, reset menu open bool, and then send delete request to SFS
- Thread.Sleep(500);
- VA.SetBoolean("AVCS_MAIN_MENU_OPEN", true); //Now that SFS is running, can set true again to prevent menu re-open before delete
- if (VA.Command.Active("F_SFS_SAVE_CONFIG"))
- {
- while (VA.Command.Active("F_SFS_SAVE_CONFIG"))
- Thread.Sleep(50);
- }
- saveRequests += 1;
- VA.SetInt("AVCS_SENS_SAVED_requests", saveRequests);
- VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWMKEY");
- VA.SetBoolean("AVCS_SENS_DELETE_saved", true);
- VA.SetBoolean("AVCS_MAIN_MENU_OPEN", null);
- VA.Command.Execute("F_SFS_SAVE_CONFIG", false);
- //Wait for delete to finish, deleted variables are cleared by SFS - reset key var to default key
- Thread.Sleep(500);
- VA.SetBoolean("AVCS_MAIN_MENU_OPEN", true); //Now that SFS is running, can set true again to prevent menu re-open during delete
- if (VA.Command.Active("F_SFS_SAVE_CONFIG"))
- {
- while (VA.Command.Active("F_SFS_SAVE_CONFIG"))
- Thread.Sleep(50);
- }
- // Reset variable cleared by SFS Delete function to default key
- VA.SetText("AVCS_SENS_OWMKEY", VA.GetText("AVCS_SENS_OWM_DefaultKey"));
- }
- }
- VA.SetBoolean("AVCS_SENS_ClearKeyNotPressed", null);
- VA.SetBoolean("AVCS_MAIN_MENU_OPEN", null);
- }
- }
- //================================================END MAIN OPTIONS=================================================================
- //================================================BEGIN MAIN OPTIONS=================================================================
- public class OptionsMenuForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public OptionsMenuForm(dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonSnsMonitoring, Button buttonOwmMonitoring)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(10);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => OptionsMenuForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = " AVCS Main Options Menu ";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // Set up buttonSnsOptions
- Button buttonSnsOptions = new Button();
- buttonSnsOptions.Text = " Sensor Options ";
- buttonSnsOptions.AutoSize = true;
- buttonSnsOptions.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSnsOptions.Font = new Font(buttonSnsOptions.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonSnsOptions.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonSnsOptions);
- buttonSnsOptions.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSnsOptions.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSnsOptions.Click += new EventHandler((sender, e) => buttonSnsOptions_Click(sender, e, VA, profileTitle, icon, mainForm, buttonSnsMonitoring));
- // Set up buttonOwmOptions
- Button buttonOwmOptions = new Button();
- buttonOwmOptions.Text = " Weather Options ";
- buttonOwmOptions.AutoSize = true;
- buttonOwmOptions.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOwmOptions.Font = new Font(buttonOwmOptions.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonOwmOptions.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonOwmOptions);
- buttonOwmOptions.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonOwmOptions.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonOwmOptions.Click += new EventHandler((sender, e) => buttonOwmOptions_Click(sender, e, VA, profileTitle, icon, mainForm, buttonOwmMonitoring));
- // Set up buttonProOptions
- Button buttonProOptions = new Button();
- buttonProOptions.Text = " Profile Options ";
- buttonProOptions.AutoSize = true;
- buttonProOptions.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonProOptions.Font = new Font(buttonProOptions.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonProOptions.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonProOptions);
- buttonProOptions.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonProOptions.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonProOptions.Click += new EventHandler((sender, e) => buttonProOptions_Click(sender, e, VA, profileTitle, icon));
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Label
- Label labelFooter = new Label();
- Functions.addFooterLabel(this, FontSizeS, labelFooter);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Open Sensor Options Form
- private void buttonSnsOptions_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonSnsMonitoring)
- {
- this.Hide();
- Form FormSensorOptions = new SensorOptionsMenuForm(VA, profileTitle, icon, mainForm, buttonSnsMonitoring);
- FormSensorOptions.ShowDialog();
- this.Show();
- }
- // Open Weather Options Form
- private void buttonOwmOptions_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonOwmMonitoring)
- {
- this.Hide();
- Form FormOptions = new WeatherOptionsMenuForm(VA, profileTitle, icon, mainForm, buttonOwmMonitoring);
- FormOptions.ShowDialog();
- this.Show();
- }
- // Open Weather Options Form
- private void buttonProOptions_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- this.Hide();
- Form FormOptions = new ProfileConfigMenuForm(VA, profileTitle, icon);
- FormOptions.ShowDialog();
- this.Show();
- }
- // Open Options Menu Form
- private void buttonCredits_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- this.Hide();
- Form FormOptions = new CreditsForm(VA, profileTitle, icon);
- FormOptions.ShowDialog();
- this.Show();
- }
- // Final Exit Options Form Closing
- private void OptionsMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END MAIN OPTIONS=================================================================
- // --------Test Buttons need checks for already running systems, output some test data instead of running test?---------
- //================================================BEGIN SENSOR OPTIONS=================================================================
- public class SensorOptionsMenuForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public SensorOptionsMenuForm(dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonSnsMonitoringMain)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(80, 80, 80);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(10);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => SensorOptionsMenuForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "Sensor Options Menu";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.MinimumSize = new Size(300, 0);
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // Set up buttonSnsMonitoring
- Button buttonSnsMonitoring = new Button();
- if (VA.GetBoolean("AVCS_SENS_Logging") != true && VA.GetBoolean("AVCS_SENS_Monitoring") != true)
- {
- buttonSnsMonitoring.Text = " Begin Sensor Monitoring ";
- }
- else
- {
- buttonSnsMonitoring.Text = " Stop Sensor Monitoring ";
- }
- buttonSnsMonitoring.AutoSize = true;
- buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip SnsMonitoringTip = new ToolTip();
- SnsMonitoringTip.SetToolTip(buttonSnsMonitoring,"(monitoring will continue even if this menu is closed)");
- this.Controls.Add(buttonSnsMonitoring);
- buttonSnsMonitoring.MouseHover += new EventHandler((sender, e) => Functions.buttonsSnsMonitoring_MouseHover(sender, e, VA));
- buttonSnsMonitoring.MouseLeave += new EventHandler((sender, e) => Functions.buttonsSnsMonitoring_MouseLeave(sender, e, VA));
- // Set up buttonTestAIDA
- Button buttonTestAIDA = new Button();
- buttonTestAIDA.Text = " Test AIDA64 Shared Memory ";
- buttonTestAIDA.AutoSize = true;
- buttonTestAIDA.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonTestAIDA.Font = new Font(buttonTestAIDA.Font.FontFamily, FontSizeM);
- buttonTestAIDA.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip TestAIDATip = new ToolTip();
- TestAIDATip.SetToolTip(buttonTestAIDA,"(see user guide for help)");
- this.Controls.Add(buttonTestAIDA);
- buttonTestAIDA.MouseHover += new EventHandler((sender, e) => buttonsTester_MouseHover(sender, e, VA, ControlSpacing, FontSizeM));
- buttonTestAIDA.MouseLeave += new EventHandler((sender, e) => buttonsTester_MouseLeave(sender, e, VA, ControlSpacing, FontSizeM));
- // Set up buttonTestDHT
- Button buttonTestDHT = new Button();
- buttonTestDHT.Text = " Test Arduino DHT11 Sensor ";
- buttonTestDHT.AutoSize = true;
- buttonTestDHT.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonTestDHT.Font = new Font(buttonTestDHT.Font.FontFamily, FontSizeM);
- buttonTestDHT.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip TestDHTTip = new ToolTip();
- TestDHTTip.SetToolTip(buttonTestDHT,"(see user guide for help)");
- this.Controls.Add(buttonTestDHT);
- buttonTestDHT.MouseHover += new EventHandler((sender, e) => buttonsTester_MouseHover(sender, e, VA, ControlSpacing, FontSizeM));
- buttonTestDHT.MouseLeave += new EventHandler((sender, e) => buttonsTester_MouseLeave(sender, e, VA, ControlSpacing, FontSizeM));
- // Set up labelSpacer
- Label labelSpacerT = new Label();
- Functions.addLabelSpacer(this, 4, labelSpacerT);
- // Set up buttonNewBaselines
- Button buttonNewBaselines = new Button();
- buttonNewBaselines.Text = " Establish Baselines ";
- buttonNewBaselines.AutoSize = true;
- buttonNewBaselines.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonNewBaselines.Font = new Font(buttonNewBaselines.Font.FontFamily, FontSizeM);
- buttonNewBaselines.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonNewBaselines);
- buttonNewBaselines.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonNewBaselines.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonNewBaselines.Click += new EventHandler((sender, e) => buttonNewBaselines_Click(sender, e, VA, profileTitle, icon));
- // Set up buttonOpenBaseline
- Button buttonOpenBaseline = new Button();
- buttonOpenBaseline.Text = " Open Baseline File ";
- buttonOpenBaseline.AutoSize = true;
- buttonOpenBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOpenBaseline.Font = new Font(buttonOpenBaseline.Font.FontFamily, FontSizeM);
- buttonOpenBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip OpenBaselineTip = new ToolTip();
- OpenBaselineTip.SetToolTip(buttonOpenBaseline,"(manual editing is discouraged, careful!)");
- this.Controls.Add(buttonOpenBaseline);
- buttonOpenBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonOpenBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonOpenBaseline.Click += new EventHandler((sender, e) => buttonOpenBaseline_Click(sender, e, VA));
- // Set up buttonOpenSensors
- Button buttonOpenSensors = new Button();
- buttonOpenSensors.Text = " Open Sensors File ";
- buttonOpenSensors.AutoSize = true;
- buttonOpenSensors.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOpenSensors.Font = new Font(buttonOpenSensors.Font.FontFamily, FontSizeM);
- buttonOpenSensors.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip OpenSensorsTip = new ToolTip();
- OpenSensorsTip.SetToolTip(buttonOpenSensors,"(manual editing is discouraged, careful!)");
- this.Controls.Add(buttonOpenSensors);
- buttonOpenSensors.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonOpenSensors.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonOpenSensors.Click += new EventHandler((sender, e) => buttonOpenSensors_Click(sender, e, VA));
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Label
- Label labelFooter = new Label();
- Functions.addFooterLabel(this, FontSizeS, labelFooter);
- // Set Button Event Handlers Last for Custom Disabling during Testing
- buttonTestDHT.Click += new EventHandler((sender, e) => buttonTestDHT_Click(sender, e, VA, buttonTestAIDA, buttonSnsMonitoring, buttonNewBaselines, buttonOpenBaseline, buttonOpenSensors, buttonBack));
- buttonTestAIDA.Click += new EventHandler((sender, e) => buttonTestAIDA_Click(sender, e, VA, buttonTestDHT, buttonSnsMonitoring, buttonNewBaselines, buttonOpenBaseline, buttonOpenSensors, buttonBack));
- buttonSnsMonitoring.Click += new EventHandler((sender, e) => Functions.buttonSnsMonitoring_Click(sender, e, VA, this, ControlSpacing, FontSizeM, buttonTestDHT, buttonTestAIDA, buttonNewBaselines, buttonOpenBaseline, buttonOpenSensors, buttonBack, mainForm, buttonSnsMonitoringMain, true));
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Test AIDA SharedMem Button Event
- private void buttonTestAIDA_Click(object sender, EventArgs e, dynamic VA, Button otherTestButton, Button buttonSnsMonitoring, Button buttonNewBaselines, Button buttonOpenBaseline, Button buttonOpenSensors, Button buttonBack)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
- if (VA.GetBoolean("AVCS_SENS_Test_SharedMem") != true)
- {
- buttonSnsMonitoring.Enabled = false;
- buttonNewBaselines.Enabled = false;
- buttonOpenBaseline.Enabled = false;
- buttonOpenSensors.Enabled = false;
- buttonBack.Enabled = false;
- (sender as Button).Enabled = false;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- otherTestButton.Enabled = false;
- otherTestButton.BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- otherTestButton.ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- try
- {
- VA.SetBoolean("AVCS_SENS_Test_SharedMem", true);
- if (VA.GetBoolean("AVCS_SENS_Monitoring") != true)
- {
- VA.SetBoolean("AVCS_SENS_Test_OnlyTest", true);
- VA.Command.Execute("F_AIDA_MAIN", true);
- }
- else
- {
- while (VA.GetBoolean("AVCS_SENS_Test_SharedMem") == true)
- Thread.Sleep(100);
- }
- }
- catch
- {
- VA.WriteToLog("AVCS ERROR: function command F_AIDA_MAIN unavailable - test incomplete", "red");
- }
- finally
- {
- buttonSnsMonitoring.Enabled = true;
- buttonNewBaselines.Enabled = true;
- buttonOpenBaseline.Enabled = true;
- buttonOpenSensors.Enabled = true;
- buttonBack.Enabled = true;
- (sender as Button).Enabled = true;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- otherTestButton.Enabled = true;
- otherTestButton.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- otherTestButton.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- VA.SetBoolean("AVCS_SENS_Test_SharedMem", false);
- VA.SetBoolean("AVCS_SENS_Test_OnlyTest", false);
- if (VA.GetText("AVCS_SENS_Test_ReturnTTS") != null)
- {
- VA.SetText("AVCS_SENS_TTS_WILDCARD", VA.GetText("AVCS_SENS_Test_ReturnTTS"));
- VA.Command.Execute("F_SAY_TTS", false);
- VA.SetText("AVCS_SENS_Test_ReturnTTS", null);
- }
- if (VA.GetText("AVCS_SENS_SHAREDMEM_XML") != null)
- Clipboard.SetText(VA.GetText("AVCS_SENS_SHAREDMEM_XML"));
- }
- }
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
- }
- }
- // Test Arduino DHT Button Event
- private void buttonTestDHT_Click(object sender, EventArgs e, dynamic VA, Button otherTestButton, Button buttonSnsMonitoring, Button buttonNewBaselines, Button buttonOpenBaseline, Button buttonOpenSensors, Button buttonBack)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
- if (VA.GetBoolean("AVCS_SENS_SensorTestDHT1") != true)
- {
- buttonSnsMonitoring.Enabled = false;
- buttonNewBaselines.Enabled = false;
- buttonOpenBaseline.Enabled = false;
- buttonOpenSensors.Enabled = false;
- buttonBack.Enabled = false;
- (sender as Button).Enabled = false;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- otherTestButton.Enabled = false;
- otherTestButton.BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- otherTestButton.ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- try
- {
- if (VA.GetBoolean("AVCS_SENS_MonitoringDHT1") != true)
- {
- VA.SetBoolean("AVCS_SENS_SensorTestDHT1", true);
- VA.Command.Execute("F_DHT1_MAIN", true);
- }
- else
- {
- VA.SetText("AVCS_SENS_TTS_WILDCARD", "Testing.;Test started.");
- VA.Command.Execute("F_SAY_TTS", true);
- VA.SetBoolean("AVCS_SENS_SensorTestDHT1", true);
- while(VA.GetBoolean("AVCS_SENS_SensorTestDHT1") == true)
- Thread.Sleep(100);
- }
- }
- catch
- {
- VA.WriteToLog("AVCS ERROR: function command F_DHT1_MAIN unavailable - test incomplete", "red");
- }
- finally
- {
- buttonSnsMonitoring.Enabled = true;
- buttonNewBaselines.Enabled = true;
- buttonOpenBaseline.Enabled = true;
- buttonOpenSensors.Enabled = true;
- buttonBack.Enabled = true;
- (sender as Button).Enabled = true;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- otherTestButton.Enabled = true;
- otherTestButton.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- otherTestButton.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- if (VA.GetText("AVCS_SENS_Test_ReturnTTS") != null)
- {
- VA.SetText("AVCS_SENS_TTS_WILDCARD", VA.GetText("AVCS_SENS_Test_ReturnTTS"));
- VA.Command.Execute("F_SAY_TTS", false);
- VA.SetText("AVCS_SENS_Test_ReturnTTS", null);
- }
- }
- }
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
- }
- }
- // New Baselines Button Event
- private void buttonNewBaselines_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- if (VA.GetBoolean("AVCS_SENS_Monitoring") != true || VA.GetBoolean("AVCS_SENS_Logging") != true)
- {
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- (sender as Button).Enabled = false;
- VA.WriteToLog("Sensor Monitoring must be enabled to establish baseline data!", "red");
- VA.WriteToLog("Please begin Sensor Monitoring. See user guide for more information.", "blank");
- VA.SetText("AVCS_SENS_TTS_WILDCARD", "Sensor data monitoring not detected. Please enable monitoring first.");
- VA.Command.Execute("F_SAY_TTS", true);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).Enabled = true;
- }
- else
- {
- if (VA.GetDecimal("AVCS_SENS_TempDHTf") != null)
- {
- this.Hide();
- Form FormBaselinesMenu = new BaselinesMenuForm(VA, profileTitle, icon);
- FormBaselinesMenu.ShowDialog();
- this.Show();
- }
- else
- {
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- (sender as Button).Enabled = false;
- VA.WriteToLog("Cannot locate AVCS-DHT1 External Temperature Sensor data!", "red");
- VA.WriteToLog("Please check settings. See user guide for more information.", "blank");
- VA.SetText("AVCS_SENS_TTS_WILDCARD", "External temperature sensor data not detected. Please check device or settings.");
- VA.Command.Execute("F_SAY_TTS", true);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).Enabled = true;
- }
- }
- }
- }
- // Open Baseline File Button Event
- private void buttonOpenBaseline_Click(object sender, EventArgs e, dynamic VA)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- Functions.buttonOpenFile(VA, VA.ParseTokens("{TXT:AVCS_SENS_BaselinesFilePath:}"));
- }
- }
- // Open Baseline File Button Event
- private void buttonOpenSensors_Click(object sender, EventArgs e, dynamic VA)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- Functions.buttonOpenFile(VA, VA.ParseTokens("{TXT:AVCS_SENS_SensorsFilePath:}"));
- }
- }
- // Functions to recolor AVCS Test buttons and button text on Mouse Hover events
- public static void buttonsTester_MouseHover(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSize)
- {
- if (VA.GetBoolean("AVCS_SENS_SensorTestDHT1") != true && VA.GetBoolean("AVCS_SENS_Test_SharedMem") != true)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- }
- }
- public static void buttonsTester_MouseLeave(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSize)
- {
- if (VA.GetBoolean("AVCS_SENS_SensorTestDHT1") != true && VA.GetBoolean("AVCS_SENS_Test_SharedMem") != true)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- }
- }
- // Final Exit Options Form Closing
- private void SensorOptionsMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END SENSOR OPTIONS=================================================================
- //================================================BEGIN WEATHER OPTIONS=================================================================
- public class WeatherOptionsMenuForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public TextBox textBoxOwmCity;
- public TextBox textBoxOwmKey;
- public WeatherOptionsMenuForm(dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonOwmMonitoringMain)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(10);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => WeatherOptionsMenuForm_FormClosing(sender, e, VA));
- // Set up weatherOwmKey Data early for checks in other form objects setup
- string weatherOwmKey = "";
- string defaultOwmKey = VA.GetText("AVCS_SENS_OWM_DefaultKey");
- string apiKeyURL = "https://veterans-gaming.com/semlerpdx-avcs/profiles/avcs_sens_owm_key.htm/";
- if (VA.GetText("AVCS_SENS_OWMKEY") != null)
- {
- weatherOwmKey = VA.GetText("AVCS_SENS_OWMKEY");
- }
- else
- {
- VA.SetText("AVCS_SENS_OWMKEY", defaultOwmKey);
- weatherOwmKey = defaultOwmKey;
- }
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "Weather Options Menu";
- labelHeader.MinimumSize = new Size(320, 0);
- labelHeader.MaximumSize = new Size(320, 0);
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // Set up buttonOwmMonitoring
- Button buttonOwmMonitoring = new Button();
- if (VA.GetBoolean("AVCS_OWM_Monitoring") != true)
- {
- buttonOwmMonitoring.Text = " Begin Weather Monitoring ";
- }
- else
- {
- buttonOwmMonitoring.Text = " Stop Weather Monitoring ";
- }
- buttonOwmMonitoring.AutoSize = true;
- buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip OwmMonitoringTip = new ToolTip();
- OwmMonitoringTip.SetToolTip(buttonOwmMonitoring,"(monitoring will continue even if this menu is closed)");
- this.Controls.Add(buttonOwmMonitoring);
- buttonOwmMonitoring.MouseHover += new EventHandler((sender, e) => Functions.buttonsOwmMonitoring_MouseHover(sender, e, VA));
- buttonOwmMonitoring.MouseLeave += new EventHandler((sender, e) => Functions.buttonsOwmMonitoring_MouseLeave(sender, e, VA));
- // Set up buttonProOptions
- Button buttonGetWeatherTest = new Button();
- buttonGetWeatherTest.Text = " Test Get Weather ";
- buttonGetWeatherTest.AutoSize = true;
- buttonGetWeatherTest.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonGetWeatherTest.Font = new Font(buttonGetWeatherTest.Font.FontFamily, FontSizeM);
- buttonGetWeatherTest.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip GetWeatherTestTip = new ToolTip();
- GetWeatherTestTip.SetToolTip(buttonGetWeatherTest,"(see user guide for help)");
- this.Controls.Add(buttonGetWeatherTest);
- buttonGetWeatherTest.MouseHover += new EventHandler((sender, e) => buttonsTester_MouseHover(sender, e, VA));
- buttonGetWeatherTest.MouseLeave += new EventHandler((sender, e) => buttonsTester_MouseLeave(sender, e, VA));
- //===================================
- // Set up labelSpacer
- string weatherOwmCity = "New York, NY, US";
- string defaultOwmCity = weatherOwmCity;
- if (VA.GetText("AVCS_SENS_OWMCITY") != null)
- weatherOwmCity = VA.GetText("AVCS_SENS_OWMCITY");
- Label labelOmwCity = new Label();
- //labelOmwCity.Text = "\nSet a location by City or GPS Coordinates\nUS City format example: New York, NY, US\nnon-US City format example: London, GB\nGPS format example: 32.88, -105.96";
- labelOmwCity.Text = "\nSet a location by City or GPS Coordinates\nUS City format example: New York, NY, US\nnon-US City format example: London, GB\nGPS format example: 45.52, -122.681944";
- labelOmwCity.Font = new Font(labelOmwCity.Font.FontFamily, FontSizeS);
- labelOmwCity.AutoSize = true;
- labelOmwCity.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip OwmCityTip = new ToolTip();
- OwmCityTip.SetToolTip(labelOmwCity, "City name, state code (only for the US) and country code\ndivided by comma. Please use ISO 3166 country codes.");
- this.Controls.Add(labelOmwCity);
- // Set up OWM User City Input TextBox
- textBoxOwmCity = new TextBox();
- textBoxOwmCity.AcceptsReturn = true;
- textBoxOwmCity.AcceptsTab = false;
- textBoxOwmCity.Multiline = false;
- textBoxOwmCity.Text = weatherOwmCity;
- textBoxOwmCity.Padding = new Padding(1);
- textBoxOwmCity.Font = new Font(textBoxOwmCity.Font.FontFamily, FontSizeS);
- ToolTip BoxOwmCityTip = new ToolTip();
- BoxOwmCityTip.SetToolTip(textBoxOwmCity, "City name, state code (only for the US) and country code\ndivided by comma. Please use ISO 3166 country codes.");
- textBoxOwmCity.MinimumSize = new Size(220, 0);
- textBoxOwmCity.MaximumSize = new Size(220, 0);
- ContextMenu emptyCityMenu = new ContextMenu();
- textBoxOwmCity.ContextMenu = emptyCityMenu;
- this.Controls.Add(this.textBoxOwmCity);
- // Set up Save OWM City button
- Button buttonOwmSaveCity = new Button();
- if (weatherOwmCity != defaultOwmCity)
- {
- buttonOwmSaveCity.Text = " Clear User City ";
- textBoxOwmCity.ReadOnly = true;
- textBoxOwmCity.Enabled = false;
- }
- else
- {
- textBoxOwmCity.ReadOnly = false;
- textBoxOwmCity.Enabled = true;
- buttonOwmSaveCity.Text = " Save User City ";
- }
- buttonOwmSaveCity.AutoSize = true;
- buttonOwmSaveCity.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOwmSaveCity.Font = new Font(buttonOwmSaveCity.Font.FontFamily, FontSizeM);
- buttonOwmSaveCity.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonOwmSaveCity);
- buttonOwmSaveCity.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonOwmSaveCity.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonOwmSaveCity.Click += new EventHandler((sender, e) => buttonSetCity_Click(sender, e, VA, ControlSpacing, FontSizeM, textBoxOwmCity, defaultOwmCity, textBoxOwmCity.Text));
- //=============================================
- // Set up labelSpacer
- Label labelSpacerW = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerW);
- // Set up labelTogglesSub
- Label labelTogglesSub = new Label();
- labelTogglesSub.Text = " Weather Data Units / Monitoring Interval ";
- labelTogglesSub.Font = new Font(labelTogglesSub.Font.FontFamily, FontSizeS);
- labelTogglesSub.AutoSize = true;
- labelTogglesSub.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelTogglesSub);
- // Set up buttonSetUnits
- Button buttonSetUnits = new Button();
- if (VA.GetBoolean("AVCS_SENS_OWM_UnitMetric") != true)
- {
- buttonSetUnits.Text = " Units: Fahrenheit ";
- }
- else
- {
- buttonSetUnits.Text = " Units: Celcius ";
- }
- buttonSetUnits.AutoSize = true;
- buttonSetUnits.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetUnits.Font = new Font(buttonSetUnits.Font.FontFamily, FontSizeM);
- buttonSetUnits.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonSetUnits);
- buttonSetUnits.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSetUnits.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSetUnits.Click += new EventHandler((sender, e) => buttonSetUnits_Click(sender, e, VA, ControlSpacing, FontSizeM));
- // Set up buttonSetWind
- Button buttonSetWind = new Button();
- if (VA.GetBoolean("AVCS_SENS_OWM_WindMetric") != true)
- {
- buttonSetWind.Text = " Wind: MPH ";
- }
- else
- {
- buttonSetWind.Text = " Wind: KPH ";
- }
- buttonSetWind.AutoSize = true;
- buttonSetWind.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetWind.Font = new Font(buttonSetWind.Font.FontFamily, FontSizeM);
- buttonSetWind.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonSetWind);
- buttonSetWind.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSetWind.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSetWind.Click += new EventHandler((sender, e) => buttonSetWind_Click(sender, e, VA, ControlSpacing, FontSizeM));
- // Set up buttonSetCallsAPI
- Button buttonSetCallsAPI = new Button();
- int intervalCallsAPI = 0;
- if (VA.GetText("AVCS_SENS_OWMKEY") == VA.GetText("AVCS_SENS_OWM_DefaultKey"))
- {
- if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null)
- {
- intervalCallsAPI = VA.GetInt("AVCS_SENS_OWM_API_Calls");
- if (intervalCallsAPI == 180)
- {
- buttonSetCallsAPI.Text = " Checks: 15 minutes ";
- }else if (intervalCallsAPI == 360) {
- buttonSetCallsAPI.Text = " Checks: 30 minutes ";
- }else if (intervalCallsAPI == 720) {
- buttonSetCallsAPI.Text = " Checks: 60 minutes ";
- }
- else
- {
- buttonSetCallsAPI.Text = " Checks: 15 minutes ";
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
- }
- }
- else
- {
- buttonSetCallsAPI.Text = " Checks: 15 minutes ";
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
- }
- }
- else
- {
- if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null)
- {
- intervalCallsAPI = VA.GetInt("AVCS_SENS_OWM_API_Calls");
- if (intervalCallsAPI == 12)
- {
- buttonSetCallsAPI.Text = " Checks: 1 minute ";
- }else if (intervalCallsAPI == 60) {
- buttonSetCallsAPI.Text = " Checks: 5 minutes ";
- }else if (intervalCallsAPI == 120) {
- buttonSetCallsAPI.Text = " Checks: 10 minutes ";
- }else if (intervalCallsAPI == 180) {
- buttonSetCallsAPI.Text = " Checks: 15 minutes ";
- }else if (intervalCallsAPI == 360) {
- buttonSetCallsAPI.Text = " Checks: 30 minutes ";
- }else if (intervalCallsAPI == 720) {
- buttonSetCallsAPI.Text = " Checks: 60 minutes ";
- }
- else
- {
- buttonSetCallsAPI.Text = " Checks: 1 minutes ";
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 12);
- }
- }
- else
- {
- buttonSetCallsAPI.Text = " Checks: 1 minutes ";
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 12);
- }
- }
- buttonSetCallsAPI.AutoSize = true;
- buttonSetCallsAPI.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetCallsAPI.Font = new Font(buttonSetCallsAPI.Font.FontFamily, FontSizeM);
- buttonSetCallsAPI.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- if ((VA.GetBoolean("AVCS_OWM_Monitoring") != null) && (VA.GetBoolean("AVCS_OWM_Monitoring") == true))
- {
- ToolTip SetCallsAPITip = new ToolTip();
- SetCallsAPITip.SetToolTip(buttonSetCallsAPI,"(restart monitor to apply changes)");
- }
- this.Controls.Add(buttonSetCallsAPI);
- buttonSetCallsAPI.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSetCallsAPI.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSetCallsAPI.Click += new EventHandler((sender, e) => buttonSetCallsAPI_Click(sender, e, VA, ControlSpacing, FontSizeM));
- // Set up buttonSetCallsForecast
- Button buttonSetCallsForecast = new Button();
- if (VA.GetInt("AVCS_SENS_OWM_FC_Calls") != null)
- {
- int intervalCallsFC = VA.GetInt("AVCS_SENS_OWM_FC_Calls");
- if (intervalCallsFC == 3600)
- {
- buttonSetCallsForecast.Text = " Forecasts: 1 hour ";
- }else if (intervalCallsFC == 7200) {
- buttonSetCallsForecast.Text = " Forecasts: 2 hours ";
- }else if (intervalCallsFC == 14400) {
- buttonSetCallsForecast.Text = " Forecasts: 4 hours ";
- }else if (intervalCallsFC == 21600) {
- buttonSetCallsForecast.Text = " Forecasts: 6 hours ";
- }else if (intervalCallsFC == 28800) {
- buttonSetCallsForecast.Text = " Forecasts: 8 hours ";
- }else if (intervalCallsFC == 43200) {
- buttonSetCallsForecast.Text = " Forecasts: 12 hours ";
- }else if (intervalCallsFC == 86400) {
- buttonSetCallsForecast.Text = " Forecasts: 24 hours ";
- }
- else
- {
- buttonSetCallsForecast.Text = " Forecasts: 24 hours ";
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 86400);
- }
- }
- else
- {
- buttonSetCallsForecast.Text = " Forecasts: 1 hours ";
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 3600);
- }
- buttonSetCallsForecast.AutoSize = true;
- buttonSetCallsForecast.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetCallsForecast.Font = new Font(buttonSetCallsForecast.Font.FontFamily, FontSizeM);
- buttonSetCallsForecast.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip SetCallsForecastTip = new ToolTip();
- SetCallsForecastTip.SetToolTip(buttonSetCallsForecast,"(restart monitor to apply changes)");
- this.Controls.Add(buttonSetCallsForecast);
- buttonSetCallsForecast.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSetCallsForecast.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSetCallsForecast.Click += new EventHandler((sender, e) => buttonSetCallsForecast_Click(sender, e, VA, ControlSpacing, FontSizeM));
- buttonSetCallsForecast.Enabled = false;
- buttonSetCallsForecast.Visible = false;
- Label labelOmwKey = new Label();
- labelOmwKey.Text = "Enter your own Open Weather Map Key (optional)";
- labelOmwKey.Font = new Font(labelOmwKey.Font.FontFamily, FontSizeS);
- labelOmwKey.AutoSize = true;
- labelOmwKey.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelOmwKey);
- // Set up OWM User Key Input TextBox
- textBoxOwmKey = new TextBox();
- textBoxOwmKey.AcceptsReturn = true;
- textBoxOwmKey.AcceptsTab = false;
- textBoxOwmKey.Multiline = false;
- if (weatherOwmKey != defaultOwmKey)
- textBoxOwmKey.Text = weatherOwmKey;
- textBoxOwmKey.Padding = new Padding(1);
- textBoxOwmKey.Font = new Font(textBoxOwmKey.Font.FontFamily, FontSizeS);
- textBoxOwmKey.MinimumSize = new Size(220, 0);
- textBoxOwmKey.MaximumSize = new Size(220, 0);
- ContextMenu emptyKeyMenu = new ContextMenu();
- textBoxOwmKey.ContextMenu = emptyKeyMenu;
- this.Controls.Add(this.textBoxOwmKey);
- // Set up Save OWM Key button
- Button buttonOwmSaveKey = new Button();
- if (weatherOwmKey != defaultOwmKey)
- {
- buttonOwmSaveKey.Text = " Clear User Key ";
- textBoxOwmKey.ReadOnly = true;
- textBoxOwmKey.Enabled = false;
- buttonSetCallsForecast.Enabled = true;
- buttonSetCallsForecast.Visible = true;
- }
- else
- {
- textBoxOwmKey.ReadOnly = false;
- textBoxOwmKey.Enabled = true;
- buttonOwmSaveKey.Text = " Save User Key ";
- buttonSetCallsForecast.Enabled = false;
- buttonSetCallsForecast.Visible = false;
- }
- buttonOwmSaveKey.AutoSize = true;
- buttonOwmSaveKey.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOwmSaveKey.Font = new Font(buttonOwmSaveKey.Font.FontFamily, FontSizeM);
- buttonOwmSaveKey.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonOwmSaveKey);
- buttonOwmSaveKey.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonOwmSaveKey.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonOwmSaveKey.Click += new EventHandler((sender, e) => buttonOwmSaveKey_Click(sender, e, VA, ControlSpacing, FontSizeM, textBoxOwmKey, defaultOwmKey, textBoxOwmKey.Text, buttonSetCallsForecast));
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Link and Credit to Open Weather Map
- LinkLabel labelOwmLink = new LinkLabel();
- Functions.addOwmLinkFooterLabel(VA, this, FontSizeS, labelOwmLink);
- // Event Handlers added last to include buttons temporarily disabled by these button clicks
- buttonOwmMonitoring.Click += new EventHandler((sender, e) => Functions.buttonOwmMonitoring_Click(sender, e, VA, this, ControlSpacing, FontSizeM, buttonGetWeatherTest, buttonOwmSaveCity, buttonSetUnits, buttonSetWind, buttonSetCallsAPI, buttonOwmSaveKey, buttonBack, mainForm, buttonOwmMonitoringMain, true));
- buttonGetWeatherTest.Click += new EventHandler((sender, e) => buttonGetWeatherTest_Click(sender, e, VA, buttonOwmMonitoring, buttonOwmSaveCity, buttonSetUnits, buttonSetWind, buttonSetCallsAPI, buttonOwmSaveKey, buttonBack));
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Test Get Weather Button Event
- private void buttonGetWeatherTest_Click(object sender, EventArgs e, dynamic VA, Button buttonOther1, Button buttonOther2, Button buttonOther3, Button buttonOther4, Button buttonOther5, Button buttonOther6, Button buttonOther7)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
- VA.SetBoolean("AVCS_SENS_Test_GetWeather", null);
- if (VA.GetBoolean("AVCS_SENS_Test_GetWeather") != true)
- {
- (sender as Button).Enabled = false;
- buttonOther1.Enabled = false;
- buttonOther2.Enabled = false;
- buttonOther3.Enabled = false;
- buttonOther4.Enabled = false;
- buttonOther5.Enabled = false;
- buttonOther6.Enabled = false;
- buttonOther7.Enabled = false;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- VA.SetBoolean("AVCS_SENS_Test_GetWeather", true);
- GetWeatherTest(VA);
- (sender as Button).Enabled = true;
- buttonOther1.Enabled = true;
- buttonOther2.Enabled = true;
- buttonOther3.Enabled = true;
- buttonOther4.Enabled = true;
- buttonOther5.Enabled = true;
- buttonOther6.Enabled = true;
- buttonOther7.Enabled = true;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- VA.SetBoolean("AVCS_SENS_Test_GetWeather", null);
- }
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
- }
- }
- // Open Config File Button Event
- private void buttonSetUnits_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- if (VA.GetBoolean("AVCS_SENS_OWM_UnitMetric") != true)
- {
- VA.SetBoolean("AVCS_SENS_OWM_UnitMetric", true);
- (sender as Button).Text = " Units: Celcius ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- else
- {
- VA.SetBoolean("AVCS_SENS_OWM_UnitMetric", false);
- (sender as Button).Text = " Units: Fahrenheit ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- }
- // Open Config Folder Button Event
- private void buttonSetWind_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- if (VA.GetBoolean("AVCS_SENS_OWM_WindMetric") != true)
- {
- VA.SetBoolean("AVCS_SENS_OWM_WindMetric", true);
- (sender as Button).Text = " Wind: KPH ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- else
- {
- VA.SetBoolean("AVCS_SENS_OWM_WindMetric", false);
- (sender as Button).Text = " Wind: MPH ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- }
- // Open Config Folder Button Event
- private void buttonSetCallsAPI_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- int checkCallsInterval = 0;
- if (VA.GetText("AVCS_SENS_OWMKEY") == VA.GetText("AVCS_SENS_OWM_DefaultKey"))
- {
- if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null)
- {
- checkCallsInterval = VA.GetInt("AVCS_SENS_OWM_API_Calls");
- if (checkCallsInterval == 180)
- {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 360);
- (sender as Button).Text = " Checks: 30 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkCallsInterval == 360) {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 720);
- (sender as Button).Text = " Checks: 60 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkCallsInterval == 720) {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
- (sender as Button).Text = " Checks: 15 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- else
- {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
- (sender as Button).Text = " Checks: 15 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- else
- {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 360);
- (sender as Button).Text = " Checks: 30 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- else
- {
- if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null)
- {
- checkCallsInterval = VA.GetInt("AVCS_SENS_OWM_API_Calls");
- if (checkCallsInterval == 12)
- {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 60);
- (sender as Button).Text = " Checks: 5 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkCallsInterval == 60) {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 120);
- (sender as Button).Text = " Checks: 10 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkCallsInterval == 120) {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
- (sender as Button).Text = " Checks: 15 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkCallsInterval == 180) {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 360);
- (sender as Button).Text = " Checks: 30 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkCallsInterval == 360) {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 720);
- (sender as Button).Text = " Checks: 60 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkCallsInterval == 720) {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 12);
- (sender as Button).Text = " Checks: 1 minute ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- else
- {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 12);
- (sender as Button).Text = " Checks: 1 minute ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- else
- {
- VA.SetInt("AVCS_SENS_OWM_API_Calls", 60);
- (sender as Button).Text = " Checks: 5 minutes ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- }
- }
- // Open Config Folder Button Event
- private void buttonSetCallsForecast_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- if (VA.GetInt("AVCS_SENS_OWM_FC_Calls") != null)
- {
- int checkIntervalFC = VA.GetInt("AVCS_SENS_OWM_FC_Calls");
- if (checkIntervalFC == 3600)
- {
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 7200);
- (sender as Button).Text = " Forecasts: 2 hours ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkIntervalFC == 7200) {
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 14400);
- (sender as Button).Text = " Forecasts: 4 hours ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkIntervalFC == 14400) {
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 21600);
- (sender as Button).Text = " Forecasts: 6 hours ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkIntervalFC == 21600) {
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 28800);
- (sender as Button).Text = " Forecasts: 8 hours ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkIntervalFC == 28800) {
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 43200);
- (sender as Button).Text = " Forecasts: 12 hours ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkIntervalFC == 43200) {
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 86400);
- (sender as Button).Text = " Forecasts: 24 hours ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- else
- {
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 3600);
- (sender as Button).Text = " Forecasts: 1 hour ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- else
- {
- VA.SetInt("AVCS_SENS_OWM_FC_Calls", 3600);
- (sender as Button).Text = " Forecasts: 1 hour ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- }
- public class GetWeatherException : Exception
- {
- public void GetWeatherTestException(dynamic VA)
- {
- VA.SetBoolean("AVCS_OWM_SET", null);
- }
- public void GetWeatherFailException(dynamic VA)
- {
- VA.WriteToLog("AVCS OWM Get Weather Data Test has failed!", "red");
- VA.WriteToLog("Please check settings. See user guide for more information.", "blank");
- VA.SetText("AVCS_SENS_TTS_WILDCARD", "Test failed. Please check settings.");
- VA.Command.Execute("F_SAY_TTS", false);
- }
- }
- private void GetWeatherTest(dynamic VA)
- {
- VA.SetBoolean("AVCS_OWM_SET", null);
- try
- {
- GetWeatherTestURL(VA);
- if (VA.GetBoolean("AVCS_OWM_SET") != true)
- {
- throw new GetWeatherException();
- }
- else
- {
- VA.WriteToLog(VA.GetText("~avcs_owm_test_data"), "blank");
- VA.WriteToLog("AVCS OWM Get Weather Data Test has succeeded!", "green");
- VA.SetText("AVCS_SENS_TTS_WILDCARD", "Test succeeded.");
- VA.Command.Execute("F_SAY_TTS", true);
- VA.SetText("AVCS_SENS_TTS_WILDCARD", VA.GetText("~avcs_owm_test_data_tts"));
- VA.Command.Execute("F_SAY_TTS", true);
- VA.SetText("~avcs_owm_test_data_tts", null);
- VA.SetText("~avcs_owm_test_data", null);
- }
- }
- catch (GetWeatherException e)
- {
- //for any expected unexpected faults
- e.GetWeatherFailException(VA);
- }
- }
- private void GetWeatherTestURL(dynamic VA)
- {
- string cityName;
- string stateName;
- string newLat = "";
- string newLon = "";
- string locationData = "New York, NY, US";
- string apiKey = "";
- string baseURL = "https://api.openweathermap.org/data/2.5/weather?lat=AVCS_SENS_OWMLAT&lon=AVCS_SENS_OWMLON&units=metric&exclude=minutely,hourly&appid=AVCS_SENS_OWMKEY";
- string weatherURL = "";
- bool hasGPS = false;
- bool faultDetected = false;
- if (VA.GetText("AVCS_SENS_OWMKEY") != null)
- {
- apiKey = VA.GetText("AVCS_SENS_OWMKEY");
- }
- else
- {
- apiKey = VA.GetText("AVCS_SENS_OWM_DefaultKey");
- }
- if (VA.GetText("AVCS_SENS_OWMCITY") != null)
- locationData = VA.GetText("AVCS_SENS_OWMCITY");
- if (locationData.Contains(","))
- {
- string[] locationDataSet = locationData.Split(
- new string[] { "," },
- StringSplitOptions.RemoveEmptyEntries
- );
- if (1 < locationDataSet.Length)
- {
- decimal checkLat;
- decimal checkLon;
- bool checkLatIsValid = decimal.TryParse(locationDataSet[0], out checkLat) && Math.Abs(checkLat) < 90;
- bool checkLonIsValid = decimal.TryParse(locationDataSet[1], out checkLon) && Math.Abs(checkLon) < 180;
- if ((checkLatIsValid && checkLonIsValid) && (Math.Abs(checkLat) > 4.4m && Math.Abs(checkLon) > 4.4m))
- {
- hasGPS = true;
- newLat = locationDataSet[0].Trim();
- newLon = locationDataSet[1].Trim();
- VA.SetText("AVCS_SENS_OWMLAT", newLat);
- VA.SetText("AVCS_SENS_OWMLON", newLon);
- weatherURL = baseURL.Replace("AVCS_SENS_OWMLAT",newLat).Replace("AVCS_SENS_OWMLON",newLon).Replace("AVCS_SENS_OWMKEY",apiKey).Trim();
- }
- }
- }
- if (hasGPS != true)
- {
- try
- {
- string apiReturn = "";
- VA.SetText("~avcs_owm_return", null);
- weatherURL = "http://api.openweathermap.org/geo/1.0/direct?q="+locationData+"&limit=1&appid="+apiKey;
- GetWeatherDataOnline(weatherURL, VA);
- if (VA.GetText("~avcs_owm_return") != null)
- apiReturn = VA.GetText("~avcs_owm_return").Replace("\"","").Replace("{","").Replace("}","");
- if (apiReturn.Contains(","))
- {
- string[] lines = apiReturn.Split(
- new string[] { "," },
- StringSplitOptions.RemoveEmptyEntries
- );
- foreach (string line in lines)
- {
- if (line.Contains("lat"))
- {
- if (line.Contains(":"))
- {
- string[] checkLine = line.Split(
- new string[] { ":" },
- StringSplitOptions.RemoveEmptyEntries
- );
- if(1 < checkLine.Length)
- newLat = checkLine[1];
- }
- }
- if (line.Contains("lon"))
- {
- if (line.Contains(":"))
- {
- string[] checkLine = line.Split(
- new string[] { ":" },
- StringSplitOptions.RemoveEmptyEntries
- );
- if(1 < checkLine.Length)
- newLon = checkLine[1];
- }
- }
- }
- decimal tryNewDecimal;
- if ((newLat != "" && Decimal.TryParse(newLat, out tryNewDecimal)) && (newLon != "" && Decimal.TryParse(newLat, out tryNewDecimal)))
- {
- VA.SetText("AVCS_SENS_OWMLAT", newLat);
- VA.SetText("AVCS_SENS_OWMLON", newLon);
- weatherURL = baseURL.Replace("AVCS_SENS_OWMLAT",newLat).Replace("AVCS_SENS_OWMLON",newLon).Replace("AVCS_SENS_OWMKEY",apiKey);
- }
- else
- {
- throw new GetWeatherException();
- }
- }
- else
- {
- throw new GetWeatherException();
- }
- }
- catch (GetWeatherException e)
- {
- //for any expected unexpected faults
- faultDetected = true;
- e.GetWeatherTestException(VA);
- }
- }
- if (faultDetected != true)
- {
- string apiLoc = "";
- string apiMain = "";
- string apiTemp = "";
- string apiHeatIndex = "";
- string apiHumidity = "";
- string apiWindSpeed = "";
- string apiWindDir = "";
- string apiTempUnits = "°C";
- string apiWindUnits = "kph";
- string apiWindFrom = "North";
- try
- {
- string apiReturn = "";
- VA.SetText("~avcs_owm_return", null);
- GetWeatherDataOnline(weatherURL,VA);
- if (VA.GetText("~avcs_owm_return") != null)
- apiReturn = VA.GetText("~avcs_owm_return").Replace("\"","").Replace("{","").Replace("}","");
- if (apiReturn.Contains(","))
- {
- string[] lines = apiReturn.Split(
- new string[] { "," },
- StringSplitOptions.RemoveEmptyEntries
- );
- foreach (string line in lines)
- {
- if (line.Contains("name") && apiLoc == "")
- {
- if (line.Contains(":"))
- {
- string[] checkLine = line.Split(
- new string[] { ":" },
- StringSplitOptions.RemoveEmptyEntries
- );
- if(1 < line.Length)
- apiLoc = checkLine[1];
- }
- }
- if (line.Contains("description") && apiMain == "")
- {
- if (line.Contains(":"))
- {
- string[] checkLine = line.Split(
- new string[] { ":" },
- StringSplitOptions.RemoveEmptyEntries
- );
- if (1 < line.Length)
- {
- apiMain = checkLine[1].Trim().ToLower();
- }
- if (apiMain.StartsWith("few"))
- {
- apiMain = apiMain.Replace("few", "a few");
- }
- else if (apiMain == "clouds" )
- {
- apiMain = apiMain.Replace("clouds", "cloudy");
- }
- else if (apiMain == "sun" )
- {
- apiMain+="ny";
- }
- else if ((apiMain == "rain" ) || (apiMain == "mist" ))
- {
- apiMain+="y";
- }
- apiMain = apiMain.Replace("sky", "skies");
- }
- }
- if (line.Contains("temp") && apiTemp == "")
- {
- if (line.Contains(":"))
- {
- string[] checkLine = line.Split(
- new string[] { ":" },
- StringSplitOptions.RemoveEmptyEntries
- );
- if(1 < line.Length)
- {
- decimal convertTemp = 1;
- decimal convertedTemp = 1;
- apiTemp = checkLine[2];
- if (VA.GetBoolean("AVCS_SENS_OWM_UnitMetric") != true)
- {
- if (Decimal.TryParse(apiTemp, out convertTemp))
- {
- convertedTemp = ((convertTemp * 9) / 5) + 32;
- convertedTemp = Math.Round(convertedTemp, 0, MidpointRounding.ToEven);
- apiTemp = convertedTemp.ToString();
- apiTempUnits = "°F";
- }
- }
- else
- {
- if (Decimal.TryParse(apiTemp, out convertTemp))
- {
- convertedTemp = Math.Round(convertTemp, 0, MidpointRounding.ToEven);
- apiTemp = convertedTemp.ToString();
- apiTempUnits = "°C";
- }
- }
- }
- }
- }
- if (line.Contains("feels_like") && apiHeatIndex == "")
- {
- if (line.Contains(":"))
- {
- string[] checkLine = line.Split(
- new string[] { ":" },
- StringSplitOptions.RemoveEmptyEntries
- );
- if(1 < line.Length)
- {
- decimal convertIndex = 1;
- decimal convertedIndex = 1;
- apiHeatIndex = checkLine[1];
- if (VA.GetBoolean("AVCS_SENS_OWM_UnitMetric") != true)
- {
- if (Decimal.TryParse(apiHeatIndex, out convertIndex))
- {
- convertedIndex = ((convertIndex * 9) / 5) + 32;
- convertedIndex = Math.Round(convertedIndex, 0, MidpointRounding.ToEven);
- apiHeatIndex = convertedIndex.ToString();
- apiTempUnits = "°F";
- }
- }
- else
- {
- if (Decimal.TryParse(apiHeatIndex, out convertIndex))
- {
- convertedIndex = Math.Round(convertIndex, 0, MidpointRounding.ToEven);
- apiHeatIndex = convertedIndex.ToString();
- apiTempUnits = "°C";
- }
- }
- }
- }
- }
- if (line.Contains("humidity") && apiHumidity == "")
- {
- if (line.Contains(":"))
- {
- string[] checkLine = line.Split(
- new string[] { ":" },
- StringSplitOptions.RemoveEmptyEntries
- );
- if(1 < line.Length)
- {
- decimal convertedRH;
- apiHumidity = checkLine[1];
- if (Decimal.TryParse(apiHumidity, out convertedRH))
- {
- convertedRH = Math.Round(convertedRH, 0, MidpointRounding.ToEven);
- apiHumidity = convertedRH.ToString();
- }
- }
- }
- }
- if (line.Contains("speed") && apiWindSpeed == "")
- {
- if (line.Contains(":"))
- {
- string[] checkLine = line.Split(
- new string[] { ":" },
- StringSplitOptions.RemoveEmptyEntries
- );
- if(1 < line.Length)
- {
- decimal convertedSpeed;
- apiWindSpeed = checkLine[2];
- if (VA.GetBoolean("AVCS_SENS_OWM_WindMetric") != true)
- {
- if (Decimal.TryParse(apiWindSpeed, out convertedSpeed))
- {
- convertedSpeed *= 0.6214m;
- convertedSpeed = Math.Round(convertedSpeed, 0, MidpointRounding.ToEven);
- apiWindSpeed = convertedSpeed.ToString();
- apiWindUnits = "mph";
- }
- }
- else
- {
- if (Decimal.TryParse(apiWindSpeed, out convertedSpeed))
- {
- convertedSpeed = Math.Round(convertedSpeed, 0, MidpointRounding.ToEven);
- apiWindSpeed = convertedSpeed.ToString();
- apiWindUnits = "kph";
- }
- }
- }
- }
- }
- if (line.Contains("deg") && apiWindDir == "")
- {
- if (line.Contains(":"))
- {
- string[] checkLine = line.Split(
- new string[] { ":" },
- StringSplitOptions.RemoveEmptyEntries
- );
- if(1 < line.Length)
- {
- apiWindDir = checkLine[1];
- decimal convertedDir = 1;
- if (Decimal.TryParse(apiWindDir, out convertedDir))
- {
- if ((convertedDir > 337.5m && convertedDir <= 359m) || (convertedDir >= 0m && convertedDir < 22.5m))
- {
- apiWindFrom = "North";
- }
- else if (convertedDir >= 22.5m && convertedDir < 67.5m)
- {
- apiWindFrom = "Northeast";
- }
- else if (convertedDir >= 67.5m && convertedDir <= 112.5m)
- {
- apiWindFrom = "East";
- }
- else if (convertedDir > 112.5m && convertedDir <= 157.5m)
- {
- apiWindFrom = "Southeast";
- }
- else if (convertedDir > 157.5m && convertedDir <= 202.5m)
- {
- apiWindFrom = "South";
- }
- else if (convertedDir > 202.5m && convertedDir <= 247.5m)
- {
- apiWindFrom = "Southwest";
- }
- else if (convertedDir > 247.5m && convertedDir <= 292.5m)
- {
- apiWindFrom = "West";
- }
- else if (convertedDir > 292.5m && convertedDir <= 337.5m)
- {
- apiWindFrom = "Northwest";
- }
- }
- }
- }
- }
- }
- if (apiMain == "")
- apiMain = "pleasant";
- string testReturn = apiMain.ToLower() + " right now at " + apiTemp + apiTempUnits + ", with a heat index of " + apiHeatIndex + apiTempUnits + " and humidity at " + apiHumidity + "%. Winds are out of the " + apiWindFrom + " at " + apiWindSpeed + apiWindUnits;
- VA.SetText("~avcs_owm_test_data", apiLoc + " reports " + testReturn.Replace(" right now",""));
- VA.SetText("~avcs_owm_test_data_tts", "Conditions are " + testReturn.Replace("°C","°").Replace("°F","°"));
- VA.SetBoolean("AVCS_OWM_SET", true);
- }
- else
- {
- throw new GetWeatherException();
- }
- }
- catch (GetWeatherException e)
- {
- //for any expected unexpected faults
- e.GetWeatherTestException(VA);
- }
- }
- }
- private void GetWeatherDataOnline(string apiURL, dynamic VA)
- {
- VA.SetText("~avcs_owm_return", null);
- try
- {
- string apiReturn;
- using (WebClient wc = new WebClient())
- {
- wc.Headers.Add("Accept-Language", " en-US");
- wc.Headers.Add("Accept", " text/html, application/xhtml+xml, */*");
- apiReturn = wc.DownloadString(apiURL);
- VA.SetText("~avcs_owm_return", apiReturn);
- }
- }
- catch (WebException ex)
- {
- if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
- {
- var resp = (HttpWebResponse)ex.Response;
- if (resp.StatusCode == HttpStatusCode.NotFound)// handle HTTP 404 errors
- {
- VA.WriteToLog("AVCS ERROR - HTTP 404 - Unable to find page at URL:","red");
- VA.WriteToLog(apiURL,"blank");
- }
- }
- }
- }
- // Functions to recolor AVCS Test buttons and button text on Mouse Hover events
- public static void buttonsTester_MouseHover(object sender, EventArgs e, dynamic VA)
- {
- if (VA.GetBoolean("AVCS_SENS_Test_GetWeather") != true)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- }
- }
- public static void buttonsTester_MouseLeave(object sender, EventArgs e, dynamic VA)
- {
- if (VA.GetBoolean("AVCS_SENS_Test_GetWeather") != true)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- }
- }
- // New Baselines Button Event
- private void buttonSetCity_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM, TextBox textBoxOwmCity, string defaultOwmCity, string newOwmCity)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- string currentOwmCity = "";
- if (VA.GetText("AVCS_SENS_OWMCITY") != null)
- currentOwmCity = VA.GetText("AVCS_SENS_OWMCITY");
- if (newOwmCity != defaultOwmCity && newOwmCity != currentOwmCity)
- {
- VA.SetText("AVCS_SENS_OWM_NextDailyForecastCheck", "null");
- VA.SetText("AVCS_SENS_OWM_FORECASTS", "");
- VA.Command.Execute("F_SFS_SAVE_FORECAST", true);
- VA.SetText("AVCS_SENS_OWMCITY", newOwmCity);
- VA.SetInt("AVCS_SENS_OWM_INTERVAL", null);
- (sender as Button).Text = " Clear User City ";
- (sender as Button).AutoSize = true;
- textBoxOwmCity.ReadOnly = true;
- textBoxOwmCity.Enabled = false;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- else
- {
- VA.SetText("AVCS_SENS_OWMCITY", null);
- (sender as Button).Text = " Save User City ";
- textBoxOwmCity.Text = defaultOwmCity;
- textBoxOwmCity.ReadOnly = false;
- textBoxOwmCity.Enabled = true;
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- }
- // New Baselines Button Event
- private void buttonOwmSaveKey_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM, TextBox textBoxOwmKey, string defaultOwmKey, string newOwmKey, Button buttonForecastChecks)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- string currentOwmKey = "";
- Guid checkOwmKey;
- if (VA.GetText("AVCS_SENS_OWMKEY") != null)
- currentOwmKey = VA.GetText("AVCS_SENS_OWMKEY");
- if ((Guid.TryParse(newOwmKey, out checkOwmKey)) && (newOwmKey != "" && newOwmKey != defaultOwmKey && newOwmKey != currentOwmKey))
- {
- VA.SetText("AVCS_SENS_OWMKEY", newOwmKey);
- (sender as Button).Text = " Clear User Key ";
- (sender as Button).AutoSize = true;
- textBoxOwmKey.ReadOnly = true;
- textBoxOwmKey.Enabled = false;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- buttonForecastChecks.Enabled = true;
- buttonForecastChecks.Visible = true;
- Functions.ResizeForm(this, ControlSpacing);
- }
- else
- {
- if (((sender as Button).Text == " Save User Key ") && (newOwmKey != defaultOwmKey))
- VA.WriteToLog("Blank or invalid OWM Key entered, reverting to default key", "black");
- if (((sender as Button).Text == " Save User Key ") && (newOwmKey == defaultOwmKey))
- VA.WriteToLog("Enter your own user key here, otherwise default key will be used", "black");
- VA.SetText("AVCS_SENS_OWMKEY", defaultOwmKey);
- VA.SetBoolean("AVCS_SENS_ClearKeyNotPressed", null);
- (sender as Button).Text = " Save User Key ";
- textBoxOwmKey.Text = "";
- textBoxOwmKey.ReadOnly = false;
- textBoxOwmKey.Enabled = true;
- buttonForecastChecks.Enabled = false;
- buttonForecastChecks.Visible = false;
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- }
- // Final Exit Options Form Closing
- private void WeatherOptionsMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END WEATHER OPTIONS=================================================================
- //================================================BEGIN PROFILE CONFIG OPTIONS=================================================================
- public class ProfileConfigMenuForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public bool defaultCountSet = false;
- public string checkPresCountsSet = " Checking Updates... , Check for Update ";
- public TextBox textBoxOwmKey;
- public ProfileConfigMenuForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(10);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => ProfileConfigMenuForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "AVCS Profile Config";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.MinimumSize = new Size(320, 0);
- labelHeader.MaximumSize = new Size(320, 0);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- labelSpacerH.Text = "\nChange Update Notifications Mode";
- labelSpacerH.Font = new Font(labelSpacerH.Font.FontFamily, FontSizeM);
- labelSpacerH.AutoSize = true;
- labelSpacerH.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelSpacerH);
- // Set up buttonSetUpdateChecks
- Button buttonSetUpdateChecks = new Button();
- Button buttonSetUpdatesCheck = new Button();
- if (VA.GetInt("AVCS_SENS_UPDATES") != null)
- {
- int intervalUpdateChecks = VA.GetInt("AVCS_SENS_UPDATES");
- if (intervalUpdateChecks == 1)
- {
- buttonSetUpdateChecks.Text = " VoiceAttack Event Log ";
- }else if (intervalUpdateChecks == 2) {
- buttonSetUpdateChecks.Text = " Text-to-Speech Notice ";
- }else if (intervalUpdateChecks == 3) {
- buttonSetUpdateChecks.Text = " Update Checks Off ";
- }
- }
- else
- {
- buttonSetUpdateChecks.Text = " Text-to-Speech Notice ";
- VA.SetInt("AVCS_SENS_UPDATES", 2);
- }
- buttonSetUpdateChecks.AutoSize = true;
- if (VA.GetText("AVCS_MENU_SetUpdateChecks") != null)
- checkPresCountsSet = VA.GetText("AVCS_MENU_SetUpdateChecks");
- string[] checkPresCountSet = checkPresCountsSet.Split(new string[] { "," },StringSplitOptions.RemoveEmptyEntries);
- if (checkPresCountSet.Length < 5)
- defaultCountSet = true;
- buttonSetUpdateChecks.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetUpdateChecks.Font = new Font(buttonSetUpdateChecks.Font.FontFamily, FontSizeM);
- buttonSetUpdateChecks.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- buttonSetUpdatesCheck.Text = checkPresCountSet[1];
- buttonSetUpdatesCheck.AutoSize = true;
- buttonSetUpdatesCheck.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetUpdatesCheck.Font = new Font(buttonSetUpdatesCheck.Font.FontFamily, FontSizeM);
- buttonSetUpdatesCheck.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonSetUpdateChecks);
- this.Controls.Add(buttonSetUpdatesCheck);
- buttonSetUpdateChecks.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSetUpdateChecks.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSetUpdateChecks.Click += new EventHandler((sender, e) => buttonSetUpdateChecks_Click(sender, e, VA, ControlSpacing, FontSizeM));
- buttonSetUpdatesCheck.MouseHover += new EventHandler((sender, e) => buttonSetUpdatesCheck_MouseHover(sender, e, VA, ControlSpacing, FontSizeM));
- buttonSetUpdatesCheck.MouseLeave += new EventHandler((sender, e) => buttonSetUpdatesCheck_MouseLeave(sender, e, VA, ControlSpacing, FontSizeM));
- buttonSetUpdatesCheck.Click += new EventHandler((sender, e) => buttonSetUpdatesCheck_Click(sender, e, VA, ControlSpacing, FontSizeM, checkPresCountsSet, defaultCountSet));
- // Set up labelSpacer
- Label labelSpacerCfg = new Label();
- Functions.addLabelSpacer(this, FontSizeL, labelSpacerCfg);
- // Set up buttonOwmOptions
- Button buttonOpenConfig = new Button();
- buttonOpenConfig.Text = " Open Config File ";
- buttonOpenConfig.AutoSize = true;
- buttonOpenConfig.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOpenConfig.Font = new Font(buttonOpenConfig.Font.FontFamily, FontSizeM);
- buttonOpenConfig.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip OpenConfigTip = new ToolTip();
- OpenConfigTip.SetToolTip(buttonOpenConfig,"(manual editing is discouraged, careful! file reloaded anytime sensor menu opens)");
- this.Controls.Add(buttonOpenConfig);
- buttonOpenConfig.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonOpenConfig.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonOpenConfig.Click += new EventHandler((sender, e) => buttonOpenConfig_Click(sender, e, VA));
- // Set up buttonOpenCfgFolder
- Button buttonOpenCfgFolder = new Button();
- buttonOpenCfgFolder.Text = " Open Config Folder ";
- buttonOpenCfgFolder.AutoSize = true;
- buttonOpenCfgFolder.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOpenCfgFolder.Font = new Font(buttonOpenCfgFolder.Font.FontFamily, FontSizeM);
- buttonOpenCfgFolder.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- ToolTip OpenCfgFolderTip = new ToolTip();
- OpenCfgFolderTip.SetToolTip(buttonOpenCfgFolder,"(manual editing is discouraged, careful!)");
- this.Controls.Add(buttonOpenCfgFolder);
- buttonOpenCfgFolder.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonOpenCfgFolder.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonOpenCfgFolder.Click += new EventHandler((sender, e) => buttonOpenCfgFolder_Click(sender, e, VA));
- // Set up labelHelp
- LinkLabel labelHelp = new LinkLabel();
- labelHelp.Text = "\n\nNeed help? Report bugs here or post up in the\nAVCS Help && Support channel at VG Discord";
- labelHelp.LinkArea = new LinkArea(25, 4);
- labelHelp.Font = new Font(labelHelp.Font.FontFamily, FontSizeS);
- labelHelp.LinkColor = Color.FromArgb(64, 188, 255);
- labelHelp.AutoSize = true;
- labelHelp.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip HelpTip = new ToolTip();
- string HelpLink = "https://veterans-gaming.com/semlerpdx/bugs/";
- HelpTip.SetToolTip(labelHelp,"Click here to report bugs at " + HelpLink);
- this.Controls.Add(labelHelp);
- labelHelp.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, HelpLink));
- // Set up buttonDiscordLink
- Button buttonDiscordLink = new Button();
- buttonDiscordLink.Text = " VG DISCORD ";
- buttonDiscordLink.AutoSize = true;
- buttonDiscordLink.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonDiscordLink.Font = new Font(buttonDiscordLink.Font.FontFamily, FontSizeM);
- buttonDiscordLink.ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
- buttonDiscordLink.BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- ToolTip DiscordLinkTip = new ToolTip();
- string DiscordLink = "https://discord.gg/xDJUjYQked";
- DiscordLinkTip.SetToolTip(buttonDiscordLink,DiscordLink);
- this.Controls.Add(buttonDiscordLink);
- buttonDiscordLink.MouseHover += new EventHandler((sender, e) => Functions.buttonsReverse_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonDiscordLink.MouseLeave += new EventHandler((sender, e) => Functions.buttonsReverse_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonDiscordLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, DiscordLink));
- // Set up buttonWikiLink
- Button buttonWikiLink = new Button();
- buttonWikiLink.Text = " AVCS WIKI ";
- buttonWikiLink.AutoSize = true;
- buttonWikiLink.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonWikiLink.Font = new Font(buttonWikiLink.Font.FontFamily, FontSizeM);
- buttonWikiLink.ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
- buttonWikiLink.BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- ToolTip WikiLinkTip = new ToolTip();
- string WikiLink = "https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather/";
- WikiLinkTip.SetToolTip(buttonWikiLink, WikiLink);
- this.Controls.Add(buttonWikiLink);
- buttonWikiLink.MouseHover += new EventHandler((sender, e) => Functions.buttonsReverse_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonWikiLink.MouseLeave += new EventHandler((sender, e) => Functions.buttonsReverse_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonWikiLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, WikiLink));
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSize, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Link to AVCS Downloads Page
- LinkLabel labelOwmLink = new LinkLabel();
- labelOwmLink.Text = "Find AVCS Profiles and Updates at Veterans-Gaming.com";
- labelOwmLink.LinkArea = new LinkArea(5, 25);
- labelOwmLink.Font = new Font(labelOwmLink.Font.FontFamily, FontSizeS);
- labelOwmLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelOwmLink.AutoSize = true;
- labelOwmLink.TextAlign = ContentAlignment.MiddleCenter;
- string OwmLink = "https://veterans-gaming.com/semlerpdx/downloads/";
- ToolTip OwmLinkTip = new ToolTip();
- OwmLinkTip.SetToolTip(labelOwmLink, OwmLink);
- this.Controls.Add(labelOwmLink);
- labelOwmLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, OwmLink));
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Change Updates Notifications Mode Button Event
- private void buttonSetUpdateChecks_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
- {
- if (VA.GetInt("AVCS_SENS_UPDATES") != null)
- {
- int checkUpdateCheckMode = VA.GetInt("AVCS_SENS_UPDATES");
- if (checkUpdateCheckMode == 1)
- {
- VA.SetInt("AVCS_SENS_UPDATES", 2);
- (sender as Button).Text = " Text-to-Speech Notice ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkUpdateCheckMode == 2) {
- VA.SetInt("AVCS_SENS_UPDATES", 3);
- (sender as Button).Text = " Update Checks Off ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }else if (checkUpdateCheckMode == 3) {
- VA.SetInt("AVCS_SENS_UPDATES", 1);
- (sender as Button).Text = " VoiceAttack Event Log ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- else
- {
- VA.SetInt("AVCS_SENS_UPDATES", 2);
- (sender as Button).Text = " Text-to-Speech Notice ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- }
- // Update Check Button Click Event
- private void buttonSetUpdatesCheck_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM, string checkPresCountsSet, bool defaultCountSet)
- {
- int checkPressCount;
- int maxPressCount = 4;
- int holdPressCount = 15;
- int maxxPressCount = 25;
- int updaterPressCount = 23;
- if (VA.GetInt("~~avcs_updatecheck_count") != null)
- {
- checkPressCount = VA.GetInt("~~avcs_updatecheck_count");
- checkPressCount += 1;
- VA.SetInt("~~avcs_updatecheck_count", checkPressCount);
- }
- else
- {
- checkPressCount = 0;
- VA.SetInt("~~avcs_updatecheck_count", checkPressCount);
- }
- if (defaultCountSet != true)
- {
- string[] checkPressCountSet = checkPresCountsSet.Split(new string[] { "," },StringSplitOptions.RemoveEmptyEntries);
- if (checkPressCount != updaterPressCount)
- (sender as Button).Text = checkPressCountSet[checkPressCount];
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- if (checkPressCount == holdPressCount)
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, checkPressCount);
- if (checkPressCount >= updaterPressCount)
- Functions.visitLink(checkPressCountSet[updaterPressCount]);
- if (checkPressCount >= maxxPressCount)
- VA.SetInt("~~avcs_updatecheck_count", maxPressCount);
- Functions.ResizeForm(this, ControlSpacing);
- }
- //'Cuz it's important to have fun now and then
- if (VA.GetBoolean("AVCS_SENS_UPDATE_CHECK") != null)
- {
- VA.WriteToLog("Update Check already in progress...", "red");
- }
- else
- {
- if (checkPressCount < maxPressCount)
- {
- VA.SetBoolean("AVCS_SENS_UPDATE_CHECK", true);
- VA.SetBoolean("AVCS_SENS_VersionChecked", null);
- try
- {
- VA.Command.Execute("F_SENS_UPDATE");
- }
- catch
- {
- VA.SetBoolean("AVCS_SENS_UPDATE_CHECK", null);
- VA.SetBoolean("AVCS_SENS_VersionChecked", true);
- }
- }
- }
- }
- // Open Config File Button Event
- private void buttonOpenConfig_Click(object sender, EventArgs e, dynamic VA)
- {
- Functions.buttonOpenFile(VA, VA.ParseTokens("{TXT:AVCS_SENS_SaveFilePath:}"));
- }
- // Open Config Folder Button Event
- private void buttonOpenCfgFolder_Click(object sender, EventArgs e, dynamic VA)
- {
- string configFolderPath = VA.ParseTokens("{TXT:AVCS_SENS_FolderPath}");
- try
- {
- Process.Start(configFolderPath);
- VA.WriteToLog("Config Folder Opened...", "green");
- }
- catch
- {
- VA.WriteToLog("AVCS ERROR: Config Folder not found at path:", "red");
- VA.WriteToLog(configFolderPath, "blank");
- }
- }
- // Functions to recolor AVCS Profile Options 'Check for Update' button and button text on Mouse Hover events
- private void buttonSetUpdatesCheck_MouseHover(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
- {
- if (VA.GetInt("~~avcs_updatecheck_count") != null)
- {
- (sender as Button).Text = " Check for Update ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- }
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- }
- private void buttonSetUpdatesCheck_MouseLeave(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
- {
- (sender as Button).Text = " Check for Update ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(this, ControlSpacing);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- }
- // Final Exit Options Form Closing
- private void ProfileConfigMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END PROFILE CONFIG OPTIONS=================================================================
- //================================================BEGIN BASELINE MENU OPTIONS=================================================================
- public class BaselinesMenuForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public BaselinesMenuForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(10);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => BaselinesMenuForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "AVCS Sensor Baselines Menu";
- labelHeader.MinimumSize = new Size(300, 0);
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // Set up labelTitle
- Label labelTitle = new Label();
- labelTitle.Text = "Choose a Baseline Level to Set:";
- labelTitle.Font = new Font(labelTitle.Font.FontFamily, FontSize);
- labelTitle.AutoSize = true;
- labelTitle.MinimumSize = new Size(300, 0);
- labelTitle.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelTitle);
- // Set up buttonSetLowBaseline
- Button buttonSetLowBaseline = new Button();
- buttonSetLowBaseline.Text = " LOW ";
- buttonSetLowBaseline.AutoSize = true;
- buttonSetLowBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetLowBaseline.Font = new Font(buttonSetLowBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonSetLowBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonSetLowBaseline);
- buttonSetLowBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSetLowBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSetLowBaseline.Click += new EventHandler((sender, e) => buttonSetBaseline_Click(sender, e, VA, profileTitle, icon, "LOW"));
- // Set up buttonSetMediumBaseline
- Button buttonSetMediumBaseline = new Button();
- buttonSetMediumBaseline.Text = " MEDIUM ";
- buttonSetMediumBaseline.AutoSize = true;
- buttonSetMediumBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetMediumBaseline.Font = new Font(buttonSetMediumBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonSetMediumBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonSetMediumBaseline);
- buttonSetMediumBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSetMediumBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSetMediumBaseline.Click += new EventHandler((sender, e) => buttonSetBaseline_Click(sender, e, VA, profileTitle, icon, "MEDIUM"));
- // Set up buttonSetHighBaseline
- Button buttonSetHighBaseline = new Button();
- buttonSetHighBaseline.Text = " HIGH ";
- buttonSetHighBaseline.AutoSize = true;
- buttonSetHighBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetHighBaseline.Font = new Font(buttonSetHighBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonSetHighBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonSetHighBaseline);
- buttonSetHighBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSetHighBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSetHighBaseline.Click += new EventHandler((sender, e) => buttonSetBaseline_Click(sender, e, VA, profileTitle, icon, "HIGH"));
- // Set up buttonSetExtremeBaseline
- Button buttonSetExtremeBaseline = new Button();
- buttonSetExtremeBaseline.Text = " EXTREME ";
- buttonSetExtremeBaseline.AutoSize = true;
- buttonSetExtremeBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSetExtremeBaseline.Font = new Font(buttonSetExtremeBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonSetExtremeBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonSetExtremeBaseline);
- buttonSetExtremeBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSetExtremeBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSetExtremeBaseline.Click += new EventHandler((sender, e) => buttonSetBaseline_Click(sender, e, VA, profileTitle, icon, "EXTREME"));
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Label
- Label labelFooter = new Label();
- Functions.addFooterLabel(this, FontSizeS, labelFooter);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Open Sensor Options Form
- private void buttonSetBaseline_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon, string baselineToSet)
- {
- this.Hide();
- Form FormBaselinesSet = new BaselinesSetForm(VA, profileTitle, icon, baselineToSet);
- FormBaselinesSet.ShowDialog();
- this.Show();
- }
- // Final Exit Options Form Closing
- private void BaselinesMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //Baseline Form Closing final actions (if any)
- }
- }
- //================================================END BASELINE MENU OPTIONS=================================================================
- //================================================BEGIN BASELINE SET FORM=================================================================
- public class BaselinesSetForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public BaselinesSetForm(dynamic VA, string profileTitle, Icon icon, string baselinesToSet)
- {
- TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
- string textThisBaseline = textInfo.ToTitleCase(baselinesToSet.ToLower());
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(20);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => BaselinesSetForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "Record " + textThisBaseline + " Baseline State";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // CC License Link and Credit to AVCS Profiles
- Label labelSetBaselineSteps = new Label();
- labelSetBaselineSteps.Text = "First, bring the computer into an operational state that best resembles the baseline you are attemping to record.\n\nNext, maintain this state for at least 30 seconds to allow the ten rolling data points to contain new values from this current state.\n\nFinally, press the SAVE button below to record all diagnostic sensor averages from current data points as baseline comparision values for " + textThisBaseline + " operational states during diagnostics.\n\n";
- labelSetBaselineSteps.Font = new Font(labelSetBaselineSteps.Font.FontFamily, FontSizeM);
- labelSetBaselineSteps.AutoSize = true;
- labelSetBaselineSteps.TextAlign = ContentAlignment.MiddleLeft;
- labelSetBaselineSteps.MinimumSize = new Size(480, 0);
- labelSetBaselineSteps.MaximumSize = new Size(480, 0);
- this.Controls.Add(labelSetBaselineSteps);
- // Set up buttonSaveBaseline
- Button buttonSaveBaseline = new Button();
- buttonSaveBaseline.Text = " SAVE " + baselinesToSet + " BASELINE ";
- buttonSaveBaseline.AutoSize = true;
- buttonSaveBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSaveBaseline.Font = new Font(buttonSaveBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonSaveBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- buttonSaveBaseline.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.Controls.Add(buttonSaveBaseline);
- buttonSaveBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSaveBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSaveBaseline.Click += new EventHandler((sender, e) => buttonSaveBaseline_Click(sender, e, VA, baselinesToSet));
- Label labelSetBaselineTips = new Label();
- labelSetBaselineTips.Text = "\nTIP:\nFor an idle/low state, consider how you use your PC in a minimum state perhaps including an open webpage or two, a music/video player running, and other usual background programs, rather than a minimal processes or fresh OS restart state, for a more useful and typical real world application.\n\nOnly a LOW baseline is required for diagnostics, all others match these values until set with new/different values.";
- labelSetBaselineTips.Font = new Font(labelSetBaselineTips.Font.FontFamily, FontSizeM);
- labelSetBaselineTips.AutoSize = true;
- labelSetBaselineTips.TextAlign = ContentAlignment.MiddleLeft;
- labelSetBaselineTips.MinimumSize = new Size(480, 0);
- labelSetBaselineTips.MaximumSize = new Size(480, 0);
- this.Controls.Add(labelSetBaselineTips);
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Label
- Label labelFooter = new Label();
- Functions.addFooterLabel(this, FontSizeS, labelFooter);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Save Baseline Button Click Event
- private void buttonSaveBaseline_Click(object sender, EventArgs e, dynamic VA, string thisBaseline)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
- int checkInterval = 0;
- int minimumInterval = 10;
- if (VA.GetInt("AVCS_SENS_MAIN_INTERVAL") != null)
- {
- checkInterval = VA.GetInt("AVCS_SENS_MAIN_INTERVAL");
- }
- if (VA.GetBoolean("AVCS_SENS_Monitoring") != true || VA.GetBoolean("AVCS_SENS_Logging") != true)
- {
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- (sender as Button).Enabled = false;
- VA.WriteToLog("Sensor Monitoring must be enabled to establish baseline data!", "red");
- VA.WriteToLog("Please begin Sensor Monitoring. See user guide for more information.", "blank");
- VA.SetText("AVCS_SENS_TTS_WILDCARD", "Sensor monitoring data not detected. Please enable monitoring first.");
- VA.Command.Execute("F_SAY_TTS", true);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).Enabled = true;
- }
- else
- {
- if (VA.GetDecimal("AVCS_SENS_TempDHTf") != null && checkInterval >= minimumInterval)
- {
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- (sender as Button).Enabled = false;
- VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", thisBaseline.ToUpper());
- VA.SetText("AVCS_SENS_TTS_WILDCARD", "Gathering " + thisBaseline.ToLower() + " baseline data now.");
- VA.WriteToLog("AVCS is Gathering Baseline Data! This may take up to a minute to complete!", "red");
- VA.Command.Execute("F_SAY_TTS", true);
- if (thisBaseline.ToUpper() == "LOW" && VA.GetBoolean("AVCS_SENS_SET_BASELINE_LEVEL_MEDIUM") != true && VA.GetBoolean("AVCS_SENS_SET_BASELINE_LEVEL_HIGH") != true && VA.GetBoolean("AVCS_SENS_SET_BASELINE_LEVEL_EXTREME") != true)
- {
- VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", "LOW");
- VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", "LOW");
- VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
- while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
- Thread.Sleep(100);
- Thread.Sleep(1500);
- if (VA.Command.Active("F_SFS_SAVE_DATA") == true)
- {
- while (VA.Command.Active("F_SFS_SAVE_DATA") == true)
- Thread.Sleep(50);
- }
- VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", "MEDIUM");
- VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", "MEDIUM");
- VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
- while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
- Thread.Sleep(100);
- Thread.Sleep(1500);
- if (VA.Command.Active("F_SFS_SAVE_DATA") == true)
- {
- while (VA.Command.Active("F_SFS_SAVE_DATA") == true)
- Thread.Sleep(50);
- }
- VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", "HIGH");
- VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", "HIGH");
- VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
- while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
- Thread.Sleep(100);
- Thread.Sleep(1500);
- if (VA.Command.Active("F_SFS_SAVE_DATA") == true)
- {
- while (VA.Command.Active("F_SFS_SAVE_DATA") == true)
- Thread.Sleep(50);
- }
- VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", "EXTREME");
- VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", "EXTREME");
- VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
- while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
- Thread.Sleep(50);
- Thread.Sleep(1500);
- if (VA.Command.Active("F_SFS_SAVE_DATA") == true)
- {
- while (VA.Command.Active("F_SFS_SAVE_DATA") == true)
- Thread.Sleep(50);
- }
- }
- else
- {
- VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", thisBaseline.ToUpper());
- VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
- while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
- Thread.Sleep(50);
- }
- VA.SetText("AVCS_SENS_TTS_WILDCARD", thisBaseline + " sensor data baseline is now complete.");
- VA.Command.Execute("F_SAY_TTS", false);
- VA.SetBoolean("AVCS_SENS_SET_BASELINE_LEVEL_" + thisBaseline.ToUpper(), true);
- this.Close();
- }
- else
- {
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- (sender as Button).Enabled = false;
- if (checkInterval < minimumInterval)
- {
- VA.WriteToLog("Not enough data points have been established yet...", "red");
- VA.WriteToLog("Please wait at least 30 seconds after enabling monitoring before setting baselines", "blank");
- VA.SetText("AVCS_SENS_TTS_WILDCARD", "Cannot establish baselines yet. Please wait at least 30 seconds.");
- }
- else
- {
- VA.WriteToLog("Cannot locate AVCS-DHT1 External Temperature Sensor data!", "red");
- VA.WriteToLog("Please check settings. See user guide for more information.", "blank");
- VA.SetText("AVCS_SENS_TTS_WILDCARD", "External temperature sensor data not detected. Please check device or settings.");
- }
- VA.Command.Execute("F_SAY_TTS", true);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).Enabled = true;
- }
- }
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
- }
- }
- // Final Exit Options Form Closing
- private void BaselinesSetForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END BASELINE SET FORM=================================================================
- //================================================BEGIN CREDITS FORM=================================================================
- public class CreditsForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public CreditsForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(10);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 1;
- this.FormClosing += new FormClosingEventHandler((sender, e) => CreditsForm_FormClosing(sender, e, VA));
- // Set up labelSpacer
- Label labelSpacerT = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacerT);
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "CREDITS";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.MinimumSize = new Size(300, 0);
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacerH);
- // Set up AVCS Credits
- Label labelByLine1 = new Label();
- labelByLine1.Text = " Thanks for checking out my AVCS Profiles! ";
- labelByLine1.Font = new Font(labelByLine1.Font.FontFamily, FontSizeM);
- labelByLine1.AutoSize = true;
- labelByLine1.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelByLine1);
- // Set up labelSpacer
- Label labelSpacerCC2a = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacerCC2a);
- // Footer Link and Credit to VoiceAttack Forums
- Label labelNonAffiliate = new Label();
- labelNonAffiliate.Text = "(AIDA64 and OpenWeather are not affiliated with AVCS)";
- labelNonAffiliate.Font = new Font(labelNonAffiliate.Font.FontFamily, FontSizeS);
- labelNonAffiliate.AutoSize = true;
- labelNonAffiliate.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelNonAffiliate);
- // Set up labelSpacer
- Label labelSpacerCC2b = new Label();
- Functions.addLabelSpacer(this, 6, labelSpacerCC2b);
- // Credits Link to Open Weather Map
- LinkLabel labelOwmLink = new LinkLabel();
- labelOwmLink.Text = "Weather data provided by OpenWeather (TM)";
- labelOwmLink.LinkArea = new LinkArea(25, 11);
- labelOwmLink.Font = new Font(labelOwmLink.Font.FontFamily, FontSize);
- labelOwmLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelOwmLink.AutoSize = true;
- labelOwmLink.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip OwmLinkTip = new ToolTip();
- string OwmLink = "https://openweathermap.org/";
- OwmLinkTip.SetToolTip(labelOwmLink, OwmLink);
- this.Controls.Add(labelOwmLink);
- labelOwmLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, OwmLink));
- // CC License Link and Credit to Open Weather Map
- LinkLabel labelCC2Link = new LinkLabel();
- labelCC2Link.Text = "under their CC BY-SA 4.0 license";
- labelCC2Link.LinkArea = new LinkArea(12, 12);
- labelCC2Link.Font = new Font(labelCC2Link.Font.FontFamily, FontSize);
- labelCC2Link.LinkColor = Color.FromArgb(64, 188, 255);
- labelCC2Link.AutoSize = true;
- labelCC2Link.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip CC2LinkTip = new ToolTip();
- string CC2Link = "https://creativecommons.org/licenses/by-sa/4.0/";
- CC2LinkTip.SetToolTip(labelCC2Link,CC2Link);
- this.Controls.Add(labelCC2Link);
- labelCC2Link.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, CC2Link));
- // Set up labelSpacer
- Label labelSpacerA = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacerA);
- // Credits to AIDA64 / FinalWire Ltd.
- LinkLabel labelAidaTrademark = new LinkLabel();
- labelAidaTrademark.Text = "AIDA64 is a Registered Trademark of FinalWire Ltd.";
- labelAidaTrademark.Font = new Font(labelAidaTrademark.Font.FontFamily, FontSize);
- labelAidaTrademark.LinkArea = new LinkArea(0, 0); //????
- labelAidaTrademark.AutoSize = true;
- labelAidaTrademark.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelAidaTrademark);
- // Credits Link to AIDA64 / FinalWire Ltd.
- LinkLabel labelAidaLink = new LinkLabel();
- labelAidaLink.Text = "©2010-" + DateTime.Now.ToString("yyyy").Trim() + " FinalWire Ltd. All rights reserved.";
- labelAidaLink.LinkArea = new LinkArea(11, 14);
- labelAidaLink.Font = new Font(labelAidaLink.Font.FontFamily, FontSize);
- labelAidaLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelAidaLink.AutoSize = true;
- labelAidaLink.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip AidaLinkTip = new ToolTip();
- string AidaLink = "https://www.aida64.com/";
- AidaLinkTip.SetToolTip(labelAidaLink, AidaLink);
- this.Controls.Add(labelAidaLink);
- labelAidaLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, AidaLink));
- // Set up labelSpacer
- Label labelSpacerCC3 = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacerCC3);
- // Footer Link and Credit to VoiceAttack Forums
- Label labelVAForums = new Label();
- labelVAForums.Text = "Check out other awesome public profiles and";
- labelVAForums.Font = new Font(labelVAForums.Font.FontFamily, FontSize);
- labelVAForums.AutoSize = true;
- labelVAForums.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelVAForums);
- // CC License Link and Credit to Open Weather Map
- LinkLabel labelVAForumLink = new LinkLabel();
- labelVAForumLink.Text = "plugins on the VoiceAttack website forums!";
- labelVAForumLink.LinkArea = new LinkArea(15, 11);
- labelVAForumLink.Font = new Font(labelVAForumLink.Font.FontFamily, FontSize);
- labelVAForumLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelVAForumLink.AutoSize = true;
- labelVAForumLink.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip VAForumLinkTip = new ToolTip();
- string VAForumLink = "https://forum.voiceattack.com/";
- VAForumLinkTip.SetToolTip(labelVAForumLink,VAForumLink);
- this.Controls.Add(labelVAForumLink);
- labelVAForumLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, VAForumLink));
- // Set up labelSpacer4
- Label labelSpacerCC4 = new Label();
- Functions.addLabelSpacer(this, 6, labelSpacerCC4);
- // Credits to Exergist C# Inline GUI Menu Tutorial Example
- Label labelMenuCredit = new Label();
- labelMenuCredit.Text = "Huge thanks goes to Exergist on the forums for his tutorial example on using Windows Forms via inline functions such as this menu, cheers to Pfeil for his endless patience and tips, and of course, to Gary for all his hard work over the years!";
- labelMenuCredit.Font = new Font(labelMenuCredit.Font.FontFamily, FontSize);
- labelMenuCredit.AutoSize = true;
- labelMenuCredit.TextAlign = ContentAlignment.MiddleCenter;
- labelMenuCredit.MaximumSize = new Size(320, 0);
- this.Controls.Add(labelMenuCredit);
- // Set up labelSpacer
- Label labelSpacerB = new Label();
- Functions.addLabelSpacer(this, 12, labelSpacerB);
- // Set up AVCS Credits
- Label labelByLine1Content = new Label();
- labelByLine1Content.Text = "I spend my days turning coffee into code, and my passion is creating free advanced voice control systems for the PC and PC games.";
- labelByLine1Content.Font = new Font(labelByLine1Content.Font.FontFamily, FontSize);
- labelByLine1Content.AutoSize = true;
- labelByLine1Content.TextAlign = ContentAlignment.MiddleCenter;
- labelByLine1Content.MaximumSize = new Size(300, 0);
- this.Controls.Add(labelByLine1Content);
- // Set up labelSpacer
- Label labelSpacerC = new Label();
- Functions.addLabelSpacer(this, 6, labelSpacerC);
- // Set up buttonCoffeeLink
- Button buttonCoffeeLink = new Button();
- buttonCoffeeLink.Text = " Buy a Coffee for this lad ";
- buttonCoffeeLink.AutoSize = true;
- buttonCoffeeLink.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonCoffeeLink.Font = new Font(buttonCoffeeLink.Font.FontFamily, FontSizeM);
- buttonCoffeeLink.ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
- buttonCoffeeLink.BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- ToolTip CoffeeLinkTip = new ToolTip();
- string CoffeeLink = "https://www.buymeacoffee.com/semlerpdx/";
- CoffeeLinkTip.SetToolTip(buttonCoffeeLink,CoffeeLink);
- this.Controls.Add(buttonCoffeeLink);
- buttonCoffeeLink.MouseHover += new EventHandler((sender, e) => Functions.buttonsReverse_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonCoffeeLink.MouseLeave += new EventHandler((sender, e) => Functions.buttonsReverse_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonCoffeeLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, CoffeeLink));
- // Set up labelSpacer
- Label labelSpacerSub1 = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacerSub1);
- // Footer Link and Credit to VoiceAttack Forums
- Label labelByLine1Sub = new Label();
- labelByLine1Sub.Text = "If you like my projects, any support \n is greatly appreciated!";
- labelByLine1Sub.Font = new Font(labelByLine1Sub.Font.FontFamily, FontSize);
- labelByLine1Sub.AutoSize = true;
- labelByLine1Sub.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelByLine1Sub);
- // Set up labelSpacer
- Label labelSpacerCC1 = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerCC1);
- // CC License Link and Credit to AVCS Profiles
- LinkLabel labelCC1Link = new LinkLabel();
- labelCC1Link.Text = "AVCS Profiles are shared under CC BY-NC-ND 4.0";
- labelCC1Link.LinkArea = new LinkArea(31, 15);
- labelCC1Link.Font = new Font(labelCC1Link.Font.FontFamily, FontSize);
- labelCC1Link.LinkColor = Color.FromArgb(64, 188, 255);
- labelCC1Link.AutoSize = true;
- labelCC1Link.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip CC1LinkTip = new ToolTip();
- string CC1Link = "https://creativecommons.org/licenses/by-nc-nd/4.0/";
- CC1LinkTip.SetToolTip(labelCC1Link,CC1Link);
- this.Controls.Add(labelCC1Link);
- labelCC1Link.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, CC1Link));
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Set up labelSpacer
- Label labelSpacerF2 = new Label();
- Functions.addLabelSpacer(this, 6, labelSpacerF2);
- // Footer Label
- Label labelFooter = new Label();
- labelFooter.Text = " - Advanced Voice Control Systems for VoiceAttack - ";
- labelFooter.Font = new Font(labelFooter.Font.FontFamily, FontSizeS);
- labelFooter.AutoSize = true;
- labelFooter.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelFooter);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Final Exit Options Form Closing
- private void CreditsForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END CREDITS FORM=================================================================
- //================================================BEGIN GUIDE FORM=================================================================
- public class GuideForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public GuideForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(20);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 1;
- this.FormClosing += new FormClosingEventHandler((sender, e) => GuideForm_FormClosing(sender, e, VA));
- // Set up labelSpacer
- Label labelSpacerH1 = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacerH1);
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "USER GUIDES";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH2 = new Label();
- Functions.addLabelSpacer(this, 20, labelSpacerH2);
- // Set up buttonSharedMem
- Button buttonSharedMem = new Button();
- buttonSharedMem.Text = " Sensors Setup Info ";
- buttonSharedMem.AutoSize = true;
- buttonSharedMem.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSharedMem.Font = new Font(buttonSharedMem.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonSharedMem.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonSharedMem);
- buttonSharedMem.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonSharedMem.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonSharedMem.Click += new EventHandler((sender, e) => buttonSharedMem_Click(sender, e, VA, profileTitle, icon));
- // Set up labelSpacer
- Label labelSpacer1 = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacer1);
- // Set up buttonReportsInfo
- Button buttonReportsInfo = new Button();
- buttonReportsInfo.Text = " Sensor Reports Use ";
- buttonReportsInfo.AutoSize = true;
- buttonReportsInfo.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonReportsInfo.Font = new Font(buttonReportsInfo.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonReportsInfo.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- //ToolTip OwmMonitoringTip = new ToolTip();
- //OwmMonitoringTip.SetToolTip(buttonReportsInfo,"(monitoring will continue even if this menu is closed)");
- this.Controls.Add(buttonReportsInfo);
- buttonReportsInfo.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonReportsInfo.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonReportsInfo.Click += new EventHandler((sender, e) => buttonReportsInfo_Click(sender, e, VA, profileTitle, icon));
- // Set up labelSpacer
- Label labelSpacer2 = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacer2);
- // Set up labelSpacer
- Label labelAuthorNote = new Label();
- labelAuthorNote.Text = "Never mistake AVCS Profile Sensors commands as getting true and important values for use in overclocking or system stability management, please continue to use AIDA64 itself and any other tools - AVCS only reports averages spanning over 30 seconds and cannot keep up with the level of accuracy and speed required for anything so important!";
- labelAuthorNote.Font = new Font(labelAuthorNote.Font.FontFamily, FontSize);
- labelAuthorNote.MaximumSize = new Size(420, 0);
- labelAuthorNote.AutoSize = true;
- labelAuthorNote.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelAuthorNote);
- // Set up labelSpacer
- Label labelSpacer3 = new Label();
- Functions.addLabelSpacer(this, 16, labelSpacer3);
- // Set up buttonDiagInfo
- Button buttonDiagInfo = new Button();
- buttonDiagInfo.Text = " PC Sensors / DHT11 Info ";
- buttonDiagInfo.AutoSize = true;
- buttonDiagInfo.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonDiagInfo.Font = new Font(buttonDiagInfo.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonDiagInfo.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonDiagInfo);
- buttonDiagInfo.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonDiagInfo.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonDiagInfo.Click += new EventHandler((sender, e) => buttonDiagInfo_Click(sender, e, VA, profileTitle, icon));
- // Set up labelSpacer
- Label labelSpacer4 = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacer4);
- // Set up buttonDiagUse
- Button buttonDiagUse = new Button();
- buttonDiagUse.Text = " Sensor Diagnostics Use ";
- buttonDiagUse.AutoSize = true;
- buttonDiagUse.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonDiagUse.Font = new Font(buttonDiagUse.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonDiagUse.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonDiagUse);
- buttonDiagUse.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonDiagUse.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonDiagUse.Click += new EventHandler((sender, e) => buttonDiagUse_Click(sender, e, VA, profileTitle, icon));
- // Set up labelSpacer
- Label labelSpacer5 = new Label();
- Functions.addLabelSpacer(this, 6, labelSpacer5);
- // Credits Link to AIDA64 / FinalWire Ltd.
- LinkLabel labelAuthorNoteLink = new LinkLabel();
- labelAuthorNoteLink.Text = "AVCS Sensor Diagnostics can be useful, and fun for live streams or personal use, but are truly 'differential diagnosis without a prognosis', meaning the user must cross check for themselves to provide their own second opinion and/or continue with further testing outside AVCS. Find complete info in the AVCS Wiki.";
- labelAuthorNoteLink.LinkArea = new LinkArea(303, 9);
- labelAuthorNoteLink.Font = new Font(labelAuthorNoteLink.Font.FontFamily, FontSize);
- labelAuthorNoteLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelAuthorNoteLink.AutoSize = true;
- labelAuthorNoteLink.MaximumSize = new Size(420, 0);
- labelAuthorNoteLink.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip AuthorNoteLinkTip = new ToolTip();
- string AuthorNoteLink = "https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather/";
- AuthorNoteLinkTip.SetToolTip(labelAuthorNoteLink, AuthorNoteLink);
- this.Controls.Add(labelAuthorNoteLink);
- labelAuthorNoteLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, AuthorNoteLink));
- // Set up labelSpacer
- Label labelSpacer6 = new Label();
- Functions.addLabelSpacer(this, 16, labelSpacer6);
- // Set up buttonWeatherData
- Button buttonWeatherData = new Button();
- buttonWeatherData.Text = " Weather Data Info ";
- buttonWeatherData.AutoSize = true;
- buttonWeatherData.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonWeatherData.Font = new Font(buttonWeatherData.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonWeatherData.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonWeatherData);
- buttonWeatherData.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonWeatherData.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonWeatherData.Click += new EventHandler((sender, e) => buttonWeatherData_Click(sender, e, VA, profileTitle, icon));
- // Set up labelSpacer
- Label labelSpacer7 = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacer7);
- // Set up buttonWeatherOptions
- Button buttonWeatherOptions = new Button();
- buttonWeatherOptions.Text = " Weather Options Info ";
- buttonWeatherOptions.AutoSize = true;
- buttonWeatherOptions.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonWeatherOptions.Font = new Font(buttonWeatherOptions.Font.FontFamily, FontSizeM, FontStyle.Bold);
- buttonWeatherOptions.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- this.Controls.Add(buttonWeatherOptions);
- buttonWeatherOptions.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonWeatherOptions.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonWeatherOptions.Click += new EventHandler((sender, e) => buttonWeatherOptions_Click(sender, e, VA, profileTitle, icon));
- // Set up labelSpacer
- Label labelSpacer8 = new Label();
- Functions.addLabelSpacer(this, 16, labelSpacer8);
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Set up labelSpacer
- Label labelSpacer9 = new Label();
- Functions.addLabelSpacer(this, 8, labelSpacer9);
- // Footer Label Non-Affiliated
- Label labelAuthorNote3 = new Label();
- labelAuthorNote3.Text = "(AIDA64 and OpenWeather are not affiliated with AVCS)";
- labelAuthorNote3.Font = new Font(labelAuthorNote3.Font.FontFamily, FontSizeS);
- labelAuthorNote3.AutoSize = true;
- labelAuthorNote3.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelAuthorNote3);
- // Footer Link and Credit to AIDA64/FinalWire
- LinkLabel labelFinalWireLink = new LinkLabel();
- Functions.addFinalWireLinkFooterLabel2(VA, this, FontSizeS, labelFinalWireLink);
- // Footer Link and Credit to Open Weather Map
- LinkLabel labelOwmFooterLink = new LinkLabel();
- Functions.addOwmLinkFooterLabel2(VA, this, FontSizeS, labelOwmFooterLink);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Open Shared Memory Info Form
- private void buttonSharedMem_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- this.Hide();
- Form FormOpenGuide = new GuideSharedMemForm(VA, profileTitle, icon);
- FormOpenGuide.ShowDialog();
- this.Show();
- }
- // Open Sensor Reports Info Form
- private void buttonReportsInfo_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- this.Hide();
- Form FormOpenGuide = new GuideReportsForm(VA, profileTitle, icon);
- FormOpenGuide.ShowDialog();
- this.Show();
- }
- // Open Sensor Diagnostics Info Form
- private void buttonDiagInfo_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- this.Hide();
- Form FormOpenGuide = new GuideDiagnosticsForm(VA, profileTitle, icon);
- FormOpenGuide.ShowDialog();
- this.Show();
- }
- // Open Sensor Diagnostics Info Form
- private void buttonDiagUse_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- this.Hide();
- Form FormOpenGuide = new GuideDiagnosticsUseForm(VA, profileTitle, icon);
- FormOpenGuide.ShowDialog();
- this.Show();
- }
- // Open Weather Data Info Form
- private void buttonWeatherData_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- this.Hide();
- Form FormOpenGuide = new GuideWeatherDataForm(VA, profileTitle, icon);
- FormOpenGuide.ShowDialog();
- this.Show();
- }
- // Open Weather Options Info Form
- private void buttonWeatherOptions_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
- {
- this.Hide();
- Form FormOpenGuide = new GuideWeatherOptionsForm(VA, profileTitle, icon);
- FormOpenGuide.ShowDialog();
- this.Show();
- }
- // Final Exit Options Form Closing
- private void GuideForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END GUIDE FORM=================================================================
- //================================================BEGIN GUIDE SHAREDMEM FORM=================================================================
- public class GuideSharedMemForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public GuideSharedMemForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(20);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => GuideSharedMemForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "Setup AIDA64 Shared Memory Sensor Data";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // Guide Line 1
- Label labelInfoLine1 = new Label();
- labelInfoLine1.Text = "\nFor this AVCS Profile to access Shared Memory Sensor Data from the AIDA64 program, first open the main AIDA64 Preferences Menu, then select the option for External Applications on the left.";
- labelInfoLine1.Font = new Font(labelInfoLine1.Font.FontFamily, FontSizeM);
- labelInfoLine1.AutoSize = true;
- labelInfoLine1.TextAlign = ContentAlignment.MiddleLeft;
- labelInfoLine1.MinimumSize = new Size(750, 0);
- labelInfoLine1.MaximumSize = new Size(750, 0);
- this.Controls.Add(labelInfoLine1);
- // Guide Line 2 (with link)
- LinkLabel labelSharedMem = new LinkLabel();
- labelSharedMem.Text = "In the available sensors listed on the right, check the box next to those listed in the image shown here (if available on your PC) - these have command keywords already set, and some are used in AVCS Sensor Diagnostics commands."; // (culled for beta) See the AVCS Wiki for details on adding sensors not listed here.";
- labelSharedMem.LinkArea = new LinkArea(100, 4);
- labelSharedMem.Font = new Font(labelSharedMem.Font.FontFamily, FontSizeM);
- labelSharedMem.LinkColor = Color.FromArgb(64, 188, 255);
- labelSharedMem.AutoSize = true;
- labelSharedMem.TextAlign = ContentAlignment.MiddleLeft;
- labelSharedMem.MinimumSize = new Size(750, 0);
- labelSharedMem.MaximumSize = new Size(750, 0);
- ToolTip SharedMemTip = new ToolTip();
- string SharedMemLink = @"https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather-img1/";
- SharedMemTip.SetToolTip(labelSharedMem,"Click here to view image at: " + SharedMemLink);
- this.Controls.Add(labelSharedMem);
- labelSharedMem.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, SharedMemLink));
- // Guide Line 3
- Label labelInfoLine3 = new Label();
- labelInfoLine3.Text = "Finally, check the box at the top to 'Enable shared memory' and click OK.\n\nUse the button in the Sensor Options Menu to test for valid AIDA64 Shared Memory data, even before turning on active Monitoring. Test data will be automatically copied to the clipboard for manual review.\n\nAny number of case fans recognized by AIDA64 as 'Chassis fans' can be assigned a keyword such as 'Rear Case Fan(s)' or 'Intake Case Fan(s)'. Fans tied together in RPM such as dual or triple GPU fans are pointless to enable here, and users should only select one of any set tied together.";
- labelInfoLine3.Font = new Font(labelInfoLine3.Font.FontFamily, FontSizeM);
- labelInfoLine3.AutoSize = true;
- labelInfoLine3.TextAlign = ContentAlignment.MiddleLeft;
- labelInfoLine3.MinimumSize = new Size(750, 0);
- labelInfoLine3.MaximumSize = new Size(750, 0);
- this.Controls.Add(labelInfoLine3);
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Link and Credit to AIDA64/FinalWire
- LinkLabel labelFinalWireLink = new LinkLabel();
- Functions.addFinalWireLinkFooterLabel(VA, this, FontSizeS, labelFinalWireLink);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Final Exit Options Form Closing
- private void GuideSharedMemForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END GUIDE SHAREDMEM FORM=================================================================
- //================================================BEGIN GUIDE REPORTS FORM=================================================================
- public class GuideReportsForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public GuideReportsForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(20);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => GuideReportsForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "AVCS PC Sensor Reports Usage";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // CC License Link and Credit to AVCS Profiles
- LinkLabel labelReportsLink = new LinkLabel();
- labelReportsLink.Text = "\nAny sensor listed in the image shown here may be queried individually at any time, or read out as part of a report containing sets of sensors such as all primary CPU sensors, or GPU sensors, or even the entire system.";
- labelReportsLink.LinkArea = new LinkArea(38, 4);
- labelReportsLink.Font = new Font(labelReportsLink.Font.FontFamily, FontSizeM);
- labelReportsLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelReportsLink.AutoSize = true;
- labelReportsLink.TextAlign = ContentAlignment.MiddleLeft;
- labelReportsLink.MinimumSize = new Size(750, 0);
- labelReportsLink.MaximumSize = new Size(750, 0);
- ToolTip ReportsTip = new ToolTip();
- string ReportsLink = @"https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather-img1/";
- ReportsTip.SetToolTip(labelReportsLink,"Click here to view image at: " + ReportsLink);
- this.Controls.Add(labelReportsLink);
- labelReportsLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, ReportsLink));
- // CC License Link and Credit to AVCS Profiles
- Label labelReports = new Label();
- labelReports.Text = "These commands naturally were inspired by love of STTNG, and follow a 'higher is faster' connotation for the levels 5 through 1, with 1 being the most complete yet slowest and possibly least automated of all reports (or diagnostics, if using an AVCS-DHT1).\n\nRunning a Level 5 Report on the Graphics Card or the CPU may return only the top one or two most relevant values, whereas saying 'Run a Level 1 Report' will begin a very long speech listing each and every attached sensor and their last reported average value.\n\nAll sensor values are added to 10 rolling data points spanning back 30 seconds, averaged out over this time once every 15 seconds. This means any given set is reusing around 5 data points from the last average set, and I've found this to be most accurate.";
- labelReports.Font = new Font(labelReports.Font.FontFamily, FontSizeM);
- labelReports.AutoSize = true;
- labelReports.TextAlign = ContentAlignment.MiddleLeft;
- labelReports.MinimumSize = new Size(750, 0);
- labelReports.MaximumSize = new Size(750, 0);
- this.Controls.Add(labelReports);
- // Set up labelStopCommands
- Label labelStopCommands = new Label();
- labelStopCommands.Text = "Say 'Stop All Sensor Commands' to halt reports speech readouts anytime";
- labelStopCommands.Font = new Font(labelStopCommands.Font.FontFamily, FontSizeM, FontStyle.Bold);
- labelStopCommands.MinimumSize = new Size(750, 0);
- labelStopCommands.MaximumSize = new Size(750, 0);
- labelStopCommands.AutoSize = true;
- labelStopCommands.TextAlign = ContentAlignment.MiddleLeft;
- this.Controls.Add(labelStopCommands);
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Label
- Label labelFooter = new Label();
- Functions.addFooterLabel(this, FontSizeS, labelFooter);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Final Exit Options Form Closing
- private void GuideReportsForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END GUIDE REPORTS FORM=================================================================
- //================================================BEGIN GUIDE DIAG FORM=================================================================
- public class GuideDiagnosticsForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public GuideDiagnosticsForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(20);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => GuideDiagnosticsForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "AVCS PC Sensor Diagnostics";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // CC License Link and Credit to AVCS Profiles
- Label labelSnsDiag = new Label();
- labelSnsDiag.Text = "Diagnostics requires an attached Arduino or equivalent microcontroller with a temperature and humidity sensor sending a string of decimals over a USB connection in a format expected by AVCS.\n\nThis allows for 'delta-T over ambient' computer temperature sensor diagnostics using a simple algorithm I designed to flag atypical high or low sensor average values as compared to established baseline averages on file. Fan speeds are also factored in, as device temperatures are managed while fan speeds go up, working even harder to do so when filtered intakes become clogged over time.";
- labelSnsDiag.Font = new Font(labelSnsDiag.Font.FontFamily, FontSizeM);
- labelSnsDiag.AutoSize = true;
- labelSnsDiag.TextAlign = ContentAlignment.MiddleLeft;
- labelSnsDiag.MinimumSize = new Size(730, 0);
- labelSnsDiag.MaximumSize = new Size(730, 0);
- this.Controls.Add(labelSnsDiag);
- // Set up labelHeaderBaselines
- Label labelHeaderBase = new Label();
- labelHeaderBase.Text = "\nEstablishing Sensor Baselines - Low, Medium, High, Extreme ";
- labelHeaderBase.Font = new Font(labelHeaderBase.Font.FontFamily, FontSizeM, FontStyle.Bold);
- labelHeaderBase.AutoSize = true;
- labelHeaderBase.MinimumSize = new Size(730, 0);
- labelHeaderBase.MaximumSize = new Size(730, 0);
- labelHeaderBase.TextAlign = ContentAlignment.MiddleLeft;
- this.Controls.Add(labelHeaderBase);
- // CC License Link and Credit to AVCS Profiles
- Label labelBaselines = new Label();
- labelBaselines.Text = "Instructions will guide users to bring the computer into 4 states of operation from (mostly) idle to medium, high, and extreme states that best resemble the users own operation of the computer, either naturally or artificially via benchmarking tools. AVCS Diagnostics attempts to assume the current state based on most sensors reporting similarity to one of these 4 baseline sets of averages, and therefore make diagnostic notes of any sensors as compared to those averages.\n\nUsers may also set only 'LOW' and therefore get diagnostic comparisons against a baseline idle state only, no matter what the current operational state of the PC is assumed to be.";
- labelBaselines.Font = new Font(labelBaselines.Font.FontFamily, FontSizeM);
- labelBaselines.AutoSize = true;
- labelBaselines.TextAlign = ContentAlignment.MiddleLeft;
- labelBaselines.MinimumSize = new Size(730, 0);
- labelBaselines.MaximumSize = new Size(730, 0);
- this.Controls.Add(labelBaselines);
- // Set up labelHeaderDHT
- Label labelHeaderDHT = new Label();
- labelHeaderDHT.Text = "\nAVCS-DHT1 USB Room Temperature && Humidity Sensor ";
- labelHeaderDHT.Font = new Font(labelHeaderDHT.Font.FontFamily, FontSizeM, FontStyle.Bold);
- labelHeaderDHT.AutoSize = true;
- labelHeaderDHT.MinimumSize = new Size(730, 0);
- labelHeaderDHT.MaximumSize = new Size(730, 0);
- labelHeaderDHT.TextAlign = ContentAlignment.MiddleLeft;
- this.Controls.Add(labelHeaderDHT);
- // CC License Link and Credit to AVCS Profiles
- LinkLabel labelSnsDHT = new LinkLabel();
- labelSnsDHT.Text = "Without an external sensor to gauge the ambient environment outside the PC case, diagnostic commands and indoor temperature/humidity commands will not return values.\n\nCheck out my DIY instructions on how to make your own AVCS-DHT1 sensor for this profile using an Arduino or equivalent clone and a DHT11 sensor, or you can buy one designed && built by me.";
- labelSnsDHT.LinkArea = new LinkArea(180, 16);
- labelSnsDHT.Font = new Font(labelSnsDHT.Font.FontFamily, FontSizeM);
- labelSnsDHT.LinkColor = Color.FromArgb(64, 188, 255);
- labelSnsDHT.AutoSize = true;
- labelSnsDHT.TextAlign = ContentAlignment.MiddleLeft;
- labelSnsDHT.MinimumSize = new Size(730, 0);
- labelSnsDHT.MaximumSize = new Size(730, 0);
- ToolTip SnsDHTTip = new ToolTip();
- string SnsDHTLink = @"https://veterans-gaming.com/avcs-wiki/dht1-guide/";
- SnsDHTTip.SetToolTip(labelSnsDHT,"Click here for AVCS-DHT1 build guide: " + SnsDHTLink);
- this.Controls.Add(labelSnsDHT);
- labelSnsDHT.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, SnsDHTLink));
- // Set up buttonDHTLink
- Button buttonDHTLink = new Button();
- buttonDHTLink.Text = " Buy an AVCS-DHT1 ";
- buttonDHTLink.AutoSize = true;
- buttonDHTLink.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonDHTLink.Font = new Font(buttonDHTLink.Font.FontFamily, FontSizeM);
- buttonDHTLink.ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
- buttonDHTLink.BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- ToolTip StoreLinkTip = new ToolTip();
- string StoreLink = "https://veterans-gaming.com/store/product/13-avcs-dht1-usb-temperature-humidity-sensor/";
- StoreLinkTip.SetToolTip(buttonDHTLink, "Check out my AVCS-DHT1 on the VG Store: " + StoreLink);
- this.Controls.Add(buttonDHTLink);
- buttonDHTLink.MouseHover += new EventHandler((sender, e) => Functions.buttonsReverse_MouseHover(sender, e, ControlSpacing, FontSizeM));
- buttonDHTLink.MouseLeave += new EventHandler((sender, e) => Functions.buttonsReverse_MouseLeave(sender, e, ControlSpacing, FontSizeM));
- buttonDHTLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, StoreLink));
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeL, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Label
- Label labelFooter = new Label();
- Functions.addFooterLabel(this, FontSizeS, labelFooter);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Final Exit Options Form Closing
- private void GuideDiagnosticsForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END GUIDE DIAG FORM=================================================================
- //================================================BEGIN GUIDE DIAG USE FORM=================================================================
- public class GuideDiagnosticsUseForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public GuideDiagnosticsUseForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(20);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => GuideDiagnosticsUseForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "AVCS PC Sensor Diagnostic Usage";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // CC License Link and Credit to AVCS Profiles
- LinkLabel labelDiagUseLink = new LinkLabel();
- labelDiagUseLink.Text = "\nAs with Sensor Reports, any sensor listed in the image shown here may be queried individually at any time, or if using an AVCS-DHT1, read out as part of a diagnostic of recent averages containing sets of sensors such as all primary CPU sensors, or GPU sensors, or even the entire system.";
- labelDiagUseLink.LinkArea = new LinkArea(62, 4);
- labelDiagUseLink.Font = new Font(labelDiagUseLink.Font.FontFamily, FontSizeM);
- labelDiagUseLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelDiagUseLink.AutoSize = true;
- labelDiagUseLink.TextAlign = ContentAlignment.MiddleLeft;
- labelDiagUseLink.MinimumSize = new Size(750, 0);
- labelDiagUseLink.MaximumSize = new Size(750, 0);
- ToolTip DiagUseTip = new ToolTip();
- string DiagUseLink = @"https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather-img1/";
- DiagUseTip.SetToolTip(labelDiagUseLink,"Click here to view image at: " + DiagUseLink);
- this.Controls.Add(labelDiagUseLink);
- labelDiagUseLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, DiagUseLink));
- // CC License Link and Credit to AVCS Profiles
- Label labelDiagUse = new Label();
- labelDiagUse.Text = "Inspired by the diagnostics portrayed in STTNG, these commands follow a 'higher is faster' connotation for the levels 5 through 1, with 1 being the most complete yet slowest and possibly least automated.\n\nSaying 'Perform a Level 5 Diagnostic on the CPU' (or GPU, or full system) will first check if at least a quarter of the available sensors of that request are reading higher than basesline averages in the current assumed state of the PC. If all is well, it will simply report back saying, 'All systems are operational', else it will read out any sensors reading higher than average.\n\nRunning a Level 4 Diagnostic will list any/all of the available sensors of that request reporting higher than basesline averages in the current assumed state. The Level 3 will report any high OR low, and Level 2 will report every sensor in the requested set (or entire system) starting with any reading high, then those reading standard, then any reading low, in a very long Text-to-Speech return. Level 1 is the same as 2, but for each level, and prompting users to simulate low through extreme PC uses states.\n\nAll PC sensor values are added to 10 rolling data points spanning back 30 seconds, averaged out over this time once every 15 seconds, with new AVCS-DHT1 sensor data twice a minute. This means any given set is reusing 5 data points from the last average set, as I have found this to be most accurate.";
- labelDiagUse.Font = new Font(labelDiagUse.Font.FontFamily, FontSizeM);
- labelDiagUse.AutoSize = true;
- labelDiagUse.TextAlign = ContentAlignment.MiddleLeft;
- labelDiagUse.MinimumSize = new Size(750, 0);
- labelDiagUse.MaximumSize = new Size(750, 0);
- this.Controls.Add(labelDiagUse);
- // Set up labelStopCommands
- Label labelStopCommands = new Label();
- labelStopCommands.Text = "Say 'Stop All Sensor Commands' to halt diagnostic speech readouts anytime";
- labelStopCommands.Font = new Font(labelStopCommands.Font.FontFamily, FontSizeM, FontStyle.Bold);
- labelStopCommands.MinimumSize = new Size(750, 0);
- labelStopCommands.MaximumSize = new Size(750, 0);
- labelStopCommands.AutoSize = true;
- labelStopCommands.TextAlign = ContentAlignment.MiddleLeft;
- this.Controls.Add(labelStopCommands);
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Label
- Label labelFooter = new Label();
- Functions.addFooterLabel(this, FontSizeS, labelFooter);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Final Exit Options Form Closing
- private void GuideDiagnosticsUseForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END GUIDE DIAG USE FORM=================================================================
- //================================================BEGIN GUIDE OWM DATA FORM=================================================================
- public class GuideWeatherDataForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public GuideWeatherDataForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(20);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => GuideWeatherDataForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "Weather Data provided by OpenWeather (TM)";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // CC License Link and Credit to AVCS Profiles
- Label labelOwmInfo = new Label();
- //labelOwmInfo.Text = "\nSo many DIY electronics and programming projects use Open Weather Maps to get accurate local weather data for free using their API. It is very simply a website URL that is created with the requests in-line so that it resolves to a flat webpage of text containing the data requested, such as current local weather info including temperature, humidity, wind speed and direction, and even forecasts.\n\nThis project has a registered key that allows AVCS access to make API calls for all users of this profile. Existing users of Open Weather Map may enter their own user key if they wish, and this key will be saved to the AVCS config file for this profile, loaded and used when Weather Monitoring is on.\n\nWeather data is set to VoiceAttack variables every 15 minutes by default when Monitoring is on, for use in Text-to-Speech replies, with daily weather forecast data saved to file for access between checks. This allows for swift replies by monitoring weather information in the background and having it ready when asked.\n\nAccuracy of results may vary depending on the distance of local weather station(s) from your location.";
- labelOwmInfo.Text = "\nSo many DIY electronics and programming projects use Open Weather Maps to get accurate local weather data for free using their API. It is very simply a website URL that is created with the requests in-line so that it resolves to a flat webpage of text containing the data requested, such as current local weather info including temperature, humidity, wind speed and direction, and even forecasts.\n\nThis project has a registered key that allows AVCS access to make API calls for all users of this profile. Existing users of Open Weather Map may enter their own user key if they wish, and this key will be saved to the AVCS config file for this profile, unlocking additional choices in Weather Options.\n\nWeather data is set to VoiceAttack variables every 15 minutes by default when Monitoring is on, for use in Text-to-Speech replies, with daily weather forecast data saved to file for access between checks. This allows for swift replies by monitoring weather information in the background and having it ready when asked. Using a weather command when monitoring is off will be much slower.\n\nAccuracy of results may vary depending on the distance of local weather station(s) from your location.";
- labelOwmInfo.Font = new Font(labelOwmInfo.Font.FontFamily, FontSizeM);
- labelOwmInfo.AutoSize = true;
- labelOwmInfo.TextAlign = ContentAlignment.MiddleLeft;
- labelOwmInfo.MinimumSize = new Size(730, 0);
- labelOwmInfo.MaximumSize = new Size(730, 0);
- this.Controls.Add(labelOwmInfo);
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Link and Credit to Open Weather Map
- LinkLabel labelOwmLink = new LinkLabel();
- Functions.addOwmLinkFooterLabel(VA, this, FontSizeS, labelOwmLink);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Final Exit Guide Form Closing
- private void GuideWeatherDataForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END GUIDE OWM DATA FORM=================================================================
- //================================================BEGIN GUIDE OWM OPTIONS FORM=================================================================
- public class GuideWeatherOptionsForm : Form
- {
- // Initialize string variable for storing user input
- public string result = null;
- public GuideWeatherOptionsForm(dynamic VA, string profileTitle, Icon icon)
- {
- profileTitle = Functions.updateMenuTitle(VA, profileTitle);
- this.Text = profileTitle;
- if (icon != null)
- this.Icon = icon;
- this.FormBorderStyle = FormBorderStyle.FixedDialog;
- this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.StartPosition = FormStartPosition.CenterScreen;
- this.AutoSize = true;
- this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- this.MinimumSize = new Size(this.Width, this.Height);
- this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- this.Padding = new Padding(20);
- int FontSizeS = 8;
- int FontSize = 10;
- int FontSizeM = 12;
- int FontSizeL = 16;
- int FontSizeX = 24;
- int ControlSpacing = 15;
- this.FormClosing += new FormClosingEventHandler((sender, e) => GuideWeatherOptionsForm_FormClosing(sender, e, VA));
- // Set up labelHeader
- Label labelHeader = new Label();
- labelHeader.Text = "Setting Weather Options && Local City";
- labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
- labelHeader.AutoSize = true;
- labelHeader.TextAlign = ContentAlignment.MiddleCenter;
- this.Controls.Add(labelHeader);
- // Set up labelSpacer
- Label labelSpacerH = new Label();
- Functions.addLabelSpacer(this, 1, labelSpacerH);
- // Link Label for ISO 3166 Country Codes and User City info for OWM
- // Label labelOwmOptions = new Label();
- // labelOwmOptions.Text = "Local weather data from Open Weather Maps API can be queried and resolved by name for cities in the United States such as 'New York, NY, US' or abroad via city name and two-letter ISO 3166 international country code, such as 'London, GB' or 'Berlin, DE'.";
- // labelOwmOptions.Font = new Font(labelOwmOptions.Font.FontFamily, FontSizeM);
- // labelOwmOptions.AutoSize = true;
- // labelOwmOptions.TextAlign = ContentAlignment.MiddleLeft;
- // labelOwmOptions.MinimumSize = new Size(730, 0);
- // labelOwmOptions.MaximumSize = new Size(730, 0);
- // this.Controls.Add(labelOwmOptions);
- // Link Label for ISO 3166 Country Codes and User City info for OWM
- LinkLabel labelCountryCodesLink = new LinkLabel();
- labelCountryCodesLink.Text = "Local weather data from Open Weather Maps API can be queried and resolved by name for cities in the United States such as 'New York, NY, US' or abroad via city name and two-letter ISO 3166 international country code, such as 'London, GB' or 'Berlin, DE'.";
- labelCountryCodesLink.LinkArea = new LinkArea(180, 8);
- labelCountryCodesLink.Font = new Font(labelCountryCodesLink.Font.FontFamily, FontSizeM);
- labelCountryCodesLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelCountryCodesLink.AutoSize = true;
- labelCountryCodesLink.TextAlign = ContentAlignment.MiddleLeft;
- labelCountryCodesLink.MinimumSize = new Size(730, 0);
- labelCountryCodesLink.MaximumSize = new Size(730, 0);
- ToolTip CountryCodesLinkTip = new ToolTip();
- string CountryCodesLink = "https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes";
- CountryCodesLinkTip.SetToolTip(labelCountryCodesLink, CountryCodesLink);
- this.Controls.Add(labelCountryCodesLink);
- labelCountryCodesLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, CountryCodesLink));
- // CC License Link and Credit to AVCS Profiles
- Label labelOwmOptions = new Label();
- //labelOwmOptions.Text = "Users can also just right click anywhere on Google Maps to copy GPS coordinates to clipboard and paste them into the 'Save User City' input box. These do NOT need to be specific, anywhere near where you live is fine, but closer points may be more accurate based on nearby OWM stations.\n\nFor peace of mind for me (I use this profile too) and for you, this information is only saved to the VoiceAttack profile, and is never written to the AVCS config file. If the profile has a hiccup and forgets this saved variable, like importing an updated profile version, you'll simply need to set it up it again.\n\nIn the Weather Options Menu, choose Unit and Wind Speed values from metric or imperial, and how often new weather data is retrieved (default 15 minutes). These settings are saved to the AVCS config file, and will persist between different versions if I update this profile, you'll not need to set them again.";
- labelOwmOptions.Text = "Users can also just right click anywhere on Google Maps to copy GPS coordinates to clipboard and paste them into the 'Save User City' input box. These do NOT need to be specific, anywhere near where you live is fine, but closer points may be more accurate based on nearby OWM stations.\n\nNOTE OF CAUTION: There is little need to set GPS coordinates exactly where you live from Google Maps, and if the Weather Options menu or user config file can become visible in a live stream or recording, your saved setting may be visible to others. Don't dox yourself! Be smart and just pick coordinates from the map using a local airport or transit station servicing your entire city or town.\n\nIn the Weather Options Menu, choose Unit and Wind Speed values from metric or imperial, and how often new weather data is retrieved (default 15 minutes). These settings are saved to the AVCS config file, and will persist between different versions if I update this profile, you'll not need to set them again.";
- labelOwmOptions.Font = new Font(labelOwmOptions.Font.FontFamily, FontSizeM);
- labelOwmOptions.AutoSize = true;
- labelOwmOptions.TextAlign = ContentAlignment.MiddleLeft;
- labelOwmOptions.MinimumSize = new Size(730, 0);
- labelOwmOptions.MaximumSize = new Size(730, 0);
- this.Controls.Add(labelOwmOptions);
- //=========================== FOOTER =======================
- // Set up labelSpacer
- Label labelSpacerF = new Label();
- Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
- // Set up buttonBack
- Button buttonBack = new Button();
- Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
- // Footer Link and Credit to Open Weather Map
- LinkLabel labelOwmLink = new LinkLabel();
- Functions.addOwmLinkFooterLabel(VA, this, FontSizeS, labelOwmLink);
- // Show Options Form
- Functions.ResizeForm(this, ControlSpacing);
- Functions.ShowForm(this);
- }
- // Final Exit Options Form Closing
- private void GuideWeatherOptionsForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
- {
- //if (result != null)
- // VA.SetText("~~UserInput", result);
- }
- }
- //================================================END GUIDE OWM OPTIONS FORM=================================================================
- //================================================REQUIRED FUNCTIONS=================================================================
- public class Functions
- {
- // Function for resizing the form and positioning all the controls based on their width
- public static void ResizeForm(Form f, int ControlSpacing)
- {
- int MaxWidth = 0;
- Control MaxWidthControl = null;
- foreach (Control c in f.Controls)
- {
- if (c.Size.Width > MaxWidth)
- {
- MaxWidthControl = c;
- MaxWidth = c.Size.Width;
- }
- }
- MaxWidthControl.Location = new Point(f.Padding.Left, 0);
- // Set location of all other controls within the form
- Control PreviousControl = null;
- foreach (Control c in f.Controls)
- {
- c.Location = new Point(MaxWidth / 2 + f.Padding.Left - c.Size.Width / 2, (PreviousControl == null ? ControlSpacing : PreviousControl.Height + PreviousControl.Top + ControlSpacing));
- PreviousControl = c;
- }
- }
- // Function for bringing form into focus
- public static void ShowForm(Form f)
- {
- IntPtr myHandle = f.Handle;
- SetForegroundWindow(myHandle.ToInt32());
- }
- public static string updateMenuTitle(dynamic VA, string profileTitle)
- {
- string currentVersion = "0.90";
- if (VA.GetText("AVCS_SENS_Version") != null)
- currentVersion = VA.GetText("AVCS_SENS_Version");
- profileTitle = "AVCS SENS v" + currentVersion + " - Sensor Menu";
- if ((VA.GetBoolean("AVCS_SENS_VersionChecked") == true) && (VA.GetBoolean("AVCS_SENS_UPDATED") == true))
- profileTitle+= " (update available)";
- return profileTitle;
- }
- // Function to open config/baselines file at provided path
- public static void buttonOpenFile(dynamic VA, string filePath)
- {
- try
- {
- Process.Start(filePath);
- }
- catch
- {
- VA.WriteToLog("AVCS ERROR - Unable to find file at File Path:","red");
- VA.WriteToLog(filePath,"blank");
- }
- }
- // Begin/Stop Sensor Monitoring Button Event
- public static void buttonSnsMonitoring_Click(object sender, EventArgs e, dynamic VA, Form thisForm, int ControlSpacing, int FontSizeM, Button buttonOther1, Button buttonOther2, Button buttonOther3, Button buttonOther4, Button buttonOther5, Button buttonOther6, Form mainForm, Button buttonSnsMonitoring, bool resetMain)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
- buttonOther1.Enabled = false;
- buttonOther2.Enabled = false;
- buttonOther3.Enabled = false;
- buttonOther4.Enabled = false;
- buttonOther5.Enabled = false;
- buttonOther6.Enabled = false;
- if (VA.GetBoolean("AVCS_SENS_Logging") != true)
- {
- VA.SetBoolean("AVCS_SENS_Monitor_Startup", true);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- (sender as Button).Enabled = false;
- VA.Command.Execute("F_AIDA_MAIN");
- Thread.Sleep(500);
- while (VA.GetBoolean("AVCS_SENS_Monitor_Startup") == true)
- Thread.Sleep(50);
- if (VA.GetBoolean("AVCS_SENS_Monitoring") != true || VA.GetBoolean("AVCS_SENS_Logging") != true)
- {
- VA.SetBoolean("AVCS_SENS_Logging", false);
- VA.SetBoolean("AVCS_SENS_Monitoring", false);
- (sender as Button).Text = " Begin Sensor Monitoring ";
- (sender as Button).Enabled = true;
- (sender as Button).AutoSize = true;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(thisForm, ControlSpacing);
- if (resetMain)
- {
- //Also change button on Main Menu form
- buttonSnsMonitoring.Text = " Begin Sensor Monitoring ";
- buttonSnsMonitoring.Enabled = true;
- buttonSnsMonitoring.AutoSize = true;
- buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- buttonSnsMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(mainForm, ControlSpacing);
- }
- }
- else
- {
- (sender as Button).Text = " Stop Sensor Monitoring ";
- (sender as Button).AutoSize = true;
- (sender as Button).Enabled = true;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(thisForm, ControlSpacing);
- if (resetMain)
- {
- //Also change button on Main Menu form
- buttonSnsMonitoring.Text = " Stop Sensor Monitoring ";
- buttonSnsMonitoring.AutoSize = true;
- buttonSnsMonitoring.Enabled = true;
- buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- buttonSnsMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(mainForm, ControlSpacing);
- }
- }
- }
- else
- {
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- (sender as Button).Enabled = false;
- VA.SetBoolean("AVCS_SENS_Logging", false);
- VA.SetBoolean("AVCS_SENS_Monitoring", false);
- Thread.Sleep(5000);
- (sender as Button).Text = " Begin Sensor Monitoring ";
- (sender as Button).AutoSize = true;
- (sender as Button).Enabled = true;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(thisForm, ControlSpacing);
- if (resetMain)
- {
- //Also change button on Main Menu form
- buttonSnsMonitoring.Text = " Begin Sensor Monitoring ";
- buttonSnsMonitoring.Enabled = true;
- buttonSnsMonitoring.AutoSize = true;
- buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- buttonSnsMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(mainForm, ControlSpacing);
- }
- }
- buttonOther1.Enabled = true;
- buttonOther2.Enabled = true;
- buttonOther3.Enabled = true;
- buttonOther4.Enabled = true;
- buttonOther5.Enabled = true;
- buttonOther6.Enabled = true;
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
- }
- }
- // Begin/Stop Weather Monitoring Button Event
- public static void buttonOwmMonitoring_Click(object sender, EventArgs e, dynamic VA, Form thisForm, int ControlSpacing, int FontSizeM, Button buttonOther1, Button buttonOther2, Button buttonOther3, Button buttonOther4, Button buttonOther5, Button buttonOther6, Button buttonOther7, Form mainForm, Button buttonOwmMonitoring, bool resetMain)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
- buttonOther1.Enabled = false;
- buttonOther2.Enabled = false;
- buttonOther3.Enabled = false;
- buttonOther4.Enabled = false;
- buttonOther5.Enabled = false;
- buttonOther6.Enabled = false;
- buttonOther7.Enabled = false;
- if (VA.GetBoolean("AVCS_OWM_Monitoring") != true)
- {
- VA.SetBoolean("AVCS_OWM_Monitor_Startup", true);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- (sender as Button).Enabled = false;
- VA.Command.Execute("F_OWM_MAIN");
- Thread.Sleep(500);
- while (VA.GetBoolean("AVCS_OWM_Monitor_Startup") == true)
- Thread.Sleep(50);
- if (VA.GetBoolean("AVCS_OWM_Monitoring") != true)
- {
- VA.SetBoolean("AVCS_OWM_Monitoring", false);
- (sender as Button).Text = " Begin Weather Monitoring ";
- (sender as Button).Enabled = true;
- (sender as Button).AutoSize = true;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(thisForm, ControlSpacing);
- if (resetMain)
- {
- //Also change button on Main Menu form
- buttonOwmMonitoring.Text = " Begin Weather Monitoring ";
- buttonOwmMonitoring.Enabled = true;
- buttonOwmMonitoring.AutoSize = true;
- buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- buttonOwmMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(mainForm, ControlSpacing);
- }
- }
- else
- {
- (sender as Button).Text = " Stop Weather Monitoring ";
- (sender as Button).AutoSize = true;
- (sender as Button).Enabled = true;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(thisForm, ControlSpacing);
- if (resetMain)
- {
- //Also change button on Main Menu form
- buttonOwmMonitoring.Text = " Stop Weather Monitoring ";
- buttonOwmMonitoring.AutoSize = true;
- buttonOwmMonitoring.Enabled = true;
- buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- buttonOwmMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(mainForm, ControlSpacing);
- // Add tooltip to Interval Option Button
- ToolTip SetCallsAPITip = new ToolTip();
- SetCallsAPITip.SetToolTip(buttonOther5,"(restart monitor to apply changes)");
- }
- }
- }
- else
- {
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
- (sender as Button).Enabled = false;
- VA.SetBoolean("AVCS_OWM_Monitoring", false);
- Thread.Sleep(5000);
- (sender as Button).Text = " Begin Weather Monitoring ";
- (sender as Button).AutoSize = true;
- (sender as Button).Enabled = true;
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(thisForm, ControlSpacing);
- if (resetMain)
- {
- //Also change button on Main Menu form
- buttonOwmMonitoring.Text = " Begin Weather Monitoring ";
- buttonOwmMonitoring.Enabled = true;
- buttonOwmMonitoring.AutoSize = true;
- buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- buttonOwmMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
- Functions.ResizeForm(mainForm, ControlSpacing);
- }
- }
- buttonOther1.Enabled = true;
- buttonOther2.Enabled = true;
- buttonOther3.Enabled = true;
- buttonOther4.Enabled = true;
- buttonOther5.Enabled = true;
- buttonOther6.Enabled = true;
- buttonOther7.Enabled = true;
- VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
- }
- }
- // Function to Add a Custom Spacer Label to Menu Form Pages
- public static void addLabelSpacer(Form thisForm, int thisFontSize, Label labelSpacer)
- {
- labelSpacer.Text = " ";
- labelSpacer.Font = new Font(labelSpacer.Font.FontFamily, thisFontSize);
- labelSpacer.AutoSize = true;
- labelSpacer.TextAlign = ContentAlignment.MiddleCenter;
- thisForm.Controls.Add(labelSpacer);
- }
- // Function to Add a Back Button to Menu Form Pages
- public static void addFooterLabel(Form thisForm, int FontSizeS, Label labelFooter)
- {
- labelFooter.Text = "Say 'Open the Sensor Command Reference' to view commands\nSay 'Open the Sensor Menu' to return here anytime!";
- labelFooter.Font = new Font(labelFooter.Font.FontFamily, FontSizeS);
- labelFooter.AutoSize = true;
- labelFooter.TextAlign = ContentAlignment.MiddleCenter;
- thisForm.Controls.Add(labelFooter);
- }
- // Function to Add a AIDA64/FinalWire Footer to Menu Form Pages
- public static void addFinalWireLinkFooterLabel(dynamic VA, Form thisForm, int FontSizeS, LinkLabel labelAidaLink)
- {
- // Credits Link to AIDA64 / FinalWire Ltd.
- labelAidaLink.Text = "(AIDA64 and OpenWeather are not affiliated with AVCS)\nAIDA64 is a Registered Trademark of FinalWire Ltd. ©2010-" + DateTime.Now.ToString("yyyy").Trim() + " All rights reserved.";
- labelAidaLink.LinkArea = new LinkArea(90, 14);
- labelAidaLink.Font = new Font(labelAidaLink.Font.FontFamily, FontSizeS);
- labelAidaLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelAidaLink.AutoSize = true;
- labelAidaLink.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip AidaLinkTip = new ToolTip();
- string AidaLink = "https://www.aida64.com/";
- AidaLinkTip.SetToolTip(labelAidaLink, AidaLink);
- thisForm.Controls.Add(labelAidaLink);
- labelAidaLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, AidaLink));
- }
- // Function to Add a AIDA64/FinalWire Footer to Menu Form Pages
- public static void addFinalWireLinkFooterLabel2(dynamic VA, Form thisForm, int FontSizeS, LinkLabel labelAidaLink)
- {
- // Credits Link to AIDA64 / FinalWire Ltd.
- labelAidaLink.Text = "AIDA64 is a Registered Trademark of FinalWire Ltd. ©2010-" + DateTime.Now.ToString("yyyy").Trim() + " All rights reserved.";
- labelAidaLink.LinkArea = new LinkArea(36, 14);
- labelAidaLink.Font = new Font(labelAidaLink.Font.FontFamily, FontSizeS);
- labelAidaLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelAidaLink.AutoSize = true;
- labelAidaLink.TextAlign = ContentAlignment.MiddleCenter;
- ToolTip AidaLinkTip = new ToolTip();
- string AidaLink = "https://www.aida64.com/";
- AidaLinkTip.SetToolTip(labelAidaLink, AidaLink);
- thisForm.Controls.Add(labelAidaLink);
- labelAidaLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, AidaLink));
- }
- // Function to Add a OpenWeather Footer Label to Menu Form Pages
- public static void addOwmLinkFooterLabel(dynamic VA, Form thisForm, int FontSizeS, LinkLabel labelOwmLink)
- {
- labelOwmLink.Text = "(AIDA64 and OpenWeather are not affiliated with AVCS)\nWeather data provided by OpenWeather (TM) via CC BY-SA 4.0";
- labelOwmLink.LinkArea = new LinkArea(79, 11);
- labelOwmLink.Font = new Font(labelOwmLink.Font.FontFamily, FontSizeS);
- labelOwmLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelOwmLink.AutoSize = true;
- labelOwmLink.TextAlign = ContentAlignment.MiddleCenter;
- string OwmLink = "https://openweathermap.org/";
- ToolTip OwmLinkTip = new ToolTip();
- OwmLinkTip.SetToolTip(labelOwmLink, OwmLink);
- thisForm.Controls.Add(labelOwmLink);
- labelOwmLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, OwmLink));
- }
- // Function to Add a OpenWeather Footer Label to Menu Form Pages
- public static void addOwmLinkFooterLabel2(dynamic VA, Form thisForm, int FontSizeS, LinkLabel labelOwmLink)
- {
- labelOwmLink.Text = "Weather data provided by OpenWeather (TM) via CC BY-SA 4.0";
- labelOwmLink.LinkArea = new LinkArea(25, 11);
- labelOwmLink.Font = new Font(labelOwmLink.Font.FontFamily, FontSizeS);
- labelOwmLink.LinkColor = Color.FromArgb(64, 188, 255);
- labelOwmLink.AutoSize = true;
- labelOwmLink.TextAlign = ContentAlignment.MiddleCenter;
- string OwmLink = "https://openweathermap.org/";
- ToolTip OwmLinkTip = new ToolTip();
- OwmLinkTip.SetToolTip(labelOwmLink, OwmLink);
- thisForm.Controls.Add(labelOwmLink);
- labelOwmLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, OwmLink));
- }
- // Function to Add a Back Button to Menu Form Pages
- public static void addBackButton(Form thisForm, int ControlSpacing, int FontSizeM, Button buttonBack)
- {
- buttonBack.Text = " BACK ";
- buttonBack.AutoSize = true;
- buttonBack.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- buttonBack.Font = new Font(buttonBack.Font.FontFamily, FontSizeM);
- buttonBack.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- thisForm.Controls.Add(buttonBack);
- buttonBack.MouseHover += new EventHandler((sender, e) => Functions.buttonBack_MouseHover(sender, e, thisForm, ControlSpacing, FontSizeM));
- buttonBack.MouseLeave += new EventHandler((sender, e) => Functions.buttonBack_MouseLeave(sender, e, thisForm, ControlSpacing, FontSizeM));
- buttonBack.Click += new EventHandler((sender, e) => Functions.buttonBack_Click(sender, e, thisForm));
- thisForm.CancelButton = buttonBack;
- }
- // Function run when buttonBack is clicked
- public static void buttonBack_Click(object sender, EventArgs e, Form thisForm)
- {
- thisForm.Close();
- }
- // buttonBack_MouseHover(sender, e, this, ControlSpacing, FontSizeM,
- // Functions to recolor AVCS Menu 'Back' buttons and button text on Mouse Hover events
- public static void buttonBack_MouseHover(object sender, EventArgs e, Form thisForm, int ControlSpacing, int FontSizeM)
- {
- (sender as Button).Text = " ← ← ← ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(thisForm, ControlSpacing);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(30, 30, 30);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- }
- public static void buttonBack_MouseLeave(object sender, EventArgs e, Form thisForm, int ControlSpacing, int FontSizeM)
- {
- (sender as Button).Text = " BACK ";
- (sender as Button).AutoSize = true;
- (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
- (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
- Functions.ResizeForm(thisForm, ControlSpacing);
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- }
- // Functions to recolor AVCS Menu buttons and button text on Mouse Hover events
- public static void buttons_MouseHover(object sender, EventArgs e, int ControlSpacing, int FontSize)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- }
- public static void buttons_MouseLeave(object sender, EventArgs e, int ControlSpacing, int FontSize)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- }
- // Reverse Color Functions to recolor Coffee button and button text on Mouse Hover events
- public static void buttonsReverse_MouseHover(object sender, EventArgs e, int ControlSpacing, int FontSize)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
- }
- public static void buttonsReverse_MouseLeave(object sender, EventArgs e, int ControlSpacing, int FontSize)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
- }
- // Functions to recolor AVCS Sensors Monitor Start/Stop button and button text on Mouse Hover events
- public static void buttonsSnsMonitoring_MouseHover(object sender, EventArgs e, dynamic VA)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- }
- }
- public static void buttonsSnsMonitoring_MouseLeave(object sender, EventArgs e, dynamic VA)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- }
- }
- // Functions to recolor AVCS Weather Monitor Start/Stop button and button text on Mouse Hover events
- public static void buttonsOwmMonitoring_MouseHover(object sender, EventArgs e, dynamic VA)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
- }
- }
- public static void buttonsOwmMonitoring_MouseLeave(object sender, EventArgs e, dynamic VA)
- {
- if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
- {
- (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
- (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
- }
- }
- // Function to open URL link - thisLink string must be URL encoded, replace {SPACE} with %20 or +
- public static void labelLink_LinkClicked(object sender, EventArgs e, dynamic VA, string thisLink)
- {
- try
- {
- if (visitLink(thisLink) != true)
- throw new Exception();
- }
- catch (Exception ex )
- {
- VA.WriteToLog("AVCS ERROR: Unable to open link:", "red");
- VA.WriteToLog(thisLink, "red");
- }
- }
- public static bool visitLink(string thisLink)
- {
- try
- {
- // Open URL with default web browser
- System.Diagnostics.Process.Start(thisLink);
- return true;
- }
- catch (Exception ex )
- {
- //just let it fail now... don't catch shit
- return false;
- }
- }
- // Function to load user settings from config file into dec/int/txt/bool VA variables
- public static void loadUserConfig(dynamic VA)
- {
- if ((VA.GetText("~avcs_sens_user_settings") != null) && (VA.GetText("~avcs_sens_user_settings") != ""))
- {
- string settingName = "";
- string settingValue = "";
- string[] configFile = VA.GetText("~avcs_sens_user_settings").Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
- foreach (string userSetting in configFile)
- {
- string[] thisSetting = userSetting.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
- settingName = thisSetting[0];
- settingValue = thisSetting[1];
- if ((isNumeric(settingValue)) & (settingValue.Contains(".") || settingValue.Contains(",")))
- {
- try
- {
- decimal decimalValue;
- decimal.TryParse(settingValue, out decimalValue);
- VA.SetDecimal(settingName, decimalValue);
- }
- catch
- {
- //VA.WriteToLog("AVCS ERROR: failed to load decimal setting " + settingName, "red");
- }
- }
- else if (isNumeric(settingValue))
- {
- try
- {
- int integerValue;
- int.TryParse(settingValue, out integerValue);
- VA.SetInt(settingName, integerValue);
- }
- catch
- {
- //VA.WriteToLog("AVCS ERROR: failed to load integer setting " + settingName, "red");
- }
- }
- else if (settingValue.ToLower() == "true")
- {
- VA.SetBoolean(settingName, true);
- }
- else if (settingValue.ToLower() == "false")
- {
- VA.SetBoolean(settingName, false);
- }
- else
- {
- VA.SetText(settingName, settingValue);
- }
- }
- }
- if (VA.GetText("AVCS_MENU_SetUpdateChecks") == null)
- {
- try
- {
- VA.SetText("AVCS_MENU_SetUpdateChecks", new System.Net.WebClient().DownloadString(@"https://veterans-gaming.com/semlerpdx-avcs/profiles/avcs_sens_updater_list.htm/"));
- }
- catch
- {
- VA.SetText("AVCS_MENU_SetUpdateChecks", " Checking Updates... , Check for Update ");
- }
- }
- }
- // Function to mimic a standard VB method familiar to me
- public static bool isNumeric(string checkNum)
- {
- decimal checkedNum;
- return (decimal.TryParse(checkNum, out checkedNum));
- }
- // External function for bringing window into focus using its handle
- [DllImport("User32.dll")]
- public static extern Int32 SetForegroundWindow(int hWnd);
- }
Add Comment
Please, Sign In to add comment