Ejemplo n.º 1
0
        public void CreateImageBrushResource(ResourceContainer container, IProjectItem item)
        {
            SceneViewModel viewModel         = container.ViewModel;
            string         resourceReference = item.GetResourceReference(viewModel.Document.DocumentReference);
            ImageBrushNode imageBrushNode    = (ImageBrushNode)viewModel.CreateSceneNode(PlatformTypes.ImageBrush);

            imageBrushNode.Source = resourceReference;
            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UndoUnitPaste, false))
            {
                IType type = viewModel.ProjectContext.ResolveType(PlatformTypes.ImageBrush);
                new CreateResourceModel(viewModel, viewModel.DesignerContext.ResourceManager, type.RuntimeType, (Type)null, (string)null, container.Node as SceneElement, (SceneNode)null, CreateResourceModel.ContextFlags.None)
                {
                    KeyString = Path.GetFileNameWithoutExtension(resourceReference)
                }.CreateResource(imageBrushNode.DocumentNode, (IPropertyId)null, -1);
                editTransaction.Commit();
            }
        }
Ejemplo n.º 2
0
        private void UpdateStartupUri(IProjectItem startupProjectItem)
        {
            IProjectItem applicationDefinitionItem = this.ApplicationDefinitionItem;

            if (applicationDefinitionItem == null)
            {
                return;
            }
            string startupUri = this.GetStartupUri(applicationDefinitionItem);

            if ((startupProjectItem != null || startupUri == null) && this.FindItemRelative(startupUri) == startupProjectItem)
            {
                return;
            }
            SceneDocument sceneDocument = applicationDefinitionItem.Document as SceneDocument;

            if (sceneDocument == null)
            {
                return;
            }
            Uri uri = (Uri)null;

            if (startupProjectItem != null)
            {
                string resourceReference = startupProjectItem.GetResourceReference(applicationDefinitionItem.DocumentReference);
                if (!string.IsNullOrEmpty(resourceReference))
                {
                    uri = new Uri(resourceReference, UriKind.Relative);
                }
            }
            using (SceneEditTransaction editTransaction = sceneDocument.CreateEditTransaction("Set StartupUri", true))
            {
                sceneDocument.StartupUri = uri;
                editTransaction.Commit();
            }
            sceneDocument.SourceChanged();
        }