Пример #1
0
        private ITypeId ComputeInstanceType(IDataObject dataObject)
        {
            TypeAsset typeAsset = AssetDropToolBehavior.GetAssetFromDropData(dataObject) as TypeAsset;

            if (typeAsset != null)
            {
                return((ITypeId)typeAsset.Type);
            }
            return((ITypeId)null);
        }
Пример #2
0
        protected override bool OnDragOver(DragEventArgs args)
        {
            bool  flag     = false;
            Point position = args.GetPosition((IInputElement)this.ActiveView.ViewRootContainer);

            this.UpdatePreviewElement(position);
            Asset assetFromDropData = AssetDropToolBehavior.GetAssetFromDropData(args.Data);

            if (assetFromDropData != null)
            {
                this.instanceType = this.ComputeInstanceType(args.Data);
                ISceneInsertionPoint insertionPoint = this.GetInsertionPoint(position);
                flag = assetFromDropData.CanCreateInstance(insertionPoint);
            }
            args.Effects = flag ? DragDropEffects.Copy : DragDropEffects.None;
            args.Handled = true;
            return(true);
        }
Пример #3
0
        protected override bool OnDrop(DragEventArgs args)
        {
            Asset assetFromDropData = AssetDropToolBehavior.GetAssetFromDropData(args.Data);

            if (assetFromDropData != null)
            {
                Point position = args.GetPosition((IInputElement)this.ActiveView.ViewRootContainer);
                ISceneInsertionPoint insertionPoint = this.GetInsertionPoint(position);
                this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null);
                Point point = this.ToolBehaviorContext.SnappingEngine.SnapPoint(position, EdgeFlags.All);
                this.ToolBehaviorContext.SnappingEngine.Stop();
                if (assetFromDropData != null && assetFromDropData.CanCreateInstance(insertionPoint))
                {
                    SceneView activeView = this.ActiveView;
                    Rect      rect       = new Rect(activeView.TransformPoint((IViewObject)activeView.HitTestRoot, insertionPoint.SceneElement.Visual, point), new Size(double.PositiveInfinity, double.PositiveInfinity));
                    assetFromDropData.CreateInstance(this.ActiveView.DesignerContext.LicenseManager, insertionPoint, rect, (OnCreateInstanceAction)null);
                    activeView.TryEnterTextEditMode(true);
                }
            }
            this.OnDragDropFinished();
            return(true);
        }
Пример #4
0
 internal static bool CanHandleDropData(IDataObject dataObj)
 {
     return(AssetDropToolBehavior.GetAssetFromDropData(dataObj) != null);
 }