private void Online() { PMSFactory.PMSInterfaceType = IntaMate.Properties.Settings.Default.InterfaceAPI; if (PMSFactory.PMSInterface.Connect()) { LogBox.Clear(); bool Active = PMSFactory.PMSInterface.IsConnected(); logger.Info("PMS API Status : " + (Active ? "On line" : "Off Line")); if (Active) { lbEnabled.Text = "Active"; lbEnabled.ForeColor = System.Drawing.Color.Green; } else { lbEnabled.Text = "Disabled"; lbEnabled.ForeColor = this.lbEnabled.ForeColor = System.Drawing.Color.Red; } } else { lbEnabled.Text = "Disabled"; lbEnabled.ForeColor = this.lbEnabled.ForeColor = System.Drawing.Color.Red; } }
private void savetofilelog() { if (LogBox.Text != "") { bool newfile = true; string textlog = ""; if (File.Exists("log.txt")) { newfile = false; textlog = File.ReadAllText("log.txt"); File.WriteAllText("log.txt", ""); } else { newfile = true; File.WriteAllText("log.txt", ""); } using (var stream = File.CreateText("log.txt")) { stream.Write(LogBox.Text); LogBox.Clear(); if (!newfile) { stream.Write(textlog); } } } }
private void Main_Load(object sender, EventArgs e) { AllocConsole(); ShowWindow(GetConsoleWindow(), 0); LogBox.Clear(); LogData(LogType.System, "Logging started!"); }
private void RefreshView() { LogBox.Clear(); UPnP.Log.LockReading(() => { foreach (Tuple <UpnpLogType, string> item in UPnP.Log) { LogBox.SelectionStart = LogBox.Text.Length; LogBox.SelectionLength = 0; switch (item.Param1) { case UpnpLogType.In: LogBox.SelectionColor = Color.Blue; break; case UpnpLogType.Out: LogBox.SelectionColor = Color.Red; break; case UpnpLogType.Other: LogBox.SelectionColor = Color.Black; break; case UpnpLogType.Error: LogBox.SelectionColor = Color.Orange; break; } LogBox.AppendText(item.Param2 + "\n\n"); } }); }
private void PrintLog(String log) { if (this.LogBox.InvokeRequired) { printDelegate printInvoke = new printDelegate(PrintLog); this.LogBox.Invoke(printInvoke, log); } else { log = Regex.Replace(String.Format("{0}|{1}\n", DateTime.Now.ToString("hh:mm:ss.fff"), log), @"[\r\n]+", "\r\n"); this.LogBox.AppendText(log); byte[] LogByte = this.SerialPort.Encoding.GetBytes(log); if (this.CheckBox_SaveLog.Checked) { using (FileStream SaveFileWrite = new FileStream(@SavePath, FileMode.Append)) { SaveFileWrite.Write(LogByte, 0, LogByte.Length); } } if (LogBox.Lines.Length > 100) { int index = LogBox.Text.IndexOf("\n"); String newString = LogBox.Text.Remove(0, index + 2); LogBox.Clear(); LogBox.AppendText(newString); } } }
private void BT_Start_Click(object sender, EventArgs e) { if (BT_Start.Text == "循环扫描") { BT_Start.Text = "结束循环"; Control = true; PrintLog("开始循环!"); try { LogBox.Clear(); BT_Check_Port_Click(sender, e); new Thread(Cycle_Test).Start(); //measure.Join(); } catch (Exception exp) { PrintLog(exp.Message); } } else { BT_Start.Text = "循环扫描"; BT_Start.Enabled = true; Control = false; PrintLog("循环结束!"); } }
private async void MyCmdOpen_Click() { DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(MyDispatcherProgressBar); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); MaximumProgressBar = 5; ValueProgressBar = 0; LblTotal = "0"; LogBox.Clear(); Task <bool> resu1 = this.run(); LogBox.Add(cbLots_Item); LogBox.Add("Plase Wait..."); await resu1; LogBox.Add("Done.."); dispatcherTimer.Stop(); _Progress = 0; ValueProgressBar = 0; LblTotal = "0"; LogBox.Clear(); _run = false; }
private void MyRefresh() { txtPDFPath = string.Empty; txtPDFPath = PDFPath; using (SqlExcuteCommand get = new SqlExcuteCommand() { DBCnnStr = DBEndososCnnStr }) { _MyLotsTable = get.MyGetLot(StatusReydi, "3", WhatIsModo); cbLots.Clear(); LogBox.Clear(); LblTotal = string.Empty; _run = false; if (_MyLotsTable.Rows.Count == 0) { MessageBox.Show("No hay lotes ", "No Hay", MessageBoxButton.OK, MessageBoxImage.Information); } foreach (DataRow row in _MyLotsTable.Rows) { Lots myLots = new Lots(); myLots.Partido = row["Partido"].ToString(); myLots.Lot = row["Lot"].ToString(); myLots.Amount = row["Amount"].ToString(); myLots.Usercode = row["Usercode"].ToString(); myLots.AuthDate = row["AuthDate"].ToString(); myLots.Status = row["Status"].ToString(); myLots.VerDate = row["VerDate"].ToString(); myLots.VerUser = row["VerUser"].ToString(); myLots.FinUser = row["FinUser"].ToString(); myLots.FinDate = row["FinDate"].ToString(); myLots.RevDate = row["RevDate"].ToString(); myLots.RevUser = row["RevUser"].ToString(); myLots.conditions = row["conditions"].ToString(); myLots.ImportDate = row["ImportDate"].ToString(); myLots.Modo = int.Parse(row["Modo"].ToString()); if (WhatIsModo == 1) { if (myLots.Modo == 1) { cbLots.Add(myLots.Lot); } } else { if (myLots.Modo == 2) { cbLots.Add(myLots.Lot); } } } cbLots_Item_Id = -1; } }
public void GameInit() { // take no prisoners foreach (Transform childTransform in transform) { Destroy(childTransform.gameObject); } // obj pooling pool = new Dictionary <ID, Stack <Thing> >(); fxPool = new Dictionary <FX.ID, Stack <FX> >(); goodies.Clear(); baddies.Clear(); spawned.Clear(); graveyard.Clear(); logBox.Clear(); rng = new System.Random(); var size = 21; playerStart.x = size / 2; playerStart.y = size / 2; bounds.size = new Vector3Int(size, size, 1); var floorSize = new Vector2(bounds.size.x * Thing.SCALE.x, bounds.size.y * Thing.SCALE.y); floor.size = floorSize; floor.transform.localPosition = new Vector3(floorSize.x * 0.5f, -floorSize.y * 0.5f); ids = new Dictionary <Vector3Int, ID>(); things = new Dictionary <Vector3Int, Thing>(); teamPaths = new Dictionary <ID, Dictionary <Vector3Int, int> > { { ID.GOOD, new Dictionary <Vector3Int, int>() }, { ID.BAD, new Dictionary <Vector3Int, int>() } }; triggers = new Dictionary <Vector3Int, List <Thing> >(); // generate level Fill(bounds, ID.LOOT | ID.GOOD, 0.05f); //Fill(bounds, ID.MON | ID.BAD, 0.1f); Fill(bounds, ID.WALL, 0.2f); Fill(bounds, ID.HARD_WALL, 0.1f); ids[playerStart] = PLAYER_ID; // it's a monster, it's a baddie, and it's the spawner variant ids[playerStart + new Vector3Int(5, 0, 0)] = ID.MON | ID.BAD | (ID)Thing.Mon.SPAWNER; // convert foreach (var pos in ids.Keys) { GetMapThing(pos); } health.total = player.thing.hpTotal; health.value = player.thing.hp; score.value = 0; power.Init(10, 5); camCtrl.SetTarget(playerStart); camCtrl.SkipPan(); state = State.WAIT; logBox.Say("Welcome Rogue."); }
/// ------------------------------------------------------------------------------------ public void ReadFilesFromBackupFile(string backupFile) { WaitCursor.Show(); Utils.SetWindowRedraw(LogBox, false); LogBox.Clear(); _prjFiles.Clear(); _dataSourceFiles.Clear(); _audioFiles.Clear(); using (var zip = new ZipFile(backupFile)) { foreach (var filename in zip.EntryFileNames) { if (filename.StartsWith("Data/", StringComparison.Ordinal)) { _dataSourceFiles.Add(filename.Replace("Data/", string.Empty)); } else if (filename.StartsWith("Audio/", StringComparison.Ordinal)) { _audioFiles.Add(filename.Replace("Audio/", string.Empty)); } else if (filename != kBackupInfoFileName) { _prjFiles.Add(filename); if (filename.ToLowerInvariant().EndsWith(".pap", StringComparison.Ordinal)) { CurrentProjectFileName = filename; } } } } WriteLogMessagesForFileType(LocalizationManager.GetString("DialogBoxes.RestoreDlg.ProjectFilesFoundInBackupMsg", "Project Files Found In Backup File..."), _prjFiles); WriteLogMessagesForFileType(Environment.NewLine + LocalizationManager.GetString("DialogBoxes.RestoreDlg.DataSourceFilesFoundInBackupMsg", "Data Source Files Found In Backup File..."), _dataSourceFiles); WriteLogMessagesForFileType(Environment.NewLine + LocalizationManager.GetString("DialogBoxes.RestoreDlg.AudioFilesFoundInBackupMsg", "Aduio Files Found In Backup File..."), _audioFiles); LogBox.ScrollToTop(); Utils.SetWindowRedraw(LogBox, true); WaitCursor.Hide(); }
private void SetDefaultOptions() { BaudRateList.SelectedIndex = BaudRateList.Items.IndexOf("921600"); RawImageCheck.Checked = false; LogBox.Clear(); dbgHexBox.Clear(); dbgStringBox.Clear(); CaptureBtn.Enabled = false; pictureBox1.Image = null; ResolutionList.Enabled = false; ExposureList.Enabled = false; PortsList.Enabled = true; BaudRateList.Enabled = true; RawImageCheck.Enabled = false; }
private void ManualQueryButton_Click(object sender, EventArgs e) { OpenFileDialog openMNISTDialog = new OpenFileDialog(); openMNISTDialog.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath) + "\\MNIST Image"; openMNISTDialog.Filter = "All files (*.*)|*.*|.bmp files(*.bmp)|*.bmp"; openMNISTDialog.FilterIndex = 2; openMNISTDialog.RestoreDirectory = true; if (openMNISTDialog.ShowDialog() == DialogResult.OK) { LogBox.Clear(); double[] input = new double[784]; double[] output; string file_addr = openMNISTDialog.FileName; string file_name = Path.GetDirectoryName(file_addr); Bitmap Image = new Bitmap(file_addr); LookWindow.Image = Image; for (int y = 0; y < 28; y++) { for (int x = 0; x < 28; x++) { input[x + y * x] = 255 * (1 - Convert.ToDouble(Image.GetPixel(x, y).GetBrightness())); } } output = network.Query(input); for (int x = 0; x < output.Length; x++) { if (output[x] >= 0.75) { LogBox.Text += network.neuron_arrays[network.neuron_arrays.Length - 1][x].name + " => TRUE\r\n"; } else if (output[x] >= 0.5) { LogBox.Text += network.neuron_arrays[network.neuron_arrays.Length - 1][x].name + " => MAYBE\r\n"; } else if (output[x] < 0.5) { LogBox.Text += network.neuron_arrays[network.neuron_arrays.Length - 1][x].name + " => FALSE\r\n"; } } } }
/* * * Services * */ internal void UpdateLogBox(Bot bot) { if (bot == null) { LogBox.Clear(); return; } string text = bot.getLogBoxText(); if (LogBox.Rtf == text) { return; } LogBox.Rtf = text; LogBox.SelectionStart = LogBox.Text.Length; LogBox.ScrollToCaret(); }
private void OnLogBox(string Message) { if (LogBox.InvokeRequired) { LogBox.Invoke(new OnLogBoxDelegate(OnLogBox), new object[] { Message }); } else { if (LogBox.Lines.Length == 150) { LogBox.Clear(); LogBox.AppendText(Message + Environment.NewLine); } else { LogBox.AppendText(Message + Environment.NewLine); } } }
void SyncNow_Click(object sender, EventArgs e) { // update the property key value before doing the sync UpdateEventPropertyKey(); bSyncNow.Enabled = false; lNextSync.Text = "Next scheduled sync:\n In progress..."; LogBox.Clear(); DateTime SyncStarted = DateTime.Now; logboxout("Sync started at " + SyncStarted.ToString()); logboxout("--------------------------------------------------"); Boolean syncOk = synchronize(); logboxout("--------------------------------------------------"); logboxout(syncOk ? "Sync finished with success!" : "Sync finished with errors!"); if (syncOk) { lastSyncDate = SyncStarted; Settings.Instance.LastSyncDate = lastSyncDate; XMLManager.export(Settings.Instance, FILENAME); lLastSync.Text = "Last succeded synchro:\n " + SyncStarted.ToLongDateString() + " - " + SyncStarted.ToLongTimeString(); setNextSync(getResyncInterval()); } else { setNextSync(5); } if (!Settings.Instance.OutlookKeepOpenAfterSync) { // close the outlook calendar instance so not to always be logged in OutlookCalendar.Instance.Release(); } bSyncNow.Enabled = true; }
private void StartButton_Click(object sender, EventArgs e) { var item = ApplicationBox.SelectedItem?.ToString(); if (string.IsNullOrWhiteSpace(item)) { return; } if (BoardScriptBox.Lines.Length <= 0) { return; } ApplicationBox.Enabled = false; BoardScriptBox.Enabled = false; MouseScriptBox.Enabled = false; ShiftBox.Enabled = false; EnableMouseScriptBox.Enabled = false; RefreshButton.Enabled = false; StartButton.Enabled = false; BindingBox.Enabled = false; LoadButton.Enabled = false; SaveButton.Enabled = false; StopButton.Enabled = true; LogBox.Clear(); var split = item.LastIndexOf("|", StringComparison.Ordinal); _data.ProcessId = int.Parse(item.Substring(split + 1).Trim()); _data.ProcessName = item.Substring(0, split).Trim(); _data.BoardScript = BoardScriptBox.Lines; _data.MouseScript = EnableMouseScriptBox.Checked ? MouseScriptBox.Lines : null; _data.ShiftControlled = EnableMouseScriptBox.Checked && ShiftBox.Checked; _data.Binding = (MouseButtons)BindingBox.SelectedItem; _data.Enabled = false; _data.StartWorkerThread(WorkerStart); _mouseHook.SetHook(); }
/// ------------------------------------------------------------------------------------ protected void PerformBackupOrRestore(Action <int> reportProgressAction, Action finishedAction) { WaitCursor.Show(); LogBox.Clear(); try { using (_worker = new BackgroundWorker()) { _worker.DoWork += PerformBackgroundWork; _worker.WorkerReportsProgress = true; _worker.ProgressChanged += (s, e) => reportProgressAction(e.ProgressPercentage); _worker.RunWorkerCompleted += (s, e) => finishedAction(); _worker.RunWorkerAsync(); while (_worker.IsBusy) { Application.DoEvents(); } } } catch (Exception error) { BackupRestoreException = error; } finally { if (BackupRestoreException != null) { LogBox.Clear(); LogBox.WriteException(BackupRestoreException); } _worker = null; WaitCursor.Hide(); } }
private void tBtnConnect_Click(object sender, EventArgs e) { #region ---------线程方式连接设备(废弃)---------- //Thread thread = new Thread(() => { // for (int i = 0; i < AllDevices.Count; i++) // { // AllDevices[i].Prot.Open(); // if (AllDevices[i].ConnectionState) // { // ChangeComListView(i, 1, "已连接"); // } // } //}); //thread.Start(); #endregion #region ---------线程池方式连接设备---------- //ThreadPool.QueueUserWorkItem(new WaitCallback((obj) => //{ // for (int i = 0; i < AllDevices.Count; i++) // { // AllDevices[i].Prot.Open(); // if (AllDevices[i].ConnectionState) // { // ChangeComListView(i, 1, "已连接"); // } // } //})); #endregion //清空日志 LogBox.Clear(); //工作状态 WorkModelLabel.Text = "模式:已连接"; //连接设备并测ISMI if (fristCheckIMSI) { #region ------------初始检测全部设备的IMSI,采用线程池方式检测------------ for (int i = 0; i < AllDevices.Count; i++) { AllDevices[i].PhoneNumber = null; ThreadPool.QueueUserWorkItem(new WaitCallback((obj) => { int x = (int)obj; AllDevices[x].Open(); if (AllDevices[x].ConnectionState) { ChangeComListView(x, (int)ListViewSetting.ColumnIndex.连接状态, "已连接"); } else { ChangeComListView(x, (int)ListViewSetting.ColumnIndex.连接状态, "未连接"); lock (disableDevicesObj) { DisableDevices.Add(AllDevices[x]); } return; } string str = AllDevices[x].ExecuteCommand("AT+CIMI"); Regex reg = new Regex(@"\d{15}", RegexOptions.Multiline); var match = reg.Match(str); if (match.Success) { AllDevices[x].IMSI = match.Value; //AllDevices[x].SMSReceived += MainFrm_SMSReceived; str = AllDevices[x].ExecuteCommand("AT+CCID"); reg = new Regex(@"\d{20}", RegexOptions.Multiline); match = reg.Match(str); if (match.Success) { AllDevices[x].CCID = match.Value; lock (readyDevicesObj) { ReadyDevices.Add(AllDevices[x]); ChangeComListView(x, (int)ListViewSetting.ColumnIndex.IMSI, AllDevices[x].IMSI); ChangeComListView(x, (int)ListViewSetting.ColumnIndex.CCID, AllDevices[x].CCID); ChangeCountStatusLab(string.Format("设备总数:{0},可用设备数:{1}", AllDevices.Count, ReadyDevices.Count)); } } } else { lock (disableDevicesObj) { DisableDevices.Add(AllDevices[x]); ChangeComListView(x, (int)ListViewSetting.ColumnIndex.IMSI, "无"); ChangeComListView(x, (int)ListViewSetting.ColumnIndex.CCID, "无"); } } }), i); } #endregion fristCheckIMSI = false; } else { #region ------------二次检测不可用设备的IMSI,采用单线程式检测------------ //单线程检测不可用设备情况 ThreadPool.QueueUserWorkItem(new WaitCallback((obj) => { for (int i = 0; i < DisableDevices.Count; i++) { if (!DisableDevices[i].ConnectionState) { DisableDevices[i].Open(); if (DisableDevices[i].ConnectionState) { ChangeComListView(i, (int)ListViewSetting.ColumnIndex.连接状态, "已连接"); } else { continue; } } string str = DisableDevices[i].ExecuteCommand("AT+CIMI"); Regex reg = new Regex(@"\d{15}", RegexOptions.Multiline); var match = reg.Match(str); if (match.Success) { DisableDevices[i].IMSI = match.Value; //DisableDevices[i].SMSReceived += MainFrm_SMSReceived; str = AllDevices[i].ExecuteCommand("AT+CCID"); reg = new Regex(@"\d{20}", RegexOptions.Multiline); match = reg.Match(str); if (match.Success) { DisableDevices[i].CCID = match.Value; ReadyDevices.Add(DisableDevices[i]); ChangeComListView(DisableDevices[i].PortName, (int)ListViewSetting.ColumnIndex.IMSI, DisableDevices[i].IMSI); ChangeComListView(DisableDevices[i].PortName, (int)ListViewSetting.ColumnIndex.CCID, DisableDevices[i].CCID); ChangeCountStatusLab(string.Format("设备总数:{0},可用设备数:{1}", AllDevices.Count, ReadyDevices.Count)); DisableDevices.RemoveAt(i);//从不可用设备集合中移除可用设备 i--; } } } })); #endregion } //workFlag = true; }
private void ClearLogMenuItem_Click(object sender, EventArgs e) { LogBox.Clear(); }
private void ClearLogBoxButton_Click(object sender, EventArgs e) { LogBox.Clear(); }
/// <summary> /// This is the main HOSTS file button event handler. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RedirectButton_Click(object sender, EventArgs e) { // Clear the output window LogBox.Clear(); // Show exception message on button push if we cant read or write if (!HostsFile.CanRead) { string message = "Unable to READ the HOST file! Please make sure this program is being ran as an administrator, or " + "modify your HOSTS file permissions, allowing this program to read/modify it."; MessageBox.Show(message, "Hosts file Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (!HostsFile.CanWrite) { string message = "HOSTS file is not WRITABLE! Please make sure this program is being ran as an administrator, or " + "modify your HOSTS file permissions, allowing this program to read/modify it."; MessageBox.Show(message, "Hosts file Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } // If we do not have a redirect in the hosts file... else if (!RedirectsEnabled) { // Make sure we are going to redirect something... if (!Bf2webCheckbox.Checked && !GpcmCheckbox.Checked) { MessageBox.Show( "Please select at least 1 redirect option", "Select an Option", MessageBoxButtons.OK, MessageBoxIcon.Information ); return; } // Lock button and groupboxes LockGroups(); // First, lets determine what the user wants to redirect if (Bf2webCheckbox.Checked) { // Make sure we have a valid IP address in the address box! string text = Bf2webAddress.Text.Trim(); if (text.Length < 8) { MessageBox.Show( "You must enter an IP address or Hostname in the Address box!", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Warning ); UnlockGroups(); Bf2webAddress.Focus(); return; } // Convert Localhost to the Loopback Address if (text.ToLower().Trim() == "localhost") { text = IPAddress.Loopback.ToString(); } // Check if this is an IP address or hostname IPAddress BF2Web; try { UpdateStatus("- Resolving Hostname: " + text); BF2Web = GetIpAddress(text); UpdateStatus("- Found IP: " + BF2Web); } catch { MessageBox.Show( "Stats server redirect address is invalid, or doesnt exist. Please enter a valid, and existing IPv4/6 or Hostname.", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Warning ); UpdateStatus("- Failed to Resolve Hostname!"); UnlockGroups(); return; } // Append line, and update status HostsFile.Set("bf2web.gamespy.com", BF2Web.ToString()); Config.LastStatsServerAddress = Bf2webAddress.Text.Trim(); UpdateStatus("- Adding bf2web.gamespy.com redirect to hosts file"); } // First, lets determine what the user wants to redirect if (GpcmCheckbox.Checked) { // Make sure we have a valid IP address in the address box! string text2 = GpcmAddress.Text.Trim(); if (text2.Length < 8) { MessageBox.Show( "You must enter an IP address or Hostname in the Address box!", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Warning ); UnlockGroups(); GpcmAddress.Focus(); return; } // Convert Localhost to the Loopback Address if (text2.ToLower().Trim() == "localhost") { text2 = IPAddress.Loopback.ToString(); } // Make sure the IP address is valid! IPAddress GpcmA; try { UpdateStatus("- Resolving Hostname: " + text2); GpcmA = GetIpAddress(text2); UpdateStatus("- Found IP: " + GpcmA); } catch { MessageBox.Show( "Login Server redirect address is invalid, or doesnt exist. Please enter a valid, and existing IPv4/6 or Hostname.", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Warning ); UpdateStatus("- Failed to Resolve Hostname!"); UnlockGroups(); return; } // Update status UpdateStatus("- Adding gpcm.gamespy.com redirect to hosts file"); UpdateStatus("- Adding gpsp.gamespy.com redirect to hosts file"); // Append lines to hosts file HostsFile.Set("gpcm.gamespy.com", GpcmA.ToString()); HostsFile.Set("gpsp.gamespy.com", GpcmA.ToString()); Config.LastLoginServerAddress = GpcmAddress.Text.Trim(); } // Save last used addresses Config.Save(); // Create new instance of the background worker HostsWorker = new BackgroundWorker(); HostsWorker.WorkerSupportsCancellation = true; // Write the lines to the hosts file UdpateStatus("- Writting to hosts file... ", false); try { // Save lines to hosts file HostsFile.Set("motd.gamespy.com", IPAddress.Loopback.ToString()); HostsFile.Set("master.gamespy.com", IPAddress.Loopback.ToString()); HostsFile.Set("battlefield2.ms14.gamespy.com", IPAddress.Loopback.ToString()); HostsFile.Set("battlefield2.available.gamespy.com", IPAddress.Loopback.ToString()); HostsFile.Save(); UpdateStatus("Success!"); // Flush DNS Cache FlushDNS(); // Do pings, And lock hosts file. We do this in // a background worker so the User can imediatly start // the BF2 client while the HOSTS redirect finishes HostsWorker.DoWork += new DoWorkEventHandler(RebuildDNSCache); HostsWorker.RunWorkerAsync(); // Set form data RedirectsEnabled = true; RedirectButton.Text = "Remove HOSTS Redirect"; RedirectButton.Enabled = true; } catch { UpdateStatus("Failed!"); UnlockGroups(); MessageBox.Show( "Unable to WRITE to HOSTS file! Please make sure to replace your HOSTS file with " + "the one provided in the release package, or remove your current permissions from the HOSTS file. " + "It may also help to run this program as an administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } } else { // Lock the button RedirectButton.Enabled = false; // Create new instance of the background worker if (HostsWorker == null) { HostsWorker = new BackgroundWorker(); HostsWorker.WorkerSupportsCancellation = true; } // Stop worker if its busy if (HostsWorker.IsBusy) { LoadingForm.ShowScreen(this); this.Enabled = false; HostsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(HostsWorker_RunWorkerCompleted); HostsWorker.CancelAsync(); return; } UndoRedirects(); } }
private void metroButton4_Click(object sender, EventArgs e) { LogBox.Clear(); }
private void ClearBtn_OnClick(object sender, RoutedEventArgs e) { LogBox.Clear(); }
private void LogClear_Click(object sender, EventArgs e) { LogBox.Clear(); }
private void TrainButton_Click(object sender, EventArgs e) { int epochs = 100; double index = 0.3; string[] filePaths = Directory.GetFiles(@"MNIST Image\\", "*.bmp", SearchOption.AllDirectories); string image_addr; string image_name; Bitmap image; Bitmap percent_graph = new Bitmap(percent_box.Width * 999, percent_box.Height); double error_percent = 0; Random rand = new Random(); try { epochs = Convert.ToInt32(EpochBox.Text); } catch (FormatException) { epochs = 100; EpochBox.Text = "100"; } try { index = Convert.ToInt32(IndexBox.Text); } catch (FormatException) { index = 0.3; IndexBox.Text = "0,3"; } if (EpochBox.Text == "") { EpochBox.Text = "100"; } if (IndexBox.Text == "") { IndexBox.Text = "0,3"; } using (Graphics g = Graphics.FromImage(percent_graph)) { g.Clear(Color.Black); } for (int epoch = 0; epoch < epochs; epoch++) { error_percent = 0; for (int file = 0; file < filePaths.Length; file++) { image_addr = filePaths[rand.Next(0, filePaths.Length)]; image_name = Path.GetFileName(image_addr); image = new Bitmap(image_addr); LookWindow.Image = image; LookWindow.Refresh(); for (int x = 0; x < answer.Length; x++) { if (network.neuron_arrays[network.neuron_arrays.Length - 1][x].name == "unnamed") { network.neuron_arrays[network.neuron_arrays.Length - 1][x].name = new DirectoryInfo(Directory.GetDirectories(@"MNIST Image")[x]).Name; } if (network.neuron_arrays[network.neuron_arrays.Length - 1][x].name == Path.GetFileName(Path.GetDirectoryName(image_addr))) { answer[x] = 1; } else { answer[x] = 0; } } for (int y = 0; y < 28; y++) { for (int x = 0; x < 28; x++) { input[x + y * x] = 1 - Convert.ToDouble(image.GetPixel(x, y).GetBrightness()); } } output = network.Query(input); LogBox.Clear(); double sum = 0; for (int x = 0; x < output.Length; x++) { if (answer[x] == 1) { error_percent += (1 - output[x]) / filePaths.Length; } else { error_percent += output[x] / filePaths.Length; } sum += output[x]; } for (int x = 0; x < output.Length; x++) { LogBox.Text += network.neuron_arrays[network.neuron_arrays.Length - 1][x].name + " => " + Convert.ToString((output[x] / sum) * 100).Substring(0, 4) + "%\r\n"; } LogBox.Refresh(); network.Train(input, answer, index); //Thread.Sleep(500);} } if (error_percent > 1) { error_percent = 1; } try { ErrorLabel.Text = Convert.ToString(error_percent * 100).Substring(0, 5) + "%"; } catch (ArgumentOutOfRangeException) { ErrorLabel.Text = "100%"; } ErrorLabel.Refresh(); using (Graphics g = Graphics.FromImage(percent_graph)) { int a = Convert.ToInt32((percent_graph.Width / epochs) * epoch); int b = Convert.ToInt32(percent_graph.Height - percent_graph.Height * error_percent); int c = Convert.ToInt32(percent_graph.Width / epochs); int d = Convert.ToInt32(percent_graph.Height * error_percent); g.DrawRectangle(new Pen(Color.Green, 1), new Rectangle(a, b, c, d)); g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(a, b, c, d)); } percent_box.Image = percent_graph; percent_box.Refresh(); } /*ouble[] input = {1.0, 0.5, -1.5}; * double[] answer = {0.20813168, 0.22549015, 0.99742175}; * double index = 0.3; * double[] output = new double[3]; * output = network.Query(input); * network.Train(input, answer, index); * output = network.Query(input);*/ }
private void ClearBtn_Click(object sender, EventArgs e) { dbgHexBox.Clear(); dbgStringBox.Clear(); LogBox.Clear(); }
private void button1_Click(object sender, EventArgs e) { LogBox.Clear(); }
private void AutoQueryButton_Click(object sender, EventArgs e) { double[] input = new double[784]; double[] answer = new double[10]; double[] output = new double[10]; string[] filePaths = Directory.GetFiles(@"MNIST Image\\", "*.bmp", SearchOption.AllDirectories); string image_addr; string image_name; Bitmap image; Bitmap percent_graph = new Bitmap(percent_box.Width * 999, percent_box.Height); double error_percent = 0; LogBox.Clear(); using (Graphics g = Graphics.FromImage(percent_graph)) { g.Clear(Color.Black); } for (int file = 0; file < filePaths.Length; file++) { error_percent = 0; image_addr = filePaths[file]; image_name = Path.GetFileName(image_addr); image = new Bitmap(image_addr); LookWindow.Image = image; LookWindow.Refresh(); for (int x = 0; x < answer.Length; x++) { if (network.neuron_arrays[network.neuron_arrays.Length - 1][x].name == "unnamed") { network.neuron_arrays[network.neuron_arrays.Length - 1][x].name = new DirectoryInfo(Directory.GetDirectories(@"MNIST Image")[x]).Name; } if (network.neuron_arrays[network.neuron_arrays.Length - 1][x].name == Path.GetFileName(Path.GetDirectoryName(image_addr))) { answer[x] = 1; } else { answer[x] = 0; } } for (int y = 0; y < 28; y++) { for (int x = 0; x < 28; x++) { input[x + y * x] = 255 * (1 - Convert.ToDouble(image.GetPixel(x, y).GetBrightness())); } } output = network.Query(input); //LogBox.Clear(); double sum = 0; bool mistake = false; for (int x = 0; x < output.Length; x++) { if (answer[x] == 1) { error_percent += (1 - output[x]) / answer.Length; } else { error_percent += output[x] / answer.Length; if (output[x] >= 0.5) { mistake = true; } } sum += output[x]; } if (mistake) { LogBox.Text += "Error in " + Path.GetFileName(filePaths[file]) + "\r\n"; } LogBox.Refresh(); if (error_percent > 1) { error_percent = 1; } try { ErrorLabel.Text = Convert.ToString(error_percent * 100).Substring(0, 5) + "%"; } catch (ArgumentOutOfRangeException) { ErrorLabel.Text = "100%"; } ErrorLabel.Refresh(); using (Graphics g = Graphics.FromImage(percent_graph)) { int a = Convert.ToInt32((percent_graph.Width / filePaths.Length) * file); int b = Convert.ToInt32(percent_graph.Height - percent_graph.Height * error_percent); int c = Convert.ToInt32(percent_graph.Width / filePaths.Length); int d = Convert.ToInt32(percent_graph.Height * error_percent); g.DrawRectangle(new Pen(Color.Green, 1), new Rectangle(a, b, c, d)); g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(a, b, c, d)); } percent_box.Image = percent_graph; percent_box.Refresh(); } }
private void ResetUi() { LogBox.Clear(); Progress.Value = 0; ProgressLabel.Text = string.Empty; }
private async void Start_Click(object sender, EventArgs e) { MessageBox.Show("The downloader is more stable if it has focus (dont click away)!", "Asset Downloader", MessageBoxButtons.OK, MessageBoxIcon.Information); ItemIDs.Clear(); if (Directory.Exists($"{SaveDirectory}\\temp")) { try { Directory.Delete($"{SaveDirectory}\\temp"); } catch { MessageBox.Show("Unable to delete temp folder, please make sure you haven't touched it!", "Asset Downloader", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Directory.CreateDirectory(SaveDirectory + "\\temp"); Directory.CreateDirectory(SaveDirectory + "\\Shirts"); Directory.CreateDirectory(SaveDirectory + "\\Pants"); Directory.CreateDirectory(SaveDirectory + "\\Audio"); Directory.CreateDirectory(SaveDirectory + "\\Accessories"); LogBox.Clear(); LogData(LogType.System, "Logging started!"); await Task.Delay(15); if (!ManualInputCheck.Checked) { LogData(LogType.System, $"Fetching {ItemCount.Text} IDs for assets: {ItemTypeCombo.Text}"); FetchIDs(); } await Task.Delay(15); LogData(LogType.System, "Gather specific IDs..."); ManualIDs(); await Task.Delay(15); LogData(LogType.System, $"Done fetching asset IDs!"); LogData(LogType.System, $"Continuing to download in ~3 seconds!"); ItemIDs = ItemIDs.Distinct().ToList(); await Task.Delay(2500); StartSave(); await Task.Delay(Convert.ToInt32((int.Parse(ItemCount.Text) * 10) / 1.2)); new Thread(async() => { for (; ;) { await Task.Delay(50); if (FinishedItems >= ItemIDs.Count - Math.Floor((ItemIDs.Count / 3) + .0)) { LogData(LogType.System, "Finished count is closing on ItemCount!"); ItemTypeCombo.Invoke(new Action(() => { LogData(LogType.System, $"Files saved: {Directory.GetFiles($"{SaveDirectory}\\{ItemTypeCombo.Text}").Count()} / {ItemIDs.Count}"); if (Directory.GetFiles($"{SaveDirectory}\\{ItemTypeCombo.Text}").Count() != ItemIDs.Count) { LogData(LogType.System, "Due to issues with some assets, some failed to download!"); } })); LogData(LogType.System, "Opening directory!"); ItemTypeCombo.Invoke(new Action(() => { Process.Start($"{SaveDirectory}\\{ItemTypeCombo.Text}"); })); break; } } }).Start(); }