public virtual bool CanInsertTo(IProjectItem projectItem, IView view, ISceneInsertionPoint insertionPoint) { if (projectItem.Project == null) { return(false); } SceneView sceneView = view as SceneView; if (sceneView == null || !sceneView.IsDesignSurfaceEnabled || insertionPoint == null) { return(false); } ViewState viewState = ViewState.ElementValid | ViewState.AncestorValid; if ((sceneView.GetViewState(insertionPoint.SceneNode) & viewState) != viewState) { return(false); } ProjectContext projectContext = (ProjectContext)ProjectXamlContext.GetProjectContext(projectItem.Project); if (projectContext == null) { return(false); } IProject project = ProjectHelper.GetProject(this.designerContext.ProjectManager, sceneView.Document.DocumentContext); return(project != null && (projectContext == sceneView.Document.ProjectContext || ProjectHelper.DoesProjectReferencesContainTarget(project, (IProjectContext)projectContext)) && ((!this.IsContentOrNoneBuildItem(projectItem) || projectItem.Project == project) && this.CanAddToProject(project))); }
internal SceneNode CreateInstance(ILicenseFileManager licenseManager, ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action) { if (LicenseManager.CurrentContext == null || !typeof(DesigntimeLicenseContext).IsAssignableFrom(LicenseManager.CurrentContext.GetType())) { LicenseManager.CurrentContext = (LicenseContext) new DesigntimeLicenseContext(); } LicenseManager.LockContext(Asset.licenseManagerLock); try { SceneNode instance = this.InternalCreateInstance(insertionPoint, rect, action); if (instance != null && instance.IsViewObjectValid) { TypeAsset typeAsset = this as TypeAsset; if (typeAsset != null && typeAsset.IsLicensed && licenseManager != null) { string projectPath = instance.ProjectContext.ProjectPath; licenseManager.AddLicensedItem(projectPath, typeAsset.Type.FullName, typeAsset.Type.RuntimeAssembly.FullName); } } return(instance); } finally { LicenseManager.UnlockContext(Asset.licenseManagerLock); } }
protected DropAction(TSourceData sourceData, ISceneInsertionPoint insertionPoint) { this.CheckNullArgument((object)sourceData, "sourceData"); this.CheckNullArgument((object)insertionPoint, "insertionPoint"); this.SourceData = sourceData; this.InsertionPoint = insertionPoint; }
protected override void OnDetach() { this.PreviewInsertionPoint = (ISceneInsertionPoint)null; this.ActiveView.NoInvisiblePanelStrokeHitTesting = this.cachedNoInvisiblePanelStrokeHitTesting; this.ActiveView.InvisiblePanelContainerOfSelectionDisable = this.cacheInvisiblePanelContainerOfSelectionDisable; base.OnDetach(); }
public override IDropAction CreateInstance(DragDropContext context) { this.CheckNullArgument((object)context, "context"); TypeAsset result1 = (TypeAsset)null; if (DragSourceHelper.FirstDataOfType <TypeAsset>(context.Data, ref result1) && PlatformTypes.IsEffectType((ITypeId)result1.Type)) { ISceneInsertionPoint insertionPoint = this.GetInsertionPoint((object)result1, context); if (insertionPoint != null) { return((IDropAction) new DropEffectAssetAction(result1, insertionPoint)); } } DocumentNodeMarkerSortedList result2 = (DocumentNodeMarkerSortedList)null; if (DragSourceHelper.FirstDataOfType <DocumentNodeMarkerSortedList>(context.Data, ref result2) && result2.Count == 1) { DocumentNodeMarker marker = result2.MarkerAt(0); if (marker != null && marker.Node != null && PlatformTypes.IsEffectType((ITypeId)marker.Node.Type)) { SceneViewModel viewModel = context.Target.TimelineItemManager.ViewModel; SceneNode sceneNode = SceneNode.FromMarker <SceneNode>(marker, viewModel); if (sceneNode != null) { ISceneInsertionPoint insertionPoint = this.GetInsertionPoint((object)sceneNode, context); if (insertionPoint != null) { return((IDropAction) new DropEffectSceneNodeAction(sceneNode, insertionPoint)); } } } } return((IDropAction)null); }
public override void Execute() { using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.UndoString)) { ItemsControlElement itemsControlElement = this.TargetElement as ItemsControlElement; if (itemsControlElement != null) { ITypeId itemType = this.ItemType; StyleAsset asset = this.Asset; IProperty targetProperty = this.SceneViewModel.ProjectContext.ResolveProperty(ItemsControlElement.ItemsProperty); ISceneInsertionPoint insertionPoint = (ISceneInsertionPoint) new PropertySceneInsertionPoint((SceneElement)itemsControlElement, targetProperty); if (asset != null && asset.CanCreateInstance(insertionPoint)) { IExpandable expandable = this.TargetElement as IExpandable; if (expandable != null) { using (this.SceneViewModel.ForceBaseValue()) this.TargetElement.SetValue(expandable.ExpansionProperty, (object)true); } asset.CreateInstance(this.DesignerContext.LicenseManager, insertionPoint, Rect.Empty, (OnCreateInstanceAction)null); } else { this.TypeInstantiator.CreateInstance(itemType, insertionPoint, Rect.Empty, (OnCreateInstanceAction)null); } } editTransaction.Commit(); } }
protected override bool InternalCanCreateInstance(ISceneInsertionPoint insertionPoint) { if (insertionPoint.Property == null || !insertionPoint.Property.Equals((object)BehaviorHelper.BehaviorsProperty)) { return(false); } return(insertionPoint.CanInsert((ITypeId)this.Type)); }
public bool CanCreateInstance(ISceneInsertionPoint insertionPoint) { if (insertionPoint != null && insertionPoint.SceneElement != null && (!insertionPoint.SceneElement.IsLocked && this.IsValid)) { return(this.InternalCanCreateInstance(insertionPoint)); } return(false); }
protected override bool InternalCanCreateInstance(ISceneInsertionPoint insertionPoint) { if (!this.provider.IsLocal && !this.provider.CanCopyLocal) { return(false); } return(base.InternalCanCreateInstance(insertionPoint)); }
protected override SceneNode InternalCreateInstance(ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action) { if (!this.EnsureTypeReferenced(ProjectContext.GetProjectContext(insertionPoint.SceneNode.ProjectContext))) { return((SceneNode)null); } return(TriggerActionAsset.CreateTrigger(insertionPoint.SceneNode, this.Type)); }
public static bool IsDefaultContentProperty(ISceneInsertionPoint insertionPoint) { if (insertionPoint.Property == null) { return(false); } return(insertionPoint.Property.Equals((object)insertionPoint.SceneElement.DefaultContentProperty)); }
private SmartInsertionPoint(int index, ISceneInsertionPoint reference) { if (reference == null) { throw new ArgumentNullException("reference"); } this.reference = reference; this.index = index; }
private static void ReselectGridToRestoreAdorners(GridElement grid) { ISceneInsertionPoint sceneInsertionPoint = grid.ViewModel.ActiveSceneInsertionPoint; if (sceneInsertionPoint == null || grid == sceneInsertionPoint.SceneElement) { return; } grid.ViewModel.ElementSelectionSet.SetSelection((SceneElement)grid); }
internal static bool CanInsertTo(SceneView view, IProjectItem projectItem, ISceneInsertionPoint insertionPoint) { AssetDocumentType assetDocumentType = projectItem.DocumentType as AssetDocumentType; if (assetDocumentType != null) { return(assetDocumentType.CanInsertTo(projectItem, (IView)view, insertionPoint)); } return(projectItem.DocumentType.CanInsertTo(projectItem, (IView)view)); }
protected void UpdatePreviewElement(Point pointerPosition) { if (this.ShowPreviewHighlightOnHover) { this.PreviewInsertionPoint = ElementCreateBehavior.GetInsertionPointToPreview(this.ActiveSceneViewModel, new InsertionPointContext(pointerPosition, this.InstanceType)); } else { this.PreviewInsertionPoint = (ISceneInsertionPoint)null; } }
protected override bool InternalCanCreateInstance(ISceneInsertionPoint insertionPoint) { AssetDocumentType assetDocumentType = this.projectItem.DocumentType as AssetDocumentType; IView view = (IView)insertionPoint.SceneNode.ViewModel.DefaultView; if (assetDocumentType != null) { return(assetDocumentType.CanInsertTo(this.projectItem, view, insertionPoint)); } return(this.projectItem.DocumentType.CanInsertTo(this.projectItem, view)); }
public void Update(AdornerElementSet adornerElementSet, AdornerLayer adornerLayer, AdornerLayer.ElementInfoUpdateSource source) { SceneElement primaryElement = adornerElementSet.PrimaryElement; bool flag = false; if (!adornerLayer.SceneView.IsInArtboard(primaryElement)) { return; } Size size2 = primaryElement.Visual != null?adornerLayer.SceneView.GetRenderSize(primaryElement.Visual) : Size.Empty; Transform transform = (Transform) new MatrixTransform(adornerElementSet.CalculatePrimaryElementTransformMatrixToAdornerLayer()); Matrix matrix = transform == null ? Matrix.Identity : transform.Value; Point renderTransformOrigin = adornerElementSet.RenderTransformOrigin; if (!AdornerLayer.ElementInfo.AreClose(renderTransformOrigin, this.sharedCenter) || !AdornerLayer.ElementInfo.AreClose(this.lastRenderSize, size2) || (this.primaryElementMatrix != matrix || adornerElementSet.IsPrimaryTransformNonAffine)) { flag = true; this.sharedCenter = renderTransformOrigin; this.lastRenderSize = size2; this.primaryElementMatrix = matrix; } ISceneInsertionPoint sceneInsertionPoint = adornerElementSet.PrimaryElement.ViewModel.ActiveSceneInsertionPoint; if (flag || source == AdornerLayer.ElementInfoUpdateSource.LayoutUpdated && adornerElementSet.NeedsUpdate) { adornerElementSet.Update(); this.matrix = adornerElementSet.GetTransformMatrixToAdornerLayer(); foreach (AdornerSet adornerSet in this.adornerSets) { this.UpdateMatrix(adornerSet, adornerLayer); } if (this.adornerSet3DContainer != null) { this.adornerSet3DContainer.SetMatrix(this.matrix); } if (sceneInsertionPoint != null && primaryElement.ParentElement is GridElement && (primaryElement.ParentElement == sceneInsertionPoint.SceneElement && primaryElement.ViewModel.IsInGridDesignMode)) { adornerLayer.InvalidateAdornerVisuals(primaryElement.ParentElement); } } if (!(primaryElement is Base3DElement) || sceneInsertionPoint == null) { return; } Base3DElement base3Delement = sceneInsertionPoint.SceneElement as Base3DElement; if (base3Delement == null) { return; } adornerLayer.InvalidateAdornerVisuals((SceneElement)base3Delement); }
public ModelItem GetRootForPrototypingScreen(string name) { if (this.prototypingService != null) { ISceneInsertionPoint importInsertionPoint = ImportManager.GetImportInsertionPoint(this.prototypingService.GetSceneViewModelForScreen(name)); if (importInsertionPoint != null) { return((ModelItem)importInsertionPoint.SceneElement.ModelItem); } } return((ModelItem)null); }
protected override bool InternalCanCreateInstance(ISceneInsertionPoint insertionPoint) { if (!this.IsInsertionPointValid(insertionPoint)) { return(false); } SceneNode sceneNode = insertionPoint.SceneNode; DocumentNodePath documentNodePath = sceneNode.DocumentNodePath; DocumentNode nodeBeingLookedFor = new ExpressionEvaluator(sceneNode.ViewModel.DocumentRootResolver).EvaluateResource(documentNodePath, this.ResourceModel.KeyNode); return(!documentNodePath.Contains(nodeBeingLookedFor)); }
public override SceneNode CreatePrototypeInstance(ISceneInsertionPoint insertionPoint) { IProjectContext projectContext = insertionPoint.SceneNode.ProjectContext; IType type1 = projectContext.ResolveType((ITypeId)this.Type); IType type2 = projectContext.GetType(type1.RuntimeAssembly.Name, type1.FullName) ?? projectContext.Platform.Metadata.GetType(type1.RuntimeType); if (type2 != null) { return(new DefaultTypeInstantiator(insertionPoint.SceneNode.ViewModel.DefaultView).CreatePrototypeInstance((ITypeId)type2)); } return((SceneNode)null); }
public ISceneInsertionPoint Create(object data) { foreach (IInsertionPointCreator insertionPointCreator in (List <IInsertionPointCreator>) this) { ISceneInsertionPoint sceneInsertionPoint = insertionPointCreator.Create(data); if (sceneInsertionPoint != null) { return(sceneInsertionPoint); } } return((ISceneInsertionPoint)null); }
private void CreateInstance(Point dropPoint, ResourceEntryItem resource, IType type) { ISceneInsertionPoint pointFromPosition = this.ActiveSceneViewModel.GetActiveSceneInsertionPointFromPosition(new InsertionPointContext(dropPoint)); TypeAsset typeAsset = new TypeAsset(type); if (!typeAsset.CanCreateInstance(pointFromPosition)) { return; } this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null); dropPoint = this.ToolBehaviorContext.SnappingEngine.SnapPoint(dropPoint, EdgeFlags.All); this.ToolBehaviorContext.SnappingEngine.Stop(); Matrix inverseMatrix = ElementUtilities.GetInverseMatrix(this.ActiveView.GetComputedTransformToRoot(pointFromPosition.SceneElement)); dropPoint *= inverseMatrix; using (SceneEditTransaction editTransaction = this.ActiveDocument.CreateEditTransaction(StringTable.CreateResourceViaToolUndoUnit)) { using (this.ActiveSceneViewModel.DesignerContext.AmbientPropertyManager.SuppressApplyAmbientProperties()) { typeAsset.CreateInstance(this.ActiveSceneViewModel.DesignerContext.LicenseManager, pointFromPosition, new Rect(dropPoint, new Size(double.PositiveInfinity, double.PositiveInfinity)), (OnCreateInstanceAction)(sceneNode => { SceneElement targetElement = sceneNode as SceneElement; if (targetElement == null) { return; } if (resource is StyleResourceItem) { this.ApplyResourceOnExistingElement(targetElement, BaseFrameworkElement.StyleProperty, resource); } else if (resource is ControlTemplateResourceItem) { this.ApplyResourceOnExistingElement(targetElement, ControlElement.TemplateProperty, resource); } else if (resource is DrawingImageResourceItem) { this.ApplyResourceOnExistingElement(targetElement, ImageElement.SourceProperty, resource); } else { if (!(resource is BrushResourceItem)) { return; } this.ApplyResourceOnExistingElement(targetElement, ShapeElement.FillProperty, resource); targetElement.SetValue(ShapeElement.StrokeProperty, (object)null); } })); editTransaction.Commit(); } } }
protected ISceneInsertionPoint GetInsertionPoint(object data, DragDropContext context) { this.CheckNullArgument(data, "data"); if (context.Target != null) { ISceneInsertionPoint insertionPoint = context.Target.GetInsertionPoint(data, context); if (insertionPoint != null) { return((ISceneInsertionPoint)SmartInsertionPoint.From(insertionPoint, context.Descriptor.DropIndex)); } } return((ISceneInsertionPoint)null); }
protected override void OnDoubleClick() { ISceneInsertionPoint sceneInsertionPoint = this.ActiveSceneViewModel.ActiveSceneInsertionPoint; if (this.asset != null && this.asset.IsValid && this.asset.CanCreateInstance(sceneInsertionPoint)) { this.asset.CreateInstance(this.ActiveSceneViewModel.DesignerContext.LicenseManager, sceneInsertionPoint, Rect.Empty, (OnCreateInstanceAction)null); } if (!this.asset.SupportsTextEditing(this.ActiveSceneViewModel.ProjectContext)) { return; } this.ActiveView.TryEnterTextEditMode(true); }
protected override SceneNode InternalCreateInstance(ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action) { SceneViewModel viewModel = insertionPoint.SceneNode.ViewModel; using (viewModel.DesignerContext.AmbientPropertyManager.SuppressApplyAmbientProperties()) { ITypeId instanceType = (ITypeId)this.StyleType; if (instanceType != null) { return(this.GetInstantiator(viewModel.DefaultView).CreateInstance(instanceType, insertionPoint, rect, action)); } return((SceneNode)null); } }
public override SceneNode CreatePrototypeInstance(ISceneInsertionPoint insertionPoint) { SceneViewModel viewModel = insertionPoint.SceneNode.ViewModel; using (viewModel.DesignerContext.AmbientPropertyManager.SuppressApplyAmbientProperties()) { ITypeId instanceType = (ITypeId)this.StyleType; if (instanceType != null) { return(this.GetInstantiator(viewModel.DefaultView).CreatePrototypeInstance(instanceType)); } return((SceneNode)null); } }
protected override SceneNode InternalCreateInstance(ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action) { AssetDocumentType assetDocumentType = this.projectItem.DocumentType as AssetDocumentType; if (assetDocumentType != null) { assetDocumentType.AddToDocument(this.projectItem, (IView)insertionPoint.SceneNode.ViewModel.DefaultView, insertionPoint, rect); } else { this.projectItem.DocumentType.AddToDocument(this.projectItem, (IView)insertionPoint.SceneNode.ViewModel.DefaultView); } return((SceneNode)null); }
public override IDropAction CreateInstance(DragDropContext context) { this.CheckNullArgument((object)context, "context"); Asset result = (Asset)null; if (DragSourceHelper.FirstDataOfType <Asset>(context.Data, ref result)) { ISceneInsertionPoint insertionPoint = this.GetInsertionPoint((object)result, context); if (insertionPoint != null) { return((IDropAction) new DropAssetAction(result, insertionPoint)); } } return((IDropAction)null); }
protected virtual bool IsInsertionPointValid(ISceneInsertionPoint insertionPoint) { if (insertionPoint == null || insertionPoint.SceneElement == null) { return(false); } SceneView defaultView = insertionPoint.SceneNode.ViewModel.DefaultView; if (defaultView == null || !defaultView.IsEditable) { return(false); } ITypeId typeToInsert = (ITypeId)this.StyleType; return(insertionPoint.CanInsert(typeToInsert)); }
protected override SceneNode InternalCreateInstance(ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action) { if (!this.EnsureTypeReferenced(ProjectContext.GetProjectContext(insertionPoint.SceneNode.ProjectContext))) { return((SceneNode)null); } if (insertionPoint.SceneNode != null) { insertionPoint.SceneNode.DesignerContext.ViewUpdateManager.RebuildPostponedViews(); } SceneView defaultView = insertionPoint.SceneNode.ViewModel.DefaultView; DefaultTypeInstantiator typeInstantiator = this.exampleInfo == null ? new DefaultTypeInstantiator(defaultView) : (DefaultTypeInstantiator) new TypeAsset.ExampleTypeInstantiator(defaultView, this.exampleInfo); using (this.IsSketchShapeType ? defaultView.DesignerContext.AmbientPropertyManager.SuppressApplyAmbientProperties() : (IDisposable)null) return(typeInstantiator.CreateInstance((ITypeId)this.type, insertionPoint, rect, action)); }