2009-10-05 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* groups.cs: * virtualmode.cs: Updated to let the tests render pictures for the items, to ensure we are rendering with the correct bounds in both cases. svn path=/trunk/winforms/; revision=143365
This commit is contained in:
Родитель
f8454b76ef
Коммит
b11863b806
|
@ -28,6 +28,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
public class Test
|
public class Test
|
||||||
|
@ -64,6 +65,14 @@ public class TestForm : Form
|
||||||
AddInfo ();
|
AddInfo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static readonly string [] Images = {
|
||||||
|
"abiword_48.png",
|
||||||
|
"bmp.png",
|
||||||
|
"disks.png"
|
||||||
|
};
|
||||||
|
|
||||||
|
static readonly string ImagesPath = "listview-items-icons/32x32/";
|
||||||
|
|
||||||
void AddInfo ()
|
void AddInfo ()
|
||||||
{
|
{
|
||||||
ListViewItem item1 = new ListViewItem (new string [] { "Les Miserables", "Hugo, Victor" });
|
ListViewItem item1 = new ListViewItem (new string [] { "Les Miserables", "Hugo, Victor" });
|
||||||
|
@ -85,6 +94,9 @@ public class TestForm : Form
|
||||||
items = new ListViewItem [] { item1, item2, item3, item4, item5, item6, item7, item8, item9, item10,
|
items = new ListViewItem [] { item1, item2, item3, item4, item5, item6, item7, item8, item9, item10,
|
||||||
item11, item12, item13, item14, item15, item16 };
|
item11, item12, item13, item14, item15, item16 };
|
||||||
|
|
||||||
|
for (int i = 0; i < items.Length; i++)
|
||||||
|
items [i].ImageIndex = i % Images.Length;
|
||||||
|
|
||||||
SetGroups ();
|
SetGroups ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +139,13 @@ public class TestForm : Form
|
||||||
lv.Size = new Size (400, 500);
|
lv.Size = new Size (400, 500);
|
||||||
lv.FullRowSelect = true;
|
lv.FullRowSelect = true;
|
||||||
lv.SmallImageList = new ImageList ();
|
lv.SmallImageList = new ImageList ();
|
||||||
|
lv.SmallImageList.ColorDepth = ColorDepth.Depth32Bit;
|
||||||
|
lv.SmallImageList.ImageSize = new Size (24, 24);
|
||||||
lv.LargeImageList = new ImageList ();
|
lv.LargeImageList = new ImageList ();
|
||||||
|
lv.LargeImageList.ColorDepth = ColorDepth.Depth32Bit;
|
||||||
|
lv.LargeImageList.ImageSize = new Size (32, 32);
|
||||||
|
LoadListViewImages ();
|
||||||
|
|
||||||
lv.ColumnClick += ColumnClicked;
|
lv.ColumnClick += ColumnClicked;
|
||||||
UpdateView (View.Details);
|
UpdateView (View.Details);
|
||||||
|
|
||||||
|
@ -200,6 +218,21 @@ public class TestForm : Form
|
||||||
{
|
{
|
||||||
lv.Sorting = (SortOrder)sorting_cb.SelectedItem;
|
lv.Sorting = (SortOrder)sorting_cb.SelectedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoadListViewImages ()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists (ImagesPath)) {
|
||||||
|
Console.WriteLine ("Images path " + ImagesPath + " does not exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string image_file in Images)
|
||||||
|
if (File.Exists (ImagesPath + image_file)) {
|
||||||
|
Image img = Image.FromFile (ImagesPath + image_file);
|
||||||
|
lv.SmallImageList.Images.Add (img);
|
||||||
|
lv.LargeImageList.Images.Add (img);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StringComparer : IComparer<string>
|
class StringComparer : IComparer<string>
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
public class Test
|
public class Test
|
||||||
|
@ -49,6 +50,14 @@ public class TestForm : Form
|
||||||
|
|
||||||
const int ItemsCount = 500;
|
const int ItemsCount = 500;
|
||||||
|
|
||||||
|
static readonly string [] Images = {
|
||||||
|
"abiword_48.png",
|
||||||
|
"bmp.png",
|
||||||
|
"disks.png"
|
||||||
|
};
|
||||||
|
|
||||||
|
static readonly string ImagesPath = "listview-items-icons/32x32/";
|
||||||
|
|
||||||
public TestForm ()
|
public TestForm ()
|
||||||
{
|
{
|
||||||
InitializeUIComponents ();
|
InitializeUIComponents ();
|
||||||
|
@ -61,10 +70,15 @@ public class TestForm : Form
|
||||||
lv.Size = new Size (400, 500);
|
lv.Size = new Size (400, 500);
|
||||||
lv.FullRowSelect = true;
|
lv.FullRowSelect = true;
|
||||||
lv.SmallImageList = new ImageList ();
|
lv.SmallImageList = new ImageList ();
|
||||||
|
lv.SmallImageList.ColorDepth = ColorDepth.Depth32Bit;
|
||||||
|
lv.SmallImageList.ImageSize = new Size (24, 24);
|
||||||
lv.LargeImageList = new ImageList ();
|
lv.LargeImageList = new ImageList ();
|
||||||
|
lv.LargeImageList.ColorDepth = ColorDepth.Depth32Bit;
|
||||||
|
lv.LargeImageList.ImageSize = new Size (32, 32);
|
||||||
lv.RetrieveVirtualItem += ListViewRetrieveItem;
|
lv.RetrieveVirtualItem += ListViewRetrieveItem;
|
||||||
lv.VirtualListSize = ItemsCount;
|
lv.VirtualListSize = ItemsCount;
|
||||||
lv.VirtualMode = true;
|
lv.VirtualMode = true;
|
||||||
|
LoadListViewImages ();
|
||||||
|
|
||||||
view_label = new Label ();
|
view_label = new Label ();
|
||||||
view_label.Location = new Point (lv.Right + 10, 10);
|
view_label.Location = new Point (lv.Right + 10, 10);
|
||||||
|
@ -115,12 +129,13 @@ public class TestForm : Form
|
||||||
|
|
||||||
// for testing purposes, we are creating one item per
|
// for testing purposes, we are creating one item per
|
||||||
// invocation
|
// invocation
|
||||||
ListViewItem item = new ListViewItem ("Item " + args.ItemIndex);
|
ListViewItem item = new ListViewItem ("Item #" + args.ItemIndex);
|
||||||
item.SubItems.Add ("Sub item " + args.ItemIndex + "-1");
|
item.SubItems.Add ("Sub item " + args.ItemIndex + "-1");
|
||||||
item.SubItems.Add ("Sub item " + args.ItemIndex + "-2");
|
item.SubItems.Add ("Sub item " + args.ItemIndex + "-2");
|
||||||
if (lv.View == View.Details && args.ItemIndex % 2 == 0)
|
if (lv.View == View.Details && args.ItemIndex % 2 == 0)
|
||||||
item.BackColor = Color.WhiteSmoke;
|
item.BackColor = Color.WhiteSmoke;
|
||||||
|
|
||||||
|
item.ImageIndex = args.ItemIndex % Images.Length;
|
||||||
args.Item = item;
|
args.Item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,5 +143,20 @@ public class TestForm : Form
|
||||||
{
|
{
|
||||||
UpdateView ((View)view_cb.SelectedItem);
|
UpdateView ((View)view_cb.SelectedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoadListViewImages ()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists (ImagesPath)) {
|
||||||
|
Console.WriteLine ("Images path " + ImagesPath + " does not exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string image_file in Images)
|
||||||
|
if (File.Exists (ImagesPath + image_file)) {
|
||||||
|
Image img = Image.FromFile (ImagesPath + image_file);
|
||||||
|
lv.SmallImageList.Images.Add (img);
|
||||||
|
lv.LargeImageList.Images.Add (img);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче