Esempio n. 1
0
        private void openPath(String path)
        {
            loadingForm l = new loadingForm();

            try
            {
                l.Show();
                Application.DoEvents();

                DirectoryInfo rootPath = new DirectoryInfo(path);
                initArray(path, rootPath);
                showTwoListBox();

                l.Close();
                l.Dispose();
            }
            catch (UnauthorizedAccessException ex) { MessageBox.Show("请以管理员身份运行"); l.Close(); }
        }
Esempio n. 2
0
        //重新获取path下的文件夹与tag信息
        private void btn_refresh_Click(object sender, EventArgs e)
        {
            if (path.Length == 0)
            {
                MessageBox.Show("未选择根目录", "提示");
                return;
            }
            try
            {
                loadingForm l = new loadingForm();
                l.Show();
                Application.DoEvents();

                DirectoryInfo rootPath = new DirectoryInfo(path);
                initArray(path, rootPath);
                showTwoListBox();

                l.Close();
                l.Dispose();
            }
            catch (Exception ex) { }
        }
Esempio n. 3
0
        //显示该页的tablelayout,maxshow为一页包含多少项
        private void showPage(int page)
        {
            #region 计算本页面显示的图片索引
            int startIndex = (page - 1) * maxshow;
            int lastIndex  = startIndex + maxshow - 1;
            if (lastIndex > imglist.Count - 1)
            {
                lastIndex = imglist.Count - 1;
            }
            int thisPageRow;
            if ((lastIndex - startIndex + 1) % 5 == 0)
            {
                thisPageRow = (lastIndex - startIndex + 1) / 5;
            }
            else
            {
                thisPageRow = ((lastIndex - startIndex) / 5) + 1;
            }
            #endregion

            loadingForm l = new loadingForm();
            l.Show();
            Application.DoEvents();

            initFilePanel(thisPageRow);//调用函数对FilePanel进行绘制

            //两个label中的信息更新-----------------------------------
            label_fileCount.Text = "共有 " + imglist.Count + " 张图片";
            label_FormTo.Text    = "从第 " + (startIndex + 1) + " 项到第 " + (lastIndex + 1) + " 项";

            //进行分页,避免一次性载入所有图像带来卡顿以及内存不足----
            int count = startIndex;
            for (int r = 0; r < thisPageRow; r++)
            {
                for (int c = 0; c < 5; c++)
                {
                    if (count == lastIndex + 1)
                    {
                        break;
                    }
                    PictureBox pBox = new PictureBox();
                    //------------------------------------------------------------
                    //制作略缩图的几个方法,有待使用
                    //ResourceImage = Image.FromFile(imglist[count].ToString());
                    //Image im = GetReducedImage(20);
                    //ResourceImage = GetReducedImage(20);
                    //pBox.Image = im;
                    //------------------------------------------------------------
                    pBox.Load(imglist[count].ToString());
                    pBox.Tag      = count;
                    pBox.Cursor   = System.Windows.Forms.Cursors.Hand;
                    pBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
                    pBox.Dock     = System.Windows.Forms.DockStyle.Fill;
                    pBox.Click   += new System.EventHandler(tab_Click);
                    tabPanel.Controls.Add(pBox, c, r);
                    count++;
                }
            }


            l.Close();
            l.Dispose();

            System.GC.Collect();
        }