public void Replace(Profile oldProfile, Profile newProfile)
        {
            for (var i = 0; i < ProfileList.Count; i++)
            {
                if (ProfileList[i] == oldProfile)
                {
                    ProfileList[i] = newProfile;
                }
            }

            if (oldProfile.Name != newProfile.Name)
            {
                var oldProfileFolder = oldProfile.Folder;
                var newProfileFolder = newProfile.Folder;
                if (oldProfileFolder.GetFiles().Any() || oldProfileFolder.GetFolders().Any())
                {
                    var folderReplace = GetEmptyProfileFolder(newProfile);

                    if (newProfileFolder.GetFiles().Any() || newProfileFolder.GetFolders().Any())
                    {
                        newProfileFolder.Move(folderReplace);
                        newProfileFolder = new ProfileFolder(newProfileFolder); // -- Recreate folder. Design flaw
                    }

                    oldProfileFolder.Move(newProfileFolder);
                }
            }
        }
        public async Task ReplaceAsync(Profile oldProfile, Profile newProfile)
        {
            for (var i = 0; i < ProfileList.Count; i++)
            {
                if (ProfileList[i] == oldProfile)
                {
                    ProfileList[i] = newProfile;
                }
            }

            if (oldProfile.Name != newProfile.Name)
            {
                var oldProfileFolder = oldProfile.Folder;
                var newProfileFolder = newProfile.Folder;
                if ((await oldProfileFolder.GetFilesAsync()).Any() || (await oldProfileFolder.GetFoldersAsync()).Any())
                {
                    var folderReplace = GetEmptyProfileFolder(newProfile);

                    if ((await newProfileFolder.GetFilesAsync()).Any() || (await newProfileFolder.GetFoldersAsync()).Any())
                    {
                        await newProfileFolder.MoveAsync(folderReplace);

                        newProfileFolder = new ProfileFolder(newProfileFolder); // -- Recreate folder. Design flaw
                    }

                    await oldProfileFolder.MoveAsync(newProfileFolder);
                }
            }
        }
 public BoundProfile(string displayName, BoundModList boundModList, string identifier = null)
 {
     identifier    = (identifier ?? displayName).Sanitize();
     ProfileFolder = App.Profiles.Directory.CreateSubdirectory(identifier);
     Source        = new FileInfo(Path.Combine(ProfileFolder.FullName, Resources.ProfileConfigName));
     XmlRoot       = new XDocument(
         new XElement("config",
                      new XElement("displayName", displayName),
                      new XElement("modpack", boundModList.Identifier)
                      )
         );
     ProfileFolder.CreateSubdirectory(Resources.SavesFolderName);
     this.Save();
 }
        private static ProfileFolder GetEmptyProfileFolder(Profile profile)
        {
            var profileFolder = profile.Folder;

            while (true)
            {
                if (profileFolder.GetFiles().Any() || profileFolder.GetFolders().Any())
                {
                    profileFolder = new ProfileFolder($"{profileFolder.Name}_old", profile.ProfileType);
                    continue;
                }

                return(profileFolder);
            }
        }
示例#5
0
        public VFS(AbsolutePath mo2Path, string profile, AbsolutePath[] ignoreFolders)
        {
            IgnoredFolders    = ignoreFolders;
            ModOrganizer2Path = mo2Path;
            MO2Ini            = ModOrganizer2Path.Combine("ModOrganizer.ini").LoadIniFile();

            ModFolder = mo2Path.Combine("mods");
            Mods      = ModFolder.EnumerateDirectories(false)
                        .Where(f => !ignoreFolders.Any(f.InFolder))
                        .Select(m => new Mod(m.FileName.ToString(), this))
                        .ToDictionary(m => m.Name);

            ProfileFolder     = mo2Path.Combine("profiles", profile);
            ModlistDefinition = LoadModList(ProfileFolder.Combine("modlist.txt"));


            ModList = ModlistDefinition.Where(m => m.Status == ModStatus.Enabled)
                      .Select(m => (m.Status, Mods[m.Name]))
                      .ToArray();

            AppliedList = ModList.Select(m => m.Mod).SelectMany(m => m.Files).ToLookup(m => m.Path);

            PluginListDefinition = LoadPluginList(ProfileFolder.Combine("plugins.txt"));
            Plugins = PluginListDefinition.Where(p => p.Status == PluginStatus.Enabled)
                      .Select(p => AppliedList[(RelativePath)p.Name].First())
                      .ToArray();

            AppliedBSAs = Plugins.SelectMany(e =>
            {
                var name = e.Path.FileNameWithoutExtension.ToString();
                return(new[]
                {
                    (RelativePath)(name + ".bsa"),
                    (RelativePath)(name + " - Textures.bsa")
                });
            }).Select(bsa => AppliedList[bsa])
                          .Where(bsa => bsa.Any())
                          .Select(bsa => bsa.First())
                          .Select(bsa => (bsa, BSADispatch.OpenRead(bsa.AbsolutePath).GetAwaiter().GetResult()))
                          .ToArray();

            AppliedBSAFiles = AppliedBSAs
                              .SelectMany(bsa => bsa.BSA.Files
                                          .Select(f => new BSAModFile(bsa.Mod, f))).ToArray();
            AllAppliedFiles = AppliedBSAFiles
                              .Concat(ModList.Select(m => m.Mod).SelectMany(m => m.Files).Cast <IModFile>())
                              .ToLookup(f => f.Path);
        }
示例#6
0
        static void ProgramFlow()
        {
            Console.WriteLine("Welcome to AutoCopy :) !");
            new ProfileFolder();
            Console.WriteLine("Create new profile(y/n)");
            string ans = Console.ReadLine();

            if (ans == "y" || ans == "Y")
            {
                ProfileFolder.CreateProfile();
            }
            FolderObject obj = ProfileFolder.SelectProfile();

            Console.WriteLine("Pulse intro to close");
            new CopyLog(obj);
            Console.ReadLine();
        }
示例#7
0
 void InitializeEngineEvents()
 {
     #region Scan events
     client.ScanningStarted += (o, e) =>
     {
         var ignore = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             p_progress.Maximum  = client.ScanTotal;
             p_progress.Value    = 0;
             t_progress.Text     = 0 + "/" + client.ScanTotal;
             g_scan.Visibility   = Windows.UI.Xaml.Visibility.Visible;
             b_cancel.Visibility = Windows.UI.Xaml.Visibility.Visible;
             b_scan.Visibility   = Windows.UI.Xaml.Visibility.Collapsed;
             CheckForAdvise();
         });
     };
     client.ScanningDone += (o, e) =>
     {
         var ignore = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             b_scan.Visibility   = Windows.UI.Xaml.Visibility.Visible;
             g_scan.Visibility   = Windows.UI.Xaml.Visibility.Collapsed;
             b_cancel.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
             CheckForAdvise();
         });
     };
     client.ScanProgressUpdated += (o, e) =>
     {
         var ignore = dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
         {
             p_progress.Value = e.Scanned;
             t_progress.Text  = e.Scanned + "/" + client.ScanTotal;
             t_lastip.Text    = e.LastIP;
             CheckForAdvise();
         });
     };
     #endregion
     #region Connection events
     client.ConnectionTimeout += (o, e) =>
     {
         var ignore = dispatcher.RunAsync(CoreDispatcherPriority.Low, async() =>
         {
             MessageDialog dialog = new MessageDialog("Cannot connect to the server.");
             dialog.Commands.Add(new UICommand("OK"));
             await dialog.ShowAsync();
         });
         manually = false;
     };
     client.NewProfile += (o, e) =>
     {
         if (manually)
         {
             var ignore = dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
             {
                 OpeningFolder = clientManager.ConnectedFolder;
             });
         }
         manually = false;
     };
     #endregion
 }
示例#8
0
 void InitializeUI()
 {
     l_folders.DataContext = clientManager.Folders;
     OpeningFolder         = clientManager.AvailableFolder;
 }