private void Form1_Load(object sender, EventArgs e) { _currentState = HUD_STATE.NotDetected; System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); EmbeddedFwMaxIndex = 0; string[] ls = a.GetManifestResourceNames(); for (int z = 0; z < ls.Length; z++) { if (ls[z].StartsWith(prefixFirmware)) { cbFirmwareSelector.Items.Add(ls[z].Substring(prefixFirmware.Length)); EmbeddedFwMaxIndex++; } } /* custom option */ Console.WriteLine("Firmware Max Index {0}", EmbeddedFwMaxIndex - 1); cbFirmwareSelector.Items.Add("Select Custom File"); setUI(_currentState); hotInitParams = new KHOT_PARAMS(); // In the real world, you would want to filter for only *your* device(s). hotInitParams.PatternMatch.DeviceInterfaceGUID = "*"; // The PLUG_ALL_ON_INIT flag will force plug events for matching devices that are already connected. hotInitParams.Flags = KHOT_FLAG.PLUG_ALL_ON_INIT; hotInitParams.OnHotPlug = OnHotPlug; // You may set your initial hot handle user context like this. // This example is using it to count connected devices and detect the first OnHotPlug event (Int32.MaxValue). AllKFunctions.LibK_SetDefaultContext(KLIB_HANDLE_TYPE.HOTK, new IntPtr(Int32.MaxValue)); // Start hot-plug detection. HotK hot = new HotK(ref hotInitParams); tbStatus.Text = "Firmware Updater v1.0\r\n"; tbStatus.Text += "Application started\r\n"; }
private void setUI(HUD_STATE state) { if (this.btnReboot.InvokeRequired) { SetUiCallback d = new SetUiCallback(setUI); this.Invoke(d, new object[] { state }); } else { _currentState = HUD_STATE.Application; switch (state) { case HUD_STATE.NotDetected: btnReboot.Enabled = false; btnProgram.Enabled = false; lblHudStatus.ForeColor = Color.Red; isNextGen = false; lblHudStatus.Text = "HUD NOT CONNECTED"; break; case HUD_STATE.Application: btnReboot.Enabled = true; btnProgram.Enabled = false; lblHudStatus.ForeColor = Color.Green; lblHudStatus.Text = "HUD CONNECTED"; break; case HUD_STATE.Bootloader: btnReboot.Enabled = false; btnProgram.Enabled = true; lblHudStatus.ForeColor = Color.Blue; lblHudStatus.Text = "BOOT LOADER MODE"; break; default: break; } } }