/// <summary>
        /// Setup the CategoryView
        /// </summary>
        /// <param name="p_lvwList">The source list view.</param>
        /// <param name="p_cmgCategoryManager">The mod Category Manager.</param>
        public void Setup(ReadOnlyObservableList <IMod> p_rolManagedMods, ReadOnlyObservableList <IMod> p_rolActiveMods, IModRepository p_mmrModRepository, CategoryManager p_cmgCategoryManager, ISettings p_Settings)
        {
            this.Tag = false;

            this.CellEditActivation = CellEditActivateMode.None;
            this.MultiSelect        = true;
            this.AllowDrop          = true;
            this.UseFiltering       = true;

            CategoryManager    = p_cmgCategoryManager;
            m_mmrModRepository = p_mmrModRepository;
            m_rolManagedMods   = p_rolManagedMods;
            m_rolActiveMods    = p_rolActiveMods;
            Settings           = p_Settings;

            // Setup menuStrip commands
            SetupContextMenu();

            // Setup category validator
            SetupCategoryValidator();

            // Setup category sorter
            SetupCategorySorter();

            this.CheckBoxes              = false;
            this.UseSubItemCheckBoxes    = false;
            this.BooleanCheckStateGetter = delegate(object x)
            {
                if (x.GetType() != typeof(ModCategory))
                {
                    if (m_rolActiveMods.Contains((IMod)x))
                    {
                        return(true);
                    }
                }

                return(false);
            };

            // Setup AspectGetter (IconListView cell parser)
            SetupColumnParser();

            // Setup the Drag&Drop functionality
            SetupDragAndDrop();

            // Setup hyperlink manager
            SetupHyperlinkManager();

            // Setup ImageGetters
            SetupImageGetters();

            // Set control initialized
            this.Tag = true;
        }
Beispiel #2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            ReadOnlyObservableList <QueueListItem> crawlingQueuelistItem = (ReadOnlyObservableList <QueueListItem>)values[0];
            QueueListItem currentQueuelistItem = (QueueListItem)values[1];

            if (crawlingQueuelistItem.Contains(currentQueuelistItem))
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Merges the chargenmorphcfg.xml file of the Dragon Age mods.
        /// </summary>
        /// <param name="p_rolActiveMods">The list of active mods.</param>
        /// <param name="p_modMod">The current mod.</param>
        /// <param name="p_booRemove">Whether we're adding or removing the mod.</param>
        public override void ModFileMerge(ReadOnlyObservableList <IMod> p_rolActiveMods, IMod p_modMod, bool p_booRemove)
        {
            List <string> lstFiles  = null;
            XDocument     XDoc      = null;
            XDocument     XDocMerge = null;
            bool          booMerge  = false;

            Byte[] bFile = null;
            strXMLDirectory = Path.Combine(m_gmdGameModeInfo.InstallationPath, "NMM_chargenmorphcfg");

            #region activeMods

            if (p_booRemove && File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")))
            {
                File.Delete(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
            }


            if ((!File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"))) || (p_booRemove))
            {
                foreach (IMod modMod in p_rolActiveMods)
                {
                    if (modMod.Filename != p_modMod.Filename)
                    {
                        lstFiles = modMod.GetFileList();

                        foreach (string strFile in lstFiles)
                        {
                            if (strFile.EndsWith("chargenmorphcfg.xml"))
                            {
                                bFile = modMod.GetFile(strFile);
                                string responseText = Encoding.ASCII.GetString(bFile);

                                XDoc = XDocument.Parse(responseText.Replace("???", ""));
                                if (XDocMerge == null)
                                {
                                    XDocMerge = XDoc;
                                    booMerge  = true;
                                }
                                else
                                {
                                    foreach (XElement ele in XDoc.Root.Elements())
                                    {
                                        XElement xeDoc      = XDoc.Root.Element(ele.Name.ToString());
                                        XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString());
                                        MergeElements(xeDoc, xeDocMerge);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                bFile = File.ReadAllBytes(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
                string responseText = Encoding.ASCII.GetString(bFile);

                XDoc     = XDocument.Parse(responseText.Replace("???", ""));
                booMerge = true;
            }

            #endregion

            #region currentMod
            if ((p_modMod != null) && (!p_rolActiveMods.Contains(p_modMod)))
            {
                lstFiles = p_modMod.GetFileList();
                foreach (string strFile in lstFiles)
                {
                    if (strFile.EndsWith("chargenmorphcfg.xml"))
                    {
                        bFile = p_modMod.GetFile(strFile);
                        string responseText = Encoding.ASCII.GetString(bFile);

                        XDocMerge = XDocument.Parse(responseText.Replace("???", ""));

                        if (booMerge)
                        {
                            foreach (XElement ele in XDoc.Root.Elements())
                            {
                                XElement xeDoc      = XDoc.Root.Element(ele.Name.ToString());
                                XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString());
                                MergeElements(xeDoc, xeDocMerge);
                            }
                        }
                    }
                }
            }
            #endregion

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

            if (XDoc != null)
            {
                XDoc.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
            }
            else if (XDocMerge != null)
            {
                XDocMerge.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
            }
        }
        /// <summary>
        /// Merges the chargenmorphcfg.xml file of the Dragon Age mods.
        /// </summary>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		/// <param name="p_modMod">The current mod.</param>
		/// <param name="p_booRemove">Whether we're adding or removing the mod.</param>
		public override void ModFileMerge(ReadOnlyObservableList<IMod> p_rolActiveMods, IMod p_modMod, bool p_booRemove)
        {
            
            List<string> lstFiles = null;
            XDocument XDoc = null;
            XDocument XDocMerge = null;
            bool booMerge = false;            
            Byte[] bFile = null;
            strXMLDirectory = Path.Combine(m_gmdGameModeInfo.InstallationPath, "NMM_chargenmorphcfg");

            #region activeMods

			if (p_booRemove && File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")))
				File.Delete(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));


			if ((!File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"))) || (p_booRemove))
            {
				foreach (IMod modMod in p_rolActiveMods)
                {
					if (modMod.Filename != p_modMod.Filename)
                    {
                        lstFiles = modMod.GetFileList();

                        foreach (string strFile in lstFiles)
                        {
                            if (strFile.EndsWith("chargenmorphcfg.xml"))
                            {
                                bFile = modMod.GetFile(strFile);
                                string responseText = Encoding.ASCII.GetString(bFile);

                                XDoc = XDocument.Parse(responseText.Replace("???", ""));
                                if (XDocMerge == null)
                                {
                                    XDocMerge = XDoc;
                                    booMerge = true;
                                }
                                else
                                {
                                    foreach (XElement ele in XDoc.Root.Elements())
                                    {
                                        XElement xeDoc = XDoc.Root.Element(ele.Name.ToString());
                                        XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString());
                                        MergeElements(xeDoc, xeDocMerge);
                                    }

                                }
                            }
                        }
                    }
                }
            }
            else
            {

                bFile = File.ReadAllBytes(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
                string responseText = Encoding.ASCII.GetString(bFile);

                XDoc = XDocument.Parse(responseText.Replace("???", ""));
                booMerge = true;
            }

            #endregion

            #region currentMod
			if ((p_modMod != null) && (!p_rolActiveMods.Contains(p_modMod)))
            {
				lstFiles = p_modMod.GetFileList();
                foreach (string strFile in lstFiles)
                {
                    if (strFile.EndsWith("chargenmorphcfg.xml"))
                    {
						bFile = p_modMod.GetFile(strFile);
                        string responseText = Encoding.ASCII.GetString(bFile);

                        XDocMerge = XDocument.Parse(responseText.Replace("???", ""));

                        if (booMerge)
                        {
                            foreach (XElement ele in XDoc.Root.Elements())
                            {
                                XElement xeDoc = XDoc.Root.Element(ele.Name.ToString());
                                XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString());
                                MergeElements(xeDoc, xeDocMerge);
                            }
                        }
                    }
                }
            }
            #endregion

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

            if(XDoc != null)
                XDoc.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
            else if(XDocMerge != null)
                XDocMerge.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
            
        }
        /// <summary>
        /// Setup the Image Getters
        /// </summary>
        public void SetupImageGetters()
        {
            tlcWebVersion.ImageGetter = delegate(object rowObject)
            {
                if (rowObject.GetType() != typeof(ModCategory))
                {
                    IMod modMod = (IMod)rowObject;
                    if (modMod != null)
                    {
                        if (modMod.UpdateWarningEnabled && (!modMod.IsMatchingVersion()))
                        {
                            return(new Bitmap(Properties.Resources.update_warning, 16, 16));
                        }
                        else if ((!modMod.IsMatchingVersion()) && (!Settings.HideModUpdateWarningIcon))
                        {
                            return(new Bitmap(Properties.Resources.update_warning_disabled, 16, 16));
                        }
                    }
                }
                else
                {
                    int intCategoryId = ((IModCategory)rowObject).Id;

                    if (GetOutdatedModList(intCategoryId).Count > 0)
                    {
                        return(new Bitmap(Properties.Resources.update_warning, 16, 16));
                    }
                }

                return(null);
            };

            tlcModName.ImageGetter = delegate(object rowObject)
            {
                if (rowObject.GetType() == typeof(ModCategory))
                {
                    return(new Bitmap(CreateBitmapImage(GetCategoryModCount((IModCategory)rowObject).ToString(), Properties.Resources.category_folder, 14, 2, 4, 1, 5), 13, 15));
                }
                else
                {
                    return(new Bitmap(!m_rolActiveMods.Contains((IMod)rowObject) ? Properties.Resources.dialog_cancel_4_16 : Properties.Resources.dialog_ok_4_16, 12, 12));
                }
            };

            tlcInstallDate.ImageGetter = delegate(object rowObject)
            {
                if (rowObject.GetType() == typeof(ModCategory))
                {
                    if (((ModCategory)rowObject).NewMods > 0)
                    {
                        return(new Bitmap(CreateBitmapImage(((ModCategory)rowObject).NewMods.ToString(), Properties.Resources.AddFile_48x48, 16, 4, 4, -2, -1), 16, 16));
                    }
                }
                return(null);
            };

            tlcEndorsement.ImageGetter = delegate(object rowObject)
            {
                if (rowObject.GetType() != typeof(ModCategory))
                {
                    IMod modMod = (IMod)rowObject;
                    if (modMod != null)
                    {
                        if (modMod.IsEndorsed == true)
                        {
                            return(new Bitmap(Properties.Resources.thumb_up, 16, 16));
                        }
                        else if (modMod.IsEndorsed == false)
                        {
                            return(new Bitmap(Properties.Resources.thumb_no, 16, 16));
                        }
                    }
                }
                return(null);
            };
        }
		/// <summary>
		/// Setup the CategoryView
		/// </summary>
		/// <param name="p_lvwList">The source list view.</param>
		/// <param name="p_cmgCategoryManager">The mod Category Manager.</param>
		public void Setup(ReadOnlyObservableList<IMod> p_rolManagedMods, ReadOnlyObservableList<IMod> p_rolActiveMods, IModRepository p_mmrModRepository, CategoryManager p_cmgCategoryManager, ISettings p_Settings)
		{
			this.Tag = false;

			this.CellEditActivation = CellEditActivateMode.None;
			this.MultiSelect = true;
			this.AllowDrop = true;
			this.UseFiltering = true;

			CategoryManager = p_cmgCategoryManager;
			m_mmrModRepository = p_mmrModRepository;
			m_rolManagedMods = p_rolManagedMods;
			m_rolActiveMods = p_rolActiveMods;
			Settings = p_Settings;

			// Setup menuStrip commands
			SetupContextMenu();

			// Setup category validator
			SetupCategoryValidator();

			// Setup category sorter
			SetupCategorySorter();

			this.CheckBoxes = false;
			this.UseSubItemCheckBoxes = false;
			this.BooleanCheckStateGetter = delegate(object x)
			{
				if (x.GetType() != typeof(ModCategory))
					if (m_rolActiveMods.Contains((IMod)x))
						return true;

				return false;
			};

			// Setup AspectGetter (IconListView cell parser)
			SetupColumnParser();

			// Setup the Drag&Drop functionality
			SetupDragAndDrop();

			// Setup hyperlink manager
			SetupHyperlinkManager();

			// Setup ImageGetters
			SetupImageGetters();

			// Set control initialized
			this.Tag = true;
		}