public ModCategory(IModCategory p_imcCategory) { Id = p_imcCategory.Id; CategoryName = p_imcCategory.CategoryName; CategoryPath = p_imcCategory.CategoryPath; NewMods = p_imcCategory.NewMods; }
/// <summary> /// Gets the mod count for the current category. /// </summary> /// <param name="p_imcCategory">The category to count.</param> public Int32 GetCategoryModCount(IModCategory p_imcCategory) { var CategoryMods = from Mod in m_rolManagedMods where (Mod != null) && ((Mod.CustomCategoryId >= 0 ? Mod.CustomCategoryId : Mod.CategoryId) == p_imcCategory.Id) select Mod; return(CategoryMods.Count()); }
/// <summary> /// Gets the mod count for the current category. /// </summary> /// <param name="p_imcCategory">The category to count.</param> /// <param name="p_modItems">The Mod List containing the categories.</param> public Int32 GetCategoryModCount(IModCategory p_imcCategory, IEnumerable <IMod> p_modItems) { var CategoryMods = from Mod in p_modItems where (Mod != null) && ((Mod.CustomCategoryId >= 0 ? Mod.CustomCategoryId : Mod.CategoryId) == p_imcCategory.Id) select Mod; return(CategoryMods.Count()); }
public void RenameCategory(int p_intCategoryId, string p_strNewName) { IModCategory imcCategory = m_tslCategories.Find(Item => Item.Id == p_intCategoryId); imcCategory.CategoryName = p_strNewName; imcCategory.CategoryPath = Path.Combine(ModInstallDirectory, p_strNewName); UpdateCategoryFile(); }
/// <summary> /// Setup the Drag&Drop /// </summary> public void SetupDragAndDrop() { this.IsSimpleDragSource = true; this.IsSimpleDropSink = true; this.CanDrop += delegate(object sender, BrightIdeasSoftware.OlvDropEventArgs e) { e.Effect = DragDropEffects.Move; }; this.Dropped += delegate(object sender, BrightIdeasSoftware.OlvDropEventArgs e) { string[] strFiles = e.DragEventArgs.Data.GetData(DataFormats.FileDrop) != null ? (string[])e.DragEventArgs.Data.GetData(DataFormats.FileDrop) : null; if (strFiles != null) { foreach (string strFilePath in strFiles) { this.FileDropped(strFilePath, new EventArgs()); } } else if (e.DropTargetItem != null) { if (e.DropTargetItem.RowObject != null) { IModCategory imcCategory = null; if (e.DropTargetItem.RowObject.GetType() == typeof(ModCategory)) { imcCategory = (IModCategory)e.DropTargetItem.RowObject; } else { try { IMod modMod = (IMod)e.DropTargetItem.RowObject; imcCategory = CategoryManager.FindCategory(modMod.CustomCategoryId >= 0 ? modMod.CustomCategoryId : modMod.CategoryId); } catch { } } if ((imcCategory != null) && (this.CategorySwitch != null)) { this.CategorySwitch(imcCategory, new EventArgs()); } } } }; }
/// <summary> /// Adds a new category to the TreeListView. /// </summary> /// <param name="p_imcCategory">The category to add to the roots list.</param> /// <param name="booIsNew">Whether the category is new or was just hidden.</param> public void AddData(IModCategory p_imcCategory, bool booIsNew) { ModCategory Category = new ModCategory(p_imcCategory); if (CategoryModeEnabled) { this.AddObject(Category); ApplyFilters(Category); if (this.Items.Count > 0) { this.EnsureVisible(this.Items.Count - 1); } } }
/// <summary> /// The method that is called to start the backgound task. /// </summary> /// <param name="p_objArgs">Arguments to for the task execution.</param> /// <returns>Always <c>null</c>.</returns> protected override object DoWork(object[] p_objArgs) { List <string> ModList = new List <string>(); List <IMod> ModCheck = new List <IMod>(); ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0]; string ModInstallDirectory = CurrentGameModeModDirectory.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).Trim(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; OverallMessage = "Updating categories info: setup search.."; OverallProgress = 0; OverallProgressStepSize = 1; ShowItemProgress = false; OverallProgressMaximum = 2; OverallMessage = "Retrieving the categories list... 1/2"; StepOverallProgress(); try { List <CategoriesInfo> lstCategories = ModRepository.GetCategories(ModRepository.RemoteGameId); int i = 1; if (lstCategories.Count > 0) { foreach (CategoriesInfo category in lstCategories) { OverallMessage = "Saving the categories list... " + i + "/" + lstCategories.Count(); StepOverallProgress(); IModCategory modCategory = CategoryManager.FindCategory(category.Id); if ((modCategory != null) && (modCategory.Id != 0)) { CategoryManager.RenameCategory(modCategory.Id, category.Name); } else { CategoryManager.AddCategory(new ModCategory(category.Id, category.Name, category.Name)); } } } } catch (Exception ex) { return(ex.Message); } return(null); }
/// <summary> /// Removes the selected category. /// </summary> /// <param name="p_imcCategory">The category to remove.</param> public void RemoveCategory(IModCategory p_imcCategory) { if ((p_imcCategory != null) && (p_imcCategory.Id != 0)) { CategoryManager.RemoveCategory(p_imcCategory); foreach (ToolStripDropDownItem Item in (cmsContextMenu.Items[0] as ToolStripMenuItem).DropDownItems) { if (Item.Text == p_imcCategory.CategoryName) { (cmsContextMenu.Items[0] as ToolStripMenuItem).DropDownItems.Remove(Item); break; } } if (this.CategoryRemoved != null) { this.CategoryRemoved(p_imcCategory, new EventArgs()); } } }
/// <summary> /// Sets all mods assigned to a removed category to Unassigned. /// </summary> /// <param name="p_imcCategory">The removed category.</param> public void SwitchModsToUnassigned(IModCategory p_imcCategory) { var CategoryMods = ManagedMods.Where(Mod => (Mod.CustomCategoryId >= 0 ? Mod.CustomCategoryId : Mod.CategoryId) == p_imcCategory.Id).ToList(); UpdatingCategory(this, new EventArgs<IBackgroundTask>(CategoryManager.Update(ModManager, CategoryMods, 0, ConfirmUpdaterAction))); }
/// <summary> /// Removes a category from the list. /// </summary> /// <param name="p_mctCategory">The <see cref="IModCategory"/> to be removed.</param> public void RemoveCategory(IModCategory p_mctCategory) { m_tslCategories.Remove(p_mctCategory); SaveCategories(); }
/// <summary> /// Adds a category to the list. /// </summary> /// <param name="p_mctCategory">The <see cref="IModCategory"/> being added.</param> public IModCategory AddCategory(IModCategory p_mctCategory) { m_tslCategories.Add(p_mctCategory); SaveCategories(); return p_mctCategory; }
/// <summary> /// Gets the mod count for the current category. /// </summary> /// <param name="p_imcCategory">The category to count.</param> /// <param name="p_modItems">The Mod List containing the categories.</param> public Int32 GetCategoryModCount(IModCategory p_imcCategory, IEnumerable<IMod> p_modItems) { var CategoryMods = from Mod in p_modItems where (Mod != null) && ((Mod.CustomCategoryId >= 0 ? Mod.CustomCategoryId : Mod.CategoryId) == p_imcCategory.Id) select Mod; return CategoryMods.Count(); }
/// <summary> /// Removes the selected category. /// </summary> /// <param name="p_imcCategory">The category to remove.</param> public void RemoveCategory(IModCategory p_imcCategory) { if ((p_imcCategory != null) && (p_imcCategory.Id != 0)) { CategoryManager.RemoveCategory(p_imcCategory); foreach (ToolStripDropDownItem Item in (cmsContextMenu.Items[0] as ToolStripMenuItem).DropDownItems) if (Item.Text == p_imcCategory.CategoryName) { (cmsContextMenu.Items[0] as ToolStripMenuItem).DropDownItems.Remove(Item); break; } if (this.CategoryRemoved != null) this.CategoryRemoved(p_imcCategory, new EventArgs()); } }
/// <summary> /// Gets the mod count for the current category. /// </summary> /// <param name="p_imcCategory">The category to count.</param> public Int32 GetCategoryModCount(IModCategory p_imcCategory) { var CategoryMods = from Mod in m_rolManagedMods where (Mod != null) && ((Mod.CustomCategoryId >= 0 ? Mod.CustomCategoryId : Mod.CategoryId) == p_imcCategory.Id) select Mod; return CategoryMods.Count(); }
/// <summary> /// Finds the category by Id. /// </summary> /// <param name="p_intCategoryId">The category Id.</param> public IModCategory FindCategory(Int32 p_intCategoryId) { IModCategory imcCategory = m_tslCategories.Find(Item => Item.Id == p_intCategoryId); return(imcCategory == null ? (IModCategory) new ModCategory() : imcCategory); }
/// <summary> /// Adds a category to the list. /// </summary> /// <param name="p_mctCategory">The <see cref="IModCategory"/> being added.</param> public IModCategory AddCategory(IModCategory p_mctCategory) { m_tslCategories.Add(p_mctCategory); SaveCategories(); return(p_mctCategory); }
/// <summary> /// Sets all mods assigned to a removed category to Unassigned. /// </summary> /// <param name="p_imcCategory">The removed category.</param> public void SwitchModsToUnassigned(IModCategory p_imcCategory) { var CategoryMods = ManagedMods.Where(Mod => (Mod.CustomCategoryId >= 0 ? Mod.CustomCategoryId : Mod.CategoryId) == p_imcCategory.Id).ToList(); UpdatingCategory(this, new EventArgs <IBackgroundTask>(CategoryManager.Update(ModManager, CategoryMods, 0, ConfirmUpdaterAction))); }
/// <summary> /// Adds a new category to the TreeListView. /// </summary> /// <param name="p_imcCategory">The category to add to the roots list.</param> /// <param name="booIsNew">Whether the category is new or was just hidden.</param> public void AddData(IModCategory p_imcCategory, bool booIsNew) { ModCategory Category = new ModCategory(p_imcCategory); if (CategoryModeEnabled) { this.AddObject(Category); ApplyFilters(Category); if (this.Items.Count > 0) this.EnsureVisible(this.Items.Count - 1); } }