Exemple #1
0
        /// <summary>
        /// Runs the edit on given view, in context of corresponding type definition.
        /// </summary>
        /// <param name="edit">The edit that will be processed in the given view.</param>
        /// <param name="view">The view where edit will be processed.</param>
        /// <returns>View representation compatible with <see cref="MEFEditor.Drawing"/> library.</returns>
        public EditViewBase RunEdit(Edit edit, EditView view)
        {
            var creatorDefinition = GetTypeDefinition(edit.Creator);

            EditViewBase result  = null;
            Action       editRun = () =>
            {
                result = view.Apply(edit.Transformation);
            };

            if (creatorDefinition == null)
            {
                //there is no available definition
                editRun();
            }
            else
            {
                creatorDefinition.RunInContextOf(edit.Creator, editRun, edit.Context);
            }

            return(result);
        }
        private void onDrop(DiagramCanvasBase dropTarget, DragEventArgs e)
        {
            DragAdorner = e.Data.GetData("DragAdorner") as DragAdorner;
            if (DragAdorner == null)
            {
                return;
            }
            E          = e;
            DropTarget = dropTarget;

            E.Handled = true;

            CurrentView = Diagram.InitialView;
            onDrop();

            if (DropTarget.OwnerItem == DragItem)
            {
                //cant drop self to sub slot
                move();
                onDropEnd();
                return;
            }

            if (DragItem.ContainingDiagramCanvas == DropTarget)
            {
                //move within dropTarget canvas
                move();
                onDropEnd();
                return;
            }

            if (excludeFromParent())
            {
                acceptItem();
            }

            onDropEnd();
        }