public void TestView() { /* * Data.UserKeywords.RemoveEmpty(); * * for (int i = 0; i < 50; i++) * { * string testStr = "test_" + i; * * var tdata = new TemplateEditorData() * { * ID = testStr, * Name = testStr * }; * tdata.Init(Data); * Data.Templates.Add(tdata); * * var kdata = new KeywordData() * { * KeywordName = testStr, * KeywordValue = "" * }; * Data.UserKeywords.Keywords.Add(kdata); * } */ Data.NewProjects.Add(new AvailableProjectViewData() { Name = "SJjjsjdiasjdiasidiahdisahdihaisdhddddddddddddddddddddddddddddddddddddddddiasdias" }); for (var i = 0; i < 15; i++) { Data.NewProjects.Add(new AvailableProjectViewData() { Name = "Project_" + i }); } Data.ManagedProjects.Add(ModProjectData.Test("Test Project")); Data.ManagedProjects.Add(ModProjectData.Test("Test Project 2")); }
public void AddProjects(List <AvailableProjectViewData> selectedItems) { bool bSaveData = false; foreach (AvailableProjectViewData project in selectedItems) { Log.Here().Activity($"Adding project {project.Name} data to managed projects."); var modData = Data.ModProjects.Where(p => p.ProjectName == project.Name).FirstOrDefault(); if (modData != null) { //ManagedProjects.Add(new ProjectEntryData(modData.ProjectInfo, modData.ModInfo)); Data.ManagedProjects.Add(modData); var availableProject = Data.NewProjects.Where(p => p.Name == project.Name).FirstOrDefault(); if (availableProject != null) { Data.NewProjects.Remove(availableProject); } if (Data.ManagedProjectsData.SavedProjects.Items.Any(p => p.UUID == modData.UUID)) { if (modData.ProjectAppData == null) { ProjectAppData data = Data.ManagedProjectsData.SavedProjects.Items.Where(p => p.UUID == modData.ModuleInfo.UUID).FirstOrDefault(); if (data != null) { modData.ProjectAppData = data; Log.Here().Activity($"Linked project {modData.ProjectName} data to managed project data."); } } } else { ProjectAppData data = new ProjectAppData() { Name = modData.ProjectName, UUID = modData.ModuleInfo.UUID, LastBackupUTC = null }; Data.ManagedProjectsData.SavedProjects.AddOrUpdate(data); modData.ProjectAppData = data; Log.Here().Activity($"Added project {modData.DisplayName} to managed projects."); bSaveData = true; } } else { #if DEBUG Data.ManagedProjects.Add(ModProjectData.Test(project.Name)); #else MainWindow.FooterError($"Error adding project {project.Name} to managed projects: Mod data doesn't exist."); #endif } } Data.RaisePropertyChanged("NewProjects"); if (bSaveData) { if (DOS2Commands.SaveManagedProjects(Data)) { MainWindow.FooterLog("Saved Managed Projects data to {0}.", Data.Settings.AddedProjectsFile); } else { MainWindow.FooterError("Error saving Managed Projects data to {0}.", Data.Settings.AddedProjectsFile); } } }