public override void SetPropertyValue(System.Reflection.PropertyInfo property, string value, bool isParse) { if (property.PropertyType == typeof(DefaultEmoticonGroupCollection)) { DefaultEmoticonGroupCollection groups = new DefaultEmoticonGroupCollection(); groups.SetValue(value); this.UniteEmotGroup(groups, true); } }
public DefaultEmotSettings() { FaceDirectory = Globals.GetPath(SystemDirecotry.Assets_Face); if (!Directory.Exists(FaceDirectory)) { Directory.CreateDirectory(FaceDirectory); } m_groups = new DefaultEmoticonGroupCollection(); init(); }
private void init(string excludePath) { DefaultEmoticonGroupCollection tempGroups = new DefaultEmoticonGroupCollection(); DirectoryInfo faceRoot = new DirectoryInfo(FaceDirectory); tempGroups.Add(new DefaultEmoticonGroup(string.Empty)); foreach (DirectoryInfo dir in faceRoot.GetDirectories()) { if (!string.IsNullOrEmpty(excludePath) && dir.Name.Equals(excludePath, StringComparison.OrdinalIgnoreCase)) { continue; } tempGroups.Add(new DefaultEmoticonGroup(dir.Name)); } foreach (DefaultEmoticonGroup group in m_groups) { if (group.IsWatching) { group.EndWach(); } } UniteEmotGroup(tempGroups, false); //sortedGroups = null; if (isInited == false) { for (int i = 0; i < m_groups.Count; i++) { m_groups[i].SortOrder = (i + 1) * 10; } } //开始文件监控 foreach (DefaultEmoticonGroup group in m_groups) { if (!group.IsWatching) { group.BeginWach(); } } BeginWach(); isInited = true; }
/// <summary> /// 合并表情分组 /// </summary> /// <param name="groups">新分组</param> /// <param name="useOriginal">以原有分组为准 (如果是文件变动引起的合并, 必须以新的为准)</param> private void UniteEmotGroup(DefaultEmoticonGroupCollection groups, bool useOriginal) { if (groups != null) { List <int> notExistGroups = new List <int>(); bool isExist = false;; int i = 0; //数据库里的和实际文件夹下的表情合并 foreach (DefaultEmoticonGroup tempGroup in groups) { isExist = false; foreach (DefaultEmoticonGroup eg in this.m_groups) { if (eg.DirectoryName == tempGroup.DirectoryName) { if (useOriginal) { eg.GroupName = tempGroup.GroupName; eg.SortOrder = tempGroup.SortOrder; eg.Disabled = tempGroup.Disabled; eg.UniteEmotincos(tempGroup.Emoticons); } else { tempGroup.Disabled = eg.Disabled; tempGroup.GroupName = eg.GroupName; tempGroup.SortOrder = eg.SortOrder; tempGroup.UniteEmotincos(eg.Emoticons); } isExist = true; break; } if (!useOriginal) { eg.Dispose(); } } if (useOriginal) { tempGroup.Dispose(); } if (!isExist) { notExistGroups.Add(i); } i++; } if (!useOriginal) { DefaultEmoticonGroupCollection tempEmotGroup = new DefaultEmoticonGroupCollection(); foreach (DefaultEmoticonGroup egroup in groups) { tempEmotGroup.Add(egroup); } m_groups = tempEmotGroup; } else { } } }