Ejemplo n.º 1
0
        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();
                }
            }
        }
Ejemplo n.º 2
0
        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();
                }
            }
        }