private Button newButton(string name, string text) { System.Windows.Forms.Button b = new System.Windows.Forms.Button(); b.ForeColor = System.Drawing.Color.White; b.BackColor = System.Drawing.Color.FromArgb(95, 95, 95); b.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(31, 31, 31); b.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(62, 62, 62); b.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(127, 127, 127); b.FlatStyle = System.Windows.Forms.FlatStyle.Flat; b.UseVisualStyleBackColor = false; b.Font = new System.Drawing.Font( "Microsoft Sans Serif", 9.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0); b.Anchor = System.Windows.Forms.AnchorStyles.None; b.TabIndex = 1; b.AutoSize = true; b.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; b.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0); b.Margin = new System.Windows.Forms.Padding(0); b.Name = name; b.Text = text; b.Invalidate(); b.Update(); b.Click += new System.EventHandler(this.button_click); return(b); }
private void buttonEraseDeployment_Click(object sender, EventArgs e) { bool bWasStarted = EnsureDebuggerConnection(); Cursor old = Cursor.Current; Cursor = Cursors.WaitCursor; buttonEraseDeployment.Text = "Erasing..."; buttonEraseDeployment.Update(); NewText("Erasing Deployment Sector...\r\n"); try { _DBG.WireProtocol.Commands.Monitor_Ping.Reply ping = m_eng.GetConnectionSource(); if (ping == null) { NewText("Unable to connect to device\r\n"); return; } bool fClrConnection = ping.m_source == _DBG.WireProtocol.Commands.Monitor_Ping.c_Ping_Source_TinyCLR; if (fClrConnection) { m_eng.PauseExecution(); } _DBG.WireProtocol.Commands.Monitor_FlashSectorMap.Reply status = m_eng.GetFlashSectorMap() as _DBG.WireProtocol.Commands.Monitor_FlashSectorMap.Reply; if (status == null) { NewText("Erase Deployment may Not be supported on this device build\r\n"); } else { const uint c_deployFlag = _DBG.WireProtocol.Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_DEPLOYMENT; const uint c_usageMask = _DBG.WireProtocol.Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_MASK; foreach (_DBG.WireProtocol.Commands.Monitor_FlashSectorMap.FlashSectorData sector in status.m_map) { if (c_deployFlag == (c_usageMask & sector.m_flags)) { NewText(string.Format("Erasing sector at 0x{0:x08}\r\n", sector.m_address)); m_eng.EraseMemory(sector.m_address, sector.m_size); } } if (fClrConnection) { m_eng.RebootDevice(_DBG.Engine.RebootOption.RebootClrOnly); } NewText("Erase Deployment Successfull"); } } catch (Exception ex) { NewText("Exception: " + ex.Message + "\r\n"); } finally { buttonEraseDeployment.Text = "Erase Deployment"; Cursor = old; if (!bWasStarted) { m_eng.Stop(); m_eng = null; } } }
private void getButtonImput( Button button ) { button.Enabled = false; // prevents button from accepting input int count = 2000000; string oldText = button.Text; button.Text = "Waiting..."; button.Update(); int ID=-1; string type="-1"; //find system if (button.Name.Substring(0,button.Name.IndexOf("_")) == "Snes") { ID = int.Parse(SNES_device_comboBox.SelectedItem.ToString().Substring(SNES_device_comboBox.SelectedItem.ToString().IndexOf(":") + 1)); type = SNES_device_comboBox.SelectedItem.ToString().Substring(0, SNES_device_comboBox.SelectedItem.ToString().IndexOf("_")); } if (button.Name.Substring(0, button.Name.IndexOf("_")) == "NES") { ID = int.Parse(NES_device_comboBox.SelectedItem.ToString().Substring(NES_device_comboBox.SelectedItem.ToString().IndexOf(":") + 1)); type = NES_device_comboBox.SelectedItem.ToString().Substring(0, NES_device_comboBox.SelectedItem.ToString().IndexOf("_")); } if (button.Name.Substring(0, button.Name.IndexOf("_")) == "GBX") { ID = int.Parse(GBX_device_comboBox.SelectedItem.ToString().Substring(GBX_device_comboBox.SelectedItem.ToString().IndexOf(":") + 1)); type = GBX_device_comboBox.SelectedItem.ToString().Substring(0, GBX_device_comboBox.SelectedItem.ToString().IndexOf("_")); } while (count > 1)//check for button { Application.DoEvents(); if (DEL_PRESS) { hidContol.setDeviceLock( false); button.Tag = button.Text = "..."; DEL_PRESS = false; button.Enabled = true; return; }// this will delete the input if ( ESC_PRESS ) { hidContol.setDeviceLock( false ); ESC_PRESS = false; button.Enabled = true; button.Text = oldText; return; } count--; string returnText =""; string returnTextB = hidContol.getDeviceButton( ID, type );// id:type:button_friendlyName string returnTextA = hidContol.getDeviceAnalog( ID, type );// id:type:button_friendlyName if ( returnTextB == "Waiting..." ) returnText = returnTextA; else returnText = returnTextB; if (returnText != "Waiting...") { //button pressed. button.Tag = returnText;//info button.Text = returnText.Substring(returnText.LastIndexOf(":") + 1);//friendly name button.Update(); button.Enabled = true; // re enable. hidContol.setDeviceLock( false); return; } } hidContol.setDeviceLock( false); button.Enabled = true;//reenable button inputs button.Text = oldText;//gave up }