private async void parsedEntitiesNames_listBox_SelectedIndexChanged(object sender, EventArgs e) { try { if (this.userName_comboBox.Text != "") { //LogFileParser.foundElementInfo selectedPC = parsedEntities parsedEntity = parsedEntities.First(el => el.name == this.parsedEntitiesNames_listBox.SelectedItem.ToString()); this.PCinfo_textBox.Lines = new string[4] { parsedEntity.name, parsedEntity.count.ToString(), parsedEntity.firstLog, parsedEntity.lastLog + " [" + parsedEntity.lastLogType + "]" }; switch (selectedSearchType) { case SearchFor.users: selectedComputer = parsedEntity.name; break; case SearchFor.computers: selectedComputer = selectedComboboxItem; break; } this.explorer_button.Enabled = false; this.explorer_button.Enabled = await Task.Run(() => Directory.Exists("\\\\" + selectedComputer + "\\c$\\")); this.ping_button.Text = " PING"; } } catch (Exception) { } }
private void userName_comboBox_TextChanged(object sender, EventArgs e) { //this.userName_comboBox.DataSource = userNameVariants; if (userName_comboBox.Text.StartsWith("\u007f")) { userName_comboBox.Text = userName_comboBox.Text.Replace("\u007f", ""); } if (userName_comboBox.Text.Length > 0 /* | userNameVariants.Length > 0*/) { this.openAsist_button.Enabled = true; this.openRDP_button.Enabled = true; this.info_button.Enabled = Directory.Exists(Utility.configuration.inventoryPath); this.printerInfo_button.Enabled = File.Exists(Utility.configuration.rPrinterManagerPath); this.copy_button.Enabled = true; this.ping_button.Enabled = true; this.infinitePing_button.Enabled = true; this.ip_button.Enabled = true; string[] foundNames = UsernameInputProcessing.searchUsername(userName_comboBox.Text); int cursorPosition = userName_comboBox.SelectionStart; this.userName_comboBox.Items.Clear(); this.userName_comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown; this.userName_comboBox.DroppedDown = true; this.userName_comboBox.Select(cursorPosition, 0); this.userName_comboBox.Items.AddRange(foundNames); } else { this.openAsist_button.Enabled = false; this.openRDP_button.Enabled = false; this.info_button.Enabled = false; this.printerInfo_button.Enabled = false; this.copy_button.Enabled = false; this.ping_button.Enabled = false; this.infinitePing_button.Enabled = false; this.ip_button.Enabled = false; //this.userName_comboBox.DroppedDown = false; this.parsedEntitiesNames_listBox.DataSource = null; this.PCinfo_textBox.Clear(); this.parsedEntities = new LogFileParser.foundElementInfo[0]; this.userName_comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple; this.userName_comboBox.Text = ""; this.parsedEntity = new LogFileParser.foundElementInfo(); this.selectedComputer = null; } //чтобы курсор не падал за список и был виден Cursor.Current = Cursors.Default; }