コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: gitter-badger/Gum
        private void AddNamedEventButton_Click(object sender, RoutedEventArgs e)
        {
            var textInputWindow = new TextInputWindow();

            textInputWindow.Message = "Enter new event name";
            var result = textInputWindow.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                AnimatedKeyframeViewModel newVm = new AnimatedKeyframeViewModel();

                newVm.EventName = textInputWindow.Result;

                if (ViewModel.SelectedAnimation.SelectedKeyframe != null)
                {
                    // put this after the current animation
                    newVm.Time = ViewModel.SelectedAnimation.SelectedKeyframe.Time + 1f;
                }
                else if (ViewModel.SelectedAnimation.Keyframes.Count != 0)
                {
                    newVm.Time = ViewModel.SelectedAnimation.Keyframes.Last().Time + 1f;
                }


                ViewModel.SelectedAnimation.Keyframes.Add(newVm);

                ViewModel.SelectedAnimation.Keyframes.BubbleSort();
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: jiailiuyan/Gum
        private void AddStateButton_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 = GetWhyAddingTimedStateIsInvalid();

            if (!string.IsNullOrEmpty(whyIsntValid))
            {
                MessageBox.Show(whyIsntValid);
            }
            else
            {
                ListBoxMessageBox lbmb = new ListBoxMessageBox();
                lbmb.RequiresSelection = true;
                lbmb.Message           = "Select a state";

                foreach (var state in SelectedState.Self.SelectedElement.AllStates)
                {
                    lbmb.Items.Add(state.Name);
                }

                var dialogResult = lbmb.ShowDialog();

                if (dialogResult.HasValue && dialogResult.Value)
                {
                    var item = lbmb.SelectedItem;

                    var newVm = new AnimatedKeyframeViewModel()
                    {
                        StateName = (string)item,
                        // User just selected the state, so it better be valid!
                        HasValidState     = true,
                        InterpolationType = FlatRedBall.Glue.StateInterpolation.InterpolationType.Linear,
                        Easing            = FlatRedBall.Glue.StateInterpolation.Easing.Out
                    };

                    if (ViewModel.SelectedAnimation.SelectedKeyframe != null)
                    {
                        // put this after the current animation
                        newVm.Time = ViewModel.SelectedAnimation.SelectedKeyframe.Time + 1f;
                    }
                    else if (ViewModel.SelectedAnimation.Keyframes.Count != 0)
                    {
                        newVm.Time = ViewModel.SelectedAnimation.Keyframes.Last().Time + 1f;
                    }

                    ViewModel.SelectedAnimation.Keyframes.Add(newVm);

                    ViewModel.SelectedAnimation.Keyframes.BubbleSort();
                }
            }
        }
コード例 #3
0
        private void AddSubAnimationButton_Click(object sender, RoutedEventArgs e)
        {
            ////////////// Early Out//////////
            if (ViewModel.SelectedAnimation == null)
            {
                MessageBox.Show("You must first select an animation");
                return;
            }
            /////////// End Early Out/////////

            SubAnimationSelectionWindow window = new SubAnimationSelectionWindow();

            window.AnimationToExclude = this.ViewModel.SelectedAnimation;

            window.AnimationContainers = CreateAnimationContainers();

            var result = window.ShowDialog();

            if (result.HasValue && result.Value && window.SelectedAnimation != null)
            {
                var selectedAnimation = window.SelectedAnimation;

                AnimatedKeyframeViewModel newVm = new AnimatedKeyframeViewModel();
                if (selectedAnimation.ContainingInstance != null)
                {
                    newVm.AnimationName = selectedAnimation.ContainingInstance.Name + "." + selectedAnimation.Name;
                }
                else
                {
                    newVm.AnimationName = selectedAnimation.Name;
                }

                newVm.SubAnimationViewModel = selectedAnimation;

                newVm.HasValidState = true;

                if (ViewModel.SelectedAnimation.SelectedKeyframe != null)
                {
                    // put this after the current animation
                    newVm.Time = ViewModel.SelectedAnimation.SelectedKeyframe.Time + 1f;
                }
                else if (ViewModel.SelectedAnimation.Keyframes.Count != 0)
                {
                    newVm.Time = ViewModel.SelectedAnimation.Keyframes.Last().Time + 1f;
                }


                ViewModel.SelectedAnimation.Keyframes.Add(newVm);

                ViewModel.SelectedAnimation.Keyframes.BubbleSort();
            }
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: jiailiuyan/Gum
        private void AddSubAnimationButton_Click(object sender, RoutedEventArgs e)
        {
            SubAnimationSelectionWindow window = new SubAnimationSelectionWindow();
            var result = window.ShowDialog();

            if (result.HasValue && result.Value && window.SelectedAnimation != null)
            {
                var selectedAnimation = window.SelectedAnimation;

                AnimatedKeyframeViewModel newVm = new AnimatedKeyframeViewModel();
                if (selectedAnimation.ContainingInstance != null)
                {
                    newVm.AnimationName = selectedAnimation.ContainingInstance.Name + "." + selectedAnimation.Name;
                }
                else
                {
                    newVm.AnimationName = selectedAnimation.Name;
                }

                newVm.SubAnimationViewModel = selectedAnimation;

                newVm.HasValidState = true;

                if (ViewModel.SelectedAnimation.SelectedKeyframe != null)
                {
                    // put this after the current animation
                    newVm.Time = ViewModel.SelectedAnimation.SelectedKeyframe.Time + 1f;
                }
                else if (ViewModel.SelectedAnimation.Keyframes.Count != 0)
                {
                    newVm.Time = ViewModel.SelectedAnimation.Keyframes.Last().Time + 1f;
                }


                ViewModel.SelectedAnimation.Keyframes.Add(newVm);

                ViewModel.SelectedAnimation.Keyframes.BubbleSort();
            }
        }
コード例 #5
0
ファイル: MainPlugin.cs プロジェクト: patridge/Gum
        private void HandleAddStateKeyframe(object sender, EventArgs e)
        {
            string whyIsntValid = GetWhyAddingTimedStateIsInvalid();

            if (!string.IsNullOrEmpty(whyIsntValid))
            {
                MessageBox.Show(whyIsntValid);
            }
            else
            {
                ListBoxMessageBox lbmb = new ListBoxMessageBox();
                lbmb.RequiresSelection = true;
                lbmb.Message           = "Select a state";

                var element = SelectedState.Self.SelectedElement;

                foreach (var state in element.States)
                {
                    lbmb.Items.Add(state.Name);
                }

                foreach (var category in element.Categories)
                {
                    foreach (var state in category.States)
                    {
                        lbmb.Items.Add(category.Name + "/" + state.Name);
                    }
                }


                var dialogResult = lbmb.ShowDialog();

                if (dialogResult.HasValue && dialogResult.Value)
                {
                    var item = lbmb.SelectedItem;

                    var newVm = new AnimatedKeyframeViewModel()
                    {
                        StateName = (string)item,
                        // User just selected the state, so it better be valid!
                        HasValidState     = true,
                        InterpolationType = FlatRedBall.Glue.StateInterpolation.InterpolationType.Linear,
                        Easing            = FlatRedBall.Glue.StateInterpolation.Easing.Out
                    };

                    newVm.AvailableStates  = this.AvailableStates;
                    newVm.PropertyChanged += HandleAnimatedKeyframePropertyChanged;

                    if (mCurrentViewModel.SelectedAnimation.SelectedKeyframe != null)
                    {
                        // put this after the current animation
                        newVm.Time = mCurrentViewModel.SelectedAnimation.SelectedKeyframe.Time + 1f;
                    }
                    else if (mCurrentViewModel.SelectedAnimation.Keyframes.Count != 0)
                    {
                        newVm.Time = mCurrentViewModel.SelectedAnimation.Keyframes.Last().Time + 1f;
                    }

                    mCurrentViewModel.SelectedAnimation.Keyframes.Add(newVm);

                    mCurrentViewModel.SelectedAnimation.Keyframes.BubbleSort();

                    mCurrentViewModel.SelectedAnimation.SelectedKeyframe = newVm;
                }
            }
        }