Ejemplo n.º 1
0
 private void Mainwindow_CanClearRamEvents(bool canclear)
 {
     if (canclear == true)
     {
         ClearRam.ClearMemory();
         canclear = false;
     }
 }
Ejemplo n.º 2
0
        string collectFile;                              //将打开的文件夹付给全局变量,如果用户点击保存收藏夹那么此变量作为路径
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.ShowDialog();//获得了指定的文件夹
            if (fbd.SelectedPath == "")
            {
                return;
            }
            collectFile = fbd.SelectedPath;
            PictureFind picturefind = new PictureFind(fbd.SelectedPath); //将路径传给picturefind类中进行解析

            picturefind.IsJpg();                                         //解析并存储jpg的文件
            picturefind.IsPNG();                                         //解析并存储png的文件
            pictureList.Clear();
            //   getPic = picturefind.CanOpenPicArr;//将解析到的JPG付给数组
            //将jpg格式付给list

            for (int i = 0; i < picturefind.CanOpenPicArr.Length; i++)
            {
                pictureList.Add(picturefind.CanOpenPicArr[i]);
            }
            //将png格式付给list
            for (int i = 0; i < picturefind.PngFile.Length; i++)
            {
                pictureList.Add(picturefind.PngFile[i]);
            }

            int  soloWidth = this.lvSolo.Size.Width;//LISTVIEW的宽度
            Size size      = new Size(soloWidth, soloWidth);

            //  this.imageList.ImageSize = size;//缩略图的宽度定义为listview的宽度
            this.lvSolo.Items.Clear();
            this.imageList.Images.Clear();
            //   MessageBox.Show(Math.Ceiling(Convert.ToDouble(this.lvSolo.Width / (this.imageList.ImageSize.Width * 2 + 30))).ToString());
            for (int i = 0; i < pictureList.Count; i++)
            {
                this.imageList.Images.Add(Image.FromFile(pictureList[i]));
                string getSoloName = Path.GetFileNameWithoutExtension(pictureList[i]);    //获取纯文件不包含后缀
                this.lvSolo.Items.Add(Path.GetFileName(getSoloName), i);
            }
            ClearRam.ClearMemory();
        }
Ejemplo n.º 3
0
        //private void tscbListCollect_SelectedIndexChanged(object sender, EventArgs e)
        //{



        //    this.lvSolo.Items.Clear();
        //    pictureList = null;
        //    this.imageList.Images.Clear();
        //    PictureFind pf = new PictureFind(this.cbCollector.SelectedItem.ToString());
        //    pf.IsJpg();
        //    getPic = pf.CanOpenPicArr;
        //    for (int i = 0; i < getPic.Length; i++)
        //    {
        //        this.imageList.Images.Add(Image.FromFile(getPic[i]));

        //        string getSoloName = Path.GetFileNameWithoutExtension(getPic[i]);//获取纯文件不包含后缀
        //        this.lvSolo.Items.Add(Path.GetFileName(getSoloName), i);
        //    }

        //}

        private void cbCollector_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.lvSolo.Items.Clear();
            pictureList.Clear();
            this.imageList.Images.Clear();
            PictureFind pf = new PictureFind(this.cbCollector.SelectedItem.ToString());

            //if (!pf.IsJpg()&&!pf.IsPNG())
            //{
            //    return;
            //}
            pf.IsJpg();
            pf.IsPNG();
            //将jpg导入list

            for (int i = 0; i < pf.CanOpenPicArr.Length; i++)
            {
                this.pictureList.Add(pf.CanOpenPicArr[i]);
            }

            //将png导入list

            for (int i = 0; i < pf.PngFile.Length; i++)
            {
                this.pictureList.Add(pf.PngFile[i]);
            }

            for (int i = 0; i < pictureList.Count; i++)
            {
                this.imageList.Images.Add(Image.FromFile(pictureList[i]));

                string getSoloName = Path.GetFileNameWithoutExtension(pictureList[i]);//获取纯文件不包含后缀
                this.lvSolo.Items.Add(Path.GetFileName(getSoloName), i);
            }

            ClearRam.ClearMemory();
        }
Ejemplo n.º 4
0
        private void btnRamBar_Click(object sender, EventArgs e)
        {
            //优化内存

            ClearRam.ClearMemory();
        }