Beispiel #1
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            // Validate favorite name.
            if (Favorite.IsTitleInvalid(MyTitle.Text))
            {
                var errorWindow = DialogWindow.ErrorWindow($"Please enter a valid name for this favorite set.");
                errorWindow.Owner = this;
                errorWindow.ShowDialog();
                MyTitle.Focus();
                MyTitle.SelectAll();
                return;
            }

            // Check if favorite title already exists.
            if (Favorite.DoesTitleExist(MyTitle.Text))
            {
                var warningWindow = DialogWindow.WarningWindow(
                    message: $"{MyTitle.Text} already exists.  Would you like to overwrite?",
                    confirmButtonText: "Overwrite");
                warningWindow.Owner = this;
                if (warningWindow.ShowDialog() == true)
                {
                    // User opted to overwrite existing favorite entry.
                    SaveFavorite();
                }
            }
            else
            {
                // Checks passed.  Saving.
                SaveFavorite();
            }
        }
Beispiel #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            FavoriteTitle = txtTitle.Text;

            if (Favorite.DoesTitleExist(txtTitle.Text))
            {
                var dialogWindow = new DialogWindow(
                    DialogWindow.DialogIcon.Warning,
                    "Warning",
                    $"{txtTitle.Text} already exists.  Would you like to overwrite?",
                    "Overwrite");
                dialogWindow.Owner = this;
                if (dialogWindow.ShowDialog() == true)
                {
                    DialogResult = true;
                }
            }
            else
            {
                DialogResult = true;
            }
        }
Beispiel #3
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(MyTitle.Text))
            {
                var dialogWindow = new DialogWindow(
                    DialogWindow.DialogIcon.Warning,
                    "Error",
                    $"Please enter a valid name for this favorite set.",
                    "OK",
                    false);
                dialogWindow.Owner = this;
                dialogWindow.ShowDialog();
                MyTitle.Focus();
                MyTitle.SelectAll();
                return;
            }

            if (Favorite.DoesTitleExist(MyTitle.Text))
            {
                var dialogWindow = new DialogWindow(
                    DialogWindow.DialogIcon.Warning,
                    "Warning",
                    $"{MyTitle.Text} already exists.  Would you like to overwrite?",
                    "Overwrite",
                    true);
                dialogWindow.Owner = this;
                if (dialogWindow.ShowDialog() == true)
                {
                    Favorite.SaveFavoriteSet(MyTitle.Text, HostList, ColumnCount);
                    DialogResult = true;
                }
            }
            else
            {
                Favorite.SaveFavoriteSet(MyTitle.Text, HostList, ColumnCount);
                DialogResult = true;
            }
        }