private void HandleRenameAnimation(object sender, RoutedEventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();

            tiw.Message = "Enter new animation name:";
            tiw.Result  = SelectedAnimation.Name;

            var dialogResult = tiw.ShowDialog();

            if (dialogResult == System.Windows.Forms.DialogResult.OK)
            {
                string whyInvalid;
                if (!NameValidator.IsAnimationNameValid(tiw.Result, Animations, out whyInvalid))
                {
                    MessageBox.Show(whyInvalid);
                }
                else
                {
                    var oldAnimationName = SelectedAnimation.Name;
                    SelectedAnimation.Name = tiw.Result;

                    StateAnimationPlugin.Managers.RenameManager.Self.HandleRename(
                        SelectedAnimation,
                        oldAnimationName, Animations, Element);
                }
            }
        }
Ejemplo n.º 2
0
        private void AddAnimationButton_Click(object sender, RoutedEventArgs e)
        {
            if (ViewModel == null)
            {
                throw new NullReferenceException("The ViewModel for this is invalid - set the DataContext on this view before showing it.");
            }

            string whyIsntValid = null;

            if (!string.IsNullOrEmpty(whyIsntValid))
            {
                MessageBox.Show(whyIsntValid);
            }
            else
            {
                TextInputWindow tiw = new TextInputWindow();
                tiw.Message = "Enter new animation name:";

                var dialogResult = tiw.ShowDialog();

                if (dialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    string whyInvalid;
                    if (!NameValidator.IsAnimationNameValid(tiw.Result, this.ViewModel.Animations, out whyInvalid))
                    {
                        MessageBox.Show(whyInvalid);
                    }
                    else
                    {
                        var newAnimation = new AnimationViewModel()
                        {
                            Name = tiw.Result
                        };

                        this.ViewModel.Animations.Add(newAnimation);

                        this.ViewModel.SelectedAnimation = newAnimation;
                    }
                }
            }
        }