Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void
		public void SelectedIndexCollectionTest_RemoveTest_VirtualMode ()
		{
			ListView listview = new ListView ();
			listview.VirtualListSize = 5;
			listview.RetrieveVirtualItem += ListViewRetrieveVirtualItemHandler;
			listview.VirtualMode = true;
			CreateVirtualItems (5);

			// Force to create the handle
			listview.CreateControl ();

			listview.SelectedIndices.Add (0);
			listview.SelectedIndices.Add (2);
			listview.SelectedIndices.Add (4);

			Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#1");
			Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#2");
			Assert.AreEqual (true, listview.Items [2].Selected, "SelectedIndexCollectionTest_RemoveTest#3");
			Assert.AreEqual (true, listview.Items [4].Selected, "SelectedIndexCollectionTest_RemoveTest#4");
			Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_RemoveTest#5");
			Assert.AreEqual (2, listview.SelectedIndices [1], "SelectedIndexCollectionTest_RemoveTest#6");
			Assert.AreEqual (4, listview.SelectedIndices [2], "SelectedIndexCollectionTest_RemoveTest#7");

			listview.SelectedIndices.Remove (2);
			Assert.AreEqual (2, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#8");
			Assert.AreEqual (false, listview.Items [2].Selected, "SelectedIndexCollectionTest_RemoveTest#9");
			Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_RemoveTest#10");
			Assert.AreEqual (4, listview.SelectedIndices [1], "SelectedIndexCollectionTest_RemoveTest#11");

			listview.SelectedIndices.Remove (0);
			Assert.AreEqual (1, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#12");
			Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#13");
			Assert.AreEqual (4, listview.SelectedIndices [0], "SelectedIndexCollectionTest_RemoveTest#14");

			listview.SelectedIndices.Remove (4);
			Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#15");
			Assert.AreEqual (false, listview.Items [4].Selected, "SelectedIndexCollectionTest_RemoveTest#16");

			// Remove an already removed index
			listview.SelectedIndices.Remove (0);
			Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#17");
			Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#18");
			listview.Dispose ();
		}
		public void SelectedItemCollectionTest_Indexer2 ()
		{
			ListView lvw = new ListView ();
			ListViewItem lvi1 = new ListViewItem ("A");
			lvi1.Name = "A name";
			lvi1.Selected = true;
			ListViewItem lvi2 = new ListViewItem ("B");
			lvi2.Name = "Same name";
			lvi2.Selected = false;
			ListViewItem lvi3 = new ListViewItem ("C");
			lvi3.Name = "Same name";
			lvi3.Selected = true;
			ListViewItem lvi4 = new ListViewItem ("D");
			lvi4.Name = String.Empty;
			lvi4.Selected = true;
			ListViewItem lvi5 = new ListViewItem ("E");
			lvi5.Name = "E name";
			lvi5.Selected = false;
			lvw.Items.AddRange (new ListViewItem [] { lvi1, lvi2, lvi3, lvi4, lvi5 });

			// Force to create the control
			lvw.CreateControl ();

			Assert.AreEqual (3, lvw.SelectedItems.Count, "#A1");
			Assert.AreEqual (null, lvw.SelectedItems [String.Empty], "#A2");
			Assert.AreEqual (null, lvw.SelectedItems [null], "#A3");
			Assert.AreEqual (lvi1, lvw.SelectedItems ["A name"], "#A4");
			Assert.AreEqual (lvi1, lvw.SelectedItems ["a NAME"], "#A5");
			Assert.AreEqual (lvi3, lvw.SelectedItems ["Same name"], "#A6");
			Assert.AreEqual (null, lvw.SelectedItems ["E name"], "#A7");

			ListViewItem lvi6 = new ListViewItem ("F");
			lvw.Items.Add (lvi6);
			lvi6.Selected = true;
			lvi6.Name = "F name";

			Assert.AreEqual (4, lvw.SelectedItems.Count, "#B1");
			Assert.AreEqual (lvi6, lvw.SelectedItems ["F name"], "#B2");
			lvw.Dispose ();
		}
		public void SelectedIndexCollectionTest_IndexOfTest_VirtualMode ()
		{
			ListView listview = new ListView ();
			listview.VirtualListSize = 4;
			listview.RetrieveVirtualItem += ListViewRetrieveVirtualItemHandler;
			listview.VirtualMode = true;
			CreateVirtualItems (4);

			// Force to create the handle
			listview.CreateControl ();

			listview.SelectedIndices.Add (0);
			listview.SelectedIndices.Add (3);
			listview.SelectedIndices.Add (2);

			Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_IndexOfTest#1");
			Assert.AreEqual (0, listview.SelectedIndices.IndexOf (0), "SelectedIndexCollectionTest_IndexOfTest#2");
			Assert.AreEqual (1, listview.SelectedIndices.IndexOf (2), "SelectedIndexCollectionTest_IndexOfTest#3");
			Assert.AreEqual (2, listview.SelectedIndices.IndexOf (3), "SelectedIndexCollectionTest_IndexOfTest#4");
			Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (1), "SelectedIndexCollectionTest_IndexOfTest#5");
			Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (99), "SelectedIndexCollectionTest_IndexOfTest#6");
			Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (-1), "SelectedIndexCollectionTest_IndexOfTest#7");
			listview.Dispose ();
		}
		public void SelectedIndexCollectionTest_RemoveTest ()
		{
			ListView listview = new ListView ();
			listview.Items.Add ("A");

			listview.SelectedIndices.Add (0);
			listview.SelectedIndices.Remove (0);
			Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#1");
			Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#2");

			// Force to create the handle
			listview.CreateControl ();

			listview.SelectedIndices.Add (0);
			listview.SelectedIndices.Remove (0);
			Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#3");
			Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#4");
			listview.Dispose ();
		}
		public void SelectedIndexCollectionTest_ClearTest_VirtualMode ()
		{
			ListView listview = new ListView ();
			listview.VirtualListSize = 3;
			listview.RetrieveVirtualItem += ListViewRetrieveVirtualItemHandler;
			listview.VirtualMode = true;
			CreateVirtualItems (3);

			// Force to create the handle
			listview.CreateControl ();

			listview.SelectedIndices.Add (2);
			listview.SelectedIndices.Add (0);

			Assert.AreEqual (2, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_ClearTest#1");
			Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_ClearTest#2");
			Assert.AreEqual (2, listview.SelectedIndices [1], "SelectedIndexCollectionTest_ClearTest#3");
			Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_ClearTest#4");
			Assert.AreEqual (false, listview.Items [1].Selected, "SelectedIndexCollectionTest_ClearTest#5");
			Assert.AreEqual (true, listview.Items [2].Selected, "SelectedIndexCollectionTest_ClearTest#6");

			listview.SelectedIndices.Clear ();
			Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_ClearTest#5");
			Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_ClearTest#6");
			Assert.AreEqual (false, listview.Items [1].Selected, "SelectedIndexCollectionTest_ClearTest#7");
			Assert.AreEqual (false, listview.Items [2].Selected, "SelectedIndexCollectionTest_ClearTest#8");
			listview.Dispose ();
		}
		public void SelectedIndexCollectionTest_IndexOfTest ()
		{
			ListView listview = new ListView ();
			ListViewItem item1 = listview.Items.Add ("A");
			ListViewItem item2 = listview.Items.Add ("B");
			ListViewItem item3 = listview.Items.Add ("C");
			ListViewItem item4 = listview.Items.Add ("D");

			listview.SelectedIndices.Add (0);
			listview.SelectedIndices.Add (3);
			listview.SelectedIndices.Add (2);

			Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_IndexOfTest#1");
			Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item1.Index), "SelectedIndexCollectionTest_IndexOfTest#2");
			Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item3.Index), "SelectedIndexCollectionTest_IndexOfTest#3");
			Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item4.Index), "SelectedIndexCollectionTest_IndexOfTest#4");
			Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item2.Index), "SelectedIndexCollectionTest_IndexOfTest#5");

			// Force to create the control
			listview.CreateControl ();

			Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_IndexOfTest#6");
			Assert.AreEqual (0, listview.SelectedIndices.IndexOf (item1.Index), "SelectedIndexCollectionTest_IndexOfTest#7");
			Assert.AreEqual (1, listview.SelectedIndices.IndexOf (item3.Index), "SelectedIndexCollectionTest_IndexOfTest#8");
			Assert.AreEqual (2, listview.SelectedIndices.IndexOf (item4.Index), "SelectedIndexCollectionTest_IndexOfTest#9");
			Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item2.Index), "SelectedIndexCollectionTest_IndexOfTest#10");
			listview.Dispose ();
		}
		public void SelectedIndexCollectionTest_AddTest_VirtualMode ()
		{
			ListView listview = new ListView ();
			listview.VirtualListSize = 5;
			listview.RetrieveVirtualItem += ListViewRetrieveVirtualItemHandler;
			listview.VirtualMode = true;
			CreateVirtualItems (5);

			int n = listview.SelectedIndices.Add (0);
			Assert.AreEqual (-1, n, "SelectedIndexCollectionTest_AddTest#1");
			Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#2");
			Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#3");

			// Force to create the handle
			// Selection state should remain empty
			listview.CreateControl ();
			Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#4");
			Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#5");

			n = listview.SelectedIndices.Add (0);
			Assert.AreEqual (1, n, "SelectedIndexCollectionTest_AddTest#5");
			Assert.AreEqual (1, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#6");
			Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_AddTest#7");
			Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#8");

			// Make sure the collection keeps them sorted
			listview.SelectedIndices.Add (4);
			n = listview.SelectedIndices.Add (2);
			Assert.AreEqual (3, n, "SelectedIndexCollectionTest_AddTest#9");
			Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#10");
			Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_AddTest#11");
			Assert.AreEqual (2, listview.SelectedIndices [1], "SelectedIndexCollectionTest_AddTest#12");
			Assert.AreEqual (4, listview.SelectedIndices [2], "SelectedIndexCollectionTest_AddTest#13");
			Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#14");
			Assert.AreEqual (true, listview.Items [2].Selected, "SelectedIndexCollectionTest_AddTest#15");
			Assert.AreEqual (true, listview.Items [4].Selected, "SelectedIndexCollectionTest_AddTest#16");

			// Add the item twice
			n = listview.SelectedIndices.Add (0);
			Assert.AreEqual (3, n, "SelectedIndexCollectionTest_AddTest#17");
			Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#18");
			listview.Dispose ();
		}
Esempio n. 8
0
		public void ImageList_ListView_Disposed ()
		{
			ListView lv = new ListView ();
			lv.View = View.Details;
			ImageList small = new ImageList ();
			lv.SmallImageList = small;
			ImageList large = new ImageList ();
			lv.LargeImageList = large;
			ColumnHeader col = new ColumnHeader ();
			lv.Columns.Add (col);
			lv.Dispose ();
			Assert.IsNull (col.ImageList);
		}
Esempio n. 9
0
		public void Width_ListView_Disposed ()
		{
			ListView lv = new ListView ();
			lv.View = View.Details;
			ColumnHeader col = new ColumnHeader ();
			lv.Columns.Add (col);
			lv.Dispose ();
			col.Width = 10;
			Assert.AreEqual (10, col.Width);
		}
		public void SelectedIndexCollectionTest_AddTest ()
		{
			ListView listview = new ListView ();
			listview.Items.Add ("A");

			int n = listview.SelectedIndices.Add (0);
			Assert.AreEqual (0, n, "SelectedIndexCollectionTest_AddTest#1");
			Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#2");

			// Force to create the handle
			listview.CreateControl ();
			Assert.AreEqual (1, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#4");

			n = listview.SelectedIndices.Add (0);
			Assert.AreEqual (1, n, "SelectedIndexCollectionTest_AddTest#5");
			Assert.AreEqual (1, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#6");
			Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#7");
			listview.Dispose ();
		}
Esempio n. 11
0
		public void TextAlign_ListView_Disposed ()
		{
			ListView lv = new ListView ();
			lv.View = View.Details;
			ColumnHeader col = new ColumnHeader ();
			lv.Columns.Add (col);
			lv.Dispose ();
			col.TextAlign = HorizontalAlignment.Right;
			Assert.AreEqual (HorizontalAlignment.Right, col.TextAlign);
		}
Esempio n. 12
0
		public void Text_ListView_Disposed ()
		{
			ListView lv = new ListView ();
			lv.View = View.Details;
			ColumnHeader col = new ColumnHeader ();
			lv.Columns.Add (col);
			lv.Dispose ();
			col.Text = "whatever";
			Assert.AreEqual ("whatever", col.Text);
		}
Esempio n. 13
0
		public void Index_ListView_Disposed ()
		{
			ListView lv = new ListView ();
			lv.View = View.Details;
			ColumnHeader colA = new ColumnHeader ();
			lv.Columns.Add (colA);
			ColumnHeader colB = new ColumnHeader ();
			lv.Columns.Add (colB);
			lv.Dispose ();
			Assert.AreEqual (-1, colA.Index, "#1");
			Assert.AreEqual (-1, colB.Index, "#2");
		}
Esempio n. 14
0
		public void DisposeTest ()
		{
			ListView lv = new ListView ();
			lv.View = View.Details;

			lv.LargeImageList = new ImageList ();
			lv.SmallImageList = new ImageList ();

			ListViewItem lvi = new ListViewItem ();
			lv.Items.Add (lvi);

			ColumnHeader col = new ColumnHeader ();
			lv.Columns.Add (col);

			lv.Dispose ();

			Assert.IsNull (lvi.ListView, "#A1");
			Assert.IsNull (col.ListView, "#A2");

			Assert.IsNull (lv.LargeImageList, "#B1");
			Assert.IsNull (lv.SmallImageList, "#B2");
			Assert.IsNull(lv.StateImageList, "#B3");
		}
		public void SelectedIndexCollectionTest_ClearTest ()
		{
			ListView listview = new ListView ();
			listview.Items.Add ("A");
			listview.Items.Add ("B");
			listview.Items.Add ("C");

			listview.SelectedIndices.Add (0);
			listview.SelectedIndices.Add (2);

			// Nothing if handle hasn't been created
			listview.SelectedIndices.Clear (); 
			Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_ClearTest#2");
			Assert.AreEqual (false, listview.Items [1].Selected, "SelectedIndexCollectionTest_ClearTest#3");
			Assert.AreEqual (true, listview.Items [2].Selected, "SelectedIndexCollectionTest_ClearTest#4");

			// Force to create the handle
			listview.CreateControl ();

			listview.SelectedIndices.Add (0);
			listview.SelectedIndices.Add (2);

			listview.SelectedIndices.Clear ();
			Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_ClearTest#5");
			Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_ClearTest#6");
			Assert.AreEqual (false, listview.Items [1].Selected, "SelectedIndexCollectionTest_ClearTest#7");
			Assert.AreEqual (false, listview.Items [2].Selected, "SelectedIndexCollectionTest_ClearTest#8");
			listview.Dispose ();
		}
Esempio n. 16
0
		public void DisposeLayoutTest ()
		{
			Form f = new Form ();
			ListView lv = new ListView ();
			f.Controls.Add (lv);
			f.Show ();

			dispose_log = String.Empty;
			lv.Layout += DisposeOnLayout;
			lv.Dispose (); // just to be sure.
			f.Dispose ();

			Assert.AreEqual (0, dispose_log.Length, "#A0");
		}
Esempio n. 17
0
		public void DisplayIndex_ListView_Disposed ()
		{
			ListView lv = new ListView ();
			lv.View = View.Details;
			ColumnHeader colA = new ColumnHeader ();
			lv.Columns.Add (colA);
			ColumnHeader colB = new ColumnHeader ();
			lv.Columns.Add (colB);
			ColumnHeader colC = new ColumnHeader ();
			lv.Columns.Add (colC);
			Assert.AreEqual (0, colA.DisplayIndex, "#A1");
			Assert.AreEqual (1, colB.DisplayIndex, "#A2");
			Assert.AreEqual (2, colC.DisplayIndex, "#A3");
			colA.DisplayIndex = 2;
			lv.Columns.Remove (colB);
			lv.Dispose ();
			Assert.AreEqual (1, colA.DisplayIndex, "#B1");
			Assert.AreEqual (-1, colB.DisplayIndex, "#B2");
			Assert.AreEqual (0, colC.DisplayIndex, "#B3");
			colA.DisplayIndex = 255;
			Assert.AreEqual (255, colA.DisplayIndex, "#C1");
			Assert.AreEqual (-1, colB.DisplayIndex, "#C2");
			Assert.AreEqual (0, colC.DisplayIndex, "#C3");
		}