Exemple #1
0
 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);
     }
 }
Exemple #2
0
 protected abstract SceneNode InternalCreateInstance(ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action);
Exemple #3
0
        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);
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        protected override SceneNode InternalCreateInstance(ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action)
        {
            ProjectContext projectContext = ProjectContext.GetProjectContext(insertionPoint.SceneNode.ProjectContext);

            if (!this.EnsureTypeReferenced(projectContext))
            {
                return((SceneNode)null);
            }
            BehaviorHelper.EnsureSystemWindowsInteractivityReferenced((ITypeResolver)projectContext);
            insertionPoint.SceneNode.DesignerContext.ViewUpdateManager.RebuildPostponedViews();
            SceneViewModel viewModel = insertionPoint.SceneNode.ViewModel;

            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitCreateControlFormat, new object[1]
            {
                (object)this.Name
            })))
            {
                viewModel.BehaviorSelectionSet.Clear();
                BehaviorBaseNode selectionToSet = (BehaviorBaseNode)base.InternalCreateInstance(insertionPoint, rect, action);
                ISceneNodeCollection <SceneNode> collectionForProperty = selectionToSet.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty);
                foreach (IProperty property in selectionToSet.GetProperties())
                {
                    if (PlatformTypes.ICommand.IsAssignableFrom((ITypeId)property.PropertyType))
                    {
                        object triggerAttribute = BehaviorHelper.CreateTriggerFromDefaultTriggerAttribute((IEnumerable)property.Attributes, insertionPoint.SceneNode.TargetType);
                        if (triggerAttribute != null)
                        {
                            BehaviorTriggerBaseNode behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)viewModel.CreateSceneNode(triggerAttribute);
                            InvokeCommandActionNode commandActionNode       = (InvokeCommandActionNode)viewModel.CreateSceneNode(ProjectNeutralTypes.InvokeCommandAction);
                            commandActionNode.CommandName = property.Name;
                            behaviorTriggerBaseNode.Actions.Add((SceneNode)commandActionNode);
                            if (ProjectNeutralTypes.BehaviorEventTriggerBase.IsAssignableFrom((ITypeId)behaviorTriggerBaseNode.Type))
                            {
                                BehaviorHelper.CreateAndSetElementNameBinding(BehaviorEventTriggerBaseNode.BehaviorSourceObjectProperty, (SceneNode)behaviorTriggerBaseNode, insertionPoint.SceneNode);
                            }
                            collectionForProperty.Add((SceneNode)behaviorTriggerBaseNode);
                        }
                    }
                }
                viewModel.BehaviorSelectionSet.SetSelection(selectionToSet);
                editTransaction.Commit();
                return((SceneNode)selectionToSet);
            }
        }
Exemple #6
0
        public virtual SceneNode CreateInstance(ITypeId instanceType, ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action)
        {
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.PropertyInspectorFromCreate);
            PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.CreateElement);
            SceneView sceneView = this.sceneView;

            if (sceneView == null || !sceneView.IsEditable || insertionPoint == null)
            {
                return((SceneNode)null);
            }
            SceneNode rawInstance = this.CreateRawInstance(instanceType);

            if (rawInstance == null || !insertionPoint.CanInsert((ITypeId)rawInstance.Type))
            {
                return((SceneNode)null);
            }
            if (rect.IsEmpty)
            {
                rect = new Rect(0.0, 0.0, double.NaN, double.NaN);
            }
            if (double.IsInfinity(rect.Width))
            {
                rect.Width = double.NaN;
            }
            if (double.IsInfinity(rect.Height))
            {
                rect.Height = double.NaN;
            }
            using (this.ViewModel.ForceBaseValue())
            {
                using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitCreateControlFormat, new object[1]
                {
                    (object)instanceType.Name
                })))
                {
                    IExpandable expandable = insertionPoint.SceneElement as IExpandable;
                    if (expandable != null)
                    {
                        insertionPoint.SceneNode.SetValue(expandable.ExpansionProperty, (object)true);
                    }
                    bool flag = this.ShouldUseDefaultInitializer && Enumerable.Any <FeatureProvider>(DefaultTypeInstantiator.GetDefaultInitializers(rawInstance));
                    IList <SceneNode> nodes = (IList <SceneNode>)null;
                    if (!flag)
                    {
                        nodes = this.CreateNodeTreeOnInsertion(rawInstance);
                        this.ApplyBeforeInsertionDefaultsToElements(nodes, rawInstance, new DefaultTypeInstantiator.SceneElementNamingCallback(DefaultTypeInstantiator.TypeNameCallback));
                    }
                    SceneNode    layoutTarget    = DefaultTypeInstantiator.GetLayoutTarget(rawInstance);
                    SceneElement selectionTarget = DefaultTypeInstantiator.GetSelectionTarget(rawInstance);
                    this.ViewModel.ElementSelectionSet.Clear();
                    insertionPoint.Insert(rawInstance);
                    editTransaction.Update();
                    this.ApplyDefaultInitializers(rawInstance);
                    if (action != null)
                    {
                        action(rawInstance);
                        editTransaction.Update();
                    }
                    if (!flag)
                    {
                        this.ApplyAfterInsertionDefaultsToElements(nodes, rawInstance);
                    }
                    SceneElement sceneElement1 = layoutTarget as SceneElement;
                    EffectNode   effectNode    = layoutTarget as EffectNode;
                    if (sceneElement1 != null && sceneElement1.IsViewObjectValid)
                    {
                        if (selectionTarget != null)
                        {
                            this.ViewModel.ElementSelectionSet.SetSelection(selectionTarget);
                        }
                        this.SetLayout(insertionPoint, rect, rawInstance, layoutTarget, editTransaction);
                    }
                    else if (effectNode != null)
                    {
                        this.ViewModel.ChildPropertySelectionSet.SetSelection((SceneNode)effectNode);
                    }
                    else
                    {
                        for (SceneNode sceneNode = layoutTarget; sceneNode != null; sceneNode = sceneNode.Parent)
                        {
                            SceneElement sceneElement2 = sceneNode as SceneElement;
                            if (sceneElement2 != null && sceneElement2.Visual != null && sceneElement2.Visual is IViewVisual)
                            {
                                this.sceneView.EnsureVisible(sceneElement2.Visual);
                                break;
                            }
                        }
                    }
                    if (this.ViewModel.DesignerContext.AmbientPropertyManager != null)
                    {
                        this.ViewModel.DesignerContext.AmbientPropertyManager.ApplyAmbientProperties(rawInstance);
                    }
                    editTransaction.Commit();
                }
            }
            return(rawInstance);
        }
Exemple #7
0
        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 CreateInstance(ITypeId instanceType, ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action)
 {
     using (!this.provider.IsLocal ? TemporaryCursor.SetWaitCursor() : (IDisposable)null)
         return(base.CreateInstance(instanceType, insertionPoint, rect, action));
 }
Exemple #9
0
 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));
 }