Ejemplo n.º 1
0
        public void ConvertSelection(KeyFrameInterpolationType keyframeInterpolationType)
        {
            SceneNode sceneNode = this.selectedObjects[0];

            if (sceneNode.ViewModel == null)
            {
                return;
            }
            SceneViewModel viewModel = sceneNode.ViewModel;

            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.ConvertKeyFramesUndoUnit, false))
            {
                bool flag = false;
                foreach (object obj in this.selectedObjects)
                {
                    KeyFrameSceneNode keyFrame = obj as KeyFrameSceneNode;
                    if (keyFrame == null || keyFrame.KeyFrameAnimation == null)
                    {
                        flag = false;
                        break;
                    }
                    if (keyFrame.InterpolationType != keyframeInterpolationType)
                    {
                        KeyFrameSceneNode selectionToExtend = keyFrame.KeyFrameAnimation.ReplaceKeyFrame(keyFrame, keyframeInterpolationType, (KeySpline)null);
                        if (selectionToExtend == null)
                        {
                            flag = false;
                            break;
                        }
                        viewModel.KeyFrameSelectionSet.ExtendSelection(selectionToExtend);
                        flag = true;
                    }
                }
                if (flag)
                {
                    editTransaction.Commit();
                    viewModel.RefreshSelection();
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
        }