Jump to content

Imagelistbox Hk.


muratboy31
 Share

Recommended Posts

benzer bir işle bende uğraşıyorum, resimleri yerel ağdan çekiyorum, 1500 civarı resim. GalleryControl kullandım, çok kasıyor.ImageListView'e backgroundworker ile yükleyince performans gayet iyi ama, ram şişmesi de olmuyor. GalleryControl 1 GB'ın üzerinde ram kullanıyor. BackGroundWorker ile bir deneyin derim.

Link to comment
Share on other sites

public Form1()

{

    InitializeComponents();

}

 

yazan yere şunu ekleyin:

 

        public Giris()
        {
            CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
        }
Link to comment
Share on other sites

bu şekilde çalışıyor ancak, çok yavaş...

Task.Factory.StartNew(() => {listBox.Items.Add(new ImageListBoxItem(nVal, "", photoList.Images.IndexOfKey(r.EmployeeID.ToString()), r.EmployeeID)); });

sistemde 776 kayıt bulunuyor !

Edited by muratboy31
Link to comment
Share on other sites

  • Editor
listBox1.BeginUpdate();

listbox a ekleme kodları

listBox1.EndUpdate();

şekline bi denermisiniz. Şuan o kaar çok dosyam olmadıgı için deneme imkanım yyok.

 

Yada 

listbox ekleme kodlari
listBox1.Update();

şeklindede deneyebilirsiniz.

Edited by pairs
Link to comment
Share on other sites

resimleri daha önce farklı formatta alıyordum ama bmp yapınca convert etmek zorunda kalmadığı için arada dağlar fark etti ;

ayrıca backgroundWorker kullanacaksanız, runtime oluşturduğunuz objeleri invoke etmeniz gerekiyor... aşağıda örneği var...

private void GetImages()
        {
          string path = @"Images";
          string[] filter = { ".bmp" };
          DirectoryInfo directoryInfo = new DirectoryInfo(path);
          FileInfo[] fileInfo = directoryInfo.GetFiles();
          ArrayList arrayList = new ArrayList();


          foreach (FileInfo fi in fileInfo)
            foreach (string s in filter)
                if (s == fi.Extension)
                    arrayList.Add(fi.FullName);

          for (int i = 0; i < arrayList.Count; i++)
          {
            Image img = Image.FromFile(arrayList[i].ToString());
            photoList.Images.Add(Path.GetFileNameWithoutExtension(arrayList[i].ToString()), img);
          }
          
        }

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
          Employees();
          try
          {
              mycon.ConnectionString = Connect;
              mycon.Open();
              mycommand.Connection = mycon;
              mycommand.CommandText = "sp_List_Offices";
              mycommand.CommandType = CommandType.StoredProcedure;
              mycommand.ExecuteNonQuery();

              using (SqlDataReader rdr = mycommand.ExecuteReader())
              {
                  while (rdr.Read())
                  {
                      int L_OfficeID = rdr.GetInt32(0);
                      string L_OfficeName = rdr.GetString(1);
                      string L_OfficeCode = rdr.GetString(2);
                      XtraTabPage tab = new XtraTabPage() { Text = L_OfficeName };

                      Invoke((MethodInvoker)delegate
                      {
                          xtraTabControl1.TabPages.Add(tab);
                      });

                      ImageListBoxControl listBox = new ImageListBoxControl() { Name = "lb_Employee_" + Convert.ToString(L_OfficeID) };
                      listBox.Dock = DockStyle.Fill;
                      listBox.ItemHeight = 40;
                      listBox.ImageList = photoList;
                      listBox.MouseClick += new MouseEventHandler(listBox_MouseClick);

                      var result = L_Employee.Where(a => a.OfficeID == L_OfficeID);
                      foreach (var r in result)
                      {                          
                          string nVal = r.Name + " " + r.Surname + "\r\n" + r.Title;
                          Invoke((MethodInvoker)delegate
                          {
                              listBox.Items.Add(new ImageListBoxItem(nVal, "", photoList.Images.IndexOfKey(r.EmployeeID.ToString()), r.EmployeeID));
                          });
                      }
                      Invoke((MethodInvoker)delegate
                      {
                          tab.Controls.Add(listBox);
                      });
                  }
                  rdr.Close();
              }
          }
          catch (Exception a)
          {
              MessageBox.Show(Convert.ToString(a));
          }
          finally
          {
              mycon.Close();
          }
        }
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...