Example #1
0
        /// <summary>
        /// 合并原有的表情(数据库有记录的) 和 现在目录底下的实际文件
        /// </summary>
        /// <param name="emoticons"></param>
        public void UniteEmotincos(DefaultEmoticonCollection emoticons)
        {
            DefaultEmoticonCollection diremoticons = new DefaultEmoticonCollection(this);

            List <DefaultEmoticon> Emoticons = new List <DefaultEmoticon>();

            foreach (FileInfo file in IOUtil.GetImagFiles(this.FilePath, SearchOption.TopDirectoryOnly))
            {
                if (file.Name.Equals(PreviewFileName, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                DefaultEmoticon face = new DefaultEmoticon(this);
                face.FileName = file.Name;
                face.FileSize = file.Length;
                diremoticons.Add(face);
            }

            foreach (DefaultEmoticon em in emoticons)
            {
                if (diremoticons.ContainsKey(em.EmoticonID))
                {
                    DefaultEmoticon temp = diremoticons.GetValue(em.EmoticonID);
                    temp.Shortcut  = em.Shortcut;
                    temp.SortOrder = em.SortOrder;
                }
            }
            m_Emoticons = diremoticons;
            Reorder();
        }
Example #2
0
        private void init()
        {
            bool isFirst = false;

            //判断是首次初始化还是文件变动引起的初始化
            if (m_Emoticons == null)
            {
                isFirst     = true;
                m_Emoticons = new DefaultEmoticonCollection(this);
            }

            UniteEmotincos(m_Emoticons);
            m_sortedemoticons = null;
            if (isFirst)
            {
                if (!File.Exists(PreviewFilePath))
                {
                    BuildPriviewPicture();
                }
            }
            else
            {
                BuildPriviewPicture();
            }

            BeginWach();
        }
Example #3
0
        public void SetValue(string value)
        {
            StringList list = StringList.Parse(value);

            if (list != null)
            {
                this.SortOrder     = int.Parse(list[0]);
                this.GroupName     = list[1];
                this.DirectoryName = list[2];
                this.Disabled      = bool.Parse(list[3]);
                DefaultEmoticonCollection emots = new DefaultEmoticonCollection(this);
                emots.SetValue(list[4]);
                if (Directory.Exists(this.FilePath))
                {
                    UniteEmotincos(emots);
                }

                Reorder();
            }
        }
Example #4
0
        /// <summary>
        /// 重新生成缩略图
        /// </summary>
        /// <param name="icons"></param>
        public void BuildPriviewPicture()
        {
            if (IsWatching)
            {
                EndWach();
            }

            DefaultEmoticonCollection icons = this.Emoticons;

            if (TotalEmoticons == 0)
            {
                if (File.Exists(this.PreviewFilePath))
                {
                    IOUtil.DeleteFile(PreviewFilePath);
                }
                return;
            }

            Bitmap   bmp = new Bitmap(GridSize.Width * TotalEmoticons, GridSize.Height);
            Graphics g   = Graphics.FromImage(bmp);

            g.Clear(Color.White);

            try
            {
                for (int i = 0; i < this.TotalEmoticons; i++)
                {
                    Image temp = null;
                    try
                    {
                        temp = new Bitmap(icons[i].FilePath);
                    }
                    catch
                    {
                        continue;
                    }
                    g.DrawImage(temp, new Rectangle(i * GridSize.Width, 0
                                                    , GridSize.Width, GridSize.Height));
                    temp.Dispose();
                }
                bmp.Save(IOUtil.JoinPath(this.FilePath, PreviewFileName), ImageFormat.Png);
            }
            catch
            {
            }

            g.Dispose();
            bmp.Dispose();
            BeginWach();

            //正方形输出
            //if(Count==0)
            //    return ;
            //int borderWidth = 2;


            //int gridX,gridY,previewImageHeight,previewImageWidth;

            //if(Count<4)
            //{
            //    gridX=4;
            //    gridY=1;
            //}
            //else
            //{
            //    gridX =(int)Math.Sqrt((double)Count);
            //    if(Count %  gridX!=0)
            //        gridX++;
            //    gridY =Count / gridX;
            //}

            //previewImageHeight = (gridSize.Height + borderWidth) * gridY + borderWidth;
            //previewImageWidth = (gridSize.Width + borderWidth) * gridX + borderWidth;

            //Bitmap bmp = new Bitmap(previewImageWidth, previewImageHeight);
            //Graphics g = Graphics.FromImage(bmp);
            //g.Clear(Color.White);

            //int imgIndex=0;
            //for (int i = 0; i < gridX; i++)
            //{
            //    for (int j = 0; j < gridY;j++ )
            //    {
            //        imgIndex=i*gridX + j;
            //        if(imgIndex >this.Count-1)
            //        {
            //            //TODO 跳出循环
            //            break;
            //        }
            //Image temp;
            //try
            //{
            //    temp=new Bitmap( icons[imgIndex].FilePath);
            //}
            //catch
            //{
            //    continue;
            //}
            //
            //        g.DrawImage(temp, new Rectangle(i * gridSize.Width + borderWidth, j * gridSize.Height + borderWidth
            //            , gridSize.Width, gridSize.Height));
            //        temp.Dispose();
            //    }
            //    if (imgIndex > this.Count - 1)
            //    {
            //        bmp.Save(IOUtil.JoinPath(this.FilePath, PreviewFileName), ImageFormat.Png);
            //        g.Dispose();
            //        bmp.Dispose();
            //        break;
            //    }
            //}
        }
Example #5
0
 /// <summary>
 /// 序号发生改变时重新排序
 /// </summary>
 public void Reorder()
 {
     this.m_sortedemoticons = null;
     BuildPriviewPicture();
 }