Exemplo n.º 1
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(MyFavoriteTitle.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();
                MyFavoriteTitle.Focus();
                MyFavoriteTitle.SelectAll();
                return;
            }

            if (_OriginalFavoriteTitle.Equals(MyFavoriteTitle.Text))
            {
                DialogResult = true;
                return;
            }

            Favorite.RenameFavoriteSet(_OriginalFavoriteTitle, MyFavoriteTitle.Text);

            DialogResult = true;
        }
Exemplo n.º 2
0
        public EditFavoriteWindow(string favoriteTitle)
        {
            InitializeComponent();

            Header.Text          = "Rename: " + favoriteTitle;
            MyFavoriteTitle.Text = favoriteTitle;
            MyFavoriteTitle.SelectAll();

            _OriginalFavoriteTitle = favoriteTitle;

            // Set initial focus to text box.
            Loaded += (sender, e) =>
                      MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
        }
Exemplo n.º 3
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            // Validate favorite name.
            if (Favorite.IsTitleInvalid(MyFavoriteTitle.Text))
            {
                var errorWindow = DialogWindow.ErrorWindow($"Please enter a valid name for this favorite set.");
                errorWindow.Owner = this;
                errorWindow.ShowDialog();
                MyFavoriteTitle.Focus();
                MyFavoriteTitle.SelectAll();
                return;
            }

            if (_OriginalFavoriteTitle.Equals(MyFavoriteTitle.Text))
            {
                // User picked the same name.  Close edit window without making any changes.
                DialogResult = true;
                return;
            }

            // Update favorite set with new name.
            Favorite.RenameFavoriteSet(_OriginalFavoriteTitle, MyFavoriteTitle.Text);
            DialogResult = true;
        }