mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 01:41:17 -10:00
Compare commits
126
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b3bfcb002 | ||
|
|
23a247a942 | ||
|
|
9f2ef9809c | ||
|
|
a111503d8b | ||
|
|
503db178aa | ||
|
|
fc080ff59c | ||
|
|
b0871c8895 | ||
|
|
4353fd8f2c | ||
|
|
afd0431985 | ||
|
|
62a731564f | ||
|
|
52cc9ad641 | ||
|
|
6540fcf26d | ||
|
|
ebd3a9281e | ||
|
|
a329776379 | ||
|
|
35707fc9bd | ||
|
|
3630d90e48 | ||
|
|
f18b59fff1 | ||
|
|
ccee7e4b9d | ||
|
|
a5b4338830 | ||
|
|
7fdb0c5558 | ||
|
|
2a99fb1060 | ||
|
|
aceb5b70e6 | ||
|
|
80ee6f45bd | ||
|
|
f9317b6730 | ||
|
|
cd1524d307 | ||
|
|
d48d61a5b3 | ||
|
|
b2cea1696b | ||
|
|
e56d0ffb1f | ||
|
|
1250fe8848 | ||
|
|
8adf9c4e63 | ||
|
|
883ad0420d | ||
|
|
77de52bdbf | ||
|
|
297bd4e009 | ||
|
|
46196ff4c4 | ||
|
|
0424bef8f1 | ||
|
|
7d36c3b9ea | ||
|
|
a50d266d26 | ||
|
|
580704c69d | ||
|
|
e9350eef2a | ||
|
|
48e2cffb75 | ||
|
|
c34e8b3eac | ||
|
|
6260184c6c | ||
|
|
778d93bf88 | ||
|
|
c0cb46ff10 | ||
|
|
0ff81ba716 | ||
|
|
e48557ea01 | ||
|
|
316e1afee5 | ||
|
|
88f93ba4d4 | ||
|
|
328122f2f8 | ||
|
|
e1a99be943 | ||
|
|
fe00fc8182 | ||
|
|
9ef62b1562 | ||
|
|
04bcafd809 | ||
|
|
429fb49940 | ||
|
|
f6c15fba31 | ||
|
|
98b067eb08 | ||
|
|
0685091566 | ||
|
|
0e7f1c8676 | ||
|
|
7053921e5c | ||
|
|
ea34135825 | ||
|
|
c00d8b2f2e | ||
|
|
e8d0f665f5 | ||
|
|
c923f03807 | ||
|
|
2d807b3fe9 | ||
|
|
aa7633a74e | ||
|
|
ae27633a66 | ||
|
|
dfe4ec189c | ||
|
|
7bef2052ef | ||
|
|
08bc44024f | ||
|
|
831f0d7461 | ||
|
|
a91c5109b0 | ||
|
|
4eb3ecc064 | ||
|
|
3aba6bf43f | ||
|
|
715d098ce9 | ||
|
|
151a6ee40d | ||
|
|
2fa1d2490e | ||
|
|
e17e04416c | ||
|
|
1583fe12b7 | ||
|
|
9809316f66 | ||
|
|
e40411592a | ||
|
|
f7290f8d7e | ||
|
|
146863bf60 | ||
|
|
fd82166795 | ||
|
|
a66c2664be | ||
|
|
3c5ff3f112 | ||
|
|
c24f8893d8 | ||
|
|
f88bcac76e | ||
|
|
80e8976130 | ||
|
|
fe5c27104f | ||
|
|
a86712e017 | ||
|
|
56e8e6273a | ||
|
|
f81b806058 | ||
|
|
41ca144a72 | ||
|
|
13e3ae40a9 | ||
|
|
75260f9e81 | ||
|
|
14ff54e757 | ||
|
|
7fe451d046 | ||
|
|
7e75b72870 | ||
|
|
511c9adecf | ||
|
|
7cd6288fc6 | ||
|
|
a4988f3889 | ||
|
|
e61dc1e89b | ||
|
|
63b0b98afc | ||
|
|
187a102e2a | ||
|
|
24516aeabe | ||
|
|
092f8596ab | ||
|
|
0c4808b22c | ||
|
|
ac48be8ec3 | ||
|
|
18fb74b024 | ||
|
|
5917d34218 | ||
|
|
67b79ccf25 | ||
|
|
4268e0a712 | ||
|
|
49c256b0c8 | ||
|
|
c1f9c48fba | ||
|
|
afd04d879e | ||
|
|
65fdb3d442 | ||
|
|
38f2bec738 | ||
|
|
efb92fc79f | ||
|
|
71464a4c62 | ||
|
|
13000f9324 | ||
|
|
208a65bee0 | ||
|
|
14b266700f | ||
|
|
832157656c | ||
|
|
48e294dac5 | ||
|
|
3015d251c6 | ||
|
|
c6967cc409 |
No files matched your search
@@ -218,6 +218,7 @@
|
||||
</cryptoNameMapping>
|
||||
<oidMap>
|
||||
<oidEntry OID="1.2.840.113549.2.2" name="MD2" />
|
||||
<oidEntry OID="1.2.840.113549.2.2" name="Mono.Security.Cryptography.MD2Managed" />
|
||||
</oidMap>
|
||||
</cryptographySettings>
|
||||
</mscorlib>
|
||||
|
||||
@@ -192,6 +192,7 @@
|
||||
</cryptoNameMapping>
|
||||
<oidMap>
|
||||
<oidEntry OID="1.2.840.113549.2.2" name="MD2" />
|
||||
<oidEntry OID="1.2.840.113549.2.2" name="Mono.Security.Cryptography.MD2Managed" />
|
||||
</oidMap>
|
||||
</cryptographySettings>
|
||||
</mscorlib>
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
2008-02-14 Geoff Norton <[email protected]>
|
||||
|
||||
* WindowHandler.cs: Ensure we send WM_ACTIVATE when we activate our
|
||||
Form. Fixes #360721
|
||||
|
||||
2008-02-04 Geoff Norton <[email protected]>
|
||||
|
||||
* KeyboardHandler.cs: [Backport fix] msg != msg.message
|
||||
|
||||
2008-02-04 Geoff Norton <[email protected]>
|
||||
|
||||
* EventHandler.cs: [Backport] Expose GetEventClass internally. Subscribe to
|
||||
the unicode text events.
|
||||
* KeyboardHandler.cs: [Backport] Commit the new keyboard handler. We grab
|
||||
the unicode characters provided by apple and push them thru a translation
|
||||
table to generate windows style keyboard events. Control+key does not generate
|
||||
SYSKEY, it prevents SYSKEY (ctrl+alt+foo). Also implement broken menu keyup
|
||||
filtering. lParam should be cleared in the broken menu filter case.
|
||||
Commit support for the last batch of keytypes .(F1-12; Fn+modifiers; etc).
|
||||
Filter the translate call.
|
||||
|
||||
2008-01-28 Geoff Norton <[email protected]>
|
||||
|
||||
* EventHandler.cs: Subscribe ot ResizeBegin and ResizeEnd events.
|
||||
|
||||
@@ -98,7 +98,8 @@ namespace System.Windows.Forms.CarbonInternal {
|
||||
new EventTypeSpec (kEventClassKeyboard, KeyboardHandler.kEventRawKeyModifiersChanged),
|
||||
new EventTypeSpec (kEventClassKeyboard, KeyboardHandler.kEventRawKeyDown),
|
||||
new EventTypeSpec (kEventClassKeyboard, KeyboardHandler.kEventRawKeyRepeat),
|
||||
new EventTypeSpec (kEventClassKeyboard, KeyboardHandler.kEventRawKeyUp)
|
||||
new EventTypeSpec (kEventClassKeyboard, KeyboardHandler.kEventRawKeyUp),
|
||||
new EventTypeSpec (kEventClassTextInput, KeyboardHandler.kEventTextInputUnicodeForKeyEvent)
|
||||
};
|
||||
|
||||
internal static int EventCallback (IntPtr callref, IntPtr eventref, IntPtr handle) {
|
||||
@@ -113,6 +114,7 @@ namespace System.Windows.Forms.CarbonInternal {
|
||||
break;
|
||||
}
|
||||
case kEventClassKeyboard:
|
||||
case kEventClassTextInput:
|
||||
handler = (IEventHandler) Driver.KeyboardHandler;
|
||||
break;
|
||||
case kEventClassWindow:
|
||||
@@ -141,13 +143,13 @@ namespace System.Windows.Forms.CarbonInternal {
|
||||
|
||||
internal static bool TranslateMessage (ref MSG msg) {
|
||||
bool result = false;
|
||||
|
||||
|
||||
if (!result)
|
||||
result = Driver.KeyboardHandler.TranslateMessage (ref msg);
|
||||
if (!result)
|
||||
result = Driver.MouseHandler.TranslateMessage (ref msg);
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static void InstallApplicationHandler () {
|
||||
@@ -170,7 +172,7 @@ namespace System.Windows.Forms.CarbonInternal {
|
||||
internal static extern IntPtr GetWindowEventTarget (IntPtr window);
|
||||
|
||||
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
|
||||
static extern uint GetEventClass (IntPtr eventref);
|
||||
internal static extern uint GetEventClass (IntPtr eventref);
|
||||
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
|
||||
static extern uint GetEventKind (IntPtr eventref);
|
||||
|
||||
|
||||
+226
-107
@@ -39,148 +39,267 @@ namespace System.Windows.Forms.CarbonInternal {
|
||||
internal const uint kEventHotKeyReleased = 6;
|
||||
|
||||
internal const uint kEventParamKeyMacCharCodes = 1801676914;
|
||||
internal const uint kEventParamKeyCode = 1801678692;
|
||||
internal const uint kEventParamKeyModifiers = 1802334052;
|
||||
internal const uint kEventTextInputUnicodeForKeyEvent = 2;
|
||||
internal const uint kEventParamTextInputSendText = 1953723512;
|
||||
|
||||
internal const uint typeChar = 1413830740;
|
||||
internal const uint typeUInt32 = 1835100014;
|
||||
internal const uint typeUnicodeText = 1970567284;
|
||||
|
||||
UInt32 modifiers = 0;
|
||||
Keys keys = Keys.None;
|
||||
internal static byte [] key_filter_table;
|
||||
internal static byte [] key_modifier_table;
|
||||
internal static byte [] key_translation_table;
|
||||
internal static byte [] char_translation_table;
|
||||
|
||||
internal static bool translate_modifier = false;
|
||||
|
||||
static KeyboardHandler () {
|
||||
// our key filter table is a 256 byte array - if the corresponding byte
|
||||
// is set the key should be filtered from WM_CHAR (apple pushes unicode events
|
||||
// for some keys which win32 only handles as KEYDOWN
|
||||
// currently filtered:
|
||||
// fn+f* == 16
|
||||
// left == 28
|
||||
// right == 29
|
||||
// up == 30
|
||||
// down == 31
|
||||
// Please update this list as well as the table as more keys are found
|
||||
key_filter_table = new byte [256] {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
// our char translation table is a set of translations from mac char codes
|
||||
// to win32 vkey codes
|
||||
// most things map directly
|
||||
char_translation_table = new byte [256] {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0x25, 0x27, 0x26, 0x28,
|
||||
32, 49, 34, 51, 52, 53, 55, 222, 57, 48, 56, 187, 188, 189, 190, 191,
|
||||
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 186, 60, 61, 62, 63,
|
||||
50, 65, 66, 67, 68, 187, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
||||
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 219, 220, 221, 54, 189,
|
||||
192, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
||||
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123, 124, 125, 126, 127,
|
||||
128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
|
||||
144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
|
||||
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
|
||||
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
|
||||
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
|
||||
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
|
||||
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
|
||||
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
|
||||
};
|
||||
key_translation_table = new byte [256] {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
||||
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
||||
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
|
||||
0x74, 0x75, 0x76, 0x72, 0x77, 0x78, 0x79, 103, 104, 105, 106, 107, 108, 109, 0x7a, 0x7b,
|
||||
112, 113, 114, 115, 116, 117, 0x73, 119, 0x71, 121, 0x70, 123, 124, 125, 126, 127,
|
||||
128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
|
||||
144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
|
||||
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
|
||||
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
|
||||
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
|
||||
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
|
||||
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
|
||||
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
|
||||
};
|
||||
// the key modifier table is a state table of the possible modifier keys
|
||||
// apple currently only goes up to 1 << 14 keys, we've extended this to 32
|
||||
// bytes as thats the size that apple uses
|
||||
key_modifier_table = new byte [32];
|
||||
}
|
||||
|
||||
internal KeyboardHandler (XplatUICarbon driver) : base (driver) {}
|
||||
|
||||
private bool ModifiersToVirtualKeys (UInt32 new_modifiers, ref MSG msg, out int vkey) {
|
||||
// TODO: X11 appears to only generate VK_SHIFT rather than VK_LSHIFT/VK_RSHIFT
|
||||
if ((new_modifiers & (uint)KeyboardModifiers.shiftKey) == (uint)KeyboardModifiers.shiftKey && ((modifiers & (uint)KeyboardModifiers.shiftKey) == 0)) {
|
||||
msg.message = Msg.WM_KEYDOWN;
|
||||
vkey = (int) VirtualKeys.VK_SHIFT;
|
||||
keys |= Keys.Shift;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.shiftKey) == 0 && ((modifiers & (uint)KeyboardModifiers.shiftKey) == (uint)KeyboardModifiers.shiftKey)) {
|
||||
msg.message = Msg.WM_KEYUP;
|
||||
vkey = (int) VirtualKeys.VK_SHIFT;
|
||||
keys &= ~Keys.Shift;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.rightShiftKey) == (uint)KeyboardModifiers.rightShiftKey && ((modifiers & (uint)KeyboardModifiers.rightShiftKey) == 0)) {
|
||||
msg.message = Msg.WM_KEYDOWN;
|
||||
vkey = (int) VirtualKeys.VK_SHIFT;
|
||||
keys |= Keys.Shift;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.rightShiftKey) == 0 && ((modifiers & (uint)KeyboardModifiers.rightShiftKey) == (uint)KeyboardModifiers.rightShiftKey)) {
|
||||
msg.message = Msg.WM_KEYUP;
|
||||
vkey = (int) VirtualKeys.VK_SHIFT;
|
||||
keys &= ~Keys.Shift;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.cmdKey) == (uint)KeyboardModifiers.cmdKey && ((modifiers & (uint)KeyboardModifiers.cmdKey) == 0)) {
|
||||
msg.message = Msg.WM_KEYDOWN;
|
||||
vkey = (int) VirtualKeys.VK_LWIN;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.cmdKey) == 0 && ((modifiers & (uint)KeyboardModifiers.cmdKey) == (uint)KeyboardModifiers.cmdKey)) {
|
||||
msg.message = Msg.WM_KEYUP;
|
||||
vkey = (int) VirtualKeys.VK_LWIN;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.optionKey) == (uint)KeyboardModifiers.optionKey && ((modifiers & (uint)KeyboardModifiers.optionKey) == 0)) {
|
||||
msg.message = Msg.WM_SYSKEYDOWN;
|
||||
private void ModifierToVirtualKey (int i, ref MSG msg, bool down) {
|
||||
msg.hwnd = XplatUICarbon.FocusWindow;
|
||||
|
||||
if (i == 9 || i == 13) {
|
||||
msg.message = (down ? Msg.WM_KEYDOWN : Msg.WM_KEYUP);
|
||||
msg.wParam = (IntPtr) VirtualKeys.VK_SHIFT;
|
||||
msg.lParam = IntPtr.Zero;
|
||||
return;
|
||||
}
|
||||
if (i == 12 || i == 14) {
|
||||
msg.message = (down ? Msg.WM_KEYDOWN : Msg.WM_KEYUP);
|
||||
msg.wParam = (IntPtr) VirtualKeys.VK_CONTROL;
|
||||
msg.lParam = IntPtr.Zero;
|
||||
return;
|
||||
}
|
||||
if (i == 8) {
|
||||
msg.message = (down ? Msg.WM_SYSKEYDOWN : Msg.WM_SYSKEYUP);
|
||||
msg.wParam = (IntPtr) VirtualKeys.VK_MENU;
|
||||
msg.lParam = new IntPtr (0x20000000);
|
||||
vkey = (int) VirtualKeys.VK_MENU;
|
||||
keys |= Keys.Alt;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.optionKey) == 0 && ((modifiers & (uint)KeyboardModifiers.optionKey) == (uint)KeyboardModifiers.optionKey)) {
|
||||
msg.message = Msg.WM_SYSKEYUP;
|
||||
vkey = (int) VirtualKeys.VK_MENU;
|
||||
keys &= ~Keys.Alt;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.controlKey) == (uint)KeyboardModifiers.controlKey && ((modifiers & (uint)KeyboardModifiers.controlKey) == 0)) {
|
||||
msg.message = Msg.WM_KEYDOWN;
|
||||
vkey = (int) VirtualKeys.VK_CONTROL;
|
||||
keys |= Keys.Control;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.controlKey) == 0 && ((modifiers & (uint)KeyboardModifiers.controlKey) == (uint)KeyboardModifiers.controlKey)) {
|
||||
msg.message = Msg.WM_KEYUP;
|
||||
vkey = (int) VirtualKeys.VK_CONTROL;
|
||||
keys &= ~Keys.Control;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.rightControlKey) == (uint)KeyboardModifiers.rightControlKey && ((modifiers & (uint)KeyboardModifiers.rightControlKey) == 0)) {
|
||||
msg.message = Msg.WM_KEYDOWN;
|
||||
vkey = (int) VirtualKeys.VK_CONTROL;
|
||||
keys |= Keys.Control;
|
||||
} else if ((new_modifiers & (uint)KeyboardModifiers.rightControlKey) == 0 && ((modifiers & (uint)KeyboardModifiers.rightControlKey) == (uint)KeyboardModifiers.rightControlKey)) {
|
||||
msg.message = Msg.WM_KEYUP;
|
||||
vkey = (int) VirtualKeys.VK_CONTROL;
|
||||
keys &= ~Keys.Control;
|
||||
} else {
|
||||
vkey = -1;
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CharCodeToVirtualKeys (byte charCode, out int vkey) {
|
||||
vkey = (int) charCode;
|
||||
switch (vkey) {
|
||||
case 28:
|
||||
vkey = (int) VirtualKeys.VK_LEFT;
|
||||
break;
|
||||
case 29:
|
||||
vkey = (int) VirtualKeys.VK_RIGHT;
|
||||
break;
|
||||
case 30:
|
||||
vkey = (int) VirtualKeys.VK_UP;
|
||||
break;
|
||||
case 31:
|
||||
vkey = (int) VirtualKeys.VK_DOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
public void ProcessModifiers (IntPtr eventref, ref MSG msg) {
|
||||
// we get notified when modifiers change, but not specifically what changed
|
||||
UInt32 modifiers = 0;
|
||||
|
||||
public bool ProcessEvent (IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg) {
|
||||
int vkey = -1;
|
||||
bool result = true;
|
||||
byte charCode = 0x0;
|
||||
UInt32 new_modifiers = 0;
|
||||
GetEventParameter (eventref, kEventParamKeyModifiers, typeUInt32, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (UInt32)), IntPtr.Zero, ref modifiers);
|
||||
|
||||
GetEventParameter (eventref, kEventParamKeyMacCharCodes, typeChar, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (byte)), IntPtr.Zero, ref charCode);
|
||||
GetEventParameter (eventref, kEventParamKeyModifiers, typeUInt32, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (UInt32)), IntPtr.Zero, ref new_modifiers);
|
||||
|
||||
switch (kind) {
|
||||
case kEventRawKeyDown:
|
||||
case kEventRawKeyRepeat:
|
||||
msg.message = Msg.WM_KEYDOWN;
|
||||
result = CharCodeToVirtualKeys (charCode, out vkey);
|
||||
break;
|
||||
case kEventRawKeyUp:
|
||||
msg.message = Msg.WM_KEYUP;
|
||||
result = CharCodeToVirtualKeys (charCode, out vkey);
|
||||
break;
|
||||
case kEventRawKeyModifiersChanged:
|
||||
result = ModifiersToVirtualKeys (new_modifiers, ref msg, out vkey);
|
||||
modifiers = new_modifiers;
|
||||
break;
|
||||
for (int i = 0; i < 32; i++) {
|
||||
if (key_modifier_table [i] == 0x01 && (modifiers & (1 << i)) == 0) {
|
||||
ModifierToVirtualKey (i, ref msg, false);
|
||||
key_modifier_table [i] = 0x00;
|
||||
return;
|
||||
} else if (key_modifier_table [i] == 0x00 && (modifiers & (1 << i)) == (1 << i)) {
|
||||
ModifierToVirtualKey (i, ref msg, true);
|
||||
key_modifier_table [i] = 0x01;
|
||||
return;
|
||||
}
|
||||
}
|
||||
msg.wParam = (IntPtr) vkey;
|
||||
|
||||
if (result) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void ProcessText (IntPtr eventref, ref MSG msg) {
|
||||
UInt32 size = 0;
|
||||
IntPtr buffer = IntPtr.Zero;
|
||||
byte [] bdata;
|
||||
|
||||
// get the size of the unicode buffer
|
||||
GetEventParameter (eventref, kEventParamTextInputSendText, typeUnicodeText, IntPtr.Zero, 0, ref size, IntPtr.Zero);
|
||||
|
||||
buffer = Marshal.AllocHGlobal ((int) size);
|
||||
bdata = new byte [size];
|
||||
|
||||
// get the actual text buffer
|
||||
GetEventParameter (eventref, kEventParamTextInputSendText, typeUnicodeText, IntPtr.Zero, size, IntPtr.Zero, buffer);
|
||||
|
||||
Marshal.Copy (buffer, bdata, 0, (int) size);
|
||||
Marshal.FreeHGlobal (buffer);
|
||||
|
||||
if (key_filter_table [bdata [0]] == 0x00) {
|
||||
// TODO: We support 2byte/4byte unicode? how does this get packed
|
||||
msg.message = Msg.WM_CHAR;
|
||||
msg.wParam = (IntPtr) bdata [0];
|
||||
msg.lParam = IntPtr.Zero;
|
||||
msg.hwnd = XplatUICarbon.FocusWindow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ProcessKeyPress (IntPtr eventref, ref MSG msg) {
|
||||
byte charCode = 0x0;
|
||||
byte keyCode = 0x0;
|
||||
|
||||
GetEventParameter (eventref, kEventParamKeyMacCharCodes, typeChar, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (byte)), IntPtr.Zero, ref charCode);
|
||||
GetEventParameter (eventref, kEventParamKeyCode, typeUInt32, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (byte)), IntPtr.Zero, ref keyCode);
|
||||
|
||||
msg.lParam = (IntPtr) charCode;
|
||||
msg.wParam = charCode == 0x10 ? (IntPtr) key_translation_table [keyCode] : (IntPtr) char_translation_table [charCode];
|
||||
msg.hwnd = XplatUICarbon.FocusWindow;
|
||||
}
|
||||
|
||||
public bool ProcessEvent (IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg) {
|
||||
uint klass = EventHandler.GetEventClass (eventref);
|
||||
bool result = true;
|
||||
|
||||
if (klass == EventHandler.kEventClassTextInput) {
|
||||
switch (kind) {
|
||||
case kEventTextInputUnicodeForKeyEvent:
|
||||
ProcessText (eventref, ref msg);
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine ("WARNING: KeyboardHandler.ProcessEvent default handler for kEventClassTextInput should not be reached");
|
||||
break;
|
||||
}
|
||||
} else if (klass == EventHandler.kEventClassKeyboard) {
|
||||
switch (kind) {
|
||||
case kEventRawKeyDown:
|
||||
case kEventRawKeyRepeat:
|
||||
msg.message = Msg.WM_KEYDOWN;
|
||||
ProcessKeyPress (eventref, ref msg);
|
||||
break;
|
||||
case kEventRawKeyUp:
|
||||
msg.message = Msg.WM_KEYUP;
|
||||
ProcessKeyPress (eventref, ref msg);
|
||||
break;
|
||||
case kEventRawKeyModifiersChanged:
|
||||
ProcessModifiers (eventref, ref msg);
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine ("WARNING: KeyboardHandler.ProcessEvent default handler for kEventClassKeyboard should not be reached");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Console.WriteLine ("WARNING: KeyboardHandler.ProcessEvent default handler for kEventClassTextInput should not be reached");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal bool TranslateMessage (ref MSG msg)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
public bool TranslateMessage (ref MSG msg) {
|
||||
bool res = false;
|
||||
|
||||
if (msg.message >= Msg.WM_KEYFIRST && msg.message <= Msg.WM_KEYLAST)
|
||||
res = true;
|
||||
|
||||
if (msg.message != Msg.WM_KEYDOWN && msg.message != Msg.WM_SYSKEYDOWN)
|
||||
|
||||
if (msg.message != Msg.WM_KEYDOWN && msg.message != Msg.WM_SYSKEYDOWN && msg.message != Msg.WM_KEYUP && msg.message != Msg.WM_SYSKEYUP && msg.message != Msg.WM_CHAR && msg.message != Msg.WM_SYSCHAR)
|
||||
return res;
|
||||
|
||||
Msg message = (msg.message == Msg.WM_KEYDOWN ? Msg.WM_CHAR : Msg.WM_SYSCHAR);
|
||||
XplatUI.PostMessage (msg.hwnd, message, msg.wParam, msg.lParam);
|
||||
|
||||
if (key_modifier_table [8] == 0x01 && key_modifier_table [12] == 0x00 && key_modifier_table [14] == 0x00) {
|
||||
if (msg.message == Msg.WM_KEYDOWN) {
|
||||
msg.message = Msg.WM_SYSKEYDOWN;
|
||||
} else if (msg.message == Msg.WM_CHAR) {
|
||||
msg.message = Msg.WM_SYSCHAR;
|
||||
translate_modifier = true;
|
||||
} else if (msg.message == Msg.WM_KEYUP) {
|
||||
msg.message = Msg.WM_SYSKEYUP;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
|
||||
msg.lParam = new IntPtr (0x20000000);
|
||||
} else if (msg.message == Msg.WM_SYSKEYUP && translate_modifier && msg.wParam == (IntPtr) 18) {
|
||||
msg.message = Msg.WM_KEYUP;
|
||||
|
||||
msg.lParam = IntPtr.Zero;
|
||||
translate_modifier = false;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
internal Keys ModifierKeys {
|
||||
get {
|
||||
Keys keys = Keys.None;
|
||||
if (key_modifier_table [9] == 0x01 || key_modifier_table [13] == 0x01) { keys |= Keys.Shift; }
|
||||
if (key_modifier_table [8] == 0x01) { keys |= Keys.Alt; }
|
||||
if (key_modifier_table [12] == 0x01 || key_modifier_table [14] == 0x01) { keys |= Keys.Control; }
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
|
||||
static extern int GetEventParameter (IntPtr eventref, uint name, uint type, IntPtr outtype, uint size, ref UInt32 outsize, IntPtr data);
|
||||
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
|
||||
static extern int GetEventParameter (IntPtr eventref, uint name, uint type, IntPtr outtype, uint size, IntPtr outsize, IntPtr data);
|
||||
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
|
||||
static extern int GetEventParameter (IntPtr eventref, uint name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref byte data);
|
||||
[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
|
||||
|
||||
@@ -117,6 +117,16 @@ namespace System.Windows.Forms.CarbonInternal {
|
||||
switch (kind) {
|
||||
case kEventWindowExpanding:
|
||||
case kEventWindowActivated:
|
||||
if (XplatUICarbon.FocusWindow == IntPtr.Zero) {
|
||||
Control c = Control.FromHandle (hwnd.client_window);
|
||||
if (c != null) {
|
||||
Form form = c.FindForm ();
|
||||
if (form != null) {
|
||||
Driver.SendMessage (form.Handle, Msg.WM_ACTIVATE, (IntPtr) WindowActiveFlags.WA_ACTIVE, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows) {
|
||||
if (utility_window != handle && !XplatUICarbon.IsWindowVisible (utility_window))
|
||||
XplatUICarbon.ShowWindow (utility_window);
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
internal class CategoryGridEntry : GridEntry
|
||||
{
|
||||
private string label;
|
||||
public CategoryGridEntry (PropertyGrid owner, string category)
|
||||
: base (owner)
|
||||
public CategoryGridEntry (PropertyGrid owner, string category, GridEntry parent)
|
||||
: base (owner, parent)
|
||||
{
|
||||
label = category;
|
||||
}
|
||||
@@ -55,5 +55,9 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
public override bool IsEditable {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool IsResetable {
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,254 @@
|
||||
2008-02-28 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* GridEntry.cs:
|
||||
- Use PropertyDescriptor.DisplayName instead of .Name for Label,
|
||||
so that DisplayNameAttribute doesn't get ignored.
|
||||
- Check for ParenthesizeNameAttribute and parenthesize the Label.
|
||||
- Add support for PasswordPropertyTextAttribute
|
||||
* PropertyGridView.cs: Check if an entry is a password.
|
||||
[Fixes bugs #365589, #365586, #365588]
|
||||
|
||||
2008-02-26 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* GridEntry.cs: Optimization in ToggleValue so that it caches
|
||||
the current value.
|
||||
* PropertyGridView.cs: An optimization so that the property isn't
|
||||
re-read twice for each StandardValue added to the drop-down menu.
|
||||
Patch by Andy Hume <[email protected]> under the MIT/X11
|
||||
license.
|
||||
[Fixes bug #362755]
|
||||
|
||||
2008-02-25 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* GridEntry.cs: Use the PropertyDescriptor.PropertyType instead
|
||||
of GetType on the value as it uses reflection to
|
||||
determine the type. This fixes the case where the new value is
|
||||
null.
|
||||
[Fixes #358332]
|
||||
|
||||
2008-02-25 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* PropertyGridView.cs: Limit mousewheel scrolling to not scroll
|
||||
past the view.
|
||||
|
||||
2008-02-20 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* PropertyGridView.cs: Fix a NRE when closing the drop down form.
|
||||
|
||||
2008-02-20 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* PropertyGridView.cs:
|
||||
- Fix a NRE that caused a test failure
|
||||
- Another performance improvement - cache the standard values
|
||||
listbox.
|
||||
|
||||
2008-02-19 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* PropertyGridView.cs: Fix a big performance bug.
|
||||
|
||||
2008-02-17 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* GridEntry.cs: Set expanded state before notifying that the
|
||||
expansion has taken place.
|
||||
* PropertyGridView.cs:
|
||||
- Set the propertygridtextbox text to the selected
|
||||
StandardValue before proceeding to setting it.
|
||||
- Scrolling bugfixes.
|
||||
|
||||
2008-02-16 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* GridEntry.cs:
|
||||
- Fix ValueText to not return null.
|
||||
- Fix conversion error reporting to actually happen.
|
||||
* PropertyGridView.cs: Set entry only if the text has changed.
|
||||
[Fixes bug #362116]
|
||||
|
||||
2008-02-16 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* GridEntry.cs:
|
||||
- Fix handling of a null current value.
|
||||
- Swallow editor exceptions.
|
||||
[Fixes bug #362114]
|
||||
|
||||
2008-02-16 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* PropertyGridTextBox.cs, PropertyGridView.cs: Explicitly send
|
||||
a mouse down event to the textbox so that we get the caret
|
||||
positioned under cursor.
|
||||
[Fixes bug #362119]
|
||||
|
||||
2008-02-16 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* PropertyGrid.cs: Clear current items first thing before
|
||||
repopulating subitems.
|
||||
* GridEntry.cs:
|
||||
- Handle null StandardValuesCollection.
|
||||
- Mark as not editable if there is no PropertyDescriptor and
|
||||
if the Converter cannot convert from string.
|
||||
[Part of fix for bugs #360666 and #358332]
|
||||
2008-02-15 Andreia Gaita <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* XplatUIX11.cs: If the handle is null when posting a message, use the
|
||||
current thread queue to post instead.
|
||||
[Fixes #332409]
|
||||
|
||||
* SendKeys.cs: Slight optimization
|
||||
|
||||
2008-02-14 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* PropertyGrid.cs, PropertyGridView.cs:
|
||||
Fix multiple scrolling and sizing issues.
|
||||
[Fixes bug #359199]
|
||||
|
||||
2008-02-12 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* PropertyGridView.cs: Ensure that drop down editors are shown
|
||||
in the WorkingArea of the screen.
|
||||
[Fixes bug #359807]
|
||||
|
||||
2008-02-12 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* GridEntry.cs: Fail silently when UITypeEditor is missing.
|
||||
[Fixes bug #360666]
|
||||
|
||||
2008-02-11 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* PropertyGridView.cs:
|
||||
- Clear the controls in the drop down form after it is hidden.
|
||||
- Fix Width sizing of the dropdown editors to match MSFT.
|
||||
|
||||
2008-02-11 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* PropertyGridView.cs:
|
||||
- Fix height for drawing the grid entry
|
||||
text value, so that it clips multiline text properly.
|
||||
- Fix unfocusing to match MSFT.
|
||||
* PropertyGrid.cs: Do not populate subgriditems unless expandable.
|
||||
Fixes a bug where on repopulation after value changed items become
|
||||
expandable.
|
||||
2008-02-08 Jonathan Pobst <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* Control.cs: Guard against an NRE in ShowFocusCues.
|
||||
[Fixes bug #359830]
|
||||
|
||||
2008-02-06 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* PropertyGridView.cs:
|
||||
- Refactor SetValue to allow setting the value
|
||||
when a custom editor is used, but the entry is not editable.
|
||||
- Remove the custom editor control on CloseDropDown.
|
||||
[Fixes #359196]
|
||||
|
||||
2008-02-06 Andreia Gaita <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* PrintControllerWithStatusDialog.cs: Set PrintFileName value through
|
||||
reflection only on 1.1, this property is public on system.drawing on 2.0.
|
||||
Fixed #359247
|
||||
|
||||
2008-02-05 Jonathan Pobst <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* Form.cs: If we change the active MDI child form, let the others
|
||||
know they need to repaint their title bar so it will appear inactive.
|
||||
[Fixes part 1 of bug #325473]
|
||||
|
||||
2008-02-05 Andreia Gaita <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* XplatUIWin32.cs, XplatUICarbon.cs: set the hwnd.Mapped flag when we create
|
||||
the window so that the check on Control.UpdateZOrderOfChild passes on non-X
|
||||
platforms. Fixes #359036
|
||||
|
||||
Note: Control.UpdateZOrderOfChild needs to be rewritten to not rely on
|
||||
platform-specific flags.
|
||||
|
||||
2008-02-05 Everaldo Canuto <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* MenuAPI.cs: Check if control is disposable when track popup menu. Thanks
|
||||
Jonathan for this patch. Fixes #358442.
|
||||
|
||||
2008-02-05 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* PropertyGridView.cs: Do not trucate custom editors' width
|
||||
and align them to the left.
|
||||
[Fixes #356527 and #358349]
|
||||
|
||||
2008-02-01 Jonathan Pobst <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* UpDownBase.cs: Make sure the internal textbox calls the base's
|
||||
OnMouseDown and OnMouseUp so the textbox will function correctly.
|
||||
There were notes saying it doesn't chain up, but its an internal
|
||||
class, so our implementation may differ.
|
||||
[Fixes bug #357482]
|
||||
|
||||
2008-02-01 Jonathan Pobst <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* Control.cs: Remove HeightInternal.
|
||||
* ListBox.cs: Commit patch from James Purcell that correctly
|
||||
calculates heights for ListBoxen.
|
||||
[Fixes bug #357152]
|
||||
|
||||
2008-02-01 Jonathan Pobst <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* Label.cs: Apply patch from James Purcell that corrects the
|
||||
signature of the AutoSize property.
|
||||
[Fixes bug #357605]
|
||||
|
||||
2008-02-04 Carlos Alberto Cortez <[email protected]>
|
||||
|
||||
[Backport to 1.9]
|
||||
* ListView.cs: In ItemControl.ItemsMouseMove, only fire ItemDrag event
|
||||
when the item in current position is different than 0. Also, save the
|
||||
item index in the beginning of the operation, instead of getting the
|
||||
index of the item when the event is actually performed. Lastly clean
|
||||
the related fields in ItemsMouseUp if the ItemDrag operation wasn't
|
||||
triggered.
|
||||
[Fixes #357873]
|
||||
|
||||
2008-02-04 Geoff Norton <[email protected]>
|
||||
|
||||
* LineTag.cs:
|
||||
* DataGriveViewCell.cs: More fixing the branch. bmp_g is the instance
|
||||
variable, call the appropriate Property instead.
|
||||
|
||||
2008-02-04 Geoff Norton <[email protected]>
|
||||
|
||||
* Control.cs: Fix the branch. bmp_g is the instance variable, call the
|
||||
appropriate Property instead.
|
||||
|
||||
2008-02-04 Geoff Norton <[email protected]>
|
||||
|
||||
* Hwnd.cs: [Backport] The conversion to Quartz coordinates happens in
|
||||
System.Drawing. Removing this translation from here.
|
||||
|
||||
2008-02-04 Ivan N. Zlatev <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* PropertyGrid.cs, PropertyGridView.cs, GridEntry.cs,
|
||||
CategoryGridEntry.cs, RootGridEntry.cs, GridItem.cs,
|
||||
GridItemCollection.cs:
|
||||
PropertyGrid backport.
|
||||
|
||||
2008-01-31 Jonathan Pobst <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* Control.cs: Remove my awesome optimization as it caused some
|
||||
regressions with control ordering. :(
|
||||
[Fixes bug #357467]
|
||||
|
||||
2008-01-31 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* PropertyGridView.cs: Fix a NRE on double click when there is no
|
||||
selected object.
|
||||
|
||||
2008-01-28 Jonathan Pobst <[email protected]>
|
||||
|
||||
* TableLayoutPanel.cs: Draw the table border at 0,0 instead of
|
||||
|
||||
@@ -1323,7 +1323,7 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
internal Graphics DeviceContext {
|
||||
get { return Hwnd.bmp_g; }
|
||||
get { return Hwnd.GraphicsContext; }
|
||||
}
|
||||
|
||||
private void ProcessActiveTracker (ref Message m)
|
||||
@@ -2856,11 +2856,6 @@ namespace System.Windows.Forms
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public int Height {
|
||||
get { return HeightInternal; }
|
||||
set { HeightInternal = value; }
|
||||
}
|
||||
|
||||
internal virtual int HeightInternal {
|
||||
get { return this.bounds.Height; }
|
||||
set { SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height); }
|
||||
}
|
||||
@@ -3571,7 +3566,12 @@ namespace System.Windows.Forms
|
||||
if (this.parent == null)
|
||||
return false;
|
||||
|
||||
return this.FindForm ().show_focus_cues;
|
||||
Form f = this.FindForm ();
|
||||
|
||||
if (f != null)
|
||||
return f.show_focus_cues;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5630,15 +5630,14 @@ namespace System.Windows.Forms
|
||||
Control [] controls = child_controls.GetAllControls ();
|
||||
bool parented = false;
|
||||
for (int i=0; i<controls.Length; i++) {
|
||||
if (controls [i].is_visible && controls[i].IsHandleCreated)
|
||||
if (XplatUI.GetParent (controls[i].Handle) != window.Handle) {
|
||||
XplatUI.SetParent(controls[i].Handle, window.Handle);
|
||||
parented = true;
|
||||
if (controls [i].is_visible && controls[i].IsHandleCreated) {
|
||||
XplatUI.SetParent(controls[i].Handle, window.Handle);
|
||||
parented = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (parented)
|
||||
if (parented) {
|
||||
UpdateChildrenZOrder ();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace System.Windows.Forms {
|
||||
if (DataGridView == null)
|
||||
return Size.Empty;
|
||||
|
||||
return GetPreferredSize (Hwnd.bmp_g, InheritedStyle, RowIndex, Size.Empty);
|
||||
return GetPreferredSize (Hwnd.GraphicsContext, InheritedStyle, RowIndex, Size.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ namespace System.Windows.Forms {
|
||||
if (DataGridView == null)
|
||||
return Rectangle.Empty;
|
||||
|
||||
return GetContentBounds (Hwnd.bmp_g, InheritedStyle, rowIndex);
|
||||
return GetContentBounds (Hwnd.GraphicsContext, InheritedStyle, rowIndex);
|
||||
}
|
||||
|
||||
public object GetEditedFormattedValue (int rowIndex, DataGridViewDataErrorContexts context) {
|
||||
|
||||
@@ -1976,6 +1976,12 @@ namespace System.Windows.Forms {
|
||||
|
||||
wm = window_manager as MdiWindowManager;
|
||||
wm.RaiseActivated ();
|
||||
|
||||
// We need to tell everyone who may have just been deactivated to redraw their titlebar
|
||||
if (MdiParent != null)
|
||||
foreach (Form form in MdiParent.MdiChildren)
|
||||
if (form != this && form.IsHandleCreated)
|
||||
XplatUI.InvalidateNC (form.Handle);
|
||||
}
|
||||
|
||||
if (window_state != FormWindowState.Normal) {
|
||||
|
||||
@@ -44,14 +44,13 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
private bool expanded;
|
||||
private GridItemCollection grid_items;
|
||||
private GridItem parent;
|
||||
private PropertyDescriptor property_descriptor;
|
||||
private object[] property_owners;
|
||||
private PropertyDescriptor[] property_descriptors;
|
||||
private int top;
|
||||
private Rectangle plus_minus_bounds;
|
||||
#endregion // Local Variables
|
||||
|
||||
#region Contructors
|
||||
protected GridEntry (PropertyGrid propertyGrid)
|
||||
protected GridEntry (PropertyGrid propertyGrid, GridEntry parent)
|
||||
{
|
||||
if (propertyGrid == null)
|
||||
throw new ArgumentNullException ("propertyGrid");
|
||||
@@ -60,20 +59,22 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
top = -1;
|
||||
grid_items = new GridItemCollection ();
|
||||
expanded = false;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public GridEntry (PropertyGrid propertyGrid, object[] propertyOwners, PropertyDescriptor prop_desc) : this (propertyGrid)
|
||||
// Cannot use one PropertyDescriptor for all owners, because the
|
||||
// propertydescriptors might have different Invokees. Check
|
||||
// ReflectionPropertyDescriptor.GetInvokee and how it's used.
|
||||
//
|
||||
public GridEntry (PropertyGrid propertyGrid, PropertyDescriptor[] properties,
|
||||
GridEntry parent) : this (propertyGrid, parent)
|
||||
{
|
||||
if (propertyOwners == null)
|
||||
throw new ArgumentNullException ("propertyOwners");
|
||||
if (prop_desc == null)
|
||||
if (properties == null || properties.Length == 0)
|
||||
throw new ArgumentNullException ("prop_desc");
|
||||
property_owners = propertyOwners;
|
||||
property_descriptor = prop_desc;
|
||||
property_descriptors = properties;
|
||||
}
|
||||
#endregion // Constructors
|
||||
|
||||
#region Public Instance Properties
|
||||
|
||||
public override bool Expandable {
|
||||
get { return grid_items.Count > 0; }
|
||||
@@ -83,11 +84,11 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
get { return expanded; }
|
||||
set {
|
||||
if (expanded != value) {
|
||||
expanded = value;
|
||||
if (value)
|
||||
property_grid.OnExpandItem (this);
|
||||
else
|
||||
property_grid.OnCollapseItem (this);
|
||||
expanded = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,55 +102,141 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
}
|
||||
|
||||
public override string Label {
|
||||
get { return property_descriptor.Name; }
|
||||
get {
|
||||
PropertyDescriptor property = this.PropertyDescriptor;
|
||||
if (property != null) {
|
||||
string label = property.DisplayName;
|
||||
ParenthesizePropertyNameAttribute parensAttr =
|
||||
property.Attributes[typeof (ParenthesizePropertyNameAttribute)] as ParenthesizePropertyNameAttribute;
|
||||
if (parensAttr != null && parensAttr.NeedParenthesis)
|
||||
label = "(" + label + ")";
|
||||
return label;
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public override GridItem Parent {
|
||||
get { return parent; }
|
||||
}
|
||||
|
||||
public GridEntry ParentEntry {
|
||||
get {
|
||||
if (parent != null && parent.GridItemType == GridItemType.Category)
|
||||
return parent.Parent as GridEntry;
|
||||
return parent as GridEntry;
|
||||
}
|
||||
}
|
||||
|
||||
public override PropertyDescriptor PropertyDescriptor {
|
||||
get { return property_descriptor; }
|
||||
get { return property_descriptors != null ? property_descriptors[0] : null; }
|
||||
}
|
||||
|
||||
public PropertyDescriptor[] PropertyDescriptors {
|
||||
get { return property_descriptors; }
|
||||
}
|
||||
|
||||
public object PropertyOwner {
|
||||
get {
|
||||
object[] owners = PropertyOwners;
|
||||
if (owners != null)
|
||||
return owners[0];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public object[] PropertyOwners {
|
||||
get {
|
||||
if (ParentEntry != null)
|
||||
return ParentEntry.Values;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// true if the value is the same among all properties
|
||||
public bool HasMergedValue {
|
||||
get {
|
||||
if (!IsMerged)
|
||||
return false;
|
||||
|
||||
object[] values = this.Values;
|
||||
for (int i=0; i+1 < values.Length; i++) {
|
||||
if (!Object.Equals (values[i], values[i+1]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsMerged {
|
||||
get { return (PropertyDescriptors != null && PropertyDescriptors.Length > 1); }
|
||||
}
|
||||
|
||||
// If IsMerged this will return all values for all properties in all owners
|
||||
public virtual object[] Values {
|
||||
get {
|
||||
if (PropertyDescriptor == null || this.PropertyOwners == null)
|
||||
return null;
|
||||
if (IsMerged) {
|
||||
object[] owners = this.PropertyOwners;
|
||||
PropertyDescriptor[] properties = PropertyDescriptors;
|
||||
object[] values = new object[owners.Length];
|
||||
for (int i=0; i < owners.Length; i++)
|
||||
values[i] = properties[i].GetValue (owners[i]);
|
||||
return values;
|
||||
} else {
|
||||
return new object[] { this.Value };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the first value for the first propertyowner and propertydescriptor
|
||||
//
|
||||
public override object Value {
|
||||
get {
|
||||
if (property_owners == null || property_owners.Length == 0 || property_descriptor == null)
|
||||
if (PropertyDescriptor == null || PropertyOwner == null)
|
||||
return null;
|
||||
|
||||
object v = property_descriptor.GetValue (property_owners[0]);
|
||||
for (int i = 1; i < property_owners.Length; i ++) {
|
||||
if (!Object.Equals (v, property_descriptor.GetValue (property_owners[i])))
|
||||
return null;
|
||||
return PropertyDescriptor.GetValue (PropertyOwner);
|
||||
}
|
||||
}
|
||||
|
||||
public string ValueText {
|
||||
get {
|
||||
string text = null;
|
||||
try {
|
||||
text = ConvertToString (this.Value);
|
||||
if (text == null)
|
||||
text = String.Empty;
|
||||
} catch {
|
||||
text = String.Empty;
|
||||
}
|
||||
|
||||
return v;
|
||||
return text;
|
||||
}
|
||||
}
|
||||
#endregion // Public Instance Properties
|
||||
|
||||
#region Public Instance Methods
|
||||
public override bool Select ()
|
||||
{
|
||||
property_grid.SelectedGridItem = this;
|
||||
return true;
|
||||
}
|
||||
#endregion // Public Instance Methods
|
||||
|
||||
#region ITypeDescriptorContext
|
||||
void ITypeDescriptorContext.OnComponentChanged () {
|
||||
void ITypeDescriptorContext.OnComponentChanged ()
|
||||
{
|
||||
}
|
||||
|
||||
bool ITypeDescriptorContext.OnComponentChanging () {
|
||||
bool ITypeDescriptorContext.OnComponentChanging ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IContainer ITypeDescriptorContext.Container {
|
||||
get {
|
||||
if (property_owners != null && property_owners.Length > 0 && property_descriptor == null)
|
||||
if (PropertyOwner == null)
|
||||
return null;
|
||||
|
||||
IComponent component = property_owners[0] as IComponent;
|
||||
IComponent component = property_grid.SelectedObject as IComponent;
|
||||
if (component != null && component.Site != null)
|
||||
return component.Site.Container;
|
||||
return null;
|
||||
@@ -157,11 +244,11 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
}
|
||||
|
||||
object ITypeDescriptorContext.Instance {
|
||||
get { return property_owners[0]; }
|
||||
get { return PropertyOwner; }
|
||||
}
|
||||
|
||||
PropertyDescriptor ITypeDescriptorContext.PropertyDescriptor {
|
||||
get { return property_descriptor; }
|
||||
get { return PropertyDescriptor; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -176,11 +263,6 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
|
||||
#endregion
|
||||
|
||||
public object[] PropertyOwners {
|
||||
get { return property_owners; }
|
||||
set { property_owners = value; }
|
||||
}
|
||||
|
||||
internal int Top {
|
||||
get { return top; }
|
||||
set {
|
||||
@@ -199,20 +281,19 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public string ValueString {
|
||||
get { return ConvertToString (this.Value); }
|
||||
}
|
||||
|
||||
public ICollection AcceptedValues {
|
||||
get {
|
||||
if (property_descriptor != null && property_descriptor.Converter != null &&
|
||||
property_descriptor.Converter.GetStandardValuesSupported ()) {
|
||||
if (PropertyDescriptor != null && PropertyDescriptor.Converter != null &&
|
||||
PropertyDescriptor.Converter.GetStandardValuesSupported ()) {
|
||||
ArrayList values = new ArrayList ();
|
||||
string stringVal = null;
|
||||
foreach (object value in property_descriptor.Converter.GetStandardValues ()) {
|
||||
stringVal = ConvertToString (value);
|
||||
if (stringVal != null)
|
||||
values.Add (stringVal);
|
||||
ICollection standardValues = PropertyDescriptor.Converter.GetStandardValues ();
|
||||
if (standardValues != null) {
|
||||
foreach (object value in standardValues) {
|
||||
stringVal = ConvertToString (value);
|
||||
if (stringVal != null)
|
||||
values.Add (stringVal);
|
||||
}
|
||||
}
|
||||
return values.Count > 0 ? values : null;
|
||||
}
|
||||
@@ -220,18 +301,18 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
private string ConvertToString (object value)
|
||||
{
|
||||
if (value is string)
|
||||
return (string)value;
|
||||
|
||||
if (property_descriptor != null && property_descriptor.Converter != null &&
|
||||
property_descriptor.Converter.CanConvertTo (typeof (string))) {
|
||||
if (PropertyDescriptor != null && PropertyDescriptor.Converter != null &&
|
||||
PropertyDescriptor.Converter.CanConvertTo (typeof (string))) {
|
||||
try {
|
||||
return property_descriptor.Converter.ConvertToString (value);
|
||||
return PropertyDescriptor.Converter.ConvertToString (value);
|
||||
} catch {
|
||||
// TODO
|
||||
// XXX: Happens too often...
|
||||
// property_grid.ShowError ("Property value of '" + property_descriptor.Name + "' is not convertible to string.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -246,8 +327,13 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
public UITypeEditorEditStyle EditorStyle {
|
||||
get {
|
||||
UITypeEditor editor = GetEditor ();
|
||||
if (editor != null)
|
||||
return editor.GetEditStyle ((ITypeDescriptorContext)this);
|
||||
if (editor != null) {
|
||||
try {
|
||||
return editor.GetEditStyle ((ITypeDescriptorContext)this);
|
||||
} catch {
|
||||
// Some of our Editors throw NotImplementedException
|
||||
}
|
||||
}
|
||||
return UITypeEditorEditStyle.None;
|
||||
}
|
||||
}
|
||||
@@ -273,9 +359,10 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
object value = editor.EditValue ((ITypeDescriptorContext)this,
|
||||
container,
|
||||
this.Value);
|
||||
return SetValue (value);
|
||||
} catch {
|
||||
// TODO
|
||||
string error = null;
|
||||
return SetValue (value, out error);
|
||||
} catch { //(Exception e) {
|
||||
// property_grid.ShowError (e.Message + Environment.NewLine + e.StackTrace);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -283,11 +370,11 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
|
||||
private UITypeEditor GetEditor ()
|
||||
{
|
||||
if (property_descriptor != null) {
|
||||
if (PropertyDescriptor != null) {
|
||||
try { // can happen, because we are missing some editors
|
||||
return property_descriptor.GetEditor (typeof (UITypeEditor)) as UITypeEditor;
|
||||
return PropertyDescriptor.GetEditor (typeof (UITypeEditor)) as UITypeEditor;
|
||||
} catch {
|
||||
// TODO
|
||||
// property_grid.ShowError ("Unable to load UITypeEditor for property '" + PropertyDescriptor.Name + "'.");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -295,71 +382,136 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
|
||||
public bool ToggleValue ()
|
||||
{
|
||||
if (IsReadOnly)
|
||||
if (IsReadOnly || (IsMerged && !HasMergedValue))
|
||||
return false;
|
||||
|
||||
bool success = false;
|
||||
if (property_descriptor.PropertyType == typeof(bool))
|
||||
success = SetValue (!(bool)this.Value);
|
||||
else if (property_descriptor.Converter != null &&
|
||||
property_descriptor.Converter.GetStandardValuesSupported ()) {
|
||||
string error = null;
|
||||
object value = this.Value;
|
||||
if (PropertyDescriptor.PropertyType == typeof(bool))
|
||||
success = SetValue (!(bool)value, out error);
|
||||
else if (PropertyDescriptor.Converter != null &&
|
||||
PropertyDescriptor.Converter.GetStandardValuesSupported ()) {
|
||||
TypeConverter.StandardValuesCollection values =
|
||||
(TypeConverter.StandardValuesCollection) property_descriptor.Converter.GetStandardValues();
|
||||
for (int i = 0; i < values.Count; i++) {
|
||||
if (this.Value.Equals (values[i])){
|
||||
if (i < values.Count-1)
|
||||
success = SetValue (values[i+1]);
|
||||
else
|
||||
success = SetValue (values[0]);
|
||||
break;
|
||||
(TypeConverter.StandardValuesCollection) PropertyDescriptor.Converter.GetStandardValues();
|
||||
if (values != null) {
|
||||
for (int i = 0; i < values.Count; i++) {
|
||||
if (value != null && value.Equals (values[i])){
|
||||
if (i < values.Count-1)
|
||||
success = SetValue (values[i+1], out error);
|
||||
else
|
||||
success = SetValue (values[0], out error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!success && error != null)
|
||||
property_grid.ShowError (error);
|
||||
return success;
|
||||
}
|
||||
|
||||
public bool SetValue (object value)
|
||||
public bool SetValue (object value, out string error)
|
||||
{
|
||||
if (property_descriptor == null)
|
||||
error = null;
|
||||
if (this.IsReadOnly)
|
||||
return false;
|
||||
|
||||
if (SetValueCore (value, out error)) {
|
||||
property_grid.OnPropertyValueChangedInternal (this, this.Value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual bool SetValueCore (object value, out string error)
|
||||
{
|
||||
error = null;
|
||||
|
||||
TypeConverter converter = PropertyDescriptor.Converter;
|
||||
Type valueType = value != null ? value.GetType () : null;
|
||||
// if the new value is not of the same type try to convert it
|
||||
if (value != null && this.Value != null && value.GetType () != this.Value.GetType ()) {
|
||||
if (property_descriptor.Converter != null &&
|
||||
property_descriptor.Converter.CanConvertFrom (value.GetType ())) {
|
||||
try {
|
||||
value = property_descriptor.Converter.ConvertFrom (value);
|
||||
} catch {
|
||||
// TODO
|
||||
if (valueType != this.PropertyDescriptor.PropertyType) {
|
||||
bool conversionError = false;
|
||||
try {
|
||||
if (converter != null &&
|
||||
converter.CanConvertFrom (valueType))
|
||||
value = converter.ConvertFrom (value);
|
||||
else
|
||||
conversionError = true;
|
||||
} catch {
|
||||
conversionError = true;
|
||||
}
|
||||
if (conversionError) {
|
||||
string valueText = ConvertToString (value);
|
||||
if (valueText != null) {
|
||||
error = "Property value '" + valueText + "' of '" +
|
||||
PropertyDescriptor.Name + "' is not convertible to type '" +
|
||||
this.PropertyDescriptor.PropertyType.Name + "'";
|
||||
|
||||
} else {
|
||||
error = "Property value of '" +
|
||||
PropertyDescriptor.Name + "' is not convertible to type '" +
|
||||
this.PropertyDescriptor.PropertyType.Name + "'";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
foreach (object propertyOwner in property_owners) {
|
||||
object currentVal = property_descriptor.GetValue (propertyOwner);
|
||||
bool current_changed = false;
|
||||
object[] propertyOwners = this.PropertyOwners;
|
||||
PropertyDescriptor[] properties = PropertyDescriptors;
|
||||
for (int i=0; i < propertyOwners.Length; i++) {
|
||||
object currentVal = properties[i].GetValue (propertyOwners[i]);
|
||||
current_changed = false;
|
||||
if (!Object.Equals (currentVal, value)) {
|
||||
try {
|
||||
property_descriptor.SetValue (propertyOwner, value);
|
||||
} catch {
|
||||
// TODO
|
||||
}
|
||||
if (IsValueType (this.Parent))
|
||||
((GridEntry) this.Parent).SetValue (propertyOwner);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (this.ShouldCreateParentInstance) {
|
||||
Hashtable updatedParentProperties = new Hashtable ();
|
||||
PropertyDescriptorCollection parentProperties = TypeDescriptor.GetProperties (propertyOwners[i]);
|
||||
foreach (PropertyDescriptor property in parentProperties) {
|
||||
if (property.Name == properties[i].Name)
|
||||
updatedParentProperties[property.Name] = value;
|
||||
else
|
||||
updatedParentProperties[property.Name] = property.GetValue (propertyOwners[i]);
|
||||
}
|
||||
object updatedParentValue = this.ParentEntry.PropertyDescriptor.Converter.CreateInstance (updatedParentProperties);
|
||||
if (updatedParentValue != null)
|
||||
current_changed = this.ParentEntry.SetValueCore (updatedParentValue, out error);
|
||||
} else {
|
||||
try {
|
||||
properties[i].SetValue (propertyOwners[i], value);
|
||||
} catch {
|
||||
// MS seems to swallow this
|
||||
//
|
||||
// string valueText = ConvertToString (value);
|
||||
// if (valueText != null)
|
||||
// error = "Property value '" + valueText + "' of '" + properties[i].Name + "' is invalid.";
|
||||
// else
|
||||
// error = "Property value of '" + properties[i].Name + "' is invalid.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
property_grid.OnPropertyValueChangedInternal (this, this.Value);
|
||||
if (IsValueType (this.ParentEntry))
|
||||
current_changed = ParentEntry.SetValueCore (propertyOwners[i], out error);
|
||||
else
|
||||
current_changed = Object.Equals (properties[i].GetValue (propertyOwners[i]), value);
|
||||
}
|
||||
// restore original value if doesn't get set
|
||||
if (!current_changed && !PropertyDescriptor.IsReadOnly)
|
||||
properties[i].SetValue (propertyOwners[i], currentVal);
|
||||
}
|
||||
if (current_changed)
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private bool IsValueType (GridItem item)
|
||||
private bool IsValueType (GridEntry item)
|
||||
{
|
||||
if (item != null && item.PropertyDescriptor != null &&
|
||||
(item.PropertyDescriptor.PropertyType.IsValueType ||
|
||||
item.PropertyDescriptor.PropertyType.IsArray))
|
||||
item.PropertyDescriptor.PropertyType.IsPrimitive))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -367,15 +519,36 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
public bool ResetValue ()
|
||||
{
|
||||
if (IsResetable) {
|
||||
property_descriptor.ResetValue (property_owners[0]);
|
||||
object[] owners = this.PropertyOwners;
|
||||
PropertyDescriptor[] properties = PropertyDescriptors;
|
||||
for (int i=0; i < owners.Length; i++) {
|
||||
properties[i].ResetValue (owners[i]);
|
||||
if (IsValueType (this.ParentEntry)) {
|
||||
string error = null;
|
||||
if (!ParentEntry.SetValueCore (owners[i], out error) && error != null)
|
||||
property_grid.ShowError (error);
|
||||
}
|
||||
}
|
||||
property_grid.OnPropertyValueChangedInternal (this, this.Value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasDefaultValue {
|
||||
get {
|
||||
if (PropertyDescriptor != null &&
|
||||
PropertyDescriptor.Attributes[typeof (DefaultValueAttribute)] != null)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Determines if the current value can be reset
|
||||
//
|
||||
public virtual bool IsResetable {
|
||||
get { return (!IsReadOnly && property_descriptor.CanResetValue (property_owners[0])); }
|
||||
get { return (!IsReadOnly && PropertyDescriptor.CanResetValue (PropertyOwner)); }
|
||||
|
||||
}
|
||||
|
||||
// If false the entry can be modified only by the means of a predefined values
|
||||
@@ -383,12 +556,17 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
//
|
||||
public virtual bool IsEditable {
|
||||
get {
|
||||
if (property_descriptor == null || property_descriptor.IsReadOnly)
|
||||
if (PropertyDescriptor == null)
|
||||
return false;
|
||||
else if (property_descriptor.Converter == null)
|
||||
else if (PropertyDescriptor.PropertyType.IsArray)
|
||||
return false;
|
||||
else if (property_descriptor.Converter.GetStandardValuesSupported () &&
|
||||
property_descriptor.Converter.GetStandardValuesExclusive ())
|
||||
else if (PropertyDescriptor.IsReadOnly && this.ShouldCreateParentInstance)
|
||||
return true;
|
||||
else if (PropertyDescriptor.Converter == null ||
|
||||
!PropertyDescriptor.Converter.CanConvertFrom (this, typeof (string)))
|
||||
return false;
|
||||
else if (PropertyDescriptor.Converter.GetStandardValuesSupported () &&
|
||||
PropertyDescriptor.Converter.GetStandardValuesExclusive ())
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@@ -399,25 +577,72 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
//
|
||||
public virtual bool IsReadOnly {
|
||||
get {
|
||||
if (property_descriptor == null || property_descriptor.IsReadOnly)
|
||||
// if (PropertyDescriptor != null) {
|
||||
// Console.WriteLine ("=== [" + PropertyDescriptor.Name + "]");
|
||||
// Console.WriteLine ("PropertyDescriptor.IsReadOnly: " + PropertyDescriptor.IsReadOnly);
|
||||
// Console.WriteLine ("Editor: " + (GetEditor () == null ? "none" : GetEditor ().GetType ().Name));
|
||||
// Console.WriteLine ("Converter: " + (PropertyDescriptor.Converter == null ? "none" : PropertyDescriptor.Converter.GetType ().Name));
|
||||
// Console.WriteLine ("Converter.GetStandardValuesSupported: " + PropertyDescriptor.Converter.GetStandardValuesSupported ().ToString ());
|
||||
// Console.WriteLine ("Converter.GetStandardValuesExclusive: " + PropertyDescriptor.Converter.GetStandardValuesExclusive ().ToString ());
|
||||
// Console.WriteLine ("ShouldCreateParentInstance: " + this.ShouldCreateParentInstance);
|
||||
// Console.WriteLine ("CanConvertFrom (string): " + PropertyDescriptor.Converter.CanConvertFrom ((ITypeDescriptorContext)this, typeof (string)));
|
||||
// Console.WriteLine ("IsArray: " + PropertyDescriptor.PropertyType.IsArray.ToString ());
|
||||
// }
|
||||
if (PropertyDescriptor == null || PropertyOwner == null ||
|
||||
(PropertyDescriptor.IsReadOnly && !this.ShouldCreateParentInstance))
|
||||
return true;
|
||||
else if (GetEditor() == null && property_descriptor.Converter == null)
|
||||
else if (!HasCustomEditor && PropertyDescriptor.Converter == null)
|
||||
return true;
|
||||
else if (!property_descriptor.Converter.GetStandardValuesSupported () &&
|
||||
!property_descriptor.Converter.CanConvertFrom ((ITypeDescriptorContext)this,
|
||||
typeof (string)) &&
|
||||
this.EditorStyle == UITypeEditorEditStyle.None) {
|
||||
else if (PropertyDescriptor.Converter != null &&
|
||||
!PropertyDescriptor.Converter.GetStandardValuesSupported () &&
|
||||
!PropertyDescriptor.Converter.CanConvertFrom ((ITypeDescriptorContext)this,
|
||||
typeof (string)) &&
|
||||
!HasCustomEditor) {
|
||||
return true;
|
||||
} else
|
||||
} else if (PropertyDescriptor.PropertyType.IsArray && !HasCustomEditor)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPassword {
|
||||
get {
|
||||
#if NET_2_0
|
||||
if (PropertyDescriptor != null)
|
||||
return PropertyDescriptor.Attributes.Contains (PasswordPropertyTextAttribute.Yes);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// This is a way to set readonly properties (e.g properties without a setter).
|
||||
// The way it works is that if CreateInstance is supported by the parent's converter
|
||||
// it gets passed a list of properties and their values which it uses to create an
|
||||
// instance (e.g by passing them to the ctor of that object type).
|
||||
//
|
||||
// This is used for e.g Font
|
||||
//
|
||||
public virtual bool ShouldCreateParentInstance {
|
||||
get {
|
||||
if (this.ParentEntry != null && ParentEntry.PropertyDescriptor != null) {
|
||||
TypeConverter parentConverter = Parent.PropertyDescriptor.Converter;
|
||||
if (parentConverter != null && parentConverter.GetCreateInstanceSupported ((ITypeDescriptorContext)this))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool PaintValueSupported {
|
||||
get {
|
||||
|
||||
UITypeEditor editor = GetEditor ();
|
||||
if (editor != null)
|
||||
return editor.GetPaintValueSupported ();
|
||||
if (editor != null) {
|
||||
try {
|
||||
return editor.GetPaintValueSupported ();
|
||||
} catch {
|
||||
// Some of our Editors throw NotImplementedException
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -429,7 +654,7 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
try {
|
||||
editor.PaintValue (this.Value, gfx, rect);
|
||||
} catch {
|
||||
// TODO
|
||||
// Some of our Editors throw NotImplementedException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,29 +67,29 @@ namespace System.Windows.Forms
|
||||
}
|
||||
}
|
||||
|
||||
public abstract new GridItemCollection GridItems
|
||||
public abstract GridItemCollection GridItems
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public abstract new GridItemType GridItemType
|
||||
public abstract GridItemType GridItemType
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public abstract new string Label
|
||||
public abstract string Label
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
|
||||
public abstract new GridItem Parent
|
||||
public abstract GridItem Parent
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
|
||||
public abstract new PropertyDescriptor PropertyDescriptor
|
||||
public abstract PropertyDescriptor PropertyDescriptor
|
||||
{
|
||||
get;
|
||||
}
|
||||
@@ -105,14 +105,14 @@ namespace System.Windows.Forms
|
||||
}
|
||||
#endif
|
||||
|
||||
public abstract new object Value
|
||||
public abstract object Value
|
||||
{
|
||||
get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Instance Methods
|
||||
public abstract new bool Select ();
|
||||
public abstract bool Select ();
|
||||
#endregion // Public Instance Methods
|
||||
}
|
||||
}
|
||||
@@ -49,15 +49,26 @@ namespace System.Windows.Forms
|
||||
#endregion // Constructors
|
||||
|
||||
#region Internal Properties and Methods
|
||||
internal void Add(string key, GridItem grid_item)
|
||||
internal void Add(GridItem grid_item)
|
||||
{
|
||||
list.Add(key,grid_item);
|
||||
list.Add (grid_item.Label, grid_item);
|
||||
}
|
||||
|
||||
internal void AddRange (GridItemCollection items)
|
||||
{
|
||||
foreach (GridItem item in items)
|
||||
Add (item);
|
||||
}
|
||||
|
||||
internal int IndexOf (GridItem grid_item)
|
||||
{
|
||||
return list.IndexOfValue (grid_item);
|
||||
}
|
||||
|
||||
internal void Remove (string key)
|
||||
{
|
||||
list.Remove (key);
|
||||
}
|
||||
#endregion // Internal Properties and Methods
|
||||
|
||||
#region Public Instance Properties
|
||||
@@ -146,14 +157,6 @@ namespace System.Windows.Forms
|
||||
|
||||
internal void Clear ()
|
||||
{
|
||||
for (int i = 0; i < list.Count; i++) {
|
||||
GridEntry grid_entry = list.GetByIndex (i) as GridEntry;
|
||||
if (grid_entry == null || grid_entry.Parent == null)
|
||||
continue;
|
||||
|
||||
grid_entry.SetParent (null);
|
||||
}
|
||||
|
||||
list.Clear ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +76,6 @@ namespace System.Windows.Forms {
|
||||
internal bool fixed_size;
|
||||
internal bool zombie; /* X11 only flag. true if the X windows have been destroyed but we haven't been Disposed */
|
||||
internal Region user_clip;
|
||||
internal static Bitmap bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
internal static Graphics bmp_g = Graphics.FromImage (bmp);
|
||||
internal XEventQueue queue;
|
||||
internal WindowExStyles initial_ex_style;
|
||||
internal WindowStyles initial_style;
|
||||
@@ -85,6 +83,11 @@ namespace System.Windows.Forms {
|
||||
internal Point previous_child_startup_location = new Point (int.MinValue, int.MinValue);
|
||||
static internal Point previous_main_startup_location = new Point (int.MinValue, int.MinValue);
|
||||
internal ArrayList children;
|
||||
|
||||
[ThreadStatic]
|
||||
private static Bitmap bmp;
|
||||
[ThreadStatic]
|
||||
private static Graphics bmp_g;
|
||||
#endregion // Local Variables
|
||||
|
||||
// locks for some operations (used in XplatUIX11.cs)
|
||||
@@ -282,6 +285,15 @@ namespace System.Windows.Forms {
|
||||
{
|
||||
ArrayList masks = new ArrayList ();
|
||||
|
||||
if (x < 0) {
|
||||
masks.Add (new Rectangle (0, 0, x*-1, Height));
|
||||
if (y < 0) {
|
||||
masks.Add (new Rectangle (x*-1, 0, Width, y*-1));
|
||||
}
|
||||
} else if (y < 0) {
|
||||
masks.Add (new Rectangle (0, 0, Width, y*-1));
|
||||
}
|
||||
|
||||
foreach (Hwnd child in children) {
|
||||
if (child.visible)
|
||||
masks.Add (new Rectangle (child.X, child.Y, child.Width, child.Height));
|
||||
@@ -312,8 +324,7 @@ namespace System.Windows.Forms {
|
||||
|
||||
intersect.X -= X;
|
||||
intersect.Y -= Y;
|
||||
intersect.Y = parent.Height - intersect.Y - intersect.Height;
|
||||
|
||||
|
||||
masks.Add (intersect);
|
||||
}
|
||||
} while (sibling_handle != IntPtr.Zero);
|
||||
@@ -330,7 +341,7 @@ namespace System.Windows.Forms {
|
||||
if (menu != null) {
|
||||
int menu_height = menu.Rect.Height;
|
||||
if (menu_height == 0)
|
||||
menu_height = ThemeEngine.Current.CalcMenuBarSize (bmp_g, menu, cp.Width);
|
||||
menu_height = ThemeEngine.Current.CalcMenuBarSize (GraphicsContext, menu, cp.Width);
|
||||
borders.top += menu_height;
|
||||
}
|
||||
|
||||
|
||||
@@ -191,15 +191,21 @@ namespace System.Windows.Forms
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
[Localizable(true)]
|
||||
[RefreshProperties(RefreshProperties.All)]
|
||||
#if NET_2_0
|
||||
[Browsable (true)]
|
||||
[DesignerSerializationVisibility (DesignerSerializationVisibility.Visible)]
|
||||
[EditorBrowsable (EditorBrowsableState.Always)]
|
||||
#endif
|
||||
public new virtual bool AutoSize {
|
||||
[DefaultValue(false)]
|
||||
[Localizable(true)]
|
||||
[RefreshProperties(RefreshProperties.All)]
|
||||
public
|
||||
#if NET_2_0
|
||||
override
|
||||
#else
|
||||
virtual
|
||||
#endif
|
||||
bool AutoSize {
|
||||
get { return autosize; }
|
||||
set {
|
||||
if (autosize == value)
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace System.Windows.Forms
|
||||
font = value;
|
||||
|
||||
height = Font.Height;
|
||||
XplatUI.GetFontMetrics (Hwnd.bmp_g, Font, out ascent, out descent);
|
||||
XplatUI.GetFontMetrics (Hwnd.GraphicsContext, Font, out ascent, out descent);
|
||||
line.recalc = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace System.Windows.Forms
|
||||
Hashtable item_heights;
|
||||
private int item_height = -1;
|
||||
private int column_width = 0;
|
||||
private int requested_height = -1;
|
||||
private int requested_height;
|
||||
private DrawMode draw_mode = DrawMode.Normal;
|
||||
private int horizontal_extent = 0;
|
||||
private bool horizontal_scrollbar = false;
|
||||
@@ -105,6 +105,7 @@ namespace System.Windows.Forms
|
||||
|
||||
public ListBox ()
|
||||
{
|
||||
requested_height = bounds.Height;
|
||||
InternalBorderStyle = BorderStyle.Fixed3D;
|
||||
BackColor = ThemeEngine.Current.ColorWindow;
|
||||
|
||||
@@ -983,6 +984,10 @@ namespace System.Windows.Forms
|
||||
protected override void OnHandleCreated (EventArgs e)
|
||||
{
|
||||
base.OnHandleCreated (e);
|
||||
|
||||
if (IntegralHeight)
|
||||
UpdateListBoxBounds ();
|
||||
|
||||
LayoutListBox ();
|
||||
}
|
||||
|
||||
@@ -1069,30 +1074,38 @@ namespace System.Windows.Forms
|
||||
SetBounds (new_bounds.X, new_bounds.Y, new_bounds.Width, new_bounds.Height, specified);
|
||||
}
|
||||
#endif
|
||||
|
||||
private int SnapHeightToIntegral (int height)
|
||||
{
|
||||
int border;
|
||||
|
||||
switch (border_style) {
|
||||
case BorderStyle.Fixed3D:
|
||||
border = ThemeEngine.Current.Border3DSize.Height;
|
||||
break;
|
||||
case BorderStyle.FixedSingle:
|
||||
border = ThemeEngine.Current.BorderSize.Height;
|
||||
break;
|
||||
case BorderStyle.None:
|
||||
default:
|
||||
border = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
height -= (2 * border);
|
||||
height -= height % ItemHeight;
|
||||
height += (2 * border);
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
|
||||
{
|
||||
if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height)
|
||||
requested_height = height;
|
||||
|
||||
if (IntegralHeight) {
|
||||
int border;
|
||||
switch (border_style) {
|
||||
case BorderStyle.Fixed3D:
|
||||
border = ThemeEngine.Current.Border3DSize.Height;
|
||||
break;
|
||||
case BorderStyle.FixedSingle:
|
||||
border = ThemeEngine.Current.BorderSize.Height;
|
||||
break;
|
||||
case BorderStyle.None:
|
||||
default:
|
||||
border = 0;
|
||||
break;
|
||||
}
|
||||
height -= (2 * border);
|
||||
height -= height % ItemHeight;
|
||||
height += (2 * border);
|
||||
}
|
||||
if (IntegralHeight && IsHandleCreated)
|
||||
height = SnapHeightToIntegral (height);
|
||||
|
||||
base.SetBoundsCore (x, y, width, height, specified);
|
||||
UpdateScrollBars ();
|
||||
@@ -1311,19 +1324,6 @@ namespace System.Windows.Forms
|
||||
return item_rect;
|
||||
}
|
||||
|
||||
internal override int HeightInternal {
|
||||
get {
|
||||
if (requested_height > -1)
|
||||
return requested_height;
|
||||
else
|
||||
return bounds.Height;
|
||||
}
|
||||
set {
|
||||
base.HeightInternal = value;
|
||||
requested_height = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Value Changed
|
||||
private void HorizontalScrollEvent (object sender, EventArgs e)
|
||||
{
|
||||
@@ -2067,10 +2067,8 @@ namespace System.Windows.Forms
|
||||
|
||||
private void UpdateListBoxBounds ()
|
||||
{
|
||||
if (requested_height == -1)
|
||||
return;
|
||||
|
||||
SetBounds(bounds.X, bounds.Y, bounds.Width, requested_height, BoundsSpecified.None);
|
||||
if (IsHandleCreated)
|
||||
SetBounds (bounds.X, bounds.Y, bounds.Width, IntegralHeight ? SnapHeightToIntegral (requested_height) : requested_height, BoundsSpecified.None);
|
||||
}
|
||||
|
||||
private void UpdateScrollBars ()
|
||||
@@ -2812,3 +2810,4 @@ namespace System.Windows.Forms
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2616,15 +2616,17 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
if (me.Button == MouseButtons.Left || me.Button == MouseButtons.Right) {
|
||||
if (drag_begin.X == -1 && drag_begin.Y == -1)
|
||||
drag_begin = new Point (me.X, me.Y);
|
||||
else {
|
||||
if (drag_begin.X == -1 && drag_begin.Y == -1) {
|
||||
if (item != null) {
|
||||
drag_begin = new Point (me.X, me.Y);
|
||||
dragged_item_index = item.Index;
|
||||
}
|
||||
|
||||
} else {
|
||||
Rectangle r = new Rectangle (drag_begin, SystemInformation.DragSize);
|
||||
if (!r.Contains (me.X, me.Y)) {
|
||||
dragged_item_index = item.Index;
|
||||
|
||||
if (item != null)
|
||||
owner.OnItemDrag (new ItemDragEventArgs (me.Button, item));
|
||||
ListViewItem dragged_item = owner.items [dragged_item_index];
|
||||
owner.OnItemDrag (new ItemDragEventArgs (me.Button, dragged_item));
|
||||
|
||||
drag_begin = new Point (-1, -1);
|
||||
dragged_item_index = -1;
|
||||
@@ -2757,6 +2759,11 @@ namespace System.Windows.Forms
|
||||
prev_selection = null;
|
||||
box_select_mode = BoxSelect.None;
|
||||
checking = false;
|
||||
|
||||
// Clean these bits in case the mouse buttons were
|
||||
// released before firing ItemDrag
|
||||
dragged_item_index = -1;
|
||||
drag_begin = new Point (-1, -1);
|
||||
}
|
||||
|
||||
private void LabelEditFinished (object sender, EventArgs e)
|
||||
|
||||
@@ -282,7 +282,10 @@ namespace System.Windows.Forms {
|
||||
XplatUI.TranslateMessage(ref msg);
|
||||
XplatUI.DispatchMessage(ref msg);
|
||||
}
|
||||
|
||||
|
||||
if (tracker.grab_control.IsDisposed)
|
||||
return true;
|
||||
|
||||
if (captured)
|
||||
tracker.grab_control.Capture = true;
|
||||
|
||||
|
||||
+10
-3
@@ -79,9 +79,16 @@ namespace System.Windows.Forms
|
||||
|
||||
void Set_PrinterSettings_PrintFileName (PrinterSettings settings, string filename)
|
||||
{
|
||||
PropertyInfo PrintFileName = typeof (PrinterSettings).GetProperty ("PrintFileName", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
PrintFileName.SetValue (settings, filename, null);
|
||||
#if NET_2_0
|
||||
settings.PrintFileName = filename;
|
||||
#else
|
||||
|
||||
PropertyInfo printFileName = typeof (PrinterSettings).GetProperty ("PrintFileName", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (printFileName == null) {
|
||||
throw new Exception ("Unable to set filename to print");
|
||||
}
|
||||
printFileName.SetValue (settings, filename, null);
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void OnStartPrint(PrintDocument document, PrintEventArgs e) {
|
||||
|
||||
@@ -47,9 +47,7 @@ namespace System.Windows.Forms {
|
||||
#region Private Members
|
||||
|
||||
|
||||
private const int GRID_ITEM_HEIGHT = 16;
|
||||
private const int GRID_LEFT_COLUMN_WIDTH = 16;
|
||||
private const int DIVIDER_PADDING = 2;
|
||||
private const string UNCATEGORIZED_CATEGORY_LABEL = "Misc";
|
||||
|
||||
private AttributeCollection browsable_attributes = null;
|
||||
private bool can_show_commands = false;
|
||||
@@ -62,8 +60,8 @@ namespace System.Windows.Forms {
|
||||
private Color line_color;
|
||||
private PropertySort property_sort;
|
||||
private PropertyTabCollection property_tabs;
|
||||
private GridItem selected_grid_item;
|
||||
private GridItem root_grid_item;
|
||||
private GridEntry selected_grid_item;
|
||||
private GridEntry root_grid_item;
|
||||
private object[] selected_objects;
|
||||
private PropertyTab selected_tab;
|
||||
|
||||
@@ -93,10 +91,6 @@ namespace System.Windows.Forms {
|
||||
private Color commands_disabled_link_color;
|
||||
private Color commands_link_color;
|
||||
#endif
|
||||
// Category and main items cache
|
||||
GridItemCollection category_grid_items;
|
||||
GridItemCollection main_grid_items;
|
||||
|
||||
#endregion // Private Members
|
||||
|
||||
#region Contructors
|
||||
@@ -544,8 +538,16 @@ namespace System.Windows.Forms {
|
||||
property_sort = value;
|
||||
UpdateToolBarButtons ();
|
||||
if (needUpdate) {
|
||||
UpdateSortLayout ();
|
||||
property_grid_view.Refresh ();
|
||||
UpdateSortLayout (root_grid_item);
|
||||
// update selection
|
||||
if (selected_grid_item != null) {
|
||||
if (selected_grid_item.GridItemType == GridItemType.Category &&
|
||||
(value == PropertySort.Alphabetical || value == PropertySort.NoSort))
|
||||
SelectItemCore (null, null);
|
||||
else
|
||||
SelectItemCore (null, selected_grid_item);
|
||||
}
|
||||
property_grid_view.UpdateView ();
|
||||
|
||||
#if NET_2_0
|
||||
EventHandler eh = (EventHandler)(Events [PropertySortChangedEvent]);
|
||||
@@ -574,8 +576,8 @@ namespace System.Windows.Forms {
|
||||
if (value == null)
|
||||
throw new ArgumentException ("GridItem specified to PropertyGrid.SelectedGridItem must be a valid GridItem.");
|
||||
if (value != selected_grid_item) {
|
||||
GridItem oldItem = selected_grid_item;
|
||||
SelectItemCore (oldItem, value);
|
||||
GridEntry oldItem = selected_grid_item;
|
||||
SelectItemCore (oldItem, (GridEntry)value);
|
||||
OnSelectedGridItemChanged (new SelectedGridItemChangedEventArgs (oldItem, value));
|
||||
}
|
||||
}
|
||||
@@ -597,7 +599,7 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectItemCore (GridItem oldItem, GridItem item)
|
||||
private void SelectItemCore (GridEntry oldItem, GridEntry item)
|
||||
{
|
||||
UpdateHelp (item);
|
||||
selected_grid_item = item;
|
||||
@@ -605,19 +607,31 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
internal void OnPropertyValueChangedInternal (GridItem item, object property_value) {
|
||||
PopulateSubGridItemsFromProperties (SelectedGridItem as GridEntry);
|
||||
PopulateSubGridItems (selected_grid_item);
|
||||
property_grid_view.UpdateView ();
|
||||
OnPropertyValueChanged (new PropertyValueChangedEventArgs (item, property_value));
|
||||
}
|
||||
|
||||
internal void OnExpandItem (GridItem item)
|
||||
internal void OnExpandItem (GridEntry item)
|
||||
{
|
||||
property_grid_view.ExpandItem ((GridEntry)item);
|
||||
property_grid_view.ExpandItem (item);
|
||||
}
|
||||
|
||||
internal void OnCollapseItem (GridItem item)
|
||||
internal void OnCollapseItem (GridEntry item)
|
||||
{
|
||||
property_grid_view.CollapseItem ((GridEntry)item);
|
||||
property_grid_view.CollapseItem (item);
|
||||
}
|
||||
|
||||
internal DialogResult ShowError (string text)
|
||||
{
|
||||
return this.ShowError (text, MessageBoxButtons.OK);
|
||||
}
|
||||
|
||||
internal DialogResult ShowError (string text, MessageBoxButtons buttons)
|
||||
{
|
||||
if (text == null)
|
||||
throw new ArgumentNullException ("text");
|
||||
return MessageBox.Show (this, text, "Properties Window", buttons, MessageBoxIcon.Exclamation);
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
@@ -668,11 +682,10 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
RefreshTabs(PropertyTabScope.Component);
|
||||
ReflectObjects();
|
||||
if (root_grid_item != null) {
|
||||
/* find the first non category grid item and select it */
|
||||
SelectItemCore (null, FindFirstItem (root_grid_item));
|
||||
}
|
||||
PopulateGrid (selected_objects);
|
||||
if (root_grid_item != null)
|
||||
SelectItemCore (null, GetDefaultPropertyItem (root_grid_item));
|
||||
property_grid_view.UpdateView ();
|
||||
OnSelectedObjectsChanged (EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
@@ -834,26 +847,70 @@ namespace System.Windows.Forms {
|
||||
base.Dispose(val);
|
||||
}
|
||||
|
||||
[MonoTODO ("should this be recursive? or just the toplevel items?")]
|
||||
public void CollapseAllGridItems () {
|
||||
if (root_grid_item != null) {
|
||||
foreach (GridItem item in root_grid_item.GridItems) {
|
||||
item.Expanded = false;
|
||||
}
|
||||
public void CollapseAllGridItems ()
|
||||
{
|
||||
GridEntry category = FindCategoryItem (selected_grid_item);
|
||||
if (category != null)
|
||||
SelectedGridItem = category;
|
||||
CollapseItemRecursive (root_grid_item);
|
||||
property_grid_view.UpdateView ();
|
||||
}
|
||||
|
||||
private void CollapseItemRecursive (GridItem item)
|
||||
{
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
foreach (GridItem child in item.GridItems) {
|
||||
CollapseItemRecursive (child);
|
||||
if (child.Expandable)
|
||||
child.Expanded = false;
|
||||
}
|
||||
}
|
||||
|
||||
[MonoTODO ("should this be recursive? or just the toplevel items?")]
|
||||
public void ExpandAllGridItems () {
|
||||
if (root_grid_item != null) {
|
||||
foreach (GridItem item in root_grid_item.GridItems) {
|
||||
item.Expanded = true;
|
||||
}
|
||||
private GridEntry FindCategoryItem (GridEntry entry)
|
||||
{
|
||||
if (entry == null || (property_sort != PropertySort.Categorized &&
|
||||
property_sort != PropertySort.CategorizedAlphabetical))
|
||||
return null;
|
||||
|
||||
if (entry.GridItemType == GridItemType.Category)
|
||||
return entry;
|
||||
|
||||
GridEntry category = null;
|
||||
GridItem current = (GridItem)entry;
|
||||
while (category == null) {
|
||||
if (current.Parent != null && current.Parent.GridItemType == GridItemType.Category)
|
||||
category = (GridEntry) current.Parent;
|
||||
current = current.Parent;
|
||||
if (current == null)
|
||||
break;
|
||||
}
|
||||
return (GridEntry) category;
|
||||
}
|
||||
|
||||
public void ExpandAllGridItems ()
|
||||
{
|
||||
ExpandItemRecursive (root_grid_item);
|
||||
property_grid_view.UpdateView ();
|
||||
}
|
||||
|
||||
private void ExpandItemRecursive (GridItem item)
|
||||
{
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
foreach (GridItem child in item.GridItems) {
|
||||
ExpandItemRecursive (child);
|
||||
if (child.Expandable)
|
||||
child.Expanded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Refresh () {
|
||||
public override void Refresh ()
|
||||
{
|
||||
base.Refresh ();
|
||||
property_grid_view.UpdateView ();
|
||||
}
|
||||
|
||||
public void RefreshTabs (PropertyTabScope tabScope) {
|
||||
@@ -880,7 +937,7 @@ namespace System.Windows.Forms {
|
||||
public void ResetSelectedProperty() {
|
||||
if (selected_grid_item == null)
|
||||
return;
|
||||
((GridEntry)selected_grid_item).ResetValue ();
|
||||
selected_grid_item.ResetValue ();
|
||||
}
|
||||
#endregion // Public Instance Methods
|
||||
|
||||
@@ -1246,13 +1303,13 @@ namespace System.Windows.Forms {
|
||||
|
||||
#region Private Helper Methods
|
||||
|
||||
private GridItem FindFirstItem (GridItem root)
|
||||
private GridItem FindFirstPropertyItem (GridItem root)
|
||||
{
|
||||
if (root.GridItemType == GridItemType.Property)
|
||||
return root;
|
||||
|
||||
foreach (GridItem item in root.GridItems) {
|
||||
GridItem subitem = FindFirstItem (item);
|
||||
GridItem subitem = FindFirstPropertyItem (item);
|
||||
if (subitem != null)
|
||||
return subitem;
|
||||
}
|
||||
@@ -1260,6 +1317,62 @@ namespace System.Windows.Forms {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: Should use the current tab's GetDefaultProperty and the current
|
||||
// code should be PropertyTab specific
|
||||
//
|
||||
private GridEntry GetDefaultPropertyItem (GridEntry rootItem)
|
||||
{
|
||||
if (rootItem == null || rootItem.GridItems.Count == 0)
|
||||
return null;
|
||||
object[] propertyOwners = rootItem.Values;
|
||||
if (propertyOwners == null || propertyOwners.Length == 0 || propertyOwners[0] == null)
|
||||
return null;
|
||||
|
||||
//return (GridEntry) FindFirstItem (rootItem);
|
||||
GridItem defaultSelected = null;
|
||||
if (propertyOwners.Length > 1)
|
||||
defaultSelected = rootItem.GridItems[0];
|
||||
else {
|
||||
PropertyDescriptor defaultProperty = null;
|
||||
ICustomTypeDescriptor customTypeDescriptor = propertyOwners[0] as ICustomTypeDescriptor;
|
||||
if (customTypeDescriptor != null) // try 1: ICustomTypeDescriptor
|
||||
defaultProperty = customTypeDescriptor.GetDefaultProperty ();
|
||||
if (defaultProperty == null) // try 2: TypeDescriptor
|
||||
defaultProperty = TypeDescriptor.GetDefaultProperty (propertyOwners[0]);
|
||||
|
||||
if (defaultProperty != null)
|
||||
defaultSelected = FindItem (defaultProperty.Name, rootItem);
|
||||
if (defaultSelected == null)
|
||||
defaultSelected = FindFirstPropertyItem (rootItem);
|
||||
}
|
||||
|
||||
return defaultSelected as GridEntry;
|
||||
}
|
||||
|
||||
private GridEntry FindItem (string name, GridEntry rootItem)
|
||||
{
|
||||
if (rootItem == null || name == null)
|
||||
return null;
|
||||
|
||||
if (property_sort == PropertySort.Alphabetical || property_sort == PropertySort.NoSort) {
|
||||
foreach (GridItem item in rootItem.GridItems) {
|
||||
if (item.Label == name) {
|
||||
return (GridEntry)item;
|
||||
}
|
||||
}
|
||||
} else if (property_sort == PropertySort.Categorized ||
|
||||
property_sort == PropertySort.CategorizedAlphabetical) {
|
||||
foreach (GridItem categoryItem in rootItem.GridItems) {
|
||||
foreach (GridItem item in categoryItem.GridItems) {
|
||||
if (item.Label == name) {
|
||||
return (GridEntry)item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
private void toolbar_ButtonClick (object sender, ToolStripItemClickedEventArgs e)
|
||||
@@ -1313,12 +1426,10 @@ namespace System.Windows.Forms {
|
||||
description_menuitem.Checked = this.HelpVisible;
|
||||
}
|
||||
|
||||
private void ReflectObjects () {
|
||||
if (selected_objects.Length > 0) {
|
||||
root_grid_item = new RootGridEntry (this,
|
||||
selected_objects.Length > 1 ? selected_objects : selected_objects[0]);
|
||||
|
||||
PopulateMergedGridItems (selected_objects, true, root_grid_item as GridEntry);
|
||||
private void PopulateGrid (object[] objects) {
|
||||
if (objects.Length > 0) {
|
||||
root_grid_item = new RootGridEntry (this, objects);
|
||||
PopulateRootGridItems (root_grid_item, objects, GetMergedPropertyNames (objects));
|
||||
} else {
|
||||
root_grid_item = null;
|
||||
}
|
||||
@@ -1346,200 +1457,203 @@ namespace System.Windows.Forms {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void PopulateMergedGridItems (object [] objs, bool recurse, GridEntry parent_grid_item)
|
||||
private string[] GetMergedPropertyNames (object [] objects)
|
||||
{
|
||||
ArrayList intersection = null;
|
||||
|
||||
if (parent_grid_item == null)
|
||||
return;
|
||||
|
||||
/* Clear any previous grid items */
|
||||
if (parent_grid_item.GridItems.Count > 0)
|
||||
parent_grid_item.GridItems.Clear ();
|
||||
|
||||
for (int i = 0; i < objs.Length; i ++) {
|
||||
if (objs [i] == null)
|
||||
for (int i = 0; i < objects.Length; i ++) {
|
||||
if (objects [i] == null)
|
||||
continue;
|
||||
|
||||
PropertyDescriptorCollection properties = GetProperties (objects[i]);
|
||||
ArrayList new_intersection = new ArrayList ();
|
||||
Type type = objs[i].GetType();
|
||||
|
||||
/* i tried using filter attributes, but there's no way to do it for EditorBrowsableAttributes,
|
||||
since that type lacks an override for IsDefaultAttribute, and for some reason the
|
||||
BrowsableAttribute.Yes filter wasn't working */
|
||||
PropertyDescriptorCollection properties = null;
|
||||
ICustomTypeDescriptor descriptor;
|
||||
foreach (PropertyDescriptor currentProperty in (i == 0 ? (ICollection)properties : (ICollection)intersection)) {
|
||||
PropertyDescriptor matchingProperty = (i == 0 ? currentProperty : properties [currentProperty.Name]);
|
||||
|
||||
descriptor = objs [i] as ICustomTypeDescriptor;
|
||||
if (descriptor != null) {
|
||||
properties = descriptor.GetProperties ();
|
||||
}
|
||||
if (properties == null) {
|
||||
TypeConverter cvt = TypeDescriptor.GetConverter (objs[i]);
|
||||
properties = cvt.GetProperties (objs[i]);
|
||||
}
|
||||
if (properties == null) {
|
||||
properties = TypeDescriptor.GetProperties (objs[i]);
|
||||
}
|
||||
|
||||
foreach (PropertyDescriptor p in (i == 0 ? (ICollection)properties : (ICollection)intersection)) {
|
||||
PropertyDescriptor property = (i == 0 ? p : properties [p.Name]);
|
||||
|
||||
if (!IsPropertyVisible (property, objs.Length > 1))
|
||||
if (!IsPropertyVisible (matchingProperty, objects.Length > 1))
|
||||
continue;
|
||||
|
||||
Type p_type = p.ComponentType;
|
||||
Type property_type = property.ComponentType;
|
||||
|
||||
if (p_type.IsAssignableFrom (type))
|
||||
new_intersection.Add (p);
|
||||
else if (property_type.IsAssignableFrom (p_type))
|
||||
new_intersection.Add (property);
|
||||
if (matchingProperty.PropertyType == currentProperty.PropertyType)
|
||||
new_intersection.Add (matchingProperty);
|
||||
}
|
||||
|
||||
intersection = new_intersection;
|
||||
}
|
||||
|
||||
if (intersection != null && intersection.Count > 0)
|
||||
PopulateGridItemsFromProperties (objs, intersection, recurse, parent_grid_item);
|
||||
}
|
||||
|
||||
private void PopulateGridItemsFromProperties (object[] objs, ArrayList properties, bool recurse, GridEntry parent_grid_item)
|
||||
{
|
||||
|
||||
GridItemCollection grid_item_coll = parent_grid_item.GridItems;
|
||||
|
||||
// Clean our grid items cache
|
||||
if (parent_grid_item == root_grid_item) {
|
||||
main_grid_items = new GridItemCollection ();
|
||||
category_grid_items = null;
|
||||
}
|
||||
|
||||
bool categorized = false, show = true;
|
||||
|
||||
if (property_sort == PropertySort.Alphabetical || /* XXX */property_sort == PropertySort.NoSort || !recurse)
|
||||
categorized = false;
|
||||
else if ((property_sort & PropertySort.Categorized) != 0) {
|
||||
categorized = parent_grid_item == root_grid_item;
|
||||
if (categorized)
|
||||
category_grid_items = new GridItemCollection ();
|
||||
} else {
|
||||
show = false;
|
||||
}
|
||||
|
||||
foreach (PropertyDescriptor property in properties) {
|
||||
GridEntry grid_entry;
|
||||
grid_entry = grid_item_coll [property.Name] as GridEntry;
|
||||
if (grid_entry == null || grid_entry is CategoryGridEntry) {
|
||||
grid_entry = new GridEntry (this, objs, property);
|
||||
} else {
|
||||
grid_entry.PropertyOwners = objs;
|
||||
}
|
||||
|
||||
grid_entry.SetParent (parent_grid_item);
|
||||
string[] propertyNames = new string [intersection.Count];
|
||||
for (int i=0; i < intersection.Count; i++)
|
||||
propertyNames[i] = ((PropertyDescriptor)intersection[i]).Name;
|
||||
|
||||
if (show) {
|
||||
if (categorized) {
|
||||
string category = property.Category;
|
||||
CategoryGridEntry cat_item = grid_item_coll [category] as CategoryGridEntry;
|
||||
if (cat_item == null) {
|
||||
cat_item = new CategoryGridEntry (this, category);
|
||||
cat_item.SetParent (parent_grid_item);
|
||||
cat_item.Expanded = true;
|
||||
grid_item_coll.Add (category, cat_item);
|
||||
return propertyNames;
|
||||
}
|
||||
|
||||
// Add to our cache
|
||||
category_grid_items.Add (category, cat_item);
|
||||
}
|
||||
if (cat_item.GridItems [property.Name] == null) {
|
||||
cat_item.GridItems.Add (property.Name, grid_entry);
|
||||
grid_entry.SetParent (cat_item);
|
||||
}
|
||||
} else {
|
||||
if (grid_item_coll [property.Name] == null) {
|
||||
grid_item_coll.Add (property.Name, grid_entry);
|
||||
grid_entry.SetParent (parent_grid_item);
|
||||
}
|
||||
private PropertyDescriptor GetPropertyDescriptor (object propertyOwner, string propertyName)
|
||||
{
|
||||
if (propertyOwner == null || propertyName == null)
|
||||
return null;
|
||||
|
||||
PropertyDescriptorCollection properties = GetProperties (propertyOwner);
|
||||
if (properties != null)
|
||||
return properties[propertyName];
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: Should use the current tab's GetProperties and the current code
|
||||
// should be PropertyTab specific
|
||||
//
|
||||
private PropertyDescriptorCollection GetProperties (object propertyOwner)
|
||||
{
|
||||
if (propertyOwner == null)
|
||||
return null;
|
||||
|
||||
PropertyDescriptorCollection properties = null;
|
||||
ICustomTypeDescriptor customTypeDescriptor = propertyOwner as ICustomTypeDescriptor;
|
||||
if (customTypeDescriptor != null) // try 1: ICustomTypeDescriptor
|
||||
properties = customTypeDescriptor.GetProperties ();
|
||||
if (properties == null) { // try 2: Converter with PropertiesSupported
|
||||
TypeConverter converter = TypeDescriptor.GetConverter (propertyOwner);
|
||||
if (converter.GetPropertiesSupported ())
|
||||
properties = converter.GetProperties (propertyOwner);
|
||||
}
|
||||
if (properties == null) // try 3: TypeDescriptor
|
||||
properties = TypeDescriptor.GetProperties (propertyOwner);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
private void PopulateRootGridItems (GridEntry rootItem, object[] propertyOwners, string[] propertyNames)
|
||||
{
|
||||
if (propertyOwners == null || propertyNames == null)
|
||||
return;
|
||||
|
||||
bool categorized = property_sort == PropertySort.Categorized ||
|
||||
property_sort == PropertySort.CategorizedAlphabetical;
|
||||
rootItem.GridItems.Clear ();
|
||||
|
||||
foreach (string propertyName in propertyNames) {
|
||||
GridEntry item = null;
|
||||
|
||||
PropertyDescriptor[] properties = new PropertyDescriptor[propertyNames.Length];
|
||||
for (int i=0; i < propertyOwners.Length; i++)
|
||||
properties[i] = GetPropertyDescriptor (propertyOwners[i], propertyName);
|
||||
|
||||
if (categorized) {
|
||||
string categoryName = null;
|
||||
foreach (PropertyDescriptor property in properties) {
|
||||
categoryName = property.Category;
|
||||
if (categoryName != null)
|
||||
break;
|
||||
}
|
||||
if (categoryName == null)
|
||||
categoryName = UNCATEGORIZED_CATEGORY_LABEL;
|
||||
GridEntry category = (GridEntry)root_grid_item.GridItems[categoryName];
|
||||
if (category == null) {
|
||||
category = new CategoryGridEntry (this, categoryName, rootItem);
|
||||
category.Expanded = true;
|
||||
rootItem.GridItems.Add (category);
|
||||
}
|
||||
item = new GridEntry (this, properties, category);
|
||||
category.GridItems.Add (item);
|
||||
} else {
|
||||
item = new GridEntry (this, properties, rootItem);
|
||||
rootItem.GridItems.Add (item);
|
||||
}
|
||||
|
||||
// Add main properties to our cache
|
||||
if (parent_grid_item == root_grid_item)
|
||||
main_grid_items.Add (grid_entry.Label, grid_entry);
|
||||
|
||||
if (recurse) {
|
||||
PopulateSubGridItemsFromProperties (grid_entry);
|
||||
}
|
||||
PopulateSubGridItems (item);
|
||||
}
|
||||
}
|
||||
|
||||
private void PopulateSubGridItemsFromProperties (GridEntry grid_entry)
|
||||
private void PopulateSubGridItems (GridEntry parentItem)
|
||||
{
|
||||
if (grid_entry == null)
|
||||
parentItem.GridItems.Clear ();
|
||||
if (!IsExpandable (parentItem))
|
||||
return;
|
||||
|
||||
if (grid_entry.PropertyOwners == null)
|
||||
object[] propertyOwners = parentItem.Values;
|
||||
if (propertyOwners == null)
|
||||
return;
|
||||
|
||||
PropertyDescriptor property = grid_entry.PropertyDescriptor;
|
||||
|
||||
if (property == null || property.Converter == null)
|
||||
PropertyDescriptorCollection propertiesCollection = GetProperties (propertyOwners[0]);
|
||||
if (propertiesCollection == null)
|
||||
return;
|
||||
|
||||
if (!property.Converter.GetPropertiesSupported () &&
|
||||
!property.Attributes.Contains (DesignerSerializationVisibilityAttribute.Content))
|
||||
return;
|
||||
foreach (PropertyDescriptor property in propertiesCollection) {
|
||||
string propertyName = property.Name;
|
||||
|
||||
object [] objs = grid_entry.PropertyOwners;
|
||||
object [] subobjs = new object [objs.Length];
|
||||
|
||||
for (int i = 0; i < objs.Length; i++)
|
||||
subobjs [i] = property.GetValue (objs [i]);
|
||||
|
||||
PopulateMergedGridItems (subobjs, true, grid_entry);
|
||||
PropertyDescriptor[] properties = new PropertyDescriptor[propertyOwners.Length];
|
||||
for (int i=0; i < propertyOwners.Length; i++)
|
||||
properties[i] = GetPropertyDescriptor (propertyOwners[i], propertyName);
|
||||
|
||||
GridEntry item = new GridEntry (this, properties, parentItem);
|
||||
parentItem.GridItems.Add (item);
|
||||
if (IsExpandable (item))
|
||||
PopulateSubGridItems (item);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateSortLayout ()
|
||||
private bool IsExpandable (GridEntry item)
|
||||
{
|
||||
if (root_grid_item == null)
|
||||
if (item == null || item.PropertyDescriptor == null ||
|
||||
item.PropertyDescriptor.Converter == null)
|
||||
return false;
|
||||
else if (!item.PropertyDescriptor.Converter.GetPropertiesSupported () &&
|
||||
!item.PropertyDescriptor.Attributes.Contains (
|
||||
DesignerSerializationVisibilityAttribute.Content))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateSortLayout (GridEntry rootItem)
|
||||
{
|
||||
if (rootItem == null)
|
||||
return;
|
||||
|
||||
root_grid_item.GridItems.Clear ();
|
||||
|
||||
if (category_grid_items == null)
|
||||
category_grid_items = new GridItemCollection ();
|
||||
GridItemCollection reordered = new GridItemCollection ();
|
||||
|
||||
if (property_sort == PropertySort.Alphabetical || property_sort == PropertySort.NoSort) {
|
||||
foreach (GridItem item in main_grid_items) {
|
||||
root_grid_item.GridItems.Add (item.Label, item);
|
||||
((GridEntry)item).SetParent (root_grid_item);
|
||||
foreach (GridItem item in rootItem.GridItems) {
|
||||
if (item.GridItemType == GridItemType.Category) {
|
||||
foreach (GridItem categoryChild in item.GridItems) {
|
||||
reordered.Add (categoryChild);
|
||||
((GridEntry)categoryChild).SetParent (rootItem);
|
||||
}
|
||||
} else {
|
||||
reordered.Add (item);
|
||||
}
|
||||
}
|
||||
} else if (property_sort == PropertySort.Categorized ||
|
||||
property_sort == PropertySort.CategorizedAlphabetical) {
|
||||
GridItemCollection categories = new GridItemCollection ();
|
||||
|
||||
foreach (GridItem category_item in category_grid_items) {
|
||||
category_item.GridItems.Clear ();
|
||||
((GridEntry)category_item).SetParent (null);
|
||||
}
|
||||
} else if ((property_sort & PropertySort.Categorized) != 0) {
|
||||
foreach (GridItem item in main_grid_items) {
|
||||
string category = item.PropertyDescriptor.Category;
|
||||
|
||||
GridItem category_item = category_grid_items [category];
|
||||
if (category_item == null) {
|
||||
// Create category grid items if they already don't
|
||||
category_item = new CategoryGridEntry (this, category);
|
||||
category_item.Expanded = true;
|
||||
category_grid_items.Add (category, category_item);
|
||||
foreach (GridItem item in rootItem.GridItems) {
|
||||
if (item.GridItemType == GridItemType.Category) {
|
||||
categories.Add (item);
|
||||
continue;
|
||||
}
|
||||
|
||||
category_item.GridItems.Add (item.Label, item);
|
||||
string categoryName = item.PropertyDescriptor.Category;
|
||||
if (categoryName == null)
|
||||
categoryName = UNCATEGORIZED_CATEGORY_LABEL;
|
||||
GridItem category_item = rootItem.GridItems [categoryName];
|
||||
if (category_item == null)
|
||||
category_item = categories [categoryName];
|
||||
|
||||
if (category_item == null) {
|
||||
// Create category grid items if they already don't
|
||||
category_item = new CategoryGridEntry (this, categoryName, rootItem);
|
||||
category_item.Expanded = true;
|
||||
categories.Add (category_item);
|
||||
}
|
||||
|
||||
category_item.GridItems.Add (item);
|
||||
((GridEntry)item).SetParent (category_item);
|
||||
}
|
||||
|
||||
foreach (GridItem category_item in category_grid_items) {
|
||||
root_grid_item.GridItems.Add (category_item.Label, category_item);
|
||||
((GridEntry)category_item).SetParent (root_grid_item);
|
||||
}
|
||||
reordered.AddRange (categories);
|
||||
}
|
||||
|
||||
rootItem.GridItems.Clear ();
|
||||
rootItem.GridItems.AddRange (reordered);
|
||||
}
|
||||
|
||||
private void help_panel_Paint(object sender, PaintEventArgs e) {
|
||||
|
||||
@@ -28,18 +28,27 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace System.Windows.Forms.PropertyGridInternal {
|
||||
internal class PGTextBox : TextBox {
|
||||
internal bool SwallowCapture = false;
|
||||
|
||||
internal override bool InternalCapture {
|
||||
get {
|
||||
return base.InternalCapture;
|
||||
}
|
||||
set {
|
||||
if (!SwallowCapture)
|
||||
base.InternalCapture = value;
|
||||
namespace System.Windows.Forms.PropertyGridInternal
|
||||
{
|
||||
internal class PGTextBox : TextBox
|
||||
{
|
||||
private bool _focusing = false;
|
||||
|
||||
public void FocusAt (Point location)
|
||||
{
|
||||
_focusing = true;
|
||||
Point pnt = PointToClient (location);
|
||||
XplatUI.SendMessage (Handle, Msg.WM_LBUTTONDOWN, new IntPtr ((int)MsgButtons.MK_LBUTTON), Control.MakeParam (pnt.X, pnt.Y));
|
||||
}
|
||||
|
||||
protected override void WndProc (ref Message m)
|
||||
{
|
||||
// Swallow the first MOUSEMOVE after the focusing WM_LBUTTONDOWN
|
||||
if (_focusing && m.Msg == (int)Msg.WM_MOUSEMOVE) {
|
||||
_focusing = false;
|
||||
return;
|
||||
}
|
||||
base.WndProc (ref m);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +111,8 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
protected override void OnGotFocus (EventArgs args)
|
||||
{
|
||||
base.OnGotFocus (args);
|
||||
// force-disable selection
|
||||
textbox.has_been_focused = true;
|
||||
textbox.Focus ();
|
||||
textbox.SelectionLength = 0;
|
||||
}
|
||||
@@ -168,6 +179,10 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
}
|
||||
}
|
||||
|
||||
public char PasswordChar {
|
||||
set { textbox.PasswordChar = value; }
|
||||
}
|
||||
|
||||
#endregion Public Instance Properties
|
||||
|
||||
#region Events
|
||||
@@ -218,6 +233,13 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
#endregion Private Helper Methods
|
||||
|
||||
internal void SendMouseDown (Point screenLocation)
|
||||
{
|
||||
Point clientLocation = PointToClient (screenLocation);
|
||||
XplatUI.SendMessage (Handle, Msg.WM_LBUTTONDOWN, new IntPtr ((int) MsgButtons.MK_LBUTTON), Control.MakeParam (clientLocation.X, clientLocation.Y));
|
||||
textbox.FocusAt (screenLocation);
|
||||
}
|
||||
|
||||
private void textbox_DoubleClick(object sender, EventArgs e) {
|
||||
EventHandler eh = (EventHandler)(Events [ToggleValueEvent]);
|
||||
if (eh != null)
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
internal class PropertyGridView : ScrollableControl, IWindowsFormsEditorService {
|
||||
|
||||
#region Private Members
|
||||
private const char PASSWORD_PAINT_CHAR = '\u25cf'; // the dot char
|
||||
private const char PASSWORD_TEXT_CHAR = '*';
|
||||
private const int V_INDENT = 16;
|
||||
private const int ENTRY_SPACING = 2;
|
||||
private const int RESIZE_WIDTH = 3;
|
||||
@@ -52,13 +54,13 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
private PropertyGridTextBox grid_textbox;
|
||||
private PropertyGrid property_grid;
|
||||
private bool resizing_grid;
|
||||
private int open_grid_item_count = -1;
|
||||
private int skipped_grid_items;
|
||||
private PropertyGridDropDown dropdown_form;
|
||||
private Form dialog_form;
|
||||
private ImplicitVScrollBar vbar;
|
||||
private StringFormat string_format;
|
||||
private Font bold_font;
|
||||
private Brush inactive_text_brush;
|
||||
private ListBox dropdown_list;
|
||||
#endregion
|
||||
|
||||
#region Contructors
|
||||
@@ -83,19 +85,19 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
dialog_form.FormBorderStyle = FormBorderStyle.None;
|
||||
dialog_form.ShowInTaskbar = false;
|
||||
|
||||
skipped_grid_items = 0;
|
||||
row_height = Font.Height + font_height_padding;
|
||||
|
||||
grid_textbox.Visible = false;
|
||||
grid_textbox.Font = this.Font;
|
||||
grid_textbox.BackColor = SystemColors.Window;
|
||||
// Not working at all, used to??
|
||||
grid_textbox.Validating += new CancelEventHandler (TextBoxValidating);
|
||||
// grid_textbox.Validating += new CancelEventHandler (TextBoxValidating);
|
||||
grid_textbox.ToggleValue+=new EventHandler (grid_textbox_ToggleValue);
|
||||
this.Controls.Add (grid_textbox);
|
||||
|
||||
vbar = new ImplicitVScrollBar ();
|
||||
vbar.Visible = false;
|
||||
vbar.Value = 0;
|
||||
vbar.ValueChanged+=new EventHandler (VScrollBar_HandleValueChanged);
|
||||
vbar.Dock = DockStyle.Right;
|
||||
this.Controls.AddImplicit (vbar);
|
||||
@@ -103,6 +105,7 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
resizing_grid = false;
|
||||
|
||||
bold_font = new Font (this.Font, FontStyle.Bold);
|
||||
inactive_text_brush = new SolidBrush (ThemeEngine.Current.ColorGrayText);
|
||||
|
||||
ForeColorChanged+=new EventHandler (RedrawEvent);
|
||||
BackColorChanged+=new System.EventHandler (RedrawEvent);
|
||||
@@ -117,6 +120,15 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
#endregion
|
||||
|
||||
private GridEntry RootGridItem {
|
||||
get { return (GridEntry)property_grid.RootGridItem; }
|
||||
}
|
||||
|
||||
private GridEntry SelectedGridItem {
|
||||
get { return (GridEntry)property_grid.SelectedGridItem; }
|
||||
set { property_grid.SelectedGridItem = value; }
|
||||
}
|
||||
|
||||
#region Protected Instance Methods
|
||||
|
||||
protected override void OnFontChanged (EventArgs e) {
|
||||
@@ -133,6 +145,9 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
private void InvalidateItem (GridEntry item)
|
||||
{
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
Rectangle rect = new Rectangle (0, item.Top, Width, row_height);
|
||||
Invalidate (rect);
|
||||
|
||||
@@ -145,22 +160,20 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
protected override void OnDoubleClick (EventArgs e)
|
||||
{
|
||||
if (property_grid.SelectedGridItem.Expandable)
|
||||
property_grid.SelectedGridItem.Expanded = !property_grid.SelectedGridItem.Expanded;
|
||||
if (this.SelectedGridItem != null && this.SelectedGridItem.Expandable)
|
||||
this.SelectedGridItem.Expanded = !this.SelectedGridItem.Expanded;
|
||||
else
|
||||
ToggleValue ((GridEntry)property_grid.SelectedGridItem);
|
||||
ToggleValue (this.SelectedGridItem);
|
||||
}
|
||||
|
||||
protected override void OnPaint (PaintEventArgs e) {
|
||||
// Decide if we need a scrollbar
|
||||
open_grid_item_count = 0;
|
||||
|
||||
protected override void OnPaint (PaintEventArgs e)
|
||||
{
|
||||
// Background
|
||||
e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
|
||||
|
||||
int yLoc = -vbar.Value*row_height;
|
||||
if (property_grid.RootGridItem != null)
|
||||
DrawGridItems (property_grid.RootGridItem.GridItems, e, 1, ref yLoc);
|
||||
if (this.RootGridItem != null)
|
||||
DrawGridItems (this.RootGridItem.GridItems, e, 1, ref yLoc);
|
||||
|
||||
UpdateScrollBar ();
|
||||
}
|
||||
@@ -170,7 +183,7 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
if (vbar == null || !vbar.Visible)
|
||||
return;
|
||||
if (e.Delta < 0)
|
||||
vbar.Value = Math.Min (vbar.Value + SystemInformation.MouseWheelScrollLines, vbar.Maximum);
|
||||
vbar.Value = Math.Min (vbar.Maximum - GetVisibleRowsCount () + 1, vbar.Value + SystemInformation.MouseWheelScrollLines);
|
||||
else
|
||||
vbar.Value = Math.Max (0, vbar.Value - SystemInformation.MouseWheelScrollLines);
|
||||
base.OnMouseWheel (e);
|
||||
@@ -178,7 +191,7 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
|
||||
protected override void OnMouseMove (MouseEventArgs e) {
|
||||
if (property_grid.RootGridItem == null)
|
||||
if (this.RootGridItem == null)
|
||||
return;
|
||||
|
||||
if (resizing_grid) {
|
||||
@@ -194,26 +207,32 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
protected override void OnMouseDown (MouseEventArgs e)
|
||||
{
|
||||
if (property_grid.RootGridItem == null)
|
||||
base.OnMouseDown (e);
|
||||
if (this.RootGridItem == null)
|
||||
return;
|
||||
|
||||
if (!TrySetEntry (this.SelectedGridItem, grid_textbox.Text)) {
|
||||
FocusSelection ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.X > SplitterLocation - RESIZE_WIDTH && e.X < SplitterLocation + RESIZE_WIDTH) {
|
||||
resizing_grid = true;
|
||||
}
|
||||
else {
|
||||
int offset = -vbar.Value*row_height;
|
||||
GridItem foundItem = GetSelectedGridItem (property_grid.RootGridItem.GridItems, e.Y, ref offset);
|
||||
GridItem foundItem = GetSelectedGridItem (this.RootGridItem.GridItems, e.Y, ref offset);
|
||||
|
||||
if (foundItem != null) {
|
||||
if (foundItem.Expandable && ((GridEntry)foundItem).PlusMinusBounds.Contains (e.X, e.Y))
|
||||
foundItem.Expanded = !foundItem.Expanded;
|
||||
|
||||
this.property_grid.SelectedGridItem = foundItem;
|
||||
if (!GridLabelHitTest (e.X))
|
||||
FocusSelection ();
|
||||
foundItem.Expanded = !foundItem.Expanded;
|
||||
|
||||
this.SelectedGridItem = (GridEntry)foundItem;
|
||||
if (!GridLabelHitTest (e.X)) {
|
||||
// send mouse down so we get the carret under cursor
|
||||
grid_textbox.SendMouseDown (PointToScreen (e.Location));
|
||||
}
|
||||
}
|
||||
|
||||
base.OnMouseDown (e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,14 +243,12 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
protected override void OnResize (EventArgs e) {
|
||||
base.OnResize (e);
|
||||
if (property_grid.SelectedGridItem != null) { // initialized already
|
||||
SuspendLayout ();
|
||||
if (this.SelectedGridItem != null) { // initialized already
|
||||
UpdateView ();
|
||||
// MS scrolls to the currently selected item on resize, even
|
||||
// when it's not in the visible area.
|
||||
//
|
||||
EnsureItemIsVisible ((GridEntry)property_grid.SelectedGridItem);
|
||||
ResumeLayout (false);
|
||||
ScrollToItem (this.SelectedGridItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,17 +263,17 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
}
|
||||
|
||||
protected override bool ProcessDialogKey (Keys keyData) {
|
||||
GridEntry selectedItem = (GridEntry) property_grid.SelectedGridItem;
|
||||
GridEntry selectedItem = this.SelectedGridItem;
|
||||
if (selectedItem != null
|
||||
&& grid_textbox.Visible) {
|
||||
switch (keyData) {
|
||||
case Keys.Enter:
|
||||
selectedItem.SetValue (grid_textbox.Text);
|
||||
UnfocusSelection ();
|
||||
if (TrySetEntry (selectedItem, grid_textbox.Text))
|
||||
UnfocusSelection ();
|
||||
return true;
|
||||
case Keys.Escape:
|
||||
if (selectedItem.IsEditable)
|
||||
grid_textbox.Text = selectedItem.ValueString;
|
||||
UpdateItem (selectedItem); // reset value
|
||||
UnfocusSelection ();
|
||||
return true;
|
||||
case Keys.Tab:
|
||||
@@ -269,6 +286,25 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
return base.ProcessDialogKey (keyData);
|
||||
}
|
||||
|
||||
private bool TrySetEntry (GridEntry entry, object value)
|
||||
{
|
||||
if (entry == null || grid_textbox.Text.Equals (entry.ValueText))
|
||||
return true;
|
||||
|
||||
if (entry.IsEditable || !entry.IsEditable && (entry.HasCustomEditor || entry.AcceptedValues != null) ||
|
||||
!entry.IsMerged || entry.HasMergedValue ||
|
||||
(!entry.HasMergedValue && grid_textbox.Text != String.Empty)) {
|
||||
string error = null;
|
||||
bool changed = entry.SetValue (value, out error);
|
||||
if (!changed && error != null) {
|
||||
if (property_grid.ShowError (error, MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
||||
UpdateItem (entry); // restore value, repaint, etc
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool IsInputKey (Keys keyData) {
|
||||
switch (keyData) {
|
||||
@@ -296,7 +332,7 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
/* move back up the visible rows (and up the hierarchy as necessary) until
|
||||
up_count == 0, or we reach the top of the display */
|
||||
while (up_count > 0) {
|
||||
items = item.Parent != null ? item.Parent.GridItems : property_grid.RootGridItem.GridItems;
|
||||
items = item.Parent != null ? item.Parent.GridItems : this.RootGridItem.GridItems;
|
||||
index = items.IndexOf (item);
|
||||
|
||||
if (index == 0) {
|
||||
@@ -357,8 +393,9 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override void OnKeyDown (KeyEventArgs e) {
|
||||
GridEntry selectedItem = (GridEntry)property_grid.SelectedGridItem;
|
||||
protected override void OnKeyDown (KeyEventArgs e)
|
||||
{
|
||||
GridEntry selectedItem = this.SelectedGridItem;
|
||||
|
||||
if (selectedItem == null) {
|
||||
/* XXX not sure what MS does, but at least we shouldn't crash */
|
||||
@@ -366,6 +403,11 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TrySetEntry (selectedItem, grid_textbox.Text)) {
|
||||
FocusSelection ();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.KeyData & Keys.KeyCode) {
|
||||
case Keys.Left:
|
||||
if (e.Control) {
|
||||
@@ -413,31 +455,31 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Keys.Up:
|
||||
property_grid.SelectedGridItem = MoveUpFromItem (selectedItem, 1);
|
||||
this.SelectedGridItem = MoveUpFromItem (selectedItem, 1);
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Keys.Down:
|
||||
property_grid.SelectedGridItem = MoveDownFromItem (selectedItem, 1);
|
||||
this.SelectedGridItem = MoveDownFromItem (selectedItem, 1);
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Keys.PageUp:
|
||||
property_grid.SelectedGridItem = MoveUpFromItem (selectedItem, vbar.LargeChange);
|
||||
this.SelectedGridItem = MoveUpFromItem (selectedItem, vbar.LargeChange);
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Keys.PageDown:
|
||||
property_grid.SelectedGridItem = MoveDownFromItem (selectedItem, vbar.LargeChange);
|
||||
this.SelectedGridItem = MoveDownFromItem (selectedItem, vbar.LargeChange);
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Keys.End:
|
||||
/* find the last, most deeply nested visible item */
|
||||
GridEntry item = (GridEntry)property_grid.RootGridItem.GridItems[property_grid.RootGridItem.GridItems.Count - 1];
|
||||
GridEntry item = (GridEntry)this.RootGridItem.GridItems[this.RootGridItem.GridItems.Count - 1];
|
||||
while (item.Expandable && item.Expanded)
|
||||
item = (GridEntry)item.GridItems[item.GridItems.Count - 1];
|
||||
property_grid.SelectedGridItem = item;
|
||||
this.SelectedGridItem = item;
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Keys.Home:
|
||||
property_grid.SelectedGridItem = property_grid.RootGridItem.GridItems[0];
|
||||
this.SelectedGridItem = (GridEntry)this.RootGridItem.GridItems[0];
|
||||
e.Handled = true;
|
||||
break;
|
||||
}
|
||||
@@ -449,7 +491,7 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
#region Private Helper Methods
|
||||
|
||||
private int SplitterLocation{
|
||||
private int SplitterLocation {
|
||||
get {
|
||||
return (int)(splitter_percent*Width);
|
||||
}
|
||||
@@ -464,7 +506,7 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
if (old_splitter_location != SplitterLocation) {
|
||||
int x = old_splitter_location > SplitterLocation ? SplitterLocation : old_splitter_location;
|
||||
Invalidate (new Rectangle (x, 0, Width - x - (vbar.Visible ? vbar.Width : 0), Height));
|
||||
UpdateItem ((GridEntry)property_grid.SelectedGridItem);
|
||||
UpdateItem (this.SelectedGridItem);
|
||||
}
|
||||
}
|
||||
get {
|
||||
@@ -494,21 +536,55 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void UpdateScrollBar () {
|
||||
int visible_rows = this.ClientRectangle.Height/row_height;
|
||||
if (open_grid_item_count > visible_rows) {
|
||||
vbar.Visible = true;
|
||||
vbar.SmallChange = 1;
|
||||
vbar.Minimum = 0;
|
||||
vbar.Maximum = open_grid_item_count-1;
|
||||
vbar.LargeChange = visible_rows;
|
||||
}
|
||||
else {
|
||||
vbar.Visible = false;
|
||||
}
|
||||
private int GetVisibleItemsCount (GridEntry entry)
|
||||
{
|
||||
if (entry == null)
|
||||
return 0;
|
||||
|
||||
int count = 0;
|
||||
foreach (GridEntry e in entry.GridItems) {
|
||||
count += 1;
|
||||
if (e.Expandable && e.Expanded)
|
||||
count += GetVisibleItemsCount (e);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private int GetVisibleRowsCount ()
|
||||
{
|
||||
return this.Height / row_height;
|
||||
}
|
||||
|
||||
private void UpdateScrollBar ()
|
||||
{
|
||||
if (this.RootGridItem == null)
|
||||
return;
|
||||
|
||||
int visibleRows = GetVisibleRowsCount ();
|
||||
int openedItems = GetVisibleItemsCount (this.RootGridItem);
|
||||
if (openedItems > visibleRows) {
|
||||
vbar.Visible = true;
|
||||
vbar.SmallChange = 1;
|
||||
vbar.LargeChange = visibleRows;
|
||||
vbar.Maximum = Math.Max (0, openedItems - 1);
|
||||
} else {
|
||||
vbar.Value = 0;
|
||||
vbar.Visible = false;
|
||||
}
|
||||
UpdateGridTextBoxBounds (this.SelectedGridItem);
|
||||
}
|
||||
|
||||
// private bool GetScrollBarVisible ()
|
||||
// {
|
||||
// if (this.RootGridItem == null)
|
||||
// return false;
|
||||
//
|
||||
// int visibleRows = GetVisibleRowsCount ();
|
||||
// int openedItems = GetVisibleItemsCount (this.RootGridItem);
|
||||
// if (openedItems > visibleRows)
|
||||
// return true;
|
||||
// return false;
|
||||
// }
|
||||
#region Drawing Code
|
||||
|
||||
private void DrawGridItems (GridItemCollection grid_items, PaintEventArgs pevent, int depth, ref int yLoc) {
|
||||
@@ -525,16 +601,16 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
if (grid_item.GridItemType == GridItemType.Category) {
|
||||
font = bold_font;
|
||||
brush = SystemBrushes.ControlDark;
|
||||
brush = SystemBrushes.ControlText;
|
||||
|
||||
pevent.Graphics.DrawString (grid_item.Label, font, brush, rect.X + 1, rect.Y + ENTRY_SPACING);
|
||||
if (grid_item == property_grid.SelectedGridItem) {
|
||||
if (grid_item == this.SelectedGridItem) {
|
||||
SizeF size = pevent.Graphics.MeasureString (grid_item.Label, font);
|
||||
ControlPaint.DrawFocusRectangle (pevent.Graphics, new Rectangle (rect.X + 1, rect.Y+ENTRY_SPACING, (int)size.Width, (int)size.Height));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (grid_item == property_grid.SelectedGridItem) {
|
||||
if (grid_item == this.SelectedGridItem) {
|
||||
Rectangle highlight = rect;
|
||||
if (depth > 1) {
|
||||
highlight.X -= V_INDENT;
|
||||
@@ -545,13 +621,9 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
brush = SystemBrushes.HighlightText;
|
||||
}
|
||||
else {
|
||||
brush = SystemBrushes.WindowText;
|
||||
if (grid_item.PropertyDescriptor.IsReadOnly
|
||||
&& !grid_item.Expandable)
|
||||
brush = SystemBrushes.InactiveCaption;
|
||||
brush = grid_item.IsReadOnly ? inactive_text_brush : SystemBrushes.ControlText;
|
||||
}
|
||||
}
|
||||
|
||||
pevent.Graphics.DrawString (grid_item.Label, font, brush,
|
||||
new Rectangle (rect.X + 1, rect.Y + ENTRY_SPACING, rect.Width - ENTRY_SPACING, rect.Height - ENTRY_SPACING),
|
||||
string_format);
|
||||
@@ -562,24 +634,33 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
if (grid_item.PropertyDescriptor == null)
|
||||
return;
|
||||
|
||||
int xLoc = SplitterLocation+1;
|
||||
int xLoc = SplitterLocation+ENTRY_SPACING;
|
||||
if (grid_item.PaintValueSupported) {
|
||||
pevent.Graphics.DrawRectangle (Pens.Black, SplitterLocation + ENTRY_SPACING,
|
||||
rect.Y + 2, VALUE_PAINT_WIDTH + 1, row_height - ENTRY_SPACING*2);
|
||||
grid_item.PaintValue (pevent.Graphics,
|
||||
new Rectangle (SplitterLocation + ENTRY_SPACING + 1,
|
||||
rect.Y + ENTRY_SPACING + 1,
|
||||
VALUE_PAINT_WIDTH, row_height - (ENTRY_SPACING*2 + 1)));
|
||||
VALUE_PAINT_WIDTH, row_height - (ENTRY_SPACING*2 +1)));
|
||||
xLoc += VALUE_PAINT_INDENT;
|
||||
}
|
||||
|
||||
Font font = this.Font;
|
||||
if (grid_item.IsResetable)
|
||||
if (grid_item.IsResetable || !grid_item.HasDefaultValue)
|
||||
font = bold_font;
|
||||
pevent.Graphics.DrawString (grid_item.ValueString, font,
|
||||
SystemBrushes.WindowText,
|
||||
new RectangleF (xLoc, rect.Y + ENTRY_SPACING,
|
||||
ClientRectangle.Width-(xLoc), row_height),string_format);
|
||||
Brush brush = grid_item.IsReadOnly ? inactive_text_brush : SystemBrushes.ControlText;
|
||||
string valueText = String.Empty;
|
||||
if (!grid_item.IsMerged || grid_item.IsMerged && grid_item.HasMergedValue) {
|
||||
if (grid_item.IsPassword)
|
||||
valueText = new String (PASSWORD_PAINT_CHAR, grid_item.ValueText.Length);
|
||||
else
|
||||
valueText = grid_item.ValueText;
|
||||
}
|
||||
pevent.Graphics.DrawString (valueText, font,
|
||||
brush,
|
||||
new RectangleF (xLoc + ENTRY_SPACING, rect.Y + ENTRY_SPACING,
|
||||
ClientRectangle.Width-(xLoc), row_height - ENTRY_SPACING*2),
|
||||
string_format);
|
||||
}
|
||||
|
||||
private void DrawGridItem (GridEntry grid_item, PaintEventArgs pevent, int depth, ref int yLoc) {
|
||||
@@ -619,7 +700,6 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
}
|
||||
grid_item.Top = yLoc;
|
||||
yLoc += row_height;
|
||||
open_grid_item_count++;
|
||||
}
|
||||
|
||||
private Rectangle DrawPlusMinus (Graphics g, int x, int y, bool expanded, bool category) {
|
||||
@@ -642,11 +722,12 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
Refresh ();
|
||||
}
|
||||
|
||||
private void TextBoxValidating (object sender, CancelEventArgs e)
|
||||
{
|
||||
if (this.property_grid.SelectedGridItem != null)
|
||||
((GridEntry) property_grid.SelectedGridItem).SetValue (grid_textbox.Text);
|
||||
}
|
||||
// private void TextBoxValidating (object sender, CancelEventArgs e)
|
||||
// {
|
||||
// GridEntry entry = (GridEntry) this.SelectedGridItem;
|
||||
// if (entry != null && entry.IsEditable)
|
||||
// TrySetEntry (entry, grid_textbox.Text);
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -668,15 +749,18 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
void AcceptListBoxSelection (object sender)
|
||||
{
|
||||
GridEntry entry = this.property_grid.SelectedGridItem as GridEntry;
|
||||
if (entry != null)
|
||||
entry.SetValue ((string) ((ListBox) sender).SelectedItem);
|
||||
GridEntry entry = this.SelectedGridItem as GridEntry;
|
||||
if (entry != null) {
|
||||
grid_textbox.Text = (string) ((ListBox) sender).SelectedItem;
|
||||
if (TrySetEntry (entry, (string) ((ListBox) sender).SelectedItem))
|
||||
UnfocusSelection ();
|
||||
}
|
||||
CloseDropDown ();
|
||||
}
|
||||
|
||||
private void DropDownButtonClicked (object sender, EventArgs e)
|
||||
{
|
||||
GridEntry entry = property_grid.SelectedGridItem as GridEntry;
|
||||
GridEntry entry = this.SelectedGridItem as GridEntry;
|
||||
if (entry == null)
|
||||
return;
|
||||
|
||||
@@ -689,22 +773,26 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
else {
|
||||
ICollection std_values = entry.AcceptedValues;
|
||||
if (std_values != null) {
|
||||
ListBox listBox = new ListBox ();
|
||||
listBox.BorderStyle = BorderStyle.FixedSingle;
|
||||
if (dropdown_list == null)
|
||||
dropdown_list = new ListBox ();
|
||||
dropdown_list.Items.Clear ();
|
||||
dropdown_list.BorderStyle = BorderStyle.FixedSingle;
|
||||
int selected_index = 0;
|
||||
int i = 0;
|
||||
string valueText = entry.ValueText;
|
||||
foreach (object obj in std_values) {
|
||||
listBox.Items.Add (obj);
|
||||
if (entry.ValueString != null && entry.ValueString.Equals (obj))
|
||||
dropdown_list.Items.Add (obj);
|
||||
if (valueText != null && valueText.Equals (obj))
|
||||
selected_index = i;
|
||||
i++;
|
||||
}
|
||||
listBox.Height = row_height * Math.Min (listBox.Items.Count, 15);
|
||||
listBox.KeyDown += new KeyEventHandler (listBox_KeyDown);
|
||||
listBox.MouseUp+=new MouseEventHandler (listBox_MouseUp);
|
||||
dropdown_list.Height = row_height * Math.Min (dropdown_list.Items.Count, 15);
|
||||
dropdown_list.Width = ClientRectangle.Width - SplitterLocation - (vbar.Visible ? vbar.Width : 0);
|
||||
dropdown_list.KeyDown += new KeyEventHandler (listBox_KeyDown);
|
||||
dropdown_list.MouseUp+=new MouseEventHandler (listBox_MouseUp);
|
||||
if (std_values.Count > 0)
|
||||
listBox.SelectedIndex = selected_index;
|
||||
DropDownControl (listBox);
|
||||
dropdown_list.SelectedIndex = selected_index;
|
||||
DropDownControl (dropdown_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -712,31 +800,19 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
private void DialogButtonClicked (object sender, EventArgs e)
|
||||
{
|
||||
GridEntry entry = property_grid.SelectedGridItem as GridEntry;
|
||||
GridEntry entry = this.SelectedGridItem as GridEntry;
|
||||
if (entry != null && entry.HasCustomEditor)
|
||||
entry.EditValue ((IWindowsFormsEditorService) this);
|
||||
}
|
||||
|
||||
private void VScrollBar_HandleValueChanged (object sender, EventArgs e)
|
||||
{
|
||||
if (vbar.Value <= 0)
|
||||
vbar.Value = 0;
|
||||
if (vbar.Value > vbar.Maximum-ClientRectangle.Height/row_height)
|
||||
vbar.Value = vbar.Maximum-ClientRectangle.Height/row_height+1;
|
||||
|
||||
int scroll_amount = (skipped_grid_items-vbar.Value)*row_height;
|
||||
|
||||
if (scroll_amount == 0)
|
||||
return;
|
||||
|
||||
skipped_grid_items = vbar.Value;
|
||||
XplatUI.ScrollWindow (Handle, 0, scroll_amount, false);
|
||||
UpdateView ();
|
||||
}
|
||||
|
||||
private void grid_textbox_ToggleValue (object sender, EventArgs args)
|
||||
{
|
||||
ToggleValue ((GridEntry)property_grid.SelectedGridItem);
|
||||
ToggleValue (this.SelectedGridItem);
|
||||
}
|
||||
|
||||
private void ToggleValue (GridEntry entry)
|
||||
@@ -747,31 +823,36 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
internal void UpdateItem (GridEntry entry)
|
||||
{
|
||||
if (entry == null || entry.GridItemType != GridItemType.Property) {
|
||||
if (entry == null || entry.GridItemType == GridItemType.Category ||
|
||||
entry.GridItemType == GridItemType.Root) {
|
||||
grid_textbox.Visible = false;
|
||||
InvalidateItem (entry);
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_grid.SelectedGridItem == entry) {
|
||||
if (this.SelectedGridItem == entry) {
|
||||
SuspendLayout ();
|
||||
grid_textbox.Visible = false;
|
||||
if (entry.IsResetable)
|
||||
if (entry.IsResetable || !entry.HasDefaultValue)
|
||||
grid_textbox.Font = bold_font;
|
||||
else
|
||||
grid_textbox.Font = this.Font;
|
||||
|
||||
grid_textbox.DropDownButtonVisible = entry.AcceptedValues != null ||
|
||||
entry.EditorStyle == UITypeEditorEditStyle.DropDown;
|
||||
grid_textbox.DialogButtonVisible = entry.EditorStyle == UITypeEditorEditStyle.Modal;
|
||||
grid_textbox.ReadOnly = !entry.IsEditable;
|
||||
|
||||
int y = -vbar.Value*row_height;
|
||||
CalculateItemY (entry, property_grid.RootGridItem.GridItems, ref y);
|
||||
int x = SplitterLocation + 1 + (entry.PaintValueSupported ? 27 : 0);
|
||||
grid_textbox.SetBounds (x, y + ENTRY_SPACING,
|
||||
ClientRectangle.Width - x - (vbar.Visible ? vbar.Width : 0),
|
||||
row_height - ENTRY_SPACING);
|
||||
grid_textbox.Text = entry.ValueString != null ? entry.ValueString : "";
|
||||
if (entry.IsReadOnly) {
|
||||
grid_textbox.DropDownButtonVisible = false;
|
||||
grid_textbox.DialogButtonVisible = false;
|
||||
grid_textbox.ReadOnly = true;
|
||||
grid_textbox.ForeColor = SystemColors.GrayText;
|
||||
} else {
|
||||
grid_textbox.DropDownButtonVisible = entry.AcceptedValues != null ||
|
||||
entry.EditorStyle == UITypeEditorEditStyle.DropDown;
|
||||
grid_textbox.DialogButtonVisible = entry.EditorStyle == UITypeEditorEditStyle.Modal;
|
||||
grid_textbox.ForeColor = SystemColors.ControlText;
|
||||
grid_textbox.ReadOnly = !entry.IsEditable;
|
||||
}
|
||||
UpdateGridTextBoxBounds (entry);
|
||||
grid_textbox.PasswordChar = entry.IsPassword ? PASSWORD_TEXT_CHAR : '\0';
|
||||
grid_textbox.Text = entry.IsMerged && !entry.HasMergedValue ? String.Empty : entry.ValueText;
|
||||
grid_textbox.Visible = true;
|
||||
InvalidateItem (entry);
|
||||
ResumeLayout (false);
|
||||
@@ -780,6 +861,18 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateGridTextBoxBounds (GridEntry entry)
|
||||
{
|
||||
if (entry == null)
|
||||
return;
|
||||
int y = -vbar.Value*row_height;
|
||||
CalculateItemY (entry, this.RootGridItem.GridItems, ref y);
|
||||
int x = SplitterLocation + ENTRY_SPACING + (entry.PaintValueSupported ? VALUE_PAINT_INDENT : 0);
|
||||
grid_textbox.SetBounds (x + ENTRY_SPACING, y + ENTRY_SPACING,
|
||||
ClientRectangle.Width - ENTRY_SPACING - x - (vbar.Visible ? vbar.Width : 0),
|
||||
row_height - ENTRY_SPACING);
|
||||
}
|
||||
|
||||
// Calculates the sum of the heights of all items before the one
|
||||
//
|
||||
private bool CalculateItemY (GridEntry entry, GridItemCollection items, ref int y)
|
||||
@@ -795,93 +888,112 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void EnsureItemIsVisible (GridEntry item)
|
||||
private void ScrollToItem (GridEntry item)
|
||||
{
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
int itemY = -vbar.Value*row_height;
|
||||
CalculateItemY (item, property_grid.RootGridItem.GridItems, ref itemY);
|
||||
int value = vbar.Value;;
|
||||
CalculateItemY (item, this.RootGridItem.GridItems, ref itemY);
|
||||
if (itemY < 0) // the new item is above the viewable area
|
||||
vbar.Value += itemY / row_height;
|
||||
value += itemY / row_height;
|
||||
else if (itemY + row_height > Height) // the new item is below the viewable area
|
||||
vbar.Value += ((itemY + row_height) - Height) / row_height + 1;
|
||||
value += ((itemY + row_height) - Height) / row_height + 1;
|
||||
if (value >= vbar.Minimum && value <= vbar.Maximum)
|
||||
vbar.Value = value;
|
||||
}
|
||||
|
||||
internal void SelectItem (GridItem oldItem, GridItem newItem)
|
||||
internal void SelectItem (GridEntry oldItem, GridEntry newItem)
|
||||
{
|
||||
if (oldItem != null)
|
||||
InvalidateItemLabel ((GridEntry)oldItem);
|
||||
InvalidateItemLabel (oldItem);
|
||||
if (newItem != null) {
|
||||
UpdateItem ((GridEntry) newItem);
|
||||
EnsureItemIsVisible ((GridEntry) newItem);
|
||||
UpdateItem (newItem);
|
||||
ScrollToItem (newItem);
|
||||
} else
|
||||
grid_textbox.Visible = false;
|
||||
}
|
||||
|
||||
internal void UpdateView ()
|
||||
{
|
||||
UpdateItem ((GridEntry)property_grid.SelectedGridItem);
|
||||
UpdateScrollBar ();
|
||||
UpdateItem (this.SelectedGridItem);
|
||||
Invalidate ();
|
||||
Update ();
|
||||
}
|
||||
|
||||
internal void ExpandItem (GridEntry item)
|
||||
{
|
||||
UpdateItem (this.SelectedGridItem);
|
||||
Invalidate (new Rectangle (0, item.Top, Width, Height - item.Top));
|
||||
}
|
||||
|
||||
internal void CollapseItem (GridEntry item)
|
||||
{
|
||||
UpdateItem (this.SelectedGridItem);
|
||||
Invalidate (new Rectangle (0, item.Top, Width, Height - item.Top));
|
||||
}
|
||||
|
||||
private void ShowDropDownControl (Control control, bool block) {
|
||||
Object queue_id;
|
||||
|
||||
Form owner = FindForm ();
|
||||
|
||||
Point location;
|
||||
private void ShowDropDownControl (Control control)
|
||||
{
|
||||
dropdown_form.Size = control.Size;
|
||||
control.Dock = DockStyle.Fill;
|
||||
dropdown_form.Controls.Clear ();
|
||||
dropdown_form.Controls.Add (control);
|
||||
dropdown_form.Location = PointToScreen (new Point (SplitterLocation, grid_textbox.Location.Y + row_height));
|
||||
location = dropdown_form.Location;
|
||||
|
||||
dropdown_form.Width = ClientRectangle.Width - SplitterLocation - (vbar.Visible ? vbar.Width : 0);
|
||||
dropdown_form.Width = Math.Max (ClientRectangle.Width - SplitterLocation - (vbar.Visible ? vbar.Width : 0),
|
||||
control.Width);
|
||||
dropdown_form.Location = PointToScreen (new Point (grid_textbox.Right - control.Width, grid_textbox.Location.Y + row_height));
|
||||
RepositionInScreenWorkingArea (dropdown_form);
|
||||
Point location = dropdown_form.Location;
|
||||
|
||||
Form owner = FindForm ();
|
||||
owner.AddOwnedForm (dropdown_form);
|
||||
|
||||
dropdown_form.Show ();
|
||||
|
||||
if (dropdown_form.Location != location) {
|
||||
if (dropdown_form.Location != location)
|
||||
dropdown_form.Location = location;
|
||||
}
|
||||
if (block) {
|
||||
System.Windows.Forms.MSG msg = new MSG ();
|
||||
queue_id = XplatUI.StartLoop (Thread.CurrentThread);
|
||||
while (dropdown_form.Visible && XplatUI.GetMessage (queue_id, ref msg, IntPtr.Zero, 0, 0)) {
|
||||
switch (msg.message) {
|
||||
case Msg.WM_NCLBUTTONDOWN:
|
||||
case Msg.WM_NCMBUTTONDOWN:
|
||||
case Msg.WM_NCRBUTTONDOWN:
|
||||
case Msg.WM_LBUTTONDOWN:
|
||||
case Msg.WM_MBUTTONDOWN:
|
||||
case Msg.WM_RBUTTONDOWN:
|
||||
if (!HwndInControl (dropdown_form, msg.hwnd))
|
||||
CloseDropDown ();
|
||||
break;
|
||||
case Msg.WM_ACTIVATE:
|
||||
case Msg.WM_NCPAINT:
|
||||
if (owner.window.Handle == msg.hwnd)
|
||||
CloseDropDown ();
|
||||
break;
|
||||
}
|
||||
XplatUI.TranslateMessage (ref msg);
|
||||
XplatUI.DispatchMessage (ref msg);
|
||||
|
||||
System.Windows.Forms.MSG msg = new MSG ();
|
||||
object queue_id = XplatUI.StartLoop (Thread.CurrentThread);
|
||||
while (dropdown_form.Visible && XplatUI.GetMessage (queue_id, ref msg, IntPtr.Zero, 0, 0)) {
|
||||
switch (msg.message) {
|
||||
case Msg.WM_NCLBUTTONDOWN:
|
||||
case Msg.WM_NCMBUTTONDOWN:
|
||||
case Msg.WM_NCRBUTTONDOWN:
|
||||
case Msg.WM_LBUTTONDOWN:
|
||||
case Msg.WM_MBUTTONDOWN:
|
||||
case Msg.WM_RBUTTONDOWN:
|
||||
if (!HwndInControl (dropdown_form, msg.hwnd))
|
||||
CloseDropDown ();
|
||||
break;
|
||||
case Msg.WM_ACTIVATE:
|
||||
case Msg.WM_NCPAINT:
|
||||
if (owner.window.Handle == msg.hwnd)
|
||||
CloseDropDown ();
|
||||
break;
|
||||
}
|
||||
XplatUI.EndLoop (Thread.CurrentThread);
|
||||
XplatUI.TranslateMessage (ref msg);
|
||||
XplatUI.DispatchMessage (ref msg);
|
||||
}
|
||||
XplatUI.EndLoop (Thread.CurrentThread);
|
||||
}
|
||||
|
||||
private void RepositionInScreenWorkingArea (Form form)
|
||||
{
|
||||
Rectangle workingArea = Screen.FromControl (form).WorkingArea;
|
||||
if (!workingArea.Contains (form.Bounds)) {
|
||||
int x, y;
|
||||
x = form.Location.X;
|
||||
y = form.Location.Y;
|
||||
|
||||
if (form.Location.X < workingArea.X)
|
||||
x = workingArea.X;
|
||||
|
||||
if (form.Location.Y + form.Size.Height > workingArea.Height) {
|
||||
Point aboveTextBox = PointToScreen (new Point (grid_textbox.Right - form.Width, grid_textbox.Location.Y));
|
||||
y = aboveTextBox.Y - form.Size.Height;
|
||||
}
|
||||
|
||||
form.Location = new Point (x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -899,14 +1011,14 @@ namespace System.Windows.Forms.PropertyGridInternal {
|
||||
|
||||
#region IWindowsFormsEditorService Members
|
||||
|
||||
public void CloseDropDown () {
|
||||
Control c = dropdown_form.Controls[0];
|
||||
c.Capture = false;
|
||||
public void CloseDropDown ()
|
||||
{
|
||||
dropdown_form.Hide ();
|
||||
dropdown_form.Controls.Clear ();
|
||||
}
|
||||
|
||||
public void DropDownControl (Control control) {
|
||||
ShowDropDownControl (control, true);
|
||||
ShowDropDownControl (control);
|
||||
}
|
||||
|
||||
public System.Windows.Forms.DialogResult ShowDialog (Form dialog) {
|
||||
|
||||
@@ -34,11 +34,13 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
[MonoTODO ("needs to implement IRootGridEntry")]
|
||||
internal class RootGridEntry : GridEntry /*, IRootGridEntry */
|
||||
{
|
||||
object val;
|
||||
object[] val;
|
||||
|
||||
public RootGridEntry (PropertyGrid owner, object obj)
|
||||
: base (owner)
|
||||
public RootGridEntry (PropertyGrid owner, object[] obj)
|
||||
: base (owner, null)
|
||||
{
|
||||
if (obj == null || obj.Length == 0)
|
||||
throw new ArgumentNullException ("obj");
|
||||
val = obj;
|
||||
}
|
||||
|
||||
@@ -47,10 +49,14 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
}
|
||||
|
||||
public override string Label {
|
||||
get { return val.GetType().ToString(); }
|
||||
get { return val.Length > 1 ? val.GetType().ToString() : val[0].GetType().ToString(); }
|
||||
}
|
||||
|
||||
public override object Value {
|
||||
get { return val.Length > 1 ? val : val[0]; }
|
||||
}
|
||||
|
||||
public override object[] Values {
|
||||
get { return val; }
|
||||
}
|
||||
|
||||
@@ -66,5 +72,13 @@ namespace System.Windows.Forms.PropertyGridInternal
|
||||
public override bool IsEditable {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool IsResetable {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool IsMerged {
|
||||
get { return val.Length > 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -305,9 +305,10 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
private static void SendInput() {
|
||||
IntPtr hwnd = IntPtr.Zero;
|
||||
if (XplatUI.GetActive () != IntPtr.Zero) {
|
||||
Form active = ((Form) Control.FromHandle (XplatUI.GetActive ()));
|
||||
IntPtr hwnd = XplatUI.GetActive ();
|
||||
|
||||
if (hwnd != IntPtr.Zero) {
|
||||
Form active = ((Form) Control.FromHandle (hwnd));
|
||||
if (active != null && active.ActiveControl != null)
|
||||
hwnd = active.ActiveControl.Handle;
|
||||
else if (active != null)
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace System.Windows.Forms
|
||||
// some way.
|
||||
|
||||
owner.OnMouseDown (e);
|
||||
// doesn't chain up
|
||||
base.OnMouseDown (e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp (MouseEventArgs e)
|
||||
@@ -285,7 +285,7 @@ namespace System.Windows.Forms
|
||||
// some way.
|
||||
|
||||
owner.OnMouseUp (e);
|
||||
// doesn't chain up
|
||||
base.OnMouseUp (e);
|
||||
}
|
||||
|
||||
// XXX there are likely more events that forward up to the UpDown
|
||||
|
||||
@@ -1788,6 +1788,7 @@ namespace System.Windows.Forms {
|
||||
HIViewSetVisible (hwnd.client_window, visible);
|
||||
|
||||
hwnd.visible = visible;
|
||||
hwnd.Mapped = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1596,7 +1596,7 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
hwnd.ClientWindow = WindowHandle;
|
||||
|
||||
hwnd.Mapped = true;
|
||||
Win32SetWindowLong(WindowHandle, WindowLong.GWL_USERDATA, (uint)ThemeEngine.Current.DefaultControlBackColor.ToArgb());
|
||||
|
||||
return WindowHandle;
|
||||
|
||||
@@ -4672,7 +4672,10 @@ namespace System.Windows.Forms {
|
||||
xevent.ClientMessageEvent.ptr3 = wparam;
|
||||
xevent.ClientMessageEvent.ptr4 = lparam;
|
||||
|
||||
hwnd.Queue.EnqueueLocked (xevent);
|
||||
if (hwnd != null)
|
||||
hwnd.Queue.EnqueueLocked (xevent);
|
||||
else
|
||||
ThreadQueue(Thread.CurrentThread).EnqueueLocked (xevent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2008-02-01 Jonathan Pobst <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* ListBoxTest.cs: Disable test that is default font dependent.
|
||||
|
||||
2008-01-28 Carlos Alberto Cortez <[email protected]>
|
||||
|
||||
* ComboBoxTest.cs: New SelectedTextWithBinding test - for #333750.
|
||||
|
||||
@@ -120,8 +120,12 @@ namespace MonoTests.System.Windows.Forms
|
||||
}
|
||||
|
||||
[Test] // bug #80620
|
||||
[NUnit.Framework.Category ("NotWorking")]
|
||||
public void ClientRectangle_Borders ()
|
||||
{
|
||||
// This test is invalid because createcontrol forces .net to resize
|
||||
// the listbox using integralheight, which defaults to true. This
|
||||
// will only hold for most font sizes.
|
||||
listBox.CreateControl ();
|
||||
Assert.AreEqual (listBox.ClientRectangle, new ListBox ().ClientRectangle);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2008-02-06 Andreia Gaita <[email protected]>
|
||||
[Backport to 1.9]
|
||||
* Navigation.cs: Pass the proper flags to reload
|
||||
|
||||
2008-01-28 Andreia Gaita <[email protected]>
|
||||
|
||||
* Assembly/AssemblyInfo.cs: Version change
|
||||
|
||||
@@ -104,11 +104,7 @@ namespace Mono.Mozilla.DOM
|
||||
|
||||
public void Reload ()
|
||||
{
|
||||
if (navigation == null)
|
||||
return;
|
||||
|
||||
control.Reset ();
|
||||
navigation.reload ((uint)ReloadOption.None);
|
||||
Reload (ReloadOption.None);
|
||||
}
|
||||
|
||||
public void Reload (ReloadOption option)
|
||||
@@ -117,7 +113,12 @@ namespace Mono.Mozilla.DOM
|
||||
return;
|
||||
|
||||
control.Reset ();
|
||||
navigation.reload ((uint)option);
|
||||
if (option == ReloadOption.None)
|
||||
navigation.reload ((uint)LoadFlags.None);
|
||||
else if (option == ReloadOption.Proxy)
|
||||
navigation.reload ((uint) LoadFlags.BypassLocalCache);
|
||||
else if (option == ReloadOption.Full)
|
||||
navigation.reload ((uint) LoadFlags.BypassProxy);
|
||||
}
|
||||
|
||||
public void Stop ()
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2008-01-28 Jonathan Pryor <[email protected]>
|
||||
|
||||
* Mono.Posix.dll.sources: Add Mono.Unix/UnixSignal.cs.
|
||||
|
||||
2006-10-24 Jonathan Pryor <[email protected]>
|
||||
|
||||
* Makefile: Don't build make-map.exe.
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
./Mono.Unix/UnixPath.cs
|
||||
./Mono.Unix/UnixPipes.cs
|
||||
./Mono.Unix/UnixProcess.cs
|
||||
./Mono.Unix/UnixSignal.cs
|
||||
./Mono.Unix/UnixStream.cs
|
||||
./Mono.Unix/UnixSymbolicLinkInfo.cs
|
||||
./Mono.Unix/UnixUserInfo.cs
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
2008-01-28 Jonathan Pryor <[email protected]>
|
||||
|
||||
* Stdlib.cs: Obsolete Stdlib.signal(), as it's not safe; see also:
|
||||
http://lists.ximian.com/pipermail/mono-devel-list/2008-January/026501.html
|
||||
http://lists.ximian.com/pipermail/mono-devel-list/2008-January/026503.html
|
||||
Add SetSignalAction() as a replacement.
|
||||
|
||||
2008-01-22 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* Syscall.cs: Fix Flock.Equals to avoid NRE (and return false if object
|
||||
|
||||
@@ -267,6 +267,12 @@ namespace Mono.Unix.Native {
|
||||
}
|
||||
|
||||
|
||||
public enum SignalAction {
|
||||
Default,
|
||||
Ignore,
|
||||
Error
|
||||
}
|
||||
|
||||
//
|
||||
// Right now using this attribute gives an assert because it
|
||||
// isn't implemented.
|
||||
@@ -454,6 +460,8 @@ namespace Mono.Unix.Native {
|
||||
private static extern IntPtr sys_signal (int signum, IntPtr handler);
|
||||
|
||||
[CLSCompliant (false)]
|
||||
[Obsolete ("This is not safe; " +
|
||||
"use Mono.Unix.UnixSignal for signal delivery or SetSignalAction()")]
|
||||
public static SignalHandler signal (Signum signum, SignalHandler handler)
|
||||
{
|
||||
int _sig = NativeConvert.FromSignum (signum);
|
||||
@@ -494,6 +502,28 @@ namespace Mono.Unix.Native {
|
||||
#endif
|
||||
}
|
||||
|
||||
public static int SetSignalAction (Signum signal, SignalAction action)
|
||||
{
|
||||
IntPtr handler = IntPtr.Zero;
|
||||
switch (action) {
|
||||
case SignalAction.Default:
|
||||
handler = _SIG_DFL;
|
||||
break;
|
||||
case SignalAction.Ignore:
|
||||
handler = _SIG_IGN;
|
||||
break;
|
||||
case SignalAction.Error:
|
||||
handler = _SIG_ERR;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException ("Invalid action value.", "action");
|
||||
}
|
||||
IntPtr r = sys_signal (NativeConvert.FromSignum (signal), handler);
|
||||
if (r == _SIG_ERR)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, EntryPoint="raise")]
|
||||
private static extern int sys_raise (int sig);
|
||||
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
2008-02-11 Jonathan Pryor <[email protected]>
|
||||
|
||||
* UnixSignal.cs: Improve argument checking to match docs.
|
||||
|
||||
2008-02-08 Jonathan Pryor <[email protected]>
|
||||
|
||||
* UnixSignal.cs: UnixSignal.WaitAny() should have the same return type as
|
||||
WaitHandle.WaitAny(). Oops.
|
||||
|
||||
2008-02-08 Jonathan Pryor <[email protected]>
|
||||
|
||||
* UnixSignal.cs: Modification of Info->count should be thread safe.
|
||||
|
||||
2008-01-28 Jonathan Pryor <[email protected]>
|
||||
|
||||
* UnixSignal.cs: Added; Polling and blocking based Unix signal mechanism.
|
||||
http://lists.ximian.com/pipermail/mono-devel-list/2008-January/026501.html
|
||||
|
||||
2008-01-22 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* UnixPipes.cs: Fix Equals to avoid NRE (and return false if object
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
//
|
||||
// Mono.Unix/UnixSignal.cs
|
||||
//
|
||||
// Authors:
|
||||
// Jonathan Pryor ([email protected])
|
||||
//
|
||||
// (C) 2008 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
using Mono.Unix.Native;
|
||||
|
||||
namespace Mono.Unix {
|
||||
public class UnixSignal : WaitHandle {
|
||||
private Signum signum;
|
||||
private IntPtr signal_info;
|
||||
|
||||
public UnixSignal (Signum signum)
|
||||
{
|
||||
this.signum = signum;
|
||||
// ensure signum is a valid signal
|
||||
int _signum = NativeConvert.FromSignum (signum);
|
||||
this.signal_info = install (_signum);
|
||||
if (this.signal_info == IntPtr.Zero) {
|
||||
throw new ArgumentException ("Unable to handle signal", "signum");
|
||||
}
|
||||
}
|
||||
|
||||
public Signum Signum {
|
||||
get {
|
||||
AssertValid ();
|
||||
return signum;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Stdlib.MPH, CallingConvention=CallingConvention.Cdecl,
|
||||
EntryPoint="Mono_Unix_UnixSignal_install")]
|
||||
private static extern IntPtr install (int signum);
|
||||
|
||||
[DllImport (Stdlib.MPH, CallingConvention=CallingConvention.Cdecl,
|
||||
EntryPoint="Mono_Unix_UnixSignal_uninstall")]
|
||||
private static extern int uninstall (IntPtr info);
|
||||
|
||||
[DllImport (Stdlib.MPH, CallingConvention=CallingConvention.Cdecl,
|
||||
EntryPoint="Mono_Unix_UnixSignal_WaitAny")]
|
||||
private static extern int WaitAny (IntPtr[] infos, int count, int timeout);
|
||||
|
||||
private void AssertValid ()
|
||||
{
|
||||
if (signal_info == IntPtr.Zero)
|
||||
throw new ObjectDisposedException (GetType().FullName);
|
||||
}
|
||||
|
||||
private unsafe SignalInfo* Info {
|
||||
get {
|
||||
AssertValid ();
|
||||
return (SignalInfo*) signal_info;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSet {
|
||||
get {
|
||||
return Count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe bool Reset ()
|
||||
{
|
||||
int n = Interlocked.Exchange (ref Info->count, 0);
|
||||
return n != 0;
|
||||
}
|
||||
|
||||
public unsafe int Count {
|
||||
get {return Info->count;}
|
||||
set {Interlocked.Exchange (ref Info->count, value);}
|
||||
}
|
||||
|
||||
[Map]
|
||||
struct SignalInfo {
|
||||
public int signum, count, read_fd, write_fd, have_handler;
|
||||
public IntPtr handler;
|
||||
}
|
||||
|
||||
#region WaitHandle overrides
|
||||
protected unsafe override void Dispose (bool disposing)
|
||||
{
|
||||
base.Dispose (disposing);
|
||||
if (signal_info == IntPtr.Zero)
|
||||
return;
|
||||
uninstall (signal_info);
|
||||
signal_info = IntPtr.Zero;
|
||||
}
|
||||
|
||||
public override bool WaitOne ()
|
||||
{
|
||||
return WaitOne (-1, false);
|
||||
}
|
||||
|
||||
public override bool WaitOne (TimeSpan timeout, bool exitContext)
|
||||
{
|
||||
long ms = (long) timeout.TotalMilliseconds;
|
||||
if (ms < -1 || ms > Int32.MaxValue)
|
||||
throw new ArgumentOutOfRangeException ("timeout");
|
||||
return WaitOne ((int) ms, exitContext);
|
||||
}
|
||||
|
||||
public override bool WaitOne (int millisecondsTimeout, bool exitContext)
|
||||
{
|
||||
AssertValid ();
|
||||
if (exitContext)
|
||||
throw new InvalidOperationException ("exitContext is not supported");
|
||||
return WaitAny (new UnixSignal[]{this}, millisecondsTimeout) == 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static int WaitAny (UnixSignal[] signals)
|
||||
{
|
||||
return WaitAny (signals, -1);
|
||||
}
|
||||
|
||||
public static int WaitAny (UnixSignal[] signals, TimeSpan timeout)
|
||||
{
|
||||
long ms = (long) timeout.TotalMilliseconds;
|
||||
if (ms < -1 || ms > Int32.MaxValue)
|
||||
throw new ArgumentOutOfRangeException ("timeout");
|
||||
return WaitAny (signals, (int) ms);
|
||||
}
|
||||
|
||||
public static unsafe int WaitAny (UnixSignal[] signals, int millisecondsTimeout)
|
||||
{
|
||||
if (signals == null)
|
||||
throw new ArgumentNullException ("signals");
|
||||
if (millisecondsTimeout < -1)
|
||||
throw new ArgumentOutOfRangeException ("millisecondsTimeout");
|
||||
IntPtr[] infos = new IntPtr [signals.Length];
|
||||
for (int i = 0; i < signals.Length; ++i) {
|
||||
infos [i] = signals [i].signal_info;
|
||||
if (infos [i] == IntPtr.Zero)
|
||||
throw new InvalidOperationException ("Disposed UnixSignal");
|
||||
}
|
||||
return WaitAny (infos, infos.Length, millisecondsTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,35 @@
|
||||
2008-02-21 Marek Habersack <[email protected]>
|
||||
|
||||
* Configuration.cs: if the section being deserialized uses the
|
||||
configSource attribute, call the section's DeserializeConfigSource
|
||||
method.
|
||||
|
||||
* SectionInfo.cs: WriteData takes care of writing the section data
|
||||
to the configSource file, if any.
|
||||
|
||||
* ConfigurationSection.cs: moved reading of the configSource
|
||||
external data file to a separate internal method,
|
||||
DeserializeConfigSource. Section's source config file path is now
|
||||
used to find the configSource.
|
||||
SerializeSection now doesn't write the section content to the
|
||||
passed writer if configSource was used. Writing of the section
|
||||
data is now done in SectionInfo.
|
||||
|
||||
* ConfigurationElement.cs: added a new method -
|
||||
HasLocalModifications which returns true of any of the element
|
||||
properties have been set locally on that element.
|
||||
|
||||
2008-02-20 Marek Habersack <[email protected]>
|
||||
|
||||
* ConfigurationSection.cs: support the "configSource" attribute
|
||||
when deserializing a section. Contents of the file (if it exists)
|
||||
replaces the previous section contents.
|
||||
|
||||
* ConfigurationElement.cs: ignore the "configSource" attribute if we're a
|
||||
ConfigurationSection instance.
|
||||
HasValues () returns true only if any of the properties has the
|
||||
origin set to SetHere.
|
||||
|
||||
2008-01-16 Zoltan Varga <[email protected]>
|
||||
|
||||
* ConfigurationElement.cs: Allow non-public constructors. Fixes #353554.
|
||||
|
||||
@@ -280,6 +280,9 @@ namespace System.Configuration {
|
||||
XmlTextReader r = new XmlTextReader (new StringReader (xml));
|
||||
sec.DeserializeSection (r);
|
||||
r.Close ();
|
||||
|
||||
if (!String.IsNullOrEmpty (sec.SectionInformation.ConfigSource) && !String.IsNullOrEmpty (FilePath))
|
||||
sec.DeserializeConfigSource (Path.GetDirectoryName (FilePath));
|
||||
}
|
||||
|
||||
elementData [config] = sec;
|
||||
|
||||
@@ -271,6 +271,16 @@ namespace System.Configuration
|
||||
foreach (PropertyInformation pi in ElementInformation.Properties)
|
||||
if (pi.ValueOrigin != PropertyValueOrigin.Default)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal virtual bool HasLocalModifications ()
|
||||
{
|
||||
foreach (PropertyInformation pi in ElementInformation.Properties)
|
||||
if (pi.ValueOrigin == PropertyValueOrigin.SetHere)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -301,8 +311,9 @@ namespace System.Configuration
|
||||
}
|
||||
else if (reader.LocalName == "xmlns") {
|
||||
/* ignore */
|
||||
}
|
||||
else if (!OnDeserializeUnrecognizedAttribute (reader.LocalName, reader.Value))
|
||||
} else if (this is ConfigurationSection && reader.LocalName == "configSource") {
|
||||
/* ignore */
|
||||
} else if (!OnDeserializeUnrecognizedAttribute (reader.LocalName, reader.Value))
|
||||
throw new ConfigurationException ("Unrecognized attribute '" + reader.LocalName + "'.");
|
||||
|
||||
continue;
|
||||
|
||||
@@ -41,11 +41,16 @@ namespace System.Configuration
|
||||
{
|
||||
SectionInformation sectionInformation;
|
||||
IConfigurationSectionHandler section_handler;
|
||||
|
||||
string externalDataXml;
|
||||
|
||||
protected ConfigurationSection ()
|
||||
{
|
||||
}
|
||||
|
||||
internal string ExternalDataXml {
|
||||
get { return externalDataXml; }
|
||||
}
|
||||
|
||||
internal IConfigurationSectionHandler SectionHandler {
|
||||
get { return section_handler; }
|
||||
set { section_handler = value; }
|
||||
@@ -95,21 +100,27 @@ namespace System.Configuration
|
||||
elem.SetReadOnly ();
|
||||
return elem;
|
||||
}
|
||||
|
||||
|
||||
[MonoInternalNote ("find the proper location for the decryption stuff")]
|
||||
protected internal virtual void DeserializeSection (XmlReader reader)
|
||||
{
|
||||
reader.MoveToContent ();
|
||||
|
||||
string protection_provider = null;
|
||||
string config_source = null;
|
||||
string localName;
|
||||
|
||||
while (reader.MoveToNextAttribute ()) {
|
||||
localName = reader.LocalName;
|
||||
|
||||
if (localName == "configProtectionProvider")
|
||||
protection_provider = reader.Value;
|
||||
else if (localName == "configSource")
|
||||
config_source = reader.Value;
|
||||
}
|
||||
|
||||
/* XXX this stuff shouldn't be here */
|
||||
{
|
||||
string protection_provider = null;
|
||||
|
||||
while (reader.MoveToNextAttribute ()) {
|
||||
if (reader.LocalName == "configProtectionProvider")
|
||||
protection_provider = reader.Value;
|
||||
}
|
||||
|
||||
if (protection_provider != null) {
|
||||
ProtectedConfigurationProvider prov = ProtectedConfiguration.GetProvider (protection_provider, true);
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
@@ -128,12 +139,41 @@ namespace System.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
if (config_source != null)
|
||||
SectionInformation.ConfigSource = config_source;
|
||||
|
||||
SectionInformation.SetRawXml (RawXml);
|
||||
DeserializeElement (reader, false);
|
||||
}
|
||||
|
||||
internal void DeserializeConfigSource (string basePath)
|
||||
{
|
||||
string config_source = SectionInformation.ConfigSource;
|
||||
|
||||
if (String.IsNullOrEmpty (config_source))
|
||||
return;
|
||||
|
||||
if (Path.IsPathRooted (config_source))
|
||||
throw new ConfigurationException ("The configSource attribute must be a relative physical path.");
|
||||
|
||||
if (HasLocalModifications ())
|
||||
throw new ConfigurationException ("A section using 'configSource' may contain no other attributes or elements.");
|
||||
|
||||
string path = Path.Combine (basePath, config_source);
|
||||
if (!File.Exists (path)) {
|
||||
RawXml = null;
|
||||
SectionInformation.SetRawXml (null);
|
||||
return;
|
||||
}
|
||||
|
||||
RawXml = File.ReadAllText (path);
|
||||
SectionInformation.SetRawXml (RawXml);
|
||||
DeserializeElement (new XmlTextReader (new StringReader (RawXml)), false);
|
||||
}
|
||||
|
||||
protected internal virtual string SerializeSection (ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode)
|
||||
{
|
||||
externalDataXml = null;
|
||||
ConfigurationElement elem;
|
||||
if (parentElement != null) {
|
||||
elem = (ConfigurationElement) CreateElement (GetType());
|
||||
@@ -141,13 +181,37 @@ namespace System.Configuration
|
||||
}
|
||||
else
|
||||
elem = this;
|
||||
|
||||
string ret;
|
||||
using (StringWriter sw = new StringWriter ()) {
|
||||
using (XmlTextWriter tw = new XmlTextWriter (sw)) {
|
||||
tw.Formatting = Formatting.Indented;
|
||||
elem.SerializeToXmlElement (tw, name);
|
||||
tw.Close ();
|
||||
}
|
||||
|
||||
ret = sw.ToString ();
|
||||
}
|
||||
|
||||
string config_source = SectionInformation.ConfigSource;
|
||||
|
||||
if (String.IsNullOrEmpty (config_source))
|
||||
return ret;
|
||||
|
||||
StringWriter sw = new StringWriter ();
|
||||
XmlTextWriter tw = new XmlTextWriter (sw);
|
||||
tw.Formatting = Formatting.Indented;
|
||||
elem.SerializeToXmlElement (tw, name);
|
||||
tw.Close ();
|
||||
return sw.ToString ();
|
||||
externalDataXml = ret;
|
||||
using (StringWriter sw = new StringWriter ()) {
|
||||
bool haveName = !String.IsNullOrEmpty (name);
|
||||
|
||||
using (XmlTextWriter tw = new XmlTextWriter (sw)) {
|
||||
if (haveName)
|
||||
tw.WriteStartElement (name);
|
||||
tw.WriteAttributeString ("configSource", config_source);
|
||||
if (haveName)
|
||||
tw.WriteEndElement ();
|
||||
}
|
||||
|
||||
return sw.ToString ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,6 +195,16 @@ namespace System.Configuration
|
||||
ConfigurationSection parentSection = config.Parent != null ? config.Parent.GetSectionInstance (this, false) : null;
|
||||
xml = section.SerializeSection (parentSection, Name, mode);
|
||||
|
||||
string externalDataXml = section.ExternalDataXml;
|
||||
string filePath = config.FilePath;
|
||||
|
||||
if (!String.IsNullOrEmpty (filePath) && !String.IsNullOrEmpty (externalDataXml)) {
|
||||
string path = Path.Combine (Path.GetDirectoryName (filePath), section.SectionInformation.ConfigSource);
|
||||
using (StreamWriter sw = new StreamWriter (path)) {
|
||||
sw.Write (externalDataXml);
|
||||
}
|
||||
}
|
||||
|
||||
if (section.SectionInformation.IsProtected) {
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
sb.AppendFormat ("<{0} configProtectionProvider=\"{1}\">\n",
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
2008-02-25 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* DateTimeEditor.cs: Set the calendar to the currently edited
|
||||
date. Patch by Andy Hume. Code is contributed under
|
||||
MIT/X11 license.
|
||||
[Fixes #362749]
|
||||
|
||||
2008-02-16 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* CollectionEditor.cs: Handle null collection.
|
||||
[Part of fix for bugs #360666 and #358332]
|
||||
|
||||
2008-02-12 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* DateTimeEditor.cs: Set edit value only if the user sets it
|
||||
in the editor.
|
||||
[Fixes #359159]
|
||||
|
||||
2008-02-05 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* MutilineStringEditor.cs: Make BorderStyle, Width and Height
|
||||
sensible.
|
||||
[Fixes #356530]
|
||||
|
||||
2008-01-22 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* MutilineStringEditor.cs: Fix EditValue to return the new
|
||||
|
||||
@@ -84,9 +84,23 @@ namespace System.ComponentModel.Design
|
||||
{
|
||||
get { return editor.GetItems (editValue); }
|
||||
set {
|
||||
object val = editor.SetItems (editValue, value);
|
||||
if (val != EditValue)
|
||||
EditValue = val;
|
||||
if (editValue == null) {
|
||||
object newEmptyCollection = null;
|
||||
try {
|
||||
if (typeof (Array).IsAssignableFrom (CollectionType))
|
||||
newEmptyCollection = Array.CreateInstance (CollectionItemType, 0);
|
||||
else
|
||||
newEmptyCollection = Activator.CreateInstance (CollectionType);
|
||||
} catch {}
|
||||
|
||||
object val = editor.SetItems (newEmptyCollection, value);
|
||||
if (val != newEmptyCollection)
|
||||
EditValue = val;
|
||||
} else {
|
||||
object val = editor.SetItems (editValue, value);
|
||||
if (val != editValue)
|
||||
EditValue = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,9 +632,7 @@ namespace System.ComponentModel.Design
|
||||
{
|
||||
CollectionForm editorForm = CreateCollectionForm ();
|
||||
editorForm.EditValue = value;
|
||||
|
||||
editorForm.ShowEditorDialog (editorService);
|
||||
|
||||
return editorForm.EditValue;
|
||||
}
|
||||
}
|
||||
@@ -655,7 +667,7 @@ namespace System.ComponentModel.Design
|
||||
protected virtual object[] GetItems (object editValue)
|
||||
{
|
||||
if (editValue == null)
|
||||
return null;
|
||||
return new object[0];
|
||||
ICollection collection = editValue as ICollection;
|
||||
if (collection == null)
|
||||
return new object[0];
|
||||
@@ -679,19 +691,11 @@ namespace System.ComponentModel.Design
|
||||
|
||||
protected virtual object SetItems (object editValue, object[] value)
|
||||
{
|
||||
IList list;
|
||||
|
||||
if (editValue == null)
|
||||
IList list = (IList) editValue;
|
||||
if (list == null)
|
||||
return null;
|
||||
|
||||
if (!(editValue is IList))
|
||||
list = new ArrayList ();
|
||||
else
|
||||
{
|
||||
list = editValue as IList;
|
||||
list.Clear ();
|
||||
}
|
||||
|
||||
list.Clear ();
|
||||
foreach (object o in value)
|
||||
list.Add (o);
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ namespace System.ComponentModel.Design
|
||||
|
||||
public DateTimeEditor ()
|
||||
{
|
||||
control.LostFocus += new EventHandler (changeHandler);
|
||||
control.DateSelected += new DateRangeEventHandler (control_DateSelected);
|
||||
}
|
||||
|
||||
@@ -71,9 +70,9 @@ namespace System.ComponentModel.Design
|
||||
|
||||
editContent = (DateTime)value;
|
||||
if (editContent > control.MaxDate || editContent < control.MinDate)
|
||||
editContent = DateTime.Today;
|
||||
|
||||
control.SelectionStart = editContent;
|
||||
control.SelectionStart = DateTime.Today;
|
||||
else
|
||||
control.SelectionStart = editContent;
|
||||
|
||||
editorService.DropDownControl (control);
|
||||
|
||||
@@ -83,11 +82,6 @@ namespace System.ComponentModel.Design
|
||||
return base.EditValue (context, provider, value);
|
||||
}
|
||||
|
||||
void changeHandler (object sender, EventArgs e)
|
||||
{
|
||||
editContent = control.SelectionStart;
|
||||
}
|
||||
|
||||
void control_DateSelected (object sender, DateRangeEventArgs e)
|
||||
{
|
||||
editContent = e.Start;
|
||||
|
||||
@@ -45,10 +45,11 @@ namespace System.ComponentModel.Design
|
||||
{
|
||||
Multiline = true;
|
||||
AcceptsReturn = true;
|
||||
Height = 250;
|
||||
Height = 135;
|
||||
Width = 280;
|
||||
ScrollBars = ScrollBars.Both;
|
||||
WordWrap = false;
|
||||
BorderStyle = BorderStyle.None;
|
||||
BorderStyle = BorderStyle.FixedSingle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace System.Windows.Forms.Design
|
||||
{
|
||||
this.SuspendLayout();
|
||||
this.Name = "AnchorSelector";
|
||||
this.Size = new System.Drawing.Size (40, 120);
|
||||
this.Size = new System.Drawing.Size (150, 120);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2008-02-11 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* AnchorEditor.cs: More sensible default width.
|
||||
|
||||
2008-01-24 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* DockEditor.cs: ITypeDescriptorContext.Instance doesn't
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
2008-02-08 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* ColorEditor.cs: Fix Height to include the last 8th row.
|
||||
|
||||
2008-02-05 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* ColorEditor.cs: Set the Height to match the custom colors tab
|
||||
Height.
|
||||
[Fixes bug #356527]
|
||||
|
||||
2008-02-04 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* ColorEditor.cs: Perfom action in OnMouseUp only if in client.
|
||||
[Fixes bug #358444]
|
||||
|
||||
2007-11-13 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* ToolboxItemCreator.cs, ToolboxService.cs, ToolboxItemContainer.cs:
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace System.Drawing.Design
|
||||
color_chosen = true;
|
||||
}
|
||||
|
||||
|
||||
tab_control.Height = 216; // the height of the custom colors tab
|
||||
editorService.DropDownControl(tab_control);
|
||||
if (color_chosen) {
|
||||
return selected_color;
|
||||
@@ -344,7 +344,7 @@ namespace System.Drawing.Design
|
||||
|
||||
protected override void OnMouseUp (MouseEventArgs e)
|
||||
{
|
||||
if (highlighting) {
|
||||
if (highlighting && this.ClientRectangle.Contains (e.X, e.Y)) {
|
||||
if (ColorChanged != null)
|
||||
ColorChanged (colors[y / 24, x / 24], EventArgs.Empty);
|
||||
highlighting = false;
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2008-02-16 Ivan N. Zlatev <[email protected]>
|
||||
|
||||
* UITypeEditor.cs: Associate string[] with StringArrayEditor in the
|
||||
editors table.
|
||||
[Part of fix for bugs #360666 and #358332]
|
||||
|
||||
2007-07-10 Rolf Bjarne Kvinge <[email protected]>
|
||||
|
||||
* UITypeEditor.cs: Add a table of special editors (types that can't use
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace System.Drawing.Design
|
||||
editors [typeof (DateTime)] = "System.ComponentModel.Design.DateTimeEditor, " + Consts.AssemblySystem_Design;
|
||||
editors [typeof (IList)] = "System.ComponentModel.Design.CollectionEditor, " + Consts.AssemblySystem_Design;
|
||||
editors [typeof (ICollection)] = "System.ComponentModel.Design.CollectionEditor, " + Consts.AssemblySystem_Design;
|
||||
editors [typeof (string[])] = "System.Windows.Forms.Design.StringArrayEditor, " + Consts.AssemblySystem_Design;
|
||||
TypeDescriptor.AddEditorTable (typeof (UITypeEditor), editors);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2008-02-22 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* ProtocolReflector.cs : reverted previous change, which caused
|
||||
several regressions.
|
||||
|
||||
2007-12-11 Vladimir Krasnov <[email protected]>
|
||||
|
||||
* ProtocolReflector.cs: fixed ImportBinding method, ports with the same
|
||||
|
||||
@@ -278,18 +278,6 @@ namespace System.Web.Services.Description {
|
||||
if (bindingFull)
|
||||
{
|
||||
port.Binding = new XmlQualifiedName (binding.Name, binfo.Namespace);
|
||||
|
||||
int n = 0;
|
||||
string name = binfo.Name;
|
||||
bool found;
|
||||
do {
|
||||
|
||||
found = false;
|
||||
foreach (Port p in service.Ports)
|
||||
if (p.Name == name) { found = true; n++; name = binfo.Name + n; break; }
|
||||
}
|
||||
while (found);
|
||||
port.Name = name;
|
||||
service.Ports.Add (port);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2008-02-22 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* TypeStubManager.cs : reverted 2007-12-11 change as it caused
|
||||
several regressions.
|
||||
|
||||
2008-01-24 Marek Habersack <[email protected]>
|
||||
|
||||
* SoapDocumentationHandler.cs: use a fake virtual path to get the
|
||||
|
||||
@@ -96,18 +96,12 @@ namespace System.Web.Services.Protocols {
|
||||
|
||||
object [] o = Type.GetCustomAttributes (typeof (WebServiceBindingAttribute), false);
|
||||
|
||||
bool defaultAdded = false;
|
||||
|
||||
string defaultBindingName = logicalType.WebServiceName + ProtocolName;
|
||||
if (o.Length > 0)
|
||||
foreach (WebServiceBindingAttribute at in o) {
|
||||
foreach (WebServiceBindingAttribute at in o)
|
||||
AddBinding (new BindingInfo (at, defaultBindingName, LogicalType.WebServiceNamespace));
|
||||
if ((at.Name == null || at.Name.Length == 0) || (at.Name == defaultBindingName))
|
||||
defaultAdded = true;
|
||||
}
|
||||
|
||||
if (!defaultAdded)
|
||||
AddBindingAt (0, new BindingInfo (null, defaultBindingName, logicalType.WebServiceNamespace));
|
||||
else
|
||||
AddBinding (new BindingInfo (null, defaultBindingName, logicalType.WebServiceNamespace));
|
||||
|
||||
#if NET_2_0
|
||||
foreach (Type ifaceType in Type.GetInterfaces ()) {
|
||||
@@ -234,11 +228,6 @@ namespace System.Web.Services.Protocols {
|
||||
{
|
||||
bindings.Add (info);
|
||||
}
|
||||
|
||||
internal void AddBindingAt (int pos, BindingInfo info)
|
||||
{
|
||||
bindings.Insert (pos, info);
|
||||
}
|
||||
|
||||
internal BindingInfo GetBinding (string name)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2008-02-22 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* ServiceDescriptionReflectorTest.cs : mark Bug345448() NotWorking.
|
||||
|
||||
2008-01-08 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* ServiceDescriptionReflectorTest.cs : added test for empty SOAP
|
||||
|
||||
+1
@@ -275,6 +275,7 @@ namespace MonoTests.System.Web.Services.Description
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void Bug345448 ()
|
||||
{
|
||||
ServiceDescriptionReflector r =
|
||||
|
||||
@@ -257,6 +257,9 @@ namespace System.Web.Compilation
|
||||
foreach (Assembly a in BuildManager.TopLevelAssemblies)
|
||||
parameters.ReferencedAssemblies.Add (a.Location);
|
||||
CompilerResults results = abuilder.BuildAssembly (parameters);
|
||||
if (results == null)
|
||||
return;
|
||||
|
||||
if (results.NativeCompilerReturnValue == 0) {
|
||||
BuildManager.CodeAssemblies.Add (results.CompiledAssembly);
|
||||
BuildManager.TopLevelAssemblies.Add (results.CompiledAssembly);
|
||||
|
||||
@@ -114,6 +114,9 @@ namespace System.Web.Compilation
|
||||
cp.EmbeddedResources.Add (f);
|
||||
|
||||
CompilerResults results = abuilder.BuildAssembly (cp);
|
||||
if (results == null)
|
||||
return;
|
||||
|
||||
Assembly ret = null;
|
||||
|
||||
if (results.NativeCompilerReturnValue == 0) {
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace System.Web.Compilation
|
||||
return type;
|
||||
|
||||
ArrayList other_deps = new ArrayList ();
|
||||
type = UserControlParser.GetCompiledType (vpath, realpath, other_deps, context);
|
||||
type = BuildManager.GetCompiledType (vpath);
|
||||
if (type != null) {
|
||||
AspGenerator.AddTypeToCache (other_deps, realpath, type);
|
||||
WebConfigurationManager.ExtraAssemblies.Add (type.Assembly.Location);
|
||||
|
||||
@@ -259,9 +259,19 @@ namespace System.Web.Compilation
|
||||
|
||||
public void Parse (string file)
|
||||
{
|
||||
#if NET_1_1_ONLY
|
||||
InitParser (file);
|
||||
#if ONLY_1_1
|
||||
Parse (file, true);
|
||||
#else
|
||||
Parse (file, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Parse (string file, bool doInitParser)
|
||||
{
|
||||
isApplication = tparser.DefaultDirectiveName == "application";
|
||||
|
||||
if (doInitParser)
|
||||
InitParser (file);
|
||||
|
||||
pstack.Parser.Parse ();
|
||||
if (text.Length > 0)
|
||||
@@ -333,7 +343,6 @@ namespace System.Web.Compilation
|
||||
return type;
|
||||
}
|
||||
|
||||
isApplication = tparser.DefaultDirectiveName == "application";
|
||||
Parse ();
|
||||
|
||||
BaseCompiler compiler = GetCompilerFromType ();
|
||||
@@ -455,7 +464,7 @@ namespace System.Web.Compilation
|
||||
file = GetIncludeFilePath (tparser.BaseDir, file);
|
||||
}
|
||||
|
||||
Parse (file);
|
||||
Parse (file, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -239,6 +239,19 @@ namespace System.Web.Compilation {
|
||||
assemblies.Add (a);
|
||||
}
|
||||
|
||||
internal void AddAssemblyReference (string assemblyLocation)
|
||||
{
|
||||
try {
|
||||
Assembly asm = Assembly.LoadFrom (assemblyLocation);
|
||||
if (asm == null)
|
||||
return;
|
||||
|
||||
AddAssemblyReference (asm);
|
||||
} catch {
|
||||
// ignore, it will come up later
|
||||
}
|
||||
}
|
||||
|
||||
internal void AddAssemblyReference (List <Assembly> asmlist)
|
||||
{
|
||||
if (asmlist == null)
|
||||
@@ -278,7 +291,7 @@ namespace System.Web.Compilation {
|
||||
// Generate a file name with the correct source language extension
|
||||
string filename = GetTempFilePhysicalPath (provider.FileExtension);
|
||||
SourceFiles.Add (filename);
|
||||
return new StreamWriter (File.OpenWrite (filename), WebEncoding.FileEncoding);
|
||||
return new StreamWriter (File.OpenWrite (filename));
|
||||
}
|
||||
|
||||
internal void AddCodeFile (string path)
|
||||
@@ -495,12 +508,18 @@ namespace System.Web.Compilation {
|
||||
// files. This also facilates possible debugging for the
|
||||
// end user, since they get the code beforehand.
|
||||
List <string> files = SourceFiles;
|
||||
Dictionary <string, string> resources = ResourceFiles;
|
||||
|
||||
if (units.Length == 0 && files.Count == 0 && resources.Count == 0 && options.EmbeddedResources.Count == 0)
|
||||
return null;
|
||||
|
||||
string filename;
|
||||
StreamWriter sw = null;
|
||||
|
||||
foreach (CodeCompileUnit unit in units) {
|
||||
filename = GetTempFilePhysicalPath (provider.FileExtension);
|
||||
try {
|
||||
sw = new StreamWriter (File.OpenWrite (filename), WebEncoding.FileEncoding);
|
||||
sw = new StreamWriter (File.OpenWrite (filename));
|
||||
provider.GenerateCodeFromCompileUnit (unit, sw, null);
|
||||
files.Add (filename);
|
||||
} catch {
|
||||
@@ -512,7 +531,7 @@ namespace System.Web.Compilation {
|
||||
}
|
||||
}
|
||||
}
|
||||
Dictionary <string, string> resources = ResourceFiles;
|
||||
|
||||
foreach (KeyValuePair <string, string> de in resources)
|
||||
options.EmbeddedResources.Add (de.Value);
|
||||
foreach (Assembly refasm in ReferencedAssemblies)
|
||||
@@ -528,7 +547,7 @@ namespace System.Web.Compilation {
|
||||
}
|
||||
} catch (Exception) {}
|
||||
|
||||
throw new CompilationException (virtualPath, results.Errors, fileText);
|
||||
throw new CompilationException (virtualPath, results, fileText);
|
||||
}
|
||||
|
||||
Assembly assembly = results.CompiledAssembly;
|
||||
|
||||
@@ -209,6 +209,8 @@ namespace System.Web.Compilation {
|
||||
|
||||
static object buildCacheLock = new object ();
|
||||
|
||||
static Stack <BuildKind> recursiveBuilds = new Stack <BuildKind> ();
|
||||
|
||||
//
|
||||
// Disabled - see comment at the end of BuildAssembly below
|
||||
//
|
||||
@@ -233,7 +235,7 @@ namespace System.Web.Compilation {
|
||||
|
||||
static Assembly globalAsaxAssembly;
|
||||
|
||||
static Dictionary <string, BuildKind> knownFileTypes = new Dictionary <string, BuildKind> () {
|
||||
static Dictionary <string, BuildKind> knownFileTypes = new Dictionary <string, BuildKind> (StringComparer.OrdinalIgnoreCase) {
|
||||
{".aspx", BuildKind.Pages},
|
||||
{".asax", BuildKind.Application},
|
||||
{".ashx", BuildKind.NonPages},
|
||||
@@ -261,7 +263,9 @@ namespace System.Web.Compilation {
|
||||
// Get the Type.
|
||||
Type type = GetCompiledType (virtualPath);
|
||||
if (type == null)
|
||||
throw new HttpException ("Instance creation failed for virtual path '" + virtualPath + "'.");
|
||||
//throw new HttpException ("Instance creation failed for virtual
|
||||
//path '" + virtualPath + "'.");
|
||||
return null;
|
||||
|
||||
if (!requiredBaseType.IsAssignableFrom (type)) {
|
||||
string msg = String.Format ("Type '{0}' does not inherit from '{1}'.",
|
||||
@@ -373,9 +377,15 @@ namespace System.Web.Compilation {
|
||||
{
|
||||
string vp;
|
||||
|
||||
if (!VirtualPathUtility.IsRooted (virtualPath))
|
||||
vp = "~/" + virtualPath;
|
||||
else
|
||||
if (!VirtualPathUtility.IsRooted (virtualPath)) {
|
||||
HttpContext ctx = HttpContext.Current;
|
||||
HttpRequest req = ctx != null ? ctx.Request : null;
|
||||
|
||||
if (req != null)
|
||||
vp = VirtualPathUtility.GetDirectory (req.FilePath) + virtualPath;
|
||||
else
|
||||
throw new HttpException ("No context, cannot map paths.");
|
||||
} else
|
||||
vp = virtualPath;
|
||||
|
||||
if (VirtualPathUtility.IsAppRelative (vp))
|
||||
@@ -414,8 +424,8 @@ namespace System.Web.Compilation {
|
||||
public static Type GetCompiledType (string virtualPath)
|
||||
{
|
||||
string vp = GetAbsoluteVirtualPath (virtualPath);
|
||||
|
||||
BuildCacheItem ret = GetCachedItem (vp);
|
||||
|
||||
if (ret != null)
|
||||
return ret.type;
|
||||
|
||||
@@ -468,8 +478,16 @@ namespace System.Web.Compilation {
|
||||
|
||||
if (kind == BuildKind.Theme || kind == BuildKind.Application)
|
||||
return ret;
|
||||
|
||||
bool doBatch = BatchMode;
|
||||
|
||||
if (BatchMode) {
|
||||
lock (buildCacheLock) {
|
||||
if (recursiveBuilds.Count > 0 && recursiveBuilds.Peek () == kind)
|
||||
doBatch = false;
|
||||
recursiveBuilds.Push (kind);
|
||||
}
|
||||
|
||||
if (doBatch) {
|
||||
string[] files = Directory.GetFiles (physicalDir, "*.*");
|
||||
BuildKind fileKind;
|
||||
|
||||
@@ -758,12 +776,40 @@ namespace System.Web.Compilation {
|
||||
builders.Add (CreateAssemblyBuilder (assemblyBaseName, virtualPath, buildItem));
|
||||
buildItem.StoreCodeUnit ();
|
||||
}
|
||||
|
||||
static void AssertVirtualPathExists (string virtualPath)
|
||||
{
|
||||
string realpath;
|
||||
bool fakePath;
|
||||
|
||||
if (StrUtils.StartsWith (virtualPath, FAKE_VIRTUAL_PATH_PREFIX)) {
|
||||
realpath = virtualPath.Substring (FAKE_VIRTUAL_PATH_PREFIX.Length);
|
||||
fakePath = true;
|
||||
} else {
|
||||
HttpContext ctx = HttpContext.Current;
|
||||
HttpRequest req = ctx != null ? ctx.Request : null;
|
||||
|
||||
if (req == null)
|
||||
throw new HttpException ("Missing context, cannot continue.");
|
||||
|
||||
realpath = req.MapPath (virtualPath);
|
||||
}
|
||||
|
||||
if (!File.Exists (realpath) && !Directory.Exists (realpath))
|
||||
throw new HttpException (404,
|
||||
"The file '" + virtualPath + "' does not exist.",
|
||||
fakePath ? Path.GetFileName (realpath) : virtualPath);
|
||||
}
|
||||
|
||||
static void BuildAssembly (string virtualPath)
|
||||
{
|
||||
AssertVirtualPathExists (virtualPath);
|
||||
|
||||
object ticket;
|
||||
bool acquired;
|
||||
string virtualDir = GetVirtualPathDirectory (virtualPath);
|
||||
BuildKind buildKind = BuildKind.Unknown;
|
||||
bool kindPushed = false;
|
||||
|
||||
acquired = AcquireCompilationTicket (virtualDir, out ticket);
|
||||
try {
|
||||
@@ -775,17 +821,29 @@ namespace System.Web.Compilation {
|
||||
|
||||
string assemblyBaseName;
|
||||
Dictionary <string, bool> vpCache = new Dictionary <string, bool> ();
|
||||
BuildKind buildKind;
|
||||
List <BuildItem> buildItems = LoadBuildProviders (virtualPath, virtualDir, vpCache, out buildKind, out assemblyBaseName);
|
||||
|
||||
kindPushed = true;
|
||||
|
||||
if (buildItems.Count == 0)
|
||||
return;
|
||||
|
||||
Dictionary <Type, List <AssemblyBuilder>> assemblyBuilders = new Dictionary <Type, List <AssemblyBuilder>> ();
|
||||
foreach (BuildItem buildItem in buildItems)
|
||||
bool checkForRecursion = buildKind == BuildKind.NonPages;
|
||||
|
||||
foreach (BuildItem buildItem in buildItems) {
|
||||
if (checkForRecursion) {
|
||||
// Expensive but, alas, necessary - the builder in
|
||||
// our list might've been put into a different
|
||||
// assembly in a recursive call.
|
||||
lock (buildCacheLock) {
|
||||
if (buildCache.ContainsKey (buildItem.VirtualPath))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (buildItem.assemblyBuilder == null)
|
||||
AssignToAssemblyBuilder (assemblyBaseName, virtualPath, buildItem, assemblyBuilders);
|
||||
|
||||
}
|
||||
CompilerResults results;
|
||||
Assembly compiledAssembly;
|
||||
string vp;
|
||||
@@ -794,13 +852,22 @@ namespace System.Web.Compilation {
|
||||
foreach (List <AssemblyBuilder> abuilders in assemblyBuilders.Values) {
|
||||
foreach (AssemblyBuilder abuilder in abuilders) {
|
||||
abuilder.AddAssemblyReference (GetReferencedAssemblies () as List <Assembly>);
|
||||
results = abuilder.BuildAssembly (virtualPath);
|
||||
compiledAssembly = results.CompiledAssembly;
|
||||
try {
|
||||
results = abuilder.BuildAssembly (virtualPath);
|
||||
} catch (CompilationException ex) {
|
||||
throw new HttpException ("Compilation failed for virtual path '" + virtualPath + "'.", ex);
|
||||
}
|
||||
|
||||
// No results is not an error - it is possible that the assembly builder contained only .asmx and
|
||||
// .ashx files which had no body, just the directive. In such case, no code unit or code file is added
|
||||
// to the assembly builder and, in effect, no assembly is produced but there are STILL types that need
|
||||
// to be added to the cache.
|
||||
compiledAssembly = results != null ? results.CompiledAssembly : null;
|
||||
|
||||
lock (buildCacheLock) {
|
||||
switch (buildKind) {
|
||||
case BuildKind.NonPages:
|
||||
if (!referencedAssemblies.Contains (compiledAssembly))
|
||||
if (compiledAssembly != null && !referencedAssemblies.Contains (compiledAssembly))
|
||||
referencedAssemblies.Add (compiledAssembly);
|
||||
break;
|
||||
|
||||
@@ -822,7 +889,7 @@ namespace System.Web.Compilation {
|
||||
buildCache.Add (vp, new BuildCacheItem (compiledAssembly, bp, results));
|
||||
}
|
||||
|
||||
if (!nonPagesCache.ContainsKey (vp))
|
||||
if (compiledAssembly != null && !nonPagesCache.ContainsKey (vp))
|
||||
nonPagesCache.Add (vp, compiledAssembly);
|
||||
}
|
||||
}
|
||||
@@ -838,6 +905,12 @@ namespace System.Web.Compilation {
|
||||
// HttpRuntime.UnloadAppDomain ();
|
||||
// }
|
||||
} finally {
|
||||
if (kindPushed && buildKind == BuildKind.Pages || buildKind == BuildKind.NonPages) {
|
||||
lock (buildCacheLock) {
|
||||
recursiveBuilds.Pop ();
|
||||
}
|
||||
}
|
||||
|
||||
Monitor.Exit (ticket);
|
||||
if (acquired)
|
||||
ReleaseCompilationTicket (virtualDir);
|
||||
|
||||
@@ -1,3 +1,96 @@
|
||||
2008-02-28 Marek Habersack <[email protected]>
|
||||
|
||||
* TemplateControlCompiler.cs: make sure that data-bound attribute
|
||||
assignments properly convert the Bind expression to the Eval
|
||||
one. Fixes bug #362039
|
||||
|
||||
2008-02-27 Marek Habersack <[email protected]>
|
||||
|
||||
* AspComponentFoundry.cs: use BuildManager.GetCompiledType in the
|
||||
LoadType method for the 2.0 profile.
|
||||
|
||||
2008-02-26 Marek Habersack <[email protected]>
|
||||
|
||||
* BuildManager.cs: known file types extensions are now matched
|
||||
case-insensitively.
|
||||
|
||||
2008-02-25 Marek Habersack <[email protected]>
|
||||
|
||||
* TemplateControlCompiler.cs: GetContainerType now checks whether
|
||||
the binding container returned from the builder implements
|
||||
IDataItemContainer (for 2.0+ profiles) and looks for one more
|
||||
property, Rows, if no Items property is found.
|
||||
|
||||
2008-02-07 Marek Habersack <[email protected]>
|
||||
|
||||
* CompilationException.cs: added new constructor which takes
|
||||
CompilerResults as one of the parameters.
|
||||
Added CompilerOutput property.
|
||||
|
||||
* AssemblyBuilder.cs: use the new CompilationError constructor.
|
||||
|
||||
* BuildManager.cs: check for virtualPath existence before
|
||||
attempting to compile the assemblies. Fixes bug #359465
|
||||
|
||||
2008-02-06 Marek Habersack <[email protected]>
|
||||
|
||||
* GenericBuildProvider.cs: GetGeneratedType may return a type even
|
||||
though the results are null.
|
||||
|
||||
* AssemblyBuilder.cs: if there are no units, no source files, no
|
||||
resources and no embedded resources in the passed options then
|
||||
do not attempt to compile the assembly. Fixes bug #359325
|
||||
|
||||
* AppResourcesAssemblyBuilder.cs, AppCodeCompiler.cs: expect that
|
||||
BuildAssembly may return null results.
|
||||
|
||||
* BuildManager.cs: protect non-page builds from endless recursion
|
||||
if a non-page file recursively references/includes another file
|
||||
from the same batch. If such case is detected, the recursively
|
||||
referenced file is compiled into a separate assembly and removed
|
||||
from the previous compilation batch. Fixes bug #358742.
|
||||
If AssemblyBuilder returns no results from BuildAssembly, it might
|
||||
mean we're dealing with a compilation of empty .as[hm]x files,
|
||||
with no code and only code-behind in bin/. Do not report an error
|
||||
in that case, only add the compiled types to the cache. Fixes bug
|
||||
#357624.
|
||||
|
||||
2008-02-05 Marek Habersack <[email protected]>
|
||||
|
||||
* BuildManager.cs: GetAbsoluteVirtualPath correctly converts
|
||||
non-rooted relative paths to absolute ones now. Fixes bug
|
||||
#357504.
|
||||
|
||||
* GenericBuildProvider.cs: introduced a new abstract method,
|
||||
GetReferencedAssemblies, which is called on descendant builders to
|
||||
get a list of assemblies referenced by the parsed file. Fixes bug
|
||||
#357499.
|
||||
|
||||
* AssemblyBuilder.cs: added a new overload of the
|
||||
AddAssemblyReference method, to be used by build providers to
|
||||
register assemblies collected by the corresponding parser.
|
||||
|
||||
* TemplateBuildProvider.cs, SimpleBuildProvider.cs: implemented
|
||||
overload of the new abstract method GetReferencedAssemblies.
|
||||
|
||||
* AspGenerator.cs: introduced a new overload for the Parse method
|
||||
which accepts a bool indicating whether or not to initialize the
|
||||
parser. The overload is used when parsing server-side
|
||||
includes. Fixes bug #357498
|
||||
|
||||
2008-02-04 Marek Habersack <[email protected]>
|
||||
|
||||
* AssemblyBuilder.cs: do not use WebEncoding.FileEncoding when
|
||||
generating source code files. Fixes bug #357053.
|
||||
|
||||
* AspGenerator.cs: set isApplication before parsing. Fixes bug
|
||||
#357036.
|
||||
|
||||
2008-01-31 Jb Evain <[email protected]>
|
||||
|
||||
* AspGenerator.cs: correct typo. Fix #357547.
|
||||
Backport from trunk at r94456.
|
||||
|
||||
2008-01-27 Marek Habersack <[email protected]>
|
||||
|
||||
* BuildManager.cs: GetReferencedAssemblies includes the extra
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
@@ -40,6 +41,7 @@ namespace System.Web.Compilation
|
||||
{
|
||||
string filename;
|
||||
CompilerErrorCollection errors;
|
||||
CompilerResults results;
|
||||
string fileText;
|
||||
string errmsg;
|
||||
int [] errorLines;
|
||||
@@ -51,6 +53,12 @@ namespace System.Web.Compilation
|
||||
this.fileText = fileText;
|
||||
}
|
||||
|
||||
public CompilationException (string filename, CompilerResults results, string fileText)
|
||||
: this (filename, results != null ? results.Errors : null, fileText)
|
||||
{
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public override string SourceFile {
|
||||
get {
|
||||
if (errors == null || errors.Count == 0)
|
||||
@@ -113,6 +121,16 @@ namespace System.Web.Compilation
|
||||
public override bool ErrorLinesPaired {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public StringCollection CompilerOutput {
|
||||
get {
|
||||
if (results == null)
|
||||
return null;
|
||||
|
||||
return results.Output;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ using System;
|
||||
using System.CodeDom;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
@@ -55,6 +56,7 @@ namespace System.Web.Compilation
|
||||
protected abstract string GetCodeBehindSource (TParser parser);
|
||||
protected abstract string GetClassType (BaseCompiler compiler, TParser parser);
|
||||
protected abstract AspGenerator CreateAspGenerator (TParser parser);
|
||||
protected abstract List <string> GetReferencedAssemblies (TParser parser);
|
||||
|
||||
protected virtual TParser Parse ()
|
||||
{
|
||||
@@ -106,6 +108,12 @@ namespace System.Web.Compilation
|
||||
if (codeBehindSource != null)
|
||||
assemblyBuilder.AddCodeFile (codeBehindSource, this);
|
||||
|
||||
List <string> refasms = GetReferencedAssemblies (parser);
|
||||
if (refasms != null && refasms.Count > 0) {
|
||||
foreach (string loc in refasms)
|
||||
assemblyBuilder.AddAssemblyReference (loc);
|
||||
}
|
||||
|
||||
GenerateCode (assemblyBuilder, parser, _compiler);
|
||||
}
|
||||
|
||||
@@ -116,15 +124,12 @@ namespace System.Web.Compilation
|
||||
|
||||
public override Type GetGeneratedType (CompilerResults results)
|
||||
{
|
||||
if (_compiler == null || results == null)
|
||||
return null;
|
||||
|
||||
if (NeedsLoadFromBin)
|
||||
if (NeedsLoadFromBin && _compiler != null)
|
||||
return LoadTypeFromBin (_compiler, Parser);
|
||||
|
||||
// This is not called if compilation failed.
|
||||
// Returning null makes the caller throw an InvalidCastException
|
||||
Assembly assembly = results.CompiledAssembly;
|
||||
Assembly assembly = results != null ? results.CompiledAssembly : null;
|
||||
if (assembly == null)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ using System;
|
||||
using System.CodeDom;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
@@ -115,6 +116,34 @@ namespace System.Web.Compilation
|
||||
return new WebServiceCompiler (parser);
|
||||
}
|
||||
|
||||
protected override List <string> GetReferencedAssemblies (SimpleWebHandlerParser parser)
|
||||
{
|
||||
if (parser == null)
|
||||
return null;
|
||||
|
||||
ArrayList al = parser.Assemblies;
|
||||
int count;
|
||||
|
||||
if (al == null || al.Count == 0)
|
||||
return null;
|
||||
|
||||
List <string> ret = new List <string> ();
|
||||
string loc;
|
||||
|
||||
foreach (object o in al) {
|
||||
loc = o as string;
|
||||
if (loc == null)
|
||||
continue;
|
||||
|
||||
if (ret.Contains (loc))
|
||||
continue;
|
||||
|
||||
ret.Add (loc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected override bool NeedsConstructType {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ using System;
|
||||
using System.CodeDom;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
@@ -91,6 +92,34 @@ namespace System.Web.Compilation
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override List <string> GetReferencedAssemblies (TemplateParser parser)
|
||||
{
|
||||
if (parser == null)
|
||||
return null;
|
||||
|
||||
ArrayList al = parser.Assemblies;
|
||||
int count;
|
||||
|
||||
if (al == null || al.Count == 0)
|
||||
return null;
|
||||
|
||||
List <string> ret = new List <string> ();
|
||||
string loc;
|
||||
|
||||
foreach (object o in al) {
|
||||
loc = o as string;
|
||||
if (loc == null)
|
||||
continue;
|
||||
|
||||
if (ret.Contains (loc))
|
||||
continue;
|
||||
|
||||
ret.Add (loc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -486,7 +486,7 @@ namespace System.Web.Compilation
|
||||
}
|
||||
|
||||
void AddCodeForPropertyOrField (ControlBuilder builder, Type type, string var_name, string att, MemberInfo member, bool isDataBound, bool isExpression)
|
||||
{
|
||||
{
|
||||
CodeMemberMethod method = builder.method;
|
||||
bool isWritable = IsWritablePropertyOrField (member);
|
||||
if (isDataBound && isWritable) {
|
||||
@@ -500,7 +500,7 @@ namespace System.Web.Compilation
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
CodeAssignStatement assign = new CodeAssignStatement ();
|
||||
assign.Left = new CodePropertyReferenceExpression (ctrlVar, var_name);
|
||||
currentLocation = builder.location;
|
||||
@@ -616,7 +616,7 @@ namespace System.Web.Compilation
|
||||
#endif
|
||||
if (!IsWritablePropertyOrField (member))
|
||||
return false;
|
||||
|
||||
|
||||
AddCodeForPropertyOrField (builder, type, member.Name, attValue, member, isDataBound, isExpression);
|
||||
return true;
|
||||
}
|
||||
@@ -657,7 +657,8 @@ namespace System.Web.Compilation
|
||||
if (attValue == null && is_bool)
|
||||
val = "true"; // Font-Bold <=> Font-Bold="true"
|
||||
#if NET_2_0
|
||||
if (isDataBound) RegisterBindingInfo (builder, prefix + member.Name + "." + subprop.Name, ref attValue);
|
||||
if (isDataBound)
|
||||
RegisterBindingInfo (builder, prefix + member.Name + "." + subprop.Name, ref attValue);
|
||||
#endif
|
||||
AddCodeForPropertyOrField (builder, subprop.PropertyType,
|
||||
prefix + member.Name + "." + subprop.Name,
|
||||
@@ -876,8 +877,14 @@ namespace System.Web.Compilation
|
||||
bool databound = IsDataBound (attvalue);
|
||||
|
||||
if (databound) {
|
||||
val = attvalue.Substring (3);
|
||||
val = val.Substring (0, val.Length - 2);
|
||||
val = attvalue.Substring (3, attvalue.Length - 5).Trim ();
|
||||
#if NET_2_0
|
||||
if (StrUtils.StartsWith (val, "Bind", true)) {
|
||||
Match match = bindRegexInValue.Match (val);
|
||||
if (match.Success)
|
||||
val = "Eval" + val.Substring (4);
|
||||
}
|
||||
#endif
|
||||
CreateDBAttributeMethod (builder, id, val);
|
||||
} else {
|
||||
CodeCastExpression cast;
|
||||
@@ -1153,17 +1160,35 @@ namespace System.Web.Compilation
|
||||
parent.renderMethod.Statements.Add (AddLinePragma (expr, cr));
|
||||
}
|
||||
|
||||
static PropertyInfo GetContainerProperty (Type type, string[] propNames)
|
||||
{
|
||||
PropertyInfo prop;
|
||||
|
||||
foreach (string name in propNames) {
|
||||
prop = type.GetProperty (name, noCaseFlags & ~BindingFlags.NonPublic);
|
||||
if (prop != null)
|
||||
return prop;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static string[] containerPropNames = {"Items", "Rows"};
|
||||
|
||||
static Type GetContainerType (ControlBuilder builder)
|
||||
{
|
||||
TemplateBuilder tb = builder as TemplateBuilder;
|
||||
if (tb != null && tb.ContainerType != null)
|
||||
return tb.ContainerType;
|
||||
#if NET_2_0
|
||||
return builder.BindingContainerType;
|
||||
#else
|
||||
|
||||
Type type = builder.BindingContainerType;
|
||||
|
||||
PropertyInfo prop = type.GetProperty ("Items", noCaseFlags & ~BindingFlags.NonPublic);
|
||||
#if NET_2_0
|
||||
if (typeof (IDataItemContainer).IsAssignableFrom (type))
|
||||
return type;
|
||||
#endif
|
||||
|
||||
PropertyInfo prop = GetContainerProperty (type, containerPropNames);
|
||||
if (prop == null)
|
||||
return type;
|
||||
|
||||
@@ -1176,7 +1201,6 @@ namespace System.Web.Compilation
|
||||
return type;
|
||||
|
||||
return prop.PropertyType;
|
||||
#endif
|
||||
}
|
||||
|
||||
CodeMemberMethod CreateDBMethod (ControlBuilder builder, string name, Type container, Type target)
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
2008-02-28 Marek Habersack <[email protected]>
|
||||
|
||||
* HandlerFactoryConfiguration.cs: ignore case when matching
|
||||
handler paths.
|
||||
|
||||
* FileMatchingInfo.cs: regular expression is created with the
|
||||
ignore case option.
|
||||
|
||||
2007-12-13 Marek Habersack <[email protected]>
|
||||
|
||||
* FileMatchingInfo.cs. MachineKeyRegistryStorage.cs: speed
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace System.Web.Configuration
|
||||
expr = expr.Substring (1);
|
||||
|
||||
expr += "\\z";
|
||||
RegExp = new Regex (expr);
|
||||
RegExp = new Regex (expr, RegexOptions.IgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,10 +102,10 @@ namespace System.Web.Configuration {
|
||||
FileMatchingInfo fm = files [j];
|
||||
|
||||
if (fm.MatchExact != null)
|
||||
return fm.MatchExact.Length == orig.Length && StrUtils.EndsWith (orig, fm.MatchExact);
|
||||
return fm.MatchExact.Length == orig.Length && StrUtils.EndsWith (orig, fm.MatchExact, true);
|
||||
|
||||
if (fm.EndsWith != null)
|
||||
return StrUtils.EndsWith (p, fm.EndsWith);
|
||||
return StrUtils.EndsWith (p, fm.EndsWith, true);
|
||||
|
||||
if (fm.MatchExpr == "*")
|
||||
return true;
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace System.Web.Configuration
|
||||
internal System.Web.Compilation.BuildProvider GetProviderForExtension (string extension)
|
||||
{
|
||||
foreach (BuildProvider provider in this) {
|
||||
if (extension != provider.Extension)
|
||||
if (String.Compare (extension, provider.Extension, StringComparison.OrdinalIgnoreCase) != 0)
|
||||
continue;
|
||||
|
||||
Type type = HttpApplication.LoadType (provider.Type);
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
2008-02-28 Marek Habersack <[email protected]>
|
||||
|
||||
* HttpHandlerAction.cs: ignore case when matching handler
|
||||
paths. Fixes bug #364995
|
||||
|
||||
2008-02-26 Marek Habersack <[email protected]>
|
||||
|
||||
* BuildProviderCollection.cs: be case-insensitive when looking for
|
||||
the extension match.
|
||||
|
||||
2008-02-18 Vladimir Krasnov <[email protected]>
|
||||
|
||||
* WebConfigurationManager.cs: performance improvement, cached
|
||||
GetSection method
|
||||
|
||||
2008-02-05 Marek Habersack <[email protected]>
|
||||
|
||||
* CompilerCollection.cs: Get (string language) should not use
|
||||
BaseGet as our collection is keyed on a list of language names
|
||||
(e.g. "cs;csharp") and passing a single language won't match in
|
||||
BaseGet correctly. Use the overriden indexer instead.
|
||||
Initialize the base class with the case-insensitive
|
||||
comparer. Fixes bug #357824.
|
||||
|
||||
2008-01-27 Daniel Nauck <[email protected]>
|
||||
|
||||
* HttpHandlerAction.cs: fixed the internal method PathMatches ()
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#if NET_2_0
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Configuration;
|
||||
|
||||
namespace System.Web.Configuration
|
||||
@@ -46,6 +47,7 @@ namespace System.Web.Configuration
|
||||
}
|
||||
|
||||
public CompilerCollection ()
|
||||
: base (CaseInsensitiveComparer.DefaultInvariant)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -61,7 +63,7 @@ namespace System.Web.Configuration
|
||||
|
||||
public Compiler Get (string language)
|
||||
{
|
||||
return (Compiler) BaseGet (language);
|
||||
return this [language];
|
||||
}
|
||||
|
||||
protected override object GetElementKey (ConfigurationElement element)
|
||||
|
||||
@@ -182,12 +182,6 @@ namespace System.Web.Configuration
|
||||
return cachedMatches [pathToMatch];
|
||||
|
||||
bool result = false;
|
||||
bool ignoreCase =
|
||||
#if TARGET_J2EE
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
string[] handlerPaths = Path.Split (',');
|
||||
int slash = pathToMatch.LastIndexOf ('/');
|
||||
string origPathToMatch = pathToMatch;
|
||||
@@ -227,7 +221,7 @@ namespace System.Web.Configuration
|
||||
|
||||
if (matchExact != null)
|
||||
{
|
||||
result = matchExact.Length == origPathToMatch.Length && StrUtils.EndsWith (origPathToMatch, matchExact, ignoreCase);
|
||||
result = matchExact.Length == origPathToMatch.Length && StrUtils.EndsWith (origPathToMatch, matchExact, true);
|
||||
if (result == true)
|
||||
break;
|
||||
else
|
||||
@@ -235,7 +229,7 @@ namespace System.Web.Configuration
|
||||
}
|
||||
else if (endsWith != null)
|
||||
{
|
||||
result = StrUtils.EndsWith (pathToMatch, endsWith, ignoreCase);
|
||||
result = StrUtils.EndsWith (pathToMatch, endsWith, true);
|
||||
if (result == true)
|
||||
break;
|
||||
else
|
||||
@@ -249,7 +243,7 @@ namespace System.Web.Configuration
|
||||
expr = expr.Substring (1);
|
||||
|
||||
expr += "\\z";
|
||||
regEx = new Regex (expr);
|
||||
regEx = new Regex (expr, RegexOptions.IgnoreCase);
|
||||
|
||||
if (regEx.IsMatch (origPathToMatch))
|
||||
{
|
||||
|
||||
@@ -47,8 +47,9 @@ namespace System.Web.Configuration {
|
||||
#if !TARGET_J2EE
|
||||
static IInternalConfigConfigurationFactory configFactory;
|
||||
static Hashtable configurations = Hashtable.Synchronized (new Hashtable ());
|
||||
static Hashtable sectionCache = new Hashtable (StringComparer.OrdinalIgnoreCase);
|
||||
#else
|
||||
static readonly object AppSettingsKey = new object ();
|
||||
const string AppSettingsKey = "WebConfigurationManager.AppSettings";
|
||||
static internal IInternalConfigConfigurationFactory configFactory
|
||||
{
|
||||
get{
|
||||
@@ -94,6 +95,23 @@ namespace System.Web.Configuration {
|
||||
AppDomain.CurrentDomain.SetData("WebConfigurationManager.configurations.initialized", true);
|
||||
}
|
||||
}
|
||||
|
||||
static Hashtable sectionCache
|
||||
{
|
||||
get
|
||||
{
|
||||
Hashtable sectionCache = (Hashtable) AppDomain.CurrentDomain.GetData ("sectionCache");
|
||||
if (sectionCache == null) {
|
||||
sectionCache = new Hashtable (StringComparer.OrdinalIgnoreCase);
|
||||
AppDomain.CurrentDomain.SetData ("sectionCache", sectionCache);
|
||||
}
|
||||
return sectionCache;
|
||||
}
|
||||
set
|
||||
{
|
||||
AppDomain.CurrentDomain.SetData ("sectionCache", value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static ArrayList extra_assemblies = null;
|
||||
@@ -266,6 +284,10 @@ namespace System.Web.Configuration {
|
||||
|
||||
public static object GetSection (string sectionName, string path)
|
||||
{
|
||||
object cachedSection = sectionCache [GetSectionCacheKey (sectionName, path)];
|
||||
if (cachedSection != null)
|
||||
return cachedSection;
|
||||
|
||||
_Configuration c = OpenWebConfiguration (path);
|
||||
ConfigurationSection section = c.GetSection (sectionName);
|
||||
|
||||
@@ -275,20 +297,17 @@ namespace System.Web.Configuration {
|
||||
#if TARGET_J2EE
|
||||
object value = get_runtime_object.Invoke (section, new object [0]);
|
||||
if (String.CompareOrdinal ("appSettings", sectionName) == 0) {
|
||||
HttpContext hc = HttpContext.Current;
|
||||
NameValueCollection collection = (NameValueCollection) hc.Items [AppSettingsKey];
|
||||
|
||||
if (collection == null) {
|
||||
collection = new KeyValueMergedCollection (hc, (NameValueCollection) value);
|
||||
hc.Items [AppSettingsKey] = collection;
|
||||
}
|
||||
|
||||
NameValueCollection collection;
|
||||
collection = new KeyValueMergedCollection (HttpContext.Current, (NameValueCollection) value);
|
||||
value = collection;
|
||||
}
|
||||
|
||||
AddSectionToCache (GetSectionCacheKey (sectionName, path), value);
|
||||
return value;
|
||||
#else
|
||||
return SettingsMappingManager.MapSection (get_runtime_object.Invoke (section, new object [0]));
|
||||
object value = SettingsMappingManager.MapSection (get_runtime_object.Invoke (section, new object [0]));
|
||||
AddSectionToCache (GetSectionCacheKey (sectionName, path), value);
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -326,6 +345,25 @@ namespace System.Web.Configuration {
|
||||
internal static IInternalConfigConfigurationFactory ConfigurationFactory {
|
||||
get { return configFactory; }
|
||||
}
|
||||
|
||||
static void AddSectionToCache (string key, object section)
|
||||
{
|
||||
if (sectionCache [key] != null)
|
||||
return;
|
||||
|
||||
Hashtable tmpTable = (Hashtable) sectionCache.Clone ();
|
||||
if (tmpTable.Contains (key))
|
||||
return;
|
||||
|
||||
tmpTable.Add (key, section);
|
||||
sectionCache = tmpTable;
|
||||
}
|
||||
|
||||
static string GetSectionCacheKey (string sectionName, string path)
|
||||
{
|
||||
return string.Concat (path, "/", sectionName);
|
||||
}
|
||||
|
||||
|
||||
#region stuff copied from WebConfigurationSettings
|
||||
#if TARGET_J2EE
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2008-02-18 Marek Habersack <[email protected]>
|
||||
|
||||
* VirtualPathProvider.cs: chain up to the previous provider, if
|
||||
prexent. Fixes bug #362038
|
||||
|
||||
2008-01-06 Marek Habersack <[email protected]>
|
||||
|
||||
* ApplicationHost.cs: make sure that application with virtualDir
|
||||
|
||||
@@ -63,38 +63,57 @@ namespace System.Web.Hosting {
|
||||
|
||||
public virtual bool DirectoryExists (string virtualDir)
|
||||
{
|
||||
if (prev != null)
|
||||
return prev.DirectoryExists (virtualDir);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool FileExists (string virtualPath)
|
||||
{
|
||||
if (prev != null)
|
||||
return FileExists (virtualPath);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual CacheDependency GetCacheDependency (string virtualPath,
|
||||
IEnumerable virtualPathDependencies,
|
||||
DateTime utcStart)
|
||||
public virtual CacheDependency GetCacheDependency (string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
|
||||
{
|
||||
if (prev != null)
|
||||
return prev.GetCacheDependency (virtualPath, virtualPathDependencies, utcStart);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual string GetCacheKey (string virtualPath)
|
||||
{
|
||||
if (prev != null)
|
||||
return prev.GetCacheKey (virtualPath);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual VirtualDirectory GetDirectory (string virtualDir)
|
||||
{
|
||||
if (prev != null)
|
||||
return prev.GetDirectory (virtualDir);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual VirtualFile GetFile (string virtualPath)
|
||||
{
|
||||
if (prev != null)
|
||||
return prev.GetFile (virtualPath);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual string GetFileHash (string virtualPath, IEnumerable virtualPathDependencies)
|
||||
{
|
||||
if (prev != null)
|
||||
return prev.GetFileHash (virtualPath, virtualPathDependencies);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -108,7 +127,10 @@ namespace System.Web.Hosting {
|
||||
// This thing throws a nullref when we're not inside an ASP.NET appdomain, which is what MS does.
|
||||
VirtualPathProvider provider = HostingEnvironment.VirtualPathProvider;
|
||||
VirtualFile file = provider.GetFile (virtualPath);
|
||||
return file.Open ();
|
||||
if (file != null)
|
||||
return file.Open ();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2008-02-06 Marek Habersack <[email protected]>
|
||||
|
||||
* HtmlMeta.cs: render XHTML compliant tag if not in the Legacy
|
||||
mode. Fixes bug #354425
|
||||
|
||||
2008-01-17 Igor Zelmanovich <[email protected]>
|
||||
|
||||
* HtmlSelect.cs: refactoring.
|
||||
|
||||
@@ -32,6 +32,7 @@ using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.Security.Permissions;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.Configuration;
|
||||
|
||||
namespace System.Web.UI.HtmlControls
|
||||
{
|
||||
@@ -112,9 +113,15 @@ namespace System.Web.UI.HtmlControls
|
||||
|
||||
protected internal override void Render (HtmlTextWriter writer)
|
||||
{
|
||||
writer.WriteBeginTag (TagName);
|
||||
RenderAttributes (writer);
|
||||
writer.Write (">");
|
||||
XhtmlConformanceSection xhtml = WebConfigurationManager.GetSection ("system.web/xhtmlConformance") as XhtmlConformanceSection;
|
||||
|
||||
if (xhtml != null && xhtml.Mode == XhtmlConformanceMode.Legacy)
|
||||
base.Render (writer);
|
||||
else {
|
||||
writer.WriteBeginTag (TagName);
|
||||
RenderAttributes (writer);
|
||||
writer.Write ("/>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1176,7 +1176,7 @@ namespace System.Web.UI.WebControls {
|
||||
cellNextPrev.Width = Unit.Percentage (15);
|
||||
|
||||
DateTime date = GetGlobalCalendar().AddMonths (DisplayDate, - 1);
|
||||
date = GetGlobalCalendar().AddDays (date, -DisplayDate.Day + 1);
|
||||
date = GetGlobalCalendar ().AddDays (date, -date.Day + 1);
|
||||
cellNextPrev.RenderBeginTag (writer);
|
||||
writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, false), cellNextPrev.ForeColor, Enabled));
|
||||
cellNextPrev.RenderEndTag (writer);
|
||||
@@ -1202,7 +1202,7 @@ namespace System.Web.UI.WebControls {
|
||||
|
||||
if (ShowNextPrevMonth) { // Next Table Data
|
||||
DateTime date = GetGlobalCalendar().AddMonths (DisplayDate, + 1);
|
||||
date = GetGlobalCalendar().AddDays (date, -DisplayDate.Day + 1);
|
||||
date = GetGlobalCalendar ().AddDays (date, -date.Day + 1);
|
||||
|
||||
cellNextPrev.HorizontalAlign = HorizontalAlign.Right;
|
||||
cellNextPrev.RenderBeginTag (writer);
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
2008-02-18 Marek Habersack <[email protected]>
|
||||
|
||||
* FormView.cs: the ItemCreated must be fired before data is bound
|
||||
to the FormView. Fixes bug #360434
|
||||
|
||||
2008-01-28 Igor Zelmanovich <[email protected]>
|
||||
|
||||
* Menu.js: dynamic nodes are positioned after hover style of
|
||||
parent node is applied.
|
||||
|
||||
2008-01-31 Igor Zelmanovich <[email protected]>
|
||||
|
||||
* Calendar.cs: resolve Next/Prev. month link date correctly.
|
||||
|
||||
2008-01-24 Vladimir Krasnov <[email protected]>
|
||||
|
||||
* DataSourceCacheManager.cs: fixed GetKeyFromParameters, incase more
|
||||
|
||||
@@ -67,8 +67,13 @@ namespace System.Web.UI.WebControls
|
||||
get {
|
||||
if (PostedFile == null)
|
||||
return Stream.Null;
|
||||
else
|
||||
return PostedFile.InputStream;
|
||||
else {
|
||||
Stream ret = PostedFile.InputStream;
|
||||
if (ret != null)
|
||||
ret.Position = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -987,10 +987,10 @@ namespace System.Web.UI.WebControls
|
||||
table.Rows.Add (bottomPagerRow);
|
||||
}
|
||||
|
||||
OnItemCreated (EventArgs.Empty);
|
||||
|
||||
if (dataBinding)
|
||||
DataBind (false);
|
||||
|
||||
OnItemCreated (EventArgs.Empty);
|
||||
|
||||
return PageCount;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,56 @@
|
||||
2008-02-28 Marek Habersack <[email protected]>
|
||||
|
||||
* TemplateControlParser.cs: when registering a control, check for
|
||||
the .ascx extension case-insensitively. Fixes bug #364995
|
||||
|
||||
2008-02-26 Marek Habersack <[email protected]>
|
||||
|
||||
* TemplateParser.cs: a better error message.
|
||||
|
||||
* ControlBuilder.cs: if one of the parent builders is a
|
||||
TemplateBuilder, use it as the naming container and use its
|
||||
ContainerType property as the value of the BindingContainerType
|
||||
property.
|
||||
|
||||
2008-02-25 Marek Habersack <[email protected]>
|
||||
|
||||
* ControlBuilder.cs: correctly chain up to the parent builder when
|
||||
looking for the naming container.
|
||||
|
||||
2008-02-21 Marek Habersack <[email protected]>
|
||||
|
||||
* ControlBuilder.cs: introduced a new internal property -
|
||||
MyNamingContainer used by the public properties
|
||||
NamingContainerType and BindingContainerType. This simplifies the
|
||||
code in the latter property, as the binding container type must
|
||||
almost always be the same as the naming container type. The only
|
||||
exception is when we're inside a content builder, in which case we
|
||||
return the parent's BindingContainerType. Fixes bug #363665
|
||||
|
||||
2008-02-08 Marek Habersack <[email protected]>
|
||||
|
||||
* SimpleWebHandlerParser.cs: always return a non-null value from
|
||||
the Program property.
|
||||
|
||||
* TemplateParser.cs: make sure that the Src attribute is treated
|
||||
correctly in the 2.0 profile. Fixes bug #319016
|
||||
|
||||
2008-02-07 Marek Habersack <[email protected]>
|
||||
|
||||
* PageHandlerFactory.cs: call PageParser.GetCompiledPageInstance
|
||||
only - that method calls the appropriate APIs for 1.1 and 2.0
|
||||
profiles.
|
||||
|
||||
2008-02-05 Marek Habersack <[email protected]>
|
||||
|
||||
* FileUpload.cs: make sure FileContent always returns the input
|
||||
stream positioned at the beginning. Fixes bug #35684
|
||||
|
||||
2008-02-04 Marek Habersack <[email protected]>
|
||||
|
||||
* SimpleWebHandlerParser.cs: use WebEncoding.FileEncoding when
|
||||
reading the source file.
|
||||
|
||||
2008-01-24 Marek Habersack <[email protected]>
|
||||
|
||||
* PageThemeFileParser.cs: the DefaultBaseType property removed.
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Security.Permissions;
|
||||
using System.Web.Compilation;
|
||||
using System.Web.Configuration;
|
||||
using System.IO;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace System.Web.UI {
|
||||
|
||||
@@ -49,6 +50,7 @@ namespace System.Web.UI {
|
||||
BindingFlags.Static |
|
||||
BindingFlags.IgnoreCase;
|
||||
|
||||
ControlBuilder myNamingContainer;
|
||||
TemplateParser parser;
|
||||
internal ControlBuilder parentBuilder;
|
||||
Type type;
|
||||
@@ -146,52 +148,58 @@ namespace System.Web.UI {
|
||||
|
||||
public Type NamingContainerType {
|
||||
get {
|
||||
if (parentBuilder == null)
|
||||
ControlBuilder cb = myNamingContainer;
|
||||
|
||||
if (cb == null)
|
||||
return typeof (Control);
|
||||
|
||||
Type ptype = parentBuilder.ControlType;
|
||||
if (ptype == null)
|
||||
return parentBuilder.NamingContainerType;
|
||||
|
||||
if (!typeof (INamingContainer).IsAssignableFrom (ptype))
|
||||
return parentBuilder.NamingContainerType;
|
||||
|
||||
return ptype;
|
||||
return cb.ControlType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ControlBuilder MyNamingContainer {
|
||||
get {
|
||||
if (myNamingContainer == null) {
|
||||
Type controlType = parentBuilder != null ? parentBuilder.ControlType : null;
|
||||
|
||||
if (parentBuilder == null && controlType == null)
|
||||
myNamingContainer = null;
|
||||
else if (parentBuilder is TemplateBuilder)
|
||||
myNamingContainer = parentBuilder;
|
||||
else if (controlType != null && typeof (INamingContainer).IsAssignableFrom (controlType))
|
||||
myNamingContainer = parentBuilder;
|
||||
else
|
||||
myNamingContainer = parentBuilder.MyNamingContainer;
|
||||
}
|
||||
|
||||
return myNamingContainer;
|
||||
}
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
public virtual
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
Type BindingContainerType {
|
||||
get {
|
||||
if (parentBuilder == null) {
|
||||
get {
|
||||
ControlBuilder cb = MyNamingContainer;
|
||||
if (cb == null)
|
||||
return typeof (Control);
|
||||
|
||||
#if NET_2_0
|
||||
Type bt = Parser.BaseType;
|
||||
if (bt != null)
|
||||
return bt;
|
||||
if (cb is ContentBuilderInternal)
|
||||
return cb.BindingContainerType;
|
||||
#endif
|
||||
|
||||
return typeof (Control);
|
||||
if (cb is TemplateBuilder) {
|
||||
Type ct =((TemplateBuilder) cb).ContainerType;
|
||||
if (ct == null)
|
||||
return typeof (Control);
|
||||
return ct;
|
||||
}
|
||||
|
||||
if (parentBuilder is TemplateBuilder && ((TemplateBuilder)parentBuilder).ContainerType != null)
|
||||
return ((TemplateBuilder)parentBuilder).ContainerType;
|
||||
|
||||
Type ptype = parentBuilder.ControlType;
|
||||
if (ptype == null)
|
||||
return parentBuilder.BindingContainerType;
|
||||
|
||||
if (!typeof (INamingContainer).IsAssignableFrom (ptype))
|
||||
return parentBuilder.BindingContainerType;
|
||||
|
||||
#if NET_2_0
|
||||
return typeof (Control);
|
||||
#else
|
||||
return ptype;
|
||||
#endif
|
||||
return cb.ControlType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,7 @@ namespace System.Web.UI
|
||||
{
|
||||
public virtual IHttpHandler GetHandler (HttpContext context, string requestType, string url, string path)
|
||||
{
|
||||
#if NET_2_0 && !TARGET_JVM
|
||||
return BuildManager.CreateInstanceFromVirtualPath (url, typeof (IHttpHandler)) as IHttpHandler;
|
||||
#else
|
||||
return PageParser.GetCompiledPageInstance (url, path, context);
|
||||
#endif
|
||||
}
|
||||
|
||||
public virtual void ReleaseHandler (IHttpHandler handler)
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace System.Web.UI
|
||||
StringBuilder content = new StringBuilder ();
|
||||
int idxStart, idxEnd, length;
|
||||
|
||||
using (StreamReader reader = new StreamReader (File.OpenRead (physPath))) {
|
||||
using (StreamReader reader = new StreamReader (File.OpenRead (physPath), WebEncoding.FileEncoding)) {
|
||||
while ((line = reader.ReadLine ()) != null && cachedType == null) {
|
||||
length = line.Length;
|
||||
if (length == 0) {
|
||||
@@ -513,7 +513,12 @@ namespace System.Web.UI
|
||||
}
|
||||
|
||||
internal string Program {
|
||||
get { return program; }
|
||||
get {
|
||||
if (program != null)
|
||||
return program;
|
||||
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
internal ArrayList Assemblies {
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace System.Web.UI {
|
||||
if (tagname != null && src == null)
|
||||
ThrowParseException ("Need a Src attribute with TagName.");
|
||||
|
||||
if (!src.EndsWith (".ascx"))
|
||||
if (!StrUtils.EndsWith (src, ".ascx", true))
|
||||
ThrowParseException ("Source file extension for controls must be .ascx");
|
||||
|
||||
RegisterCustomControl (tagprefix, tagname, src);
|
||||
|
||||
@@ -587,6 +587,8 @@ namespace System.Web.UI {
|
||||
string legacySrc = GetString (atts, "Src", null);
|
||||
if (legacySrc != null) {
|
||||
legacySrc = UrlUtils.Combine (BaseVirtualDir, legacySrc);
|
||||
GetAssemblyFromSource (legacySrc);
|
||||
|
||||
if (src == null) {
|
||||
src = legacySrc;
|
||||
legacySrc = MapPath (legacySrc, false);
|
||||
@@ -596,9 +598,8 @@ namespace System.Web.UI {
|
||||
|
||||
srcIsLegacy = true;
|
||||
} else
|
||||
legacySrc = MapPath (legacySrc, false);
|
||||
|
||||
GetAssemblyFromSource (legacySrc);
|
||||
legacySrc = MapPath (legacySrc, false);
|
||||
|
||||
AddDependency (legacySrc);
|
||||
}
|
||||
|
||||
@@ -783,7 +784,7 @@ namespace System.Web.UI {
|
||||
ThrowParseException ("Cannot find type " + type);
|
||||
|
||||
if (!DefaultBaseType.IsAssignableFrom (parent))
|
||||
ThrowParseException ("The parent type does not derive from " + DefaultBaseType);
|
||||
ThrowParseException ("The parent type '" + type + "' does not derive from " + DefaultBaseType);
|
||||
|
||||
baseType = parent;
|
||||
}
|
||||
@@ -793,17 +794,33 @@ namespace System.Web.UI {
|
||||
this.language = language;
|
||||
implicitLanguage = false;
|
||||
}
|
||||
|
||||
|
||||
Assembly GetAssemblyFromSource (string vpath)
|
||||
{
|
||||
{
|
||||
vpath = UrlUtils.Combine (BaseVirtualDir, vpath);
|
||||
string realPath = MapPath (vpath, false);
|
||||
if (!File.Exists (realPath))
|
||||
ThrowParseException ("File " + vpath + " not found");
|
||||
|
||||
AddSourceDependency (vpath);
|
||||
|
||||
CompilerResults result;
|
||||
|
||||
CompilerResults result = CachingCompiler.Compile (language, realPath, realPath, assemblies, Debug);
|
||||
#if NET_2_0
|
||||
string tmp;
|
||||
CompilerParameters parameters;
|
||||
CodeDomProvider provider = BaseCompiler.CreateProvider (HttpContext.Current, language, out parameters, out tmp);
|
||||
if (provider == null)
|
||||
throw new HttpException ("Cannot find provider for language '" + language + "'.");
|
||||
|
||||
AssemblyBuilder abuilder = new AssemblyBuilder (provider);
|
||||
abuilder.CompilerOptions = parameters;
|
||||
abuilder.AddAssemblyReference (BuildManager.GetReferencedAssemblies () as List <Assembly>);
|
||||
abuilder.AddCodeFile (realPath);
|
||||
result = abuilder.BuildAssembly (vpath);
|
||||
#else
|
||||
result = CachingCompiler.Compile (language, realPath, realPath, assemblies, Debug);
|
||||
#endif
|
||||
if (result.NativeCompilerReturnValue != 0) {
|
||||
StreamReader reader = new StreamReader (realPath);
|
||||
throw new CompilationException (realPath, result.Errors, reader.ReadToEnd ());
|
||||
@@ -840,7 +857,12 @@ namespace System.Web.UI {
|
||||
}
|
||||
|
||||
internal string CodeBehindSource {
|
||||
get { return src; }
|
||||
get {
|
||||
if (srcIsLegacy)
|
||||
return null;
|
||||
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
internal string PartialClassName {
|
||||
|
||||
@@ -1,3 +1,67 @@
|
||||
2008-02-28 Marek Habersack <[email protected]>
|
||||
|
||||
* HttpParamsCollection.cs: restore the GetValues overrides only to
|
||||
make sure the collections are merged before invoking the base
|
||||
implementation.
|
||||
Remove code that's no longer needed.
|
||||
|
||||
2008-02-25 Marek Habersack <[email protected]>
|
||||
|
||||
* HttpContext.cs: correctly set the timeout if the user has
|
||||
specified a timeout which, when converted to milliseconds yields a
|
||||
value larger than one allowed by Timer.Change. This can happen,
|
||||
for instance, when HttpServerUtility.ScriptTimeout is set to
|
||||
Int32.MaxValue. Previously, when something like that happened, the
|
||||
value was converted to 0ms, giving an instantenous timer
|
||||
expiration and, what follows, a request "timeout".
|
||||
|
||||
2008-02-19 Marek Habersack <[email protected]>
|
||||
|
||||
* HttpParamsCollection.cs: do not override the NVC behavior for
|
||||
GetValues - values from different sources (Form, Query, Cookies,
|
||||
ServerVariables) must be kept separate for this purpose. This is
|
||||
also the behavior of MS.NET. Fixes bug #362189
|
||||
|
||||
2008-02-18 Marek Habersack <[email protected]>
|
||||
|
||||
* HttpRuntime.cs: When app is offline, send status code 503
|
||||
instead of 200. Fixes bug #357565
|
||||
|
||||
2008-02-07 Marek Habersack <[email protected]>
|
||||
|
||||
* HttpException.cs: more exception output compatibility changes to
|
||||
match MS.NET.
|
||||
|
||||
2008-02-07 Marek Habersack <[email protected]>
|
||||
|
||||
* HttpException.cs: moved several strings to constants, for easier
|
||||
maintenance.
|
||||
Added 3 new constructors which let the caller to set the exception
|
||||
description.
|
||||
The Description property is now settable.
|
||||
The stack trace at the bottom of the file is written after the
|
||||
terminating </html>, inside a HTML comment. Format changed to
|
||||
match MS.NET.
|
||||
Error 404 is handled in a special way, to match the output with
|
||||
MS.NET.
|
||||
|
||||
* HttpContext.cs, StaticFileHandler.cs, HttpApplication.cs: use
|
||||
the new HttpException constructor for 404.
|
||||
|
||||
2008-02-06 Marek Habersack <[email protected]>
|
||||
|
||||
* HttpApplicationFactory.cs: in FireOnAppEnd, set app_type to null
|
||||
after the event has been fired.
|
||||
|
||||
* HttpRuntime.cs: when switching to offline mode fire the
|
||||
shutdown events. Fixes bug #357565.
|
||||
Watch for Created event in the FileSystemWatcher for the
|
||||
app_offline.htm files.
|
||||
|
||||
2008-01-29 Vladimir Krasnov <[email protected]>
|
||||
|
||||
* HttpRequest.cs: performance optimization of QueryStringRaw
|
||||
|
||||
2008-01-27 Igor Zelmanovich <[email protected]>
|
||||
|
||||
* HttpResponse.cs: rise PreSendRequestHeaders befire headers_sent
|
||||
|
||||
@@ -946,9 +946,9 @@ namespace System.Web {
|
||||
#endif
|
||||
} catch (FileNotFoundException fnf){
|
||||
if (context.Request.IsLocal)
|
||||
ProcessError (new HttpException (404, String.Format ("File not found {0}", fnf.FileName), fnf));
|
||||
ProcessError (new HttpException (404, String.Format ("File not found {0}", fnf.FileName), fnf, context.Request.FilePath));
|
||||
else
|
||||
ProcessError (new HttpException (404, "File not found: " + Path.GetFileName (fnf.FileName)));
|
||||
ProcessError (new HttpException (404, "File not found: " + Path.GetFileName (fnf.FileName), context.Request.FilePath));
|
||||
} catch (DirectoryNotFoundException dnf){
|
||||
if (!context.Request.IsLocal)
|
||||
dnf = null; // Do not "leak" real path information
|
||||
|
||||
@@ -191,6 +191,7 @@ namespace System.Web {
|
||||
HttpApplication app = (HttpApplication) Activator.CreateInstance (app_type, true);
|
||||
FireEvent ("Application_End", app, new object [] {new object (), EventArgs.Empty});
|
||||
app.Dispose ();
|
||||
app_type = null;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -609,8 +609,7 @@ namespace System.Web {
|
||||
{
|
||||
filePath = UrlUtils.Combine (Request.BaseVirtualDir, filePath);
|
||||
if (!StrUtils.StartsWith (filePath, HttpRuntime.AppDomainAppVirtualPath))
|
||||
throw new HttpException (404, "The virtual path '" + filePath +
|
||||
"' maps to another application.");
|
||||
throw new HttpException (404, "The virtual path '" + filePath + "' maps to another application.", filePath);
|
||||
|
||||
Request.SetCurrentExePath (filePath);
|
||||
// A null pathInfo or queryString is ignored and previous values remain untouched
|
||||
@@ -664,8 +663,13 @@ namespace System.Web {
|
||||
#if !TARGET_J2EE
|
||||
if (timer != null) {
|
||||
TimeSpan remaining = value - (DateTime.UtcNow - time_stamp);
|
||||
int remaining_ms = Math.Max ((int)remaining.TotalMilliseconds, 0);
|
||||
timer.Change (remaining_ms, Timeout.Infinite);
|
||||
long remaining_ms = Math.Max ((long)remaining.TotalMilliseconds, 0);
|
||||
|
||||
// See http://msdn2.microsoft.com/en-us/library/7hs7492w.aspx
|
||||
if (remaining_ms > 4294967294)
|
||||
remaining_ms = 4294967294;
|
||||
|
||||
timer.Change (remaining_ms, (long)Timeout.Infinite);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Security.Permissions;
|
||||
using System.Text;
|
||||
using System.Web.Util;
|
||||
using System.Web.Compilation;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace System.Web
|
||||
{
|
||||
@@ -47,7 +48,13 @@ namespace System.Web
|
||||
#endif
|
||||
public class HttpException : ExternalException
|
||||
{
|
||||
const string DEFAULT_DESCRIPTION_TEXT = "Error processing request.";
|
||||
const string ERROR_404_DESCRIPTION = "The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.";
|
||||
|
||||
int http_code = 500;
|
||||
string resource_name;
|
||||
string description;
|
||||
|
||||
const string errorStyleFonts = "\"Verdana\",\"DejaVu Sans\",sans-serif";
|
||||
|
||||
public HttpException ()
|
||||
@@ -69,6 +76,16 @@ namespace System.Web
|
||||
http_code = httpCode;
|
||||
}
|
||||
|
||||
internal HttpException (int httpCode, string message, string resourceName) : this (httpCode, message)
|
||||
{
|
||||
resource_name = resourceName;
|
||||
}
|
||||
|
||||
internal HttpException (int httpCode, string message, string resourceName, string description) : this (httpCode, message, resourceName)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
protected HttpException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
@@ -101,6 +118,12 @@ namespace System.Web
|
||||
http_code = httpCode;
|
||||
}
|
||||
|
||||
public HttpException (int httpCode, string message, Exception innerException, string resourceName)
|
||||
: this (httpCode, message, innerException)
|
||||
{
|
||||
resource_name = resourceName;
|
||||
}
|
||||
|
||||
public string GetHtmlErrorMessage ()
|
||||
{
|
||||
try {
|
||||
@@ -111,7 +134,9 @@ namespace System.Web
|
||||
return GetDefaultErrorMessage ();
|
||||
|
||||
return GetHtmlizedErrorMessage ();
|
||||
} catch {
|
||||
} catch (Exception ex) {
|
||||
Console.WriteLine (ex);
|
||||
|
||||
// we need the try/catch block in case the
|
||||
// problem was with MapPath, which will cause
|
||||
// IsCustomErrorEnabled to throw an exception
|
||||
@@ -120,7 +145,19 @@ namespace System.Web
|
||||
}
|
||||
|
||||
internal virtual string Description {
|
||||
get { return "Error processing request."; }
|
||||
get {
|
||||
if (description != null)
|
||||
return description;
|
||||
|
||||
return DEFAULT_DESCRIPTION_TEXT;
|
||||
}
|
||||
|
||||
set {
|
||||
if (value != null && value.Length > 0)
|
||||
description = value;
|
||||
else
|
||||
description = DEFAULT_DESCRIPTION_TEXT;
|
||||
}
|
||||
}
|
||||
|
||||
void WriteFileTop (StringBuilder builder, string title)
|
||||
@@ -134,27 +171,47 @@ p {{font-family:{0};font-weight:normal;color:black;margin-top: -5px}}
|
||||
b {{font-family:{0};font-weight:bold;color:black;margin-top: -5px}}
|
||||
h1 {{ font-family:{0};font-weight:normal;font-size:18pt;color:red }}
|
||||
h2 {{ font-family:{0};font-weight:normal;font-size:14pt;color:maroon }}
|
||||
pre {{font-family:""Lucida Console"",""DejaVu Sans Mono"", monospace;font-size: 1.2em}}
|
||||
pre {{font-family:""Lucida Console"",""DejaVu Sans Mono"",monospace;font-size: 0.9em}}
|
||||
div.bodyText {{font-family: {0}}}
|
||||
table.sampleCode {{width: 100%; background-color: #ffffcc; }}
|
||||
.errorText {{color: red; font-weight: bold}}
|
||||
.marker {{font-weight: bold; color: black;text-decoration: none;}}
|
||||
.version {{color: gray;}}
|
||||
.error {{margin-bottom: 10px;}}
|
||||
.expandable {{ text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }}", errorStyleFonts);
|
||||
.expandable {{ text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; }}", errorStyleFonts);
|
||||
|
||||
builder.AppendFormat (
|
||||
"</style></head><body><h1>Server Error in '{0}' Application</h1><hr style=\"color: silver\"/>",
|
||||
HtmlEncode (HttpRuntime.AppDomainAppVirtualPath));
|
||||
}
|
||||
|
||||
void WriteFileBottom (StringBuilder builder, string trace1, string trace2)
|
||||
|
||||
void WriteFileBottom (StringBuilder builder)
|
||||
{
|
||||
if (trace1 != null)
|
||||
builder.AppendFormat ("<![CDATA[\r\n{0}\r\n]]>\r\n", HttpUtility.HtmlEncode (trace1));
|
||||
if (trace2 != null)
|
||||
builder.AppendFormat ("<![CDATA[\r\n{0}\r\n]]>\r\n", HttpUtility.HtmlEncode (trace2));
|
||||
builder.AppendFormat ("<hr style=\"color: silver\"/>{0}</body></html>\r\n", DateTime.UtcNow);
|
||||
builder.Append ("<hr style=\"color: silver\"/>");
|
||||
builder.AppendFormat ("<strong>Version information: </strong> Mono Version: {0}; ASP.NET Version: {0}</body></html>\r\n<!--", Environment.Version);
|
||||
|
||||
string trace, message;
|
||||
bool haveTrace;
|
||||
Exception ex = this;
|
||||
|
||||
while (ex != null) {
|
||||
trace = ex.StackTrace;
|
||||
message = ex.Message;
|
||||
haveTrace = (trace != null && trace.Length > 0);
|
||||
|
||||
if (!haveTrace && (message == null || message.Length == 0)) {
|
||||
ex = ex.InnerException;
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.Append ("\r\n[" + ex.GetType () + "]: " + HtmlEncode (message) + "\r\n");
|
||||
if (haveTrace)
|
||||
builder.Append (ex.StackTrace);
|
||||
|
||||
ex = ex.InnerException;
|
||||
}
|
||||
|
||||
builder.Append ("\r\n-->");
|
||||
}
|
||||
|
||||
string GetCustomErrorDefaultMessage ()
|
||||
@@ -189,7 +246,7 @@ table.sampleCode {{width: 100%; background-color: #ffffcc; }}
|
||||
|
||||
</system.web>
|
||||
</configuration></pre></td></tr></table>");
|
||||
WriteFileBottom (builder, null, null);
|
||||
WriteFileBottom (builder);
|
||||
return builder.ToString ();
|
||||
}
|
||||
|
||||
@@ -202,23 +259,28 @@ table.sampleCode {{width: 100%; background-color: #ffffcc; }}
|
||||
|
||||
StringBuilder builder = new StringBuilder ();
|
||||
WriteFileTop (builder, String.Format ("Error{0}", http_code != 0 ? " " + http_code : String.Empty));
|
||||
builder.AppendFormat ("<h2><em>{0}</em></h2>\r\n", HtmlEncode (ex.Message));
|
||||
builder.AppendFormat ("<p><strong>Description: </strong>{0}</p>\r\n", HtmlEncode (Description));
|
||||
builder.Append ("<p><strong>Error Message: </strong>");
|
||||
builder.Append ("<h2><em>");
|
||||
if (http_code == 404)
|
||||
builder.Append ("The resource cannot be found.");
|
||||
else
|
||||
builder.AppendFormat (HtmlEncode (ex.Message));
|
||||
builder.Append ("</em></h2>\r\n<p><strong>Description: </strong>");
|
||||
|
||||
if (http_code != 0)
|
||||
builder.AppendFormat ("HTTP {0}. ", http_code);
|
||||
builder.AppendFormat ("{0}: {1}\r\n</p>\r\n", ex.GetType ().FullName, HtmlEncode (ex.Message));
|
||||
builder.Append (http_code == 404 ? ERROR_404_DESCRIPTION : HtmlEncode (Description));
|
||||
builder.Append ("</p>\r\n");
|
||||
|
||||
if (baseEx != null) {
|
||||
builder.AppendFormat ("<p><strong>Stack Trace: </strong></p>");
|
||||
if (resource_name != null && resource_name.Length > 0)
|
||||
builder.AppendFormat ("<p><strong>Resource URL: </strong>{0}</p>\r\n", resource_name);
|
||||
|
||||
if (baseEx != null && http_code != 404) {
|
||||
builder.Append ("<p><strong>Stack Trace: </strong></p>");
|
||||
builder.Append ("<table summary=\"Stack Trace\" class=\"sampleCode\">\r\n<tr><td>");
|
||||
WriteTextAsCode (builder, baseEx.ToString ());
|
||||
builder.Append ("</td></tr>\r\n</table>\r\n");
|
||||
}
|
||||
WriteFileBottom (builder,
|
||||
this.ToString (),
|
||||
null
|
||||
);
|
||||
WriteFileBottom (builder);
|
||||
|
||||
return builder.ToString ();
|
||||
}
|
||||
@@ -236,73 +298,128 @@ table.sampleCode {{width: 100%; background-color: #ffffcc; }}
|
||||
{
|
||||
StringBuilder builder = new StringBuilder ();
|
||||
HtmlizedException exc = (HtmlizedException) this.InnerException;
|
||||
bool isParseException = exc is ParseException;
|
||||
bool isCompileException = (!isParseException && exc is CompilationException);
|
||||
|
||||
WriteFileTop (builder, exc.Title);
|
||||
builder.AppendFormat ("<h2><em>{0}</em></h2>\r\n", exc.Title);
|
||||
builder.AppendFormat ("<p><strong>Description: </strong>{0}\r\n</p>\r\n", HtmlEncode (exc.Description));
|
||||
string errorMessage = HtmlEncode (exc.ErrorMessage).Replace ("\n", "<br/>");
|
||||
builder.AppendFormat ("<p><strong>Error message: </strong></p><p>{0}</p>", errorMessage);
|
||||
|
||||
if (exc.FileName != null)
|
||||
builder.AppendFormat ("<p><strong>File name: </strong> {0}</p>", HtmlEncode (exc.FileName));
|
||||
|
||||
builder.Append ("<p><strong>");
|
||||
if (isParseException)
|
||||
builder.Append ("Parser ");
|
||||
else if (isCompileException)
|
||||
builder.Append ("Compiler ");
|
||||
|
||||
builder.AppendFormat ("Error Message: </strong>{0}</p>", errorMessage);
|
||||
|
||||
StringBuilder longCodeVersion = null;
|
||||
|
||||
if (exc.FileText != null) {
|
||||
if (exc.SourceFile != exc.FileName)
|
||||
builder.AppendFormat ("<p><strong>Source File: </strong>{0}</p>", exc.SourceFile);
|
||||
|
||||
if (exc is ParseException) {
|
||||
builder.Append ("<p> <strong>Line: </strong>");
|
||||
builder.Append (exc.ErrorLines [0]);
|
||||
builder.Append ("</p>");
|
||||
}
|
||||
|
||||
if (exc is ParseException) {
|
||||
builder.Append ("<strong>Source Error: </strong>\r\n");
|
||||
if (isParseException || isCompileException) {
|
||||
builder.Append ("<p><strong>Source Error: </strong></p>\r\n");
|
||||
builder.Append ("<table summary=\"Source error\" class=\"sampleCode\">\r\n<tr><td>");
|
||||
WriteSource (builder, exc);
|
||||
builder.Append ("</td></tr>\r\n</table>\r\n");
|
||||
|
||||
if (isCompileException)
|
||||
longCodeVersion = new StringBuilder ();
|
||||
WriteSource (builder, longCodeVersion, exc);
|
||||
builder.Append ("</pre></code></td></tr>\r\n</table>\r\n");
|
||||
} else {
|
||||
builder.Append ("<table summary=\"Source file\" class=\"sampleCode\">\r\n<tr><td>");
|
||||
WriteSource (builder, exc);
|
||||
builder.Append ("</td></tr>\r\n</table>\r\n");
|
||||
WriteSource (builder, null, exc);
|
||||
builder.Append ("</pre></code></td></tr>\r\n</table>\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
WriteFileBottom (
|
||||
builder,
|
||||
exc.ToString (),
|
||||
null
|
||||
);
|
||||
builder.Append ("<br/><p><strong>Source File: </strong>");
|
||||
if (exc.SourceFile != exc.FileName)
|
||||
builder.Append (exc.SourceFile);
|
||||
else
|
||||
builder.Append (exc.FileName);
|
||||
|
||||
if (isParseException || isCompileException) {
|
||||
builder.Append (" <strong>Line: </strong>");
|
||||
builder.Append (exc.ErrorLines [0]);
|
||||
}
|
||||
builder.Append ("</p>");
|
||||
} else if (exc.FileName != null)
|
||||
builder.AppendFormat ("{0}</p>", HtmlEncode (exc.FileName));
|
||||
|
||||
bool needToggleJS = false;
|
||||
|
||||
if (isCompileException) {
|
||||
CompilationException cex = exc as CompilationException;
|
||||
StringCollection output = cex.CompilerOutput;
|
||||
|
||||
if (output != null && output.Count > 0) {
|
||||
needToggleJS = true;
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
foreach (string s in output)
|
||||
sb.Append (s + "\r\n");
|
||||
WriteExpandableBlock (builder, "compilerOutput", "Show Detailed Compiler Output", sb.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
if (longCodeVersion != null && longCodeVersion.Length > 0) {
|
||||
WriteExpandableBlock (builder, "fullCode", "Show Complete Compilation Source", longCodeVersion.ToString ());
|
||||
needToggleJS = true;
|
||||
}
|
||||
|
||||
if (needToggleJS)
|
||||
builder.Append ("<script type=\"text/javascript\">\r\n" +
|
||||
"function ToggleVisible (id)\r\n" +
|
||||
"{\r\n" +
|
||||
"\tvar e = document.getElementById (id);\r\n" +
|
||||
"\tif (e.style.display == 'none')\r\n" +
|
||||
"\t{\r\n" +
|
||||
"\t\te.style.display = '';\r\n" +
|
||||
"\t} else {\r\n" +
|
||||
"\t\te.style.display = 'none';\r\n" +
|
||||
"\t}\r\n" +
|
||||
"}\r\n" +
|
||||
"</script>\r\n");
|
||||
|
||||
WriteFileBottom (builder);
|
||||
|
||||
return builder.ToString ();
|
||||
}
|
||||
|
||||
static void WriteExpandableBlock (StringBuilder builder, string id, string title, string contents)
|
||||
{
|
||||
builder.AppendFormat ("<br><div class=\"expandable\" onclick=\"ToggleVisible ('{1}')\">{0}:</div><br/>" +
|
||||
"<div id=\"{1}\" style=\"display: none\"><table summary=\"Details\" class=\"sampleCode\"><tr><td>" +
|
||||
"<code><pre>\r\n", title, id);
|
||||
builder.Append (contents);
|
||||
builder.Append ("</pre></code></td></tr></table></div>");
|
||||
}
|
||||
|
||||
static void WriteTextAsCode (StringBuilder builder, string text)
|
||||
{
|
||||
builder.AppendFormat ("<pre>{0}</pre>", HtmlEncode (text));
|
||||
}
|
||||
|
||||
#if TARGET_J2EE
|
||||
static void WriteSource (StringBuilder builder, HtmlizedException e)
|
||||
static void WriteSource (StringBuilder builder, StringBuilder longVersion, HtmlizedException e)
|
||||
{
|
||||
builder.Append ("<pre>");
|
||||
WritePageSource (builder, e);
|
||||
builder.Append ("</pre>\r\n");
|
||||
builder.Append ("<code><pre>");
|
||||
WritePageSource (builder, longVersion, e);
|
||||
builder.Append ("</code></pre>\r\n");
|
||||
}
|
||||
|
||||
#else
|
||||
static void WriteSource (StringBuilder builder, HtmlizedException e)
|
||||
static void WriteSource (StringBuilder builder, StringBuilder longVersion, HtmlizedException e)
|
||||
{
|
||||
builder.Append ("<pre>");
|
||||
builder.Append ("<code><pre>");
|
||||
if (e is CompilationException)
|
||||
WriteCompilationSource (builder, e);
|
||||
WriteCompilationSource (builder, longVersion, e);
|
||||
else
|
||||
WritePageSource (builder, e);
|
||||
|
||||
builder.Append ("</pre>\r\n");
|
||||
builder.Append ("<code></pre>\r\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void WriteCompilationSource (StringBuilder builder, HtmlizedException e)
|
||||
static void WriteCompilationSource (StringBuilder builder, StringBuilder longVersion, HtmlizedException e)
|
||||
{
|
||||
int [] a = e.ErrorLines;
|
||||
string s;
|
||||
@@ -312,21 +429,42 @@ table.sampleCode {{width: 100%; background-color: #ffffcc; }}
|
||||
|
||||
if (a != null && a.Length > 0)
|
||||
errline = a [0];
|
||||
|
||||
TextReader reader = new StringReader (e.FileText);
|
||||
while ((s = reader.ReadLine ()) != null) {
|
||||
line++;
|
||||
|
||||
if (errline == line)
|
||||
builder.Append ("<span style=\"color: red\">");
|
||||
int begin = errline - 2;
|
||||
int end = errline + 2;
|
||||
|
||||
builder.AppendFormat ("Line {0}: {1}\r\n", line, HtmlEncode (s));
|
||||
if (begin < 0)
|
||||
begin = 0;
|
||||
|
||||
if (line == errline) {
|
||||
builder.Append ("</span>");
|
||||
errline = (++index < a.Length) ? a [index] : 0;
|
||||
string tmp;
|
||||
using (TextReader reader = new StringReader (e.FileText)) {
|
||||
while ((s = reader.ReadLine ()) != null) {
|
||||
line++;
|
||||
if (line < begin || line > end) {
|
||||
if (longVersion != null)
|
||||
longVersion.AppendFormat ("Line {0}: {1}\r\n", line, HtmlEncode (s));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (errline == line) {
|
||||
if (longVersion != null)
|
||||
longVersion.Append ("<span style=\"color: red\">");
|
||||
builder.Append ("<span style=\"color: red\">");
|
||||
}
|
||||
|
||||
tmp = String.Format ("Line {0}: {1}\r\n", line, HtmlEncode (s));
|
||||
builder.Append (tmp);
|
||||
if (longVersion != null)
|
||||
longVersion.Append (tmp);
|
||||
|
||||
if (line == errline) {
|
||||
builder.Append ("</span>");
|
||||
if (longVersion != null)
|
||||
longVersion.Append ("</span>");
|
||||
errline = (++index < a.Length) ? a [index] : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void WritePageSource (StringBuilder builder, HtmlizedException e)
|
||||
@@ -335,8 +473,8 @@ table.sampleCode {{width: 100%; background-color: #ffffcc; }}
|
||||
int line = 0;
|
||||
int beginerror = e.ErrorLines [0];
|
||||
int enderror = e.ErrorLines [1];
|
||||
int begin = beginerror - 3;
|
||||
int end = enderror + 3;
|
||||
int begin = beginerror - 2;
|
||||
int end = enderror + 2;
|
||||
if (begin <= 0)
|
||||
begin = 1;
|
||||
|
||||
@@ -352,7 +490,7 @@ table.sampleCode {{width: 100%; background-color: #ffffcc; }}
|
||||
if (beginerror == line)
|
||||
builder.Append ("<span style=\"color: red\">");
|
||||
|
||||
builder.AppendFormat ("{0}\r\n", HtmlEncode (s));
|
||||
builder.AppendFormat ("Line {0}: {1}\r\n", line, HtmlEncode (s));
|
||||
|
||||
if (enderror <= line) {
|
||||
builder.Append ("</span>");
|
||||
|
||||
Loaded 100 of 166 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user