コード例 #1
0
        private void UpdateToolkitXmlNamespace()
        {
            string str;

            if (string.Compare(Path.GetExtension(this.currentXamlPath), ".xaml", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return;
            }
            if (!this.ContainsWpfToolkitNamespace(this.currentXamlPath, out str))
            {
                return;
            }
            string str1 = File.ReadAllText(this.currentXamlPath, Encoding.UTF8);
            string str2 = this.ReplaceWpfToolkitNamespace(str1, str);

            if (str2 != null)
            {
                try
                {
                    if (this.context == null || ProjectPathHelper.AttemptToMakeWritable(DocumentReference.Create(this.currentXamlPath), this.context))
                    {
                        File.WriteAllText(this.currentXamlPath, str2, Encoding.UTF8);
                        ProjectLog.LogSuccess(this.currentXamlPath, StringTable.SaveAction, new object[0]);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    ProjectLog.LogError(this.currentXamlPath, exception, StringTable.SaveAction, new object[0]);
                }
            }
        }
コード例 #2
0
        public static string GetAvailableFilePath(string fileOrDirectoryName, string targetFolder, IProject project, bool tryNoDigitFirst)
        {
            string str;
            string str1;
            string str2;

            ProjectPathHelper.GetFileNameAndExtension(fileOrDirectoryName, out str, out str1);
            int    num  = 1;
            string str3 = null;
            bool   flag = tryNoDigitFirst;

            do
            {
                if (!flag)
                {
                    str2 = string.Concat(str, num.ToString(CultureInfo.InvariantCulture), str1);
                    num++;
                }
                else
                {
                    str2 = string.Concat(str, str1);
                    flag = false;
                }
                string str4 = Path.Combine(targetFolder, str2);
                if (!ProjectPathHelper.IsFilePathAvailable(project, str4))
                {
                    continue;
                }
                str3 = str4;
            }while (str3 == null);
            return(str3);
        }
コード例 #3
0
 public static void CleanDirectory(string directoryName, bool deleteTopDirectoryOnError)
 {
     if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(directoryName))
     {
         return;
     }
     string[] files = Directory.GetFiles(directoryName);
     for (int i = 0; i < (int)files.Length; i++)
     {
         string str = files[i];
         try
         {
             File.SetAttributes(str, FileAttributes.Normal);
             File.Delete(str);
         }
         catch (IOException oException)
         {
             deleteTopDirectoryOnError = false;
             break;
         }
     }
     string[] directories = Directory.GetDirectories(directoryName);
     for (int j = 0; j < (int)directories.Length; j++)
     {
         ProjectPathHelper.CleanDirectory(directories[j], deleteTopDirectoryOnError);
     }
     if (deleteTopDirectoryOnError)
     {
         Directory.Delete(directoryName, true);
     }
 }
コード例 #4
0
 private MigratingMSBuildStore(Microsoft.Expression.Framework.Documents.DocumentReference documentReference, IServiceProvider serviceProvider)
 {
     this.DocumentReference = documentReference;
     this.serviceProvider   = serviceProvider;
     this.AttemptToMigrate  = (bool callerSuccess) => {
         if (!callerSuccess)
         {
             return(callerSuccess);
         }
         try
         {
             ProjectPathHelper.AttemptToMakeWritable(this.DocumentReference, this.serviceProvider);
             this.Save();
             IProjectStore projectStore = MSBuildBasedProjectStore.CreateInstance(this.DocumentReference, this.serviceProvider);
             this.NestedStore.Dispose();
             this.NestedStore      = projectStore;
             this.AttemptToMigrate = (bool value) => value;
         }
         catch (InvalidProjectFileException invalidProjectFileException)
         {
             this.LastError = invalidProjectFileException;
         }
         return(callerSuccess);
     };
 }
コード例 #5
0
        public static string GetFileNameWithoutExtension(string fileOrDirectoryName)
        {
            string str;
            string str1;

            ProjectPathHelper.GetFileNameAndExtension(fileOrDirectoryName, out str, out str1);
            return(str);
        }
コード例 #6
0
ファイル: AssemblyCache.cs プロジェクト: radtek/Shopdrawing
 public void Clean()
 {
     try
     {
         ProjectPathHelper.CleanDirectory(this.location, true);
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         if (!(exception is ArgumentException) && !(exception is IOException) && !(exception is NotSupportedException) && !(exception is UnauthorizedAccessException))
         {
             throw;
         }
     }
 }
コード例 #7
0
        public static bool AttemptToMakeWritable(DocumentReference documentReference, IServiceProvider serviceProvider)
        {
            HandlerBasedProjectActionContext handlerBasedProjectActionContext = new HandlerBasedProjectActionContext(serviceProvider)
            {
                ExceptionHandler = (DocumentReference doc, Exception exception) => {
                    if (!ErrorHandling.ShouldHandleExceptions(exception))
                    {
                        return(false);
                    }
                    serviceProvider.MessageDisplayService().ShowError(string.Format(CultureInfo.CurrentCulture, StringTable.FileAccessErrorDialogMessage, new object[] { doc.DisplayNameShort, exception.Message }));
                    return(true);
                },
                CanOverwriteHandler = (DocumentReference doc) => ProjectPathHelper.PromptToOverwrite(doc, serviceProvider)
            };

            return(ProjectPathHelper.AttemptToMakeWritable(documentReference, handlerBasedProjectActionContext));
        }
コード例 #8
0
ファイル: CutBuffer.cs プロジェクト: radtek/Shopdrawing
        public static IProjectItem AddImageDataFromClipboard(IProjectManager projectManager, IProject project)
        {
            InteropBitmap data;
            IProjectItem  projectItem;

            try
            {
                data = (InteropBitmap)Clipboard.GetData(DataFormats.Bitmap);
                goto Label0;
            }
            catch (OutOfMemoryException outOfMemoryException)
            {
                LowMemoryMessage.Show();
                projectItem = null;
            }
            return(projectItem);

Label0:
            if (data == null)
            {
                return(null);
            }
            FormatConvertedBitmap formatConvertedBitmap = new FormatConvertedBitmap(data, PixelFormats.Bgr32, null, 0);
            string str = projectManager.TargetFolderForProject(project);
            string availableFilePath = ProjectPathHelper.GetAvailableFilePath("Image.png", str, null);

            using (FileStream fileStream = new FileStream(availableFilePath, FileMode.Create, FileAccess.Write))
            {
                PngBitmapEncoder pngBitmapEncoder = new PngBitmapEncoder();
                pngBitmapEncoder.Frames.Add(BitmapFrame.Create(formatConvertedBitmap));
                pngBitmapEncoder.Save(fileStream);
                fileStream.Close();
            }
            DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo()
            {
                SourcePath = availableFilePath,
                TargetPath = availableFilePath
            };

            return(project.AddItem(documentCreationInfo));
        }
コード例 #9
0
        private static IList <MoveResult> MoveSafeInternal(IEnumerable <Microsoft.Expression.Project.MoveInfo> moveRequests, Microsoft.Expression.Project.MoveOptions moveOptions, bool isMove, bool shouldThrowIOExceptions)
        {
            IList <MoveResult> moveResults;

            if (moveRequests == null)
            {
                throw new ArgumentNullException("moveRequests");
            }
            IList <MoveResult> moveResults1 = new List <MoveResult>();

            if (!moveRequests.Any <Microsoft.Expression.Project.MoveInfo>())
            {
                return(moveResults1);
            }
            List <Microsoft.Expression.Project.MoveInfo> list = (
                from moveInfo in moveRequests
                where ProjectPathHelper.ValidateMoveInfo(moveInfo, moveOptions)
                select moveInfo).ToList <Microsoft.Expression.Project.MoveInfo>();
            List <Microsoft.Expression.Project.MoveInfo> moveInfos = new List <Microsoft.Expression.Project.MoveInfo>();

            List <Microsoft.Expression.Project.MoveInfo> .Enumerator enumerator = list.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    Microsoft.Expression.Project.MoveInfo current = enumerator.Current;
                    try
                    {
                        bool flag  = (moveOptions & Microsoft.Expression.Project.MoveOptions.OverwriteDestination) == Microsoft.Expression.Project.MoveOptions.OverwriteDestination;
                        bool flag1 = isMove;
                        if (Microsoft.Expression.Framework.Documents.PathHelper.IsDirectory(current.Source))
                        {
                            if (ProjectPathHelper.HasContentAlreadyBeenMoved(moveInfos, current.Source))
                            {
                                MoveResult moveResult = new MoveResult()
                                {
                                    Source            = current.Source,
                                    Destination       = current.Destination,
                                    MovedSuccessfully = true
                                };
                                moveResults1.Add(moveResult);
                            }
                            else
                            {
                                using (IEnumerator <MoveResult> enumerator1 = ProjectPathHelper.MoveDirectorySafe(current, flag1, flag).GetEnumerator())
                                {
                                    while (enumerator1.MoveNext())
                                    {
                                        moveResults1.Add(enumerator1.Current);
                                    }
                                }
                            }
                            moveInfos.Add(current);
                        }
                        else if (!ProjectPathHelper.HasContentAlreadyBeenMoved(moveInfos, current.Source))
                        {
                            Microsoft.Expression.Framework.Documents.PathHelper.ClearFileOrDirectoryReadOnlyAttribute(current.Source);
                            string directoryNameOrRoot = Microsoft.Expression.Framework.Documents.PathHelper.GetDirectoryNameOrRoot(current.Destination);
                            if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(directoryNameOrRoot))
                            {
                                Directory.CreateDirectory(directoryNameOrRoot);
                            }
                            if (flag && Microsoft.Expression.Framework.Documents.PathHelper.FileExists(current.Destination))
                            {
                                Microsoft.Expression.Framework.Documents.PathHelper.ClearFileOrDirectoryReadOnlyAttribute(current.Destination);
                            }
                            File.Copy(current.Source, current.Destination, flag);
                            MoveResult moveResult1 = new MoveResult()
                            {
                                Source            = current.Source,
                                Destination       = current.Destination,
                                MovedSuccessfully = true
                            };
                            moveResults1.Add(moveResult1);
                            if (flag1)
                            {
                                File.Delete(current.Source);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        if (!ProjectPathHelper.IsIOException(exception) || shouldThrowIOExceptions)
                        {
                            throw;
                        }
                        else
                        {
                            moveResults = null;
                            return(moveResults);
                        }
                    }
                }
                return(moveResults1);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            return(moveResults);
        }
コード例 #10
0
 public static IList <MoveResult> MoveSafe(IEnumerable <Microsoft.Expression.Project.MoveInfo> moveRequests, Microsoft.Expression.Project.MoveOptions moveOptions, bool shouldThrowIOExceptions)
 {
     return(ProjectPathHelper.MoveSafeInternal(moveRequests, moveOptions, true, shouldThrowIOExceptions));
 }
コード例 #11
0
 public static string GetAvailableFilePath(string fileOrDirectoryName, string targetFolder, IProject project)
 {
     return(ProjectPathHelper.GetAvailableFilePath(fileOrDirectoryName, targetFolder, project, false));
 }
コード例 #12
0
 public static IList <MoveResult> CopySafe(IEnumerable <Microsoft.Expression.Project.MoveInfo> copyRequests, Microsoft.Expression.Project.MoveOptions copyOptions, bool shouldThrowIOExceptions)
 {
     return(ProjectPathHelper.MoveSafeInternal(copyRequests, copyOptions, false, shouldThrowIOExceptions));
 }