Пример #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            lvClusters.Items.Clear();
            lvClusters.Refresh();
            int    k         = Application.StartupPath.IndexOf("\\bin");
            string sub       = Application.StartupPath.Substring(k);
            string ImagePath = Application.StartupPath.Substring(0, Application.StartupPath.Length - sub.Length) + "\\AnhData";

            //DirectoryInfo directoryInfo;
            //FileInfo[] files;
            try
            {
                //directoryInfo = new DirectoryInfo(ImagePath);
                //files = directoryInfo.GetFiles("*.png", SearchOption.AllDirectories);
                //exit = false;
                Database  db = new Database();
                DataTable dt = db.RunProcedureGet("usp_ImageGetAll");
                var       processImagesDelegate = new ProcessImagesDelegate(ProcessImages);
                processImagesDelegate.BeginInvoke(dt, null, null);
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #2
0
        private void LoadImageFromDB()
        {
            int       k         = Application.StartupPath.IndexOf("\\bin");
            string    sub       = Application.StartupPath.Substring(k);
            string    ImagePath = Application.StartupPath.Substring(0, Application.StartupPath.Length - sub.Length);
            Database  db        = new Database();
            DataTable dt        = db.RunProcedureGet("usp_ImageGetAll");
            ImageList imglist   = new ImageList();

            foreach (DataRow row in dt.Rows)
            {
                Image image = Image.FromFile(ImagePath + row["Url"].ToString());
                imglist.Images.Add(image);
                lvImageDB.Items.Add(new ListViewItem(row["ImageName"].ToString()));
            }
            imglist.ImageSize        = new System.Drawing.Size(200, 200);
            lvImageDB.LargeImageList = imglist;
            for (int i = 0; i < lvImageDB.Items.Count; i++)
            {
                lvImageDB.Items[i].ImageIndex = i;
            }
            lvImageDB.Refresh();
        }
Пример #3
0
 private void LoadImageFromDB()
 {
     int k = Application.StartupPath.IndexOf("\\bin");
     string sub = Application.StartupPath.Substring(k);
     string ImagePath = Application.StartupPath.Substring(0, Application.StartupPath.Length - sub.Length);
     Database db = new Database();
     DataTable dt=db.RunProcedureGet("usp_ImageGetAll");
     ImageList imglist = new ImageList();
     foreach (DataRow row in dt.Rows)
     {
         Image image= Image.FromFile(ImagePath+row["Url"].ToString());
         imglist.Images.Add(image);
         lvImageDB.Items.Add(new ListViewItem(row["ImageName"].ToString()));
     }
     imglist.ImageSize = new System.Drawing.Size(200, 200);
     lvImageDB.LargeImageList = imglist;
     for (int i=0; i < lvImageDB.Items.Count; i++)
     {
         lvImageDB.Items[i].ImageIndex = i;
     }
     lvImageDB.Refresh();
 }
Пример #4
0
        private void btnSearch_Click(object sender, EventArgs e)
        {

            lvClusters.Items.Clear();
            lvClusters.Refresh();
            int k = Application.StartupPath.IndexOf("\\bin");
            string sub = Application.StartupPath.Substring(k);
            string ImagePath = Application.StartupPath.Substring(0, Application.StartupPath.Length - sub.Length) + "\\AnhData";
            //DirectoryInfo directoryInfo;
            //FileInfo[] files;
            try
            {
                //directoryInfo = new DirectoryInfo(ImagePath);
                //files = directoryInfo.GetFiles("*.png", SearchOption.AllDirectories);
                //exit = false;
                Database db = new Database();
                DataTable dt = db.RunProcedureGet("usp_ImageGetAll");
                var processImagesDelegate = new ProcessImagesDelegate(ProcessImages);
                processImagesDelegate.BeginInvoke(dt, null, null);
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Path not valid.", "Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }