using elite_power_sim; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Elite_Power_Management_Simulator { public partial class form_main : Form { public form_main() { InitializeComponent(); } public static class global { public static Int16 eng = 4; public static Int16 sys = 4; public static Int16 wep = 4; public static string key_rst = "{down}"; public static string key_sys = "{left}"; public static string key_eng = "{up}"; public static string key_wep = "{right}"; public static string rst_text = "[ RST ]\t\t[ 2 / 2 / 2 ]"; } public static class calc { public static int e = 0; } private void btn_reset_Click(object sender, EventArgs e) { pwr_reset(); } public void update() { prog_eng.Value = global.eng; prog_sys.Value = global.sys; prog_wep.Value = global.wep; } //Distribution History Tracking public void track_history(string log_item, string log_btn) { string q = log_item; string eng = Convert.ToString(Convert.ToDecimal(global.eng)/2); string sys = Convert.ToString(Convert.ToDecimal(global.sys)/2); string wep = Convert.ToString(Convert.ToDecimal(global.wep)/2); lst_log.Items.Add(q + "\t\t" + "[ " + sys + " / " + eng + " / " + wep + " ]"); txt_mba.Text = txt_mba.Text + log_btn; } public void reset_history() { lst_log.Items.Clear(); lst_log.Items.Add(global.rst_text); txt_mba.Text = "{down}"; } //Power Distribution Functions public void pwr_reset() { global.eng = 4; global.sys = 4; global.wep = 4; reset_history(); update(); } public void pwr_eng() { string log_iname = "+ENG"; bool fin = false; if (global.eng < 8) { if (global.eng == 7) { calc.e = 1; } else { calc.e = 2; } if (calc.e == 2) { if (global.sys >= 1 && global.wep >= 1 && !fin) { global.eng += 2; global.sys -= 1; global.wep -= 1; fin = true; } if (global.sys < 1 && global.wep > 1 && !fin) { global.eng += 2; global.wep -= 2; fin = true; } if (global.sys > 1 && global.wep < 1 && !fin) { global.eng += 2; global.sys -= 2; fin = true; } } if (calc.e == 1) { if (global.sys % 2 == 0) { if (global.wep >= 1 && !fin) { global.eng += 1; global.wep -= 1; fin = true; } /*else { if (!fin) { MessageBox.Show("Internal math error!"); } }*/ } else { if (global.sys >= 1 && !fin) { global.eng += 1; global.sys -= 1; fin = true; } /*else { if (!fin) { MessageBox.Show("Internal math error!"); } }*/ } } } track_history(log_iname, global.key_eng); update(); } public void pwr_sys() { string log_iname = "+SYS"; bool fin = false; if (global.sys < 8) { if (global.sys == 7) { calc.e = 1; } else { calc.e = 2; } if (calc.e == 2) { if (global.eng >= 1 && global.wep >= 1 && !fin) { global.sys += 2; global.eng -= 1; global.wep -= 1; fin = true; } if (global.eng < 1 && global.wep > 1 && !fin) { global.sys += 2; global.wep -= 2; fin = true; } if (global.eng > 1 && global.wep < 1 && !fin) { global.sys += 2; global.eng -= 2; fin = true; } } if (calc.e == 1) { if (global.eng % 2 == 0) { if (global.wep >= 1 && !fin) { global.sys += 1; global.wep -= 1; fin = true; } } else { if (global.eng >= 1 && !fin) { global.sys += 1; global.eng -= 1; fin = true; } } } } track_history(log_iname, global.key_sys); update(); } public void pwr_wep() { string log_iname = "+WEP"; bool fin = false; if (global.wep < 8) { if (global.wep == 7) { calc.e = 1; } else { calc.e = 2; } if (calc.e == 2) { if (global.sys >= 1 && global.eng >= 1 && !fin) { global.wep += 2; global.sys -= 1; global.eng -= 1; fin = true; } if (global.sys < 1 && global.eng > 1 && !fin) { global.wep += 2; global.eng -= 2; fin = true; } if (global.sys > 1 && global.eng < 1 && !fin) { global.wep += 2; global.sys -= 2; fin = true; } } if (calc.e == 1) { if (global.sys % 2 == 0) { if (global.eng >= 1 && !fin) { global.wep += 1; global.eng -= 1; fin = true; } } else { if (global.sys >= 1 && !fin) { global.wep += 1; global.sys -= 1; fin = true; } } } } track_history(log_iname, global.key_wep); update(); } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Up) { pwr_eng(); return true; } if (keyData == Keys.Down) { pwr_reset(); return true; } if (keyData == Keys.Left) { pwr_sys(); return true; } if (keyData == Keys.Right) { pwr_wep(); return true; } return base.ProcessCmdKey(ref msg, keyData); } private void lbl_copyright_Click(object sender, EventArgs e) { lbl_xant_ad.Visible = true; } private void cbox_showLog_CheckedChanged(object sender, EventArgs e) { //Default size: 408, 248 if (!cbox_showLog.Checked) { this.Width = 408; this.Height = 248; lst_log.Hide(); txt_mba.Hide(); gbox_log.Hide(); gbox_macroBuilder.Hide(); } else { this.Width = 800; this.Height = 296; lst_log.Show(); txt_mba.Show(); gbox_log.Show(); gbox_macroBuilder.Show(); } } } }