예제 #1
0
 public DocumentNode GetThemeResourceFromAssembly(IProjectContext projectContext, IAssembly themeRuntimeAssembly, IAssembly themeTargetAssembly, object resourceKey, out IList <DocumentCompositeNode> auxillaryResources)
 {
     using (TemporaryCursor.SetWaitCursor())
     {
         foreach (string str1 in ThemeContentProvider.GetThemeNames(projectContext))
         {
             string str2 = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "themes/{0}.xaml", new object[1]
             {
                 (object)str1.ToLowerInvariant()
             });
             IProjectContext   projectContext1  = (IProjectContext) new ThemeContentProvider.TargetThemeAssemblyProjectContext(projectContext, themeRuntimeAssembly, this.designerContext.AssemblyService);
             DocumentReference theme            = DocumentReference.Create(Path.Combine(themeTargetAssembly.Name, str2));
             DocumentNode      resourceInternal = this.GetResourceInternal(this.projectThemeCache, projectContext.Platform.ThemeManager, projectContext1, theme, themeTargetAssembly, str2, resourceKey, out auxillaryResources);
             if (resourceInternal != null)
             {
                 return(resourceInternal);
             }
         }
         if (projectContext.Platform.ThemeManager.AllowFallbackToPlatform)
         {
             return(this.GetThemeResourceFromPlatform(projectContext.Platform, resourceKey, out auxillaryResources));
         }
         auxillaryResources = (IList <DocumentCompositeNode>)null;
         return((DocumentNode)null);
     }
 }
예제 #2
0
        private void Cleanup(bool cleanSupportingFolderIfNotInProject)
        {
            if (this.temporaryFolderPlaceholder != null)
            {
                this.temporaryFolderPlaceholder.Dispose();
                this.temporaryFolderPlaceholder = (ProjectPathHelper.TemporaryDirectory)null;
            }
            if (this.supportingDirectoryPath != null && cleanSupportingFolderIfNotInProject)
            {
                if (this.ImportContext.ActiveProject.FindItem(DocumentReference.Create(this.supportingDirectoryPath)) == null)
                {
                    try
                    {
                        Directory.Delete(this.supportingDirectoryPath);
                    }
                    catch (IOException ex)
                    {
                    }
                }
            }
            IDisposable disposable = this.asyncHandlerArgument as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
            }
            this.asyncHandlerArgument = (object)null;
        }
예제 #3
0
        private void PerformPartialCompile(IProjectItem xamlProjectItem)
        {
            if (this.lastDirtyStateBeforePartialCompileIndex.ContainsKey(xamlProjectItem.DocumentReference) && xamlProjectItem.Document != null)
            {
                CodeProject.PartialCompileDirtyState compileDirtyState = new CodeProject.PartialCompileDirtyState()
                {
                    DirtyState         = xamlProjectItem.Document.IsDirty,
                    PartialCompileTime = DateTime.UtcNow
                };
                this.lastDirtyStateBeforePartialCompileIndex[xamlProjectItem.DocumentReference] = new CodeProject.PartialCompileDirtyState?(compileDirtyState);
            }
            string fileName = DocumentReference.Create(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectoryNameOrRoot(this.project.DocumentReference.Path)).GetRelativePath(xamlProjectItem.DocumentReference);

            foreach (char oldChar in Microsoft.Expression.Framework.Documents.PathHelper.GetDirectorySeparatorCharacters())
            {
                fileName = fileName.Replace(oldChar, '_');
            }
            string documentText = this.GetDocumentText(xamlProjectItem);

            if (documentText == null)
            {
                return;
            }
            PartialXamlBuilder partialXamlBuilder = new PartialXamlBuilder(this.project, xamlProjectItem, documentText, fileName, this.buildManager);

            partialXamlBuilder.BuildFinished += new EventHandler <PartialXamlBuildFinishedEventArgs>(this.XamlBuilder_BuildFinished);
            partialXamlBuilder.Build();
        }
예제 #4
0
        private void SafelyRemoveSampleDataAndRootFolder(SampleDataSet dataSet, bool forceDeleteFiles)
        {
            dataSet.Close();
            if (forceDeleteFiles)
            {
                SampleDataCollection.DeleteFolder(dataSet.SampleDataFolder, false);
            }
            else
            {
                SampleDataCollection.DeleteFolder(dataSet.AssetFilesFolder, true);
                SampleDataCollection.DeleteFolder(dataSet.SampleDataFolder, true);
            }
            this.OnSampleDataRemoving(dataSet);
            this.dataSets.Remove(dataSet);
            if (Enumerable.FirstOrDefault <SampleDataSet>(Enumerable.Where <SampleDataSet>((IEnumerable <SampleDataSet>) this.dataSets, (Func <SampleDataSet, bool>)(item => item.Context == dataSet.Context))) != null)
            {
                return;
            }
            string       path        = Path.Combine(Path.GetDirectoryName(this.projectContext.ProjectPath), dataSet.Context.DataRootFolder);
            IProject     project     = (IProject)this.projectContext.GetService(typeof(IProject));
            IProjectItem projectItem = project.FindItem(DocumentReference.Create(path));

            if (projectItem == null || Enumerable.FirstOrDefault <IProjectItem>(projectItem.Children) != null)
            {
                return;
            }
            project.RemoveItems(0 != 0, projectItem);
            SampleDataCollection.DeleteFolder(dataSet.Context.DataRootFolder, true);
        }
예제 #5
0
        public string MakeSourceReference(string fullPath)
        {
            DocumentReference reference = DocumentReference.Create(fullPath);

            if (this.sceneViewModel != null)
            {
                string str = this.sceneViewModel.Document.DocumentReference.GetRelativePath(reference);
                if (str != null && this.sceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.ShouldSanitizeResourceReferences))
                {
                    str = str.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                }
                return(str);
            }
            string str1 = this.ActiveProject.DocumentReference.GetRelativePath(reference);

            if (str1 == null)
            {
                return((string)null);
            }
            IXamlProject xamlProject = this.ActiveProject as IXamlProject;

            if (xamlProject != null)
            {
                ITypeResolver typeResolver = (ITypeResolver)ProjectContext.GetProjectContext(xamlProject.ProjectContext);
                if (typeResolver != null && typeResolver.IsCapabilitySet(PlatformCapability.ShouldSanitizeResourceReferences))
                {
                    str1 = str1.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                }
            }
            return(str1);
        }
예제 #6
0
        public override void Execute()
        {
            string project = this.Project;

            if (!string.IsNullOrEmpty(project))
            {
                if (PathHelper.FileExists(project) || PathHelper.DirectoryExists(project))
                {
                    if (this.Solution() != null && this.Solution().DocumentReference.Path == project)
                    {
                        return;
                    }
                    if (this.ProjectManager().CloseSolution())
                    {
                        this.ProjectManager().OpenSolution(DocumentReference.Create(project), true, true);
                    }
                }
                else
                {
                    MessageBoxArgs messageBoxArg  = new MessageBoxArgs();
                    CultureInfo    currentCulture = CultureInfo.CurrentCulture;
                    string         openRecentProjectNotFoundDialogMessage = StringTable.OpenRecentProjectNotFoundDialogMessage;
                    object[]       objArray = new object[] { project };
                    messageBoxArg.Message = string.Format(currentCulture, openRecentProjectNotFoundDialogMessage, objArray);
                    messageBoxArg.Button  = MessageBoxButton.YesNo;
                    messageBoxArg.Image   = MessageBoxImage.Hand;
                    if (base.Services.MessageDisplayService().ShowMessage(messageBoxArg) == MessageBoxResult.Yes)
                    {
                        ((ProjectManager)this.ProjectManager()).RemoveRecentProject(project);
                        return;
                    }
                }
            }
        }
예제 #7
0
        private static string AdjustTargetFolder(string targetFolder, string rootSourcePath, string fullSourcePath)
        {
            string            directoryNameOrRoot = Microsoft.Expression.Framework.Documents.PathHelper.GetDirectoryNameOrRoot(fullSourcePath);
            DocumentReference documentReference   = DocumentReference.Create(rootSourcePath);
            DocumentReference documentReference1  = DocumentReference.Create(directoryNameOrRoot);

            return(Microsoft.Expression.Framework.Documents.PathHelper.ResolveCombinedPath(targetFolder, documentReference.GetRelativePath(documentReference1)));
        }
예제 #8
0
 public static DesignDataMode GetDesignDataMode(IProject project, string path)
 {
     if (project == null || string.IsNullOrEmpty(path))
     {
         return(DesignDataMode.None);
     }
     return(DocumentContextHelper.GetDesignDataMode(project.FindItem(DocumentReference.Create(path))));
 }
예제 #9
0
        private IProjectItem FindItemRelative(string projectRelativeItemName)
        {
            IProjectItem projectItem = (IProjectItem)null;

            if (projectRelativeItemName != null)
            {
                projectItem = this.FindItem(DocumentReference.Create(Path.Combine(this.ProjectRoot.Path, projectRelativeItemName)));
            }
            return(projectItem);
        }
예제 #10
0
        private string GetSupportingDirectory(string supportingFolderName, bool create)
        {
            string   importDirectoryPath = this.ImportDirectoryPath;
            string   path1         = Path.Combine(importDirectoryPath, supportingFolderName);
            IProject activeProject = this.importContext.ActiveProject;

            if (activeProject == null)
            {
                return((string)null);
            }
            if (this.supportingFolderName == null)
            {
                DocumentReference documentReference = DocumentReference.Create(path1);
                if (activeProject.FindItem(documentReference) != null)
                {
                    string str1 = ProjectPathHelper.GetAvailableFilePath(supportingFolderName, importDirectoryPath, activeProject, true).Substring(importDirectoryPath.Length).Trim(Path.DirectorySeparatorChar);
                    string str2 = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.ImportImageDirectoryOverwriteDialogMessage, new object[2]
                    {
                        (object)supportingFolderName,
                        (object)str1
                    });
                    Dictionary <MessageChoice, string> dictionary = new Dictionary <MessageChoice, string>();
                    dictionary[MessageChoice.Yes] = StringTable.ImportImageDirectoryOverwriteDialogMessageYesButtonCaption;
                    dictionary[MessageChoice.No]  = StringTable.ImportImageDirectoryOverwriteDialogMessageNoButtonCaption;
                    switch (this.messageDisplayService.ShowMessage(new MessageBoxArgs()
                    {
                        Message = str2,
                        Button = MessageBoxButton.YesNoCancel,
                        Image = MessageBoxImage.Exclamation,
                        TextOverrides = (IDictionary <MessageChoice, string>)dictionary
                    }))
                    {
                    case MessageBoxResult.Yes:
                        supportingFolderName = str1;
                        break;

                    case MessageBoxResult.No:
                        break;

                    default:
                        throw new OperationCanceledException();
                    }
                }
                this.supportingFolderName = supportingFolderName;
            }
            string path2 = Path.Combine(importDirectoryPath, this.supportingFolderName);

            if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(path2) && create)
            {
                Directory.CreateDirectory(path2);
            }
            this.supportingDirectoryPath = path2;
            return(this.supportingFolderName);
        }
예제 #11
0
        private string GetRelativePathForDocumentReference(DocumentReference referencingDocument)
        {
            string            str = this.resourceItem.ProjectRelativeDocumentReference.TrimStart(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectorySeparatorCharacters());
            DocumentReference documentReference = null;

            if (!Microsoft.Expression.Framework.Documents.PathHelper.IsValidPath(str))
            {
                return(null);
            }
            documentReference = DocumentReference.Create(Microsoft.Expression.Framework.Documents.PathHelper.ResolveCombinedPath(this.resourceItem.Project.ProjectRoot.Path, str));
            return(referencingDocument.GetRelativePath(documentReference));
        }
예제 #12
0
        public static TDocumentItem FindMatchByUrl <TDocumentItem>(this IEnumerable <TDocumentItem> source, string url)
            where TDocumentItem : class, IDocumentItem
        {
            DocumentReference documentReference            = DocumentReference.Create(url);
            IIndexedHashSet <TDocumentItem> tDocumentItems = source as IIndexedHashSet <TDocumentItem>;

            if (tDocumentItems != null)
            {
                return(tDocumentItems[documentReference.GetHashCode()]);
            }
            return(source.FirstOrDefault <TDocumentItem>((TDocumentItem d) => d.DocumentReference.GetHashCode() == documentReference.GetHashCode()));
        }
예제 #13
0
 public override void Execute()
 {
     this.HandleBasicExceptions(() => {
         string str = base.SelectProject(this.DisplayName);
         if (!string.IsNullOrEmpty(str))
         {
             IProjectStore projectStore = ProjectStoreHelper.CreateProjectStore(DocumentReference.Create(str), base.Services, ProjectStoreHelper.ResilientProjectCreationChain);
             if (projectStore == null)
             {
                 return;
             }
             UpgradeWizard upgradeWizard = new UpgradeWizard(this.Solution() as ISolutionManagement,
                                                             from project in this.Solution().Projects.OfType <ProjectBase>()
                                                             select project.ProjectStore, projectStore, null, base.Services);
             try
             {
                 if (!upgradeWizard.Upgrade())
                 {
                     return;
                 }
             }
             finally
             {
                 projectStore.Dispose();
                 projectStore = null;
             }
             projectStore = ProjectStoreHelper.CreateProjectStore(DocumentReference.Create(str), base.Services, ProjectStoreHelper.DefaultProjectCreationChain);
             if (projectStore == null)
             {
                 return;
             }
             INamedProject namedProject = null;
             try
             {
                 namedProject = this.ProjectManager().AddProject(projectStore);
                 if (namedProject != null)
                 {
                     base.UpdateSourceControl(EnumerableExtensions.AsEnumerable <INamedProject>(namedProject));
                     base.ActivateProjectPane();
                 }
             }
             finally
             {
                 if (namedProject == null && projectStore != null)
                 {
                     projectStore.Dispose();
                     projectStore = null;
                 }
             }
         }
     });
 }
예제 #14
0
        private static bool IsResourceInSameProject(SceneViewModel viewModel, DocumentReference localPath, Uri originalUri)
        {
            IProject project = ResourceHelper.ProjectFromViewModel(viewModel);
            Uri      uri     = ResourceHelper.DocumentContextFromViewModel(viewModel).MakeDesignTimeUri(originalUri);

            if (project.FindItem(localPath) != null)
            {
                return(true);
            }
            if (uri != (Uri)null)
            {
                return(project.FindItem(DocumentReference.Create(uri.OriginalString)) != null);
            }
            return(false);
        }
예제 #15
0
        protected override void InternalExectute()
        {
            Dictionary <string, string> strs;
            IDocumentItem documentItem = this.Selection().SingleOrNull <IDocumentItem>();

            if (documentItem != null)
            {
                if (!this.SaveSolution(true))
                {
                    return;
                }
                using (IDisposable disposable = this.SuspendWatchers())
                {
                    List <IDocumentItem> list  = base.GetFileItemAndDescendants(documentItem).Where <IDocumentItem>(new Func <IDocumentItem, bool>(this.FileHasPendingChange)).ToList <IDocumentItem>();
                    string[]             array = (
                        from item in list
                        select item.DocumentReference.Path).ToArray <string>();
                    base.SourceControlProvider.RevertChange(array, out strs);
                    foreach (string key in strs.Keys)
                    {
                        DocumentReference documentReference = DocumentReference.Create(key);
                        if (!documentReference.IsValidPathFormat)
                        {
                            continue;
                        }
                        string directoryNameOrRoot = Microsoft.Expression.Framework.Documents.PathHelper.GetDirectoryNameOrRoot(documentReference);
                        if (directoryNameOrRoot == null || !Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(directoryNameOrRoot))
                        {
                            continue;
                        }
                        try
                        {
                            if (!Directory.EnumerateFiles(directoryNameOrRoot, "*.*", SearchOption.AllDirectories).Any <string>())
                            {
                                Directory.Delete(directoryNameOrRoot);
                            }
                        }
                        catch (IOException oException)
                        {
                        }
                        catch (SecurityException securityException)
                        {
                        }
                    }
                }
                SourceControlStatusCache.UpdateStatus(this.Solution().Descendants.AppendItem <IDocumentItem>(this.Solution()), base.SourceControlProvider);
            }
        }
예제 #16
0
 public override void Execute()
 {
     this.HandleBasicExceptions(() => {
         string str = base.SelectProject(StringTable.OpenProjectDialogTitle);
         if (!string.IsNullOrEmpty(str))
         {
             PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.OpenProjectInner);
             ISolution solution = this.ProjectManager().OpenSolution(DocumentReference.Create(str), true, true);
             PerformanceUtility.MarkInterimStep(PerformanceEvent.OpenProjectInner, "Finished loading, now closing all projects.");
             if (solution != null)
             {
                 this.ProjectManager().DefaultOpenProjectPath = Path.GetDirectoryName(Path.GetDirectoryName(solution.DocumentReference.Path));
             }
         }
     });
 }
예제 #17
0
        private bool HandleCanProcessCommandLineArgs(string[] args)
        {
            string[] arguments = this.commandLineService.GetArguments(string.Empty, args);
            bool     flag      = false;

            if (arguments != null)
            {
                if (arguments.Length == 1)
                {
                    try
                    {
                        string fullPath = Path.GetFullPath(arguments[0]);
                        if (Microsoft.Expression.Framework.Documents.PathHelper.FileOrDirectoryExists(fullPath))
                        {
                            DocumentReference documentReference = DocumentReference.Create(fullPath);
                            if (this.projectManager.CurrentSolution == null || this.projectManager.CurrentSolution.DocumentReference.Path.Equals(fullPath, StringComparison.OrdinalIgnoreCase) || this.projectManager.CurrentSolution.FindProject(documentReference) != null)
                            {
                                flag = true;
                            }
                            else
                            {
                                foreach (IProject project in this.projectManager.CurrentSolution.Projects)
                                {
                                    if (project.FindItem(documentReference) != null)
                                    {
                                        flag = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (!ErrorHandling.ShouldHandleExceptions(ex))
                        {
                            throw;
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }
            return(flag);
        }
예제 #18
0
        public void AddLicensedItem(string projectPath, string typeName, string assemblyName)
        {
            IProject      matchByUrl = DocumentItemExtensions.FindMatchByUrl <IProject>(this.context.ProjectManager.CurrentSolution.Projects, projectPath);
            List <string> list       = new List <string>();
            string        path       = Path.Combine(matchByUrl.ProjectRoot.Path, "Properties\\Licenses.licx");

            if (matchByUrl.FindItem(DocumentReference.Create(path)) == null)
            {
                IDocumentType documentType = this.context.DocumentTypeManager.DocumentTypes[DocumentTypeNamesHelper.Licx];
                matchByUrl.AddItem(new DocumentCreationInfo()
                {
                    DocumentType = documentType,
                    TargetPath   = path
                });
            }
            else if (Microsoft.Expression.Framework.Documents.PathHelper.FileExists(path))
            {
                using (StreamReader streamReader = File.OpenText(path))
                {
                    while (!streamReader.EndOfStream)
                    {
                        list.Add(streamReader.ReadLine());
                    }
                }
            }
            string str1 = typeName + ", " + assemblyName;

            if (list.Contains(str1))
            {
                return;
            }
            list.Add(str1);
            string directoryName = Path.GetDirectoryName(path);

            if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(directoryName))
            {
                Directory.CreateDirectory(directoryName);
            }
            using (StreamWriter text = File.CreateText(path))
            {
                foreach (string str2 in list)
                {
                    text.WriteLine(str2);
                }
            }
        }
예제 #19
0
 private void OpenExistingSample(string path, IProjectTemplate sampleTemplate, IProjectManager projectManager)
 {
     try
     {
         this.dialogWindow.Opacity = 0.0;
         UIThreadDispatcher.Instance.DoEvents();
         if (!sampleTemplate.HasProjectFile)
         {
             if (projectManager.OpenSolution(DocumentReference.Create(path), false, true) == null)
             {
                 return;
             }
             this.dialogWindow.Close();
         }
         else
         {
             string projectFilename = sampleTemplate.ProjectFilename;
             string path1           = (string)null;
             if (!string.IsNullOrEmpty(projectFilename))
             {
                 string[] strArray = (string[])null;
                 try
                 {
                     strArray = Directory.GetFiles(path, projectFilename, SearchOption.AllDirectories);
                 }
                 catch (DirectoryNotFoundException ex)
                 {
                 }
                 if (strArray != null && strArray.Length != 0)
                 {
                     path1 = strArray[0];
                 }
             }
             if (string.IsNullOrEmpty(path1) || !Microsoft.Expression.Framework.Documents.PathHelper.FileExists(path1) || projectManager.OpenSolution(DocumentReference.Create(path1), false, true) == null)
             {
                 return;
             }
             this.dialogWindow.Close();
         }
     }
     finally
     {
         this.dialogWindow.Opacity = 1.0;
     }
 }
        private DocumentReference DetermineOutOfBrowserPrivateLocation(IProject sourceProject, Uri outOfBrowserQueryUri, out string applicationIdentifier)
        {
            DocumentReference documentReference = (DocumentReference)null;

            applicationIdentifier = (string)null;
            IXamlProject    xamlProject    = sourceProject as IXamlProject;
            IProjectContext projectContext = xamlProject != null ? xamlProject.ProjectContext : (IProjectContext)null;

            if (projectContext != null && projectContext.Platform != null)
            {
                string deploymentLocation;
                applicationIdentifier = projectContext.Platform.GetDeploymentInformation(outOfBrowserQueryUri, out deploymentLocation);
                if (deploymentLocation != null)
                {
                    documentReference = DocumentReference.Create(deploymentLocation);
                }
            }
            return(documentReference);
        }
예제 #21
0
        private DocumentNode FindProjectResource(IProject project, ResourceDictionaryContentProvider currentThemeProvider, string currentThemePath, object resourceKey, out IList <DocumentCompositeNode> auxillaryResources)
        {
            List <string> resolvedUris = new List <string>();

            return(ThemeContentProvider.FindResource(currentThemeProvider, currentThemePath, (Func <ResourceDictionaryContentProvider, Func <DocumentNode, object> >)(provider => (Func <DocumentNode, object>)(resourceKeyNode =>
            {
                DocumentNode rootNode = currentThemeProvider.Document.RootNode;
                using (StandaloneInstanceBuilderContext instanceBuilderContext = new StandaloneInstanceBuilderContext(rootNode.Context, this.designerContext))
                {
                    using (instanceBuilderContext.DisablePostponedResourceEvaluation())
                    {
                        instanceBuilderContext.ViewNodeManager.RootNodePath = new DocumentNodePath(rootNode, resourceKeyNode);
                        instanceBuilderContext.ViewNodeManager.Instantiate(instanceBuilderContext.ViewNodeManager.Root);
                        return instanceBuilderContext.ViewNodeManager.ValidRootInstance;
                    }
                }
            })), (Func <Uri, string, string>)((relativeUri, sourcePath) =>
            {
                Uri uri = project.MakeDesignTimeUri(relativeUri, sourcePath);
                if (!(uri != (Uri)null))
                {
                    return (string)null;
                }
                string originalString = uri.OriginalString;
                if (resolvedUris.Contains(originalString))
                {
                    return (string)null;
                }
                resolvedUris.Add(originalString);
                return originalString;
            }), (Func <string, ResourceDictionaryContentProvider>)(resolvedUri =>
            {
                if (!string.IsNullOrEmpty(resolvedUri))
                {
                    IProjectItem projectItem = project.FindItem(DocumentReference.Create(resolvedUri));
                    if (projectItem != null)
                    {
                        return this.designerContext.ResourceManager.GetContentProviderForResourceDictionary(projectItem);
                    }
                }
                return (ResourceDictionaryContentProvider)null;
            }), resourceKey, out auxillaryResources));
        }
예제 #22
0
        internal MakeUserControlDialog(DesignerContext designerContext, string dialogTitle, TemplateItemHelper templateItemHelper, string recommendedName)
        {
            this.InitializeComponent();
            this.userControlItem = templateItemHelper.FindTemplateItem("UserControl");
            this.designerContext = designerContext;
            this.Title           = dialogTitle;
            this.DataContext     = (object)this;
            string str1 = designerContext.ProjectManager.TargetFolderForProject(designerContext.ActiveProject);

            if (!string.IsNullOrEmpty(recommendedName))
            {
                string            str2 = recommendedName + ".xaml";
                DocumentReference documentReference = DocumentReference.Create(Path.Combine(str1, str2));
                this.name = designerContext.ActiveProject.FindItem(documentReference) == null ? recommendedName : Path.GetFileNameWithoutExtension(ProjectPathHelper.GetAvailableFilePath(str2, str1, designerContext.ActiveProject));
            }
            else if (this.userControlItem != null)
            {
                this.name = Path.GetFileNameWithoutExtension(ProjectPathHelper.GetAvailableFilePath(this.userControlItem.DefaultName, str1, designerContext.ActiveProject));
            }
            this.controlNameMessageBubble = new MessageBubbleHelper((UIElement)this.Control_Name, (IMessageBubbleValidator) new ProjectItemNameValidator(designerContext.ActiveProject));
        }
예제 #23
0
        private static bool HasContentAlreadyBeenMoved(IEnumerable <Microsoft.Expression.Project.MoveInfo> movedDirectories, string fileName)
        {
            bool flag;
            DocumentReference documentReference = DocumentReference.Create(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectoryNameOrRoot(fileName));

            using (IEnumerator <Microsoft.Expression.Project.MoveInfo> enumerator = movedDirectories.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Microsoft.Expression.Project.MoveInfo current = enumerator.Current;
                    DocumentReference documentReference1          = DocumentReference.Create(Microsoft.Expression.Framework.Documents.PathHelper.EnsurePathEndsInDirectorySeparator(current.Source));
                    if (!documentReference.Path.StartsWith(documentReference1.Path, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    flag = true;
                    return(flag);
                }
                return(false);
            }
            return(flag);
        }
예제 #24
0
        public static IProjectItem GetDesignDataFile(DocumentNode documentNode)
        {
            IProject project = (IProject)((IServiceProvider)documentNode.TypeResolver).GetService(typeof(IProject));
            string   path    = (string)null;

            if (documentNode.Type.RuntimeType == typeof(DesignDataExtension))
            {
                path = DesignDataInstanceBuilder.GetSourceFilePath((DocumentCompositeNode)documentNode);
            }
            else if (documentNode.Parent == null)
            {
                path = documentNode.Context.DocumentUrl;
            }
            if (!string.IsNullOrEmpty(path))
            {
                IProjectItem projectItem = project.FindItem(DocumentReference.Create(path));
                if (projectItem != null && DocumentContextHelper.GetDesignDataMode(projectItem) != DesignDataMode.None)
                {
                    return(projectItem);
                }
            }
            return((IProjectItem)null);
        }
        private IProject FindXapSourceProject(IProject targetProject, out DocumentReference xapDeploymentDirectory)
        {
            xapDeploymentDirectory = (DocumentReference)null;
            IProject project = (IProject)null;

            if (targetProject is SilverlightProject && targetProject.GetCapability <bool>("CanBeStartupProject"))
            {
                project = targetProject;
                if (project.FullTargetPath != null)
                {
                    xapDeploymentDirectory = DocumentReference.Create(PathHelper.GetDirectoryNameOrRoot(project.FullTargetPath));
                }
            }
            else
            {
                ISolution currentSolution = ServiceExtensions.ProjectManager(this.serviceProvider).CurrentSolution;
                IProjectOutputReferenceResolver referenceResolver = currentSolution as IProjectOutputReferenceResolver;
                if (currentSolution != null && referenceResolver != null)
                {
                    foreach (IProject sourceProject in currentSolution.Projects)
                    {
                        Uri deploymentResolvedRoot = referenceResolver.GetDeploymentResolvedRoot(sourceProject);
                        if (deploymentResolvedRoot != (Uri)null)
                        {
                            DocumentReference documentReference = DocumentReference.Create(deploymentResolvedRoot.LocalPath);
                            if (documentReference.Path.StartsWith(targetProject.ProjectRoot.Path, StringComparison.OrdinalIgnoreCase))
                            {
                                xapDeploymentDirectory = documentReference;
                                project = sourceProject;
                                break;
                            }
                        }
                    }
                }
            }
            return(project);
        }
예제 #26
0
 internal static void UpdateImageReferences(DocumentNode parentNode, IDictionary <DocumentNode, string> imageMap, PastePackage pastePackage, SceneViewModel viewModel)
 {
     foreach (DocumentNode key1 in parentNode.DescendantNodes)
     {
         if (imageMap.ContainsKey(key1))
         {
             string index = imageMap[key1];
             KeyValuePair <Uri, string> keyValuePair = pastePackage.ImageReferences[index];
             Uri key2 = keyValuePair.Key;
             DocumentReference documentReference = DocumentReference.Create(keyValuePair.Value);
             if (!ResourceHelper.IsResourceInSameProject(viewModel, documentReference, key2))
             {
                 IProjectItem itemForImage = ResourceHelper.CreateItemForImage(viewModel, documentReference, pastePackage);
                 if (itemForImage != null)
                 {
                     documentReference = itemForImage.DocumentReference;
                 }
             }
             IDocumentContext referencingDocument = ResourceHelper.DocumentContextFromViewModel(viewModel);
             string           str = (ResourceHelper.MakeResourceReference(referencingDocument, documentReference) ?? key2).OriginalString;
             if (viewModel.Document.ProjectContext.IsCapabilitySet(PlatformCapability.ShouldSanitizeResourceReferences))
             {
                 str = str.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
             }
             DocumentNode documentNode = (DocumentNode)referencingDocument.CreateNode((ITypeId)key1.Type, (IDocumentNodeValue) new DocumentNodeStringValue(str));
             if (key1.IsProperty)
             {
                 key1.Parent.Properties[(IPropertyId)key1.SitePropertyKey] = documentNode;
             }
             else
             {
                 key1.Parent.Children[key1.SiteChildIndex] = documentNode;
             }
         }
     }
 }
예제 #27
0
 private void UpdateLastCut(DataObject thisCut)
 {
     if (this.lastCut != null && thisCut != this.lastCut && this.lastCut.GetDataPresent(typeof(CutBuffer.ProjectCopyInformation)))
     {
         CutBuffer.ProjectCopyInformation data = (CutBuffer.ProjectCopyInformation) this.lastCut.GetData(typeof(CutBuffer.ProjectCopyInformation));
         if (data.IsCut)
         {
             IProject project = this.Services.ProjectManager().CurrentSolution.Projects.FindMatchByUrl <IProject>(data.ProjectUrl);
             if (project != null)
             {
                 foreach (CutBuffer.ItemCopyInformation item in data.Items)
                 {
                     IProjectItem projectItem = project.FindItem(DocumentReference.Create(item.ItemUrl));
                     if (projectItem == null)
                     {
                         continue;
                     }
                     projectItem.IsCut = false;
                 }
             }
         }
     }
     this.lastCut = thisCut;
 }
예제 #28
0
        private string GetRelativePath(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(path);
            }
            string path1 = path;

            try
            {
                if (!Microsoft.Expression.Framework.Documents.PathHelper.IsPathRelative(path))
                {
                    path1 = DocumentReference.Create(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectory(this.projectContext.ProjectPath)).GetRelativePath(DocumentReference.Create(path));
                    path1 = Microsoft.Expression.Framework.Documents.PathHelper.TrimTrailingDirectorySeparators(path1);
                }
            }
            catch (ArgumentException ex)
            {
            }
            catch (UriFormatException ex)
            {
            }
            return(path1);
        }
예제 #29
0
        protected override sealed void Work()
        {
            IProjectDocument projectDocument = this.ProjectDocuments[this.currentViewIndex];

            if (projectDocument == null)
            {
                return;
            }
            bool flag = false;

            if (projectDocument.Document == null)
            {
                IXamlProject xamlProject = this.designerContext.ProjectManager.CurrentSolution.FindProjectContainingItem(DocumentReference.Create(projectDocument.Path)) as IXamlProject;
                if (xamlProject == null)
                {
                    return;
                }
                try
                {
                    projectDocument = xamlProject.ProjectContext.OpenDocument(projectDocument.Path);
                }
                catch (NotSupportedException ex)
                {
                    return;
                }
                flag = true;
                if (projectDocument == null)
                {
                    return;
                }
            }
            SceneDocument document = projectDocument.Document as SceneDocument;

            if (document == null || !document.IsEditable)
            {
                return;
            }
            this.ProcessDocument(document);
            if (!flag)
            {
                return;
            }
            this.CloseDocument(document);
        }
 public override void Execute()
 {
     this.HandleBasicExceptions(() => {
         string str = this.SelectProject();
         if (!string.IsNullOrEmpty(str))
         {
             this.ProjectManager().AddProject(FileSystemProjectStore.CreateInstance(DocumentReference.Create(str), base.Services));
             base.ActivateProjectPane();
         }
     });
 }