private void Save_Click(object sender, RoutedEventArgs e)
        {
            // Validate hostname.
            if (Alias.IsHostInvalid(MyHost.Text))
            {
                var errorWindow = DialogWindow.ErrorWindow($"Please enter a valid host name.");
                errorWindow.Owner = this;
                errorWindow.ShowDialog();
                MyHost.Focus();
                MyHost.SelectAll();
                return;
            }

            // Validate alias name.
            if (Alias.IsNameInvalid(MyAlias.Text))
            {
                var errorWindow = DialogWindow.ErrorWindow($"Please enter a valid alias.");
                errorWindow.Owner = this;
                errorWindow.ShowDialog();
                MyAlias.Focus();
                MyAlias.SelectAll();
                return;
            }

            // Checks passed.  Add alias entry.
            Alias.AddAlias(MyHost.Text.ToUpper(), MyAlias.Text);
            DialogResult = true;
        }
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(MyHost.Text))
            {
                var dialogWindow = new DialogWindow(
                    DialogWindow.DialogIcon.Warning,
                    "Error",
                    $"Please enter a valid host name.",
                    "OK",
                    false);
                dialogWindow.Owner = this;
                dialogWindow.ShowDialog();
                MyHost.Focus();
                MyHost.SelectAll();
                return;
            }

            if (string.IsNullOrWhiteSpace(MyAlias.Text))
            {
                var dialogWindow = new DialogWindow(
                    DialogWindow.DialogIcon.Warning,
                    "Error",
                    $"Please enter a valid alias.",
                    "OK",
                    false);
                dialogWindow.Owner = this;
                dialogWindow.ShowDialog();
                MyAlias.Focus();
                MyAlias.SelectAll();
                return;
            }

            Alias.AddAlias(MyHost.Text.ToUpper(), MyAlias.Text);
            DialogResult = true;
        }
Exemple #3
0
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(MyAlias.Text))
     {
         Alias.DeleteAlias(_Hostname);
     }
     else
     {
         Alias.AddAlias(_Hostname, MyAlias.Text);
     }
     DialogResult = true;
 }