Пример #1
0
        private bool AddContentFolderCanExecute(string folderName)
        {
            if (folderName == null)
            {
                return(false);
            }

            return(!RootFolder.ContainsFolder(folderName));
        }
Пример #2
0
        private bool AddContentFolderCanExecute(string folderName)
        {
            if (folderName == null)
            {
                return(false);
            }

            if (IsSigned || IsInEditFileMode)
            {
                return(false);
            }

            return(!RootFolder.ContainsFolder(folderName));
        }
Пример #3
0
        public void AddDraggedAndDroppedFiles(PackageFolder folder, string[] fileNames)
        {
            if (folder == null)
            {
                bool?rememberedAnswer = null;

                for (var i = 0; i < fileNames.Length; i++)
                {
                    var file = fileNames[i];
                    if (File.Exists(file))
                    {
                        bool movingFile;

                        PackageFolder targetFolder;
                        var           guessFolderName = FileHelper.GuessFolderNameFromFile(file);

                        if (rememberedAnswer == null)
                        {
                            // ask user if he wants to move file
                            var answer = UIServices.ConfirmMoveFile(
                                Path.GetFileName(file),
                                guessFolderName, fileNames.Length - i - 1);

                            if (answer.Item1 == null)
                            {
                                // user presses Cancel
                                break;
                            }

                            movingFile = (bool)answer.Item1;
                            if (answer.Item2)
                            {
                                rememberedAnswer = answer.Item1;
                            }
                        }
                        else
                        {
                            movingFile = (bool)rememberedAnswer;
                        }

                        if (movingFile)
                        {
                            if (RootFolder.ContainsFolder(guessFolderName))
                            {
                                targetFolder = (PackageFolder)RootFolder[guessFolderName];
                            }
                            else
                            {
                                targetFolder = RootFolder.AddFolder(guessFolderName);
                            }
                        }
                        else
                        {
                            targetFolder = RootFolder;
                        }

                        targetFolder.AddFile(file);
                    }
                    else if (Directory.Exists(file))
                    {
                        RootFolder.AddPhysicalFolder(file);
                    }
                }
            }
            else
            {
                foreach (var file in fileNames)
                {
                    if (File.Exists(file))
                    {
                        folder.AddFile(file);
                    }
                    else if (Directory.Exists(file))
                    {
                        folder.AddPhysicalFolder(file);
                    }
                }
            }
        }