Example #1
0
        /// <inheritdoc/>
        public void OpenCurveEditorWindow([NotNull] object curve, string name)
        {
            if (curve == null)
            {
                throw new ArgumentNullException(nameof(curve));
            }
            if (dockingLayoutManager == null)
            {
                throw new InvalidOperationException("This method can only be invoked on the IEditorDialogService that has the editor main window as parent.");
            }

            CurveEditorViewModel editorViewModel = null;
            LayoutAnchorable     editorPane      = null;

            if (curveEditor != null)
            {
                // curve editor already exists
                editorViewModel = curveEditor.Item1;
                editorPane      = curveEditor.Item2;
            }

            // Create the editor view model if needed
            if (editorViewModel == null)
            {
                editorViewModel = new CurveEditorViewModel(session.ServiceProvider, session);
            }

            // Populate the editor view model
            if (curve is IComputeCurve <Color4> )
            {
                editorViewModel.AddCurve((IComputeCurve <Color4>)curve, name);
            }
            else if (curve is IComputeCurve <float> )
            {
                editorViewModel.AddCurve((IComputeCurve <float>)curve, name);
            }
            else if (curve is IComputeCurve <Quaternion> )
            {
                editorViewModel.AddCurve((IComputeCurve <Quaternion>)curve, name);
            }
            else if (curve is IComputeCurve <Vector2> )
            {
                editorViewModel.AddCurve((IComputeCurve <Vector2>)curve, name);
            }
            else if (curve is IComputeCurve <Vector3> )
            {
                editorViewModel.AddCurve((IComputeCurve <Vector3>)curve, name);
            }
            else if (curve is IComputeCurve <Vector4> )
            {
                editorViewModel.AddCurve((IComputeCurve <Vector4>)curve, name);
            }

            editorViewModel.Focus();

            // Create the editor pane if needed
            if (editorPane == null)
            {
                editorPane = new LayoutAnchorable
                {
                    Content = new CurveEditorView {
                        DataContext = editorViewModel
                    },
                    Title    = "Curve Editor",
                    CanClose = true,
                };

                editorPane.Closed += CurveEditorClosed;

                //editorPane.Closed += (s, e) =>
                //{
                //    if (((LayoutAnchorable)s).IsHidden)
                //    {
                //        RemoveCurveEditor(true);
                //    }
                //};

                AvalonDockHelper.GetDocumentPane(dockingLayoutManager.DockingManager).Children.Add(editorPane);
            }

            curveEditor = Tuple.Create(editorViewModel, editorPane);

            MakeActiveVisible(editorPane);
        }
 public HorizontalAndVerticalAxisRenderer(CurveEditorViewModel editor, IDrawingContext drawingContext)
 {
     Editor         = editor;
     DrawingContext = drawingContext;
 }