private void MainWindow_OnClosing(object sender, CancelEventArgs e) { foreach (var item in IpAddresses) { item.Status = String.Empty; item.Time = 0; } DataInteract.SaveCollection(IpAddresses); }
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { if (!File.Exists($@"{Directory.GetCurrentDirectory()}\config.json")) { File.Create($@"{Directory.GetCurrentDirectory()}\config.json").Close(); } tm.Enabled = false; tm.Elapsed += (o, args) => Pinging(); IpAddresses = DataInteract.GetCollection(); if (IpAddresses == null) IpAddresses = new ObservableCollection<Address>(); dg_data.ItemsSource = IpAddresses; }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(Ip_TextBox.Text) || string.IsNullOrWhiteSpace(Name_TextBox.Text)) { MessageBox.Show("IP-адрес и наименование должны быть заполнены!", "Ошибка!", MessageBoxButton.OK); return; } var parse = DataInteract.IsIp(Ip_TextBox.Text); if (!parse) { MessageBox.Show("Проверьте правильность ввода IP адреса!"); return; } IpAddresses.Add(new Address(Ip_TextBox.Text, Name_TextBox.Text)); Ip_TextBox.Clear(); Name_TextBox.Clear(); }