[Mono-winforms-list] [PATCH] AsyncMethodResult patch and Question

Kazuki Oikawa kazuki at panicode.com
Wed Sep 21 20:07:23 EDT 2005


Hi,

I made small patches.
please review it.

AsyncMethodResult.patch
- Fixes Control.Invoke is blocked infinitely.

ListBox1.patch
- Cannot get last index using IndexFromPoint.

ListBox2.patch (not good patch...)
- Improve action when MultiColumn is true.


I have a question.
I think Control.ClientRectangle is without Border width,
but current implement is not.
If improve the current implement to return the correct ClientRectangle,
X and Y of ClientRectangle is not zero.
This result is not equal with MSFT but I think this is good.
What do you think ?

--
Kazuki Oikawa


-------------- next part --------------
Index: AsyncMethodResult.cs
===================================================================
--- AsyncMethodResult.cs	(リビジョン 50212)
+++ AsyncMethodResult.cs	(作業コピー)
@@ -74,7 +74,6 @@
 		public void Complete (object result)
 		{
 			lock (this) {
-				handle.WaitOne ();
 				completed = true;
 				return_value = result;
 				handle.ReleaseMutex ();


-------------- next part --------------
Index: ListBox.cs
===================================================================
--- ListBox.cs	(ƒŠƒrƒWƒ‡ƒ“ 50212)
+++ ListBox.cs	(ì‹ÆƒRƒs[)
@@ -792,7 +792,7 @@
 		// Only returns visible points
 		public int IndexFromPoint (int x, int y)
 		{
-			for (int i = LBoxInfo.top_item; i < LBoxInfo.last_item; i++) {
+			for (int i = LBoxInfo.top_item; i <= LBoxInfo.last_item; i++) {
 				if (GetItemRectangle (i).Contains (x,y) == true)
 					return i;
 			}


-------------- next part --------------
Index: ListBox.cs
===================================================================
--- ListBox.cs	(リビジョン 50212)
+++ ListBox.cs	(作業コピー)
@@ -1234,8 +1234,8 @@
 					break;
 				}
 
-				if (focused_item + LBoxInfo.page_size > LBoxInfo.last_item) {
-					LBoxInfo.top_item = focused_item;
+				if (focused_item + LBoxInfo.page_size >= LBoxInfo.top_item + page_size) {
+					LBoxInfo.top_item = LBoxInfo.last_item - page_size + LBoxInfo.page_size - (LBoxInfo.last_item % LBoxInfo.page_size);
 					UpdatedTopItem ();
 				}
 					
@@ -1276,7 +1276,7 @@
 					if (actualHeight >= LBoxInfo.textdrawing_rect.Height) {
 						int bal = IntegralHeight ? 0 : (listbox_info.textdrawing_rect.Height == actualHeight ? 0 : 1);
 						if (focused_item + bal >= LBoxInfo.last_item) {
-							LBoxInfo.top_item++;
+							LBoxInfo.top_item += (MultiColumn ? LBoxInfo.page_size : 1);
 							UpdatedTopItem ();						
 						}
 					}
@@ -1690,7 +1690,8 @@
 					int fullpage = (listbox_info.page_size * (listbox_info.client_rect.Width / ColumnWidthInternal));
 
 					if (hscrollbar_ctrl.Enabled && listbox_info.page_size > 0)
-						hscrollbar_ctrl.Maximum  = Math.Max (0, 1 + ((Items.Count - fullpage) / listbox_info.page_size));
+						hscrollbar_ctrl.Maximum  = Math.Max (0,
+							(Items.Count % listbox_info.page_size == 0 ? 0 : 1) + ((Items.Count - fullpage) / listbox_info.page_size));
 				}
 			}
 
@@ -1754,7 +1755,7 @@
 
 				/* Is it really need it */
 				int page_size = listbox_info.client_rect.Height / listbox_info.item_height;
-				int fullpage = (page_size * (listbox_info.textdrawing_rect.Height / ColumnWidthInternal));
+				int fullpage = (page_size * (listbox_info.textdrawing_rect.Width / ColumnWidthInternal));
 
 				if (Items.Count > fullpage) {					
 					show = true;



More information about the Mono-winforms-list mailing list