예제 #1
0
        void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //获取分类名称
            String classText = treeView.SelectedNode.Text;

            listView.Items.Clear();
            textBox1.Clear();
            pictureBox1.Image = null;

            Dictionary <String, List <String> > vDict = _pixmapManage.getData();

            if (vDict.ContainsKey(classText))
            {
                foreach (var text in vDict[classText])
                {
                    //文件路径
                    String file = Path.Combine(SVProData.IconPath, _pixmapManage.getFilePathFromName(text));
                    if (!File.Exists(file))
                    {
                        return;
                    }

                    //读文件数据
                    SVPixmapFile pixmap = new SVPixmapFile();
                    pixmap.readPixmapFile(file);

                    imageList.Images.Add(text, pixmap.getBitmapFromData());
                    imageList1.Images.Add(text, pixmap.getBitmapFromData());

                    ListViewItem viewItem = listView.Items.Add(text);
                    viewItem.ImageKey = text;
                }
            }
        }
예제 #2
0
        //将文件转换为bmp 256色
        void convertBitmap(String fileName, String outFile)
        {
            Bitmap bitmap       = new Bitmap(fileName);
            String outName      = Path.GetFileNameWithoutExtension(fileName);
            Bitmap bitmapResult = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), PixelFormat.Format8bppIndexed);
            String outFileName  = Path.Combine(SVProData.IconPath, outFile);

            ///如果已经存在,不执行该文件的导入
            if (_pixmapManage.isItemExist(outName))
            {
                SVLog.WinLog.Warning(String.Format("图元名称{0} 已经存在, 导入失败!", outName));
                return;
            }

            MemoryStream outStream = new MemoryStream();

            bitmapResult.Save(outStream, ImageFormat.Bmp);

            //保存文件
            SVPixmapFile pixFile = new SVPixmapFile();

            pixFile.ShowName = outName;
            pixFile.Pixmap   = outStream;

            imageList.Images.Add(outName, pixFile.getBitmapFromData());
            imageList1.Images.Add(outName, pixFile.getBitmapFromData());

            pixFile.writePixmapFile(outFileName);

            if (this.listRadio.Checked)
            {
                listView.View           = View.Details;
                listView.SmallImageList = imageList;
                listView.LargeImageList = imageList1;
            }
            else
            {
                listView.View           = View.LargeIcon;
                listView.SmallImageList = imageList1;
                listView.LargeImageList = imageList1;
            }

            ListViewItem viewItem = listView.Items.Add(outName);

            viewItem.ImageKey = outName;

            _pixmapManage.insertItemByClass(treeView.SelectedNode.Text, outName, outFile);
            saveIconInfo();
        }
예제 #3
0
        public Bitmap bitmap()
        {
            Bitmap result = null;

            try
            {
                String       file       = Path.Combine(SVProData.IconPath, ImageFileName);
                SVPixmapFile pixmapFile = new SVPixmapFile();
                pixmapFile.readPixmapFile(file);
                result = pixmapFile.getBitmapFromData();
            }
            catch
            {
                return(result);
            }

            return(result);
        }