public void NewFolder()
        {
            string name;

            if (!View.ShowEditDialog("New Folder", "Folder Name:", "", true, out name))
            {
                return;
            }

            string folder = Path.Combine(GetFullPath(GetCurrentPath()), name);

            try
            {
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
            }
            catch
            {
                View.ShowError("Error While Creating a Directory", "An error has occured while the directory: \"" + folder + "\" was beeing created, aborting...");
                return;
            }

            var action = new IncludeAction(this, null, new List <string> {
                folder
            });

            if (action.Do())
            {
                _actionStack.Add(action);
            }
        }
Exemplo n.º 2
0
        public void IncludeFolder()
        {
            var path = GetFullPath(GetCurrentPath());

            if (!View.ChooseContentFolder(path, out string folder))
            {
                return;
            }

            var items  = new List <IncludeItem>();
            var repeat = false;
            var action = IncludeType.Copy;

            if (!IncludeDirectory(items, path, folder, ref repeat, ref action))
            {
                return;
            }

            if (items.Count == 0)
            {
                return;
            }

            var includeaction = new IncludeAction(items);

            if (includeaction.Do())
            {
                _actionStack.Add(includeaction);
            }
        }
Exemplo n.º 3
0
        public void NewItem()
        {
            string name;
            ContentItemTemplate template;

            if (!View.ChooseItemTemplate(GetFullPath(GetCurrentPath()), out template, out name))
            {
                return;
            }

            var destpath = Path.Combine(GetCurrentPath(), name);

            var action = new IncludeAction(
                new IncludeItem {
                SourcePath       = GetFullPath(destpath),
                RelativeDestPath = destpath,
                IncludeType      = IncludeType.Create,
                ItemTemplate     = template
            }
                );

            if (action.Do())
            {
                _actionStack.Add(action);
            }
        }
Exemplo n.º 4
0
        public void Include()
        {
            var path = GetFullPath(GetCurrentPath());

            if (View.ChooseContentFile(path, out List <string> files))
            {
                var items  = new List <IncludeItem>();
                var repeat = false;
                var action = IncludeType.Copy;

                if (!IncludeFiles(items, path, files.ToArray(), ref repeat, ref action))
                {
                    return;
                }

                if (items.Count == 0)
                {
                    return;
                }

                var includeaction = new IncludeAction(items);
                if (includeaction.Do())
                {
                    _actionStack.Add(includeaction);
                }
            }
        }
Exemplo n.º 5
0
        public void NewFolder(string name, string location)
        {
            string folder = Path.Combine(location, name);

            if (!Path.IsPathRooted(folder))
            {
                folder = _project.Location + Path.DirectorySeparatorChar + folder;
            }

            try
            {
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
            }
            catch {
                View.ShowError("Error While Creating a Directory", "An error has occured while the directory: \"" + folder + "\" was beeing created, aborting...");
                return;
            }

            var action = new IncludeAction(this, null, new List <string> {
                folder
            });

            if (action.Do())
            {
                _actionStack.Add(action);
            }
        }
Exemplo n.º 6
0
        public void NewFolder()
        {
            if (!View.ShowEditDialog("New Folder", "Folder Name:", "", true, out string name))
            {
                return;
            }

            var action = new IncludeAction(new IncludeItem {
                SourcePath       = Path.Combine(GetFullPath(GetCurrentPath()), name),
                RelativeDestPath = Path.Combine(GetCurrentPath(), name),
                IncludeType      = IncludeType.Create,
                IsDirectory      = true
            });

            if (action.Do())
            {
                _actionStack.Add(action);
            }
        }
Exemplo n.º 7
0
        public void Include(string initialDirectory)
        {
            // Root the path to the project.
            if (!Path.IsPathRooted(initialDirectory))
            {
                initialDirectory = Path.Combine(_project.Location, initialDirectory);
            }

            List <string> files;

            if (!_view.ChooseContentFile(initialDirectory, out files))
            {
                return;
            }

            var action = new IncludeAction(this, files);

            action.Do();
            _actionStack.Add(action);
        }
        public void IncludeFolder(string initialDirectory, string[] dirs)
        {
            CopyAction caction     = CopyAction.Copy;
            bool       applyforall = false;

            List <string> ffiles       = new List <string>();
            List <string> ddirectories = new List <string>();

            List <string> sc = new List <string>(), dc = new List <string>();

            foreach (string fol in dirs)
            {
                List <string> files       = new List <string>();
                List <string> directories = new List <string>();

                string folder = fol;

                if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
                {
                    folder += Path.DirectorySeparatorChar;
                }

                files.AddRange(GetFiles(folder));
                directories.Add(folder);
                directories.AddRange(GetDirectories(folder));

                if (!folder.StartsWith(initialDirectory))
                {
                    string nd = folder.Replace(folder, Path.Combine(initialDirectory, (new DirectoryInfo(folder)).Name + Path.DirectorySeparatorChar));

                    if (!applyforall)
                    {
                        if (!View.CopyOrLinkFolder(folder, Directory.Exists(nd), out caction, out applyforall))
                        {
                            return;
                        }
                    }

                    if (caction == CopyAction.Copy)
                    {
                        for (int i = 0; i < directories.Count; i++)
                        {
                            ddirectories.Add(directories[i].Replace(folder, Path.Combine(initialDirectory, (new DirectoryInfo(folder)).Name + Path.DirectorySeparatorChar)));
                        }

                        for (int i = 0; i < files.Count; i++)
                        {
                            ffiles.Add(files[i].Replace(folder, Path.Combine(initialDirectory, (new DirectoryInfo(folder)).Name + Path.DirectorySeparatorChar)));
                        }

                        sc.Add(folder);
                        dc.Add(nd);
                    }
                    else if (caction == CopyAction.Link)
                    {
                        string pl = _project.Location;
                        if (!pl.EndsWith(Path.DirectorySeparatorChar.ToString()))
                        {
                            pl += Path.DirectorySeparatorChar;
                        }

                        Uri folderUri = new Uri(pl);

                        for (int i = 0; i < directories.Count; i++)
                        {
                            Uri pathUri = new Uri(directories[i]);
                            ddirectories.Add(Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar)));
                        }

                        for (int i = 0; i < files.Count; i++)
                        {
                            Uri pathUri = new Uri(files[i]);
                            ffiles.Add(Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar)));
                        }
                    }
                }
                else
                {
                    ddirectories.AddRange(directories);
                    ffiles.AddRange(files);
                }
            }

            try
            {
                for (int i = 0; i < sc.Count; i++)
                {
                    DirectoryCopy(sc[i], dc[i]);
                }

                var action2 = new IncludeAction(this, ffiles, ddirectories);
                if (action2.Do())
                {
                    _actionStack.Add(action2);
                }
            }
            catch
            {
                View.ShowError("Error While Copying Files", "An error occurred while the directories were being copied, aborting.");
            }
        }
        private void Include(string initialDirectory, string[] f)
        {
            List <string> files = new List <string>();

            files.AddRange(f);

            List <string> sc = new List <string>(), dc = new List <string>();
            int           def = 0;

            for (int i = 0; i < files.Count; i++)
            {
                if (!files[i].StartsWith(initialDirectory))
                {
                    string newfile = Path.Combine(initialDirectory, Path.GetFileName(files[i]));
                    int    daction = def;

                    if (daction == 1)
                    {
                        if (File.Exists(newfile))
                        {
                            daction = 2;
                        }
                    }

                    if (daction == 0)
                    {
                        bool       applyforall;
                        CopyAction act;

                        if (!View.CopyOrLinkFile(files[i], File.Exists(newfile), out act, out applyforall))
                        {
                            return;
                        }

                        daction = (int)act + 1;
                        if (applyforall)
                        {
                            def = daction;
                        }
                    }

                    if (daction == 1)
                    {
                        sc.Add(files[i]);
                        dc.Add(newfile);
                        files[i] = newfile;
                    }
                    else if (daction == 3)
                    {
                        files.RemoveAt(i);
                        i--;
                    }
                }
            }

            if (files.Count == 0)
            {
                return;
            }

            try
            {
                for (int i = 0; i < sc.Count; i++)
                {
                    File.Copy(sc[i], dc[i]);
                }

                var action = new IncludeAction(this, files);
                if (action.Do())
                {
                    _actionStack.Add(action);
                }
            }
            catch
            {
                View.ShowError("Error While Copying Files", "An error occurred while the files were being copied, aborting.");
            }
        }
        public void Include(string initialDirectory)
        {       
            // Root the path to the project.
            if (!Path.IsPathRooted(initialDirectory))
                initialDirectory = Path.Combine(_project.Location, initialDirectory);

            List<string> files;
            if (!_view.ChooseContentFile(initialDirectory, out files))
                return;

            var action = new IncludeAction(this, files);
            action.Do();
            _actionStack.Add(action);  
        }
Exemplo n.º 11
0
        public void IncludeFolder(string initialDirectory)
        {
            // Root the path to the project.
            if (!Path.IsPathRooted(initialDirectory))
            {
                initialDirectory = Path.Combine(_project.Location, initialDirectory);
            }

            string folder;

            if (!View.ChooseContentFolder(initialDirectory, out folder))
            {
                return;
            }

            if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                folder += Path.DirectorySeparatorChar;
            }

            List <string> files       = new List <string>();
            List <string> directories = new List <string>();

            files.AddRange(GetFiles(folder));
            directories.Add(folder);
            directories.AddRange(GetDirectories(folder));

            if (!folder.StartsWith(initialDirectory))
            {
                CopyAction caction;

                if (!View.CopyOrLinkFolder(folder, out caction))
                {
                    return;
                }

                if (caction == CopyAction.Copy)
                {
                    for (int i = 0; i < directories.Count; i++)
                    {
                        try
                        {
                            DirectoryInfo dinfo  = new DirectoryInfo(folder);
                            string        newdir = directories[i].Replace(folder, initialDirectory + Path.DirectorySeparatorChar + dinfo.Name + Path.DirectorySeparatorChar);

                            if (!Directory.Exists(newdir))
                            {
                                Directory.CreateDirectory(newdir);
                            }

                            directories[i] = newdir;
                        }
                        catch
                        {
                            View.ShowError("Error While Creating Directories", "An error occurred while the directories were beeing created, aborting.");
                            return;
                        }
                    }

                    for (int i = 0; i < files.Count; i++)
                    {
                        try
                        {
                            DirectoryInfo dinfo   = new DirectoryInfo(folder);
                            string        newfile = files[i].Replace(folder, initialDirectory + Path.DirectorySeparatorChar + dinfo.Name + Path.DirectorySeparatorChar);

                            if (!File.Exists(newfile))
                            {
                                File.Copy(files[i], newfile);
                            }
                            else
                            {
                                View.ShowError("Error While Copying Files", "An error occurred while the files were being copied, the file:\"" +
                                               newfile + "\" already exists, aborting.");
                                return;
                            }

                            files[i] = newfile;
                        }
                        catch
                        {
                            View.ShowError("Error While Copying Files", "An error occurred while the files were being copied, aborting.");
                            return;
                        }
                    }
                }
                else
                {
                    string pl = _project.Location;
                    if (!pl.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    {
                        pl += Path.DirectorySeparatorChar;
                    }

                    Uri folderUri = new Uri(pl);

                    for (int i = 0; i < directories.Count; i++)
                    {
                        Uri pathUri = new Uri(directories[i]);
                        directories[i] = Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar));
                    }
                }
            }

            var action2 = new IncludeAction(this, files, directories);

            if (action2.Do())
            {
                _actionStack.Add(action2);
            }
        }
Exemplo n.º 12
0
        public void NewFolder(string name, string location)
        {
            string folder = Path.Combine(location, name);

            if (!Path.IsPathRooted(folder))
                folder = _project.Location + Path.DirectorySeparatorChar + folder;

            try
            {
                if (!Directory.Exists(folder))
                    Directory.CreateDirectory(folder);
            }
            catch {
                View.ShowError ("Error While Creating a Directory", "An error has occured while the directory: \"" + folder + "\" was beeing created, aborting...");
                return;
            }

            var action = new IncludeAction(this, null, new List<string> { folder });
            if(action.Do())
                _actionStack.Add(action);
        }
Exemplo n.º 13
0
        public void IncludeFolder(string initialDirectory, string[] dirs)
        {
            CopyAction caction = CopyAction.Copy;
            bool applyforall = false;

            List<string> ffiles = new List<string>();
            List<string> ddirectories = new List<string>();

            List<string> sc = new List<string>(), dc = new List<string>();

            foreach (string fol in dirs)
            {
                List<string> files = new List<string>();
                List<string> directories = new List<string>();

                string folder = fol;

                if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    folder += Path.DirectorySeparatorChar;

                files.AddRange(GetFiles(folder));
                directories.Add(folder);
                directories.AddRange(GetDirectories(folder));

                if (!folder.StartsWith(initialDirectory))
                {
                    string nd = folder.Replace(folder, initialDirectory + (new DirectoryInfo(folder)).Name + Path.DirectorySeparatorChar);

                    if (!applyforall)
                    if (!View.CopyOrLinkFolder(folder, Directory.Exists(nd), out caction, out applyforall))
                        return;

                    if (caction == CopyAction.Copy)
                    {
                        for (int i = 0; i < directories.Count; i++)
                            ddirectories.Add(directories[i].Replace(folder, initialDirectory + (new DirectoryInfo(folder)).Name + Path.DirectorySeparatorChar));

                        for (int i = 0; i < files.Count; i++)
                            ffiles.Add(files[i].Replace(folder, initialDirectory + (new DirectoryInfo(folder)).Name + Path.DirectorySeparatorChar));

                        sc.Add(folder);
                        dc.Add(nd);
                    }
                    else if (caction == CopyAction.Link)
                    {
                        string pl = _project.Location;
                        if (!pl.EndsWith(Path.DirectorySeparatorChar.ToString()))
                            pl += Path.DirectorySeparatorChar;

                        Uri folderUri = new Uri(pl);

                        for (int i = 0; i < directories.Count; i++)
                        {
                            Uri pathUri = new Uri(directories[i]);
                            ddirectories.Add(Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar)));
                        }

                        for (int i = 0; i < files.Count; i++)
                        {
                            Uri pathUri = new Uri(files[i]);
                            ffiles.Add(Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar)));
                        }
                    }
                }
                else
                {
                    ddirectories.AddRange(directories);
                    ffiles.AddRange(files);
                }
            }

            try
            {
                for (int i = 0; i < sc.Count; i++)
                    DirectoryCopy(sc[i], dc[i]);

                var action2 = new IncludeAction(this, ffiles, ddirectories);
                if (action2.Do())
                    _actionStack.Add(action2);
            }
            catch
            {
                View.ShowError("Error While Copying Files", "An error occurred while the directories were being copied, aborting.");
            }
        }
Exemplo n.º 14
0
        private void Include(string initialDirectory, string[] f)
        {
            List<string> files = new List<string>();
            files.AddRange(f);

            List<string> sc = new List<string>(), dc = new List<string>();
            int def = 0;

            for (int i = 0; i < files.Count; i++)
            {
                if (!files[i].StartsWith(initialDirectory))
                {
                    string newfile = Path.Combine(initialDirectory, Path.GetFileName(files[i]));
                    int daction = def;

                    if (daction == 1)
                        if (File.Exists(newfile))
                            daction = 2;

                    if (daction == 0)
                    {
                        bool applyforall;
                        CopyAction act;

                        if (!View.CopyOrLinkFile(files[i], File.Exists(newfile), out act, out applyforall))
                            return;

                        daction = (int)act + 1;
                        if (applyforall)
                            def = daction;
                    }

                    if (daction == 1)
                    {
                        sc.Add(files[i]);
                        dc.Add(newfile);
                        files[i] = newfile;
                    }
                    else if (daction == 3)
                    {
                        files.RemoveAt(i);
                        i--;
                    }
                }
            }

            if (files.Count == 0)
                return;

            try
            {
                for (int i = 0; i < sc.Count; i++)
                    File.Copy(sc[i], dc[i]);

                var action = new IncludeAction(this, files);
                if(action.Do())
                    _actionStack.Add(action);  
            }
            catch
            {
                View.ShowError("Error While Copying Files", "An error occurred while the files were being copied, aborting.");
            }
        }
Exemplo n.º 15
0
        public void Include(string initialDirectory)
        {
            // Root the path to the project.
            if (!Path.IsPathRooted(initialDirectory))
            {
                initialDirectory = Path.Combine(_project.Location, initialDirectory);
            }

            List <string> files;

            if (!View.ChooseContentFile(initialDirectory, out files))
            {
                return;
            }

            List <string> sc = new List <string>(), dc = new List <string>();
            int           def = 0;

            for (int i = 0; i < files.Count; i++)
            {
                if (!files[i].StartsWith(initialDirectory))
                {
                    string newfile = Path.Combine(initialDirectory, Path.GetFileName(files[i]));
                    int    daction = def;

                    if (daction == 1)
                    {
                        if (File.Exists(newfile))
                        {
                            daction = 2;
                        }
                    }

                    if (daction == 0)
                    {
                        bool       applyforall;
                        CopyAction act;

                        if (!View.CopyOrLink(files[i], File.Exists(newfile), out act, out applyforall))
                        {
                            return;
                        }

                        daction = (int)act + 1;
                        if (applyforall)
                        {
                            def = daction;
                        }
                    }

                    if (daction == 1)
                    {
                        sc.Add(files[i]);
                        dc.Add(newfile);
                        files[i] = newfile;
                    }
                    else if (daction == 3)
                    {
                        files.RemoveAt(i);
                        i--;
                    }
                }
            }

            if (files.Count == 0)
            {
                return;
            }

            try
            {
                for (int i = 0; i < sc.Count; i++)
                {
                    File.Copy(sc[i], dc[i]);
                }

                var action = new IncludeAction(this, files);
                action.Do();
                _actionStack.Add(action);
            }
            catch
            {
                View.ShowError("Error While Copying Files", "An error occurred while the files were being copied, aborting.");
            }
        }
Exemplo n.º 16
0
        public void IncludeFolder(string initialDirectory)
        {
            // Root the path to the project.
            if (!Path.IsPathRooted(initialDirectory))
                initialDirectory = Path.Combine(_project.Location, initialDirectory);

            string folder;
            if (!View.ChooseContentFolder(initialDirectory, out folder))
                return;

            if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
                folder += Path.DirectorySeparatorChar;

            List<string> files = new List<string>();
            List<string> directories = new List<string>();

            files.AddRange(GetFiles(folder));
            directories.Add(folder);
            directories.AddRange(GetDirectories(folder));

            if (!folder.StartsWith(initialDirectory))
            {
                CopyAction caction;

                if (!View.CopyOrLinkFolder(folder, out caction))
                    return;

                if (caction == CopyAction.Copy)
                {

                    for (int i = 0; i < directories.Count; i++)
                    {
                        try
                        {
                            DirectoryInfo dinfo = new DirectoryInfo(folder);
                            string newdir = directories[i].Replace(folder, initialDirectory + Path.DirectorySeparatorChar + dinfo.Name + Path.DirectorySeparatorChar);

                            if (!Directory.Exists(newdir))
                                Directory.CreateDirectory(newdir);

                            directories[i] = newdir;
                        }
                        catch
                        {
                            View.ShowError("Error While Creating Directories", "An error occurred while the directories were beeing created, aborting.");
                            return;
                        }
                    }

                    for (int i = 0; i < files.Count; i++)
                    {
                        try
                        {
                            DirectoryInfo dinfo = new DirectoryInfo(folder);
                            string newfile = files[i].Replace(folder, initialDirectory + Path.DirectorySeparatorChar + dinfo.Name + Path.DirectorySeparatorChar);

                            if (!File.Exists(newfile))
                                File.Copy(files[i], newfile);
                            else
                            {
                                View.ShowError("Error While Copying Files", "An error occurred while the files were being copied, the file:\"" +
                                    newfile + "\" already exists, aborting.");
                                return;
                            }

                            files[i] = newfile;
                        }
                        catch
                        {
                            View.ShowError("Error While Copying Files", "An error occurred while the files were being copied, aborting.");
                            return;
                        }
                    }
                }
                else
                {
                    string pl = _project.Location;
                    if (!pl.EndsWith(Path.DirectorySeparatorChar.ToString()))
                        pl += Path.DirectorySeparatorChar;

                    Uri folderUri = new Uri(pl);

                    for (int i = 0; i < directories.Count; i++)
                    {
                        Uri pathUri = new Uri(directories[i]);
                        directories[i] = Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar));
                    }
                }
            }

            var action2 = new IncludeAction(this, files, directories);
            if(action2.Do())
                _actionStack.Add(action2);
        }