SemlerPDX

AVCS SENS MENU GUI MAIN-v0.98 Windows Forms Profile Menu Inline Function in C# for VoiceAttack

Jun 14th, 2022
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 214.90 KB | None | 0 0
  1. //AVCS Main Menu GUI-v0.98
  2. //'Sensor Menu' for AIDA64 and Open Weather Maps VoiceAttack profile
  3. // by SemlerPDX Mar2022 (see credits in menu)
  4. // VETERANS-GAMING.COM
  5.  
  6. using System;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Diagnostics;
  10. using System.Globalization;
  11. using System.Runtime.InteropServices;
  12. using System.Windows.Forms;
  13. using System.Collections.Generic;
  14. using System.ComponentModel;
  15. using System.Net;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Threading;
  19. using System.Threading.Tasks;
  20. using System.Windows.Forms;
  21.  
  22.  
  23. public class VAInline
  24. {
  25.     public Icon icon;
  26.     public bool pressedCancel = false;
  27.     public string profileTitle = "AVCS SENS - Sensors Menu";
  28.     [STAThread]
  29.     public void main()
  30.     {
  31.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  32.         try
  33.         {
  34.             if (VA.GetText("AVCS_ICON_PATH") != null)
  35.             {
  36.                 icon = Icon.ExtractAssociatedIcon(VA.ParseTokens("{TXT:AVCS_ICON_PATH:}"));
  37.             }
  38.             else
  39.             {
  40.                 VA.SetText("AVCS_ICON_PATH", VA.ParseTokens("{VA_DIR}")+@"\voiceattack.ico");
  41.                 icon = Icon.ExtractAssociatedIcon(VA.ParseTokens("{TXT:AVCS_ICON_PATH:}"));
  42.             }
  43.         }
  44.         catch
  45.         {
  46.             icon = null;
  47.         }
  48.        
  49.         // Welcome New Users and teach them about this Main Sensor Menu, how to return to it, etc.
  50.         if (VA.GetBoolean("AVCS_SENS_RETURNING_USER") != true)
  51.             MessageBox.Show("Thank you for checking out my VoiceAttack profile!"+
  52.                         "\n\nOn first-time use, the main Sensor Menu will open,"+
  53.                         "\nso you can review and set options before trying to use"+
  54.                         "\ncommands which require setup, like local weather."+
  55.                         "\n\nYou may exit and return at a later time, too."+
  56.                         "\n(this pop-up only appears once)"+
  57.                         "\n\nSay 'Open the Sensor Menu' anytime to change profile settings."+
  58.                         "\n\nCheers!"+
  59.                         "\n  -SemlerPDX",
  60.                         profileTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
  61.         VA.SetBoolean("AVCS_SENS_RETURNING_USER", true);
  62.        
  63.         //Load User Settings from Config File & Check for Updates (if user's update setting allows)
  64.         Functions.loadUserConfig(VA);
  65.         if (VA.GetBoolean("AVCS_SENS_VersionChecked") != true)
  66.         {
  67.             if (VA.GetInt("AVCS_SENS_UPDATES") != 3)
  68.                 VA.Command.Execute("F_SENS_UPDATE", true);
  69.         }
  70.         //Credits to Exergist for his work creating a tutorial example inline function for VA using Windows Forms!
  71.         // Please check out the post: "Alternate 'Get User Input' Method (buttons!)" on the VoiceAttack forums if you're interested
  72.        
  73.         //Special Global Bool to communicate to SFS that Key was cleared
  74.         //Will tell SFS to delete Key from User Config when Menu closes (after saving other items)
  75.         VA.SetBoolean("AVCS_SENS_ClearKeyNotPressed", true);
  76.        
  77.         VA.ResetStopFlag();
  78.         // Enable (operating system) visual styles for the application
  79.         Application.EnableVisualStyles();
  80.         // Create an instance of my MainMenuForm (while passing the dynamic VA for use by the form) and an associated message loop
  81.         Application.Run(new MainMenuForm(VA, profileTitle, icon));
  82.     }
  83. }
  84.  
  85.  
  86. //================================================BEGIN MAIN OPTIONS=================================================================
  87. public class MainMenuForm : Form
  88. {
  89.     // Initialize string variable for storing user input
  90.     public string result = null;
  91.    
  92.     public MainMenuForm(dynamic VA, string profileTitle, Icon icon)
  93.     {
  94.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  95.         this.Text = profileTitle;
  96.         if (icon != null)
  97.             this.Icon = icon;
  98.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  99.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  100.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  101.         this.MaximizeBox = false;
  102.         this.MinimizeBox = false;
  103.         this.StartPosition = FormStartPosition.CenterScreen;
  104.         this.AutoSize = true;
  105.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  106.         this.MinimumSize = new Size(this.Width, this.Height);
  107.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  108.         this.Padding = new Padding(10);
  109.         int FontSizeS = 8;
  110.         int FontSize = 10;
  111.         int FontSizeM = 12;
  112.         int FontSizeL = 16;
  113.         int FontSizeX = 24;
  114.         int ControlSpacing = 15;
  115.         this.FormClosing += new FormClosingEventHandler((sender, e) => MainMenuForm_FormClosing(sender, e, VA));
  116.        
  117.         // Set up labelHeader
  118.         Label labelHeader = new Label();
  119.         labelHeader.Text = "AVCS Sensors Main Menu";
  120.         labelHeader.MinimumSize = new Size(300, 0);
  121.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  122.         labelHeader.AutoSize = true;
  123.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  124.         this.Controls.Add(labelHeader);
  125.        
  126.         // Set up labelSpacer
  127.         Label labelSpacerH = new Label();
  128.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  129.        
  130.        
  131.         // Set up buttonSnsMonitoring
  132.         Button buttonSnsMonitoring = new Button();
  133.         if (VA.GetBoolean("AVCS_SENS_Logging") != true && VA.GetBoolean("AVCS_SENS_Monitoring") != true)
  134.         {
  135.             buttonSnsMonitoring.Text = " Begin Sensor Monitoring ";
  136.         }
  137.         else
  138.         {
  139.             buttonSnsMonitoring.Text = " Stop Sensor Monitoring ";
  140.         }
  141.         buttonSnsMonitoring.AutoSize = true;
  142.         buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  143.         buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  144.         buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  145.         ToolTip SnsMonitoringTip = new ToolTip();
  146.         SnsMonitoringTip.SetToolTip(buttonSnsMonitoring,"(monitoring will continue even if this menu is closed)");
  147.         this.Controls.Add(buttonSnsMonitoring);
  148.         buttonSnsMonitoring.MouseHover += new EventHandler((sender, e) => Functions.buttonsSnsMonitoring_MouseHover(sender, e, VA));
  149.         buttonSnsMonitoring.MouseLeave += new EventHandler((sender, e) => Functions.buttonsSnsMonitoring_MouseLeave(sender, e, VA));
  150.        
  151.        
  152.         // Set up buttonOwmMonitoring
  153.         Button buttonOwmMonitoring = new Button();
  154.         if (VA.GetBoolean("AVCS_OWM_Monitoring") != true)
  155.         {
  156.             buttonOwmMonitoring.Text = " Begin Weather Monitoring ";
  157.         }
  158.         else
  159.         {
  160.             buttonOwmMonitoring.Text = " Stop Weather Monitoring ";
  161.         }
  162.         buttonOwmMonitoring.AutoSize = true;
  163.         buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  164.         buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  165.         buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  166.         ToolTip OwmMonitoringTip = new ToolTip();
  167.         OwmMonitoringTip.SetToolTip(buttonOwmMonitoring,"(monitoring will continue even if this menu is closed)");
  168.         this.Controls.Add(buttonOwmMonitoring);
  169.         buttonOwmMonitoring.MouseHover += new EventHandler((sender, e) => Functions.buttonsOwmMonitoring_MouseHover(sender, e, VA));
  170.         buttonOwmMonitoring.MouseLeave += new EventHandler((sender, e) => Functions.buttonsOwmMonitoring_MouseLeave(sender, e, VA));
  171.        
  172.        
  173.         // Set up buttonGuide
  174.         Button buttonGuide = new Button();
  175.         buttonGuide.Text = " USER GUIDES ";
  176.         buttonGuide.AutoSize = true;
  177.         buttonGuide.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  178.         buttonGuide.Font = new Font(buttonGuide.Font.FontFamily, FontSizeM);
  179.         buttonGuide.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  180.         this.Controls.Add(buttonGuide);
  181.         buttonGuide.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  182.         buttonGuide.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  183.         buttonGuide.Click += new EventHandler((sender, e) => buttonGuide_Click(sender, e, VA, profileTitle, icon));
  184.        
  185.         // Set up buttonOptionsMenu
  186.         Button buttonOptionsMenu = new Button();
  187.         buttonOptionsMenu.Text = "  OPTIONS  ";
  188.         buttonOptionsMenu.AutoSize = true;
  189.         buttonOptionsMenu.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  190.         buttonOptionsMenu.Font = new Font(buttonOptionsMenu.Font.FontFamily, FontSizeM);
  191.         buttonOptionsMenu.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  192.         this.Controls.Add(buttonOptionsMenu);
  193.         buttonOptionsMenu.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  194.         buttonOptionsMenu.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  195.         buttonOptionsMenu.Click += new EventHandler((sender, e) => buttonOptionsMenu_Click(sender, e, VA, profileTitle, icon, this, buttonSnsMonitoring, buttonOwmMonitoring));
  196.        
  197.        
  198.        
  199.         //===========================  FOOTER  =======================
  200.         // Set up labelSpacer
  201.         Label labelSpacerF = new Label();
  202.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  203.        
  204.         // Set up buttonCredits
  205.         Button buttonCredits = new Button();
  206.         buttonCredits.Text = " CREDITS ";
  207.         buttonCredits.AutoSize = true;
  208.         buttonCredits.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  209.         buttonCredits.Font = new Font(buttonCredits.Font.FontFamily, FontSizeM);
  210.         buttonCredits.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  211.         this.Controls.Add(buttonCredits);
  212.         buttonCredits.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  213.         buttonCredits.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  214.         buttonCredits.Click += new EventHandler((sender, e) => buttonCredits_Click(sender, e, VA, profileTitle, icon));
  215.        
  216.         // Set up buttonExit
  217.         Button buttonExit = new Button();
  218.         buttonExit.Text = "  EXIT  ";
  219.         buttonExit.AutoSize = true;
  220.         buttonExit.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  221.         buttonExit.Font = new Font(buttonExit.Font.FontFamily, FontSizeM);
  222.         buttonExit.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  223.         ToolTip buttonCloseTip = new ToolTip();
  224.         buttonCloseTip.SetToolTip(buttonExit,"(monitoring will continue even if this menu is closed)");
  225.         this.Controls.Add(buttonExit);
  226.         buttonExit.MouseHover += new EventHandler((sender, e) => buttonExit_MouseHover(sender, e, ControlSpacing, FontSizeM));
  227.         buttonExit.MouseLeave += new EventHandler((sender, e) => buttonExit_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  228.         buttonExit.Click += new EventHandler((sender, e) => buttonExit_Click(sender, e, VA));
  229.         this.CancelButton = buttonExit;
  230.        
  231.        
  232.         // Footer Label
  233.         Label labelFooter = new Label();
  234.         Functions.addFooterLabel(this, FontSizeS, labelFooter);
  235.        
  236.         // Event Handlers added last to include buttons temporarily disabled by these button clicks
  237.         buttonSnsMonitoring.Click += new EventHandler((sender, e) => Functions.buttonSnsMonitoring_Click(sender, e, VA, this, ControlSpacing, FontSizeM, buttonOwmMonitoring, buttonGuide, buttonOptionsMenu, buttonCredits, buttonExit, buttonExit, this, buttonSnsMonitoring, false));
  238.         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));
  239.        
  240.         // Show Options Form
  241.         Functions.ResizeForm(this, ControlSpacing);
  242.         Functions.ShowForm(this);
  243.     }
  244.    
  245.    
  246.     // Open User Guide Form
  247.     private void buttonGuide_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  248.     {
  249.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  250.         {
  251.             this.Hide();
  252.             Form FormOptions = new GuideForm(VA, profileTitle, icon);
  253.             FormOptions.ShowDialog();
  254.             this.Show();
  255.         }
  256.     }
  257.    
  258.     // Open Options Menu Form
  259.     private void buttonOptionsMenu_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonSnsMonitoring, Button buttonOwmMonitoring)
  260.     {
  261.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  262.         {
  263.             this.Hide();
  264.             Form FormOptions = new OptionsMenuForm(VA, profileTitle, icon, mainForm, buttonSnsMonitoring, buttonOwmMonitoring);
  265.             FormOptions.ShowDialog();
  266.             this.Show();
  267.         }
  268.     }
  269.    
  270.     // Open Credits Form
  271.     private void buttonCredits_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  272.     {
  273.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  274.         {
  275.             this.Hide();
  276.             Form FormOptions = new CreditsForm(VA, profileTitle, icon);
  277.             FormOptions.ShowDialog();
  278.             this.Show();
  279.         }
  280.     }
  281.    
  282.     // Functions to recolor buttons and button text on Mouse Hover events
  283.     private void buttonExit_MouseHover(object sender, EventArgs e, int ControlSpacing, int FontSizeM)
  284.     {
  285.         (sender as Button).Text = " GOODBYE! ";
  286.         (sender as Button).AutoSize = true;
  287.         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  288.         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  289.         Functions.ResizeForm(this, ControlSpacing);
  290.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(30, 30, 30);
  291.         (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  292.     }
  293.     private void buttonExit_MouseLeave(object sender, EventArgs e, int ControlSpacing, int FontSizeM)
  294.     {
  295.         (sender as Button).Text = "  EXIT  ";
  296.         (sender as Button).AutoSize = true;
  297.         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  298.         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  299.         Functions.ResizeForm(this, ControlSpacing);
  300.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  301.         (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  302.     }
  303.    
  304.    
  305.    
  306.     // Function run when buttonBack is clicked
  307.     private void buttonExit_Click(object sender, EventArgs e, dynamic VA)
  308.     {
  309.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  310.         {
  311.             this.Close();
  312.         }
  313.     }
  314.    
  315.    
  316.     //  Final Exit Options Form Closing
  317.     private void MainMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  318.     {
  319.         // Using modified "function" command from AVCS CORE profile, ambiguous Save File System (SFS) Save/Delete method here:
  320.         //Saving User Settings to User Config File (if changed, or null) - Hide menu now, can take a second or two...
  321.         this.Hide();
  322.         if (VA.GetText("AVCS_SENS_OWMCITY") == null)
  323.             VA.SetText("AVCS_SENS_OWMCITY", "New York, NY, US");
  324.         if (VA.GetText("AVCS_SENS_OWMKEY") == null)
  325.             VA.SetText("AVCS_SENS_OWMKEY", VA.GetText("AVCS_SENS_OWM_DefaultKey"));
  326.        
  327.         //SFS will accept these requests, and read config - only if values changed will a write occur
  328.         int saveRequests = 1;
  329.         VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_RETURNING_USER");
  330.         VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), "True");
  331.         saveRequests += 1;
  332.         VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_UPDATES");
  333.         VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{INT:AVCS_SENS_UPDATES:2}"));
  334.        
  335.         if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null && VA.GetText("AVCS_SENS_OWMKEY") == VA.GetText("AVCS_SENS_OWM_DefaultKey"))
  336.         {
  337.             if (VA.GetInt("AVCS_SENS_OWM_API_Calls") < 180)
  338.             {
  339.                 saveRequests += 1;
  340.                 VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
  341.                 VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_API_Calls");
  342.                 VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), "180");
  343.             }
  344.         }
  345.         else
  346.         {
  347.             saveRequests += 1;
  348.             VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_API_Calls");
  349.             VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{INT:AVCS_SENS_OWM_API_Calls:180}"));
  350.         }
  351.        
  352.        
  353.         saveRequests += 1;
  354.         VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_UnitMetric");
  355.         VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{BOOL:AVCS_SENS_OWM_UnitMetric:False}"));
  356.         saveRequests += 1;
  357.         VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_WindMetric");
  358.         VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{BOOL:AVCS_SENS_OWM_WindMetric:False}"));
  359.         saveRequests += 1;
  360.         VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWMCITY");
  361.         VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{TXT:AVCS_SENS_OWMCITY:New York, NY, US}"));
  362.        
  363.         if (VA.GetText("AVCS_SENS_OWMKEY") != null && VA.GetText("AVCS_SENS_OWMKEY") != VA.GetText("AVCS_SENS_OWM_DefaultKey"))
  364.         {
  365.             saveRequests += 1;
  366.             VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWMKEY");
  367.             VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.GetText("AVCS_SENS_OWMKEY"));
  368.             saveRequests += 1;
  369.             VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_FC_Calls");
  370.             VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), VA.ParseTokens("{INT:AVCS_SENS_OWM_FC_Calls:86400}"));
  371.         }
  372.         else
  373.         {
  374.             saveRequests += 1;
  375.             VA.SetInt("AVCS_SENS_OWM_FC_Calls", 86400);
  376.             VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWM_FC_Calls");
  377.             VA.SetText("AVCS_SENS_SAVED_value_" + saveRequests.ToString(), "86400");
  378.         }
  379.        
  380.         VA.SetInt("AVCS_SENS_SAVED_requests", saveRequests);
  381.        
  382.         // Ensure path is correct, this SFS can utilize any supplied path (therefore don't trust it was changed back)
  383.         VA.SetText("AVCS_SENS_SaveFilePath", VA.GetText("AVCS_SENS_UserConfigFilePath"));
  384.        
  385.         // This save system trigger below on 'bool=null' is simply a 'look and feel' thing, to minimize event log writes
  386.         /////  such as 'executing F_SFS_SAVE_CONFIG' when sometimes called twice on menu exit i.e. save + delete OWM key)
  387.         //Setting this bool null will signal already waiting 'F_SFS_SAVE_CONFIG' to write to config file (only if variables changed)
  388.         VA.SetBoolean("AVCS_MAIN_MENU_OPEN", null);
  389.        
  390.         //If it was stopped, launch it directly from here
  391.         if (VA.Command.Active("F_SFS_SAVE_CONFIG") != true)
  392.         {
  393.             VA.Command.Execute("F_SFS_SAVE_CONFIG", false);
  394.         }
  395.        
  396.         //Check for OWM Key Clear press, delete user key from file, reset to default key
  397.         if (VA.GetBoolean("AVCS_SENS_ClearKeyNotPressed") != true)
  398.         {
  399.             saveRequests = 0;
  400.             if (VA.GetText("AVCS_SENS_OWMKEY") == VA.GetText("AVCS_SENS_OWM_DefaultKey"))
  401.             {
  402.                 //Wait for save to finish, reset menu open bool, and then send delete request to SFS
  403.                 Thread.Sleep(500);
  404.                 VA.SetBoolean("AVCS_MAIN_MENU_OPEN", true);  //Now that SFS is running, can set true again to prevent menu re-open before delete
  405.                 if (VA.Command.Active("F_SFS_SAVE_CONFIG"))
  406.                 {
  407.                     while (VA.Command.Active("F_SFS_SAVE_CONFIG"))
  408.                         Thread.Sleep(50);
  409.                 }
  410.                 saveRequests += 1;
  411.                 VA.SetInt("AVCS_SENS_SAVED_requests", saveRequests);
  412.                 VA.SetText("AVCS_SENS_SAVED_name_" + saveRequests.ToString(), "AVCS_SENS_OWMKEY");
  413.                 VA.SetBoolean("AVCS_SENS_DELETE_saved", true);
  414.                
  415.                 VA.SetBoolean("AVCS_MAIN_MENU_OPEN", null);
  416.                 VA.Command.Execute("F_SFS_SAVE_CONFIG", false);
  417.                
  418.                 //Wait for delete to finish, deleted variables are cleared by SFS - reset key var to default key
  419.                 Thread.Sleep(500);
  420.                 VA.SetBoolean("AVCS_MAIN_MENU_OPEN", true);  //Now that SFS is running, can set true again to prevent menu re-open during delete
  421.                 if (VA.Command.Active("F_SFS_SAVE_CONFIG"))
  422.                 {
  423.                     while (VA.Command.Active("F_SFS_SAVE_CONFIG"))
  424.                         Thread.Sleep(50);
  425.                 }
  426.                 // Reset variable cleared by SFS Delete function to default key
  427.                 VA.SetText("AVCS_SENS_OWMKEY", VA.GetText("AVCS_SENS_OWM_DefaultKey"));
  428.             }
  429.         }
  430.         VA.SetBoolean("AVCS_SENS_ClearKeyNotPressed", null);
  431.         VA.SetBoolean("AVCS_MAIN_MENU_OPEN", null);
  432.     }
  433. }
  434.  
  435. //================================================END MAIN OPTIONS=================================================================
  436.  
  437.  
  438. //================================================BEGIN MAIN OPTIONS=================================================================
  439. public class OptionsMenuForm : Form
  440. {
  441.     // Initialize string variable for storing user input
  442.     public string result = null;
  443.    
  444.     public OptionsMenuForm(dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonSnsMonitoring, Button buttonOwmMonitoring)
  445.     {
  446.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  447.         this.Text = profileTitle;
  448.         if (icon != null)
  449.             this.Icon = icon;
  450.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  451.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  452.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  453.         this.MaximizeBox = false;
  454.         this.MinimizeBox = false;
  455.         this.StartPosition = FormStartPosition.CenterScreen;
  456.         this.AutoSize = true;
  457.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  458.         this.MinimumSize = new Size(this.Width, this.Height);
  459.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  460.         this.Padding = new Padding(10);
  461.         int FontSizeS = 8;
  462.         int FontSize = 10;
  463.         int FontSizeM = 12;
  464.         int FontSizeL = 16;
  465.         int FontSizeX = 24;
  466.         int ControlSpacing = 15;
  467.         this.FormClosing += new FormClosingEventHandler((sender, e) => OptionsMenuForm_FormClosing(sender, e, VA));
  468.        
  469.         // Set up labelHeader
  470.         Label labelHeader = new Label();
  471.         labelHeader.Text = "  AVCS Main Options Menu  ";
  472.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  473.         labelHeader.AutoSize = true;
  474.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  475.         this.Controls.Add(labelHeader);
  476.        
  477.         // Set up labelSpacer
  478.         Label labelSpacerH = new Label();
  479.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  480.        
  481.        
  482.        
  483.        
  484.         // Set up buttonSnsOptions
  485.         Button buttonSnsOptions = new Button();
  486.         buttonSnsOptions.Text = " Sensor Options ";
  487.         buttonSnsOptions.AutoSize = true;
  488.         buttonSnsOptions.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  489.         buttonSnsOptions.Font = new Font(buttonSnsOptions.Font.FontFamily, FontSizeM, FontStyle.Bold);
  490.         buttonSnsOptions.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  491.         this.Controls.Add(buttonSnsOptions);
  492.         buttonSnsOptions.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  493.         buttonSnsOptions.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  494.         buttonSnsOptions.Click += new EventHandler((sender, e) => buttonSnsOptions_Click(sender, e, VA, profileTitle, icon, mainForm, buttonSnsMonitoring));
  495.        
  496.         // Set up buttonOwmOptions
  497.         Button buttonOwmOptions = new Button();
  498.         buttonOwmOptions.Text = " Weather Options ";
  499.         buttonOwmOptions.AutoSize = true;
  500.         buttonOwmOptions.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  501.         buttonOwmOptions.Font = new Font(buttonOwmOptions.Font.FontFamily, FontSizeM, FontStyle.Bold);
  502.         buttonOwmOptions.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  503.         this.Controls.Add(buttonOwmOptions);
  504.         buttonOwmOptions.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  505.         buttonOwmOptions.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  506.         buttonOwmOptions.Click += new EventHandler((sender, e) => buttonOwmOptions_Click(sender, e, VA, profileTitle, icon, mainForm, buttonOwmMonitoring));
  507.        
  508.        
  509.         // Set up buttonProOptions
  510.         Button buttonProOptions = new Button();
  511.         buttonProOptions.Text = " Profile Options ";
  512.         buttonProOptions.AutoSize = true;
  513.         buttonProOptions.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  514.         buttonProOptions.Font = new Font(buttonProOptions.Font.FontFamily, FontSizeM, FontStyle.Bold);
  515.         buttonProOptions.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  516.         this.Controls.Add(buttonProOptions);
  517.         buttonProOptions.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  518.         buttonProOptions.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  519.         buttonProOptions.Click += new EventHandler((sender, e) => buttonProOptions_Click(sender, e, VA, profileTitle, icon));
  520.        
  521.        
  522.         //===========================  FOOTER  =======================
  523.         // Set up labelSpacer
  524.         Label labelSpacerF = new Label();
  525.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  526.        
  527.        
  528.         // Set up buttonBack
  529.         Button buttonBack = new Button();
  530.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  531.        
  532.        
  533.         // Footer Label
  534.         Label labelFooter = new Label();
  535.         Functions.addFooterLabel(this, FontSizeS, labelFooter);
  536.        
  537.        
  538.         // Show Options Form
  539.         Functions.ResizeForm(this, ControlSpacing);
  540.         Functions.ShowForm(this);
  541.     }
  542.    
  543.     // Open Sensor Options Form
  544.     private void buttonSnsOptions_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonSnsMonitoring)
  545.     {
  546.         this.Hide();
  547.         Form FormSensorOptions = new SensorOptionsMenuForm(VA, profileTitle, icon, mainForm, buttonSnsMonitoring);
  548.         FormSensorOptions.ShowDialog();
  549.         this.Show();
  550.     }
  551.    
  552.     // Open Weather Options Form
  553.     private void buttonOwmOptions_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonOwmMonitoring)
  554.     {
  555.         this.Hide();
  556.         Form FormOptions = new WeatherOptionsMenuForm(VA, profileTitle, icon, mainForm, buttonOwmMonitoring);
  557.         FormOptions.ShowDialog();
  558.         this.Show();
  559.     }
  560.    
  561.     // Open Weather Options Form
  562.     private void buttonProOptions_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  563.     {
  564.         this.Hide();
  565.         Form FormOptions = new ProfileConfigMenuForm(VA, profileTitle, icon);
  566.         FormOptions.ShowDialog();
  567.         this.Show();
  568.     }
  569.    
  570.     // Open Options Menu Form
  571.     private void buttonCredits_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  572.     {
  573.         this.Hide();
  574.         Form FormOptions = new CreditsForm(VA, profileTitle, icon);
  575.         FormOptions.ShowDialog();
  576.         this.Show();
  577.     }
  578.    
  579.    
  580.    
  581.     //  Final Exit Options Form Closing
  582.     private void OptionsMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  583.     {
  584.         //if (result != null)
  585.         //  VA.SetText("~~UserInput", result);
  586.     }
  587. }
  588.  
  589. //================================================END MAIN OPTIONS=================================================================
  590.  
  591. // --------Test Buttons need checks for already running systems, output some test data instead of running test?---------
  592. //================================================BEGIN SENSOR OPTIONS=================================================================
  593. public class SensorOptionsMenuForm : Form
  594. {
  595.     // Initialize string variable for storing user input
  596.     public string result = null;
  597.    
  598.     public SensorOptionsMenuForm(dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonSnsMonitoringMain)
  599.     {
  600.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  601.         this.Text = profileTitle;
  602.         if (icon != null)
  603.             this.Icon = icon;
  604.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  605.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  606.         this.BackColor = System.Drawing.Color.FromArgb(80, 80, 80);
  607.         this.MaximizeBox = false;
  608.         this.MinimizeBox = false;
  609.         this.StartPosition = FormStartPosition.CenterScreen;
  610.         this.AutoSize = true;
  611.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  612.         this.MinimumSize = new Size(this.Width, this.Height);
  613.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  614.         this.Padding = new Padding(10);
  615.         int FontSizeS = 8;
  616.         int FontSize = 10;
  617.         int FontSizeM = 12;
  618.         int FontSizeL = 16;
  619.         int FontSizeX = 24;
  620.         int ControlSpacing = 15;
  621.         this.FormClosing += new FormClosingEventHandler((sender, e) => SensorOptionsMenuForm_FormClosing(sender, e, VA));
  622.        
  623.         // Set up labelHeader
  624.         Label labelHeader = new Label();
  625.         labelHeader.Text = "Sensor Options Menu";
  626.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  627.         labelHeader.AutoSize = true;
  628.         labelHeader.MinimumSize = new Size(300, 0);
  629.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  630.         this.Controls.Add(labelHeader);
  631.        
  632.         // Set up labelSpacer
  633.         Label labelSpacerH = new Label();
  634.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  635.        
  636.        
  637.         // Set up buttonSnsMonitoring
  638.         Button buttonSnsMonitoring = new Button();
  639.         if (VA.GetBoolean("AVCS_SENS_Logging") != true && VA.GetBoolean("AVCS_SENS_Monitoring") != true)
  640.         {
  641.             buttonSnsMonitoring.Text = " Begin Sensor Monitoring ";
  642.         }
  643.         else
  644.         {
  645.             buttonSnsMonitoring.Text = " Stop Sensor Monitoring ";
  646.         }
  647.         buttonSnsMonitoring.AutoSize = true;
  648.         buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  649.         buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  650.         buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  651.         ToolTip SnsMonitoringTip = new ToolTip();
  652.         SnsMonitoringTip.SetToolTip(buttonSnsMonitoring,"(monitoring will continue even if this menu is closed)");
  653.         this.Controls.Add(buttonSnsMonitoring);
  654.         buttonSnsMonitoring.MouseHover += new EventHandler((sender, e) => Functions.buttonsSnsMonitoring_MouseHover(sender, e, VA));
  655.         buttonSnsMonitoring.MouseLeave += new EventHandler((sender, e) => Functions.buttonsSnsMonitoring_MouseLeave(sender, e, VA));
  656.        
  657.        
  658.        
  659.         // Set up buttonTestAIDA
  660.         Button buttonTestAIDA = new Button();
  661.         buttonTestAIDA.Text = " Test AIDA64 Shared Memory ";
  662.         buttonTestAIDA.AutoSize = true;
  663.         buttonTestAIDA.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  664.         buttonTestAIDA.Font = new Font(buttonTestAIDA.Font.FontFamily, FontSizeM);
  665.         buttonTestAIDA.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  666.         ToolTip TestAIDATip = new ToolTip();
  667.         TestAIDATip.SetToolTip(buttonTestAIDA,"(see user guide for help)");
  668.         this.Controls.Add(buttonTestAIDA);
  669.         buttonTestAIDA.MouseHover += new EventHandler((sender, e) => buttonsTester_MouseHover(sender, e, VA, ControlSpacing, FontSizeM));
  670.         buttonTestAIDA.MouseLeave += new EventHandler((sender, e) => buttonsTester_MouseLeave(sender, e, VA, ControlSpacing, FontSizeM));
  671.        
  672.         // Set up buttonTestDHT
  673.         Button buttonTestDHT = new Button();
  674.         buttonTestDHT.Text = " Test Arduino DHT11 Sensor ";
  675.         buttonTestDHT.AutoSize = true;
  676.         buttonTestDHT.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  677.         buttonTestDHT.Font = new Font(buttonTestDHT.Font.FontFamily, FontSizeM);
  678.         buttonTestDHT.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  679.         ToolTip TestDHTTip = new ToolTip();
  680.         TestDHTTip.SetToolTip(buttonTestDHT,"(see user guide for help)");
  681.         this.Controls.Add(buttonTestDHT);
  682.         buttonTestDHT.MouseHover += new EventHandler((sender, e) => buttonsTester_MouseHover(sender, e, VA, ControlSpacing, FontSizeM));
  683.         buttonTestDHT.MouseLeave += new EventHandler((sender, e) => buttonsTester_MouseLeave(sender, e, VA, ControlSpacing, FontSizeM));
  684.        
  685.        
  686.        
  687.         // Set up labelSpacer
  688.         Label labelSpacerT = new Label();
  689.         Functions.addLabelSpacer(this, 4, labelSpacerT);
  690.        
  691.         // Set up buttonNewBaselines
  692.         Button buttonNewBaselines = new Button();
  693.         buttonNewBaselines.Text = " Establish Baselines ";
  694.         buttonNewBaselines.AutoSize = true;
  695.         buttonNewBaselines.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  696.         buttonNewBaselines.Font = new Font(buttonNewBaselines.Font.FontFamily, FontSizeM);
  697.         buttonNewBaselines.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  698.         this.Controls.Add(buttonNewBaselines);
  699.         buttonNewBaselines.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  700.         buttonNewBaselines.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  701.         buttonNewBaselines.Click += new EventHandler((sender, e) => buttonNewBaselines_Click(sender, e, VA, profileTitle, icon));
  702.        
  703.         // Set up buttonOpenBaseline
  704.         Button buttonOpenBaseline = new Button();
  705.         buttonOpenBaseline.Text = " Open Baseline File ";
  706.         buttonOpenBaseline.AutoSize = true;
  707.         buttonOpenBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  708.         buttonOpenBaseline.Font = new Font(buttonOpenBaseline.Font.FontFamily, FontSizeM);
  709.         buttonOpenBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  710.         ToolTip OpenBaselineTip = new ToolTip();
  711.         OpenBaselineTip.SetToolTip(buttonOpenBaseline,"(manual editing is discouraged, careful!)");
  712.         this.Controls.Add(buttonOpenBaseline);
  713.         buttonOpenBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  714.         buttonOpenBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  715.         buttonOpenBaseline.Click += new EventHandler((sender, e) => buttonOpenBaseline_Click(sender, e, VA));
  716.        
  717.        
  718.         // Set up buttonOpenSensors
  719.         Button buttonOpenSensors = new Button();
  720.         buttonOpenSensors.Text = " Open Sensors File ";
  721.         buttonOpenSensors.AutoSize = true;
  722.         buttonOpenSensors.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  723.         buttonOpenSensors.Font = new Font(buttonOpenSensors.Font.FontFamily, FontSizeM);
  724.         buttonOpenSensors.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  725.         ToolTip OpenSensorsTip = new ToolTip();
  726.         OpenSensorsTip.SetToolTip(buttonOpenSensors,"(manual editing is discouraged, careful!)");
  727.         this.Controls.Add(buttonOpenSensors);
  728.         buttonOpenSensors.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  729.         buttonOpenSensors.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  730.         buttonOpenSensors.Click += new EventHandler((sender, e) => buttonOpenSensors_Click(sender, e, VA));
  731.        
  732.        
  733.        
  734.        
  735.        
  736.        
  737.         //===========================  FOOTER  =======================
  738.         // Set up labelSpacer
  739.         Label labelSpacerF = new Label();
  740.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  741.        
  742.        
  743.         // Set up buttonBack
  744.         Button buttonBack = new Button();
  745.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  746.        
  747.        
  748.         // Footer Label
  749.         Label labelFooter = new Label();
  750.         Functions.addFooterLabel(this, FontSizeS, labelFooter);
  751.        
  752.         // Set Button Event Handlers Last for Custom Disabling during Testing
  753.         buttonTestDHT.Click += new EventHandler((sender, e) => buttonTestDHT_Click(sender, e, VA, buttonTestAIDA, buttonSnsMonitoring, buttonNewBaselines, buttonOpenBaseline, buttonOpenSensors, buttonBack));
  754.         buttonTestAIDA.Click += new EventHandler((sender, e) => buttonTestAIDA_Click(sender, e, VA, buttonTestDHT, buttonSnsMonitoring, buttonNewBaselines, buttonOpenBaseline, buttonOpenSensors, buttonBack));
  755.         buttonSnsMonitoring.Click += new EventHandler((sender, e) => Functions.buttonSnsMonitoring_Click(sender, e, VA, this, ControlSpacing, FontSizeM, buttonTestDHT, buttonTestAIDA, buttonNewBaselines, buttonOpenBaseline, buttonOpenSensors, buttonBack, mainForm, buttonSnsMonitoringMain, true));
  756.        
  757.         // Show Options Form
  758.         Functions.ResizeForm(this, ControlSpacing);
  759.         Functions.ShowForm(this);
  760.     }
  761.    
  762.    
  763.     // Test AIDA SharedMem Button Event
  764.     private void buttonTestAIDA_Click(object sender, EventArgs e, dynamic VA, Button otherTestButton, Button buttonSnsMonitoring, Button buttonNewBaselines, Button buttonOpenBaseline, Button buttonOpenSensors, Button buttonBack)
  765.     {
  766.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  767.         {
  768.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
  769.             if (VA.GetBoolean("AVCS_SENS_Test_SharedMem") != true)
  770.             {
  771.                 buttonSnsMonitoring.Enabled = false;
  772.                 buttonNewBaselines.Enabled = false;
  773.                 buttonOpenBaseline.Enabled = false;
  774.                 buttonOpenSensors.Enabled = false;
  775.                 buttonBack.Enabled = false;
  776.                
  777.                 (sender as Button).Enabled = false;
  778.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  779.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  780.                 otherTestButton.Enabled = false;
  781.                 otherTestButton.BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  782.                 otherTestButton.ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  783.                 try
  784.                 {
  785.                     VA.SetBoolean("AVCS_SENS_Test_SharedMem", true);
  786.                     if (VA.GetBoolean("AVCS_SENS_Monitoring") != true)
  787.                     {
  788.                         VA.SetBoolean("AVCS_SENS_Test_OnlyTest", true);
  789.                         VA.Command.Execute("F_AIDA_MAIN", true);
  790.                     }
  791.                     else
  792.                     {
  793.                         while (VA.GetBoolean("AVCS_SENS_Test_SharedMem") == true)
  794.                             Thread.Sleep(100);
  795.                     }
  796.                 }
  797.                 catch
  798.                 {
  799.                     VA.WriteToLog("AVCS ERROR: function command F_AIDA_MAIN unavailable - test incomplete", "red");
  800.                 }
  801.                 finally
  802.                 {
  803.                     buttonSnsMonitoring.Enabled = true;
  804.                     buttonNewBaselines.Enabled = true;
  805.                     buttonOpenBaseline.Enabled = true;
  806.                     buttonOpenSensors.Enabled = true;
  807.                     buttonBack.Enabled = true;
  808.                    
  809.                     (sender as Button).Enabled = true;
  810.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  811.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  812.                     otherTestButton.Enabled = true;
  813.                     otherTestButton.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  814.                     otherTestButton.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  815.                     VA.SetBoolean("AVCS_SENS_Test_SharedMem", false);
  816.                     VA.SetBoolean("AVCS_SENS_Test_OnlyTest", false);
  817.                     if (VA.GetText("AVCS_SENS_Test_ReturnTTS") != null)
  818.                     {
  819.                         VA.SetText("AVCS_SENS_TTS_WILDCARD", VA.GetText("AVCS_SENS_Test_ReturnTTS"));
  820.                         VA.Command.Execute("F_SAY_TTS", false);
  821.                         VA.SetText("AVCS_SENS_Test_ReturnTTS", null);
  822.                     }
  823.                     if (VA.GetText("AVCS_SENS_SHAREDMEM_XML") != null)
  824.                         Clipboard.SetText(VA.GetText("AVCS_SENS_SHAREDMEM_XML"));
  825.                 }
  826.             }
  827.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
  828.         }
  829.     }
  830.    
  831.     // Test Arduino DHT Button Event
  832.     private void buttonTestDHT_Click(object sender, EventArgs e, dynamic VA, Button otherTestButton, Button buttonSnsMonitoring, Button buttonNewBaselines, Button buttonOpenBaseline, Button buttonOpenSensors, Button buttonBack)
  833.     {
  834.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  835.         {
  836.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
  837.             if (VA.GetBoolean("AVCS_SENS_SensorTestDHT1") != true)
  838.             {
  839.                 buttonSnsMonitoring.Enabled = false;
  840.                 buttonNewBaselines.Enabled = false;
  841.                 buttonOpenBaseline.Enabled = false;
  842.                 buttonOpenSensors.Enabled = false;
  843.                 buttonBack.Enabled = false;
  844.                
  845.                 (sender as Button).Enabled = false;
  846.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  847.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  848.                 otherTestButton.Enabled = false;
  849.                 otherTestButton.BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  850.                 otherTestButton.ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  851.                 try
  852.                 {
  853.                     if (VA.GetBoolean("AVCS_SENS_MonitoringDHT1") != true)
  854.                     {
  855.                         VA.SetBoolean("AVCS_SENS_SensorTestDHT1", true);
  856.                         VA.Command.Execute("F_DHT1_MAIN", true);
  857.                     }
  858.                     else
  859.                     {
  860.                         VA.SetText("AVCS_SENS_TTS_WILDCARD", "Testing.;Test started.");
  861.                         VA.Command.Execute("F_SAY_TTS", true);
  862.                         VA.SetBoolean("AVCS_SENS_SensorTestDHT1", true);
  863.                         while(VA.GetBoolean("AVCS_SENS_SensorTestDHT1") == true)
  864.                             Thread.Sleep(100);
  865.                     }
  866.                 }
  867.                 catch
  868.                 {
  869.                     VA.WriteToLog("AVCS ERROR: function command F_DHT1_MAIN unavailable - test incomplete", "red");
  870.                 }
  871.                 finally
  872.                 {
  873.                     buttonSnsMonitoring.Enabled = true;
  874.                     buttonNewBaselines.Enabled = true;
  875.                     buttonOpenBaseline.Enabled = true;
  876.                     buttonOpenSensors.Enabled = true;
  877.                     buttonBack.Enabled = true;
  878.                    
  879.                     (sender as Button).Enabled = true;
  880.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  881.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  882.                     otherTestButton.Enabled = true;
  883.                     otherTestButton.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  884.                     otherTestButton.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  885.                     if (VA.GetText("AVCS_SENS_Test_ReturnTTS") != null)
  886.                     {
  887.                         VA.SetText("AVCS_SENS_TTS_WILDCARD", VA.GetText("AVCS_SENS_Test_ReturnTTS"));
  888.                         VA.Command.Execute("F_SAY_TTS", false);
  889.                         VA.SetText("AVCS_SENS_Test_ReturnTTS", null);
  890.                     }
  891.                 }
  892.             }
  893.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
  894.         }
  895.     }
  896.    
  897.     // New Baselines Button Event
  898.     private void buttonNewBaselines_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  899.     {
  900.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  901.         {
  902.             if (VA.GetBoolean("AVCS_SENS_Monitoring") != true || VA.GetBoolean("AVCS_SENS_Logging") != true)
  903.             {
  904.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  905.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  906.                 (sender as Button).Enabled = false;
  907.                 VA.WriteToLog("Sensor Monitoring must be enabled to establish baseline data!", "red");
  908.                 VA.WriteToLog("Please begin Sensor Monitoring. See user guide for more information.", "blank");
  909.                 VA.SetText("AVCS_SENS_TTS_WILDCARD", "Sensor data monitoring not detected. Please enable monitoring first.");
  910.                 VA.Command.Execute("F_SAY_TTS", true);
  911.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  912.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  913.                 (sender as Button).Enabled = true;
  914.             }
  915.             else
  916.             {
  917.                 if (VA.GetDecimal("AVCS_SENS_TempDHTf") != null)
  918.                 {
  919.                     this.Hide();
  920.                     Form FormBaselinesMenu = new BaselinesMenuForm(VA, profileTitle, icon);
  921.                     FormBaselinesMenu.ShowDialog();
  922.                     this.Show();
  923.                 }
  924.                 else
  925.                 {
  926.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  927.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  928.                     (sender as Button).Enabled = false;
  929.                     VA.WriteToLog("Cannot locate AVCS-DHT1 External Temperature Sensor data!", "red");
  930.                     VA.WriteToLog("Please check settings. See user guide for more information.", "blank");
  931.                     VA.SetText("AVCS_SENS_TTS_WILDCARD", "External temperature sensor data not detected. Please check device or settings.");
  932.                     VA.Command.Execute("F_SAY_TTS", true);
  933.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  934.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  935.                     (sender as Button).Enabled = true;
  936.                 }
  937.             }
  938.         }
  939.     }
  940.    
  941.     // Open Baseline File Button Event
  942.     private void buttonOpenBaseline_Click(object sender, EventArgs e, dynamic VA)
  943.     {
  944.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  945.         {
  946.             Functions.buttonOpenFile(VA, VA.ParseTokens("{TXT:AVCS_SENS_BaselinesFilePath:}"));
  947.         }
  948.     }
  949.    
  950.     // Open Baseline File Button Event
  951.     private void buttonOpenSensors_Click(object sender, EventArgs e, dynamic VA)
  952.     {
  953.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  954.         {
  955.             Functions.buttonOpenFile(VA, VA.ParseTokens("{TXT:AVCS_SENS_SensorsFilePath:}"));
  956.         }
  957.     }
  958.    
  959.     // Functions to recolor AVCS Test buttons and button text on Mouse Hover events
  960.     public static void buttonsTester_MouseHover(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSize)
  961.     {
  962.         if (VA.GetBoolean("AVCS_SENS_SensorTestDHT1") != true && VA.GetBoolean("AVCS_SENS_Test_SharedMem") != true)
  963.         {
  964.             (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
  965.             (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  966.         }
  967.     }
  968.     public static void buttonsTester_MouseLeave(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSize)
  969.     {
  970.         if (VA.GetBoolean("AVCS_SENS_SensorTestDHT1") != true && VA.GetBoolean("AVCS_SENS_Test_SharedMem") != true)
  971.         {
  972.             (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  973.             (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  974.         }
  975.     }
  976.    
  977.    
  978.    
  979.     //  Final Exit Options Form Closing
  980.     private void SensorOptionsMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  981.     {
  982.         //if (result != null)
  983.         //  VA.SetText("~~UserInput", result);
  984.     }
  985. }
  986.  
  987. //================================================END SENSOR OPTIONS=================================================================
  988.  
  989.  
  990. //================================================BEGIN WEATHER OPTIONS=================================================================
  991. public class WeatherOptionsMenuForm : Form
  992. {
  993.     // Initialize string variable for storing user input
  994.     public string result = null;
  995.     public TextBox textBoxOwmCity;
  996.     public TextBox textBoxOwmKey;
  997.    
  998.     public WeatherOptionsMenuForm(dynamic VA, string profileTitle, Icon icon, Form mainForm, Button buttonOwmMonitoringMain)
  999.     {
  1000.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  1001.         this.Text = profileTitle;
  1002.         if (icon != null)
  1003.             this.Icon = icon;
  1004.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  1005.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  1006.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  1007.         this.MaximizeBox = false;
  1008.         this.MinimizeBox = false;
  1009.         this.StartPosition = FormStartPosition.CenterScreen;
  1010.         this.AutoSize = true;
  1011.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1012.         this.MinimumSize = new Size(this.Width, this.Height);
  1013.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  1014.         this.Padding = new Padding(10);
  1015.         int FontSizeS = 8;
  1016.         int FontSize = 10;
  1017.         int FontSizeM = 12;
  1018.         int FontSizeL = 16;
  1019.         int FontSizeX = 24;
  1020.         int ControlSpacing = 15;
  1021.         this.FormClosing += new FormClosingEventHandler((sender, e) => WeatherOptionsMenuForm_FormClosing(sender, e, VA));
  1022.        
  1023.         // Set up weatherOwmKey Data early for checks in other form objects setup
  1024.         string weatherOwmKey = "";
  1025.         string defaultOwmKey = VA.GetText("AVCS_SENS_OWM_DefaultKey");
  1026.         string apiKeyURL = "https://veterans-gaming.com/semlerpdx-avcs/profiles/avcs_sens_owm_key.htm/";
  1027.         if (VA.GetText("AVCS_SENS_OWMKEY") != null)
  1028.         {
  1029.             weatherOwmKey = VA.GetText("AVCS_SENS_OWMKEY");
  1030.         }
  1031.         else
  1032.         {
  1033.             VA.SetText("AVCS_SENS_OWMKEY", defaultOwmKey);
  1034.             weatherOwmKey = defaultOwmKey;
  1035.         }
  1036.        
  1037.         // Set up labelHeader
  1038.         Label labelHeader = new Label();
  1039.         labelHeader.Text = "Weather Options Menu";
  1040.         labelHeader.MinimumSize = new Size(320, 0);
  1041.         labelHeader.MaximumSize = new Size(320, 0);
  1042.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  1043.         labelHeader.AutoSize = true;
  1044.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  1045.         this.Controls.Add(labelHeader);
  1046.        
  1047.         // Set up labelSpacer
  1048.         Label labelSpacerH = new Label();
  1049.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  1050.        
  1051.        
  1052.         // Set up buttonOwmMonitoring
  1053.         Button buttonOwmMonitoring = new Button();
  1054.         if (VA.GetBoolean("AVCS_OWM_Monitoring") != true)
  1055.         {
  1056.             buttonOwmMonitoring.Text = " Begin Weather Monitoring ";
  1057.         }
  1058.         else
  1059.         {
  1060.             buttonOwmMonitoring.Text = " Stop Weather Monitoring ";
  1061.         }
  1062.         buttonOwmMonitoring.AutoSize = true;
  1063.         buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1064.         buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  1065.         buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  1066.         ToolTip OwmMonitoringTip = new ToolTip();
  1067.         OwmMonitoringTip.SetToolTip(buttonOwmMonitoring,"(monitoring will continue even if this menu is closed)");
  1068.         this.Controls.Add(buttonOwmMonitoring);
  1069.         buttonOwmMonitoring.MouseHover += new EventHandler((sender, e) => Functions.buttonsOwmMonitoring_MouseHover(sender, e, VA));
  1070.         buttonOwmMonitoring.MouseLeave += new EventHandler((sender, e) => Functions.buttonsOwmMonitoring_MouseLeave(sender, e, VA));
  1071.        
  1072.        
  1073.        
  1074.         // Set up buttonProOptions
  1075.         Button buttonGetWeatherTest = new Button();
  1076.         buttonGetWeatherTest.Text = " Test Get Weather ";
  1077.         buttonGetWeatherTest.AutoSize = true;
  1078.         buttonGetWeatherTest.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1079.         buttonGetWeatherTest.Font = new Font(buttonGetWeatherTest.Font.FontFamily, FontSizeM);
  1080.         buttonGetWeatherTest.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  1081.         ToolTip GetWeatherTestTip = new ToolTip();
  1082.         GetWeatherTestTip.SetToolTip(buttonGetWeatherTest,"(see user guide for help)");
  1083.         this.Controls.Add(buttonGetWeatherTest);
  1084.         buttonGetWeatherTest.MouseHover += new EventHandler((sender, e) => buttonsTester_MouseHover(sender, e, VA));
  1085.         buttonGetWeatherTest.MouseLeave += new EventHandler((sender, e) => buttonsTester_MouseLeave(sender, e, VA));
  1086.        
  1087.         //===================================
  1088.         // Set up labelSpacer
  1089.         string weatherOwmCity = "New York, NY, US";
  1090.         string defaultOwmCity = weatherOwmCity;
  1091.         if (VA.GetText("AVCS_SENS_OWMCITY") != null)
  1092.             weatherOwmCity = VA.GetText("AVCS_SENS_OWMCITY");
  1093.        
  1094.         Label labelOmwCity = new Label();
  1095.         //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";
  1096.         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";
  1097.         labelOmwCity.Font = new Font(labelOmwCity.Font.FontFamily, FontSizeS);
  1098.         labelOmwCity.AutoSize = true;
  1099.         labelOmwCity.TextAlign = ContentAlignment.MiddleCenter;
  1100.         ToolTip OwmCityTip = new ToolTip();
  1101.         OwmCityTip.SetToolTip(labelOmwCity, "City name, state code (only for the US) and country code\ndivided by comma. Please use ISO 3166 country codes.");
  1102.         this.Controls.Add(labelOmwCity);
  1103.        
  1104.         // Set up OWM User City Input TextBox
  1105.         textBoxOwmCity = new TextBox();
  1106.         textBoxOwmCity.AcceptsReturn = true;
  1107.         textBoxOwmCity.AcceptsTab = false;
  1108.         textBoxOwmCity.Multiline = false;
  1109.         textBoxOwmCity.Text = weatherOwmCity;
  1110.         textBoxOwmCity.Padding = new Padding(1);
  1111.         textBoxOwmCity.Font = new Font(textBoxOwmCity.Font.FontFamily, FontSizeS);
  1112.         ToolTip BoxOwmCityTip = new ToolTip();
  1113.         BoxOwmCityTip.SetToolTip(textBoxOwmCity, "City name, state code (only for the US) and country code\ndivided by comma. Please use ISO 3166 country codes.");
  1114.         textBoxOwmCity.MinimumSize = new Size(220, 0);
  1115.         textBoxOwmCity.MaximumSize = new Size(220, 0);
  1116.         ContextMenu emptyCityMenu = new ContextMenu();
  1117.         textBoxOwmCity.ContextMenu = emptyCityMenu;
  1118.         this.Controls.Add(this.textBoxOwmCity);
  1119.        
  1120.         // Set up Save OWM City button
  1121.         Button buttonOwmSaveCity = new Button();
  1122.         if (weatherOwmCity != defaultOwmCity)
  1123.         {
  1124.             buttonOwmSaveCity.Text = " Clear User City ";
  1125.             textBoxOwmCity.ReadOnly = true;
  1126.             textBoxOwmCity.Enabled = false;
  1127.         }
  1128.         else
  1129.         {
  1130.             textBoxOwmCity.ReadOnly = false;
  1131.             textBoxOwmCity.Enabled = true;
  1132.             buttonOwmSaveCity.Text = " Save User City ";
  1133.         }
  1134.         buttonOwmSaveCity.AutoSize = true;
  1135.         buttonOwmSaveCity.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1136.         buttonOwmSaveCity.Font = new Font(buttonOwmSaveCity.Font.FontFamily, FontSizeM);
  1137.         buttonOwmSaveCity.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  1138.         this.Controls.Add(buttonOwmSaveCity);
  1139.         buttonOwmSaveCity.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  1140.         buttonOwmSaveCity.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  1141.         buttonOwmSaveCity.Click += new EventHandler((sender, e) => buttonSetCity_Click(sender, e, VA, ControlSpacing, FontSizeM, textBoxOwmCity, defaultOwmCity, textBoxOwmCity.Text));
  1142.        
  1143.         //=============================================
  1144.        
  1145.         // Set up labelSpacer
  1146.         Label labelSpacerW = new Label();
  1147.         Functions.addLabelSpacer(this, 1, labelSpacerW);
  1148.        
  1149.         // Set up labelTogglesSub
  1150.         Label labelTogglesSub = new Label();
  1151.         labelTogglesSub.Text = " Weather Data Units / Monitoring Interval ";
  1152.         labelTogglesSub.Font = new Font(labelTogglesSub.Font.FontFamily, FontSizeS);
  1153.         labelTogglesSub.AutoSize = true;
  1154.         labelTogglesSub.TextAlign = ContentAlignment.MiddleCenter;
  1155.         this.Controls.Add(labelTogglesSub);
  1156.        
  1157.         // Set up buttonSetUnits
  1158.         Button buttonSetUnits = new Button();
  1159.         if (VA.GetBoolean("AVCS_SENS_OWM_UnitMetric") != true)
  1160.         {
  1161.             buttonSetUnits.Text = " Units: Fahrenheit ";
  1162.         }
  1163.         else
  1164.         {
  1165.             buttonSetUnits.Text = "   Units: Celcius   ";
  1166.         }
  1167.         buttonSetUnits.AutoSize = true;
  1168.         buttonSetUnits.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1169.         buttonSetUnits.Font = new Font(buttonSetUnits.Font.FontFamily, FontSizeM);
  1170.         buttonSetUnits.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  1171.         this.Controls.Add(buttonSetUnits);
  1172.         buttonSetUnits.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  1173.         buttonSetUnits.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  1174.         buttonSetUnits.Click += new EventHandler((sender, e) => buttonSetUnits_Click(sender, e, VA, ControlSpacing, FontSizeM));
  1175.        
  1176.         // Set up buttonSetWind
  1177.         Button buttonSetWind = new Button();
  1178.         if (VA.GetBoolean("AVCS_SENS_OWM_WindMetric") != true)
  1179.         {
  1180.             buttonSetWind.Text = "   Wind: MPH   ";
  1181.         }
  1182.         else
  1183.         {
  1184.             buttonSetWind.Text = "   Wind: KPH   ";
  1185.         }
  1186.         buttonSetWind.AutoSize = true;
  1187.         buttonSetWind.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1188.         buttonSetWind.Font = new Font(buttonSetWind.Font.FontFamily, FontSizeM);
  1189.         buttonSetWind.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  1190.         this.Controls.Add(buttonSetWind);
  1191.         buttonSetWind.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  1192.         buttonSetWind.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  1193.         buttonSetWind.Click += new EventHandler((sender, e) => buttonSetWind_Click(sender, e, VA, ControlSpacing, FontSizeM));
  1194.        
  1195.         // Set up buttonSetCallsAPI
  1196.         Button buttonSetCallsAPI = new Button();
  1197.         int intervalCallsAPI = 0;
  1198.         if (VA.GetText("AVCS_SENS_OWMKEY") == VA.GetText("AVCS_SENS_OWM_DefaultKey"))
  1199.         {
  1200.             if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null)
  1201.             {
  1202.                 intervalCallsAPI = VA.GetInt("AVCS_SENS_OWM_API_Calls");
  1203.                 if (intervalCallsAPI == 180)
  1204.                 {
  1205.                     buttonSetCallsAPI.Text = " Checks: 15 minutes ";
  1206.                 }else if (intervalCallsAPI == 360) {
  1207.                     buttonSetCallsAPI.Text = " Checks: 30 minutes ";
  1208.                 }else if (intervalCallsAPI == 720) {
  1209.                     buttonSetCallsAPI.Text = " Checks: 60 minutes ";
  1210.                 }
  1211.                 else
  1212.                 {
  1213.                     buttonSetCallsAPI.Text = " Checks: 15 minutes ";
  1214.                     VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
  1215.                 }
  1216.             }
  1217.             else
  1218.             {
  1219.                 buttonSetCallsAPI.Text = " Checks: 15 minutes ";
  1220.                 VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
  1221.             }
  1222.         }
  1223.         else
  1224.         {
  1225.             if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null)
  1226.             {
  1227.                 intervalCallsAPI = VA.GetInt("AVCS_SENS_OWM_API_Calls");
  1228.                 if (intervalCallsAPI == 12)
  1229.                 {
  1230.                     buttonSetCallsAPI.Text = " Checks: 1 minute ";
  1231.                 }else if (intervalCallsAPI == 60) {
  1232.                     buttonSetCallsAPI.Text = " Checks: 5 minutes ";
  1233.                 }else if (intervalCallsAPI == 120) {
  1234.                     buttonSetCallsAPI.Text = " Checks: 10 minutes ";
  1235.                 }else if (intervalCallsAPI == 180) {
  1236.                     buttonSetCallsAPI.Text = " Checks: 15 minutes ";
  1237.                 }else if (intervalCallsAPI == 360) {
  1238.                     buttonSetCallsAPI.Text = " Checks: 30 minutes ";
  1239.                 }else if (intervalCallsAPI == 720) {
  1240.                     buttonSetCallsAPI.Text = " Checks: 60 minutes ";
  1241.                 }
  1242.                 else
  1243.                 {
  1244.                     buttonSetCallsAPI.Text = " Checks: 1 minutes ";
  1245.                     VA.SetInt("AVCS_SENS_OWM_API_Calls", 12);
  1246.                 }
  1247.             }
  1248.             else
  1249.             {
  1250.                 buttonSetCallsAPI.Text = " Checks: 1 minutes ";
  1251.                 VA.SetInt("AVCS_SENS_OWM_API_Calls", 12);
  1252.             }
  1253.         }
  1254.         buttonSetCallsAPI.AutoSize = true;
  1255.         buttonSetCallsAPI.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1256.         buttonSetCallsAPI.Font = new Font(buttonSetCallsAPI.Font.FontFamily, FontSizeM);
  1257.         buttonSetCallsAPI.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  1258.         if ((VA.GetBoolean("AVCS_OWM_Monitoring") != null) && (VA.GetBoolean("AVCS_OWM_Monitoring") == true))
  1259.         {
  1260.             ToolTip SetCallsAPITip = new ToolTip();
  1261.             SetCallsAPITip.SetToolTip(buttonSetCallsAPI,"(restart monitor to apply changes)");
  1262.         }
  1263.         this.Controls.Add(buttonSetCallsAPI);
  1264.         buttonSetCallsAPI.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  1265.         buttonSetCallsAPI.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  1266.         buttonSetCallsAPI.Click += new EventHandler((sender, e) => buttonSetCallsAPI_Click(sender, e, VA, ControlSpacing, FontSizeM));
  1267.        
  1268.         // Set up buttonSetCallsForecast
  1269.         Button buttonSetCallsForecast = new Button();
  1270.         if (VA.GetInt("AVCS_SENS_OWM_FC_Calls") != null)
  1271.         {
  1272.             int intervalCallsFC = VA.GetInt("AVCS_SENS_OWM_FC_Calls");
  1273.             if (intervalCallsFC == 3600)
  1274.             {
  1275.                 buttonSetCallsForecast.Text = " Forecasts: 1 hour ";
  1276.             }else if (intervalCallsFC == 7200) {
  1277.                 buttonSetCallsForecast.Text = " Forecasts: 2 hours ";
  1278.             }else if (intervalCallsFC == 14400) {
  1279.                 buttonSetCallsForecast.Text = " Forecasts: 4 hours ";
  1280.             }else if (intervalCallsFC == 21600) {
  1281.                 buttonSetCallsForecast.Text = " Forecasts: 6 hours ";
  1282.             }else if (intervalCallsFC == 28800) {
  1283.                 buttonSetCallsForecast.Text = " Forecasts: 8 hours ";
  1284.             }else if (intervalCallsFC == 43200) {
  1285.                 buttonSetCallsForecast.Text = " Forecasts: 12 hours ";
  1286.             }else if (intervalCallsFC == 86400) {
  1287.                 buttonSetCallsForecast.Text = " Forecasts: 24 hours ";
  1288.             }
  1289.             else
  1290.             {
  1291.                 buttonSetCallsForecast.Text = " Forecasts: 24 hours ";
  1292.                 VA.SetInt("AVCS_SENS_OWM_FC_Calls", 86400);
  1293.             }
  1294.         }
  1295.         else
  1296.         {
  1297.             buttonSetCallsForecast.Text = " Forecasts: 1 hours ";
  1298.             VA.SetInt("AVCS_SENS_OWM_FC_Calls", 3600);
  1299.         }
  1300.         buttonSetCallsForecast.AutoSize = true;
  1301.         buttonSetCallsForecast.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1302.         buttonSetCallsForecast.Font = new Font(buttonSetCallsForecast.Font.FontFamily, FontSizeM);
  1303.         buttonSetCallsForecast.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  1304.         ToolTip SetCallsForecastTip = new ToolTip();
  1305.         SetCallsForecastTip.SetToolTip(buttonSetCallsForecast,"(restart monitor to apply changes)");
  1306.         this.Controls.Add(buttonSetCallsForecast);
  1307.         buttonSetCallsForecast.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  1308.         buttonSetCallsForecast.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  1309.         buttonSetCallsForecast.Click += new EventHandler((sender, e) => buttonSetCallsForecast_Click(sender, e, VA, ControlSpacing, FontSizeM));
  1310.         buttonSetCallsForecast.Enabled = false;
  1311.         buttonSetCallsForecast.Visible = false;
  1312.        
  1313.         Label labelOmwKey = new Label();
  1314.         labelOmwKey.Text = "Enter your own Open Weather Map Key  (optional)";
  1315.         labelOmwKey.Font = new Font(labelOmwKey.Font.FontFamily, FontSizeS);
  1316.         labelOmwKey.AutoSize = true;
  1317.         labelOmwKey.TextAlign = ContentAlignment.MiddleCenter;
  1318.        
  1319.         this.Controls.Add(labelOmwKey);
  1320.        
  1321.         // Set up OWM User Key Input TextBox
  1322.         textBoxOwmKey = new TextBox();
  1323.         textBoxOwmKey.AcceptsReturn = true;
  1324.         textBoxOwmKey.AcceptsTab = false;
  1325.         textBoxOwmKey.Multiline = false;
  1326.         if (weatherOwmKey != defaultOwmKey)
  1327.             textBoxOwmKey.Text = weatherOwmKey;
  1328.         textBoxOwmKey.Padding = new Padding(1);
  1329.         textBoxOwmKey.Font = new Font(textBoxOwmKey.Font.FontFamily, FontSizeS);
  1330.         textBoxOwmKey.MinimumSize = new Size(220, 0);
  1331.         textBoxOwmKey.MaximumSize = new Size(220, 0);
  1332.         ContextMenu emptyKeyMenu = new ContextMenu();
  1333.         textBoxOwmKey.ContextMenu = emptyKeyMenu;
  1334.         this.Controls.Add(this.textBoxOwmKey);
  1335.        
  1336.         // Set up Save OWM Key button
  1337.         Button buttonOwmSaveKey = new Button();
  1338.         if (weatherOwmKey != defaultOwmKey)
  1339.         {
  1340.             buttonOwmSaveKey.Text = " Clear User Key ";
  1341.             textBoxOwmKey.ReadOnly = true;
  1342.             textBoxOwmKey.Enabled = false;
  1343.             buttonSetCallsForecast.Enabled = true;
  1344.             buttonSetCallsForecast.Visible = true;
  1345.         }
  1346.         else
  1347.         {
  1348.             textBoxOwmKey.ReadOnly = false;
  1349.             textBoxOwmKey.Enabled = true;
  1350.             buttonOwmSaveKey.Text = " Save User Key ";
  1351.             buttonSetCallsForecast.Enabled = false;
  1352.             buttonSetCallsForecast.Visible = false;
  1353.         }
  1354.         buttonOwmSaveKey.AutoSize = true;
  1355.         buttonOwmSaveKey.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1356.         buttonOwmSaveKey.Font = new Font(buttonOwmSaveKey.Font.FontFamily, FontSizeM);
  1357.         buttonOwmSaveKey.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  1358.         this.Controls.Add(buttonOwmSaveKey);
  1359.         buttonOwmSaveKey.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  1360.         buttonOwmSaveKey.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  1361.         buttonOwmSaveKey.Click += new EventHandler((sender, e) => buttonOwmSaveKey_Click(sender, e, VA, ControlSpacing, FontSizeM, textBoxOwmKey, defaultOwmKey, textBoxOwmKey.Text, buttonSetCallsForecast));
  1362.        
  1363.        
  1364.        
  1365.         //===========================  FOOTER  =======================
  1366.         // Set up labelSpacer
  1367.         Label labelSpacerF = new Label();
  1368.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  1369.        
  1370.         // Set up buttonBack
  1371.         Button buttonBack = new Button();
  1372.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  1373.        
  1374.        
  1375.         // Footer Link and Credit to Open Weather Map
  1376.         LinkLabel labelOwmLink = new LinkLabel();
  1377.         Functions.addOwmLinkFooterLabel(VA, this, FontSizeS, labelOwmLink);
  1378.        
  1379.         // Event Handlers added last to include buttons temporarily disabled by these button clicks
  1380.         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));
  1381.         buttonGetWeatherTest.Click += new EventHandler((sender, e) => buttonGetWeatherTest_Click(sender, e, VA, buttonOwmMonitoring, buttonOwmSaveCity, buttonSetUnits, buttonSetWind, buttonSetCallsAPI, buttonOwmSaveKey,  buttonBack));
  1382.        
  1383.         // Show Options Form
  1384.         Functions.ResizeForm(this, ControlSpacing);
  1385.         Functions.ShowForm(this);
  1386.     }
  1387.    
  1388.    
  1389.     // Test Get Weather Button Event
  1390.     private void buttonGetWeatherTest_Click(object sender, EventArgs e, dynamic VA, Button buttonOther1, Button buttonOther2, Button buttonOther3, Button buttonOther4, Button buttonOther5, Button buttonOther6, Button buttonOther7)
  1391.     {
  1392.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  1393.         {
  1394.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
  1395.             VA.SetBoolean("AVCS_SENS_Test_GetWeather", null);
  1396.             if (VA.GetBoolean("AVCS_SENS_Test_GetWeather") != true)
  1397.             {
  1398.                 (sender as Button).Enabled = false;
  1399.                 buttonOther1.Enabled = false;
  1400.                 buttonOther2.Enabled = false;
  1401.                 buttonOther3.Enabled = false;
  1402.                 buttonOther4.Enabled = false;
  1403.                 buttonOther5.Enabled = false;
  1404.                 buttonOther6.Enabled = false;
  1405.                 buttonOther7.Enabled = false;
  1406.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  1407.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  1408.                 VA.SetBoolean("AVCS_SENS_Test_GetWeather", true);
  1409.                
  1410.                 GetWeatherTest(VA);
  1411.                
  1412.                 (sender as Button).Enabled = true;
  1413.                 buttonOther1.Enabled = true;
  1414.                 buttonOther2.Enabled = true;
  1415.                 buttonOther3.Enabled = true;
  1416.                 buttonOther4.Enabled = true;
  1417.                 buttonOther5.Enabled = true;
  1418.                 buttonOther6.Enabled = true;
  1419.                 buttonOther7.Enabled = true;
  1420.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  1421.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  1422.                 VA.SetBoolean("AVCS_SENS_Test_GetWeather", null);
  1423.             }
  1424.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
  1425.         }
  1426.     }
  1427.    
  1428.     // Open Config File Button Event
  1429.     private void buttonSetUnits_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
  1430.     {
  1431.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  1432.         {
  1433.             if (VA.GetBoolean("AVCS_SENS_OWM_UnitMetric") != true)
  1434.             {
  1435.                 VA.SetBoolean("AVCS_SENS_OWM_UnitMetric", true);
  1436.                 (sender as Button).Text = "   Units: Celcius   ";
  1437.                 (sender as Button).AutoSize = true;
  1438.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1439.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1440.                 Functions.ResizeForm(this, ControlSpacing);
  1441.             }
  1442.             else
  1443.             {
  1444.                 VA.SetBoolean("AVCS_SENS_OWM_UnitMetric", false);
  1445.                 (sender as Button).Text = " Units: Fahrenheit ";
  1446.                 (sender as Button).AutoSize = true;
  1447.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1448.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1449.                 Functions.ResizeForm(this, ControlSpacing);
  1450.             }
  1451.         }
  1452.     }
  1453.    
  1454.     // Open Config Folder Button Event
  1455.     private void buttonSetWind_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
  1456.     {
  1457.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  1458.         {
  1459.             if (VA.GetBoolean("AVCS_SENS_OWM_WindMetric") != true)
  1460.             {
  1461.                 VA.SetBoolean("AVCS_SENS_OWM_WindMetric", true);
  1462.                 (sender as Button).Text = "   Wind: KPH   ";
  1463.                 (sender as Button).AutoSize = true;
  1464.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1465.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1466.                 Functions.ResizeForm(this, ControlSpacing);
  1467.             }
  1468.             else
  1469.             {
  1470.                 VA.SetBoolean("AVCS_SENS_OWM_WindMetric", false);
  1471.                 (sender as Button).Text = "   Wind: MPH   ";
  1472.                 (sender as Button).AutoSize = true;
  1473.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1474.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1475.                 Functions.ResizeForm(this, ControlSpacing);
  1476.             }
  1477.         }
  1478.     }
  1479.    
  1480.     // Open Config Folder Button Event
  1481.     private void buttonSetCallsAPI_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
  1482.     {
  1483.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  1484.         {
  1485.             int checkCallsInterval = 0;
  1486.             if (VA.GetText("AVCS_SENS_OWMKEY") == VA.GetText("AVCS_SENS_OWM_DefaultKey"))
  1487.             {
  1488.                 if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null)
  1489.                 {
  1490.                     checkCallsInterval = VA.GetInt("AVCS_SENS_OWM_API_Calls");
  1491.                     if (checkCallsInterval == 180)
  1492.                     {
  1493.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 360);
  1494.                         (sender as Button).Text = " Checks: 30 minutes ";
  1495.                         (sender as Button).AutoSize = true;
  1496.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1497.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1498.                         Functions.ResizeForm(this, ControlSpacing);
  1499.                     }else if (checkCallsInterval == 360) {
  1500.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 720);
  1501.                         (sender as Button).Text = " Checks: 60 minutes ";
  1502.                         (sender as Button).AutoSize = true;
  1503.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1504.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1505.                         Functions.ResizeForm(this, ControlSpacing);
  1506.                     }else if (checkCallsInterval == 720) {
  1507.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
  1508.                         (sender as Button).Text = " Checks: 15 minutes ";
  1509.                         (sender as Button).AutoSize = true;
  1510.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1511.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1512.                         Functions.ResizeForm(this, ControlSpacing);
  1513.                     }
  1514.                     else
  1515.                     {
  1516.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
  1517.                         (sender as Button).Text = " Checks: 15 minutes ";
  1518.                         (sender as Button).AutoSize = true;
  1519.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1520.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1521.                         Functions.ResizeForm(this, ControlSpacing);
  1522.                     }
  1523.                 }
  1524.                 else
  1525.                 {
  1526.                     VA.SetInt("AVCS_SENS_OWM_API_Calls", 360);
  1527.                     (sender as Button).Text = " Checks: 30 minutes ";
  1528.                     (sender as Button).AutoSize = true;
  1529.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1530.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1531.                     Functions.ResizeForm(this, ControlSpacing);
  1532.                 }
  1533.             }
  1534.             else
  1535.             {
  1536.                 if (VA.GetInt("AVCS_SENS_OWM_API_Calls") != null)
  1537.                 {
  1538.                     checkCallsInterval = VA.GetInt("AVCS_SENS_OWM_API_Calls");
  1539.                     if (checkCallsInterval == 12)
  1540.                     {
  1541.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 60);
  1542.                         (sender as Button).Text = " Checks: 5 minutes ";
  1543.                         (sender as Button).AutoSize = true;
  1544.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1545.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1546.                         Functions.ResizeForm(this, ControlSpacing);
  1547.                     }else if (checkCallsInterval == 60) {
  1548.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 120);
  1549.                         (sender as Button).Text = " Checks: 10 minutes ";
  1550.                         (sender as Button).AutoSize = true;
  1551.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1552.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1553.                         Functions.ResizeForm(this, ControlSpacing);
  1554.                     }else if (checkCallsInterval == 120) {
  1555.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 180);
  1556.                         (sender as Button).Text = " Checks: 15 minutes ";
  1557.                         (sender as Button).AutoSize = true;
  1558.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1559.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1560.                         Functions.ResizeForm(this, ControlSpacing);
  1561.                     }else if (checkCallsInterval == 180) {
  1562.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 360);
  1563.                         (sender as Button).Text = " Checks: 30 minutes ";
  1564.                         (sender as Button).AutoSize = true;
  1565.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1566.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1567.                         Functions.ResizeForm(this, ControlSpacing);
  1568.                     }else if (checkCallsInterval == 360) {
  1569.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 720);
  1570.                         (sender as Button).Text = " Checks: 60 minutes ";
  1571.                         (sender as Button).AutoSize = true;
  1572.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1573.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1574.                         Functions.ResizeForm(this, ControlSpacing);
  1575.                     }else if (checkCallsInterval == 720) {
  1576.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 12);
  1577.                         (sender as Button).Text = " Checks: 1 minute ";
  1578.                         (sender as Button).AutoSize = true;
  1579.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1580.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1581.                         Functions.ResizeForm(this, ControlSpacing);
  1582.                     }
  1583.                     else
  1584.                     {
  1585.                         VA.SetInt("AVCS_SENS_OWM_API_Calls", 12);
  1586.                         (sender as Button).Text = " Checks: 1 minute ";
  1587.                         (sender as Button).AutoSize = true;
  1588.                         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1589.                         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1590.                         Functions.ResizeForm(this, ControlSpacing);
  1591.                     }
  1592.                 }
  1593.                 else
  1594.                 {
  1595.                     VA.SetInt("AVCS_SENS_OWM_API_Calls", 60);
  1596.                     (sender as Button).Text = " Checks: 5 minutes ";
  1597.                     (sender as Button).AutoSize = true;
  1598.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1599.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1600.                     Functions.ResizeForm(this, ControlSpacing);
  1601.                 }
  1602.             }
  1603.         }
  1604.     }
  1605.    
  1606.     // Open Config Folder Button Event
  1607.     private void buttonSetCallsForecast_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
  1608.     {
  1609.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  1610.         {
  1611.             if (VA.GetInt("AVCS_SENS_OWM_FC_Calls") != null)
  1612.             {
  1613.                 int checkIntervalFC = VA.GetInt("AVCS_SENS_OWM_FC_Calls");
  1614.                 if (checkIntervalFC == 3600)
  1615.                 {
  1616.                     VA.SetInt("AVCS_SENS_OWM_FC_Calls", 7200);
  1617.                     (sender as Button).Text = " Forecasts: 2 hours ";
  1618.                     (sender as Button).AutoSize = true;
  1619.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1620.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1621.                     Functions.ResizeForm(this, ControlSpacing);
  1622.                 }else if (checkIntervalFC == 7200) {
  1623.                     VA.SetInt("AVCS_SENS_OWM_FC_Calls", 14400);
  1624.                     (sender as Button).Text = " Forecasts: 4 hours ";
  1625.                     (sender as Button).AutoSize = true;
  1626.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1627.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1628.                     Functions.ResizeForm(this, ControlSpacing);
  1629.                 }else if (checkIntervalFC == 14400) {
  1630.                     VA.SetInt("AVCS_SENS_OWM_FC_Calls", 21600);
  1631.                     (sender as Button).Text = " Forecasts: 6 hours ";
  1632.                     (sender as Button).AutoSize = true;
  1633.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1634.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1635.                     Functions.ResizeForm(this, ControlSpacing);
  1636.                 }else if (checkIntervalFC == 21600) {
  1637.                     VA.SetInt("AVCS_SENS_OWM_FC_Calls", 28800);
  1638.                     (sender as Button).Text = " Forecasts: 8 hours ";
  1639.                     (sender as Button).AutoSize = true;
  1640.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1641.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1642.                     Functions.ResizeForm(this, ControlSpacing);
  1643.                 }else if (checkIntervalFC == 28800) {
  1644.                     VA.SetInt("AVCS_SENS_OWM_FC_Calls", 43200);
  1645.                     (sender as Button).Text = " Forecasts: 12 hours ";
  1646.                     (sender as Button).AutoSize = true;
  1647.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1648.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1649.                     Functions.ResizeForm(this, ControlSpacing);
  1650.                 }else if (checkIntervalFC == 43200) {
  1651.                     VA.SetInt("AVCS_SENS_OWM_FC_Calls", 86400);
  1652.                     (sender as Button).Text = " Forecasts: 24 hours ";
  1653.                     (sender as Button).AutoSize = true;
  1654.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1655.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1656.                     Functions.ResizeForm(this, ControlSpacing);
  1657.                 }
  1658.                 else
  1659.                 {
  1660.                     VA.SetInt("AVCS_SENS_OWM_FC_Calls", 3600);
  1661.                     (sender as Button).Text = " Forecasts: 1 hour ";
  1662.                     (sender as Button).AutoSize = true;
  1663.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1664.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1665.                     Functions.ResizeForm(this, ControlSpacing);
  1666.                 }
  1667.             }
  1668.             else
  1669.             {
  1670.                 VA.SetInt("AVCS_SENS_OWM_FC_Calls", 3600);
  1671.                 (sender as Button).Text = " Forecasts: 1 hour ";
  1672.                 (sender as Button).AutoSize = true;
  1673.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  1674.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  1675.                 Functions.ResizeForm(this, ControlSpacing);
  1676.             }
  1677.         }
  1678.     }
  1679.    
  1680.     public class GetWeatherException : Exception
  1681.     {
  1682.         public void GetWeatherTestException(dynamic VA)
  1683.         {
  1684.             VA.SetBoolean("AVCS_OWM_SET", null);
  1685.         }
  1686.         public void GetWeatherFailException(dynamic VA)
  1687.         {
  1688.             VA.WriteToLog("AVCS OWM Get Weather Data Test has failed!", "red");
  1689.             VA.WriteToLog("Please check settings. See user guide for more information.", "blank");
  1690.             VA.SetText("AVCS_SENS_TTS_WILDCARD", "Test failed. Please check settings.");
  1691.             VA.Command.Execute("F_SAY_TTS", false);
  1692.         }
  1693.     }
  1694.    
  1695.     private void GetWeatherTest(dynamic VA)
  1696.     {
  1697.         VA.SetBoolean("AVCS_OWM_SET", null);
  1698.         try
  1699.         {
  1700.             GetWeatherTestURL(VA);
  1701.             if (VA.GetBoolean("AVCS_OWM_SET") != true)
  1702.             {
  1703.                 throw new GetWeatherException();
  1704.             }
  1705.             else
  1706.             {
  1707.                 VA.WriteToLog(VA.GetText("~avcs_owm_test_data"), "blank");
  1708.                 VA.WriteToLog("AVCS OWM Get Weather Data Test has succeeded!", "green");
  1709.                 VA.SetText("AVCS_SENS_TTS_WILDCARD", "Test succeeded.");
  1710.                 VA.Command.Execute("F_SAY_TTS", true);
  1711.                 VA.SetText("AVCS_SENS_TTS_WILDCARD", VA.GetText("~avcs_owm_test_data_tts"));
  1712.                 VA.Command.Execute("F_SAY_TTS", true);
  1713.                 VA.SetText("~avcs_owm_test_data_tts", null);
  1714.                 VA.SetText("~avcs_owm_test_data", null);
  1715.             }
  1716.         }
  1717.         catch (GetWeatherException e)
  1718.         {
  1719.             //for any expected unexpected faults
  1720.             e.GetWeatherFailException(VA);
  1721.         }
  1722.     }
  1723.    
  1724.     private void GetWeatherTestURL(dynamic VA)
  1725.     {
  1726.         string cityName;
  1727.         string stateName;
  1728.         string newLat = "";
  1729.         string newLon = "";
  1730.         string locationData = "New York, NY, US";
  1731.         string apiKey = "";
  1732.         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";
  1733.         string weatherURL = "";
  1734.         bool hasGPS = false;
  1735.         bool faultDetected = false;
  1736.        
  1737.        
  1738.         if (VA.GetText("AVCS_SENS_OWMKEY") != null)
  1739.         {
  1740.             apiKey = VA.GetText("AVCS_SENS_OWMKEY");
  1741.         }
  1742.         else
  1743.         {
  1744.             apiKey = VA.GetText("AVCS_SENS_OWM_DefaultKey");
  1745.         }
  1746.         if (VA.GetText("AVCS_SENS_OWMCITY") != null)
  1747.             locationData = VA.GetText("AVCS_SENS_OWMCITY");
  1748.         if (locationData.Contains(","))
  1749.         {
  1750.             string[] locationDataSet = locationData.Split(
  1751.                 new string[] { "," },
  1752.                 StringSplitOptions.RemoveEmptyEntries
  1753.             );
  1754.             if (1 < locationDataSet.Length)
  1755.             {
  1756.                 decimal checkLat;
  1757.                 decimal checkLon;
  1758.                 bool checkLatIsValid = decimal.TryParse(locationDataSet[0], out checkLat) && Math.Abs(checkLat) < 90;
  1759.                 bool checkLonIsValid = decimal.TryParse(locationDataSet[1], out checkLon) && Math.Abs(checkLon) < 180;
  1760.                 if ((checkLatIsValid && checkLonIsValid) && (Math.Abs(checkLat) > 4.4m && Math.Abs(checkLon) > 4.4m))
  1761.                 {
  1762.                     hasGPS = true;
  1763.                     newLat = locationDataSet[0].Trim();
  1764.                     newLon = locationDataSet[1].Trim();
  1765.                     VA.SetText("AVCS_SENS_OWMLAT", newLat);
  1766.                     VA.SetText("AVCS_SENS_OWMLON", newLon);
  1767.                     weatherURL = baseURL.Replace("AVCS_SENS_OWMLAT",newLat).Replace("AVCS_SENS_OWMLON",newLon).Replace("AVCS_SENS_OWMKEY",apiKey).Trim();
  1768.                 }
  1769.             }
  1770.         }
  1771.         if (hasGPS != true)
  1772.         {
  1773.             try
  1774.             {
  1775.                 string apiReturn = "";
  1776.                 VA.SetText("~avcs_owm_return", null);
  1777.                 weatherURL = "http://api.openweathermap.org/geo/1.0/direct?q="+locationData+"&limit=1&appid="+apiKey;
  1778.                
  1779.                 GetWeatherDataOnline(weatherURL, VA);
  1780.                
  1781.                 if (VA.GetText("~avcs_owm_return") != null)
  1782.                     apiReturn = VA.GetText("~avcs_owm_return").Replace("\"","").Replace("{","").Replace("}","");
  1783.                
  1784.                 if (apiReturn.Contains(","))
  1785.                 {
  1786.                     string[] lines = apiReturn.Split(
  1787.                         new string[] { "," },
  1788.                         StringSplitOptions.RemoveEmptyEntries
  1789.                     );
  1790.                    
  1791.                     foreach (string line in lines)
  1792.                     {
  1793.                         if (line.Contains("lat"))
  1794.                         {
  1795.                             if (line.Contains(":"))
  1796.                             {
  1797.                                 string[] checkLine = line.Split(
  1798.                                     new string[] { ":" },
  1799.                                     StringSplitOptions.RemoveEmptyEntries
  1800.                                 );
  1801.                                 if(1 < checkLine.Length)
  1802.                                     newLat = checkLine[1];
  1803.                             }
  1804.                         }
  1805.                         if (line.Contains("lon"))
  1806.                         {
  1807.                             if (line.Contains(":"))
  1808.                             {
  1809.                                 string[] checkLine = line.Split(
  1810.                                     new string[] { ":" },
  1811.                                     StringSplitOptions.RemoveEmptyEntries
  1812.                                 );
  1813.                                 if(1 < checkLine.Length)
  1814.                                     newLon = checkLine[1];
  1815.                             }
  1816.                         }
  1817.                     }
  1818.                     decimal tryNewDecimal;
  1819.                     if ((newLat != "" && Decimal.TryParse(newLat, out tryNewDecimal)) && (newLon != "" && Decimal.TryParse(newLat, out tryNewDecimal)))
  1820.                     {
  1821.                         VA.SetText("AVCS_SENS_OWMLAT", newLat);
  1822.                         VA.SetText("AVCS_SENS_OWMLON", newLon);
  1823.                         weatherURL = baseURL.Replace("AVCS_SENS_OWMLAT",newLat).Replace("AVCS_SENS_OWMLON",newLon).Replace("AVCS_SENS_OWMKEY",apiKey);
  1824.                     }
  1825.                     else
  1826.                     {
  1827.                         throw new GetWeatherException();
  1828.                     }
  1829.                 }
  1830.                 else
  1831.                 {
  1832.                     throw new GetWeatherException();
  1833.                 }
  1834.             }
  1835.             catch (GetWeatherException e)
  1836.             {
  1837.                 //for any expected unexpected faults
  1838.                 faultDetected = true;
  1839.                 e.GetWeatherTestException(VA);
  1840.             }
  1841.         }
  1842.        
  1843.         if (faultDetected != true)
  1844.         {
  1845.             string apiLoc = "";
  1846.             string apiMain = "";
  1847.             string apiTemp = "";
  1848.             string apiHeatIndex = "";
  1849.             string apiHumidity = "";
  1850.             string apiWindSpeed = "";
  1851.             string apiWindDir = "";
  1852.             string apiTempUnits = "°C";
  1853.             string apiWindUnits = "kph";
  1854.             string apiWindFrom = "North";
  1855.             try
  1856.             {
  1857.                 string apiReturn = "";
  1858.                 VA.SetText("~avcs_owm_return", null);
  1859.                 GetWeatherDataOnline(weatherURL,VA);
  1860.                 if (VA.GetText("~avcs_owm_return") != null)
  1861.                     apiReturn = VA.GetText("~avcs_owm_return").Replace("\"","").Replace("{","").Replace("}","");
  1862.                
  1863.                 if (apiReturn.Contains(","))
  1864.                 {
  1865.                     string[] lines = apiReturn.Split(
  1866.                         new string[] { "," },
  1867.                         StringSplitOptions.RemoveEmptyEntries
  1868.                     );
  1869.                     foreach (string line in lines)
  1870.                     {
  1871.                         if (line.Contains("name") && apiLoc == "")
  1872.                         {
  1873.                             if (line.Contains(":"))
  1874.                             {
  1875.                                 string[] checkLine = line.Split(
  1876.                                     new string[] { ":" },
  1877.                                     StringSplitOptions.RemoveEmptyEntries
  1878.                                 );
  1879.                                 if(1 < line.Length)
  1880.                                     apiLoc = checkLine[1];
  1881.                             }
  1882.                         }
  1883.                         if (line.Contains("description") && apiMain == "")
  1884.                         {
  1885.                             if (line.Contains(":"))
  1886.                             {
  1887.                                 string[] checkLine = line.Split(
  1888.                                     new string[] { ":" },
  1889.                                     StringSplitOptions.RemoveEmptyEntries
  1890.                                 );
  1891.                                 if (1 < line.Length)
  1892.                                 {
  1893.                                     apiMain = checkLine[1].Trim().ToLower();
  1894.                                 }
  1895.                                
  1896.                                 if (apiMain.StartsWith("few"))
  1897.                                 {
  1898.                                     apiMain = apiMain.Replace("few", "a few");
  1899.                                 }
  1900.                                 else if (apiMain == "clouds" )
  1901.                                 {
  1902.                                     apiMain = apiMain.Replace("clouds", "cloudy");
  1903.                                 }
  1904.                                 else if (apiMain == "sun" )
  1905.                                 {
  1906.                                     apiMain+="ny";
  1907.                                 }
  1908.                                 else if ((apiMain == "rain" ) || (apiMain == "mist" ))
  1909.                                 {
  1910.                                     apiMain+="y";
  1911.                                 }
  1912.                                 apiMain = apiMain.Replace("sky", "skies");
  1913.                             }
  1914.                         }
  1915.                         if (line.Contains("temp") && apiTemp == "")
  1916.                         {
  1917.                             if (line.Contains(":"))
  1918.                             {
  1919.                                 string[] checkLine = line.Split(
  1920.                                     new string[] { ":" },
  1921.                                     StringSplitOptions.RemoveEmptyEntries
  1922.                                 );
  1923.                                 if(1 < line.Length)
  1924.                                 {
  1925.                                     decimal convertTemp = 1;
  1926.                                     decimal convertedTemp = 1;
  1927.                                     apiTemp = checkLine[2];
  1928.                                     if (VA.GetBoolean("AVCS_SENS_OWM_UnitMetric") != true)
  1929.                                     {
  1930.                                         if (Decimal.TryParse(apiTemp, out convertTemp))
  1931.                                         {
  1932.                                             convertedTemp = ((convertTemp * 9) / 5) + 32;
  1933.                                             convertedTemp = Math.Round(convertedTemp, 0, MidpointRounding.ToEven);
  1934.                                             apiTemp = convertedTemp.ToString();
  1935.                                             apiTempUnits = "°F";
  1936.                                         }
  1937.                                     }
  1938.                                     else
  1939.                                     {
  1940.                                         if (Decimal.TryParse(apiTemp, out convertTemp))
  1941.                                         {
  1942.                                             convertedTemp = Math.Round(convertTemp, 0, MidpointRounding.ToEven);
  1943.                                             apiTemp = convertedTemp.ToString();
  1944.                                             apiTempUnits = "°C";
  1945.                                         }
  1946.                                     }
  1947.                                 }
  1948.                             }
  1949.                         }
  1950.                         if (line.Contains("feels_like") && apiHeatIndex == "")
  1951.                         {
  1952.                             if (line.Contains(":"))
  1953.                             {
  1954.                                 string[] checkLine = line.Split(
  1955.                                     new string[] { ":" },
  1956.                                     StringSplitOptions.RemoveEmptyEntries
  1957.                                 );
  1958.                                 if(1 < line.Length)
  1959.                                 {
  1960.                                     decimal convertIndex = 1;
  1961.                                     decimal convertedIndex = 1;
  1962.                                     apiHeatIndex = checkLine[1];
  1963.                                     if (VA.GetBoolean("AVCS_SENS_OWM_UnitMetric") != true)
  1964.                                     {
  1965.                                         if (Decimal.TryParse(apiHeatIndex, out convertIndex))
  1966.                                         {
  1967.                                             convertedIndex = ((convertIndex * 9) / 5) + 32;
  1968.                                             convertedIndex = Math.Round(convertedIndex, 0, MidpointRounding.ToEven);
  1969.                                             apiHeatIndex = convertedIndex.ToString();
  1970.                                             apiTempUnits = "°F";
  1971.                                         }
  1972.                                     }
  1973.                                     else
  1974.                                     {
  1975.                                         if (Decimal.TryParse(apiHeatIndex, out convertIndex))
  1976.                                         {
  1977.                                             convertedIndex = Math.Round(convertIndex, 0, MidpointRounding.ToEven);
  1978.                                             apiHeatIndex = convertedIndex.ToString();
  1979.                                             apiTempUnits = "°C";
  1980.                                         }
  1981.                                     }
  1982.                                 }
  1983.                             }
  1984.                         }
  1985.                         if (line.Contains("humidity") && apiHumidity == "")
  1986.                         {
  1987.                             if (line.Contains(":"))
  1988.                             {
  1989.                                 string[] checkLine = line.Split(
  1990.                                     new string[] { ":" },
  1991.                                     StringSplitOptions.RemoveEmptyEntries
  1992.                                 );
  1993.                                 if(1 < line.Length)
  1994.                                 {
  1995.                                     decimal convertedRH;
  1996.                                     apiHumidity = checkLine[1];
  1997.                                     if (Decimal.TryParse(apiHumidity, out convertedRH))
  1998.                                     {
  1999.                                         convertedRH = Math.Round(convertedRH, 0, MidpointRounding.ToEven);
  2000.                                         apiHumidity = convertedRH.ToString();
  2001.                                     }
  2002.                                 }
  2003.                             }
  2004.                         }
  2005.                         if (line.Contains("speed") && apiWindSpeed == "")
  2006.                         {
  2007.                             if (line.Contains(":"))
  2008.                             {
  2009.                                 string[] checkLine = line.Split(
  2010.                                     new string[] { ":" },
  2011.                                     StringSplitOptions.RemoveEmptyEntries
  2012.                                 );
  2013.                                 if(1 < line.Length)
  2014.                                 {
  2015.                                     decimal convertedSpeed;
  2016.                                     apiWindSpeed = checkLine[2];
  2017.                                     if (VA.GetBoolean("AVCS_SENS_OWM_WindMetric") != true)
  2018.                                     {
  2019.                                         if (Decimal.TryParse(apiWindSpeed, out convertedSpeed))
  2020.                                         {
  2021.                                             convertedSpeed *= 0.6214m;
  2022.                                             convertedSpeed = Math.Round(convertedSpeed, 0, MidpointRounding.ToEven);
  2023.                                             apiWindSpeed = convertedSpeed.ToString();
  2024.                                             apiWindUnits = "mph";
  2025.                                         }
  2026.                                     }
  2027.                                     else
  2028.                                     {
  2029.                                         if (Decimal.TryParse(apiWindSpeed, out convertedSpeed))
  2030.                                         {
  2031.                                             convertedSpeed = Math.Round(convertedSpeed, 0, MidpointRounding.ToEven);
  2032.                                             apiWindSpeed = convertedSpeed.ToString();
  2033.                                             apiWindUnits = "kph";
  2034.                                         }
  2035.                                     }
  2036.                                 }
  2037.                             }
  2038.                         }
  2039.                         if (line.Contains("deg") && apiWindDir == "")
  2040.                         {
  2041.                             if (line.Contains(":"))
  2042.                             {
  2043.                                 string[] checkLine = line.Split(
  2044.                                     new string[] { ":" },
  2045.                                     StringSplitOptions.RemoveEmptyEntries
  2046.                                 );
  2047.                                 if(1 < line.Length)
  2048.                                 {
  2049.                                     apiWindDir = checkLine[1];
  2050.                                     decimal convertedDir = 1;
  2051.                                    
  2052.                                     if (Decimal.TryParse(apiWindDir, out convertedDir))
  2053.                                     {
  2054.                                         if ((convertedDir > 337.5m && convertedDir <= 359m) || (convertedDir >= 0m && convertedDir < 22.5m))
  2055.                                         {
  2056.                                             apiWindFrom = "North";
  2057.                                         }
  2058.                                         else if (convertedDir >= 22.5m && convertedDir < 67.5m)
  2059.                                         {
  2060.                                             apiWindFrom = "Northeast";
  2061.                                         }
  2062.                                         else if (convertedDir >= 67.5m && convertedDir <= 112.5m)
  2063.                                         {
  2064.                                             apiWindFrom = "East";
  2065.                                         }
  2066.                                         else if (convertedDir > 112.5m && convertedDir <= 157.5m)
  2067.                                         {
  2068.                                             apiWindFrom = "Southeast";
  2069.                                         }
  2070.                                         else if (convertedDir > 157.5m && convertedDir <= 202.5m)
  2071.                                         {
  2072.                                             apiWindFrom = "South";
  2073.                                         }
  2074.                                         else if (convertedDir > 202.5m && convertedDir <= 247.5m)
  2075.                                         {
  2076.                                             apiWindFrom = "Southwest";
  2077.                                         }
  2078.                                         else if (convertedDir > 247.5m && convertedDir <= 292.5m)
  2079.                                         {
  2080.                                             apiWindFrom = "West";
  2081.                                         }
  2082.                                         else if (convertedDir > 292.5m && convertedDir <= 337.5m)
  2083.                                         {
  2084.                                             apiWindFrom = "Northwest";
  2085.                                         }
  2086.                                     }
  2087.                                 }
  2088.                             }
  2089.                            
  2090.                         }
  2091.                     }
  2092.                    
  2093.                     if (apiMain == "")
  2094.                         apiMain = "pleasant";
  2095.                    
  2096.                     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;
  2097.                     VA.SetText("~avcs_owm_test_data", apiLoc + " reports " + testReturn.Replace(" right now",""));
  2098.                     VA.SetText("~avcs_owm_test_data_tts", "Conditions are " + testReturn.Replace("°C","°").Replace("°F","°"));
  2099.                     VA.SetBoolean("AVCS_OWM_SET", true);
  2100.                 }
  2101.                 else
  2102.                 {
  2103.                     throw new GetWeatherException();
  2104.                 }
  2105.             }
  2106.             catch (GetWeatherException e)
  2107.             {
  2108.                 //for any expected unexpected faults
  2109.                 e.GetWeatherTestException(VA);
  2110.             }
  2111.         }
  2112.     }
  2113.    
  2114.     private void GetWeatherDataOnline(string apiURL, dynamic VA)
  2115.     {
  2116.         VA.SetText("~avcs_owm_return", null);
  2117.         try
  2118.         {
  2119.             string apiReturn;
  2120.             using (WebClient wc = new WebClient())
  2121.             {
  2122.                 wc.Headers.Add("Accept-Language", " en-US");
  2123.                 wc.Headers.Add("Accept", " text/html, application/xhtml+xml, */*");
  2124.                 apiReturn = wc.DownloadString(apiURL);
  2125.                 VA.SetText("~avcs_owm_return", apiReturn);
  2126.             }
  2127.            
  2128.         }
  2129.         catch (WebException ex)
  2130.         {
  2131.             if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
  2132.             {
  2133.                 var resp = (HttpWebResponse)ex.Response;
  2134.                 if (resp.StatusCode == HttpStatusCode.NotFound)// handle HTTP 404 errors
  2135.                 {
  2136.                     VA.WriteToLog("AVCS ERROR - HTTP 404 - Unable to find page at URL:","red");
  2137.                     VA.WriteToLog(apiURL,"blank");
  2138.                 }
  2139.             }
  2140.         }
  2141.     }
  2142.    
  2143.     // Functions to recolor AVCS Test buttons and button text on Mouse Hover events
  2144.     public static void buttonsTester_MouseHover(object sender, EventArgs e, dynamic VA)
  2145.     {
  2146.         if (VA.GetBoolean("AVCS_SENS_Test_GetWeather") != true)
  2147.         {
  2148.             (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
  2149.             (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2150.         }
  2151.     }
  2152.     public static void buttonsTester_MouseLeave(object sender, EventArgs e, dynamic VA)
  2153.     {
  2154.         if (VA.GetBoolean("AVCS_SENS_Test_GetWeather") != true)
  2155.         {
  2156.             (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2157.             (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2158.         }
  2159.     }
  2160.    
  2161.     // New Baselines Button Event
  2162.     private void buttonSetCity_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM, TextBox textBoxOwmCity, string defaultOwmCity, string newOwmCity)
  2163.     {
  2164.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  2165.         {
  2166.             string currentOwmCity = "";
  2167.             if (VA.GetText("AVCS_SENS_OWMCITY") != null)
  2168.                 currentOwmCity = VA.GetText("AVCS_SENS_OWMCITY");
  2169.             if (newOwmCity != defaultOwmCity && newOwmCity != currentOwmCity)
  2170.             {
  2171.                 VA.SetText("AVCS_SENS_OWM_NextDailyForecastCheck", "null");
  2172.                 VA.SetText("AVCS_SENS_OWM_FORECASTS", "");
  2173.                 VA.Command.Execute("F_SFS_SAVE_FORECAST", true);
  2174.                 VA.SetText("AVCS_SENS_OWMCITY", newOwmCity);
  2175.                 VA.SetInt("AVCS_SENS_OWM_INTERVAL", null);
  2176.                 (sender as Button).Text = " Clear User City ";
  2177.                 (sender as Button).AutoSize = true;
  2178.                 textBoxOwmCity.ReadOnly = true;
  2179.                 textBoxOwmCity.Enabled = false;
  2180.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2181.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2182.                 Functions.ResizeForm(this, ControlSpacing);
  2183.             }
  2184.             else
  2185.             {
  2186.                 VA.SetText("AVCS_SENS_OWMCITY", null);
  2187.                 (sender as Button).Text = " Save User City ";
  2188.                 textBoxOwmCity.Text = defaultOwmCity;
  2189.                 textBoxOwmCity.ReadOnly = false;
  2190.                 textBoxOwmCity.Enabled = true;
  2191.                 (sender as Button).AutoSize = true;
  2192.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2193.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2194.                 Functions.ResizeForm(this, ControlSpacing);
  2195.             }
  2196.         }
  2197.     }
  2198.    
  2199.    
  2200.     // New Baselines Button Event
  2201.     private void buttonOwmSaveKey_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM, TextBox textBoxOwmKey, string defaultOwmKey, string newOwmKey, Button buttonForecastChecks)
  2202.     {
  2203.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  2204.         {
  2205.         string currentOwmKey = "";
  2206.         Guid checkOwmKey;
  2207.         if (VA.GetText("AVCS_SENS_OWMKEY") != null)
  2208.             currentOwmKey = VA.GetText("AVCS_SENS_OWMKEY");
  2209.             if ((Guid.TryParse(newOwmKey, out checkOwmKey)) && (newOwmKey != "" && newOwmKey != defaultOwmKey && newOwmKey != currentOwmKey))
  2210.             {
  2211.                 VA.SetText("AVCS_SENS_OWMKEY", newOwmKey);
  2212.                 (sender as Button).Text = " Clear User Key ";
  2213.                 (sender as Button).AutoSize = true;
  2214.                 textBoxOwmKey.ReadOnly = true;
  2215.                 textBoxOwmKey.Enabled = false;
  2216.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2217.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2218.                 buttonForecastChecks.Enabled = true;
  2219.                 buttonForecastChecks.Visible = true;
  2220.                 Functions.ResizeForm(this, ControlSpacing);
  2221.             }
  2222.             else
  2223.             {
  2224.                 if (((sender as Button).Text == " Save User Key ") && (newOwmKey != defaultOwmKey))
  2225.                     VA.WriteToLog("Blank or invalid OWM Key entered, reverting to default key", "black");
  2226.                 if (((sender as Button).Text == " Save User Key ") && (newOwmKey == defaultOwmKey))
  2227.                     VA.WriteToLog("Enter your own user key here, otherwise default key will be used", "black");
  2228.                 VA.SetText("AVCS_SENS_OWMKEY", defaultOwmKey);
  2229.                 VA.SetBoolean("AVCS_SENS_ClearKeyNotPressed", null);
  2230.                 (sender as Button).Text = " Save User Key ";
  2231.                 textBoxOwmKey.Text = "";
  2232.                 textBoxOwmKey.ReadOnly = false;
  2233.                 textBoxOwmKey.Enabled = true;
  2234.                 buttonForecastChecks.Enabled = false;
  2235.                 buttonForecastChecks.Visible = false;
  2236.                 (sender as Button).AutoSize = true;
  2237.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2238.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2239.                 Functions.ResizeForm(this, ControlSpacing);
  2240.             }
  2241.         }
  2242.     }
  2243.    
  2244.    
  2245.     //  Final Exit Options Form Closing
  2246.     private void WeatherOptionsMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  2247.     {
  2248.         //if (result != null)
  2249.         //  VA.SetText("~~UserInput", result);
  2250.     }
  2251. }
  2252.  
  2253. //================================================END WEATHER OPTIONS=================================================================
  2254.  
  2255.  
  2256. //================================================BEGIN PROFILE CONFIG OPTIONS=================================================================
  2257. public class ProfileConfigMenuForm : Form
  2258. {
  2259.     // Initialize string variable for storing user input
  2260.     public string result = null;
  2261.     public bool defaultCountSet = false;
  2262.     public string checkPresCountsSet = " Checking Updates... , Check for Update ";
  2263.     public TextBox textBoxOwmKey;
  2264.    
  2265.     public ProfileConfigMenuForm(dynamic VA, string profileTitle, Icon icon)
  2266.     {
  2267.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  2268.         this.Text = profileTitle;
  2269.         if (icon != null)
  2270.             this.Icon = icon;
  2271.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  2272.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2273.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  2274.         this.MaximizeBox = false;
  2275.         this.MinimizeBox = false;
  2276.         this.StartPosition = FormStartPosition.CenterScreen;
  2277.         this.AutoSize = true;
  2278.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2279.         this.MinimumSize = new Size(this.Width, this.Height);
  2280.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  2281.         this.Padding = new Padding(10);
  2282.         int FontSizeS = 8;
  2283.         int FontSize = 10;
  2284.         int FontSizeM = 12;
  2285.         int FontSizeL = 16;
  2286.         int FontSizeX = 24;
  2287.         int ControlSpacing = 15;
  2288.         this.FormClosing += new FormClosingEventHandler((sender, e) => ProfileConfigMenuForm_FormClosing(sender, e, VA));
  2289.        
  2290.         // Set up labelHeader
  2291.         Label labelHeader = new Label();
  2292.         labelHeader.Text = "AVCS Profile Config";
  2293.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  2294.         labelHeader.MinimumSize = new Size(320, 0);
  2295.         labelHeader.MaximumSize = new Size(320, 0);
  2296.         labelHeader.AutoSize = true;
  2297.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  2298.         this.Controls.Add(labelHeader);
  2299.        
  2300.        
  2301.         // Set up labelSpacer
  2302.         Label labelSpacerH = new Label();
  2303.         labelSpacerH.Text = "\nChange Update Notifications Mode";
  2304.         labelSpacerH.Font = new Font(labelSpacerH.Font.FontFamily, FontSizeM);
  2305.         labelSpacerH.AutoSize = true;
  2306.         labelSpacerH.TextAlign = ContentAlignment.MiddleCenter;
  2307.         this.Controls.Add(labelSpacerH);
  2308.         // Set up buttonSetUpdateChecks
  2309.         Button buttonSetUpdateChecks = new Button();
  2310.         Button buttonSetUpdatesCheck = new Button();
  2311.         if (VA.GetInt("AVCS_SENS_UPDATES") != null)
  2312.         {
  2313.             int intervalUpdateChecks = VA.GetInt("AVCS_SENS_UPDATES");
  2314.             if (intervalUpdateChecks == 1)
  2315.             {
  2316.                 buttonSetUpdateChecks.Text = " VoiceAttack Event Log ";
  2317.             }else if (intervalUpdateChecks == 2) {
  2318.                 buttonSetUpdateChecks.Text = " Text-to-Speech Notice ";
  2319.             }else if (intervalUpdateChecks == 3) {
  2320.                 buttonSetUpdateChecks.Text = " Update Checks Off ";
  2321.             }
  2322.         }
  2323.         else
  2324.         {
  2325.             buttonSetUpdateChecks.Text = " Text-to-Speech Notice ";
  2326.             VA.SetInt("AVCS_SENS_UPDATES", 2);
  2327.         }
  2328.         buttonSetUpdateChecks.AutoSize = true;
  2329.         if (VA.GetText("AVCS_MENU_SetUpdateChecks") != null)
  2330.             checkPresCountsSet = VA.GetText("AVCS_MENU_SetUpdateChecks");
  2331.         string[] checkPresCountSet = checkPresCountsSet.Split(new string[] { "," },StringSplitOptions.RemoveEmptyEntries);
  2332.         if (checkPresCountSet.Length < 5)
  2333.             defaultCountSet = true;
  2334.         buttonSetUpdateChecks.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2335.         buttonSetUpdateChecks.Font = new Font(buttonSetUpdateChecks.Font.FontFamily, FontSizeM);
  2336.         buttonSetUpdateChecks.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2337.         buttonSetUpdatesCheck.Text = checkPresCountSet[1];
  2338.         buttonSetUpdatesCheck.AutoSize = true;
  2339.         buttonSetUpdatesCheck.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2340.         buttonSetUpdatesCheck.Font = new Font(buttonSetUpdatesCheck.Font.FontFamily, FontSizeM);
  2341.         buttonSetUpdatesCheck.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2342.         this.Controls.Add(buttonSetUpdateChecks);
  2343.         this.Controls.Add(buttonSetUpdatesCheck);
  2344.         buttonSetUpdateChecks.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2345.         buttonSetUpdateChecks.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2346.         buttonSetUpdateChecks.Click += new EventHandler((sender, e) => buttonSetUpdateChecks_Click(sender, e, VA, ControlSpacing, FontSizeM));
  2347.         buttonSetUpdatesCheck.MouseHover += new EventHandler((sender, e) => buttonSetUpdatesCheck_MouseHover(sender, e, VA, ControlSpacing, FontSizeM));
  2348.         buttonSetUpdatesCheck.MouseLeave += new EventHandler((sender, e) => buttonSetUpdatesCheck_MouseLeave(sender, e, VA, ControlSpacing, FontSizeM));
  2349.         buttonSetUpdatesCheck.Click += new EventHandler((sender, e) => buttonSetUpdatesCheck_Click(sender, e, VA, ControlSpacing, FontSizeM, checkPresCountsSet, defaultCountSet));
  2350.        
  2351.        
  2352.         // Set up labelSpacer
  2353.         Label labelSpacerCfg = new Label();
  2354.         Functions.addLabelSpacer(this, FontSizeL, labelSpacerCfg);
  2355.        
  2356.        
  2357.         // Set up buttonOwmOptions
  2358.         Button buttonOpenConfig = new Button();
  2359.         buttonOpenConfig.Text = " Open Config File ";
  2360.         buttonOpenConfig.AutoSize = true;
  2361.         buttonOpenConfig.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2362.         buttonOpenConfig.Font = new Font(buttonOpenConfig.Font.FontFamily, FontSizeM);
  2363.         buttonOpenConfig.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2364.         ToolTip OpenConfigTip = new ToolTip();
  2365.         OpenConfigTip.SetToolTip(buttonOpenConfig,"(manual editing is discouraged, careful! file reloaded anytime sensor menu opens)");
  2366.         this.Controls.Add(buttonOpenConfig);
  2367.         buttonOpenConfig.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2368.         buttonOpenConfig.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2369.         buttonOpenConfig.Click += new EventHandler((sender, e) => buttonOpenConfig_Click(sender, e, VA));
  2370.        
  2371.         // Set up buttonOpenCfgFolder
  2372.         Button buttonOpenCfgFolder = new Button();
  2373.         buttonOpenCfgFolder.Text = " Open Config Folder ";
  2374.         buttonOpenCfgFolder.AutoSize = true;
  2375.         buttonOpenCfgFolder.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2376.         buttonOpenCfgFolder.Font = new Font(buttonOpenCfgFolder.Font.FontFamily, FontSizeM);
  2377.         buttonOpenCfgFolder.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2378.         ToolTip OpenCfgFolderTip = new ToolTip();
  2379.         OpenCfgFolderTip.SetToolTip(buttonOpenCfgFolder,"(manual editing is discouraged, careful!)");
  2380.         this.Controls.Add(buttonOpenCfgFolder);
  2381.         buttonOpenCfgFolder.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2382.         buttonOpenCfgFolder.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2383.         buttonOpenCfgFolder.Click += new EventHandler((sender, e) => buttonOpenCfgFolder_Click(sender, e, VA));
  2384.        
  2385.        
  2386.        
  2387.        
  2388.         // Set up labelHelp
  2389.         LinkLabel labelHelp = new LinkLabel();
  2390.         labelHelp.Text = "\n\nNeed help? Report bugs here or post up in the\nAVCS Help && Support channel at VG Discord";
  2391.         labelHelp.LinkArea = new LinkArea(25, 4);
  2392.         labelHelp.Font = new Font(labelHelp.Font.FontFamily, FontSizeS);
  2393.         labelHelp.LinkColor = Color.FromArgb(64, 188, 255);
  2394.         labelHelp.AutoSize = true;
  2395.         labelHelp.TextAlign = ContentAlignment.MiddleCenter;
  2396.         ToolTip HelpTip = new ToolTip();
  2397.         string HelpLink = "https://veterans-gaming.com/semlerpdx/bugs/";
  2398.         HelpTip.SetToolTip(labelHelp,"Click here to report bugs at " + HelpLink);
  2399.         this.Controls.Add(labelHelp);
  2400.         labelHelp.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, HelpLink));
  2401.        
  2402.        
  2403.         // Set up buttonDiscordLink
  2404.         Button buttonDiscordLink = new Button();
  2405.         buttonDiscordLink.Text = " VG DISCORD ";
  2406.         buttonDiscordLink.AutoSize = true;
  2407.         buttonDiscordLink.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2408.         buttonDiscordLink.Font = new Font(buttonDiscordLink.Font.FontFamily, FontSizeM);
  2409.         buttonDiscordLink.ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
  2410.         buttonDiscordLink.BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2411.         ToolTip DiscordLinkTip = new ToolTip();
  2412.         string DiscordLink = "https://discord.gg/xDJUjYQked";
  2413.         DiscordLinkTip.SetToolTip(buttonDiscordLink,DiscordLink);
  2414.         this.Controls.Add(buttonDiscordLink);
  2415.         buttonDiscordLink.MouseHover += new EventHandler((sender, e) => Functions.buttonsReverse_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2416.         buttonDiscordLink.MouseLeave += new EventHandler((sender, e) => Functions.buttonsReverse_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2417.         buttonDiscordLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, DiscordLink));
  2418.        
  2419.         // Set up buttonWikiLink
  2420.         Button buttonWikiLink = new Button();
  2421.         buttonWikiLink.Text = " AVCS WIKI ";
  2422.         buttonWikiLink.AutoSize = true;
  2423.         buttonWikiLink.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2424.         buttonWikiLink.Font = new Font(buttonWikiLink.Font.FontFamily, FontSizeM);
  2425.         buttonWikiLink.ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
  2426.         buttonWikiLink.BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2427.         ToolTip WikiLinkTip = new ToolTip();
  2428.         string WikiLink = "https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather/";
  2429.         WikiLinkTip.SetToolTip(buttonWikiLink, WikiLink);
  2430.         this.Controls.Add(buttonWikiLink);
  2431.         buttonWikiLink.MouseHover += new EventHandler((sender, e) => Functions.buttonsReverse_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2432.         buttonWikiLink.MouseLeave += new EventHandler((sender, e) => Functions.buttonsReverse_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2433.         buttonWikiLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, WikiLink));
  2434.                
  2435.        
  2436.        
  2437.         //===========================  FOOTER  =======================
  2438.         // Set up labelSpacer
  2439.         Label labelSpacerF = new Label();
  2440.         Functions.addLabelSpacer(this, FontSize, labelSpacerF);
  2441.        
  2442.         // Set up buttonBack
  2443.         Button buttonBack = new Button();
  2444.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  2445.        
  2446.        
  2447.         // Footer Link to AVCS Downloads Page
  2448.         LinkLabel labelOwmLink = new LinkLabel();
  2449.         labelOwmLink.Text = "Find AVCS Profiles and Updates at Veterans-Gaming.com";
  2450.         labelOwmLink.LinkArea = new LinkArea(5, 25);
  2451.         labelOwmLink.Font = new Font(labelOwmLink.Font.FontFamily, FontSizeS);
  2452.         labelOwmLink.LinkColor = Color.FromArgb(64, 188, 255);
  2453.         labelOwmLink.AutoSize = true;
  2454.         labelOwmLink.TextAlign = ContentAlignment.MiddleCenter;
  2455.         string OwmLink = "https://veterans-gaming.com/semlerpdx/downloads/";
  2456.         ToolTip OwmLinkTip = new ToolTip();
  2457.         OwmLinkTip.SetToolTip(labelOwmLink, OwmLink);
  2458.         this.Controls.Add(labelOwmLink);
  2459.         labelOwmLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, OwmLink));
  2460.        
  2461.         // Show Options Form
  2462.         Functions.ResizeForm(this, ControlSpacing);
  2463.         Functions.ShowForm(this);
  2464.     }
  2465.    
  2466.    
  2467.     // Change Updates Notifications Mode Button Event
  2468.     private void buttonSetUpdateChecks_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
  2469.     {
  2470.         if (VA.GetInt("AVCS_SENS_UPDATES") != null)
  2471.         {
  2472.             int checkUpdateCheckMode = VA.GetInt("AVCS_SENS_UPDATES");
  2473.             if (checkUpdateCheckMode == 1)
  2474.             {
  2475.                 VA.SetInt("AVCS_SENS_UPDATES", 2);
  2476.                 (sender as Button).Text = " Text-to-Speech Notice ";
  2477.                 (sender as Button).AutoSize = true;
  2478.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2479.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2480.                 Functions.ResizeForm(this, ControlSpacing);
  2481.             }else if (checkUpdateCheckMode == 2) {
  2482.                 VA.SetInt("AVCS_SENS_UPDATES", 3);
  2483.                 (sender as Button).Text = " Update Checks Off ";
  2484.                 (sender as Button).AutoSize = true;
  2485.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2486.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2487.                 Functions.ResizeForm(this, ControlSpacing);
  2488.             }else if (checkUpdateCheckMode == 3) {
  2489.                 VA.SetInt("AVCS_SENS_UPDATES", 1);
  2490.                 (sender as Button).Text = " VoiceAttack Event Log ";
  2491.                 (sender as Button).AutoSize = true;
  2492.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2493.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2494.                 Functions.ResizeForm(this, ControlSpacing);
  2495.             }
  2496.         }
  2497.         else
  2498.         {
  2499.             VA.SetInt("AVCS_SENS_UPDATES", 2);
  2500.             (sender as Button).Text = " Text-to-Speech Notice ";
  2501.             (sender as Button).AutoSize = true;
  2502.             (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2503.             (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2504.             Functions.ResizeForm(this, ControlSpacing);
  2505.         }
  2506.     }
  2507.    
  2508.     // Update Check Button Click Event
  2509.     private void buttonSetUpdatesCheck_Click(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM, string checkPresCountsSet, bool defaultCountSet)
  2510.     {
  2511.         int checkPressCount;
  2512.         int maxPressCount = 4;
  2513.         int holdPressCount = 15;
  2514.         int maxxPressCount = 25;
  2515.         int updaterPressCount = 23;
  2516.         if (VA.GetInt("~~avcs_updatecheck_count") != null)
  2517.         {
  2518.             checkPressCount = VA.GetInt("~~avcs_updatecheck_count");
  2519.             checkPressCount += 1;
  2520.             VA.SetInt("~~avcs_updatecheck_count", checkPressCount);
  2521.         }
  2522.         else
  2523.         {
  2524.             checkPressCount = 0;
  2525.             VA.SetInt("~~avcs_updatecheck_count", checkPressCount);
  2526.         }
  2527.         if (defaultCountSet != true)
  2528.         {
  2529.             string[] checkPressCountSet = checkPresCountsSet.Split(new string[] { "," },StringSplitOptions.RemoveEmptyEntries);
  2530.             if (checkPressCount != updaterPressCount)
  2531.                 (sender as Button).Text = checkPressCountSet[checkPressCount];
  2532.             (sender as Button).AutoSize = true;
  2533.             (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2534.             (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2535.             if (checkPressCount == holdPressCount)
  2536.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, checkPressCount);
  2537.             if (checkPressCount >= updaterPressCount)
  2538.                 Functions.visitLink(checkPressCountSet[updaterPressCount]);
  2539.             if (checkPressCount >= maxxPressCount)
  2540.                 VA.SetInt("~~avcs_updatecheck_count", maxPressCount);
  2541.             Functions.ResizeForm(this, ControlSpacing);
  2542.         }
  2543.         //'Cuz it's important to have fun now and then
  2544.        
  2545.         if (VA.GetBoolean("AVCS_SENS_UPDATE_CHECK") != null)
  2546.         {
  2547.             VA.WriteToLog("Update Check already in progress...", "red");
  2548.         }
  2549.         else
  2550.         {
  2551.             if (checkPressCount < maxPressCount)
  2552.             {
  2553.                 VA.SetBoolean("AVCS_SENS_UPDATE_CHECK", true);
  2554.                 VA.SetBoolean("AVCS_SENS_VersionChecked", null);
  2555.                 try
  2556.                 {
  2557.                     VA.Command.Execute("F_SENS_UPDATE");
  2558.                 }
  2559.                 catch
  2560.                 {
  2561.                     VA.SetBoolean("AVCS_SENS_UPDATE_CHECK", null);
  2562.                     VA.SetBoolean("AVCS_SENS_VersionChecked", true);
  2563.                 }
  2564.             }
  2565.         }
  2566.     }
  2567.    
  2568.     // Open Config File Button Event
  2569.     private void buttonOpenConfig_Click(object sender, EventArgs e, dynamic VA)
  2570.     {
  2571.         Functions.buttonOpenFile(VA, VA.ParseTokens("{TXT:AVCS_SENS_SaveFilePath:}"));
  2572.     }
  2573.    
  2574.     // Open Config Folder Button Event
  2575.     private void buttonOpenCfgFolder_Click(object sender, EventArgs e, dynamic VA)
  2576.     {
  2577.         string configFolderPath = VA.ParseTokens("{TXT:AVCS_SENS_FolderPath}");
  2578.         try
  2579.         {
  2580.             Process.Start(configFolderPath);
  2581.             VA.WriteToLog("Config Folder Opened...", "green");
  2582.         }
  2583.         catch
  2584.         {
  2585.             VA.WriteToLog("AVCS ERROR: Config Folder not found at path:", "red");
  2586.             VA.WriteToLog(configFolderPath, "blank");
  2587.         }
  2588.     }
  2589.    
  2590.    
  2591.     // Functions to recolor AVCS Profile Options 'Check for Update' button and button text on Mouse Hover events
  2592.     private void buttonSetUpdatesCheck_MouseHover(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
  2593.     {
  2594.         if (VA.GetInt("~~avcs_updatecheck_count") != null)
  2595.         {
  2596.             (sender as Button).Text = " Check for Update ";
  2597.             (sender as Button).AutoSize = true;
  2598.             (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2599.             (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2600.             Functions.ResizeForm(this, ControlSpacing);
  2601.         }
  2602.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
  2603.         (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2604.     }
  2605.     private void buttonSetUpdatesCheck_MouseLeave(object sender, EventArgs e, dynamic VA, int ControlSpacing, int FontSizeM)
  2606.     {
  2607.         (sender as Button).Text = " Check for Update ";
  2608.         (sender as Button).AutoSize = true;
  2609.         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2610.         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  2611.         Functions.ResizeForm(this, ControlSpacing);
  2612.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2613.         (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2614.     }
  2615.    
  2616.    
  2617.     //  Final Exit Options Form Closing
  2618.     private void ProfileConfigMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  2619.     {
  2620.         //if (result != null)
  2621.         //  VA.SetText("~~UserInput", result);
  2622.     }
  2623. }
  2624.  
  2625. //================================================END PROFILE CONFIG OPTIONS=================================================================
  2626.  
  2627.  
  2628. //================================================BEGIN BASELINE MENU OPTIONS=================================================================
  2629. public class BaselinesMenuForm : Form
  2630. {
  2631.     // Initialize string variable for storing user input
  2632.     public string result = null;
  2633.    
  2634.     public BaselinesMenuForm(dynamic VA, string profileTitle, Icon icon)
  2635.     {
  2636.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  2637.         this.Text = profileTitle;
  2638.         if (icon != null)
  2639.             this.Icon = icon;
  2640.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  2641.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2642.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  2643.         this.MaximizeBox = false;
  2644.         this.MinimizeBox = false;
  2645.         this.StartPosition = FormStartPosition.CenterScreen;
  2646.         this.AutoSize = true;
  2647.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2648.         this.MinimumSize = new Size(this.Width, this.Height);
  2649.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  2650.         this.Padding = new Padding(10);
  2651.         int FontSizeS = 8;
  2652.         int FontSize = 10;
  2653.         int FontSizeM = 12;
  2654.         int FontSizeL = 16;
  2655.         int FontSizeX = 24;
  2656.         int ControlSpacing = 15;
  2657.         this.FormClosing += new FormClosingEventHandler((sender, e) => BaselinesMenuForm_FormClosing(sender, e, VA));
  2658.        
  2659.         // Set up labelHeader
  2660.         Label labelHeader = new Label();
  2661.         labelHeader.Text = "AVCS Sensor Baselines Menu";
  2662.         labelHeader.MinimumSize = new Size(300, 0);
  2663.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  2664.         labelHeader.AutoSize = true;
  2665.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  2666.         this.Controls.Add(labelHeader);
  2667.        
  2668.         // Set up labelSpacer
  2669.         Label labelSpacerH = new Label();
  2670.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  2671.        
  2672.        
  2673.         // Set up labelTitle
  2674.         Label labelTitle = new Label();
  2675.         labelTitle.Text = "Choose a Baseline Level to Set:";
  2676.         labelTitle.Font = new Font(labelTitle.Font.FontFamily, FontSize);
  2677.         labelTitle.AutoSize = true;
  2678.         labelTitle.MinimumSize = new Size(300, 0);
  2679.         labelTitle.TextAlign = ContentAlignment.MiddleCenter;
  2680.         this.Controls.Add(labelTitle);
  2681.        
  2682.        
  2683.         // Set up buttonSetLowBaseline
  2684.         Button buttonSetLowBaseline = new Button();
  2685.         buttonSetLowBaseline.Text = "   LOW   ";
  2686.         buttonSetLowBaseline.AutoSize = true;
  2687.         buttonSetLowBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2688.         buttonSetLowBaseline.Font = new Font(buttonSetLowBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
  2689.         buttonSetLowBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2690.         this.Controls.Add(buttonSetLowBaseline);
  2691.         buttonSetLowBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2692.         buttonSetLowBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2693.         buttonSetLowBaseline.Click += new EventHandler((sender, e) => buttonSetBaseline_Click(sender, e, VA, profileTitle, icon, "LOW"));
  2694.        
  2695.        
  2696.        
  2697.         // Set up buttonSetMediumBaseline
  2698.         Button buttonSetMediumBaseline = new Button();
  2699.         buttonSetMediumBaseline.Text = " MEDIUM ";
  2700.         buttonSetMediumBaseline.AutoSize = true;
  2701.         buttonSetMediumBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2702.         buttonSetMediumBaseline.Font = new Font(buttonSetMediumBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
  2703.         buttonSetMediumBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2704.         this.Controls.Add(buttonSetMediumBaseline);
  2705.         buttonSetMediumBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2706.         buttonSetMediumBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2707.         buttonSetMediumBaseline.Click += new EventHandler((sender, e) => buttonSetBaseline_Click(sender, e, VA, profileTitle, icon, "MEDIUM"));
  2708.        
  2709.        
  2710.        
  2711.         // Set up buttonSetHighBaseline
  2712.         Button buttonSetHighBaseline = new Button();
  2713.         buttonSetHighBaseline.Text = "  HIGH  ";
  2714.         buttonSetHighBaseline.AutoSize = true;
  2715.         buttonSetHighBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2716.         buttonSetHighBaseline.Font = new Font(buttonSetHighBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
  2717.         buttonSetHighBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2718.         this.Controls.Add(buttonSetHighBaseline);
  2719.         buttonSetHighBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2720.         buttonSetHighBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2721.         buttonSetHighBaseline.Click += new EventHandler((sender, e) => buttonSetBaseline_Click(sender, e, VA, profileTitle, icon, "HIGH"));
  2722.        
  2723.        
  2724.        
  2725.         // Set up buttonSetExtremeBaseline
  2726.         Button buttonSetExtremeBaseline = new Button();
  2727.         buttonSetExtremeBaseline.Text = " EXTREME ";
  2728.         buttonSetExtremeBaseline.AutoSize = true;
  2729.         buttonSetExtremeBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2730.         buttonSetExtremeBaseline.Font = new Font(buttonSetExtremeBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
  2731.         buttonSetExtremeBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2732.         this.Controls.Add(buttonSetExtremeBaseline);
  2733.         buttonSetExtremeBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2734.         buttonSetExtremeBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2735.         buttonSetExtremeBaseline.Click += new EventHandler((sender, e) => buttonSetBaseline_Click(sender, e, VA, profileTitle, icon, "EXTREME"));
  2736.        
  2737.        
  2738.        
  2739.        
  2740.         //===========================  FOOTER  =======================
  2741.         // Set up labelSpacer
  2742.         Label labelSpacerF = new Label();
  2743.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  2744.        
  2745.         // Set up buttonBack
  2746.         Button buttonBack = new Button();
  2747.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  2748.        
  2749.         // Footer Label
  2750.         Label labelFooter = new Label();
  2751.         Functions.addFooterLabel(this, FontSizeS, labelFooter);
  2752.        
  2753.         // Show Options Form
  2754.         Functions.ResizeForm(this, ControlSpacing);
  2755.         Functions.ShowForm(this);
  2756.     }
  2757.    
  2758.    
  2759.     // Open Sensor Options Form
  2760.     private void buttonSetBaseline_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon, string baselineToSet)
  2761.     {
  2762.         this.Hide();
  2763.         Form FormBaselinesSet = new BaselinesSetForm(VA, profileTitle, icon, baselineToSet);
  2764.         FormBaselinesSet.ShowDialog();
  2765.         this.Show();
  2766.     }
  2767.    
  2768.    
  2769.     //  Final Exit Options Form Closing
  2770.     private void BaselinesMenuForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  2771.     {
  2772.         //Baseline Form Closing final actions (if any)
  2773.     }
  2774. }
  2775. //================================================END BASELINE MENU OPTIONS=================================================================
  2776.  
  2777.  
  2778. //================================================BEGIN BASELINE SET FORM=================================================================
  2779. public class BaselinesSetForm : Form
  2780. {
  2781.     // Initialize string variable for storing user input
  2782.     public string result = null;
  2783.    
  2784.     public BaselinesSetForm(dynamic VA, string profileTitle, Icon icon, string baselinesToSet)
  2785.     {
  2786.         TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
  2787.         string textThisBaseline = textInfo.ToTitleCase(baselinesToSet.ToLower());
  2788.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  2789.         this.Text = profileTitle;
  2790.         if (icon != null)
  2791.             this.Icon = icon;
  2792.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  2793.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2794.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  2795.         this.MaximizeBox = false;
  2796.         this.MinimizeBox = false;
  2797.         this.StartPosition = FormStartPosition.CenterScreen;
  2798.         this.AutoSize = true;
  2799.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2800.         this.MinimumSize = new Size(this.Width, this.Height);
  2801.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  2802.         this.Padding = new Padding(20);
  2803.         int FontSizeS = 8;
  2804.         int FontSize = 10;
  2805.         int FontSizeM = 12;
  2806.         int FontSizeL = 16;
  2807.         int FontSizeX = 24;
  2808.         int ControlSpacing = 15;
  2809.         this.FormClosing += new FormClosingEventHandler((sender, e) => BaselinesSetForm_FormClosing(sender, e, VA));
  2810.        
  2811.         // Set up labelHeader
  2812.         Label labelHeader = new Label();
  2813.         labelHeader.Text = "Record " + textThisBaseline + " Baseline State";
  2814.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  2815.         labelHeader.AutoSize = true;
  2816.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  2817.         this.Controls.Add(labelHeader);
  2818.        
  2819.         // Set up labelSpacer
  2820.         Label labelSpacerH = new Label();
  2821.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  2822.        
  2823.        
  2824.        
  2825.         // CC License Link and Credit to AVCS Profiles
  2826.         Label labelSetBaselineSteps = new Label();
  2827.         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";
  2828.         labelSetBaselineSteps.Font = new Font(labelSetBaselineSteps.Font.FontFamily, FontSizeM);
  2829.         labelSetBaselineSteps.AutoSize = true;
  2830.         labelSetBaselineSteps.TextAlign = ContentAlignment.MiddleLeft;
  2831.         labelSetBaselineSteps.MinimumSize = new Size(480, 0);
  2832.         labelSetBaselineSteps.MaximumSize = new Size(480, 0);
  2833.         this.Controls.Add(labelSetBaselineSteps);
  2834.        
  2835.        
  2836.         // Set up buttonSaveBaseline
  2837.         Button buttonSaveBaseline = new Button();
  2838.         buttonSaveBaseline.Text = " SAVE " + baselinesToSet + " BASELINE ";
  2839.         buttonSaveBaseline.AutoSize = true;
  2840.         buttonSaveBaseline.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2841.         buttonSaveBaseline.Font = new Font(buttonSaveBaseline.Font.FontFamily, FontSizeM, FontStyle.Bold);
  2842.         buttonSaveBaseline.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2843.         buttonSaveBaseline.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2844.         this.Controls.Add(buttonSaveBaseline);
  2845.         buttonSaveBaseline.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  2846.         buttonSaveBaseline.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  2847.         buttonSaveBaseline.Click += new EventHandler((sender, e) => buttonSaveBaseline_Click(sender, e, VA, baselinesToSet));
  2848.        
  2849.        
  2850.         Label labelSetBaselineTips = new Label();
  2851.         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.";
  2852.         labelSetBaselineTips.Font = new Font(labelSetBaselineTips.Font.FontFamily, FontSizeM);
  2853.         labelSetBaselineTips.AutoSize = true;
  2854.         labelSetBaselineTips.TextAlign = ContentAlignment.MiddleLeft;
  2855.         labelSetBaselineTips.MinimumSize = new Size(480, 0);
  2856.         labelSetBaselineTips.MaximumSize = new Size(480, 0);
  2857.         this.Controls.Add(labelSetBaselineTips);
  2858.        
  2859.        
  2860.        
  2861.         //===========================  FOOTER  =======================
  2862.         // Set up labelSpacer
  2863.         Label labelSpacerF = new Label();
  2864.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  2865.        
  2866.         // Set up buttonBack
  2867.         Button buttonBack = new Button();
  2868.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  2869.        
  2870.        
  2871.         // Footer Label
  2872.         Label labelFooter = new Label();
  2873.         Functions.addFooterLabel(this, FontSizeS, labelFooter);
  2874.        
  2875.        
  2876.         // Show Options Form
  2877.         Functions.ResizeForm(this, ControlSpacing);
  2878.         Functions.ShowForm(this);
  2879.     }
  2880.    
  2881.    
  2882.     // Save Baseline Button Click Event
  2883.     private void buttonSaveBaseline_Click(object sender, EventArgs e, dynamic VA, string thisBaseline)
  2884.     {
  2885.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  2886.         {
  2887.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
  2888.             int checkInterval = 0;
  2889.             int minimumInterval = 10;
  2890.             if (VA.GetInt("AVCS_SENS_MAIN_INTERVAL") != null)
  2891.             {
  2892.                 checkInterval = VA.GetInt("AVCS_SENS_MAIN_INTERVAL");
  2893.             }
  2894.            
  2895.             if (VA.GetBoolean("AVCS_SENS_Monitoring") != true || VA.GetBoolean("AVCS_SENS_Logging") != true)
  2896.             {
  2897.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  2898.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  2899.                 (sender as Button).Enabled = false;
  2900.                 VA.WriteToLog("Sensor Monitoring must be enabled to establish baseline data!", "red");
  2901.                 VA.WriteToLog("Please begin Sensor Monitoring. See user guide for more information.", "blank");
  2902.                 VA.SetText("AVCS_SENS_TTS_WILDCARD", "Sensor monitoring data not detected. Please enable monitoring first.");
  2903.                 VA.Command.Execute("F_SAY_TTS", true);
  2904.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2905.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2906.                 (sender as Button).Enabled = true;
  2907.             }
  2908.             else
  2909.             {
  2910.                 if (VA.GetDecimal("AVCS_SENS_TempDHTf") != null && checkInterval >= minimumInterval)
  2911.                 {
  2912.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  2913.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  2914.                     (sender as Button).Enabled = false;
  2915.                     VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", thisBaseline.ToUpper());
  2916.                     VA.SetText("AVCS_SENS_TTS_WILDCARD", "Gathering " + thisBaseline.ToLower() + " baseline data now.");
  2917.                     VA.WriteToLog("AVCS is Gathering Baseline Data! This may take up to a minute to complete!", "red");
  2918.                     VA.Command.Execute("F_SAY_TTS", true);
  2919.                     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)
  2920.                     {
  2921.                         VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", "LOW");
  2922.                         VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", "LOW");
  2923.                         VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
  2924.                         while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
  2925.                             Thread.Sleep(100);
  2926.                         Thread.Sleep(1500);
  2927.                         if (VA.Command.Active("F_SFS_SAVE_DATA") == true)
  2928.                         {
  2929.                             while (VA.Command.Active("F_SFS_SAVE_DATA") == true)
  2930.                                 Thread.Sleep(50);
  2931.                         }
  2932.                         VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", "MEDIUM");
  2933.                         VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", "MEDIUM");
  2934.                         VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
  2935.                         while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
  2936.                             Thread.Sleep(100);
  2937.                         Thread.Sleep(1500);
  2938.                         if (VA.Command.Active("F_SFS_SAVE_DATA") == true)
  2939.                         {
  2940.                             while (VA.Command.Active("F_SFS_SAVE_DATA") == true)
  2941.                                 Thread.Sleep(50);
  2942.                         }
  2943.                         VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", "HIGH");
  2944.                         VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", "HIGH");
  2945.                         VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
  2946.                         while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
  2947.                             Thread.Sleep(100);
  2948.                         Thread.Sleep(1500);
  2949.                         if (VA.Command.Active("F_SFS_SAVE_DATA") == true)
  2950.                         {
  2951.                             while (VA.Command.Active("F_SFS_SAVE_DATA") == true)
  2952.                                 Thread.Sleep(50);
  2953.                         }
  2954.                         VA.SetText("AVCS_SENS_SET_BASELINE_LEVEL", "EXTREME");
  2955.                         VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", "EXTREME");
  2956.                         VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
  2957.                         while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
  2958.                             Thread.Sleep(50);
  2959.                         Thread.Sleep(1500);
  2960.                         if (VA.Command.Active("F_SFS_SAVE_DATA") == true)
  2961.                         {
  2962.                             while (VA.Command.Active("F_SFS_SAVE_DATA") == true)
  2963.                                 Thread.Sleep(50);
  2964.                         }
  2965.                     }
  2966.                     else
  2967.                     {
  2968.                         VA.SetText("AVCS_SENS_SETTING_BASELINE_LEVEL", thisBaseline.ToUpper());
  2969.                         VA.SetBoolean("AVCS_SENS_GET_BASELINE", true);
  2970.                         while (VA.GetBoolean("AVCS_SENS_GET_BASELINE") == true)
  2971.                             Thread.Sleep(50);
  2972.                     }
  2973.                     VA.SetText("AVCS_SENS_TTS_WILDCARD", thisBaseline + " sensor data baseline is now complete.");
  2974.                     VA.Command.Execute("F_SAY_TTS", false);
  2975.                     VA.SetBoolean("AVCS_SENS_SET_BASELINE_LEVEL_" + thisBaseline.ToUpper(), true);
  2976.                     this.Close();
  2977.                 }
  2978.                 else
  2979.                 {
  2980.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  2981.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  2982.                     (sender as Button).Enabled = false;
  2983.                     if (checkInterval < minimumInterval)
  2984.                     {
  2985.                         VA.WriteToLog("Not enough data points have been established yet...", "red");
  2986.                         VA.WriteToLog("Please wait at least 30 seconds after enabling monitoring before setting baselines", "blank");
  2987.                         VA.SetText("AVCS_SENS_TTS_WILDCARD", "Cannot establish baselines yet. Please wait at least 30 seconds.");
  2988.                     }
  2989.                     else
  2990.                     {
  2991.                         VA.WriteToLog("Cannot locate AVCS-DHT1 External Temperature Sensor data!", "red");
  2992.                         VA.WriteToLog("Please check settings. See user guide for more information.", "blank");
  2993.                         VA.SetText("AVCS_SENS_TTS_WILDCARD", "External temperature sensor data not detected. Please check device or settings.");
  2994.                     }
  2995.                     VA.Command.Execute("F_SAY_TTS", true);
  2996.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  2997.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  2998.                     (sender as Button).Enabled = true;
  2999.                 }
  3000.             }
  3001.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
  3002.         }
  3003.     }
  3004.    
  3005.     //  Final Exit Options Form Closing
  3006.     private void BaselinesSetForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  3007.     {
  3008.         //if (result != null)
  3009.         //  VA.SetText("~~UserInput", result);
  3010.     }
  3011. }
  3012. //================================================END BASELINE SET FORM=================================================================
  3013.  
  3014.  
  3015. //================================================BEGIN CREDITS FORM=================================================================
  3016. public class CreditsForm : Form
  3017. {
  3018.     // Initialize string variable for storing user input
  3019.     public string result = null;
  3020.    
  3021.     public CreditsForm(dynamic VA, string profileTitle, Icon icon)
  3022.     {
  3023.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  3024.         this.Text = profileTitle;
  3025.         if (icon != null)
  3026.             this.Icon = icon;
  3027.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  3028.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  3029.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  3030.         this.MaximizeBox = false;
  3031.         this.MinimizeBox = false;
  3032.         this.StartPosition = FormStartPosition.CenterScreen;
  3033.         this.AutoSize = true;
  3034.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3035.         this.MinimumSize = new Size(this.Width, this.Height);
  3036.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  3037.         this.Padding = new Padding(10);
  3038.         int FontSizeS = 8;
  3039.         int FontSize = 10;
  3040.         int FontSizeM = 12;
  3041.         int FontSizeL = 16;
  3042.         int FontSizeX = 24;
  3043.         int ControlSpacing = 1;
  3044.         this.FormClosing += new FormClosingEventHandler((sender, e) => CreditsForm_FormClosing(sender, e, VA));
  3045.        
  3046.         // Set up labelSpacer
  3047.         Label labelSpacerT = new Label();
  3048.         Functions.addLabelSpacer(this, 8, labelSpacerT);
  3049.        
  3050.         // Set up labelHeader
  3051.         Label labelHeader = new Label();
  3052.         labelHeader.Text = "CREDITS";
  3053.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  3054.         labelHeader.AutoSize = true;
  3055.         labelHeader.MinimumSize = new Size(300, 0);
  3056.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  3057.         this.Controls.Add(labelHeader);
  3058.        
  3059.         // Set up labelSpacer
  3060.         Label labelSpacerH = new Label();
  3061.         Functions.addLabelSpacer(this, 8, labelSpacerH);
  3062.        
  3063.        
  3064.        
  3065.         // Set up AVCS Credits
  3066.         Label labelByLine1 = new Label();
  3067.         labelByLine1.Text = " Thanks for checking out my AVCS Profiles! ";
  3068.         labelByLine1.Font = new Font(labelByLine1.Font.FontFamily, FontSizeM);
  3069.         labelByLine1.AutoSize = true;
  3070.         labelByLine1.TextAlign = ContentAlignment.MiddleCenter;
  3071.         this.Controls.Add(labelByLine1);
  3072.        
  3073.        
  3074.         // Set up labelSpacer
  3075.         Label labelSpacerCC2a = new Label();
  3076.         Functions.addLabelSpacer(this, 8, labelSpacerCC2a);
  3077.        
  3078.         // Footer Link and Credit to VoiceAttack Forums
  3079.         Label labelNonAffiliate = new Label();
  3080.         labelNonAffiliate.Text = "(AIDA64 and OpenWeather are not affiliated with AVCS)";
  3081.         labelNonAffiliate.Font = new Font(labelNonAffiliate.Font.FontFamily, FontSizeS);
  3082.         labelNonAffiliate.AutoSize = true;
  3083.         labelNonAffiliate.TextAlign = ContentAlignment.MiddleCenter;
  3084.         this.Controls.Add(labelNonAffiliate);
  3085.        
  3086.         // Set up labelSpacer
  3087.         Label labelSpacerCC2b = new Label();
  3088.         Functions.addLabelSpacer(this, 6, labelSpacerCC2b);
  3089.        
  3090.        
  3091.         // Credits Link to Open Weather Map
  3092.         LinkLabel labelOwmLink = new LinkLabel();
  3093.         labelOwmLink.Text = "Weather data provided by OpenWeather (TM)";
  3094.         labelOwmLink.LinkArea = new LinkArea(25, 11);
  3095.         labelOwmLink.Font = new Font(labelOwmLink.Font.FontFamily, FontSize);
  3096.         labelOwmLink.LinkColor = Color.FromArgb(64, 188, 255);
  3097.         labelOwmLink.AutoSize = true;
  3098.         labelOwmLink.TextAlign = ContentAlignment.MiddleCenter;
  3099.         ToolTip OwmLinkTip = new ToolTip();
  3100.         string OwmLink = "https://openweathermap.org/";
  3101.         OwmLinkTip.SetToolTip(labelOwmLink, OwmLink);
  3102.         this.Controls.Add(labelOwmLink);
  3103.         labelOwmLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, OwmLink));
  3104.        
  3105.         // CC License Link and Credit to Open Weather Map
  3106.         LinkLabel labelCC2Link = new LinkLabel();
  3107.         labelCC2Link.Text = "under their CC BY-SA 4.0 license";
  3108.         labelCC2Link.LinkArea = new LinkArea(12, 12);
  3109.         labelCC2Link.Font = new Font(labelCC2Link.Font.FontFamily, FontSize);
  3110.         labelCC2Link.LinkColor = Color.FromArgb(64, 188, 255);
  3111.         labelCC2Link.AutoSize = true;
  3112.         labelCC2Link.TextAlign = ContentAlignment.MiddleCenter;
  3113.         ToolTip CC2LinkTip = new ToolTip();
  3114.         string CC2Link = "https://creativecommons.org/licenses/by-sa/4.0/";
  3115.         CC2LinkTip.SetToolTip(labelCC2Link,CC2Link);
  3116.         this.Controls.Add(labelCC2Link);
  3117.         labelCC2Link.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, CC2Link));
  3118.        
  3119.         // Set up labelSpacer
  3120.         Label labelSpacerA = new Label();
  3121.         Functions.addLabelSpacer(this, 8, labelSpacerA);
  3122.        
  3123.        
  3124.         // Credits to AIDA64 / FinalWire Ltd.
  3125.         LinkLabel labelAidaTrademark = new LinkLabel();
  3126.         labelAidaTrademark.Text = "AIDA64 is a Registered Trademark of FinalWire Ltd.";
  3127.         labelAidaTrademark.Font = new Font(labelAidaTrademark.Font.FontFamily, FontSize);
  3128.         labelAidaTrademark.LinkArea = new LinkArea(0, 0); //????
  3129.         labelAidaTrademark.AutoSize = true;
  3130.         labelAidaTrademark.TextAlign = ContentAlignment.MiddleCenter;
  3131.         this.Controls.Add(labelAidaTrademark);
  3132.        
  3133.         // Credits Link to AIDA64 / FinalWire Ltd.
  3134.         LinkLabel labelAidaLink = new LinkLabel();
  3135.         labelAidaLink.Text = "©2010-" + DateTime.Now.ToString("yyyy").Trim() + " FinalWire Ltd. All rights reserved.";
  3136.         labelAidaLink.LinkArea = new LinkArea(11, 14);
  3137.         labelAidaLink.Font = new Font(labelAidaLink.Font.FontFamily, FontSize);
  3138.         labelAidaLink.LinkColor = Color.FromArgb(64, 188, 255);
  3139.         labelAidaLink.AutoSize = true;
  3140.         labelAidaLink.TextAlign = ContentAlignment.MiddleCenter;
  3141.         ToolTip AidaLinkTip = new ToolTip();
  3142.         string AidaLink = "https://www.aida64.com/";
  3143.         AidaLinkTip.SetToolTip(labelAidaLink, AidaLink);
  3144.         this.Controls.Add(labelAidaLink);
  3145.         labelAidaLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, AidaLink));
  3146.        
  3147.        
  3148.         // Set up labelSpacer
  3149.         Label labelSpacerCC3 = new Label();
  3150.         Functions.addLabelSpacer(this, 8, labelSpacerCC3);
  3151.        
  3152.        
  3153.         // Footer Link and Credit to VoiceAttack Forums
  3154.         Label labelVAForums = new Label();
  3155.         labelVAForums.Text = "Check out other awesome public profiles and";
  3156.         labelVAForums.Font = new Font(labelVAForums.Font.FontFamily, FontSize);
  3157.         labelVAForums.AutoSize = true;
  3158.         labelVAForums.TextAlign = ContentAlignment.MiddleCenter;
  3159.         this.Controls.Add(labelVAForums);
  3160.        
  3161.         // CC License Link and Credit to Open Weather Map
  3162.         LinkLabel labelVAForumLink = new LinkLabel();
  3163.         labelVAForumLink.Text = "plugins on the VoiceAttack website forums!";
  3164.         labelVAForumLink.LinkArea = new LinkArea(15, 11);
  3165.         labelVAForumLink.Font = new Font(labelVAForumLink.Font.FontFamily, FontSize);
  3166.         labelVAForumLink.LinkColor = Color.FromArgb(64, 188, 255);
  3167.         labelVAForumLink.AutoSize = true;
  3168.         labelVAForumLink.TextAlign = ContentAlignment.MiddleCenter;
  3169.         ToolTip VAForumLinkTip = new ToolTip();
  3170.         string VAForumLink = "https://forum.voiceattack.com/";
  3171.         VAForumLinkTip.SetToolTip(labelVAForumLink,VAForumLink);
  3172.         this.Controls.Add(labelVAForumLink);
  3173.         labelVAForumLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, VAForumLink));
  3174.        
  3175.        
  3176.        
  3177.         // Set up labelSpacer4
  3178.         Label labelSpacerCC4 = new Label();
  3179.         Functions.addLabelSpacer(this, 6, labelSpacerCC4);
  3180.        
  3181.        
  3182.        
  3183.         // Credits to Exergist C# Inline GUI Menu Tutorial Example
  3184.         Label labelMenuCredit = new Label();
  3185.         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!";
  3186.         labelMenuCredit.Font = new Font(labelMenuCredit.Font.FontFamily, FontSize);
  3187.         labelMenuCredit.AutoSize = true;
  3188.         labelMenuCredit.TextAlign = ContentAlignment.MiddleCenter;
  3189.         labelMenuCredit.MaximumSize = new Size(320, 0);
  3190.         this.Controls.Add(labelMenuCredit);
  3191.        
  3192.         // Set up labelSpacer
  3193.         Label labelSpacerB = new Label();
  3194.         Functions.addLabelSpacer(this, 12, labelSpacerB);
  3195.        
  3196.        
  3197.         // Set up AVCS Credits
  3198.         Label labelByLine1Content = new Label();
  3199.         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.";
  3200.         labelByLine1Content.Font = new Font(labelByLine1Content.Font.FontFamily, FontSize);
  3201.         labelByLine1Content.AutoSize = true;
  3202.         labelByLine1Content.TextAlign = ContentAlignment.MiddleCenter;
  3203.         labelByLine1Content.MaximumSize = new Size(300, 0);
  3204.         this.Controls.Add(labelByLine1Content);
  3205.        
  3206.        
  3207.         // Set up labelSpacer
  3208.         Label labelSpacerC = new Label();
  3209.         Functions.addLabelSpacer(this, 6, labelSpacerC);
  3210.        
  3211.        
  3212.         // Set up buttonCoffeeLink
  3213.         Button buttonCoffeeLink = new Button();
  3214.         buttonCoffeeLink.Text = " Buy a Coffee for this lad ";
  3215.         buttonCoffeeLink.AutoSize = true;
  3216.         buttonCoffeeLink.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3217.         buttonCoffeeLink.Font = new Font(buttonCoffeeLink.Font.FontFamily, FontSizeM);
  3218.         buttonCoffeeLink.ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
  3219.         buttonCoffeeLink.BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  3220.         ToolTip CoffeeLinkTip = new ToolTip();
  3221.         string CoffeeLink = "https://www.buymeacoffee.com/semlerpdx/";
  3222.         CoffeeLinkTip.SetToolTip(buttonCoffeeLink,CoffeeLink);
  3223.         this.Controls.Add(buttonCoffeeLink);
  3224.         buttonCoffeeLink.MouseHover += new EventHandler((sender, e) => Functions.buttonsReverse_MouseHover(sender, e, ControlSpacing, FontSizeM));
  3225.         buttonCoffeeLink.MouseLeave += new EventHandler((sender, e) => Functions.buttonsReverse_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  3226.         buttonCoffeeLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, CoffeeLink));
  3227.        
  3228.        
  3229.        
  3230.         // Set up labelSpacer
  3231.         Label labelSpacerSub1 = new Label();
  3232.         Functions.addLabelSpacer(this, 8, labelSpacerSub1);
  3233.        
  3234.         // Footer Link and Credit to VoiceAttack Forums
  3235.         Label labelByLine1Sub = new Label();
  3236.         labelByLine1Sub.Text = "If you like my projects, any support \n is greatly appreciated!";
  3237.         labelByLine1Sub.Font = new Font(labelByLine1Sub.Font.FontFamily, FontSize);
  3238.         labelByLine1Sub.AutoSize = true;
  3239.         labelByLine1Sub.TextAlign = ContentAlignment.MiddleCenter;
  3240.         this.Controls.Add(labelByLine1Sub);
  3241.        
  3242.        
  3243.         // Set up labelSpacer
  3244.         Label labelSpacerCC1 = new Label();
  3245.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerCC1);
  3246.        
  3247.        
  3248.         // CC License Link and Credit to AVCS Profiles
  3249.         LinkLabel labelCC1Link = new LinkLabel();
  3250.         labelCC1Link.Text = "AVCS Profiles are shared under CC BY-NC-ND 4.0";
  3251.         labelCC1Link.LinkArea = new LinkArea(31, 15);
  3252.         labelCC1Link.Font = new Font(labelCC1Link.Font.FontFamily, FontSize);
  3253.         labelCC1Link.LinkColor = Color.FromArgb(64, 188, 255);
  3254.         labelCC1Link.AutoSize = true;
  3255.         labelCC1Link.TextAlign = ContentAlignment.MiddleCenter;
  3256.         ToolTip CC1LinkTip = new ToolTip();
  3257.         string CC1Link = "https://creativecommons.org/licenses/by-nc-nd/4.0/";
  3258.         CC1LinkTip.SetToolTip(labelCC1Link,CC1Link);
  3259.         this.Controls.Add(labelCC1Link);
  3260.         labelCC1Link.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, CC1Link));
  3261.        
  3262.        
  3263.        
  3264.         //===========================  FOOTER  =======================
  3265.         // Set up labelSpacer
  3266.         Label labelSpacerF = new Label();
  3267.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  3268.        
  3269.         // Set up buttonBack
  3270.         Button buttonBack = new Button();
  3271.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  3272.        
  3273.        
  3274.         // Set up labelSpacer
  3275.         Label labelSpacerF2 = new Label();
  3276.         Functions.addLabelSpacer(this, 6, labelSpacerF2);
  3277.        
  3278.         // Footer Label
  3279.         Label labelFooter = new Label();
  3280.         labelFooter.Text = " - Advanced Voice Control Systems for VoiceAttack - ";
  3281.         labelFooter.Font = new Font(labelFooter.Font.FontFamily, FontSizeS);
  3282.         labelFooter.AutoSize = true;
  3283.         labelFooter.TextAlign = ContentAlignment.MiddleCenter;
  3284.         this.Controls.Add(labelFooter);
  3285.        
  3286.         // Show Options Form
  3287.         Functions.ResizeForm(this, ControlSpacing);
  3288.         Functions.ShowForm(this);
  3289.     }
  3290.    
  3291.    
  3292.     //  Final Exit Options Form Closing
  3293.     private void CreditsForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  3294.     {
  3295.         //if (result != null)
  3296.         //  VA.SetText("~~UserInput", result);
  3297.     }
  3298. }
  3299.  
  3300. //================================================END CREDITS FORM=================================================================
  3301.  
  3302.  
  3303. //================================================BEGIN GUIDE FORM=================================================================
  3304. public class GuideForm : Form
  3305. {
  3306.     // Initialize string variable for storing user input
  3307.     public string result = null;
  3308.    
  3309.     public GuideForm(dynamic VA, string profileTitle, Icon icon)
  3310.     {
  3311.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  3312.         this.Text = profileTitle;
  3313.         if (icon != null)
  3314.             this.Icon = icon;
  3315.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  3316.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  3317.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  3318.         this.MaximizeBox = false;
  3319.         this.MinimizeBox = false;
  3320.         this.StartPosition = FormStartPosition.CenterScreen;
  3321.         this.AutoSize = true;
  3322.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3323.         this.MinimumSize = new Size(this.Width, this.Height);
  3324.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  3325.         this.Padding = new Padding(20);
  3326.         int FontSizeS = 8;
  3327.         int FontSize = 10;
  3328.         int FontSizeM = 12;
  3329.         int FontSizeL = 16;
  3330.         int FontSizeX = 24;
  3331.         int ControlSpacing = 1;
  3332.         this.FormClosing += new FormClosingEventHandler((sender, e) => GuideForm_FormClosing(sender, e, VA));
  3333.        
  3334.         // Set up labelSpacer
  3335.         Label labelSpacerH1 = new Label();
  3336.         Functions.addLabelSpacer(this, 8, labelSpacerH1);
  3337.        
  3338.         // Set up labelHeader
  3339.         Label labelHeader = new Label();
  3340.         labelHeader.Text = "USER GUIDES";
  3341.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  3342.         labelHeader.AutoSize = true;
  3343.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  3344.         this.Controls.Add(labelHeader);
  3345.        
  3346.         // Set up labelSpacer
  3347.         Label labelSpacerH2 = new Label();
  3348.         Functions.addLabelSpacer(this, 20, labelSpacerH2);
  3349.        
  3350.         // Set up buttonSharedMem
  3351.         Button buttonSharedMem = new Button();
  3352.         buttonSharedMem.Text = "  Sensors Setup Info  ";
  3353.         buttonSharedMem.AutoSize = true;
  3354.         buttonSharedMem.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3355.         buttonSharedMem.Font = new Font(buttonSharedMem.Font.FontFamily, FontSizeM, FontStyle.Bold);
  3356.         buttonSharedMem.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  3357.         this.Controls.Add(buttonSharedMem);
  3358.         buttonSharedMem.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  3359.         buttonSharedMem.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  3360.         buttonSharedMem.Click += new EventHandler((sender, e) => buttonSharedMem_Click(sender, e, VA, profileTitle, icon));
  3361.        
  3362.         // Set up labelSpacer
  3363.         Label labelSpacer1 = new Label();
  3364.         Functions.addLabelSpacer(this, 8, labelSpacer1);
  3365.        
  3366.         // Set up buttonReportsInfo
  3367.         Button buttonReportsInfo = new Button();
  3368.         buttonReportsInfo.Text = " Sensor Reports Use ";
  3369.         buttonReportsInfo.AutoSize = true;
  3370.         buttonReportsInfo.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3371.         buttonReportsInfo.Font = new Font(buttonReportsInfo.Font.FontFamily, FontSizeM, FontStyle.Bold);
  3372.         buttonReportsInfo.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  3373.         //ToolTip OwmMonitoringTip = new ToolTip();
  3374.         //OwmMonitoringTip.SetToolTip(buttonReportsInfo,"(monitoring will continue even if this menu is closed)");
  3375.         this.Controls.Add(buttonReportsInfo);
  3376.         buttonReportsInfo.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  3377.         buttonReportsInfo.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  3378.         buttonReportsInfo.Click += new EventHandler((sender, e) => buttonReportsInfo_Click(sender, e, VA, profileTitle, icon));
  3379.        
  3380.         // Set up labelSpacer
  3381.         Label labelSpacer2 = new Label();
  3382.         Functions.addLabelSpacer(this, 8, labelSpacer2);
  3383.        
  3384.         // Set up labelSpacer
  3385.         Label labelAuthorNote = new Label();
  3386.         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!";
  3387.         labelAuthorNote.Font = new Font(labelAuthorNote.Font.FontFamily, FontSize);
  3388.         labelAuthorNote.MaximumSize = new Size(420, 0);
  3389.         labelAuthorNote.AutoSize = true;
  3390.         labelAuthorNote.TextAlign = ContentAlignment.MiddleCenter;
  3391.         this.Controls.Add(labelAuthorNote);
  3392.        
  3393.         // Set up labelSpacer
  3394.         Label labelSpacer3 = new Label();
  3395.         Functions.addLabelSpacer(this, 16, labelSpacer3);
  3396.        
  3397.         // Set up buttonDiagInfo
  3398.         Button buttonDiagInfo = new Button();
  3399.         buttonDiagInfo.Text = " PC Sensors / DHT11 Info ";
  3400.         buttonDiagInfo.AutoSize = true;
  3401.         buttonDiagInfo.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3402.         buttonDiagInfo.Font = new Font(buttonDiagInfo.Font.FontFamily, FontSizeM, FontStyle.Bold);
  3403.         buttonDiagInfo.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  3404.         this.Controls.Add(buttonDiagInfo);
  3405.         buttonDiagInfo.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  3406.         buttonDiagInfo.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  3407.         buttonDiagInfo.Click += new EventHandler((sender, e) => buttonDiagInfo_Click(sender, e, VA, profileTitle, icon));
  3408.        
  3409.         // Set up labelSpacer
  3410.         Label labelSpacer4 = new Label();
  3411.         Functions.addLabelSpacer(this, 8, labelSpacer4);
  3412.        
  3413.         // Set up buttonDiagUse
  3414.         Button buttonDiagUse = new Button();
  3415.         buttonDiagUse.Text = " Sensor Diagnostics Use ";
  3416.         buttonDiagUse.AutoSize = true;
  3417.         buttonDiagUse.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3418.         buttonDiagUse.Font = new Font(buttonDiagUse.Font.FontFamily, FontSizeM, FontStyle.Bold);
  3419.         buttonDiagUse.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  3420.         this.Controls.Add(buttonDiagUse);
  3421.         buttonDiagUse.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  3422.         buttonDiagUse.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  3423.         buttonDiagUse.Click += new EventHandler((sender, e) => buttonDiagUse_Click(sender, e, VA, profileTitle, icon));
  3424.        
  3425.         // Set up labelSpacer
  3426.         Label labelSpacer5 = new Label();
  3427.         Functions.addLabelSpacer(this, 6, labelSpacer5);
  3428.        
  3429.         // Credits Link to AIDA64 / FinalWire Ltd.
  3430.         LinkLabel labelAuthorNoteLink = new LinkLabel();
  3431.         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.";
  3432.         labelAuthorNoteLink.LinkArea = new LinkArea(303, 9);
  3433.         labelAuthorNoteLink.Font = new Font(labelAuthorNoteLink.Font.FontFamily, FontSize);
  3434.         labelAuthorNoteLink.LinkColor = Color.FromArgb(64, 188, 255);
  3435.         labelAuthorNoteLink.AutoSize = true;
  3436.         labelAuthorNoteLink.MaximumSize = new Size(420, 0);
  3437.         labelAuthorNoteLink.TextAlign = ContentAlignment.MiddleCenter;
  3438.         ToolTip AuthorNoteLinkTip = new ToolTip();
  3439.         string AuthorNoteLink = "https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather/";
  3440.         AuthorNoteLinkTip.SetToolTip(labelAuthorNoteLink, AuthorNoteLink);
  3441.         this.Controls.Add(labelAuthorNoteLink);
  3442.         labelAuthorNoteLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, AuthorNoteLink));
  3443.        
  3444.        
  3445.         // Set up labelSpacer
  3446.         Label labelSpacer6 = new Label();
  3447.         Functions.addLabelSpacer(this, 16, labelSpacer6);
  3448.        
  3449.        
  3450.         // Set up buttonWeatherData
  3451.         Button buttonWeatherData = new Button();
  3452.         buttonWeatherData.Text = " Weather Data Info ";
  3453.         buttonWeatherData.AutoSize = true;
  3454.         buttonWeatherData.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3455.         buttonWeatherData.Font = new Font(buttonWeatherData.Font.FontFamily, FontSizeM, FontStyle.Bold);
  3456.         buttonWeatherData.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  3457.         this.Controls.Add(buttonWeatherData);
  3458.         buttonWeatherData.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  3459.         buttonWeatherData.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  3460.         buttonWeatherData.Click += new EventHandler((sender, e) => buttonWeatherData_Click(sender, e, VA, profileTitle, icon));
  3461.        
  3462.         // Set up labelSpacer
  3463.         Label labelSpacer7 = new Label();
  3464.         Functions.addLabelSpacer(this, 8, labelSpacer7);
  3465.        
  3466.        
  3467.         // Set up buttonWeatherOptions
  3468.         Button buttonWeatherOptions = new Button();
  3469.         buttonWeatherOptions.Text = " Weather Options Info ";
  3470.         buttonWeatherOptions.AutoSize = true;
  3471.         buttonWeatherOptions.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3472.         buttonWeatherOptions.Font = new Font(buttonWeatherOptions.Font.FontFamily, FontSizeM, FontStyle.Bold);
  3473.         buttonWeatherOptions.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  3474.         this.Controls.Add(buttonWeatherOptions);
  3475.         buttonWeatherOptions.MouseHover += new EventHandler((sender, e) => Functions.buttons_MouseHover(sender, e, ControlSpacing, FontSizeM));
  3476.         buttonWeatherOptions.MouseLeave += new EventHandler((sender, e) => Functions.buttons_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  3477.         buttonWeatherOptions.Click += new EventHandler((sender, e) => buttonWeatherOptions_Click(sender, e, VA, profileTitle, icon));
  3478.        
  3479.        
  3480.         // Set up labelSpacer
  3481.         Label labelSpacer8 = new Label();
  3482.         Functions.addLabelSpacer(this, 16, labelSpacer8);
  3483.        
  3484.        
  3485.         //===========================  FOOTER  =======================
  3486.         // Set up labelSpacer
  3487.         Label labelSpacerF = new Label();
  3488.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  3489.        
  3490.         // Set up buttonBack
  3491.         Button buttonBack = new Button();
  3492.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  3493.        
  3494.         // Set up labelSpacer
  3495.         Label labelSpacer9 = new Label();
  3496.         Functions.addLabelSpacer(this, 8, labelSpacer9);
  3497.        
  3498.        
  3499.         // Footer Label Non-Affiliated
  3500.         Label labelAuthorNote3 = new Label();
  3501.         labelAuthorNote3.Text = "(AIDA64 and OpenWeather are not affiliated with AVCS)";
  3502.         labelAuthorNote3.Font = new Font(labelAuthorNote3.Font.FontFamily, FontSizeS);
  3503.         labelAuthorNote3.AutoSize = true;
  3504.         labelAuthorNote3.TextAlign = ContentAlignment.MiddleCenter;
  3505.         this.Controls.Add(labelAuthorNote3);
  3506.         // Footer Link and Credit to AIDA64/FinalWire
  3507.         LinkLabel labelFinalWireLink = new LinkLabel();
  3508.         Functions.addFinalWireLinkFooterLabel2(VA, this, FontSizeS, labelFinalWireLink);
  3509.         // Footer Link and Credit to Open Weather Map
  3510.         LinkLabel labelOwmFooterLink = new LinkLabel();
  3511.         Functions.addOwmLinkFooterLabel2(VA, this, FontSizeS, labelOwmFooterLink);
  3512.        
  3513.         // Show Options Form
  3514.         Functions.ResizeForm(this, ControlSpacing);
  3515.         Functions.ShowForm(this);
  3516.     }
  3517.    
  3518.     // Open Shared Memory Info Form
  3519.     private void buttonSharedMem_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  3520.     {
  3521.         this.Hide();
  3522.         Form FormOpenGuide = new GuideSharedMemForm(VA, profileTitle, icon);
  3523.         FormOpenGuide.ShowDialog();
  3524.         this.Show();
  3525.     }
  3526.    
  3527.     // Open Sensor Reports Info Form
  3528.     private void buttonReportsInfo_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  3529.     {
  3530.         this.Hide();
  3531.         Form FormOpenGuide = new GuideReportsForm(VA, profileTitle, icon);
  3532.         FormOpenGuide.ShowDialog();
  3533.         this.Show();
  3534.     }
  3535.    
  3536.     // Open Sensor Diagnostics Info Form
  3537.     private void buttonDiagInfo_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  3538.     {
  3539.         this.Hide();
  3540.         Form FormOpenGuide = new GuideDiagnosticsForm(VA, profileTitle, icon);
  3541.         FormOpenGuide.ShowDialog();
  3542.         this.Show();
  3543.     }
  3544.    
  3545.     // Open Sensor Diagnostics Info Form
  3546.     private void buttonDiagUse_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  3547.     {
  3548.         this.Hide();
  3549.         Form FormOpenGuide = new GuideDiagnosticsUseForm(VA, profileTitle, icon);
  3550.         FormOpenGuide.ShowDialog();
  3551.         this.Show();
  3552.     }
  3553.    
  3554.     // Open Weather Data Info Form
  3555.     private void buttonWeatherData_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  3556.     {
  3557.         this.Hide();
  3558.         Form FormOpenGuide = new GuideWeatherDataForm(VA, profileTitle, icon);
  3559.         FormOpenGuide.ShowDialog();
  3560.         this.Show();
  3561.     }
  3562.    
  3563.     // Open Weather Options Info Form
  3564.     private void buttonWeatherOptions_Click(object sender, EventArgs e, dynamic VA, string profileTitle, Icon icon)
  3565.     {
  3566.         this.Hide();
  3567.         Form FormOpenGuide = new GuideWeatherOptionsForm(VA, profileTitle, icon);
  3568.         FormOpenGuide.ShowDialog();
  3569.         this.Show();
  3570.     }
  3571.    
  3572.    
  3573.     //  Final Exit Options Form Closing
  3574.     private void GuideForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  3575.     {
  3576.         //if (result != null)
  3577.         //  VA.SetText("~~UserInput", result);
  3578.     }
  3579. }
  3580.  
  3581. //================================================END GUIDE FORM=================================================================
  3582.  
  3583.  
  3584. //================================================BEGIN GUIDE SHAREDMEM FORM=================================================================
  3585. public class GuideSharedMemForm : Form
  3586. {
  3587.     // Initialize string variable for storing user input
  3588.     public string result = null;
  3589.    
  3590.     public GuideSharedMemForm(dynamic VA, string profileTitle, Icon icon)
  3591.     {
  3592.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  3593.         this.Text = profileTitle;
  3594.         if (icon != null)
  3595.             this.Icon = icon;
  3596.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  3597.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  3598.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  3599.         this.MaximizeBox = false;
  3600.         this.MinimizeBox = false;
  3601.         this.StartPosition = FormStartPosition.CenterScreen;
  3602.         this.AutoSize = true;
  3603.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3604.         this.MinimumSize = new Size(this.Width, this.Height);
  3605.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  3606.         this.Padding = new Padding(20);
  3607.         int FontSizeS = 8;
  3608.         int FontSize = 10;
  3609.         int FontSizeM = 12;
  3610.         int FontSizeL = 16;
  3611.         int FontSizeX = 24;
  3612.         int ControlSpacing = 15;
  3613.         this.FormClosing += new FormClosingEventHandler((sender, e) => GuideSharedMemForm_FormClosing(sender, e, VA));
  3614.        
  3615.         // Set up labelHeader
  3616.         Label labelHeader = new Label();
  3617.         labelHeader.Text = "Setup AIDA64 Shared Memory Sensor Data";
  3618.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  3619.         labelHeader.AutoSize = true;
  3620.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  3621.         this.Controls.Add(labelHeader);
  3622.        
  3623.         // Set up labelSpacer
  3624.         Label labelSpacerH = new Label();
  3625.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  3626.        
  3627.         // Guide Line 1
  3628.         Label labelInfoLine1 = new Label();
  3629.         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.";
  3630.         labelInfoLine1.Font = new Font(labelInfoLine1.Font.FontFamily, FontSizeM);
  3631.         labelInfoLine1.AutoSize = true;
  3632.         labelInfoLine1.TextAlign = ContentAlignment.MiddleLeft;
  3633.         labelInfoLine1.MinimumSize = new Size(750, 0);
  3634.         labelInfoLine1.MaximumSize = new Size(750, 0);
  3635.         this.Controls.Add(labelInfoLine1);
  3636.        
  3637.        
  3638.         // Guide Line 2 (with link)
  3639.         LinkLabel labelSharedMem = new LinkLabel();
  3640.         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.";
  3641.         labelSharedMem.LinkArea = new LinkArea(100, 4);
  3642.         labelSharedMem.Font = new Font(labelSharedMem.Font.FontFamily, FontSizeM);
  3643.         labelSharedMem.LinkColor = Color.FromArgb(64, 188, 255);
  3644.         labelSharedMem.AutoSize = true;
  3645.         labelSharedMem.TextAlign = ContentAlignment.MiddleLeft;
  3646.         labelSharedMem.MinimumSize = new Size(750, 0);
  3647.         labelSharedMem.MaximumSize = new Size(750, 0);
  3648.         ToolTip SharedMemTip = new ToolTip();
  3649.         string SharedMemLink = @"https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather-img1/";
  3650.         SharedMemTip.SetToolTip(labelSharedMem,"Click here to view image at: " + SharedMemLink);
  3651.         this.Controls.Add(labelSharedMem);
  3652.         labelSharedMem.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, SharedMemLink));
  3653.        
  3654.         // Guide Line 3
  3655.         Label labelInfoLine3 = new Label();
  3656.         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.";
  3657.         labelInfoLine3.Font = new Font(labelInfoLine3.Font.FontFamily, FontSizeM);
  3658.         labelInfoLine3.AutoSize = true;
  3659.         labelInfoLine3.TextAlign = ContentAlignment.MiddleLeft;
  3660.         labelInfoLine3.MinimumSize = new Size(750, 0);
  3661.         labelInfoLine3.MaximumSize = new Size(750, 0);
  3662.         this.Controls.Add(labelInfoLine3);
  3663.        
  3664.        
  3665.        
  3666.        
  3667.         //===========================  FOOTER  =======================
  3668.         // Set up labelSpacer
  3669.         Label labelSpacerF = new Label();
  3670.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  3671.        
  3672.         // Set up buttonBack
  3673.         Button buttonBack = new Button();
  3674.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  3675.        
  3676.         // Footer Link and Credit to AIDA64/FinalWire
  3677.         LinkLabel labelFinalWireLink = new LinkLabel();
  3678.         Functions.addFinalWireLinkFooterLabel(VA, this, FontSizeS, labelFinalWireLink);
  3679.        
  3680.         // Show Options Form
  3681.         Functions.ResizeForm(this, ControlSpacing);
  3682.         Functions.ShowForm(this);
  3683.     }
  3684.    
  3685.    
  3686.     //  Final Exit Options Form Closing
  3687.     private void GuideSharedMemForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  3688.     {
  3689.         //if (result != null)
  3690.         //  VA.SetText("~~UserInput", result);
  3691.     }
  3692. }
  3693.  
  3694. //================================================END GUIDE SHAREDMEM FORM=================================================================
  3695.  
  3696.  
  3697. //================================================BEGIN GUIDE REPORTS FORM=================================================================
  3698. public class GuideReportsForm : Form
  3699. {
  3700.     // Initialize string variable for storing user input
  3701.     public string result = null;
  3702.    
  3703.     public GuideReportsForm(dynamic VA, string profileTitle, Icon icon)
  3704.     {
  3705.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  3706.         this.Text = profileTitle;
  3707.         if (icon != null)
  3708.             this.Icon = icon;
  3709.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  3710.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  3711.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  3712.         this.MaximizeBox = false;
  3713.         this.MinimizeBox = false;
  3714.         this.StartPosition = FormStartPosition.CenterScreen;
  3715.         this.AutoSize = true;
  3716.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3717.         this.MinimumSize = new Size(this.Width, this.Height);
  3718.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  3719.         this.Padding = new Padding(20);
  3720.         int FontSizeS = 8;
  3721.         int FontSize = 10;
  3722.         int FontSizeM = 12;
  3723.         int FontSizeL = 16;
  3724.         int FontSizeX = 24;
  3725.         int ControlSpacing = 15;
  3726.         this.FormClosing += new FormClosingEventHandler((sender, e) => GuideReportsForm_FormClosing(sender, e, VA));
  3727.        
  3728.         // Set up labelHeader
  3729.         Label labelHeader = new Label();
  3730.         labelHeader.Text = "AVCS PC Sensor Reports Usage";
  3731.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  3732.         labelHeader.AutoSize = true;
  3733.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  3734.         this.Controls.Add(labelHeader);
  3735.        
  3736.         // Set up labelSpacer
  3737.         Label labelSpacerH = new Label();
  3738.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  3739.        
  3740.        
  3741.         // CC License Link and Credit to AVCS Profiles
  3742.         LinkLabel labelReportsLink = new LinkLabel();
  3743.         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.";
  3744.         labelReportsLink.LinkArea = new LinkArea(38, 4);
  3745.         labelReportsLink.Font = new Font(labelReportsLink.Font.FontFamily, FontSizeM);
  3746.         labelReportsLink.LinkColor = Color.FromArgb(64, 188, 255);
  3747.         labelReportsLink.AutoSize = true;
  3748.         labelReportsLink.TextAlign = ContentAlignment.MiddleLeft;
  3749.         labelReportsLink.MinimumSize = new Size(750, 0);
  3750.         labelReportsLink.MaximumSize = new Size(750, 0);
  3751.         ToolTip ReportsTip = new ToolTip();
  3752.         string ReportsLink = @"https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather-img1/";
  3753.         ReportsTip.SetToolTip(labelReportsLink,"Click here to view image at: " + ReportsLink);
  3754.         this.Controls.Add(labelReportsLink);
  3755.         labelReportsLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, ReportsLink));
  3756.        
  3757.        
  3758.         // CC License Link and Credit to AVCS Profiles
  3759.         Label labelReports = new Label();
  3760.         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.";
  3761.         labelReports.Font = new Font(labelReports.Font.FontFamily, FontSizeM);
  3762.         labelReports.AutoSize = true;
  3763.         labelReports.TextAlign = ContentAlignment.MiddleLeft;
  3764.         labelReports.MinimumSize = new Size(750, 0);
  3765.         labelReports.MaximumSize = new Size(750, 0);
  3766.         this.Controls.Add(labelReports);
  3767.        
  3768.         // Set up labelStopCommands
  3769.         Label labelStopCommands = new Label();
  3770.         labelStopCommands.Text = "Say 'Stop All Sensor Commands' to halt reports speech readouts anytime";
  3771.         labelStopCommands.Font = new Font(labelStopCommands.Font.FontFamily, FontSizeM, FontStyle.Bold);
  3772.         labelStopCommands.MinimumSize = new Size(750, 0);
  3773.         labelStopCommands.MaximumSize = new Size(750, 0);
  3774.         labelStopCommands.AutoSize = true;
  3775.         labelStopCommands.TextAlign = ContentAlignment.MiddleLeft;
  3776.         this.Controls.Add(labelStopCommands);
  3777.        
  3778.        
  3779.         //===========================  FOOTER  =======================
  3780.         // Set up labelSpacer
  3781.         Label labelSpacerF = new Label();
  3782.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  3783.        
  3784.         // Set up buttonBack
  3785.         Button buttonBack = new Button();
  3786.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  3787.        
  3788.        
  3789.         // Footer Label
  3790.         Label labelFooter = new Label();
  3791.         Functions.addFooterLabel(this, FontSizeS, labelFooter);
  3792.        
  3793.        
  3794.         // Show Options Form
  3795.         Functions.ResizeForm(this, ControlSpacing);
  3796.         Functions.ShowForm(this);
  3797.     }
  3798.    
  3799.    
  3800.     //  Final Exit Options Form Closing
  3801.     private void GuideReportsForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  3802.     {
  3803.         //if (result != null)
  3804.         //  VA.SetText("~~UserInput", result);
  3805.     }
  3806. }
  3807.  
  3808. //================================================END GUIDE REPORTS FORM=================================================================
  3809.  
  3810.  
  3811. //================================================BEGIN GUIDE DIAG FORM=================================================================
  3812. public class GuideDiagnosticsForm : Form
  3813. {
  3814.     // Initialize string variable for storing user input
  3815.     public string result = null;
  3816.    
  3817.     public GuideDiagnosticsForm(dynamic VA, string profileTitle, Icon icon)
  3818.     {
  3819.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  3820.         this.Text = profileTitle;
  3821.         if (icon != null)
  3822.             this.Icon = icon;
  3823.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  3824.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  3825.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  3826.         this.MaximizeBox = false;
  3827.         this.MinimizeBox = false;
  3828.         this.StartPosition = FormStartPosition.CenterScreen;
  3829.         this.AutoSize = true;
  3830.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3831.         this.MinimumSize = new Size(this.Width, this.Height);
  3832.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  3833.         this.Padding = new Padding(20);
  3834.         int FontSizeS = 8;
  3835.         int FontSize = 10;
  3836.         int FontSizeM = 12;
  3837.         int FontSizeL = 16;
  3838.         int FontSizeX = 24;
  3839.         int ControlSpacing = 15;
  3840.         this.FormClosing += new FormClosingEventHandler((sender, e) => GuideDiagnosticsForm_FormClosing(sender, e, VA));
  3841.        
  3842.         // Set up labelHeader
  3843.         Label labelHeader = new Label();
  3844.         labelHeader.Text = "AVCS PC Sensor Diagnostics";
  3845.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  3846.         labelHeader.AutoSize = true;
  3847.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  3848.         this.Controls.Add(labelHeader);
  3849.        
  3850.         // Set up labelSpacer
  3851.         Label labelSpacerH = new Label();
  3852.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  3853.        
  3854.        
  3855.        
  3856.         // CC License Link and Credit to AVCS Profiles
  3857.         Label labelSnsDiag = new Label();
  3858.         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.";
  3859.         labelSnsDiag.Font = new Font(labelSnsDiag.Font.FontFamily, FontSizeM);
  3860.         labelSnsDiag.AutoSize = true;
  3861.         labelSnsDiag.TextAlign = ContentAlignment.MiddleLeft;
  3862.         labelSnsDiag.MinimumSize = new Size(730, 0);
  3863.         labelSnsDiag.MaximumSize = new Size(730, 0);
  3864.         this.Controls.Add(labelSnsDiag);
  3865.        
  3866.        
  3867.         // Set up labelHeaderBaselines
  3868.         Label labelHeaderBase = new Label();
  3869.         labelHeaderBase.Text = "\nEstablishing Sensor Baselines - Low, Medium, High, Extreme                                      ";
  3870.         labelHeaderBase.Font = new Font(labelHeaderBase.Font.FontFamily, FontSizeM, FontStyle.Bold);
  3871.         labelHeaderBase.AutoSize = true;
  3872.         labelHeaderBase.MinimumSize = new Size(730, 0);
  3873.         labelHeaderBase.MaximumSize = new Size(730, 0);
  3874.         labelHeaderBase.TextAlign = ContentAlignment.MiddleLeft;
  3875.         this.Controls.Add(labelHeaderBase);
  3876.        
  3877.         // CC License Link and Credit to AVCS Profiles
  3878.         Label labelBaselines = new Label();
  3879.         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.";
  3880.         labelBaselines.Font = new Font(labelBaselines.Font.FontFamily, FontSizeM);
  3881.         labelBaselines.AutoSize = true;
  3882.         labelBaselines.TextAlign = ContentAlignment.MiddleLeft;
  3883.         labelBaselines.MinimumSize = new Size(730, 0);
  3884.         labelBaselines.MaximumSize = new Size(730, 0);
  3885.         this.Controls.Add(labelBaselines);
  3886.        
  3887.        
  3888.         // Set up labelHeaderDHT
  3889.         Label labelHeaderDHT = new Label();
  3890.         labelHeaderDHT.Text = "\nAVCS-DHT1 USB Room Temperature && Humidity Sensor                                             ";
  3891.         labelHeaderDHT.Font = new Font(labelHeaderDHT.Font.FontFamily, FontSizeM, FontStyle.Bold);
  3892.         labelHeaderDHT.AutoSize = true;
  3893.         labelHeaderDHT.MinimumSize = new Size(730, 0);
  3894.         labelHeaderDHT.MaximumSize = new Size(730, 0);
  3895.         labelHeaderDHT.TextAlign = ContentAlignment.MiddleLeft;
  3896.         this.Controls.Add(labelHeaderDHT);
  3897.        
  3898.         // CC License Link and Credit to AVCS Profiles
  3899.         LinkLabel labelSnsDHT = new LinkLabel();
  3900.         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.";
  3901.         labelSnsDHT.LinkArea = new LinkArea(180, 16);
  3902.         labelSnsDHT.Font = new Font(labelSnsDHT.Font.FontFamily, FontSizeM);
  3903.         labelSnsDHT.LinkColor = Color.FromArgb(64, 188, 255);
  3904.         labelSnsDHT.AutoSize = true;
  3905.         labelSnsDHT.TextAlign = ContentAlignment.MiddleLeft;
  3906.         labelSnsDHT.MinimumSize = new Size(730, 0);
  3907.         labelSnsDHT.MaximumSize = new Size(730, 0);
  3908.         ToolTip SnsDHTTip = new ToolTip();
  3909.         string SnsDHTLink = @"https://veterans-gaming.com/avcs-wiki/dht1-guide/";
  3910.         SnsDHTTip.SetToolTip(labelSnsDHT,"Click here for AVCS-DHT1 build guide: " + SnsDHTLink);
  3911.         this.Controls.Add(labelSnsDHT);
  3912.         labelSnsDHT.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, SnsDHTLink));
  3913.        
  3914.        
  3915.         // Set up buttonDHTLink
  3916.         Button buttonDHTLink = new Button();
  3917.         buttonDHTLink.Text = " Buy an AVCS-DHT1 ";
  3918.         buttonDHTLink.AutoSize = true;
  3919.         buttonDHTLink.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3920.         buttonDHTLink.Font = new Font(buttonDHTLink.Font.FontFamily, FontSizeM);
  3921.         buttonDHTLink.ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
  3922.         buttonDHTLink.BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  3923.         ToolTip StoreLinkTip = new ToolTip();
  3924.         string StoreLink = "https://veterans-gaming.com/store/product/13-avcs-dht1-usb-temperature-humidity-sensor/";
  3925.         StoreLinkTip.SetToolTip(buttonDHTLink, "Check out my AVCS-DHT1 on the VG Store: " + StoreLink);
  3926.         this.Controls.Add(buttonDHTLink);
  3927.         buttonDHTLink.MouseHover += new EventHandler((sender, e) => Functions.buttonsReverse_MouseHover(sender, e, ControlSpacing, FontSizeM));
  3928.         buttonDHTLink.MouseLeave += new EventHandler((sender, e) => Functions.buttonsReverse_MouseLeave(sender, e, ControlSpacing, FontSizeM));
  3929.         buttonDHTLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, StoreLink));
  3930.        
  3931.        
  3932.        
  3933.         //===========================  FOOTER  =======================
  3934.         // Set up labelSpacer
  3935.         Label labelSpacerF = new Label();
  3936.         Functions.addLabelSpacer(this, FontSizeL, labelSpacerF);
  3937.        
  3938.         // Set up buttonBack
  3939.         Button buttonBack = new Button();
  3940.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  3941.        
  3942.        
  3943.         // Footer Label
  3944.         Label labelFooter = new Label();
  3945.         Functions.addFooterLabel(this, FontSizeS, labelFooter);
  3946.        
  3947.        
  3948.         // Show Options Form
  3949.         Functions.ResizeForm(this, ControlSpacing);
  3950.         Functions.ShowForm(this);
  3951.     }
  3952.    
  3953.    
  3954.     //  Final Exit Options Form Closing
  3955.     private void GuideDiagnosticsForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  3956.     {
  3957.         //if (result != null)
  3958.         //  VA.SetText("~~UserInput", result);
  3959.     }
  3960. }
  3961.  
  3962. //================================================END GUIDE DIAG FORM=================================================================
  3963.  
  3964.  
  3965. //================================================BEGIN GUIDE DIAG USE FORM=================================================================
  3966. public class GuideDiagnosticsUseForm : Form
  3967. {
  3968.     // Initialize string variable for storing user input
  3969.     public string result = null;
  3970.    
  3971.     public GuideDiagnosticsUseForm(dynamic VA, string profileTitle, Icon icon)
  3972.     {
  3973.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  3974.         this.Text = profileTitle;
  3975.         if (icon != null)
  3976.             this.Icon = icon;
  3977.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  3978.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  3979.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  3980.         this.MaximizeBox = false;
  3981.         this.MinimizeBox = false;
  3982.         this.StartPosition = FormStartPosition.CenterScreen;
  3983.         this.AutoSize = true;
  3984.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  3985.         this.MinimumSize = new Size(this.Width, this.Height);
  3986.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  3987.         this.Padding = new Padding(20);
  3988.         int FontSizeS = 8;
  3989.         int FontSize = 10;
  3990.         int FontSizeM = 12;
  3991.         int FontSizeL = 16;
  3992.         int FontSizeX = 24;
  3993.         int ControlSpacing = 15;
  3994.         this.FormClosing += new FormClosingEventHandler((sender, e) => GuideDiagnosticsUseForm_FormClosing(sender, e, VA));
  3995.        
  3996.         // Set up labelHeader
  3997.         Label labelHeader = new Label();
  3998.         labelHeader.Text = "AVCS PC Sensor Diagnostic Usage";
  3999.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  4000.         labelHeader.AutoSize = true;
  4001.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  4002.         this.Controls.Add(labelHeader);
  4003.        
  4004.         // Set up labelSpacer
  4005.         Label labelSpacerH = new Label();
  4006.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  4007.        
  4008.         // CC License Link and Credit to AVCS Profiles
  4009.         LinkLabel labelDiagUseLink = new LinkLabel();
  4010.         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.";
  4011.         labelDiagUseLink.LinkArea = new LinkArea(62, 4);
  4012.         labelDiagUseLink.Font = new Font(labelDiagUseLink.Font.FontFamily, FontSizeM);
  4013.         labelDiagUseLink.LinkColor = Color.FromArgb(64, 188, 255);
  4014.         labelDiagUseLink.AutoSize = true;
  4015.         labelDiagUseLink.TextAlign = ContentAlignment.MiddleLeft;
  4016.         labelDiagUseLink.MinimumSize = new Size(750, 0);
  4017.         labelDiagUseLink.MaximumSize = new Size(750, 0);
  4018.         ToolTip DiagUseTip = new ToolTip();
  4019.         string DiagUseLink = @"https://veterans-gaming.com/avcs-wiki/avcs-sensors-weather-img1/";
  4020.         DiagUseTip.SetToolTip(labelDiagUseLink,"Click here to view image at: " + DiagUseLink);
  4021.         this.Controls.Add(labelDiagUseLink);
  4022.         labelDiagUseLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, DiagUseLink));
  4023.        
  4024.         // CC License Link and Credit to AVCS Profiles
  4025.         Label labelDiagUse = new Label();
  4026.         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.";
  4027.         labelDiagUse.Font = new Font(labelDiagUse.Font.FontFamily, FontSizeM);
  4028.         labelDiagUse.AutoSize = true;
  4029.         labelDiagUse.TextAlign = ContentAlignment.MiddleLeft;
  4030.         labelDiagUse.MinimumSize = new Size(750, 0);
  4031.         labelDiagUse.MaximumSize = new Size(750, 0);
  4032.         this.Controls.Add(labelDiagUse);
  4033.        
  4034.         // Set up labelStopCommands
  4035.         Label labelStopCommands = new Label();
  4036.         labelStopCommands.Text = "Say 'Stop All Sensor Commands' to halt diagnostic speech readouts anytime";
  4037.         labelStopCommands.Font = new Font(labelStopCommands.Font.FontFamily, FontSizeM, FontStyle.Bold);
  4038.         labelStopCommands.MinimumSize = new Size(750, 0);
  4039.         labelStopCommands.MaximumSize = new Size(750, 0);
  4040.         labelStopCommands.AutoSize = true;
  4041.         labelStopCommands.TextAlign = ContentAlignment.MiddleLeft;
  4042.         this.Controls.Add(labelStopCommands);
  4043.        
  4044.         //===========================  FOOTER  =======================
  4045.         // Set up labelSpacer
  4046.         Label labelSpacerF = new Label();
  4047.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  4048.        
  4049.         // Set up buttonBack
  4050.         Button buttonBack = new Button();
  4051.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  4052.        
  4053.        
  4054.         // Footer Label
  4055.         Label labelFooter = new Label();
  4056.         Functions.addFooterLabel(this, FontSizeS, labelFooter);
  4057.        
  4058.        
  4059.         // Show Options Form
  4060.         Functions.ResizeForm(this, ControlSpacing);
  4061.         Functions.ShowForm(this);
  4062.     }
  4063.    
  4064.    
  4065.     //  Final Exit Options Form Closing
  4066.     private void GuideDiagnosticsUseForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  4067.     {
  4068.         //if (result != null)
  4069.         //  VA.SetText("~~UserInput", result);
  4070.     }
  4071. }
  4072.  
  4073. //================================================END GUIDE DIAG USE FORM=================================================================
  4074.  
  4075.  
  4076. //================================================BEGIN GUIDE OWM DATA FORM=================================================================
  4077. public class GuideWeatherDataForm : Form
  4078. {
  4079.     // Initialize string variable for storing user input
  4080.     public string result = null;
  4081.    
  4082.     public GuideWeatherDataForm(dynamic VA, string profileTitle, Icon icon)
  4083.     {
  4084.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  4085.         this.Text = profileTitle;
  4086.         if (icon != null)
  4087.             this.Icon = icon;
  4088.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  4089.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4090.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  4091.         this.MaximizeBox = false;
  4092.         this.MinimizeBox = false;
  4093.         this.StartPosition = FormStartPosition.CenterScreen;
  4094.         this.AutoSize = true;
  4095.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4096.         this.MinimumSize = new Size(this.Width, this.Height);
  4097.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  4098.         this.Padding = new Padding(20);
  4099.         int FontSizeS = 8;
  4100.         int FontSize = 10;
  4101.         int FontSizeM = 12;
  4102.         int FontSizeL = 16;
  4103.         int FontSizeX = 24;
  4104.         int ControlSpacing = 15;
  4105.         this.FormClosing += new FormClosingEventHandler((sender, e) => GuideWeatherDataForm_FormClosing(sender, e, VA));
  4106.        
  4107.         // Set up labelHeader
  4108.         Label labelHeader = new Label();
  4109.         labelHeader.Text = "Weather Data provided by OpenWeather (TM)";
  4110.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  4111.         labelHeader.AutoSize = true;
  4112.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  4113.         this.Controls.Add(labelHeader);
  4114.        
  4115.         // Set up labelSpacer
  4116.         Label labelSpacerH = new Label();
  4117.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  4118.        
  4119.        
  4120.        
  4121.         // CC License Link and Credit to AVCS Profiles
  4122.         Label labelOwmInfo = new Label();
  4123.         //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.";
  4124.         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.";
  4125.         labelOwmInfo.Font = new Font(labelOwmInfo.Font.FontFamily, FontSizeM);
  4126.         labelOwmInfo.AutoSize = true;
  4127.         labelOwmInfo.TextAlign = ContentAlignment.MiddleLeft;
  4128.         labelOwmInfo.MinimumSize = new Size(730, 0);
  4129.         labelOwmInfo.MaximumSize = new Size(730, 0);
  4130.         this.Controls.Add(labelOwmInfo);
  4131.        
  4132.        
  4133.        
  4134.         //===========================  FOOTER  =======================
  4135.         // Set up labelSpacer
  4136.         Label labelSpacerF = new Label();
  4137.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  4138.        
  4139.         // Set up buttonBack
  4140.         Button buttonBack = new Button();
  4141.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  4142.        
  4143.        
  4144.         // Footer Link and Credit to Open Weather Map
  4145.         LinkLabel labelOwmLink = new LinkLabel();
  4146.         Functions.addOwmLinkFooterLabel(VA, this, FontSizeS, labelOwmLink);
  4147.        
  4148.        
  4149.         // Show Options Form
  4150.         Functions.ResizeForm(this, ControlSpacing);
  4151.         Functions.ShowForm(this);
  4152.     }
  4153.    
  4154.    
  4155.     //  Final Exit Guide Form Closing
  4156.     private void GuideWeatherDataForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  4157.     {
  4158.         //if (result != null)
  4159.         //  VA.SetText("~~UserInput", result);
  4160.     }
  4161. }
  4162.  
  4163. //================================================END GUIDE OWM DATA FORM=================================================================
  4164.  
  4165.  
  4166. //================================================BEGIN GUIDE OWM OPTIONS FORM=================================================================
  4167. public class GuideWeatherOptionsForm : Form
  4168. {
  4169.     // Initialize string variable for storing user input
  4170.     public string result = null;
  4171.    
  4172.     public GuideWeatherOptionsForm(dynamic VA, string profileTitle, Icon icon)
  4173.     {
  4174.         profileTitle = Functions.updateMenuTitle(VA, profileTitle);
  4175.         this.Text = profileTitle;
  4176.         if (icon != null)
  4177.             this.Icon = icon;
  4178.         this.FormBorderStyle = FormBorderStyle.FixedDialog;
  4179.         this.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4180.         this.BackColor = System.Drawing.Color.FromArgb(75, 75, 75);
  4181.         this.MaximizeBox = false;
  4182.         this.MinimizeBox = false;
  4183.         this.StartPosition = FormStartPosition.CenterScreen;
  4184.         this.AutoSize = true;
  4185.         this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4186.         this.MinimumSize = new Size(this.Width, this.Height);
  4187.         this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  4188.         this.Padding = new Padding(20);
  4189.         int FontSizeS = 8;
  4190.         int FontSize = 10;
  4191.         int FontSizeM = 12;
  4192.         int FontSizeL = 16;
  4193.         int FontSizeX = 24;
  4194.         int ControlSpacing = 15;
  4195.         this.FormClosing += new FormClosingEventHandler((sender, e) => GuideWeatherOptionsForm_FormClosing(sender, e, VA));
  4196.        
  4197.         // Set up labelHeader
  4198.         Label labelHeader = new Label();
  4199.         labelHeader.Text = "Setting Weather Options && Local City";
  4200.         labelHeader.Font = new Font(labelHeader.Font.FontFamily, FontSizeL, FontStyle.Bold);
  4201.         labelHeader.AutoSize = true;
  4202.         labelHeader.TextAlign = ContentAlignment.MiddleCenter;
  4203.         this.Controls.Add(labelHeader);
  4204.        
  4205.         // Set up labelSpacer
  4206.         Label labelSpacerH = new Label();
  4207.         Functions.addLabelSpacer(this, 1, labelSpacerH);
  4208.        
  4209.        
  4210.         // Link Label for ISO 3166 Country Codes and User City info for OWM
  4211.     //  Label labelOwmOptions = new Label();
  4212.     //  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'.";
  4213.     //  labelOwmOptions.Font = new Font(labelOwmOptions.Font.FontFamily, FontSizeM);
  4214.     //  labelOwmOptions.AutoSize = true;
  4215.     //  labelOwmOptions.TextAlign = ContentAlignment.MiddleLeft;
  4216.     //  labelOwmOptions.MinimumSize = new Size(730, 0);
  4217.     //  labelOwmOptions.MaximumSize = new Size(730, 0);
  4218.     //  this.Controls.Add(labelOwmOptions);
  4219.        
  4220.         // Link Label for ISO 3166 Country Codes and User City info for OWM
  4221.         LinkLabel labelCountryCodesLink = new LinkLabel();
  4222.         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'.";
  4223.         labelCountryCodesLink.LinkArea = new LinkArea(180, 8);
  4224.         labelCountryCodesLink.Font = new Font(labelCountryCodesLink.Font.FontFamily, FontSizeM);
  4225.         labelCountryCodesLink.LinkColor = Color.FromArgb(64, 188, 255);
  4226.         labelCountryCodesLink.AutoSize = true;
  4227.         labelCountryCodesLink.TextAlign = ContentAlignment.MiddleLeft;
  4228.         labelCountryCodesLink.MinimumSize = new Size(730, 0);
  4229.         labelCountryCodesLink.MaximumSize = new Size(730, 0);
  4230.         ToolTip CountryCodesLinkTip = new ToolTip();
  4231.         string CountryCodesLink = "https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes";
  4232.         CountryCodesLinkTip.SetToolTip(labelCountryCodesLink, CountryCodesLink);
  4233.         this.Controls.Add(labelCountryCodesLink);
  4234.         labelCountryCodesLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, CountryCodesLink));
  4235.        
  4236.        
  4237.        
  4238.         // CC License Link and Credit to AVCS Profiles
  4239.         Label labelOwmOptions = new Label();
  4240.         //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.";
  4241.         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.";
  4242.         labelOwmOptions.Font = new Font(labelOwmOptions.Font.FontFamily, FontSizeM);
  4243.         labelOwmOptions.AutoSize = true;
  4244.         labelOwmOptions.TextAlign = ContentAlignment.MiddleLeft;
  4245.         labelOwmOptions.MinimumSize = new Size(730, 0);
  4246.         labelOwmOptions.MaximumSize = new Size(730, 0);
  4247.         this.Controls.Add(labelOwmOptions);
  4248.        
  4249.        
  4250.        
  4251.         //===========================  FOOTER  =======================
  4252.         // Set up labelSpacer
  4253.         Label labelSpacerF = new Label();
  4254.         Functions.addLabelSpacer(this, FontSizeX, labelSpacerF);
  4255.        
  4256.         // Set up buttonBack
  4257.         Button buttonBack = new Button();
  4258.         Functions.addBackButton(this, ControlSpacing, FontSizeM, buttonBack);
  4259.        
  4260.        
  4261.        
  4262.         // Footer Link and Credit to Open Weather Map
  4263.         LinkLabel labelOwmLink = new LinkLabel();
  4264.         Functions.addOwmLinkFooterLabel(VA, this, FontSizeS, labelOwmLink);
  4265.        
  4266.        
  4267.         // Show Options Form
  4268.         Functions.ResizeForm(this, ControlSpacing);
  4269.         Functions.ShowForm(this);
  4270.     }
  4271.    
  4272.    
  4273.     //  Final Exit Options Form Closing
  4274.     private void GuideWeatherOptionsForm_FormClosing(object sender, FormClosingEventArgs e, dynamic VA)
  4275.     {
  4276.         //if (result != null)
  4277.         //  VA.SetText("~~UserInput", result);
  4278.     }
  4279. }
  4280.  
  4281. //================================================END GUIDE OWM OPTIONS FORM=================================================================
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288. //================================================REQUIRED FUNCTIONS=================================================================
  4289. public class Functions
  4290. {
  4291.     // Function for resizing the form and positioning all the controls based on their width
  4292.     public static void ResizeForm(Form f, int ControlSpacing)
  4293.     {
  4294.         int MaxWidth = 0;
  4295.         Control MaxWidthControl = null;
  4296.         foreach (Control c in f.Controls)
  4297.         {
  4298.             if (c.Size.Width > MaxWidth)
  4299.             {
  4300.                 MaxWidthControl = c;
  4301.                 MaxWidth = c.Size.Width;
  4302.             }
  4303.         }
  4304.         MaxWidthControl.Location = new Point(f.Padding.Left, 0);
  4305.        
  4306.         // Set location of all other controls within the form
  4307.         Control PreviousControl = null;
  4308.         foreach (Control c in f.Controls)
  4309.         {
  4310.             c.Location = new Point(MaxWidth / 2 + f.Padding.Left - c.Size.Width / 2, (PreviousControl == null ? ControlSpacing : PreviousControl.Height + PreviousControl.Top + ControlSpacing));
  4311.             PreviousControl = c;
  4312.         }
  4313.     }
  4314.    
  4315.     // Function for bringing form into focus
  4316.     public static void ShowForm(Form f)
  4317.     {
  4318.         IntPtr myHandle = f.Handle;
  4319.         SetForegroundWindow(myHandle.ToInt32());
  4320.     }
  4321.    
  4322.     public static string updateMenuTitle(dynamic VA, string profileTitle)
  4323.     {
  4324.         string currentVersion = "0.90";
  4325.         if (VA.GetText("AVCS_SENS_Version") != null)
  4326.             currentVersion = VA.GetText("AVCS_SENS_Version");
  4327.         profileTitle = "AVCS SENS v" + currentVersion + " - Sensor Menu";
  4328.         if ((VA.GetBoolean("AVCS_SENS_VersionChecked") == true) && (VA.GetBoolean("AVCS_SENS_UPDATED") == true))
  4329.             profileTitle+= " (update available)";
  4330.         return profileTitle;
  4331.     }
  4332.    
  4333.    
  4334.     // Function to open config/baselines file at provided path
  4335.     public static void buttonOpenFile(dynamic VA, string filePath)
  4336.     {
  4337.         try
  4338.         {
  4339.             Process.Start(filePath);
  4340.         }
  4341.         catch
  4342.         {
  4343.             VA.WriteToLog("AVCS ERROR - Unable to find file at File Path:","red");
  4344.             VA.WriteToLog(filePath,"blank");
  4345.         }
  4346.     }
  4347.    
  4348.     // Begin/Stop Sensor Monitoring Button Event
  4349.     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)
  4350.     {
  4351.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  4352.         {
  4353.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
  4354.             buttonOther1.Enabled = false;
  4355.             buttonOther2.Enabled = false;
  4356.             buttonOther3.Enabled = false;
  4357.             buttonOther4.Enabled = false;
  4358.             buttonOther5.Enabled = false;
  4359.             buttonOther6.Enabled = false;
  4360.             if (VA.GetBoolean("AVCS_SENS_Logging") != true)
  4361.             {
  4362.                 VA.SetBoolean("AVCS_SENS_Monitor_Startup", true);
  4363.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  4364.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  4365.                 (sender as Button).Enabled = false;
  4366.                 VA.Command.Execute("F_AIDA_MAIN");
  4367.                 Thread.Sleep(500);
  4368.                 while (VA.GetBoolean("AVCS_SENS_Monitor_Startup") == true)
  4369.                     Thread.Sleep(50);
  4370.                
  4371.                 if (VA.GetBoolean("AVCS_SENS_Monitoring") != true || VA.GetBoolean("AVCS_SENS_Logging") != true)
  4372.                 {
  4373.                     VA.SetBoolean("AVCS_SENS_Logging", false);
  4374.                     VA.SetBoolean("AVCS_SENS_Monitoring", false);
  4375.                     (sender as Button).Text = " Begin Sensor Monitoring ";
  4376.                     (sender as Button).Enabled = true;
  4377.                     (sender as Button).AutoSize = true;
  4378.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4379.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4380.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4381.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
  4382.                     Functions.ResizeForm(thisForm, ControlSpacing);
  4383.                     if (resetMain)
  4384.                     {
  4385.                         //Also change button on Main Menu form
  4386.                         buttonSnsMonitoring.Text = " Begin Sensor Monitoring ";
  4387.                         buttonSnsMonitoring.Enabled = true;
  4388.                         buttonSnsMonitoring.AutoSize = true;
  4389.                         buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4390.                         buttonSnsMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4391.                         buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4392.                         buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  4393.                         Functions.ResizeForm(mainForm, ControlSpacing);
  4394.                     }
  4395.                 }
  4396.                 else
  4397.                 {
  4398.                     (sender as Button).Text = " Stop Sensor Monitoring ";
  4399.                     (sender as Button).AutoSize = true;
  4400.                     (sender as Button).Enabled = true;
  4401.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4402.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4403.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4404.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
  4405.                     Functions.ResizeForm(thisForm, ControlSpacing);
  4406.                    
  4407.                     if (resetMain)
  4408.                     {
  4409.                         //Also change button on Main Menu form
  4410.                         buttonSnsMonitoring.Text = " Stop Sensor Monitoring ";
  4411.                         buttonSnsMonitoring.AutoSize = true;
  4412.                         buttonSnsMonitoring.Enabled = true;
  4413.                         buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4414.                         buttonSnsMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4415.                         buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4416.                         buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  4417.                         Functions.ResizeForm(mainForm, ControlSpacing);
  4418.                     }
  4419.                 }
  4420.             }
  4421.             else
  4422.             {
  4423.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  4424.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  4425.                 (sender as Button).Enabled = false;
  4426.                 VA.SetBoolean("AVCS_SENS_Logging", false);
  4427.                 VA.SetBoolean("AVCS_SENS_Monitoring", false);
  4428.                 Thread.Sleep(5000);
  4429.                 (sender as Button).Text = " Begin Sensor Monitoring ";
  4430.                 (sender as Button).AutoSize = true;
  4431.                 (sender as Button).Enabled = true;
  4432.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4433.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4434.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4435.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
  4436.                 Functions.ResizeForm(thisForm, ControlSpacing);
  4437.                
  4438.                 if (resetMain)
  4439.                 {
  4440.                     //Also change button on Main Menu form
  4441.                     buttonSnsMonitoring.Text = " Begin Sensor Monitoring ";
  4442.                     buttonSnsMonitoring.Enabled = true;
  4443.                     buttonSnsMonitoring.AutoSize = true;
  4444.                     buttonSnsMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4445.                     buttonSnsMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4446.                     buttonSnsMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4447.                     buttonSnsMonitoring.Font = new Font(buttonSnsMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  4448.                     Functions.ResizeForm(mainForm, ControlSpacing);
  4449.                 }
  4450.             }
  4451.             buttonOther1.Enabled = true;
  4452.             buttonOther2.Enabled = true;
  4453.             buttonOther3.Enabled = true;
  4454.             buttonOther4.Enabled = true;
  4455.             buttonOther5.Enabled = true;
  4456.             buttonOther6.Enabled = true;
  4457.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
  4458.         }
  4459.     }
  4460.    
  4461.     // Begin/Stop Weather Monitoring Button Event
  4462.     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)
  4463.     {
  4464.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  4465.         {
  4466.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", true);
  4467.             buttonOther1.Enabled = false;
  4468.             buttonOther2.Enabled = false;
  4469.             buttonOther3.Enabled = false;
  4470.             buttonOther4.Enabled = false;
  4471.             buttonOther5.Enabled = false;
  4472.             buttonOther6.Enabled = false;
  4473.             buttonOther7.Enabled = false;
  4474.             if (VA.GetBoolean("AVCS_OWM_Monitoring") != true)
  4475.             {
  4476.                 VA.SetBoolean("AVCS_OWM_Monitor_Startup", true);
  4477.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  4478.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  4479.                 (sender as Button).Enabled = false;
  4480.                 VA.Command.Execute("F_OWM_MAIN");
  4481.                 Thread.Sleep(500);
  4482.                 while (VA.GetBoolean("AVCS_OWM_Monitor_Startup") == true)
  4483.                     Thread.Sleep(50);
  4484.                
  4485.                 if (VA.GetBoolean("AVCS_OWM_Monitoring") != true)
  4486.                 {
  4487.                     VA.SetBoolean("AVCS_OWM_Monitoring", false);
  4488.                     (sender as Button).Text = " Begin Weather Monitoring ";
  4489.                     (sender as Button).Enabled = true;
  4490.                     (sender as Button).AutoSize = true;
  4491.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4492.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4493.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4494.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
  4495.                     Functions.ResizeForm(thisForm, ControlSpacing);
  4496.                    
  4497.                     if (resetMain)
  4498.                     {
  4499.                         //Also change button on Main Menu form
  4500.                         buttonOwmMonitoring.Text = " Begin Weather Monitoring ";
  4501.                         buttonOwmMonitoring.Enabled = true;
  4502.                         buttonOwmMonitoring.AutoSize = true;
  4503.                         buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4504.                         buttonOwmMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4505.                         buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4506.                         buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  4507.                         Functions.ResizeForm(mainForm, ControlSpacing);
  4508.                     }
  4509.                 }
  4510.                 else
  4511.                 {
  4512.                     (sender as Button).Text = " Stop Weather Monitoring ";
  4513.                     (sender as Button).AutoSize = true;
  4514.                     (sender as Button).Enabled = true;
  4515.                     (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4516.                     (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4517.                     (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4518.                     (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
  4519.                     Functions.ResizeForm(thisForm, ControlSpacing);
  4520.                    
  4521.                     if (resetMain)
  4522.                     {
  4523.                         //Also change button on Main Menu form
  4524.                         buttonOwmMonitoring.Text = " Stop Weather Monitoring ";
  4525.                         buttonOwmMonitoring.AutoSize = true;
  4526.                         buttonOwmMonitoring.Enabled = true;
  4527.                         buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4528.                         buttonOwmMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4529.                         buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4530.                         buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  4531.                         Functions.ResizeForm(mainForm, ControlSpacing);
  4532.                         // Add tooltip to Interval Option Button
  4533.                         ToolTip SetCallsAPITip = new ToolTip();
  4534.                         SetCallsAPITip.SetToolTip(buttonOther5,"(restart monitor to apply changes)");
  4535.                     }
  4536.                 }
  4537.             }
  4538.             else
  4539.             {
  4540.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(155, 119, 0);
  4541.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(160, 160, 160);
  4542.                 (sender as Button).Enabled = false;
  4543.                 VA.SetBoolean("AVCS_OWM_Monitoring", false);
  4544.                 Thread.Sleep(5000);
  4545.                 (sender as Button).Text = " Begin Weather Monitoring ";
  4546.                 (sender as Button).AutoSize = true;
  4547.                 (sender as Button).Enabled = true;
  4548.                 (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4549.                 (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4550.                 (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4551.                 (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM, FontStyle.Bold);
  4552.                 Functions.ResizeForm(thisForm, ControlSpacing);
  4553.                
  4554.                 if (resetMain)
  4555.                 {
  4556.                     //Also change button on Main Menu form
  4557.                     buttonOwmMonitoring.Text = " Begin Weather Monitoring ";
  4558.                     buttonOwmMonitoring.Enabled = true;
  4559.                     buttonOwmMonitoring.AutoSize = true;
  4560.                     buttonOwmMonitoring.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4561.                     buttonOwmMonitoring.ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4562.                     buttonOwmMonitoring.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4563.                     buttonOwmMonitoring.Font = new Font(buttonOwmMonitoring.Font.FontFamily, FontSizeM, FontStyle.Bold);
  4564.                     Functions.ResizeForm(mainForm, ControlSpacing);
  4565.                 }
  4566.             }
  4567.             buttonOther1.Enabled = true;
  4568.             buttonOther2.Enabled = true;
  4569.             buttonOther3.Enabled = true;
  4570.             buttonOther4.Enabled = true;
  4571.             buttonOther5.Enabled = true;
  4572.             buttonOther6.Enabled = true;
  4573.             buttonOther7.Enabled = true;
  4574.             VA.SetBoolean("AVCS_Menu_ButtonTimeout", null);
  4575.         }
  4576.     }
  4577.    
  4578.     // Function to Add a Custom Spacer Label to Menu Form Pages
  4579.     public static void addLabelSpacer(Form thisForm, int thisFontSize, Label labelSpacer)
  4580.     {
  4581.         labelSpacer.Text = " ";
  4582.         labelSpacer.Font = new Font(labelSpacer.Font.FontFamily, thisFontSize);
  4583.         labelSpacer.AutoSize = true;
  4584.         labelSpacer.TextAlign = ContentAlignment.MiddleCenter;
  4585.         thisForm.Controls.Add(labelSpacer);
  4586.     }
  4587.    
  4588.     // Function to Add a Back Button to Menu Form Pages
  4589.     public static void addFooterLabel(Form thisForm, int FontSizeS, Label labelFooter)
  4590.     {
  4591.         labelFooter.Text = "Say  'Open the Sensor Command Reference'  to view commands\nSay  'Open the Sensor Menu'  to return here anytime!";
  4592.         labelFooter.Font = new Font(labelFooter.Font.FontFamily, FontSizeS);
  4593.         labelFooter.AutoSize = true;
  4594.         labelFooter.TextAlign = ContentAlignment.MiddleCenter;
  4595.         thisForm.Controls.Add(labelFooter);
  4596.     }
  4597.    
  4598.    
  4599.     // Function to Add a AIDA64/FinalWire Footer to Menu Form Pages
  4600.     public static void addFinalWireLinkFooterLabel(dynamic VA, Form thisForm, int FontSizeS, LinkLabel labelAidaLink)
  4601.     {
  4602.         // Credits Link to AIDA64 / FinalWire Ltd.
  4603.         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.";
  4604.         labelAidaLink.LinkArea = new LinkArea(90, 14);
  4605.         labelAidaLink.Font = new Font(labelAidaLink.Font.FontFamily, FontSizeS);
  4606.         labelAidaLink.LinkColor = Color.FromArgb(64, 188, 255);
  4607.         labelAidaLink.AutoSize = true;
  4608.         labelAidaLink.TextAlign = ContentAlignment.MiddleCenter;
  4609.         ToolTip AidaLinkTip = new ToolTip();
  4610.         string AidaLink = "https://www.aida64.com/";
  4611.         AidaLinkTip.SetToolTip(labelAidaLink, AidaLink);
  4612.         thisForm.Controls.Add(labelAidaLink);
  4613.         labelAidaLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, AidaLink));
  4614.     }
  4615.        
  4616.    
  4617.     // Function to Add a AIDA64/FinalWire Footer to Menu Form Pages
  4618.     public static void addFinalWireLinkFooterLabel2(dynamic VA, Form thisForm, int FontSizeS, LinkLabel labelAidaLink)
  4619.     {
  4620.         // Credits Link to AIDA64 / FinalWire Ltd.
  4621.         labelAidaLink.Text = "AIDA64 is a Registered Trademark of FinalWire Ltd. ©2010-" + DateTime.Now.ToString("yyyy").Trim() + " All rights reserved.";
  4622.         labelAidaLink.LinkArea = new LinkArea(36, 14);
  4623.         labelAidaLink.Font = new Font(labelAidaLink.Font.FontFamily, FontSizeS);
  4624.         labelAidaLink.LinkColor = Color.FromArgb(64, 188, 255);
  4625.         labelAidaLink.AutoSize = true;
  4626.         labelAidaLink.TextAlign = ContentAlignment.MiddleCenter;
  4627.         ToolTip AidaLinkTip = new ToolTip();
  4628.         string AidaLink = "https://www.aida64.com/";
  4629.         AidaLinkTip.SetToolTip(labelAidaLink, AidaLink);
  4630.         thisForm.Controls.Add(labelAidaLink);
  4631.         labelAidaLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, AidaLink));
  4632.     }
  4633.    
  4634.    
  4635.     // Function to Add a OpenWeather Footer Label to Menu Form Pages
  4636.     public static void addOwmLinkFooterLabel(dynamic VA, Form thisForm, int FontSizeS, LinkLabel labelOwmLink)
  4637.     {
  4638.         labelOwmLink.Text = "(AIDA64 and OpenWeather are not affiliated with AVCS)\nWeather data provided by OpenWeather (TM) via CC BY-SA 4.0";
  4639.         labelOwmLink.LinkArea = new LinkArea(79, 11);
  4640.         labelOwmLink.Font = new Font(labelOwmLink.Font.FontFamily, FontSizeS);
  4641.         labelOwmLink.LinkColor = Color.FromArgb(64, 188, 255);
  4642.         labelOwmLink.AutoSize = true;
  4643.         labelOwmLink.TextAlign = ContentAlignment.MiddleCenter;
  4644.         string OwmLink = "https://openweathermap.org/";
  4645.         ToolTip OwmLinkTip = new ToolTip();
  4646.         OwmLinkTip.SetToolTip(labelOwmLink, OwmLink);
  4647.         thisForm.Controls.Add(labelOwmLink);
  4648.         labelOwmLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, OwmLink));
  4649.     }
  4650.    
  4651.    
  4652.     // Function to Add a OpenWeather Footer Label to Menu Form Pages
  4653.     public static void addOwmLinkFooterLabel2(dynamic VA, Form thisForm, int FontSizeS, LinkLabel labelOwmLink)
  4654.     {
  4655.         labelOwmLink.Text = "Weather data provided by OpenWeather (TM) via CC BY-SA 4.0";
  4656.         labelOwmLink.LinkArea = new LinkArea(25, 11);
  4657.         labelOwmLink.Font = new Font(labelOwmLink.Font.FontFamily, FontSizeS);
  4658.         labelOwmLink.LinkColor = Color.FromArgb(64, 188, 255);
  4659.         labelOwmLink.AutoSize = true;
  4660.         labelOwmLink.TextAlign = ContentAlignment.MiddleCenter;
  4661.         string OwmLink = "https://openweathermap.org/";
  4662.         ToolTip OwmLinkTip = new ToolTip();
  4663.         OwmLinkTip.SetToolTip(labelOwmLink, OwmLink);
  4664.         thisForm.Controls.Add(labelOwmLink);
  4665.         labelOwmLink.Click += new EventHandler((sender, e) => Functions.labelLink_LinkClicked(sender, e, VA, OwmLink));
  4666.     }
  4667.    
  4668.    
  4669.     // Function to Add a Back Button to Menu Form Pages
  4670.     public static void addBackButton(Form thisForm, int ControlSpacing, int FontSizeM, Button buttonBack)
  4671.     {
  4672.         buttonBack.Text = "  BACK  ";
  4673.         buttonBack.AutoSize = true;
  4674.         buttonBack.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4675.         buttonBack.Font = new Font(buttonBack.Font.FontFamily, FontSizeM);
  4676.         buttonBack.BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4677.         thisForm.Controls.Add(buttonBack);
  4678.         buttonBack.MouseHover += new EventHandler((sender, e) => Functions.buttonBack_MouseHover(sender, e, thisForm, ControlSpacing, FontSizeM));
  4679.         buttonBack.MouseLeave += new EventHandler((sender, e) => Functions.buttonBack_MouseLeave(sender, e, thisForm, ControlSpacing, FontSizeM));
  4680.         buttonBack.Click += new EventHandler((sender, e) => Functions.buttonBack_Click(sender, e, thisForm));
  4681.         thisForm.CancelButton = buttonBack;
  4682.     }
  4683.    
  4684.     // Function run when buttonBack is clicked
  4685.     public static void buttonBack_Click(object sender, EventArgs e, Form thisForm)
  4686.     {
  4687.         thisForm.Close();
  4688.     }
  4689.    
  4690. //  buttonBack_MouseHover(sender, e, this, ControlSpacing, FontSizeM,
  4691.     // Functions to recolor AVCS Menu 'Back' buttons and button text on Mouse Hover events
  4692.     public static void buttonBack_MouseHover(object sender, EventArgs e, Form thisForm, int ControlSpacing, int FontSizeM)
  4693.     {
  4694.         (sender as Button).Text = " ← ← ← ";
  4695.         (sender as Button).AutoSize = true;
  4696.         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4697.         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  4698.         Functions.ResizeForm(thisForm, ControlSpacing);
  4699.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(30, 30, 30);
  4700.         (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4701.     }
  4702.     public static void buttonBack_MouseLeave(object sender, EventArgs e, Form thisForm, int ControlSpacing, int FontSizeM)
  4703.     {
  4704.         (sender as Button).Text = "  BACK  ";
  4705.         (sender as Button).AutoSize = true;
  4706.         (sender as Button).AutoSizeMode = AutoSizeMode.GrowAndShrink;
  4707.         (sender as Button).Font = new Font((sender as Button).Font.FontFamily, FontSizeM);
  4708.         Functions.ResizeForm(thisForm, ControlSpacing);
  4709.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4710.         (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4711.     }
  4712.    
  4713.     // Functions to recolor AVCS Menu buttons and button text on Mouse Hover events
  4714.     public static void buttons_MouseHover(object sender, EventArgs e, int ControlSpacing, int FontSize)
  4715.     {
  4716.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
  4717.         (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4718.     }
  4719.     public static void buttons_MouseLeave(object sender, EventArgs e, int ControlSpacing, int FontSize)
  4720.     {
  4721.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4722.         (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4723.     }
  4724.    
  4725.     // Reverse Color Functions to recolor Coffee button and button text on Mouse Hover events
  4726.     public static void buttonsReverse_MouseHover(object sender, EventArgs e, int ControlSpacing, int FontSize)
  4727.     {
  4728.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
  4729.     }
  4730.     public static void buttonsReverse_MouseLeave(object sender, EventArgs e, int ControlSpacing, int FontSize)
  4731.     {
  4732.         (sender as Button).ForeColor = System.Drawing.Color.FromArgb(20, 20, 20);
  4733.     }
  4734.    
  4735.     // Functions to recolor AVCS Sensors Monitor Start/Stop button and button text on Mouse Hover events
  4736.     public static void buttonsSnsMonitoring_MouseHover(object sender, EventArgs e, dynamic VA)
  4737.     {
  4738.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  4739.         {
  4740.             (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
  4741.             (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4742.         }
  4743.     }
  4744.     public static void buttonsSnsMonitoring_MouseLeave(object sender, EventArgs e, dynamic VA)
  4745.     {
  4746.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  4747.         {
  4748.             (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4749.             (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4750.         }
  4751.     }
  4752.    
  4753.     // Functions to recolor AVCS Weather Monitor Start/Stop button and button text on Mouse Hover events
  4754.     public static void buttonsOwmMonitoring_MouseHover(object sender, EventArgs e, dynamic VA)
  4755.     {
  4756.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  4757.         {
  4758.             (sender as Button).ForeColor = System.Drawing.Color.FromArgb(65, 65, 65);
  4759.             (sender as Button).BackColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4760.         }
  4761.     }
  4762.     public static void buttonsOwmMonitoring_MouseLeave(object sender, EventArgs e, dynamic VA)
  4763.     {
  4764.         if (VA.GetBoolean("AVCS_Menu_ButtonTimeout") != true)
  4765.         {
  4766.             (sender as Button).ForeColor = System.Drawing.Color.FromArgb(219, 169, 1);
  4767.             (sender as Button).BackColor = System.Drawing.Color.FromArgb(95, 95, 95);
  4768.         }
  4769.     }
  4770.    
  4771.     // Function to open URL link - thisLink string must be URL encoded, replace {SPACE} with %20 or +
  4772.     public static void labelLink_LinkClicked(object sender, EventArgs e, dynamic VA, string thisLink)
  4773.     {
  4774.         try
  4775.         {
  4776.             if (visitLink(thisLink) != true)
  4777.                 throw new Exception();
  4778.         }
  4779.         catch (Exception ex )
  4780.         {
  4781.             VA.WriteToLog("AVCS ERROR: Unable to open link:", "red");
  4782.             VA.WriteToLog(thisLink, "red");
  4783.         }
  4784.     }  
  4785.     public static bool visitLink(string thisLink)
  4786.     {
  4787.         try
  4788.         {
  4789.             // Open URL with default web browser
  4790.             System.Diagnostics.Process.Start(thisLink);
  4791.             return true;
  4792.         }
  4793.         catch (Exception ex )
  4794.         {
  4795.             //just let it fail now... don't catch shit
  4796.             return false;
  4797.         }
  4798.     }
  4799.    
  4800.     // Function to load user settings from config file into dec/int/txt/bool VA variables
  4801.     public static void loadUserConfig(dynamic VA)
  4802.     {
  4803.         if ((VA.GetText("~avcs_sens_user_settings") != null) && (VA.GetText("~avcs_sens_user_settings") != ""))
  4804.         {
  4805.             string settingName = "";
  4806.             string settingValue = "";
  4807.             string[] configFile = VA.GetText("~avcs_sens_user_settings").Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
  4808.             foreach (string userSetting in configFile)
  4809.             {
  4810.                 string[] thisSetting = userSetting.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
  4811.                 settingName = thisSetting[0];
  4812.                 settingValue = thisSetting[1];
  4813.                
  4814.                 if ((isNumeric(settingValue)) & (settingValue.Contains(".") || settingValue.Contains(",")))
  4815.                 {
  4816.                     try
  4817.                     {
  4818.                         decimal decimalValue;
  4819.                         decimal.TryParse(settingValue, out decimalValue);
  4820.                         VA.SetDecimal(settingName, decimalValue);
  4821.                     }
  4822.                     catch
  4823.                     {
  4824.                         //VA.WriteToLog("AVCS ERROR: failed to load decimal setting " + settingName, "red");
  4825.                     }
  4826.                 }
  4827.                 else if (isNumeric(settingValue))
  4828.                 {
  4829.                     try
  4830.                     {
  4831.                         int integerValue;
  4832.                         int.TryParse(settingValue, out integerValue);
  4833.                         VA.SetInt(settingName, integerValue);
  4834.                     }
  4835.                     catch
  4836.                     {
  4837.                         //VA.WriteToLog("AVCS ERROR: failed to load integer setting " + settingName, "red");
  4838.                     }
  4839.                 }
  4840.                 else if (settingValue.ToLower() == "true")
  4841.                 {
  4842.                     VA.SetBoolean(settingName, true);
  4843.                 }
  4844.                 else if (settingValue.ToLower() == "false")
  4845.                 {
  4846.                     VA.SetBoolean(settingName, false);
  4847.                 }
  4848.                 else
  4849.                 {
  4850.                     VA.SetText(settingName, settingValue);
  4851.                 }
  4852.             }
  4853.         }
  4854.         if (VA.GetText("AVCS_MENU_SetUpdateChecks") == null)
  4855.         {
  4856.             try
  4857.             {
  4858.                 VA.SetText("AVCS_MENU_SetUpdateChecks", new System.Net.WebClient().DownloadString(@"https://veterans-gaming.com/semlerpdx-avcs/profiles/avcs_sens_updater_list.htm/"));
  4859.             }
  4860.             catch
  4861.             {
  4862.                 VA.SetText("AVCS_MENU_SetUpdateChecks", " Checking Updates... , Check for Update ");
  4863.             }
  4864.         }
  4865.     }
  4866.    
  4867.    
  4868.     // Function to mimic a standard VB method familiar to me
  4869.     public static bool isNumeric(string checkNum)
  4870.     {
  4871.         decimal checkedNum;
  4872.         return (decimal.TryParse(checkNum, out checkedNum));
  4873.     }
  4874.    
  4875.     // External function for bringing window into focus using its handle
  4876.     [DllImport("User32.dll")]
  4877.     public static extern Int32 SetForegroundWindow(int hWnd);
  4878. }
Add Comment
Please, Sign In to add comment