/// <summary> /// Updates all of the automaticly added GrhDatas. /// </summary> /// <param name="cm"><see cref="IContentManager"/> to use for new GrhDatas.</param> /// <param name="rootGrhDir">Root Grh texture directory.</param> /// <param name="sender">The <see cref="Control"/> that is invoking this event.</param> /// <returns> /// IEnumerable of all of the new GrhDatas created. /// </returns> public static IEnumerable<GrhData> Update(IContentManager cm, string rootGrhDir, Control sender = null) { var senderForm = GetRootForm(sender); // Clear the temporary content to make sure we have plenty of working memory cm.Unload(ContentLevel.Temporary, true); // Get the tasks var tasks = GetStationaryTasks(rootGrhDir).Concat(GetAnimatedTasks(rootGrhDir)).ToArray(); // If we have a lot of tasks, show a "busy" form GrhDataUpdaterProgressForm frm = null; if (tasks.Length > _minTaskToShowTaskForm) { frm = new GrhDataUpdaterProgressForm(tasks.Length); if (senderForm != null) frm.Show(senderForm); else frm.Show(); frm.Focus(); } var createdGrhDatas = new List<GrhData>(); if (senderForm != null) { senderForm.Enabled = false; senderForm.Visible = false; } try { // Start processing the tasks for (var i = 0; i < tasks.Length; i++) { if (frm != null) frm.UpdateStatus(i); var newGD = tasks[i].Add(cm); if (newGD != null) { createdGrhDatas.Add(newGD); if (log.IsInfoEnabled) log.InfoFormat("Created automatic GrhData `{0}` ({1} of {2} in batch).", newGD, i, tasks.Length); } } } finally { // Dispose of the form, if needed if (frm != null) frm.Dispose(); if (senderForm != null) { senderForm.Enabled = true; senderForm.Visible = true; } } if (log.IsInfoEnabled) log.WarnFormat("Automatic GrhData creation update resulted in `{0}` new GrhData(s).", createdGrhDatas.Count); return createdGrhDatas; }
/// <summary> /// Updates all of the automaticly added GrhDatas. /// </summary> /// <param name="cm"><see cref="IContentManager"/> to use for new GrhDatas.</param> /// <param name="rootGrhDir">Root Grh texture directory.</param> /// <param name="sender">The <see cref="Control"/> that is invoking this event.</param> /// <returns> /// IEnumerable of all of the new GrhDatas created. /// </returns> public static IEnumerable <GrhData> Update(IContentManager cm, string rootGrhDir, Control sender = null) { var senderForm = GetRootForm(sender); // Clear the temporary content to make sure we have plenty of working memory cm.Unload(ContentLevel.Temporary, true); // Get the tasks var tasks = GetStationaryTasks(rootGrhDir).Concat(GetAnimatedTasks(rootGrhDir)).ToArray(); // If we have a lot of tasks, show a "busy" form GrhDataUpdaterProgressForm frm = null; if (tasks.Length > _minTaskToShowTaskForm) { frm = new GrhDataUpdaterProgressForm(tasks.Length); if (senderForm != null) { frm.Show(senderForm); } else { frm.Show(); } frm.Focus(); } var createdGrhDatas = new List <GrhData>(); if (senderForm != null) { senderForm.Enabled = false; senderForm.Visible = false; } try { // Start processing the tasks for (var i = 0; i < tasks.Length; i++) { if (frm != null) { frm.UpdateStatus(i); } var newGD = tasks[i].Add(cm); if (newGD != null) { createdGrhDatas.Add(newGD); if (log.IsInfoEnabled) { log.InfoFormat("Created automatic GrhData `{0}` ({1} of {2} in batch).", newGD, i, tasks.Length); } } } } finally { // Dispose of the form, if needed if (frm != null) { frm.Dispose(); } if (senderForm != null) { senderForm.Enabled = true; senderForm.Visible = true; } } if (log.IsInfoEnabled) { log.WarnFormat("Automatic GrhData creation update resulted in `{0}` new GrhData(s).", createdGrhDatas.Count); } return(createdGrhDatas); }