public MainWindow() { Assembly assem; string ver; InitializeComponent(); //Fill in version number assem = Assembly.GetExecutingAssembly(); ver = FileVersionInfo.GetVersionInfo(assem.Location).FileVersion; ver = ver.Substring(0, ver.LastIndexOf('.')); //If compiled with "DEBUG", let the user know this is a debug build #if DEBUG ver += " (debug)"; #endif version_num.Text = ver; //Setup logger log.setup_dispatcher(this.Dispatcher); log.setup_textbox(textBox_console); //Setup config form fields config.textbox_ping_url = textBox_url; config.textbox_attempts = textBox_attempts; config.textbox_delay = textBox_delay; //Load configuration file (or create if it doesn't exist) config.load_config("config.txt"); //Run any other setup functions needed tab_init(); //Setup net function helper net_util = new net_func(); net_util.setup_interface_combobox(combobox_network_interfaces); net_util.setup_access_point_combobox(combobox_network_access_points); net_util.update_adapter(); //Setup sledgehammer helper hammer = new sledgehammer(); //Setup the brushes for sledgehammer on and off brush_sh_off_bg = brush_from_rgba("#FF3A0A0A"); brush_sh_off_bd = brush_from_rgba("#FF640000"); brush_sh_off_fg = brush_from_rgba("#FFD40000"); brush_sh_on_bg = brush_from_rgba("#FF0C3A0A"); brush_sh_on_bd = brush_from_rgba("#FF006409"); brush_sh_on_fg = brush_from_rgba("#FF30D400"); //Sledgehammer is "off" by default; sh_on = false; }
/* * sledgehammer_toggle * * Enables/Disables the sledgehammer. */ private bool sledgehammer_toggle(sledgehammer hammer) { if (!sh_on) { int i_id, ap_id; //Test configuration if (config.is_valid() != 0) { return(false); } //Start by testing connection. if (!test_connection()) { return(false); } //Ok it was able to connect. Now start up the thread. i_id = combobox_network_interfaces.SelectedIndex; ap_id = combobox_network_access_points.SelectedIndex; thd_sh = new Thread(new ThreadStart(() => hammer.thread( net_util, i_id, ap_id ))); thd_sh.Start(); } else { //Brutally slaughter the thread. We're done here. thd_sh.Abort(); } //Flip variable and we're done. sh_on = !sh_on; return(true); }