2using System.Collections.Generic;
3using System.ComponentModel;
6using System.Drawing.Imaging;
9using System.Threading.Tasks;
10using System.Windows.Forms;
15using Bitmap = System.Drawing.Bitmap;
17using Rectangle = System.Drawing.Rectangle;
20 public partial class OMERO : Form
22 public List<omero.gateway.model.DatasetData>
datas =
new List<omero.gateway.model.DatasetData>();
23 private List<ListViewItem> items =
new List<ListViewItem>();
25 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
28 get {
return progressBar.Value; }
32 progressBar.Value = value;
36 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
39 get {
return statusLabel.Text; }
40 set { statusLabel.Text = value; }
44 InitializeComponent();
46 if (log.ShowDialog() == DialogResult.OK)
54 BioLib.OMERO.ReConnect();
55 var dst = BioLib.OMERO.GetDatasetsData();
57 foreach (var src
in dst)
61 comboBox1.Items.Add(src.getName() +
" " + src.getId());
65 private void comboBox1_SelectedIndexChanged(
object sender, EventArgs e)
67 listView1.Items.Clear();
69 string[] sts = comboBox1.SelectedItem.ToString().Split(
" ");
70 List<ListViewItem> lss =
new List<ListViewItem>();
71 foreach (omero.gateway.model.DatasetData s in
datas)
73 if (s.getId().ToString() == sts[1].ToString())
75 Status =
"Getting dataset information.";
76 List<string> fs =
new List<string>();
77 List<long> ids = BioLib.OMERO.GetDatasetIds(s.getId());
78 foreach (
long id in ids)
80 fs.Add(BioLib.OMERO.GetNameFromID(
id));
82 if (loadIconsBox.Checked)
84 Status =
"Loading icons...";
86 ImageList ims =
new ImageList
88 ImageSize =
new System.Drawing.Size(64, 64),
89 ColorDepth = ColorDepth.Depth32Bit
91 Dictionary<long, Pixbuf> dict = BioLib.OMERO.GetThumbnails(fs.ToArray(), 64, 64);
93 Status =
"Loading files...";
94 foreach (var item
in ids)
96 foreach (var itm
in dict)
102 ListViewItem li =
new ListViewItem();
106 Progress = (int)(((
float)(i + 1) / (
float)(ids.Count)) * 100);
111 listView1.SmallImageList = ims;
112 listView1.LargeImageList = ims;
113 listView1.View = View.LargeIcon;
114 listView1.Items.AddRange(items.ToArray());
121 Status =
"Loading files...";
123 foreach (var item
in ids)
125 ListViewItem li =
new ListViewItem();
128 Progress = (int)(((
float)(i + 1) / (
float)(ids.Count)) * 100);
131 listView1.View = View.List;
132 listView1.Items.AddRange(items.ToArray());
143 throw new ArgumentNullException(nameof(pixbuf),
"Pixbuf cannot be null.");
146 int width = pixbuf.Width;
147 int height = pixbuf.Height;
148 int rowstride = pixbuf.Rowstride;
149 bool hasAlpha = pixbuf.HasAlpha;
150 byte[] pixelData = pixbuf.PixelBytes.Data;
157 BitmapData bmpData = bitmap.LockBits(
159 ImageLockMode.WriteOnly,
163 IntPtr bmpPtr = bmpData.Scan0;
166 byte* srcPtr = (
byte*)pixbuf.Pixels;
167 byte* destPtr = (
byte*)bmpPtr;
169 for (
int y = 0; y < height; y++)
171 byte* srcRow = srcPtr + y * rowstride;
172 byte* destRow = destPtr + y * bmpData.Stride;
176 for (
int x = 0; x < width; x++)
178 destRow[x * 4 + 0] = srcRow[x * 4 + 2];
179 destRow[x * 4 + 1] = srcRow[x * 4 + 1];
180 destRow[x * 4 + 2] = srcRow[x * 4 + 0];
181 destRow[x * 4 + 3] = srcRow[x * 4 + 3];
186 for (
int x = 0; x < width; x++)
188 destRow[x * 3 + 0] = srcRow[x * 3 + 2];
189 destRow[x * 3 + 1] = srcRow[x * 3 + 1];
190 destRow[x * 3 + 2] = srcRow[x * 3 + 0];
197 bitmap.UnlockBits(bmpData);
201 private void listView1_SelectedIndexChanged(
object sender, EventArgs e)
203 if (listView1.SelectedIndices.Count <= 0)
205 string[] f = listView1.SelectedItems[0].Text.Split(
' ');
210 private void searchBox_TextChanged(
object sender, EventArgs e)
212 listView1.Items.Clear();
213 List<ListViewItem> list =
new List<ListViewItem>();
214 foreach (ListViewItem item
in items)
216 if(item.Text.Contains(searchBox.Text))
219 listView1.Items.AddRange(list.ToArray());
AForge.Rectangle Rectangle
System.Drawing.Graphics Graphics
AForge.PixelFormat PixelFormat
List< omero.gateway.model.DatasetData > datas
static Bitmap PixbufToBitmap(Pixbuf pixbuf)