mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 19:10:23 -10:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
812f508c35 | ||
|
|
562f96a255 | ||
|
|
680b340f6d | ||
|
|
50f9c8b2db | ||
|
|
c98df0e00c | ||
|
|
328ff3c77c | ||
|
|
3d08571390 | ||
|
|
b3dc166c6a | ||
|
|
e5b0f1a6ce | ||
|
|
ec3870d985 |
No files matched your search
@@ -1,3 +1,10 @@
|
||||
2006-07-19 Wade Berrier <[email protected]>
|
||||
|
||||
* scripts/mono-find-provides.in: Remove support for only scanning files in the gac.
|
||||
The problem is that mono apps are often broken up into subpackages, and deps can only
|
||||
be resolved if the assemblies are in the gac, even when they sometimes shouldn't be.
|
||||
(See https://bugzilla.novell.com/show_bug.cgi?id=144655)
|
||||
|
||||
2006-07-04 Zoltan Varga <[email protected]>
|
||||
|
||||
* configure.in: Add the contents of LIBS to libmono_ldflags on sol-x86 too.
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
|
||||
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,1.1.16)
|
||||
AM_INIT_AUTOMAKE(mono,1.1.16.1)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_LN_S
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2006-07-11 Wade Berrier <[email protected]>
|
||||
|
||||
* Makefile: add some files EXTRA_DISTFILES needed by the tests
|
||||
|
||||
2006-06-23 Chris Toshok <[email protected]>
|
||||
|
||||
* System.Windows.Forms_test.dll.sources: add
|
||||
|
||||
@@ -58,11 +58,18 @@ IMAGES_RESOURCES = \
|
||||
resources/dialog-question.png \
|
||||
resources/dialog-warning.png
|
||||
|
||||
TEST_DISTFILES = \
|
||||
M.gif \
|
||||
Test/resources/a.cur \
|
||||
Test/System.Resources/compat_1_1.resx \
|
||||
Test/System.Resources/compat_2_0.resx \
|
||||
Test/System.Windows.Forms/bitmaps/a.png
|
||||
|
||||
EXTRA_DISTFILES = \
|
||||
README System.Windows.Forms.dll.resources \
|
||||
$(RESX_RESOURCES:.resources=.resx) $(CUR_RESOURCES) $(PREBUILT) build-csproj \
|
||||
$(IMAGES_RESOURCES) \
|
||||
Test/resources/a.cur
|
||||
$(TEST_DISTFILES)
|
||||
|
||||
TEST_MCS_FLAGS = /r:System.Data.dll /r:System.Drawing.dll \
|
||||
-resource:Test/resources/a.cur,a.cur
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2006-07-11 Peter Dennis Bartok <[email protected]>
|
||||
|
||||
* Font.cs: Set a default emtpy name so we don't crash if an RTF
|
||||
document defines a font but no name for it
|
||||
|
||||
2006-04-26 Peter Dennis Bartok <[email protected]>
|
||||
|
||||
* RTF.cs: Skip \r and \n characters instead of passing them back up
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace System.Windows.Forms.RTF {
|
||||
public Font(RTF rtf) {
|
||||
this.rtf = rtf;
|
||||
num = -1;
|
||||
name = String.Empty;
|
||||
|
||||
lock (rtf) {
|
||||
if (rtf.Fonts == null)
|
||||
|
||||
@@ -1,3 +1,195 @@
|
||||
2006-07-11 Peter Dennis Bartok <[email protected]>
|
||||
|
||||
* LinkLabel.cs: Hack to handle Shift-Tabbing to the linklabel.
|
||||
Hopefully we will have a better way once all of focus is complete.
|
||||
|
||||
2006-07-11 Peter Dennis Bartok <[email protected]>
|
||||
|
||||
* ThemeWin32Classic.cs: Commented out some debug code and fixed
|
||||
a compile error with csc.
|
||||
|
||||
2006-07-11 Jackson Harper <[email protected]>
|
||||
|
||||
* Control.cs: When hiding a control only select the next control
|
||||
if the current control was focused.
|
||||
- Don't handle enter/leave when setting/killing focus, this is
|
||||
done by the container control.
|
||||
- Remove is_selected, it's not needed anymore.
|
||||
- Add utility methods for selecting a child control, and for
|
||||
firing the Enter/Leave events.
|
||||
* ContainerControl.cs: When a control is activated fire the
|
||||
enter/leave events.
|
||||
- Don't wrap when processing the tab key, so that focus can be
|
||||
moved outside of the container.
|
||||
- Use the correct active control
|
||||
|
||||
2006-07-11 Jackson Harper <[email protected]>
|
||||
|
||||
* ComboBox.cs: Remove some debug code that was blinding me.
|
||||
* UpDownBase.cs: These controls actually aren't implicit, they are
|
||||
visible to the user.
|
||||
|
||||
2006-07-10 Chris Toshok <[email protected]>
|
||||
|
||||
* DataGridTableStyle.cs: just check if the property type is bool.
|
||||
if it is, use DataGridBoolColumn, otherwise DataGridTextBoxColumn.
|
||||
Don't use CanRenderType.
|
||||
|
||||
* DataGridTextBoxColumn.cs: set the value to DBNull.Value, not "",
|
||||
if our text == NullText. Remove CanRenderType.
|
||||
|
||||
* DataGridBoolColumn.cs: nuke CanRenderType.
|
||||
|
||||
* DataGrid.cs: reenable some code to end the current edit inside
|
||||
of set_CurrentCell. This fixes the other 1.1.16 regression.
|
||||
Also, remove rowhdrs_maxheight and just use rowhdrs_area.Height.
|
||||
Also, remove the visible_row_count arg from CalcRowHeaders, since
|
||||
we don't need to worry about the actual height of the area.
|
||||
|
||||
2006-07-10 Chris Toshok <[email protected]>
|
||||
|
||||
* DataGridTextBoxColumn.cs: if when we Commit we're in navigate
|
||||
mode, just return.
|
||||
|
||||
* DataGridTextBox.cs: change "isedit" to "isnavigating" to reflect
|
||||
the real sense of the IsInEditOrNavigateMode property (true =
|
||||
navigate, false = edit). Also, update OnKeyPress to reflect this.
|
||||
|
||||
* DataGridTableStyle.cs (CreateColumnsForTable): even if the
|
||||
column style exists, we still need to set its property descriptor
|
||||
to match up with our list manager.
|
||||
|
||||
2006-07-10 Chris Toshok <[email protected]>
|
||||
|
||||
* ThemeWin32Classic.cs: implement the new row/header painting
|
||||
approach. The parent row painting will likely go away and
|
||||
replaced with label controls, but the rest seems to work ok (and
|
||||
efficiently).
|
||||
|
||||
* Theme.cs: change the way we draw datagrid rows. we don't draw
|
||||
the row headers as a block now. Instead we draw them in the
|
||||
normal draw-row loop. Add some calls for drawing parent rows and
|
||||
relation rows.
|
||||
|
||||
* DataGridTableStyle.cs: add tons of ArgumentExceptions if this is
|
||||
a default table style. Set the defaults from ThemeEngine.Current,
|
||||
not SystemColors. Fix lots of misc issues with property setters.
|
||||
|
||||
* DataGrid.cs: move loads of style information out of this class
|
||||
as it's being duplicated with DataGridTableStyle. keep track of a
|
||||
special DataGridTableStyle for the properties we used to mirror
|
||||
here. Switch all the style properties to access this table style
|
||||
instead of instance fields of this class. Also add a internal
|
||||
class to represent parent rows (more needs to be stored here, like
|
||||
the selection state from the parent table, as well as the
|
||||
expansion state.) Also, for datasources with relations, do the
|
||||
right thing for collapse/expand, and add support for the
|
||||
navigation/parent row buttons.
|
||||
|
||||
Lastly, fix the crash in the 1.1.16 build.
|
||||
|
||||
* GridTableStylesCollection.cs: make the explicit interface
|
||||
implementations call the class's methods as opposed to duplicating
|
||||
them.
|
||||
|
||||
* DataGridTextBoxColumn.cs: set the x/y offset of the textfield to
|
||||
0 so the text doesn't jump around when we move the cursor.
|
||||
|
||||
2006-07-10 Jackson Harper <[email protected]>
|
||||
|
||||
* TextBoxBase.cs:
|
||||
* ListBox.cs: Match MS's ToString (this makes debugging focus
|
||||
stuff infinitely easier).
|
||||
|
||||
2006-07-10 Jackson Harper <[email protected]>
|
||||
|
||||
* Control.cs (SelectNextControl): When checking the control's
|
||||
parent use this instead of ctrl.parent so that null can be passed
|
||||
to SelectNextControl. (I have unit tests for this).
|
||||
- Remove unused var.
|
||||
|
||||
2006-07-10 Chris Toshok <[email protected]>
|
||||
|
||||
* CurrencyManager.cs: correct one regression, the removal of the
|
||||
finalType field. Also, add a MonoTODO on CanAddRows, implement
|
||||
Refresh() correctly, and fix some event emission in
|
||||
ListChangedHandler.
|
||||
|
||||
2006-07-07 Alexander Olk <[email protected]>
|
||||
|
||||
* FileDialog.cs: Don't use brackets for new folders if they exist
|
||||
under *nix. Instead use -(number of existing folders +1).
|
||||
|
||||
2006-07-07 Alexander Olk <[email protected]>
|
||||
|
||||
* FileDialog.cs:
|
||||
- Fixed really nasty bug #78771
|
||||
- Don't block the whole GUI when reading directories with a lot of
|
||||
entries. Use an other thread instead and call BeginInvoke to
|
||||
update the ListView in MWFFileView
|
||||
|
||||
2006-07-07 Chris Toshok <[email protected]>
|
||||
|
||||
* Control.cs (Dispose): release any Capture when disposing.
|
||||
|
||||
2006-07-07 Chris Toshok <[email protected]>
|
||||
|
||||
* LinkLabel.cs (Select): if we chain up to the parent, set
|
||||
focused_index to -1 so we'll search for the first available link
|
||||
the next time the user tabs into us. Also, if the direction is
|
||||
backward and focused_index == -1, start the search from the last
|
||||
element.
|
||||
|
||||
2006-07-07 Chris Toshok <[email protected]>
|
||||
|
||||
* LinkLabel.cs (CreatePiecesFromText): if the link's range piece
|
||||
is beyond the end of the text, don't do anything.
|
||||
(CreateLinkPieces): set our ControlStyles.Selectable based on
|
||||
whether or not we have any links.
|
||||
(Link.Invalidate): use a loop instead of foreach.
|
||||
(Link.set_Start): null out owner.sorted_links so it'll be
|
||||
recreated by CreateLinkPieces.
|
||||
|
||||
2006-07-06 Chris Toshok <[email protected]>
|
||||
|
||||
* LinkLabel.cs: revert the SetStyle change.
|
||||
|
||||
2006-07-06 Chris Toshok <[email protected]>
|
||||
|
||||
* LinkLabel.cs (.ctor): SetStyle Selectable to true.
|
||||
(OnEnableChanged): s/Refresh/Invalidate
|
||||
(OnGotFocus): if we have a focused index already, refocus it (so
|
||||
if we mouse out/in to the window it'll focus the right link).
|
||||
(OnKeyDown): move the tab handling out of here.
|
||||
(OnLostFocus): don't set focused_index to -1, so we can refocus it
|
||||
when we lose focus.
|
||||
(OnMouseDown): don't Capture here - Control handles it. Also,
|
||||
focus the active link.
|
||||
(OnMouseUp): don't deal with Capture.
|
||||
(OnPaintBackgroundInternal): remove.
|
||||
(OnTextAlignChanged): CreateLinkPieces before calling the
|
||||
superclass's method.
|
||||
(OnTextChanged): call CreateLinkPieces before calling superclass's
|
||||
method.
|
||||
(ProcessDialogKey): handle Tab here, and call Select(bool,bool) to
|
||||
move around.
|
||||
(Select): implement this, moving the selection between different
|
||||
links, and call parent.SelectNextControl if we don't have another
|
||||
link to focus in the given direction.
|
||||
(CreateLinkPieces): call Invalidate instead of Refresh.
|
||||
|
||||
2006-07-06 Chris Toshok <[email protected]>
|
||||
|
||||
* ThemeWin32Classic.cs: DrawLinkLabel changes to accomodate the
|
||||
new LinkLabel internals.
|
||||
|
||||
* LinkLabel.cs: fairly major rewrite. get rid of all the loops
|
||||
over pieces looking for active/focused/etc links. also, deal with
|
||||
runs of text (and links) with embedded \n's in them, and use
|
||||
MeasureCharacterRanges instead of MeasureString to figure out the
|
||||
regions text occupies. Lastly, do the usual s/Refresh/Invalidate
|
||||
two-step.
|
||||
|
||||
2006-07-04 Jackson Harper <[email protected]>
|
||||
|
||||
* XplatUIX11.cs: Enable key auto repeat. If the user doesn't have
|
||||
|
||||
@@ -1607,7 +1607,6 @@ namespace System.Windows.Forms
|
||||
|
||||
private Rectangle GetItemDisplayRectangle (int index, int top_index)
|
||||
{
|
||||
Console.WriteLine (index + " " + top_index);
|
||||
if (index < 0 || index >= owner.Items.Count)
|
||||
throw new ArgumentOutOfRangeException ("GetItemRectangle index out of range.");
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
// NOT COMPLETE
|
||||
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
@@ -67,23 +68,81 @@ namespace System.Windows.Forms {
|
||||
return;
|
||||
}
|
||||
|
||||
active_control = value;
|
||||
|
||||
|
||||
if (!Contains(value) && this != value) {
|
||||
throw new ArgumentException("Not a child control");
|
||||
}
|
||||
|
||||
if (value == this) {
|
||||
|
||||
}
|
||||
|
||||
// Fire the enter and leave events if possible
|
||||
Form form = FindForm ();
|
||||
if (form != null) {
|
||||
Control active = form.ActiveControl;
|
||||
Control common_container = GetCommonContainer (form.ActiveControl, value);
|
||||
ArrayList chain = new ArrayList ();
|
||||
Control walk = active;
|
||||
|
||||
// Generate the leave messages
|
||||
while (walk != common_container) {
|
||||
walk.FireLeave ();
|
||||
walk = walk.Parent;
|
||||
}
|
||||
|
||||
walk = value;
|
||||
while (walk != common_container) {
|
||||
chain.Add (walk);
|
||||
walk = walk.Parent;
|
||||
}
|
||||
|
||||
for (int i = chain.Count - 1; i >= 0; i--) {
|
||||
walk = (Control) chain [i];
|
||||
walk.FireEnter ();
|
||||
}
|
||||
}
|
||||
|
||||
active_control = value;
|
||||
|
||||
|
||||
if (this is Form)
|
||||
CheckAcceptButton();
|
||||
|
||||
|
||||
// Scroll control into view
|
||||
ScrollControlIntoView(active_control);
|
||||
|
||||
// Let the control know it's selected
|
||||
Select(value);
|
||||
// value.is_selected = true;
|
||||
// if (value.IsHandleCreated) {
|
||||
// XplatUI.SetFocus (value.window.Handle);
|
||||
// }
|
||||
|
||||
SelectChild (value);
|
||||
}
|
||||
}
|
||||
|
||||
// Just in a separate method to make debugging a little easier,
|
||||
// should eventually be rolled into ActiveControl setter
|
||||
private Control GetCommonContainer (Control active_control, Control value)
|
||||
{
|
||||
Control new_container = null;
|
||||
Control prev_container = active_control;
|
||||
|
||||
while (prev_container != null) {
|
||||
new_container = value.Parent;
|
||||
while (new_container != null) {
|
||||
if (new_container == prev_container)
|
||||
return new_container;
|
||||
new_container = new_container.Parent;
|
||||
}
|
||||
|
||||
prev_container = prev_container.Parent;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
public SizeF AutoScaleDimensions {
|
||||
get {
|
||||
@@ -319,7 +378,7 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
protected virtual bool ProcessTabKey(bool forward) {
|
||||
return SelectNextControl(active_control, forward, true, true, true);
|
||||
return SelectNextControl(active_control, forward, true, true, false);
|
||||
}
|
||||
|
||||
protected override void Select(bool directed, bool forward) {
|
||||
@@ -366,6 +425,21 @@ namespace System.Windows.Forms {
|
||||
|
||||
[EditorBrowsable (EditorBrowsableState.Advanced)]
|
||||
protected override void WndProc(ref Message m) {
|
||||
switch ((Msg) m.Msg) {
|
||||
/*
|
||||
case Msg.WM_LBUTTONDOWN:
|
||||
OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
|
||||
mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()),
|
||||
HighOrder ((int) m.LParam.ToInt32 ()), 0));
|
||||
return;
|
||||
*/
|
||||
case Msg.WM_SETFOCUS:
|
||||
if (active_control == null)
|
||||
SelectNextControl (null, true, true, true, false);
|
||||
break;
|
||||
case Msg.WM_KILLFOCUS:
|
||||
break;
|
||||
}
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
#endregion // Protected Instance Methods
|
||||
|
||||
@@ -69,7 +69,6 @@ namespace System.Windows.Forms
|
||||
internal bool is_visible; // true if control is visible
|
||||
internal bool is_entered; // is the mouse inside the control?
|
||||
internal bool is_enabled; // true if control is enabled (usable/not grayed out)
|
||||
internal bool is_selected; // true if control is selected
|
||||
internal bool is_accessible; // true if the control is visible to accessibility applications
|
||||
internal bool is_captured; // tracks if the control has captured the mouse
|
||||
internal bool is_toplevel; // tracks if the control is a toplevel window
|
||||
@@ -735,6 +734,8 @@ namespace System.Windows.Forms
|
||||
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
Capture = false;
|
||||
|
||||
if (dc_mem!=null) {
|
||||
dc_mem.Dispose();
|
||||
dc_mem=null;
|
||||
@@ -937,17 +938,12 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
internal bool Select(Control control) {
|
||||
Control parent;
|
||||
IContainerControl container;
|
||||
|
||||
if (control == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
parent = control.parent;
|
||||
|
||||
control.is_selected = true;
|
||||
|
||||
container = GetContainerControl();
|
||||
if (container != null) {
|
||||
container.ActiveControl = control;
|
||||
@@ -958,6 +954,12 @@ namespace System.Windows.Forms
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void SelectChild (Control control)
|
||||
{
|
||||
if (control.IsHandleCreated)
|
||||
XplatUI.SetFocus (control.window.Handle);
|
||||
}
|
||||
|
||||
internal virtual void DoDefaultAction() {
|
||||
// Only here to be overriden by our actual controls; this is needed by the accessibility class
|
||||
}
|
||||
@@ -1110,6 +1112,16 @@ namespace System.Windows.Forms
|
||||
|
||||
}
|
||||
|
||||
internal void FireEnter ()
|
||||
{
|
||||
OnEnter (EventArgs.Empty);
|
||||
}
|
||||
|
||||
internal void FireLeave ()
|
||||
{
|
||||
OnLeave (EventArgs.Empty);
|
||||
}
|
||||
|
||||
internal virtual bool ProcessControlMnemonic(char charCode) {
|
||||
return ProcessMnemonic(charCode);
|
||||
}
|
||||
@@ -3110,7 +3122,7 @@ namespace System.Windows.Forms
|
||||
|
||||
public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
|
||||
Control c;
|
||||
|
||||
|
||||
c = ctl;
|
||||
do {
|
||||
c = GetNextControl(c, forward);
|
||||
@@ -3122,7 +3134,7 @@ namespace System.Windows.Forms
|
||||
break;
|
||||
}
|
||||
|
||||
if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
|
||||
if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
|
||||
Select(c);
|
||||
return true;
|
||||
}
|
||||
@@ -3641,7 +3653,7 @@ namespace System.Windows.Forms
|
||||
|
||||
OnVisibleChanged(EventArgs.Empty);
|
||||
|
||||
if (value == false && parent != null) {
|
||||
if (value == false && parent != null && Focused) {
|
||||
Control container;
|
||||
|
||||
// Need to start at parent, GetContainerControl might return ourselves if we're a container
|
||||
@@ -3884,7 +3896,7 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
case Msg.WM_LBUTTONDOWN: {
|
||||
if (CanSelect && !is_selected) {
|
||||
if (CanSelect) {
|
||||
Select(this);
|
||||
}
|
||||
InternalCapture = true;
|
||||
@@ -4086,7 +4098,6 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
case Msg.WM_KILLFOCUS: {
|
||||
OnLeave(EventArgs.Empty);
|
||||
if (CausesValidation) {
|
||||
CancelEventArgs e;
|
||||
e = new CancelEventArgs(false);
|
||||
@@ -4102,14 +4113,12 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
this.has_focus = false;
|
||||
this.is_selected = false;
|
||||
OnLostFocus(EventArgs.Empty);
|
||||
return;
|
||||
}
|
||||
|
||||
case Msg.WM_SETFOCUS: {
|
||||
if (!has_focus) {
|
||||
OnEnter(EventArgs.Empty);
|
||||
this.has_focus = true;
|
||||
OnGotFocus(EventArgs.Empty);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace System.Windows.Forms {
|
||||
public class CurrencyManager : BindingManagerBase {
|
||||
|
||||
protected int listposition;
|
||||
protected Type finalType;
|
||||
|
||||
private IList list;
|
||||
private bool binding_suspended;
|
||||
@@ -98,6 +99,8 @@ namespace System.Windows.Forms {
|
||||
data_source = ((IListSource)data_source).GetList();
|
||||
|
||||
this.data_source = data_source;
|
||||
if (data_source != null)
|
||||
this.finalType = data_source.GetType();
|
||||
|
||||
if (this.data_source is IBindingList)
|
||||
((IBindingList)this.data_source).ListChanged += new ListChangedEventHandler (ListChangedHandler);
|
||||
@@ -163,14 +166,16 @@ namespace System.Windows.Forms {
|
||||
internal override bool IsSuspended {
|
||||
get { return binding_suspended; }
|
||||
}
|
||||
|
||||
|
||||
[MonoTODO ("this needs re-addressing once DataViewManager.AllowNew is implemented")]
|
||||
internal bool CanAddRows {
|
||||
get {
|
||||
if (list as IBindingList == null) {
|
||||
return false;
|
||||
if (list is IBindingList) {
|
||||
return true;
|
||||
//return ((IBindingList)list).AllowNew;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +219,7 @@ namespace System.Windows.Forms {
|
||||
|
||||
public void Refresh ()
|
||||
{
|
||||
PushData ();
|
||||
ListChangedHandler (null, new ListChangedEventArgs (ListChangedType.Reset, -1));
|
||||
}
|
||||
|
||||
protected void CheckEmpty ()
|
||||
@@ -253,11 +258,9 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
return ((ITypedList) list).GetListName (pds);
|
||||
}
|
||||
#if false
|
||||
else if (finalType != null) {
|
||||
return finalType.Name;
|
||||
}
|
||||
#endif
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
@@ -305,7 +308,6 @@ namespace System.Windows.Forms {
|
||||
listposition = e.NewIndex - 1;
|
||||
OnCurrentChanged (EventArgs.Empty);
|
||||
OnPositionChanged (EventArgs.Empty);
|
||||
OnItemChanged (new ItemChangedEventArgs (listposition));
|
||||
}
|
||||
|
||||
OnItemChanged (new ItemChangedEventArgs (-1));
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -272,11 +272,6 @@ namespace System.Windows.Forms
|
||||
#endregion // Public Instance Methods
|
||||
|
||||
#region Private Instance Methods
|
||||
internal static bool CanRenderType (Type type)
|
||||
{
|
||||
return (type == typeof (Boolean));
|
||||
}
|
||||
|
||||
private object FromStateToValue (CheckState state)
|
||||
{
|
||||
if ((state & CheckState.Checked) == CheckState.Checked)
|
||||
|
||||
@@ -45,17 +45,18 @@ namespace System.Windows.Forms
|
||||
public static DataGridTableStyle DefaultTableStyle = new DataGridTableStyle (true);
|
||||
|
||||
#region Local Variables
|
||||
private static readonly Color def_alternating_backcolor = SystemColors.Window;
|
||||
private static readonly Color def_backcolor = SystemColors.Window;
|
||||
private static readonly Color def_alternating_backcolor = ThemeEngine.Current.DataGridAlternatingBackColor;
|
||||
private static readonly Color def_backcolor = ThemeEngine.Current.DataGridBackColor;
|
||||
private static readonly Color def_forecolor = SystemColors.WindowText;
|
||||
private static readonly Color def_gridline_color = SystemColors.Control;
|
||||
private static readonly Color def_header_backcolor = SystemColors.Control;
|
||||
private static readonly Font def_header_font = null;
|
||||
private static readonly Color def_header_forecolor = SystemColors.ControlText;
|
||||
private static readonly Color def_link_color = SystemColors.HotTrack;
|
||||
private static readonly Color def_link_hovercolor = SystemColors.HotTrack;
|
||||
private static readonly Color def_selection_backcolor = SystemColors.ActiveCaption;
|
||||
private static readonly Color def_selection_forecolor = SystemColors.ActiveCaptionText;
|
||||
private static readonly Color def_gridline_color = ThemeEngine.Current.DataGridGridLineColor;
|
||||
private static readonly Color def_header_backcolor = ThemeEngine.Current.DataGridHeaderBackColor;
|
||||
private static readonly Font def_header_font = ThemeEngine.Current.DefaultFont;
|
||||
private static readonly Color def_header_forecolor = ThemeEngine.Current.DataGridHeaderForeColor;
|
||||
private static readonly Color def_link_color = ThemeEngine.Current.DataGridLinkColor;
|
||||
private static readonly Color def_link_hovercolor = ThemeEngine.Current.DataGridLinkHoverColor;
|
||||
private static readonly Color def_selection_backcolor = ThemeEngine.Current.DataGridSelectionBackColor;
|
||||
private static readonly Color def_selection_forecolor = ThemeEngine.Current.DataGridSelectionForeColor;
|
||||
private static readonly int def_preferredrow_height = ThemeEngine.Current.DefaultFont.Height + 3;
|
||||
|
||||
private bool allow_sorting;
|
||||
private DataGrid datagrid;
|
||||
@@ -129,11 +130,11 @@ namespace System.Windows.Forms
|
||||
#region Public Instance Properties
|
||||
[DefaultValue(true)]
|
||||
public bool AllowSorting {
|
||||
get {
|
||||
return allow_sorting;
|
||||
}
|
||||
|
||||
get { return allow_sorting; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (allow_sorting != value) {
|
||||
allow_sorting = value;
|
||||
OnAllowSortingChanged (EventArgs.Empty);
|
||||
@@ -146,11 +147,11 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
public Color AlternatingBackColor {
|
||||
get {
|
||||
return alternating_backcolor;
|
||||
}
|
||||
|
||||
get { return alternating_backcolor; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (alternating_backcolor != value) {
|
||||
alternating_backcolor = value;
|
||||
OnAlternatingBackColorChanged (EventArgs.Empty);
|
||||
@@ -163,11 +164,11 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
public Color BackColor {
|
||||
get {
|
||||
return backcolor;
|
||||
}
|
||||
|
||||
get { return backcolor; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (backcolor != value) {
|
||||
backcolor = value;
|
||||
OnBackColorChanged (EventArgs.Empty);
|
||||
@@ -199,23 +200,25 @@ namespace System.Windows.Forms
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual DataGrid DataGrid {
|
||||
get {
|
||||
return datagrid;
|
||||
}
|
||||
|
||||
get { return datagrid; }
|
||||
set {
|
||||
if (datagrid != value) {
|
||||
datagrid = value;
|
||||
|
||||
/* now set the value on all our column styles */
|
||||
for (int i = 0; i < column_styles.Count; i ++) {
|
||||
column_styles[i].SetDataGridInternal (datagrid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Color ForeColor {
|
||||
get {
|
||||
return forecolor;
|
||||
}
|
||||
|
||||
get { return forecolor; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (forecolor != value) {
|
||||
forecolor = value;
|
||||
OnForeColorChanged (EventArgs.Empty);
|
||||
@@ -234,11 +237,11 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
public Color GridLineColor {
|
||||
get {
|
||||
return gridline_color;
|
||||
}
|
||||
|
||||
get { return gridline_color; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (gridline_color != value) {
|
||||
gridline_color = value;
|
||||
OnGridLineColorChanged (EventArgs.Empty);
|
||||
@@ -252,11 +255,11 @@ namespace System.Windows.Forms
|
||||
|
||||
[DefaultValue(DataGridLineStyle.Solid)]
|
||||
public DataGridLineStyle GridLineStyle {
|
||||
get {
|
||||
return gridline_style;
|
||||
}
|
||||
|
||||
get { return gridline_style; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (gridline_style != value) {
|
||||
gridline_style = value;
|
||||
OnGridLineStyleChanged (EventArgs.Empty);
|
||||
@@ -269,11 +272,11 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
public Color HeaderBackColor {
|
||||
get {
|
||||
return header_backcolor;
|
||||
}
|
||||
|
||||
get { return header_backcolor; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (value == Color.Empty) {
|
||||
throw new ArgumentNullException ("Color.Empty value is invalid.");
|
||||
}
|
||||
@@ -292,17 +295,14 @@ namespace System.Windows.Forms
|
||||
[AmbientValue(null)]
|
||||
[Localizable(true)]
|
||||
public Font HeaderFont {
|
||||
get {
|
||||
if (header_font != null)
|
||||
return header_font;
|
||||
|
||||
if (datagrid != null)
|
||||
return datagrid.HeaderFont;
|
||||
|
||||
return ThemeEngine.Current.DefaultFont;
|
||||
}
|
||||
|
||||
get { return header_font; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (value == null)
|
||||
value = def_header_font;
|
||||
|
||||
if (header_font != value) {
|
||||
header_font = value;
|
||||
OnHeaderFontChanged (EventArgs.Empty);
|
||||
@@ -315,11 +315,10 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
public Color HeaderForeColor {
|
||||
get {
|
||||
return header_forecolor;
|
||||
}
|
||||
|
||||
get { return header_forecolor; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (header_forecolor != value) {
|
||||
header_forecolor = value;
|
||||
@@ -334,11 +333,11 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
public Color LinkColor {
|
||||
get {
|
||||
return link_color;
|
||||
}
|
||||
|
||||
get { return link_color; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (link_color != value) {
|
||||
link_color = value;
|
||||
|
||||
@@ -355,10 +354,7 @@ namespace System.Windows.Forms
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Browsable(false)]
|
||||
public Color LinkHoverColor {
|
||||
get {
|
||||
return link_hovercolor;
|
||||
}
|
||||
|
||||
get { return link_hovercolor; }
|
||||
set {
|
||||
if (link_hovercolor != value) {
|
||||
link_hovercolor = value;
|
||||
@@ -369,11 +365,11 @@ namespace System.Windows.Forms
|
||||
|
||||
[Editor("System.Windows.Forms.Design.DataGridTableStyleMappingNameEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
|
||||
public string MappingName {
|
||||
get {
|
||||
return mapping_name;
|
||||
}
|
||||
|
||||
get { return mapping_name; }
|
||||
set {
|
||||
if (value == null)
|
||||
value = "";
|
||||
|
||||
if (mapping_name != value) {
|
||||
mapping_name = value;
|
||||
OnMappingNameChanged (EventArgs.Empty);
|
||||
@@ -385,11 +381,11 @@ namespace System.Windows.Forms
|
||||
[TypeConverter(typeof(DataGridPreferredColumnWidthTypeConverter))]
|
||||
[Localizable(true)]
|
||||
public int PreferredColumnWidth {
|
||||
get {
|
||||
return preferredcolumn_width;
|
||||
}
|
||||
|
||||
get { return preferredcolumn_width; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (value < 0) {
|
||||
throw new ArgumentException ("PreferredColumnWidth is less than 0");
|
||||
}
|
||||
@@ -403,11 +399,11 @@ namespace System.Windows.Forms
|
||||
|
||||
[Localizable(true)]
|
||||
public int PreferredRowHeight {
|
||||
get {
|
||||
return preferredrow_height;
|
||||
}
|
||||
|
||||
get { return preferredrow_height; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (preferredrow_height != value) {
|
||||
preferredrow_height = value;
|
||||
OnPreferredRowHeightChanged (EventArgs.Empty);
|
||||
@@ -417,10 +413,7 @@ namespace System.Windows.Forms
|
||||
|
||||
[DefaultValue(false)]
|
||||
public virtual bool ReadOnly {
|
||||
get {
|
||||
return _readonly;
|
||||
}
|
||||
|
||||
get { return _readonly; }
|
||||
set {
|
||||
if (_readonly != value) {
|
||||
_readonly = value;
|
||||
@@ -431,10 +424,7 @@ namespace System.Windows.Forms
|
||||
|
||||
[DefaultValue(true)]
|
||||
public bool RowHeadersVisible {
|
||||
get {
|
||||
return rowheaders_visible;
|
||||
}
|
||||
|
||||
get { return rowheaders_visible; }
|
||||
set {
|
||||
if (rowheaders_visible != value) {
|
||||
rowheaders_visible = value;
|
||||
@@ -446,10 +436,7 @@ namespace System.Windows.Forms
|
||||
[DefaultValue(35)]
|
||||
[Localizable(true)]
|
||||
public int RowHeaderWidth {
|
||||
get {
|
||||
return rowheaders_width;
|
||||
}
|
||||
|
||||
get { return rowheaders_width; }
|
||||
set {
|
||||
if (rowheaders_width != value) {
|
||||
rowheaders_width = value;
|
||||
@@ -459,11 +446,11 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
public Color SelectionBackColor {
|
||||
get {
|
||||
return selection_backcolor;
|
||||
}
|
||||
|
||||
get { return selection_backcolor; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (selection_backcolor != value) {
|
||||
selection_backcolor = value;
|
||||
OnSelectionBackColorChanged (EventArgs.Empty);
|
||||
@@ -473,11 +460,11 @@ namespace System.Windows.Forms
|
||||
|
||||
[Description("The foreground color for the current data grid row")]
|
||||
public Color SelectionForeColor {
|
||||
get {
|
||||
return selection_forecolor;
|
||||
}
|
||||
|
||||
get { return selection_forecolor; }
|
||||
set {
|
||||
if (is_default)
|
||||
throw new ArgumentException ("Cannot change the value of this property on the default DataGridTableStyle.");
|
||||
|
||||
if (selection_forecolor != value) {
|
||||
selection_forecolor = value;
|
||||
OnSelectionForeColorChanged (EventArgs.Empty);
|
||||
@@ -587,12 +574,9 @@ namespace System.Windows.Forms
|
||||
|
||||
protected internal virtual DataGridColumnStyle CreateGridColumn (PropertyDescriptor prop, bool isDefault)
|
||||
{
|
||||
if (DataGridBoolColumn.CanRenderType (prop.PropertyType)) {
|
||||
if (prop.PropertyType == typeof (bool))
|
||||
return new DataGridBoolColumn (prop, isDefault);
|
||||
}
|
||||
|
||||
if (DataGridTextBoxColumn.CanRenderType (prop.PropertyType)) {
|
||||
|
||||
else {
|
||||
// At least to special cases with formats
|
||||
if (prop.PropertyType.Equals (typeof (DateTime))) {
|
||||
return new DataGridTextBoxColumn (prop, "d", isDefault);
|
||||
@@ -605,8 +589,6 @@ namespace System.Windows.Forms
|
||||
|
||||
return new DataGridTextBoxColumn (prop, isDefault);
|
||||
}
|
||||
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
@@ -857,7 +839,7 @@ namespace System.Windows.Forms
|
||||
|
||||
protected bool ShouldSerializePreferredRowHeight ()
|
||||
{
|
||||
return (preferredrow_height != datagrid.def_preferredrow_height);
|
||||
return (preferredrow_height != def_preferredrow_height);
|
||||
}
|
||||
|
||||
protected bool ShouldSerializeSelectionBackColor ()
|
||||
@@ -896,6 +878,8 @@ namespace System.Windows.Forms
|
||||
if (st.Width == -1)
|
||||
st.Width = CurrentPreferredColumnWidth;
|
||||
|
||||
st.PropertyDescriptor = propcol[i];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -904,7 +888,6 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
if (typeof (IBindingList).IsAssignableFrom (propcol[i].PropertyType)) {
|
||||
Console.WriteLine ("adding relation {0}", propcol[i].Name);
|
||||
table_relations.Add (propcol[i].Name);
|
||||
} else {
|
||||
st = CreateGridColumn (propcol[i], true);
|
||||
|
||||
@@ -40,14 +40,14 @@ namespace System.Windows.Forms
|
||||
{
|
||||
|
||||
#region Local Variables
|
||||
private bool isedit;
|
||||
private bool isnavigating;
|
||||
private DataGrid grid;
|
||||
#endregion // Local Variables
|
||||
|
||||
#region Constructors
|
||||
public DataGridTextBox ()
|
||||
{
|
||||
isedit = false;
|
||||
isnavigating = true;
|
||||
grid = null;
|
||||
accepts_tab = true;
|
||||
accepts_return = true;
|
||||
@@ -59,8 +59,8 @@ namespace System.Windows.Forms
|
||||
|
||||
#region Public Instance Properties
|
||||
public bool IsInEditOrNavigateMode {
|
||||
get { return isedit; }
|
||||
set { isedit = value; }
|
||||
get { return isnavigating; }
|
||||
set { isnavigating = value; }
|
||||
}
|
||||
|
||||
#endregion // Public Instance Properties
|
||||
@@ -68,7 +68,7 @@ namespace System.Windows.Forms
|
||||
#region Public Instance Methods
|
||||
protected override void OnKeyPress (KeyPressEventArgs e)
|
||||
{
|
||||
isedit = true;
|
||||
isnavigating = false;
|
||||
grid.ColumnStartedEditing (Bounds);
|
||||
base.OnKeyPress (e);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace System.Windows.Forms
|
||||
private IFormatProvider format_provider = null;
|
||||
private StringFormat string_format = new StringFormat ();
|
||||
private DataGridTextBox textbox;
|
||||
private static readonly int offset_x = 2;
|
||||
private static readonly int offset_y = 2;
|
||||
private static readonly int offset_x = 0;
|
||||
private static readonly int offset_y = 0;
|
||||
#endregion // Local Variables
|
||||
|
||||
#region Constructors
|
||||
@@ -123,26 +123,27 @@ namespace System.Windows.Forms
|
||||
|
||||
protected internal override bool Commit (CurrencyManager dataSource, int rowNum)
|
||||
{
|
||||
DataGridTextBox box = (DataGridTextBox)textbox;
|
||||
|
||||
/* Do not write data if not editing. */
|
||||
if (box.IsInEditOrNavigateMode)
|
||||
return true;
|
||||
|
||||
try {
|
||||
object obj = GetColumnValueAtRow (dataSource, rowNum);
|
||||
string existing_text = GetFormattedString (obj);
|
||||
|
||||
if (existing_text != textbox.Text) {
|
||||
string text;
|
||||
|
||||
if (textbox.Text == NullText) {
|
||||
text = string.Empty;
|
||||
} else {
|
||||
text = textbox.Text;
|
||||
}
|
||||
|
||||
SetColumnValueAtRow (dataSource, rowNum, text);
|
||||
if (textbox.Text == NullText)
|
||||
SetColumnValueAtRow (dataSource, rowNum, DBNull.Value);
|
||||
else
|
||||
SetColumnValueAtRow (dataSource, rowNum, textbox.Text);
|
||||
}
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
EndEdit ();
|
||||
return true;
|
||||
}
|
||||
@@ -306,12 +307,6 @@ namespace System.Windows.Forms
|
||||
|
||||
#region Private Instance Methods
|
||||
|
||||
// We use DataGridTextBox to render everything that DataGridBoolColumn does not
|
||||
internal static bool CanRenderType (Type type)
|
||||
{
|
||||
return (type != typeof (Boolean));
|
||||
}
|
||||
|
||||
private string GetFormattedString (object obj)
|
||||
{
|
||||
if (obj == DBNull.Value) {
|
||||
|
||||
@@ -34,6 +34,7 @@ using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Xml;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Windows.Forms {
|
||||
#region FileDialog
|
||||
@@ -256,6 +257,7 @@ namespace System.Windows.Forms {
|
||||
|
||||
// fileTypeComboBox
|
||||
fileTypeComboBox.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right)));
|
||||
fileTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
fileTypeComboBox.Location = new Point (195, 356);
|
||||
fileTypeComboBox.Size = new Size (245, 21);
|
||||
fileTypeComboBox.TabIndex = 2;
|
||||
@@ -1903,9 +1905,12 @@ namespace System.Windows.Forms {
|
||||
private int old_menuitem_index;
|
||||
private bool do_update_view = false;
|
||||
|
||||
private int platform = (int) Environment.OSVersion.Platform;
|
||||
|
||||
public MWFFileView (MWFVFS vfs)
|
||||
{
|
||||
this.vfs = vfs;
|
||||
vfs.RegisterUpdateDelegate (new MWFVFS.UpdateDelegate (RealFileViewUpdate), this);
|
||||
|
||||
SuspendLayout ();
|
||||
|
||||
@@ -1973,8 +1978,6 @@ namespace System.Windows.Forms {
|
||||
|
||||
ResumeLayout (false);
|
||||
|
||||
// currentFolder = Environment.CurrentDirectory;
|
||||
|
||||
KeyDown += new KeyEventHandler (MWF_KeyDown);
|
||||
}
|
||||
|
||||
@@ -2039,7 +2042,7 @@ namespace System.Windows.Forms {
|
||||
set {
|
||||
filterIndex = value;
|
||||
if (Visible)
|
||||
UpdateFileView (currentFolder);
|
||||
UpdateFileView ();
|
||||
}
|
||||
|
||||
get {
|
||||
@@ -2113,11 +2116,19 @@ namespace System.Windows.Forms {
|
||||
if (Directory.Exists (Path.Combine (folder, tmp_filename))) {
|
||||
int i = 1;
|
||||
|
||||
tmp_filename = tmp_filename + " (" + i + ")";
|
||||
if ((platform == 4) || (platform == 128)) {
|
||||
tmp_filename = tmp_filename + "-" + i;
|
||||
} else {
|
||||
tmp_filename = tmp_filename + " (" + i + ")";
|
||||
}
|
||||
|
||||
while (Directory.Exists (Path.Combine (folder, tmp_filename))) {
|
||||
i++;
|
||||
tmp_filename = "New Folder" + " (" + i + ")";
|
||||
if ((platform == 4) || (platform == 128)) {
|
||||
tmp_filename = "New Folder" + "-" + i;
|
||||
} else {
|
||||
tmp_filename = "New Folder" + " (" + i + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2206,7 +2217,7 @@ namespace System.Windows.Forms {
|
||||
EndUpdate ();
|
||||
|
||||
try {
|
||||
UpdateFileView (folder);
|
||||
UpdateFileView ();
|
||||
} catch (Exception e) {
|
||||
if (should_push)
|
||||
PopDir ();
|
||||
@@ -2214,18 +2225,18 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateFileView (string folder)
|
||||
public void UpdateFileView ()
|
||||
{
|
||||
ArrayList directoriesArrayList;
|
||||
ArrayList fileArrayList;
|
||||
|
||||
if (filterArrayList != null && filterArrayList.Count != 0) {
|
||||
FilterStruct fs = (FilterStruct)filterArrayList [filterIndex - 1];
|
||||
|
||||
vfs.GetFolderContent (fs.filters, out directoriesArrayList, out fileArrayList);
|
||||
vfs.GetFolderContent (fs.filters);
|
||||
} else
|
||||
vfs.GetFolderContent (out directoriesArrayList, out fileArrayList);
|
||||
|
||||
vfs.GetFolderContent ();
|
||||
}
|
||||
|
||||
public void RealFileViewUpdate (ArrayList directoriesArrayList, ArrayList fileArrayList)
|
||||
{
|
||||
BeginUpdate ();
|
||||
|
||||
Items.Clear ();
|
||||
@@ -2437,7 +2448,7 @@ namespace System.Windows.Forms {
|
||||
if (senderMenuItem == showHiddenFilesMenuItem) {
|
||||
senderMenuItem.Checked = !senderMenuItem.Checked;
|
||||
showHiddenFiles = senderMenuItem.Checked;
|
||||
UpdateFileView (currentFolder);
|
||||
UpdateFileView ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2690,6 +2701,15 @@ namespace System.Windows.Forms {
|
||||
|
||||
public static Hashtable MyComputerDevicesPrefix = new Hashtable ();
|
||||
|
||||
public delegate void UpdateDelegate (ArrayList folders, ArrayList files);
|
||||
private UpdateDelegate updateDelegate;
|
||||
private Control calling_control;
|
||||
|
||||
private ThreadStart get_folder_content_thread_start;
|
||||
private Thread worker;
|
||||
private WorkerThread workerThread = null;
|
||||
private StringCollection the_filters;
|
||||
|
||||
public MWFVFS ()
|
||||
{
|
||||
if ((platform == 4) || (platform == 128)) {
|
||||
@@ -2704,14 +2724,73 @@ namespace System.Windows.Forms {
|
||||
return fileSystem.ChangeDirectory (folder);
|
||||
}
|
||||
|
||||
public void GetFolderContent (out ArrayList folders_out, out ArrayList files_out)
|
||||
public void GetFolderContent ()
|
||||
{
|
||||
fileSystem.GetFolderContent (null, out folders_out, out files_out);
|
||||
GetFolderContent (null);
|
||||
}
|
||||
|
||||
public void GetFolderContent (StringCollection filters, out ArrayList folders_out, out ArrayList files_out)
|
||||
public void GetFolderContent (StringCollection filters)
|
||||
{
|
||||
fileSystem.GetFolderContent (filters, out folders_out, out files_out);
|
||||
the_filters = filters;
|
||||
|
||||
if (workerThread != null) {
|
||||
workerThread.Stop ();
|
||||
workerThread = null;
|
||||
}
|
||||
|
||||
workerThread = new WorkerThread (fileSystem, the_filters, updateDelegate, calling_control);
|
||||
|
||||
get_folder_content_thread_start = new ThreadStart (workerThread.GetFolderContentThread);
|
||||
worker = new Thread (get_folder_content_thread_start);
|
||||
worker.IsBackground = true;
|
||||
worker.Start();
|
||||
}
|
||||
|
||||
internal class WorkerThread
|
||||
{
|
||||
private FileSystem fileSystem;
|
||||
private StringCollection the_filters;
|
||||
private UpdateDelegate updateDelegate;
|
||||
private Control calling_control;
|
||||
private readonly object lockobject = new object ();
|
||||
private bool stopped = false;
|
||||
|
||||
public WorkerThread (FileSystem fileSystem, StringCollection the_filters, UpdateDelegate updateDelegate, Control calling_control)
|
||||
{
|
||||
this.fileSystem = fileSystem;
|
||||
this.the_filters = the_filters;
|
||||
this.updateDelegate = updateDelegate;
|
||||
this.calling_control = calling_control;
|
||||
}
|
||||
|
||||
public void GetFolderContentThread()
|
||||
{
|
||||
ArrayList folders;
|
||||
ArrayList files;
|
||||
|
||||
fileSystem.GetFolderContent (the_filters, out folders, out files);
|
||||
|
||||
if (stopped)
|
||||
return;
|
||||
|
||||
if (updateDelegate != null) {
|
||||
lock (this) {
|
||||
object[] objectArray = new object[2];
|
||||
|
||||
objectArray[0] = folders;
|
||||
objectArray[1] = files;
|
||||
|
||||
calling_control.BeginInvoke (updateDelegate, objectArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop ()
|
||||
{
|
||||
lock (lockobject) {
|
||||
stopped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteRecentlyUsedFiles (string filename)
|
||||
@@ -2755,6 +2834,12 @@ namespace System.Windows.Forms {
|
||||
{
|
||||
return fileSystem.GetParent ();
|
||||
}
|
||||
|
||||
public void RegisterUpdateDelegate(UpdateDelegate updateDelegate, Control control)
|
||||
{
|
||||
this.updateDelegate = updateDelegate;
|
||||
calling_control = control;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -134,21 +134,17 @@ namespace System.Windows.Forms
|
||||
|
||||
int IList.Add (object value)
|
||||
{
|
||||
int cnt = AddInternal ((DataGridTableStyle)value);
|
||||
|
||||
OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, null));
|
||||
return cnt;
|
||||
return Add ((DataGridTableStyle)value);
|
||||
}
|
||||
|
||||
void IList.Clear ()
|
||||
{
|
||||
items.Clear ();
|
||||
OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Refresh , null));
|
||||
Clear ();
|
||||
}
|
||||
|
||||
bool IList.Contains (object value)
|
||||
{
|
||||
return items.Contains (value);
|
||||
return Contains ((DataGridTableStyle) value);
|
||||
}
|
||||
|
||||
int IList.IndexOf (object value)
|
||||
@@ -163,15 +159,12 @@ namespace System.Windows.Forms
|
||||
|
||||
void IList.Remove (object value)
|
||||
{
|
||||
items.Remove (value);
|
||||
OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, value));
|
||||
Remove ((DataGridTableStyle) value);
|
||||
}
|
||||
|
||||
void IList.RemoveAt (int index)
|
||||
{
|
||||
object item = items[index];
|
||||
items.RemoveAt (index);
|
||||
OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, item));
|
||||
RemoveAt (index);
|
||||
}
|
||||
|
||||
protected void OnCollectionChanged (CollectionChangeEventArgs ccevent)
|
||||
@@ -212,7 +205,7 @@ namespace System.Windows.Forms
|
||||
|
||||
table.DataGrid = owner;
|
||||
int cnt = items.Add (table);
|
||||
return cnt;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
private int FromTableNameToIndex (string tableName)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
//
|
||||
// Authors:
|
||||
// Jordi Mas i Hernandez, [email protected]
|
||||
// Chris Toshok <[email protected]>
|
||||
//
|
||||
// Based on work by:
|
||||
// Daniel Carrera, [email protected] (stubbed out)
|
||||
@@ -45,36 +46,40 @@ namespace System.Windows.Forms
|
||||
{
|
||||
public string text;
|
||||
public int start;
|
||||
public int end;
|
||||
public int length;
|
||||
public LinkLabel.Link link; // Empty link indicates regular text
|
||||
public Rectangle rect;
|
||||
public bool clicked;
|
||||
public bool focused;
|
||||
public Region region;
|
||||
|
||||
public Piece ()
|
||||
public Piece (int start, int length, string text, Link link)
|
||||
{
|
||||
start = end = 0;
|
||||
link = null;
|
||||
clicked = false;
|
||||
focused = false;
|
||||
this.start = start;
|
||||
this.length = length;
|
||||
this.text = text;
|
||||
this.link = link;
|
||||
}
|
||||
}
|
||||
|
||||
private Color active_link;
|
||||
private Color disabled_link;
|
||||
private Color active_link_color;
|
||||
private Color disabled_link_color;
|
||||
private Color link_color;
|
||||
private Color visited_color;
|
||||
private LinkArea link_area;
|
||||
private LinkBehavior link_behavior;
|
||||
private LinkCollection link_collection;
|
||||
private bool link_visited;
|
||||
internal Link[] sorted_links;
|
||||
private bool link_visited;
|
||||
private bool link_click;
|
||||
internal Piece[] pieces;
|
||||
internal int num_pieces;
|
||||
internal Font link_font;
|
||||
internal Font link_font;
|
||||
private Cursor override_cursor;
|
||||
private DialogResult dialog_result;
|
||||
|
||||
private Link active_link;
|
||||
private Link hovered_link;
|
||||
/* this is an index instead of a Link because we have
|
||||
* to search through sorted links for the new one */
|
||||
private int focused_index;
|
||||
|
||||
#region Events
|
||||
public event LinkLabelLinkClickedEventHandler LinkClicked;
|
||||
#endregion // Events
|
||||
@@ -86,50 +91,50 @@ namespace System.Windows.Forms
|
||||
link_visited = false;
|
||||
link_click = false;
|
||||
pieces = null;
|
||||
num_pieces = 0;
|
||||
link_font = null;
|
||||
focused_index = -1;
|
||||
|
||||
ActiveLinkColor = Color.Red;
|
||||
DisabledLinkColor = ThemeEngine.Current.ColorGrayText;
|
||||
LinkColor = Color.FromArgb (255, 0, 0, 255);
|
||||
VisitedLinkColor = Color.FromArgb (255, 128, 0, 128);
|
||||
SetStyle (ControlStyles.Selectable, false);
|
||||
SetStyle (ControlStyles.Opaque, true);
|
||||
SetStyle (ControlStyles.Selectable, false);
|
||||
}
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public Color ActiveLinkColor {
|
||||
get { return active_link;}
|
||||
get { return active_link_color; }
|
||||
set {
|
||||
if (active_link == value)
|
||||
if (active_link_color == value)
|
||||
return;
|
||||
|
||||
active_link = value;
|
||||
Refresh ();
|
||||
active_link_color = value;
|
||||
Invalidate ();
|
||||
}
|
||||
}
|
||||
|
||||
public Color DisabledLinkColor {
|
||||
|
||||
get { return disabled_link;}
|
||||
get { return disabled_link_color; }
|
||||
set {
|
||||
if (disabled_link == value)
|
||||
if (disabled_link_color == value)
|
||||
return;
|
||||
|
||||
disabled_link = value;
|
||||
Refresh ();
|
||||
disabled_link_color = value;
|
||||
Invalidate ();
|
||||
}
|
||||
}
|
||||
|
||||
public Color LinkColor {
|
||||
get { return link_color;}
|
||||
get { return link_color; }
|
||||
set {
|
||||
if (link_color == value)
|
||||
return;
|
||||
|
||||
link_color = value;
|
||||
Refresh ();
|
||||
Invalidate ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +145,7 @@ namespace System.Windows.Forms
|
||||
return;
|
||||
|
||||
visited_color = value;
|
||||
Refresh ();
|
||||
Invalidate ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +162,7 @@ namespace System.Windows.Forms
|
||||
Links.Add (value.Start, value.Length);
|
||||
|
||||
link_area = value;
|
||||
Refresh ();
|
||||
Invalidate ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +175,7 @@ namespace System.Windows.Forms
|
||||
return;
|
||||
|
||||
link_behavior = value;
|
||||
Refresh ();
|
||||
Invalidate ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +199,7 @@ namespace System.Windows.Forms
|
||||
return;
|
||||
|
||||
link_visited = value;
|
||||
Refresh ();
|
||||
Invalidate ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +209,7 @@ namespace System.Windows.Forms
|
||||
override_cursor = Cursors.Hand;
|
||||
return override_cursor;
|
||||
}
|
||||
set { override_cursor = value;}
|
||||
set { override_cursor = value; }
|
||||
}
|
||||
|
||||
[RefreshProperties(RefreshProperties.Repaint)]
|
||||
@@ -229,12 +234,10 @@ namespace System.Windows.Forms
|
||||
|
||||
void IButtonControl.NotifyDefault (bool value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IButtonControl.PerformClick ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
@@ -253,7 +256,7 @@ namespace System.Windows.Forms
|
||||
protected override void OnEnabledChanged (EventArgs e)
|
||||
{
|
||||
base.OnEnabledChanged (e);
|
||||
Refresh ();
|
||||
Invalidate ();
|
||||
}
|
||||
|
||||
protected override void OnFontChanged (EventArgs e)
|
||||
@@ -266,46 +269,42 @@ namespace System.Windows.Forms
|
||||
protected override void OnGotFocus (EventArgs e)
|
||||
{
|
||||
base.OnGotFocus (e);
|
||||
|
||||
// Set focus to the first enabled link piece
|
||||
for (int i = 0; i < num_pieces; i++) {
|
||||
if (pieces[i].link != null && pieces[i].link.Enabled) {
|
||||
pieces[i].focused = true;
|
||||
Invalidate (pieces[i].rect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyDown (KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
// Set focus to the next link piece
|
||||
if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Right) {
|
||||
for (int i = 0; i < num_pieces; i++) {
|
||||
if (pieces[i].focused) {
|
||||
pieces[i].focused = false;
|
||||
Invalidate (pieces[i].rect);
|
||||
|
||||
for (int n = i + 1; n < num_pieces; n++) {
|
||||
if (pieces[n].link != null && pieces[n].link.Enabled) {
|
||||
pieces[n].focused = true;
|
||||
e.Handled = true;
|
||||
Invalidate (pieces[n].rect);
|
||||
return;
|
||||
}
|
||||
// Set focus to the first enabled link piece
|
||||
if (focused_index == -1) {
|
||||
if ((Control.ModifierKeys & Keys.Shift) == 0) {
|
||||
for (int i = 0; i < sorted_links.Length; i ++) {
|
||||
if (sorted_links[i].Enabled) {
|
||||
focused_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (focused_index == -1)
|
||||
focused_index = sorted_links.Length;
|
||||
|
||||
for (int n = focused_index - 1; n >= 0; n--) {
|
||||
if (sorted_links[n].Enabled) {
|
||||
sorted_links[n].Focused = true;
|
||||
focused_index = n;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (e.KeyCode == Keys.Return) {
|
||||
for (int i = 0; i < num_pieces; i++) {
|
||||
if (pieces[i].focused && pieces[i].link != null) {
|
||||
OnLinkClicked (new LinkLabelLinkClickedEventArgs (pieces[i].link));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (focused_index != -1)
|
||||
sorted_links[focused_index].Focused = true;
|
||||
}
|
||||
|
||||
protected override void OnKeyDown (KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Return) {
|
||||
if (focused_index != -1)
|
||||
OnLinkClicked (new LinkLabelLinkClickedEventArgs (sorted_links[focused_index]));
|
||||
}
|
||||
|
||||
base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
protected virtual void OnLinkClicked (LinkLabelLinkClickedEventArgs e)
|
||||
@@ -319,13 +318,8 @@ namespace System.Windows.Forms
|
||||
base.OnLostFocus (e);
|
||||
|
||||
// Clean focus in link pieces
|
||||
for (int i = 0; i < num_pieces; i++) {
|
||||
if (pieces[i].focused) {
|
||||
pieces[i].focused = false;
|
||||
}
|
||||
}
|
||||
|
||||
Refresh ();
|
||||
if (focused_index != -1)
|
||||
sorted_links[focused_index].Focused = false;
|
||||
}
|
||||
|
||||
protected override void OnMouseDown (MouseEventArgs e)
|
||||
@@ -333,14 +327,15 @@ namespace System.Windows.Forms
|
||||
if (!Enabled) return;
|
||||
|
||||
base.OnMouseDown (e);
|
||||
this.Capture = true;
|
||||
|
||||
for (int i = 0; i < num_pieces; i++) {
|
||||
if (pieces[i].rect.Contains (e.X, e.Y)) {
|
||||
if (pieces[i].link!= null) {
|
||||
pieces[i].clicked = true;
|
||||
Invalidate (pieces[i].rect);
|
||||
}
|
||||
for (int i = 0; i < sorted_links.Length; i ++) {
|
||||
if (sorted_links[i].Contains (e.X, e.Y) && sorted_links[i].Enabled) {
|
||||
sorted_links[i].Active = true;
|
||||
if (focused_index != -1)
|
||||
sorted_links[focused_index].Focused = false;
|
||||
active_link = sorted_links[i];
|
||||
focused_index = i;
|
||||
sorted_links[focused_index].Focused = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -350,49 +345,39 @@ namespace System.Windows.Forms
|
||||
{
|
||||
if (!Enabled) return;
|
||||
base.OnMouseLeave (e);
|
||||
UpdateHover(null);
|
||||
UpdateHover (null);
|
||||
}
|
||||
|
||||
private bool UpdateHover(Link link) {
|
||||
bool changed;
|
||||
private void UpdateHover (Link link)
|
||||
{
|
||||
if (link == hovered_link)
|
||||
return;
|
||||
|
||||
changed = false;
|
||||
if (link == null) {
|
||||
Cursor = Cursors.Default;
|
||||
if (hovered_link != null)
|
||||
hovered_link.Hovered = false;
|
||||
|
||||
if (link_behavior == LinkBehavior.HoverUnderline) {
|
||||
for (int i = 0; i < Links.Count; i++) {
|
||||
if (Links[i].Hoovered == true) {
|
||||
changed = true;
|
||||
Links[i].Hoovered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Cursor = OverrideCursor;
|
||||
if (link_behavior == LinkBehavior.HoverUnderline) {
|
||||
if (link.Hoovered != true) {
|
||||
link.Hoovered = true;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
hovered_link = link;
|
||||
|
||||
if (changed == true) {
|
||||
Refresh ();
|
||||
}
|
||||
|
||||
if (hovered_link != null)
|
||||
hovered_link.Hovered = true;
|
||||
|
||||
return changed;
|
||||
Cursor = (hovered_link != null) ? OverrideCursor : Cursors.Default;
|
||||
|
||||
/* XXX this shouldn't be here. the
|
||||
* Link.Invalidate machinery should be enough,
|
||||
* but it seems the piece regions don't
|
||||
* contain the area with the underline. this
|
||||
* can be seen easily when you click on a link
|
||||
* and the focus rectangle shows up (it's too
|
||||
* far up), and also the bottom few pixels of
|
||||
* a linklabel aren't active when it comes to
|
||||
* hovering */
|
||||
Invalidate ();
|
||||
}
|
||||
|
||||
protected override void OnMouseMove (MouseEventArgs e)
|
||||
{
|
||||
if (e.X >= 0 && e.Y >= 0 && e.X < bounds.Width && e.Y < bounds.Height) {
|
||||
UpdateHover (PointInLink (e.X, e.Y));
|
||||
} else if (Capture) {
|
||||
Cursor = Cursors.Default;
|
||||
}
|
||||
UpdateHover (PointInLink (e.X, e.Y));
|
||||
base.OnMouseMove (e);
|
||||
}
|
||||
|
||||
@@ -401,17 +386,17 @@ namespace System.Windows.Forms
|
||||
if (!Enabled) return;
|
||||
|
||||
base.OnMouseUp (e);
|
||||
this.Capture = false;
|
||||
bool onclick = (e.X >= 0 && e.Y >= 0 && e.X < bounds.Width && e.Y < bounds.Height);
|
||||
for (int i = 0; i < num_pieces; i++) {
|
||||
if (pieces[i].link!= null && pieces[i].clicked == true) {
|
||||
if (onclick)
|
||||
OnLinkClicked (new LinkLabelLinkClickedEventArgs (pieces[i].link));
|
||||
pieces[i].clicked = false;
|
||||
Invalidate (pieces[i].rect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (active_link == null)
|
||||
return;
|
||||
|
||||
Link clicked_link = (PointInLink (e.X, e.Y) == active_link) ? active_link : null;
|
||||
|
||||
active_link.Active = false;
|
||||
active_link = null;
|
||||
|
||||
if (clicked_link != null)
|
||||
OnLinkClicked (new LinkLabelLinkClickedEventArgs (clicked_link));
|
||||
}
|
||||
|
||||
protected override void OnPaint (PaintEventArgs pevent)
|
||||
@@ -421,10 +406,6 @@ namespace System.Windows.Forms
|
||||
// Do not call base.OnPaint since it's the Label class
|
||||
}
|
||||
|
||||
internal override void OnPaintBackgroundInternal(PaintEventArgs e) {
|
||||
base.OnPaintBackground (e);
|
||||
}
|
||||
|
||||
protected override void OnPaintBackground (PaintEventArgs e)
|
||||
{
|
||||
base.OnPaintBackground (e);
|
||||
@@ -432,38 +413,73 @@ namespace System.Windows.Forms
|
||||
|
||||
protected override void OnTextAlignChanged (EventArgs e)
|
||||
{
|
||||
base.OnTextAlignChanged (e);
|
||||
CreateLinkPieces ();
|
||||
base.OnTextAlignChanged (e);
|
||||
}
|
||||
|
||||
protected override void OnTextChanged (EventArgs e)
|
||||
{
|
||||
base.OnTextChanged (e);
|
||||
CreateLinkPieces ();
|
||||
base.OnTextChanged (e);
|
||||
}
|
||||
|
||||
protected Link PointInLink (int x, int y)
|
||||
{
|
||||
for (int i = 0; i < num_pieces; i++) {
|
||||
if (pieces[i].rect.Contains (x,y) && pieces[i].link != null)
|
||||
return pieces[i].link;
|
||||
}
|
||||
for (int i = 0; i < sorted_links.Length; i ++)
|
||||
if (sorted_links[i].Contains (x, y))
|
||||
return sorted_links[i];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override bool ProcessDialogKey (Keys keyData)
|
||||
{
|
||||
if ((keyData & Keys.KeyCode) == Keys.Tab) {
|
||||
Select (true, (keyData & Keys.Shift) == 0);
|
||||
return true;
|
||||
}
|
||||
return base.ProcessDialogKey (keyData);
|
||||
}
|
||||
|
||||
protected override void Select (bool directed, bool forward)
|
||||
{
|
||||
base.Select (directed, forward);
|
||||
if (directed) {
|
||||
if (focused_index != -1)
|
||||
sorted_links[focused_index].Focused = false;
|
||||
|
||||
if (forward) {
|
||||
for (int n = focused_index + 1; n < sorted_links.Length; n++) {
|
||||
if (sorted_links[n].Enabled) {
|
||||
sorted_links[n].Focused = true;
|
||||
focused_index = n;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (focused_index == -1)
|
||||
focused_index = sorted_links.Length;
|
||||
|
||||
for (int n = focused_index - 1; n >= 0; n--) {
|
||||
if (sorted_links[n].Enabled) {
|
||||
sorted_links[n].Focused = true;
|
||||
focused_index = n;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
focused_index = -1;
|
||||
|
||||
if (parent != null)
|
||||
parent.SelectNextControl (this, forward, false, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
|
||||
{
|
||||
base.SetBoundsCore (x, y, width, height, specified);
|
||||
CreateLinkFont ();
|
||||
CreateLinkPieces();
|
||||
}
|
||||
|
||||
@@ -476,114 +492,146 @@ namespace System.Windows.Forms
|
||||
|
||||
#region Private Methods
|
||||
|
||||
internal void CreateLinkPieces ()
|
||||
private ArrayList CreatePiecesFromText (int start, int len, Link link)
|
||||
{
|
||||
if (Links.Count == 0 || IsHandleCreated == false || Text.Length == 0)
|
||||
ArrayList rv = new ArrayList ();
|
||||
|
||||
if (start + len > Text.Length)
|
||||
len = Text.Length - start;
|
||||
if (len < 0)
|
||||
return rv;
|
||||
|
||||
string t = Text.Substring (start, len);
|
||||
|
||||
int ps = 0;
|
||||
for (int i = 0; i < t.Length; i ++) {
|
||||
if (t[i] == '\n') {
|
||||
if (i != 0) {
|
||||
Piece p = new Piece (start + ps, i + 1, t.Substring (ps, i+1-ps), link);
|
||||
rv.Add (p);
|
||||
}
|
||||
ps = i+1;
|
||||
}
|
||||
}
|
||||
if (ps < t.Length) {
|
||||
Piece p = new Piece (start + ps, t.Length - ps, t.Substring (ps, t.Length-ps), link);
|
||||
rv.Add (p);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
private void CreateLinkPieces ()
|
||||
{
|
||||
if (Links.Count == 0 || Text.Length == 0) {
|
||||
SetStyle (ControlStyles.Selectable, false);
|
||||
return;
|
||||
}
|
||||
|
||||
SetStyle (ControlStyles.Selectable, true);
|
||||
|
||||
/* don't bother doing the rest if our handle hasn't been created */
|
||||
if (!IsHandleCreated)
|
||||
return;
|
||||
|
||||
int cur_piece = 0;
|
||||
num_pieces = 0;
|
||||
if (Links.Count == 1 && Links[0].Start == 0 && Links[0].Length == -1)
|
||||
Links[0].Length = Text.Length;
|
||||
|
||||
if (Links.Count == 1 && Links[0].Start == 0 && Links[0].Length == -1) {
|
||||
Links[0].Length = Text.Length;
|
||||
}
|
||||
SortLinks ();
|
||||
|
||||
pieces = new Piece [(Links.Count * 2) + 1];
|
||||
pieces[cur_piece] = new Piece();
|
||||
pieces[cur_piece].start = 0;
|
||||
ArrayList pieces_list = new ArrayList ();
|
||||
|
||||
for (int i = 0; i < Text.Length; i++) { /* Every char on the text*/
|
||||
for (int l = 0; l < Links.Count; l++) { /* Every link that we know of*/
|
||||
if (Links[l].Start == i) {
|
||||
if (i > 0) {
|
||||
/*Push prev. regular text*/
|
||||
pieces[cur_piece].end = i;
|
||||
pieces[cur_piece].text = Text.Substring (pieces[cur_piece].start,
|
||||
pieces[cur_piece].end - pieces[cur_piece].start);
|
||||
int current_end = 0;
|
||||
|
||||
cur_piece++;
|
||||
for (int l = 0; l < sorted_links.Length; l ++) {
|
||||
int new_link_start = sorted_links[l].Start;
|
||||
|
||||
/* New link*/
|
||||
pieces[cur_piece] = new Piece ();
|
||||
}
|
||||
|
||||
int end;
|
||||
|
||||
if (Links[l].Start + Links[l].Length > Text.Length) {
|
||||
end = Text.Length - Links[l].Start;
|
||||
}
|
||||
else {
|
||||
end = Links[l].Length;
|
||||
}
|
||||
|
||||
pieces[cur_piece].start = Links[l].Start;
|
||||
pieces[cur_piece].end = Links[l].Start + end;
|
||||
pieces[cur_piece].link = Links[l];
|
||||
|
||||
pieces[cur_piece].text = Text.Substring (pieces[cur_piece].start, end);
|
||||
|
||||
cur_piece++; /* Push link*/
|
||||
pieces[cur_piece] = new Piece();
|
||||
i+= Links[l].Length;
|
||||
pieces[cur_piece].start = i;
|
||||
}
|
||||
if (new_link_start > current_end) {
|
||||
/* create/push a piece
|
||||
* containing the text between
|
||||
* the previous/new link */
|
||||
ArrayList text_pieces = CreatePiecesFromText (current_end, new_link_start - current_end, null);
|
||||
pieces_list.AddRange (text_pieces);
|
||||
}
|
||||
}
|
||||
|
||||
if (pieces[cur_piece].end == 0 && pieces[cur_piece].start < Text.Length) {
|
||||
pieces[cur_piece].end = Text.Length;
|
||||
pieces[cur_piece].text = Text.Substring (pieces[cur_piece].start, pieces[cur_piece].end - pieces[cur_piece].start);
|
||||
cur_piece++;
|
||||
/* now create a group of pieces for
|
||||
* the new link (split up by \n's) */
|
||||
ArrayList link_pieces = CreatePiecesFromText (new_link_start, sorted_links[l].Length, sorted_links[l]);
|
||||
pieces_list.AddRange (link_pieces);
|
||||
sorted_links[l].pieces.AddRange (link_pieces);
|
||||
|
||||
current_end = sorted_links[l].Start + sorted_links[l].Length;
|
||||
}
|
||||
|
||||
num_pieces = cur_piece;
|
||||
|
||||
if (link_font == null)
|
||||
CreateLinkFont ();
|
||||
|
||||
for (int i = 0; i < num_pieces; i++) {
|
||||
SizeF s;
|
||||
|
||||
s = DeviceContext.MeasureString(Text.Substring(pieces[i].start, pieces[i].end - pieces[i].start), link_font, ClientRectangle.Location, string_format);
|
||||
pieces[i].rect = new Rectangle(0, 0, (int)s.Width, (int)s.Height);
|
||||
if (current_end < Text.Length) {
|
||||
ArrayList text_pieces = CreatePiecesFromText (current_end, Text.Length - current_end, null);
|
||||
pieces_list.AddRange (text_pieces);
|
||||
}
|
||||
|
||||
if (Visible && IsHandleCreated)
|
||||
Refresh ();
|
||||
pieces = new Piece[pieces_list.Count];
|
||||
pieces_list.CopyTo (pieces, 0);
|
||||
|
||||
CharacterRange[] ranges = new CharacterRange[pieces.Length];
|
||||
|
||||
for(int i = 0; i < pieces.Length; i++)
|
||||
ranges[i] = new CharacterRange (pieces[i].start, pieces[i].length);
|
||||
|
||||
string_format.FormatFlags = StringFormatFlags.NoClip;
|
||||
string_format.SetMeasurableCharacterRanges (ranges);
|
||||
|
||||
SizeF size = DeviceContext.MeasureString (Text, link_font, ClientRectangle.Location, string_format);
|
||||
|
||||
RectangleF layout_rect = new RectangleF (0.0f, 0.0f, size.Width, size.Height);
|
||||
|
||||
Region[] regions = DeviceContext.MeasureCharacterRanges (Text,
|
||||
link_font,
|
||||
layout_rect,
|
||||
string_format);
|
||||
|
||||
for (int i = 0; i < pieces.Length; i ++)
|
||||
pieces[i].region = regions[i];
|
||||
|
||||
Invalidate ();
|
||||
}
|
||||
|
||||
private void SortLinks ()
|
||||
{
|
||||
if (sorted_links != null)
|
||||
return;
|
||||
|
||||
sorted_links = new Link [Links.Count];
|
||||
((ICollection)Links).CopyTo (sorted_links, 0);
|
||||
|
||||
Array.Sort (sorted_links, new LinkComparer ());
|
||||
}
|
||||
|
||||
/* Check if the links overlap */
|
||||
internal void CheckLinks ()
|
||||
private void CheckLinks ()
|
||||
{
|
||||
for (int i = 0; i < Links.Count; i++) {
|
||||
for (int l = 0; l < Links.Count; l++) {
|
||||
if (i==l) continue;
|
||||
SortLinks ();
|
||||
|
||||
if (((Links[i].Start + Links[i].Length) >= Links[l].Start &&
|
||||
Links[i].Start + Links[i].Length <= Links[l].Start + Links[l].Length) ||
|
||||
(Links[i].Start >= Links[l].Start &&
|
||||
Links[i].Start <= Links[l].Start + Links[l].Length))
|
||||
throw new InvalidOperationException ("Overlapping link regions.");
|
||||
}
|
||||
int current_end = 0;
|
||||
|
||||
for (int i = 0; i < sorted_links.Length; i++) {
|
||||
if (sorted_links[i].Start < current_end)
|
||||
throw new InvalidOperationException ("Overlapping link regions.");
|
||||
current_end = sorted_links[i].Start + sorted_links[i].Length;
|
||||
}
|
||||
}
|
||||
|
||||
internal Font GetPieceFont (Piece piece)
|
||||
{
|
||||
if (piece.link == null)
|
||||
return Font;
|
||||
|
||||
switch (link_behavior) {
|
||||
case LinkBehavior.AlwaysUnderline:
|
||||
case LinkBehavior.SystemDefault: // Depends on IE configuration
|
||||
{
|
||||
if (piece.link == null) {
|
||||
return Font;
|
||||
} else {
|
||||
return link_font;
|
||||
}
|
||||
return link_font;
|
||||
}
|
||||
case LinkBehavior.HoverUnderline:
|
||||
{
|
||||
if (piece.link != null && piece.link.Hoovered) {
|
||||
if (piece.link.Hovered) {
|
||||
return link_font;
|
||||
} else {
|
||||
return Font;
|
||||
@@ -598,22 +646,24 @@ namespace System.Windows.Forms
|
||||
}
|
||||
|
||||
|
||||
internal Color GetLinkColor (Piece piece, int i)
|
||||
internal Color GetPieceColor (Piece piece, int i)
|
||||
{
|
||||
Color color;
|
||||
|
||||
if (Enabled == false ||
|
||||
(piece.link != null && piece.link.Enabled == false))
|
||||
if (Enabled == false)
|
||||
return DisabledLinkColor;
|
||||
|
||||
if (piece.link == null)
|
||||
return ForeColor;
|
||||
|
||||
if (!piece.link.Enabled)
|
||||
color = DisabledLinkColor;
|
||||
else if (piece.link.Active)
|
||||
color = ActiveLinkColor;
|
||||
else if ((LinkVisited && i == 0) || piece.link.Visited == true)
|
||||
color = VisitedLinkColor;
|
||||
else
|
||||
if (piece.clicked == true)
|
||||
color = ActiveLinkColor;
|
||||
else
|
||||
if ((LinkVisited == true && i == 0) ||
|
||||
(piece.link != null && piece.link.Visited == true))
|
||||
color = VisitedLinkColor;
|
||||
else
|
||||
color = LinkColor;
|
||||
color = LinkColor;
|
||||
|
||||
return color;
|
||||
}
|
||||
@@ -624,7 +674,7 @@ namespace System.Windows.Forms
|
||||
link_font.Dispose ();
|
||||
|
||||
link_font = new Font (Font.FontFamily, Font.Size, Font.Style | FontStyle.Underline,
|
||||
Font.Unit);
|
||||
Font.Unit);
|
||||
}
|
||||
|
||||
#endregion // Private Methods
|
||||
@@ -640,36 +690,29 @@ namespace System.Windows.Forms
|
||||
private int start;
|
||||
private bool visited;
|
||||
private LinkLabel owner;
|
||||
private bool hoovered;
|
||||
|
||||
internal Link ()
|
||||
{
|
||||
enabled = true;
|
||||
visited = false;
|
||||
length = start = 0;
|
||||
linkData = null;
|
||||
owner = null;
|
||||
}
|
||||
private bool hovered;
|
||||
internal ArrayList pieces;
|
||||
private bool focused;
|
||||
private bool active;
|
||||
|
||||
internal Link (LinkLabel owner)
|
||||
{
|
||||
focused = false;
|
||||
enabled = true;
|
||||
visited = false;
|
||||
length = start = 0;
|
||||
linkData = null;
|
||||
this.owner = owner;
|
||||
pieces = new ArrayList ();
|
||||
}
|
||||
|
||||
public bool Enabled {
|
||||
get { return enabled; }
|
||||
set {
|
||||
if (enabled == value)
|
||||
return;
|
||||
if (enabled != value)
|
||||
Invalidate ();
|
||||
|
||||
enabled = value;
|
||||
|
||||
if (owner != null)
|
||||
owner.Refresh ();
|
||||
enabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,12 +726,11 @@ namespace System.Windows.Forms
|
||||
}
|
||||
set {
|
||||
if (length == value)
|
||||
return;
|
||||
return;
|
||||
|
||||
length = value;
|
||||
|
||||
if (owner != null)
|
||||
owner.CreateLinkPieces ();
|
||||
owner.CreateLinkPieces ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,27 +747,72 @@ namespace System.Windows.Forms
|
||||
|
||||
start = value;
|
||||
|
||||
if (owner != null)
|
||||
owner.CreateLinkPieces ();
|
||||
owner.sorted_links = null;
|
||||
owner.CreateLinkPieces ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Visited {
|
||||
get { return visited; }
|
||||
set {
|
||||
if (visited == value)
|
||||
return;
|
||||
if (visited != value)
|
||||
Invalidate ();
|
||||
|
||||
visited = value;
|
||||
|
||||
if (owner != null)
|
||||
owner.Refresh ();
|
||||
}
|
||||
}
|
||||
|
||||
internal bool Hoovered {
|
||||
get { return hoovered; }
|
||||
set { hoovered = value; }
|
||||
internal bool Hovered {
|
||||
get { return hovered; }
|
||||
set {
|
||||
if (hovered != value)
|
||||
Invalidate ();
|
||||
hovered = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool Focused {
|
||||
get { return focused; }
|
||||
set {
|
||||
if (focused != value)
|
||||
Invalidate ();
|
||||
focused = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool Active {
|
||||
get { return active; }
|
||||
set {
|
||||
if (active != value)
|
||||
Invalidate ();
|
||||
active = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void Invalidate ()
|
||||
{
|
||||
for (int i = 0; i < pieces.Count; i ++)
|
||||
owner.Invalidate (((Piece)pieces[i]).region);
|
||||
}
|
||||
|
||||
internal bool Contains (int x, int y)
|
||||
{
|
||||
foreach (Piece p in pieces) {
|
||||
if (p.region.IsVisible (new Point (x,y)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class LinkComparer : IComparer
|
||||
{
|
||||
public int Compare (object x, object y)
|
||||
{
|
||||
Link l1 = (Link)x;
|
||||
Link l2 = (Link)y;
|
||||
|
||||
return l1.Start - l2.Start;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -790,6 +877,7 @@ namespace System.Windows.Forms
|
||||
link.LinkData = o;
|
||||
idx = collection.Add (link);
|
||||
|
||||
owner.sorted_links = null;
|
||||
owner.CheckLinks ();
|
||||
owner.CreateLinkPieces ();
|
||||
return (Link) collection[idx];
|
||||
@@ -798,10 +886,11 @@ namespace System.Windows.Forms
|
||||
public virtual void Clear ()
|
||||
{
|
||||
collection.Clear();
|
||||
owner.sorted_links = null;
|
||||
owner.CreateLinkPieces ();
|
||||
}
|
||||
|
||||
public bool Contains (LinkLabel.Link link)
|
||||
public bool Contains (Link link)
|
||||
{
|
||||
return collection.Contains (link);
|
||||
}
|
||||
@@ -811,7 +900,7 @@ namespace System.Windows.Forms
|
||||
return collection.GetEnumerator ();
|
||||
}
|
||||
|
||||
public int IndexOf (LinkLabel.Link link)
|
||||
public int IndexOf (Link link)
|
||||
{
|
||||
return collection.IndexOf (link);
|
||||
}
|
||||
@@ -819,6 +908,7 @@ namespace System.Windows.Forms
|
||||
public void Remove (LinkLabel.Link value)
|
||||
{
|
||||
collection.Remove (value);
|
||||
owner.sorted_links = null;
|
||||
owner.CreateLinkPieces ();
|
||||
}
|
||||
|
||||
@@ -828,6 +918,7 @@ namespace System.Windows.Forms
|
||||
throw new ArgumentOutOfRangeException ("Invalid value for array index");
|
||||
|
||||
collection.Remove (collection[index]);
|
||||
owner.sorted_links = null;
|
||||
owner.CreateLinkPieces ();
|
||||
}
|
||||
|
||||
@@ -856,6 +947,7 @@ namespace System.Windows.Forms
|
||||
int IList.Add (object control)
|
||||
{
|
||||
int idx = collection.Add (control);
|
||||
owner.sorted_links = null;
|
||||
owner.CheckLinks ();
|
||||
owner.CreateLinkPieces ();
|
||||
return idx;
|
||||
@@ -863,7 +955,7 @@ namespace System.Windows.Forms
|
||||
|
||||
bool IList.Contains (object control)
|
||||
{
|
||||
return collection.Contains (control);
|
||||
return Contains ((Link)control);
|
||||
}
|
||||
|
||||
int IList.IndexOf (object control)
|
||||
@@ -874,14 +966,14 @@ namespace System.Windows.Forms
|
||||
void IList.Insert (int index, object value)
|
||||
{
|
||||
collection.Insert (index, value);
|
||||
owner.sorted_links = null;
|
||||
owner.CheckLinks ();
|
||||
owner.CreateLinkPieces ();
|
||||
}
|
||||
|
||||
void IList.Remove (object control)
|
||||
{
|
||||
collection.Remove (control);
|
||||
owner.CreateLinkPieces ();
|
||||
Remove ((Link)control);
|
||||
}
|
||||
}
|
||||
#if NET_2_0
|
||||
|
||||
@@ -939,7 +939,7 @@ namespace System.Windows.Forms
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return base.ToString () + ", Items Count: " + Items.Count;
|
||||
return base.ToString ();
|
||||
}
|
||||
|
||||
protected virtual void WmReflectCommand (ref Message m)
|
||||
|
||||
@@ -682,7 +682,7 @@ namespace System.Windows.Forms {
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return Text;
|
||||
return String.Concat (base.ToString (), ", Text: ", Text);
|
||||
}
|
||||
|
||||
public void Undo() {
|
||||
|
||||
@@ -696,11 +696,14 @@ namespace System.Windows.Forms
|
||||
public abstract void DataGridPaint (PaintEventArgs pe, DataGrid grid);
|
||||
public abstract void DataGridPaintCaption (Graphics g, Rectangle clip, DataGrid grid);
|
||||
public abstract void DataGridPaintColumnHeaders (Graphics g, Rectangle clip, DataGrid grid);
|
||||
public abstract void DataGridPaintRowHeaders (Graphics g, Rectangle clip, DataGrid grid);
|
||||
public abstract void DataGridPaintRowContents (Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, DataGrid grid);
|
||||
public abstract void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid);
|
||||
public abstract void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid);
|
||||
public abstract void DataGridPaintParentRows (Graphics g, Rectangle bounds, DataGrid grid);
|
||||
public abstract void DataGridPaintParentRow (Graphics g, Rectangle bounds, DataGridParentRow row, DataGrid grid);
|
||||
public abstract void DataGridPaintRows (Graphics g, Rectangle cells, Rectangle clip, DataGrid grid);
|
||||
public abstract void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, DataGrid grid);
|
||||
public abstract void DataGridPaintRelationRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, DataGrid grid);
|
||||
|
||||
#endregion // Datagrid
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
// Alexander Olk, [email protected]
|
||||
//
|
||||
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
@@ -843,26 +843,21 @@ namespace System.Windows.Forms
|
||||
|
||||
public override void DataGridPaint (PaintEventArgs pe, DataGrid grid)
|
||||
{
|
||||
// Draw parent rows
|
||||
if (pe.ClipRectangle.IntersectsWith (grid.parent_rows)) {
|
||||
pe.Graphics.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor), grid.parent_rows);
|
||||
}
|
||||
|
||||
DataGridPaintCaption (pe.Graphics, pe.ClipRectangle, grid);
|
||||
DataGridPaintParentRows (pe.Graphics, pe.ClipRectangle, grid);
|
||||
DataGridPaintColumnHeaders (pe.Graphics, pe.ClipRectangle, grid);
|
||||
DataGridPaintRowHeaders (pe.Graphics, pe.ClipRectangle, grid);
|
||||
DataGridPaintRows (pe.Graphics, grid.cells_area, pe.ClipRectangle, grid);
|
||||
|
||||
// Paint scrollBar corner
|
||||
if (grid.vert_scrollbar.Visible && grid.horiz_scrollbar.Visible) {
|
||||
if (grid.VScrollBar.Visible && grid.HScrollBar.Visible) {
|
||||
|
||||
Rectangle corner = new Rectangle (grid.ClientRectangle.X + grid.ClientRectangle.Width - grid.horiz_scrollbar.Height,
|
||||
grid.ClientRectangle.Y + grid.ClientRectangle.Height - grid.horiz_scrollbar.Height,
|
||||
grid.horiz_scrollbar.Height, grid.horiz_scrollbar.Height);
|
||||
Rectangle corner = new Rectangle (grid.ClientRectangle.X + grid.ClientRectangle.Width - grid.HScrollBar.Width,
|
||||
grid.ClientRectangle.Y + grid.ClientRectangle.Height - grid.VScrollBar.Height,
|
||||
grid.VScrollBar.Width, grid.HScrollBar.Height);
|
||||
|
||||
if (pe.ClipRectangle.IntersectsWith (corner)) {
|
||||
pe.Graphics.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor),
|
||||
corner);
|
||||
corner);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -877,7 +872,7 @@ namespace System.Windows.Forms
|
||||
|
||||
g.DrawString (grid.CaptionText, grid.CaptionFont,
|
||||
ResPool.GetSolidBrush (grid.CaptionForeColor),
|
||||
grid.caption_area);
|
||||
grid.caption_area);
|
||||
}
|
||||
|
||||
public override void DataGridPaintColumnHeaders (Graphics g, Rectangle clip, DataGrid grid)
|
||||
@@ -887,13 +882,11 @@ namespace System.Windows.Forms
|
||||
if (grid.CurrentTableStyle.CurrentRowHeadersVisible) { // Paint corner shared between row and column header
|
||||
Rectangle rect_bloc = grid.columnhdrs_area;
|
||||
rect_bloc.Width = grid.RowHeaderWidth;
|
||||
rect_bloc.Height = grid.ColumnHeadersArea.Height;
|
||||
if (clip.IntersectsWith (rect_bloc)) {
|
||||
if (grid.visiblecolumn_count > 0) {
|
||||
if (grid.VisibleColumnCount > 0)
|
||||
g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor), rect_bloc);
|
||||
}else {
|
||||
else
|
||||
g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), rect_bloc);
|
||||
}
|
||||
}
|
||||
|
||||
columns_area.X += grid.RowHeaderWidth;
|
||||
@@ -915,11 +908,11 @@ namespace System.Windows.Forms
|
||||
rect_columnhdr.Y = columns_area.Y;
|
||||
rect_columnhdr.Height = columns_area.Height;
|
||||
|
||||
int column_cnt = grid.first_visiblecolumn + grid.visiblecolumn_count;
|
||||
for (int column = grid.first_visiblecolumn; column < column_cnt; column++) {
|
||||
int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
|
||||
for (int column = grid.FirstVisibleColumn; column < column_cnt; column++) {
|
||||
|
||||
col_pixel = grid.GetColumnStartingPixel (column);
|
||||
rect_columnhdr.X = columns_area.X + col_pixel - grid.horz_pixeloffset;
|
||||
rect_columnhdr.X = columns_area.X + col_pixel - grid.HorizPixelOffset;
|
||||
rect_columnhdr.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
|
||||
|
||||
if (clip.IntersectsWith (rect_columnhdr) == false)
|
||||
@@ -944,37 +937,106 @@ namespace System.Windows.Forms
|
||||
|
||||
}
|
||||
|
||||
public override void DataGridPaintRowHeaders (Graphics g, Rectangle clip, DataGrid grid)
|
||||
public override void DataGridPaintParentRows (Graphics g, Rectangle clip, DataGrid grid)
|
||||
{
|
||||
Rectangle rowhdrs_area_complete = grid.rowhdrs_area;
|
||||
rowhdrs_area_complete.Height = grid.rowhdrs_maxheight;
|
||||
Rectangle rect_row = new Rectangle ();
|
||||
rect_row.X = grid.RowHeadersArea.X;
|
||||
int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
|
||||
Rectangle not_usedarea = rowhdrs_area_complete;
|
||||
|
||||
if (rowcnt < grid.RowsCount) { // Paint one row more for partial rows
|
||||
rowcnt++;
|
||||
}
|
||||
rect_row.X = grid.ParentRowsArea.X;
|
||||
rect_row.Width = grid.ParentRowsArea.Width;
|
||||
rect_row.Height = (grid.CaptionFont.Height + 3);
|
||||
|
||||
g.SetClip (grid.rowhdrs_area);
|
||||
for (int row = grid.FirstVisibleRow; row < rowcnt; row++) {
|
||||
g.SetClip (grid.ParentRowsArea);
|
||||
|
||||
rect_row.Width = grid.RowHeadersArea.Width;
|
||||
rect_row.Height = grid.rows[row].Height;
|
||||
rect_row.Y = grid.RowHeadersArea.Y + grid.rows[row].VerticalOffset - grid.rows[grid.FirstVisibleRow].VerticalOffset;
|
||||
object[] parentRows = grid.parentRows.ToArray();
|
||||
|
||||
Region current_clip;
|
||||
for (int row = 0; row < parentRows.Length; row++) {
|
||||
Console.WriteLine ("row {0}", row);
|
||||
|
||||
if (clip.IntersectsWith (rect_row)) {
|
||||
DataGridPaintRowHeader (g, rect_row, row, grid);
|
||||
rect_row.Y = grid.ParentRowsArea.Y + row * rect_row.Height;
|
||||
|
||||
Console.WriteLine ("rect_row = {0}", rect_row);
|
||||
|
||||
if (clip.IntersectsWith (rect_row) == false) {
|
||||
Console.WriteLine ("doesn't intersect");
|
||||
continue;
|
||||
}
|
||||
|
||||
current_clip = new Region (rect_row);
|
||||
current_clip.Intersect (clip);
|
||||
g.Clip = current_clip;
|
||||
|
||||
DataGridPaintParentRow (g, rect_row, (DataGridParentRow)parentRows[parentRows.Length - row - 1], grid);
|
||||
|
||||
current_clip.Dispose ();
|
||||
}
|
||||
|
||||
g.ResetClip ();
|
||||
not_usedarea.Height = grid.rowhdrs_maxheight - grid.RowHeadersArea.Height;
|
||||
not_usedarea.Y = grid.RowHeadersArea.Y + grid.RowHeadersArea.Height;
|
||||
g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
|
||||
}
|
||||
|
||||
|
||||
public override void DataGridPaintParentRow (Graphics g, Rectangle bounds, DataGridParentRow row, DataGrid grid)
|
||||
{
|
||||
//Console.WriteLine ("drawing parent row {0}", row);
|
||||
|
||||
// Background
|
||||
g.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor),
|
||||
bounds);
|
||||
|
||||
Font bold_font = new Font (grid.Font.FontFamily, grid.Font.Size, grid.Font.Style | FontStyle.Bold);
|
||||
// set up some standard string formating variables
|
||||
StringFormat text_format = new StringFormat();
|
||||
text_format.LineAlignment = StringAlignment.Center;
|
||||
text_format.Alignment = StringAlignment.Near;
|
||||
|
||||
string table_name = ((ITypedList)row.view.DataView).GetListName (null) + ": ";
|
||||
|
||||
Rectangle text_rect;
|
||||
Size text_size;
|
||||
|
||||
text_size = g.MeasureString (table_name, bold_font).ToSize();
|
||||
text_rect = new Rectangle(new Point(bounds.X + 3, bounds.Y + bounds.Height - text_size.Height), text_size);
|
||||
|
||||
//Console.WriteLine ("drawing text at {0}", text_rect);
|
||||
|
||||
g.DrawString (table_name,
|
||||
bold_font, ResPool.GetSolidBrush (grid.ParentRowsForeColor), text_rect, text_format);
|
||||
|
||||
foreach (PropertyDescriptor pd in ((ICustomTypeDescriptor)row.view).GetProperties()) {
|
||||
if (typeof(IBindingList).IsAssignableFrom (pd.PropertyType))
|
||||
continue;
|
||||
|
||||
text_rect.X += text_rect.Size.Width + 5;
|
||||
|
||||
string text = String.Format ("{0}: {1}",
|
||||
pd.Name,
|
||||
pd.GetValue (row.view));
|
||||
|
||||
text_rect.Size = g.MeasureString (text, grid.Font).ToSize();
|
||||
text_rect.Y = bounds.Y + bounds.Height - text_rect.Height; // XXX
|
||||
|
||||
//Console.WriteLine ("drawing text at {0}", text_rect);
|
||||
|
||||
g.DrawString (text,
|
||||
grid.Font, ResPool.GetSolidBrush (grid.ParentRowsForeColor), text_rect, text_format);
|
||||
}
|
||||
|
||||
if (grid.FlatMode == false) {
|
||||
|
||||
// Paint Borders
|
||||
g.DrawLine (ResPool.GetPen (ColorControlLight),
|
||||
bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
|
||||
|
||||
g.DrawLine (ResPool.GetPen (ColorControlLight),
|
||||
bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
|
||||
|
||||
g.DrawLine (ResPool.GetPen (ColorControlDark),
|
||||
bounds.X + bounds.Width - 1, bounds.Y + 1 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
|
||||
|
||||
g.DrawLine (ResPool.GetPen (ColorControlDark),
|
||||
bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid)
|
||||
{
|
||||
Point[] arrow = new Point[3];
|
||||
@@ -1007,66 +1069,49 @@ namespace System.Windows.Forms
|
||||
g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor),
|
||||
bounds);
|
||||
|
||||
if (grid.FlatMode == false) {
|
||||
if (grid.ShowEditRow && grid.RowsCount > 0 && row == grid.RowsCount && !(row == grid.CurrentCell.RowNumber && grid.IsChanging == true)) {
|
||||
|
||||
// Paint Borders
|
||||
g.DrawLine (ResPool.GetPen (ColorControlLight),
|
||||
bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
|
||||
|
||||
g.DrawLine (ResPool.GetPen (ColorControlLight),
|
||||
bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
|
||||
|
||||
g.DrawLine (ResPool.GetPen (ColorControlDark),
|
||||
bounds.X + bounds.Width - 1, bounds.Y + 1 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
|
||||
|
||||
g.DrawLine (ResPool.GetPen (ColorControlDark),
|
||||
bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
|
||||
}
|
||||
|
||||
if (grid.ShowEditRow && grid.RowsCount > 0 && row == grid.RowsCount && !(row == grid.CurrentCell.RowNumber && grid.is_changing == true)) {
|
||||
|
||||
g.DrawString ("*", grid.font_newrow, ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
|
||||
g.DrawString ("*", grid.Font, ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
|
||||
bounds);
|
||||
|
||||
} else {
|
||||
if (grid.FlatMode == false) {
|
||||
|
||||
// Paint Borders
|
||||
g.DrawLine (ResPool.GetPen (ColorControlLight),
|
||||
bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
|
||||
|
||||
g.DrawLine (ResPool.GetPen (ColorControlLight),
|
||||
bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
|
||||
|
||||
g.DrawLine (ResPool.GetPen (ColorControlDark),
|
||||
bounds.X + bounds.Width - 1, bounds.Y + 1 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
|
||||
|
||||
g.DrawLine (ResPool.GetPen (ColorControlDark),
|
||||
bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
|
||||
}
|
||||
|
||||
// Draw arrow
|
||||
if (row == grid.CurrentCell.RowNumber) {
|
||||
|
||||
if (grid.is_changing == true) {
|
||||
if (grid.IsChanging == true) {
|
||||
g.DrawString ("...", grid.Font,
|
||||
ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
|
||||
bounds);
|
||||
|
||||
} else {
|
||||
|
||||
Rectangle rect = new Rectangle (bounds.X - 2, bounds.Y, 18, 18);
|
||||
Rectangle rect = new Rectangle (bounds.X - 2, bounds.Y, 18, 18);
|
||||
DataGridPaintRowHeaderArrow (g, rect, grid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (grid.CurrentTableStyle.HasRelations) {
|
||||
bounds.X += bounds.Width / 2;
|
||||
bounds.Width /= 2;
|
||||
|
||||
if (grid.IsExpanded (row)) {
|
||||
g.DrawString ("-", grid.Font,
|
||||
ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
|
||||
bounds);
|
||||
}
|
||||
else {
|
||||
g.DrawString ("+", grid.Font,
|
||||
ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
|
||||
bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void DataGridPaintRows (Graphics g, Rectangle cells, Rectangle clip, DataGrid grid)
|
||||
{
|
||||
Rectangle rect_row = new Rectangle ();
|
||||
Rectangle not_usedarea = new Rectangle ();
|
||||
rect_row.X = cells.X;
|
||||
|
||||
int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
|
||||
|
||||
@@ -1080,33 +1125,124 @@ namespace System.Windows.Forms
|
||||
|
||||
rect_row.Width = cells.Width;
|
||||
for (int row = grid.FirstVisibleRow; row < rowcnt; row++) {
|
||||
rect_row.Height = grid.rows[row].Height;
|
||||
rect_row.Y = cells.Y + grid.rows[row].VerticalOffset - grid.rows[grid.FirstVisibleRow].VerticalOffset;
|
||||
if (row == grid.Rows.Length - 1)
|
||||
rect_row.Height = grid.Rows[row].Height;
|
||||
else
|
||||
rect_row.Height = grid.Rows[row + 1].VerticalOffset - grid.Rows[row].VerticalOffset;
|
||||
rect_row.Y = cells.Y + grid.Rows[row].VerticalOffset - grid.Rows[grid.FirstVisibleRow].VerticalOffset;
|
||||
if (clip.IntersectsWith (rect_row)) {
|
||||
DataGridPaintRow (g, row, rect_row, false, clip, grid);
|
||||
if (grid.CurrentTableStyle.HasRelations)
|
||||
DataGridPaintRelationRow (g, row, rect_row, false, clip, grid);
|
||||
else
|
||||
DataGridPaintRow (g, row, rect_row, false, clip, grid);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX
|
||||
if (grid.ShowEditRow && grid.RowsCount > 0 && grid.FirstVisibleRow + grid.VisibleRowCount == grid.RowsCount + 1) {
|
||||
rect_row.Y = cells.Y + ((rowcnt - grid.FirstVisibleRow) * grid.RowHeight);
|
||||
rect_row.Y = rect_row.Y + rect_row.Height;
|
||||
rect_row.Height = grid.RowHeight;
|
||||
if (clip.IntersectsWith (rect_row)) {
|
||||
DataGridPaintRow (g, rowcnt, rect_row, true, clip, grid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
not_usedarea.Height = cells.Y + cells.Height - rect_row.Y - rect_row.Height;
|
||||
not_usedarea.Y = rect_row.Y + rect_row.Height;
|
||||
not_usedarea.Width = rect_row.Width = cells.Width;
|
||||
not_usedarea.X = cells.X;
|
||||
not_usedarea.Width = rect_row.Width = cells.Width + grid.RowHeadersArea.Width;
|
||||
not_usedarea.X = 0;
|
||||
|
||||
g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
|
||||
}
|
||||
|
||||
public override void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow,
|
||||
Rectangle clip, DataGrid grid)
|
||||
{
|
||||
|
||||
public override void DataGridPaintRelationRow (Graphics g, int row, Rectangle row_rect, bool is_newrow,
|
||||
Rectangle clip, DataGrid grid)
|
||||
{
|
||||
Rectangle rect_header;
|
||||
Rectangle icon_bounds = new Rectangle ();
|
||||
Pen pen = ThemeEngine.Current.ResPool.GetPen (grid.CurrentTableStyle.ForeColor);
|
||||
|
||||
/* paint the header if it's visible and intersects the clip */
|
||||
if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
|
||||
rect_header = row_rect;
|
||||
rect_header.Width = grid.RowHeaderWidth;
|
||||
row_rect.X += grid.RowHeaderWidth;
|
||||
if (clip.IntersectsWith (rect_header)) {
|
||||
DataGridPaintRowHeader (g, rect_header, row, grid);
|
||||
}
|
||||
|
||||
icon_bounds = rect_header;
|
||||
icon_bounds.X += icon_bounds.Width / 2;
|
||||
icon_bounds.Y += 3;
|
||||
icon_bounds.Width = 8;
|
||||
icon_bounds.Height = 8;
|
||||
|
||||
g.DrawRectangle (pen, icon_bounds);
|
||||
|
||||
/* the - part of the icon */
|
||||
g.DrawLine (pen,
|
||||
icon_bounds.X + 2, icon_bounds.Y + icon_bounds.Height / 2,
|
||||
icon_bounds.X + icon_bounds.Width - 2, icon_bounds.Y + icon_bounds.Height / 2);
|
||||
|
||||
if (!grid.IsExpanded (row)) {
|
||||
/* the | part of the icon */
|
||||
g.DrawLine (pen,
|
||||
icon_bounds.X + icon_bounds.Width / 2, icon_bounds.Y + 2,
|
||||
icon_bounds.X + icon_bounds.Width / 2, icon_bounds.Y + icon_bounds.Height - 2);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle nested_rect = row_rect;
|
||||
|
||||
if (grid.Rows[row].IsExpanded)
|
||||
nested_rect.Height -= grid.Rows[row].RelationHeight;
|
||||
|
||||
DataGridPaintRowContents (g, row, nested_rect, is_newrow, clip, grid);
|
||||
|
||||
if (grid.Rows[row].IsExpanded) {
|
||||
|
||||
Region prev_clip = g.Clip;
|
||||
Region current_clip;
|
||||
Rectangle rect_cell = row_rect;
|
||||
|
||||
rect_cell.X = row_rect.X + grid.GetColumnStartingPixel (grid.FirstVisibleColumn) - grid.HorizPixelOffset;
|
||||
rect_cell.Y += nested_rect.Height;
|
||||
rect_cell.Height = grid.Rows[row].RelationHeight;
|
||||
rect_cell.Width = 0;
|
||||
|
||||
int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
|
||||
for (int column = grid.FirstVisibleColumn; column < column_cnt; column++)
|
||||
rect_cell.Width += grid.CurrentTableStyle.GridColumnStyles[column].Width;
|
||||
|
||||
g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (grid.CurrentTableStyle.BackColor),
|
||||
rect_cell);
|
||||
|
||||
Rectangle outline = grid.Rows[row].relation_link.Bounds;
|
||||
|
||||
g.DrawLine (pen,
|
||||
icon_bounds.X + icon_bounds.Width / 2, icon_bounds.Y + icon_bounds.Height,
|
||||
icon_bounds.X + icon_bounds.Width / 2, outline.Y + outline.Height / 2);
|
||||
|
||||
g.DrawLine (pen,
|
||||
icon_bounds.X + icon_bounds.Width / 2, outline.Y + outline.Height / 2,
|
||||
outline.X, outline.Y + outline.Height / 2);
|
||||
|
||||
if (row_rect.X + row_rect.Width > rect_cell.X + rect_cell.Width) {
|
||||
Rectangle not_usedarea = new Rectangle ();
|
||||
not_usedarea.X = rect_cell.X + rect_cell.Width;
|
||||
not_usedarea.Width = row_rect.X + row_rect.Width - rect_cell.X - rect_cell.Width;
|
||||
not_usedarea.Y = row_rect.Y;
|
||||
not_usedarea.Height = row_rect.Height;
|
||||
if (clip.IntersectsWith (not_usedarea))
|
||||
g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
|
||||
not_usedarea);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void DataGridPaintRowContents (Graphics g, int row, Rectangle row_rect, bool is_newrow,
|
||||
Rectangle clip, DataGrid grid)
|
||||
{
|
||||
Rectangle rect_cell = new Rectangle ();
|
||||
int col_pixel;
|
||||
Color backcolor, forecolor;
|
||||
@@ -1136,12 +1272,12 @@ namespace System.Windows.Forms
|
||||
foreBrush = ResPool.GetSolidBrush (forecolor);
|
||||
|
||||
// PaintCells at row, column
|
||||
int column_cnt = grid.first_visiblecolumn + grid.visiblecolumn_count;
|
||||
for (int column = grid.first_visiblecolumn; column < column_cnt; column++) {
|
||||
int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
|
||||
for (int column = grid.FirstVisibleColumn; column < column_cnt; column++) {
|
||||
|
||||
col_pixel = grid.GetColumnStartingPixel (column);
|
||||
|
||||
rect_cell.X = row_rect.X + col_pixel - grid.horz_pixeloffset;
|
||||
rect_cell.X = row_rect.X + col_pixel - grid.HorizPixelOffset;
|
||||
rect_cell.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
|
||||
|
||||
if (clip.IntersectsWith (rect_cell)) {
|
||||
@@ -1177,6 +1313,22 @@ namespace System.Windows.Forms
|
||||
not_usedarea);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow,
|
||||
Rectangle clip, DataGrid grid)
|
||||
{
|
||||
/* paint the header if it's visible and intersects the clip */
|
||||
if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
|
||||
Rectangle rect_header = row_rect;
|
||||
rect_header.Width = grid.RowHeaderWidth;
|
||||
row_rect.X += grid.RowHeaderWidth;
|
||||
if (clip.IntersectsWith (rect_header)) {
|
||||
DataGridPaintRowHeader (g, rect_header, row, grid);
|
||||
}
|
||||
}
|
||||
|
||||
DataGridPaintRowContents (g, row, row_rect, is_newrow, clip, grid);
|
||||
}
|
||||
|
||||
#endregion // Datagrid
|
||||
|
||||
@@ -1301,30 +1453,29 @@ namespace System.Windows.Forms
|
||||
#region LinkLabel
|
||||
public override void DrawLinkLabel (Graphics dc, Rectangle clip_rectangle, LinkLabel label)
|
||||
{
|
||||
Color color;
|
||||
|
||||
dc.FillRectangle (GetControlBackBrush (label.BackColor), clip_rectangle);
|
||||
|
||||
for (int i = 0; i < label.num_pieces; i++) {
|
||||
|
||||
if (clip_rectangle.IntersectsWith (label.pieces[i].rect) == false) {
|
||||
if (label.pieces == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < label.pieces.Length; i ++) {
|
||||
RectangleF clipf = new RectangleF (clip_rectangle.X, clip_rectangle.Y,
|
||||
clip_rectangle.Width, clip_rectangle.Height);
|
||||
RectangleF rectf = label.pieces[i].region.GetBounds (dc);
|
||||
|
||||
if (!clipf.IntersectsWith (rectf))
|
||||
continue;
|
||||
}
|
||||
|
||||
color = label.GetLinkColor (label.pieces[i], i);
|
||||
|
||||
if (label.pieces[i].link == null)
|
||||
dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (label.ForeColor),
|
||||
label.pieces[i].rect.X, label.pieces[i].rect.Y);
|
||||
else
|
||||
dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (color),
|
||||
label.pieces[i].rect.X, label.pieces[i].rect.Y);
|
||||
dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (label.GetPieceColor (label.pieces[i], i)),
|
||||
rectf, label.string_format);
|
||||
|
||||
if (label.pieces[i].focused) {
|
||||
CPDrawFocusRectangle (dc, label.pieces[i].rect, label.ForeColor, label.BackColor);
|
||||
LinkLabel.Link link = label.pieces[i].link;
|
||||
if (link != null && link.Focused) {
|
||||
Rectangle rect = new Rectangle ((int)rectf.X, (int)rectf.Y,
|
||||
(int)rectf.Width, (int)rectf.Height);
|
||||
CPDrawFocusRectangle (dc, rect, label.ForeColor, label.BackColor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endregion // LinkLabel
|
||||
#region ListBox
|
||||
|
||||
@@ -251,8 +251,8 @@ namespace System.Windows.Forms
|
||||
txtView.TabIndex = TabIndex;
|
||||
|
||||
SuspendLayout ();
|
||||
Controls.AddImplicit (txtView);
|
||||
Controls.AddImplicit (spnSpinner);
|
||||
Controls.Add (spnSpinner);
|
||||
Controls.Add (txtView);
|
||||
ResumeLayout ();
|
||||
|
||||
this.ActiveControl = txtView;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
2006-07-10 Chris Toshok <[email protected]>
|
||||
|
||||
* DataGridTest.cs: make this class public so it shows up in the
|
||||
list of fixtures (and its tests get run).
|
||||
|
||||
* CurrencyManagerTest.cs: add a test that just spews properties
|
||||
about the currency manager and the datasource, as well as a test
|
||||
for the finalType field.
|
||||
|
||||
2006-07-07 Chris Toshok <[email protected]>
|
||||
|
||||
* DataGridTableStyleTest.cs: couple more tests.
|
||||
|
||||
2006-07-06 Peter Dennis Bartok <[email protected]>
|
||||
|
||||
* ControlTest.cs: Added "LinkLabel with link" test
|
||||
|
||||
2006-06-30 Chris Toshok <[email protected]>
|
||||
|
||||
* DataGridTableStyleTest.cs: add a bunch of mirrored tests for the
|
||||
|
||||
@@ -19,6 +19,17 @@ namespace MonoTests.System.Windows.Forms {
|
||||
static Array style_values = Enum.GetValues(typeof(ControlStyles));
|
||||
static string[] style_names = Enum.GetNames(typeof(ControlStyles));
|
||||
|
||||
public void AssertAreEqual(string[] want, string[] got, string name) {
|
||||
if (want.Length == got.Length) {
|
||||
for (int i=0; i < want.Length; i++) {
|
||||
if (want[i] != got[i]) {
|
||||
Console.WriteLine("{0}: Expected {1}, got {2}", name, want[i], got[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.AreEqual(want, got, name);
|
||||
}
|
||||
|
||||
public static string[] GetStyles(Control control) {
|
||||
string[] result;
|
||||
|
||||
@@ -252,7 +263,33 @@ namespace MonoTests.System.Windows.Forms {
|
||||
"DoubleBuffer=True"
|
||||
};
|
||||
|
||||
string[] LinkLabel_link_want = {
|
||||
"ContainerControl=False",
|
||||
"UserPaint=True",
|
||||
"Opaque=True",
|
||||
"ResizeRedraw=True",
|
||||
"FixedWidth=False",
|
||||
"FixedHeight=False",
|
||||
"StandardClick=True",
|
||||
"Selectable=True",
|
||||
"UserMouse=False",
|
||||
"SupportsTransparentBackColor=True",
|
||||
"StandardDoubleClick=True",
|
||||
"AllPaintingInWmPaint=True",
|
||||
"CacheText=False",
|
||||
"EnableNotifyMessage=False",
|
||||
"DoubleBuffer=True"
|
||||
};
|
||||
|
||||
|
||||
Assert.AreEqual(LinkLabel_want, GetStyles(new LinkLabel()), "LinkLabelStyles");
|
||||
|
||||
// Test LinkLabel with a link
|
||||
LinkLabel link = new LinkLabel();
|
||||
link.Text = "Users need not fear making the switch to Linux";
|
||||
link.Links.Add (6,9, "http://link1");
|
||||
Assert.AreEqual(LinkLabel_link_want, GetStyles(link), "LinkLabelStyles2");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using NUnit.Framework;
|
||||
@@ -560,7 +561,6 @@ namespace MonoTests.System.Windows.Forms {
|
||||
|
||||
return dataset;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EndUninitializedEdit ()
|
||||
{
|
||||
@@ -636,11 +636,13 @@ namespace MonoTests.System.Windows.Forms {
|
||||
|
||||
Assert.AreEqual (0, cm.Position, "AddNew1");
|
||||
Assert.AreEqual (10, cm.Count, "AddNew2");
|
||||
Assert.AreEqual (cm.Count, cm.List.Count, "AddNew2.5");
|
||||
|
||||
cm.AddNew ();
|
||||
|
||||
Assert.AreEqual (10, cm.Position, "AddNew3");
|
||||
Assert.AreEqual (11, cm.Count, "AddNew4");
|
||||
Assert.AreEqual (cm.Count, cm.List.Count, "AddNew4.5");
|
||||
|
||||
Assert.AreEqual (0, item_changed, "AddNew5");
|
||||
Assert.AreEqual (-1, item_changed_args.Index, "AddNew6");
|
||||
@@ -668,6 +670,7 @@ namespace MonoTests.System.Windows.Forms {
|
||||
|
||||
Assert.AreEqual (0, cm.Position, "CancelAddNew1");
|
||||
Assert.AreEqual (10, cm.Count, "CancelAddNew2");
|
||||
Assert.AreEqual (cm.Count, cm.List.Count, "AddNew2.5");
|
||||
|
||||
cm.AddNew ();
|
||||
|
||||
@@ -685,6 +688,7 @@ namespace MonoTests.System.Windows.Forms {
|
||||
|
||||
Assert.AreEqual (9, cm.Position, "CancelAddNew11");
|
||||
Assert.AreEqual (10, cm.Count, "CancelAddNew12");
|
||||
Assert.AreEqual (cm.Count, cm.List.Count, "AddNew12.5");
|
||||
|
||||
cm.CurrentChanged -= new EventHandler (CurrentChanged);
|
||||
cm.PositionChanged -= new EventHandler (PositionChanged);
|
||||
@@ -873,6 +877,92 @@ namespace MonoTests.System.Windows.Forms {
|
||||
Assert.AreEqual (5, rcm.Count, "count3");
|
||||
Assert.AreEqual (3, list.Count, "listcount3");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCurrencyManagerBindings ()
|
||||
{
|
||||
DataSet data_source = CreateRelatedDataSetLarge ();
|
||||
BindingContext bc = new BindingContext ();
|
||||
|
||||
CurrencyManager cm = bc [data_source] as CurrencyManager;
|
||||
|
||||
Console.WriteLine ("cm properties:");
|
||||
foreach (PropertyDescriptor pd in cm.GetItemProperties ())
|
||||
Console.WriteLine (" + {0}", pd.Name);
|
||||
Console.WriteLine ();
|
||||
|
||||
Console.WriteLine ("dataset:");
|
||||
Console.WriteLine ("cm = {0}", cm.GetType());
|
||||
Console.WriteLine ("cm.Count = {0}", cm.Count);
|
||||
cm.Position = 0;
|
||||
Console.WriteLine ("cm.Current = {0}", cm.Current);
|
||||
Console.WriteLine ("cm.Current properties");
|
||||
foreach (PropertyDescriptor pd in ((ICustomTypeDescriptor)cm.Current).GetProperties ())
|
||||
Console.WriteLine (" + {0}", pd.Name);
|
||||
Console.WriteLine ();
|
||||
|
||||
cm = bc [data_source.Tables["Customers"]] as CurrencyManager;
|
||||
Console.WriteLine ("datatable:");
|
||||
Console.WriteLine ("cm = {0}", cm.GetType());
|
||||
Console.WriteLine ("cm.Count = {0}", cm.Count);
|
||||
cm.Position = 0;
|
||||
Console.WriteLine ("cm.Current = {0}", cm.Current);
|
||||
Console.WriteLine ("cm.Current properties");
|
||||
foreach (PropertyDescriptor pd in ((ICustomTypeDescriptor)cm.Current).GetProperties ())
|
||||
Console.WriteLine (" + {0}", pd.Name);
|
||||
|
||||
Console.WriteLine ();
|
||||
|
||||
DataViewManager vm = new DataViewManager (data_source);
|
||||
Console.WriteLine ("vm properties:");
|
||||
foreach (PropertyDescriptor pd in ((ITypedList)vm).GetItemProperties (null))
|
||||
Console.WriteLine (" + {0}", pd.Name);
|
||||
Console.WriteLine ();
|
||||
|
||||
}
|
||||
|
||||
Type GetFinalType (CurrencyManager cm)
|
||||
{
|
||||
FieldInfo fi = cm.GetType().GetField ("finalType", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
return (Type)fi.GetValue (cm);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FinalTypeTest ()
|
||||
{
|
||||
BindingContext bc = new BindingContext ();
|
||||
CurrencyManager cm;
|
||||
ArrayList al;
|
||||
DataSet data_source = CreateRelatedDataSetLarge ();
|
||||
|
||||
/* empty arraylist */
|
||||
al = new ArrayList ();
|
||||
cm = bc[al] as CurrencyManager;
|
||||
Assert.AreEqual (typeof (ArrayList), GetFinalType (cm), "A1");
|
||||
|
||||
/* arraylist with a string element*/
|
||||
al = new ArrayList ();
|
||||
al.Add ("hi");
|
||||
cm = bc[al] as CurrencyManager;
|
||||
Assert.AreEqual (typeof (ArrayList), GetFinalType (cm), "A2");
|
||||
|
||||
/* string array */
|
||||
string[] s = new string[1];
|
||||
s[0] = "hi";
|
||||
cm = bc[s] as CurrencyManager;
|
||||
Assert.AreEqual (typeof (string[]), GetFinalType (cm), "A3");
|
||||
|
||||
/* dataview */
|
||||
cm = bc [data_source, "Customers"] as CurrencyManager;
|
||||
Assert.AreEqual (typeof (DataView), GetFinalType (cm), "A4");
|
||||
|
||||
/* relatedview */
|
||||
cm = bc [data_source, "Customers.Customer_Orders"] as CurrencyManager;
|
||||
/* on MS this is a RelatedView, on Mono a RelatedDataView. both subclass from DataView, so let's check that. */
|
||||
Assert.IsFalse (typeof (DataView) == GetFinalType (cm), "A5");
|
||||
Assert.IsTrue (typeof (DataView).IsAssignableFrom (GetFinalType (cm)), "A6");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,6 +319,7 @@ namespace MonoTests.System.Windows.Forms
|
||||
Assert.AreEqual (false, eventhandled, "A1");
|
||||
}
|
||||
|
||||
// Microsoft is not firing any event
|
||||
[Test]
|
||||
public void TestLinkHoverColorChangedEvent_default ()
|
||||
{
|
||||
@@ -497,5 +498,56 @@ namespace MonoTests.System.Windows.Forms
|
||||
{
|
||||
eventhandled = true;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DataGridNull ()
|
||||
{
|
||||
DataGridTableStyle dg = new DataGridTableStyle ();
|
||||
dg.DataGrid = null;
|
||||
Assert.IsNull (dg.DataGrid, "A1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HeaderFontNull ()
|
||||
{
|
||||
DataGridTableStyle dg = new DataGridTableStyle ();
|
||||
Font header_font = dg.HeaderFont;
|
||||
eventhandled = false;
|
||||
dg.HeaderFontChanged += new EventHandler (OnEventHandler);
|
||||
dg.HeaderFont = null;
|
||||
Assert.AreEqual (header_font, dg.HeaderFont, "A1");
|
||||
Assert.IsFalse (eventhandled, "A2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HeaderFontNull2 ()
|
||||
{
|
||||
DataGridTableStyle dg = new DataGridTableStyle ();
|
||||
Font header_font = dg.HeaderFont;
|
||||
|
||||
Font new_font = new Font ("Helvetica", 8.5f, GraphicsUnit.Point);
|
||||
|
||||
dg.HeaderFont = new_font;
|
||||
Assert.AreEqual (new_font, dg.HeaderFont, "A1");
|
||||
|
||||
eventhandled = false;
|
||||
dg.HeaderFontChanged += new EventHandler (OnEventHandler);
|
||||
dg.HeaderFont = null;
|
||||
|
||||
Assert.AreEqual (header_font, dg.HeaderFont, "A2");
|
||||
Assert.IsTrue (eventhandled, "A3");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MappingNameNull ()
|
||||
{
|
||||
DataGridTableStyle dg = new DataGridTableStyle ();
|
||||
Assert.AreEqual ("", dg.MappingName, "A1");
|
||||
eventhandled = false;
|
||||
dg.MappingNameChanged += new EventHandler (OnEventHandler);
|
||||
dg.MappingName = null;
|
||||
Assert.AreEqual ("", dg.MappingName, "A2");
|
||||
Assert.IsFalse (eventhandled, "A3");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace MonoTests.System.Windows.Forms
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
class DataGridTest
|
||||
public class DataGridTest
|
||||
{
|
||||
private bool eventhandled;
|
||||
|
||||
@@ -174,9 +174,9 @@ namespace MonoTests.System.Windows.Forms
|
||||
Assert.AreEqual (true, eventhandled, "A1");
|
||||
}
|
||||
|
||||
public void OnEventHandler (object sender, EventArgs e)
|
||||
{
|
||||
eventhandled = true;
|
||||
public void OnEventHandler (object sender, EventArgs e)
|
||||
{
|
||||
eventhandled = true;
|
||||
}
|
||||
|
||||
// Property exceptions
|
||||
@@ -311,7 +311,8 @@ namespace MonoTests.System.Windows.Forms
|
||||
Assert.AreEqual (dg.SelectionForeColor, dg2.SelectionForeColor, "A1");
|
||||
}
|
||||
|
||||
[Test] public void TestSetDataBinding ()
|
||||
[Test]
|
||||
public void TestSetDataBinding ()
|
||||
{
|
||||
DataGrid dg = new DataGrid ();
|
||||
DataSet ds = new DataSet ("DataSet");
|
||||
@@ -320,7 +321,6 @@ namespace MonoTests.System.Windows.Forms
|
||||
ds.Tables.Add (dt);
|
||||
|
||||
dg.SetDataBinding (ds, "DataTable");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
2006-07-06 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* System.Drawing_test.dll.sources: Added unit tests for direct GDI+
|
||||
function calls.
|
||||
|
||||
2006-06-30 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* System.Drawing_test.dll.sources: Added unit tests for SolidBrush.
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
2006-07-06 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* Image.cs: Ensure we're setting the nativeObject to NULL before
|
||||
throwing any exception while disposing (and avoid possible double
|
||||
freeing). Avoid multiple casts in Clone method.
|
||||
* Pen.cs: Ensure the internal pen's brush is always disposed
|
||||
correctly. Avoid making a reference to the internal brush.
|
||||
* SolidBrush.cs: Avoid setting color when cloning the solid brush
|
||||
as the .ctor(IntPtr) always does this job.
|
||||
|
||||
2006-07-04 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* Image.cs: Made GetThumbnailImage throw OutOfMemoryException when
|
||||
|
||||
@@ -758,38 +758,28 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
private void DisposeResources ()
|
||||
{
|
||||
Status status = GDIPlus.GdipDisposeImage (nativeObject);
|
||||
GDIPlus.CheckStatus (status);
|
||||
}
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (nativeObject != IntPtr.Zero){
|
||||
DisposeResources ();
|
||||
Status status = GDIPlus.GdipDisposeImage (nativeObject);
|
||||
// set nativeObject to null before throwing an exception
|
||||
nativeObject = IntPtr.Zero;
|
||||
GDIPlus.CheckStatus (status);
|
||||
}
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
public object Clone ()
|
||||
{
|
||||
Bitmap b = (this as Bitmap);
|
||||
if (b == null)
|
||||
throw new NotImplementedException ("This Image instance isn't a Bitmap instance.");
|
||||
|
||||
IntPtr newimage = IntPtr.Zero;
|
||||
|
||||
if (!(this is Bitmap))
|
||||
throw new NotImplementedException ();
|
||||
|
||||
Status status = GDIPlus.GdipCloneImage (NativeObject, out newimage);
|
||||
GDIPlus.CheckStatus (status);
|
||||
|
||||
if (this is Bitmap){
|
||||
return new Bitmap (newimage);
|
||||
}
|
||||
|
||||
throw new NotImplementedException ();
|
||||
return new Bitmap (newimage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -180,7 +180,14 @@ namespace System.Drawing
|
||||
color = value;
|
||||
Status status = GDIPlus.GdipSetPenColor (nativeObject, value.ToArgb ());
|
||||
GDIPlus.CheckStatus (status);
|
||||
|
||||
/* if required clear existing brush */
|
||||
if (must_dispose_brush && (brush != null)) {
|
||||
brush.Dispose ();
|
||||
}
|
||||
brush = new SolidBrush (color);
|
||||
must_dispose_brush = true;
|
||||
|
||||
status = GDIPlus.GdipSetPenBrushFill (nativeObject, brush.nativeObject);
|
||||
GDIPlus.CheckStatus (status);
|
||||
} else
|
||||
@@ -471,7 +478,7 @@ namespace System.Drawing
|
||||
Status status = GDIPlus.GdipClonePen (nativeObject, out ptr);
|
||||
GDIPlus.CheckStatus (status);
|
||||
Pen p = new Pen (ptr);
|
||||
p.brush = brush;
|
||||
p.brush = null; // don't reference! managed brush will be re-created on demand
|
||||
p.color = color;
|
||||
p.startCap = startCap;
|
||||
p.endCap = endCap;
|
||||
@@ -493,6 +500,7 @@ namespace System.Drawing
|
||||
|
||||
if (must_dispose_brush && (brush != null)) {
|
||||
brush.Dispose ();
|
||||
brush = null;
|
||||
}
|
||||
if (nativeObject != IntPtr.Zero) {
|
||||
Status status = GDIPlus.GdipDeletePen (nativeObject);
|
||||
|
||||
@@ -78,11 +78,7 @@ namespace System.Drawing
|
||||
Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
|
||||
GDIPlus.CheckStatus (status);
|
||||
|
||||
SolidBrush clone = new SolidBrush (clonePtr);
|
||||
clone.color = color;
|
||||
|
||||
return clone;
|
||||
|
||||
return new SolidBrush (clonePtr);
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
System.Drawing/ColorTranslator.cs
|
||||
System.Drawing/ColorConverter.cs
|
||||
System.Drawing/FontFamilyTest.cs
|
||||
System.Drawing/GDIPlusTest.cs
|
||||
System.Drawing/PenTest.cs
|
||||
System.Drawing/RegionDataTest.cs
|
||||
System.Drawing/RegionNonRectTest.cs
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
2006-07-06 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* GDIPlusTest.cs: New WIP. Unit tests for the GDI+ function calls.
|
||||
* TestImage.cs: Added checks to validate that the thumbnail's callback
|
||||
is never called.
|
||||
|
||||
2006-07-06 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* SolidBrushTest.cs: New test case using DrawLine.
|
||||
|
||||
2006-07-04 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* TestImage.cs: Add test cases for GetThumbnailImage.
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// Direct GDI+ API unit tests
|
||||
//
|
||||
// Authors:
|
||||
// Sebastien Pouliot <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// 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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Drawing {
|
||||
|
||||
// copied from Mono's System.Drawing.dll gdiEnums.cs
|
||||
internal enum Status {
|
||||
Ok = 0,
|
||||
GenericError = 1,
|
||||
InvalidParameter = 2,
|
||||
OutOfMemory = 3,
|
||||
ObjectBusy = 4,
|
||||
InsufficientBuffer = 5,
|
||||
NotImplemented = 6,
|
||||
Win32Error = 7,
|
||||
WrongState = 8,
|
||||
Aborted = 9,
|
||||
FileNotFound = 10,
|
||||
ValueOverflow = 11,
|
||||
AccessDenied = 12,
|
||||
UnknownImageFormat = 13,
|
||||
FontFamilyNotFound = 14,
|
||||
FontStyleNotFound = 15,
|
||||
NotTrueTypeFont = 16,
|
||||
UnsupportedGdiplusVersion = 17,
|
||||
GdiplusNotInitialized = 18,
|
||||
PropertyNotFound = 19,
|
||||
PropertyNotSupported = 20,
|
||||
ProfileNotFound = 21
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class GDIPlusTest {
|
||||
|
||||
[DllImport ("gdiplus.dll")]
|
||||
internal static extern Status GdipCreateBitmapFromScan0 (int width, int height, int stride, PixelFormat format, IntPtr scan0, out IntPtr bmp);
|
||||
|
||||
[Test]
|
||||
public void CreateBitmapFromScan0 ()
|
||||
{
|
||||
IntPtr bmp;
|
||||
Assert.AreEqual (Status.InvalidParameter, GdipCreateBitmapFromScan0 (-1, 10, 10, PixelFormat.Format32bppArgb, IntPtr.Zero, out bmp), "negative width");
|
||||
}
|
||||
|
||||
|
||||
[DllImport ("gdiplus.dll")]
|
||||
internal static extern Status GdipDisposeImage (IntPtr image);
|
||||
|
||||
[Test]
|
||||
public void DisposeImage ()
|
||||
{
|
||||
// invalid image pointer (null)
|
||||
Assert.AreEqual (Status.InvalidParameter, GdipDisposeImage (IntPtr.Zero), "null");
|
||||
|
||||
IntPtr image;
|
||||
GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format32bppArgb, IntPtr.Zero, out image);
|
||||
Assert.AreEqual (Status.Ok, GdipDisposeImage (image), "first");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void DisposeImage_Dual ()
|
||||
{
|
||||
IntPtr image;
|
||||
GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format32bppArgb, IntPtr.Zero, out image);
|
||||
// first dispose
|
||||
Assert.AreEqual (Status.Ok, GdipDisposeImage (image), "first");
|
||||
// second dispose
|
||||
Assert.AreEqual (Status.ObjectBusy, GdipDisposeImage (image), "second");
|
||||
}
|
||||
|
||||
|
||||
[DllImport ("gdiplus.dll")]
|
||||
internal static extern Status GdipGetImageThumbnail (IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData);
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")] // libgdiplus doesn't implement GdipGetImageThumbnail (it is done inside S.D)
|
||||
public void GetImageThumbnail ()
|
||||
{
|
||||
IntPtr ptr;
|
||||
|
||||
// invalid image pointer (null)
|
||||
Assert.AreEqual (Status.InvalidParameter, GdipGetImageThumbnail (IntPtr.Zero, 10, 10, out ptr, IntPtr.Zero, IntPtr.Zero));
|
||||
|
||||
IntPtr image;
|
||||
GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format32bppArgb, IntPtr.Zero, out image);
|
||||
try {
|
||||
// invalid width (0)
|
||||
Assert.AreEqual (Status.OutOfMemory, GdipGetImageThumbnail (image, 0, 10, out ptr, IntPtr.Zero, IntPtr.Zero));
|
||||
// invalid width (negative)
|
||||
Assert.AreEqual (Status.OutOfMemory, GdipGetImageThumbnail (image, 0x8000000, 10, out ptr, IntPtr.Zero, IntPtr.Zero));
|
||||
// invalid height (0)
|
||||
Assert.AreEqual (Status.OutOfMemory, GdipGetImageThumbnail (image, 10, 0, out ptr, IntPtr.Zero, IntPtr.Zero));
|
||||
// invalid height (negative)
|
||||
Assert.AreEqual (Status.OutOfMemory, GdipGetImageThumbnail (image, 10, 0x8000000, out ptr, IntPtr.Zero, IntPtr.Zero));
|
||||
}
|
||||
finally {
|
||||
GdipDisposeImage (image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,5 +89,22 @@ namespace MonoTests.System.Drawing {
|
||||
Assert.AreEqual (0, bmp.GetPixel (9, 9).ToArgb (), "9,9");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DrawLine ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (10, 10)) {
|
||||
using (Graphics g = Graphics.FromImage (bmp)) {
|
||||
SolidBrush sb = new SolidBrush (Color.Red);
|
||||
Pen p = new Pen (sb);
|
||||
g.DrawLine (p, 0, 0, 9, 9);
|
||||
sb.Color = Color.Blue;
|
||||
g.DrawLine (p, 8, 8, 4, 4); // pen is still red
|
||||
}
|
||||
Assert.AreEqual (Color.Red.ToArgb (), bmp.GetPixel (0, 0).ToArgb (), "0,0");
|
||||
Assert.AreEqual (Color.Red.ToArgb (), bmp.GetPixel (8, 8).ToArgb (), "8,8");
|
||||
Assert.AreEqual (Color.Red.ToArgb (), bmp.GetPixel (9, 9).ToArgb (), "9,9"); // include end point
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
//using System.Runtime.InteropServices;
|
||||
using System.Security.Permissions;
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -43,6 +42,7 @@ namespace MonoTests.System.Drawing{
|
||||
public class ImageTest {
|
||||
|
||||
private string fname;
|
||||
private bool callback;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void FixtureSetup ()
|
||||
@@ -60,6 +60,12 @@ namespace MonoTests.System.Drawing{
|
||||
}
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
callback = false;
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (FileNotFoundException))]
|
||||
public void FileDoesNotExists ()
|
||||
@@ -69,11 +75,13 @@ namespace MonoTests.System.Drawing{
|
||||
|
||||
private bool CallbackTrue ()
|
||||
{
|
||||
callback = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CallbackFalse ()
|
||||
{
|
||||
callback = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -85,6 +93,7 @@ namespace MonoTests.System.Drawing{
|
||||
Image tn = bmp.GetThumbnailImage (10, 5, null, IntPtr.Zero);
|
||||
Assert.AreEqual (5, tn.Height, "Height");
|
||||
Assert.AreEqual (10, tn.Width, "Width");
|
||||
Assert.IsFalse (callback, "Callback called");
|
||||
tn.Save (fname, ImageFormat.Tiff);
|
||||
}
|
||||
}
|
||||
@@ -115,6 +124,7 @@ namespace MonoTests.System.Drawing{
|
||||
Image tn = bmp.GetThumbnailImage (5, 5, new Image.GetThumbnailImageAbort (CallbackFalse), (IntPtr)Int32.MaxValue);
|
||||
Assert.AreEqual (5, tn.Height, "Height");
|
||||
Assert.AreEqual (5, tn.Width, "Width");
|
||||
Assert.IsFalse (callback, "Callback called");
|
||||
tn.Save (fname, ImageFormat.Tiff);
|
||||
}
|
||||
}
|
||||
@@ -126,6 +136,7 @@ namespace MonoTests.System.Drawing{
|
||||
Image tn = bmp.GetThumbnailImage (10, 10, new Image.GetThumbnailImageAbort (CallbackFalse), IntPtr.Zero);
|
||||
Assert.AreEqual (10, tn.Height, "Height");
|
||||
Assert.AreEqual (10, tn.Width, "Width");
|
||||
Assert.IsFalse (callback, "Callback called");
|
||||
tn.Save (fname, ImageFormat.Bmp);
|
||||
}
|
||||
}
|
||||
@@ -137,6 +148,7 @@ namespace MonoTests.System.Drawing{
|
||||
Image tn = bmp.GetThumbnailImage (4, 4, new Image.GetThumbnailImageAbort (CallbackTrue), IntPtr.Zero);
|
||||
Assert.AreEqual (4, tn.Height, "Height");
|
||||
Assert.AreEqual (4, tn.Width, "Width");
|
||||
Assert.IsFalse (callback, "Callback called");
|
||||
tn.Save (fname, ImageFormat.Gif);
|
||||
}
|
||||
}
|
||||
@@ -148,6 +160,7 @@ namespace MonoTests.System.Drawing{
|
||||
Image tn = bmp.GetThumbnailImage (40, 40, new Image.GetThumbnailImageAbort (CallbackTrue), IntPtr.Zero);
|
||||
Assert.AreEqual (40, tn.Height, "Height");
|
||||
Assert.AreEqual (40, tn.Width, "Width");
|
||||
Assert.IsFalse (callback, "Callback called");
|
||||
tn.Save (fname, ImageFormat.Png);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
2006-07-11 Zoltan Varga <[email protected]>
|
||||
|
||||
* MethodBuilder.cs (SetCustomAttribute): Fix handling of SpecialNameAttribute.
|
||||
|
||||
2006-07-08 Zoltan Varga <[email protected]>
|
||||
|
||||
* DynamicMethod.cs: Create all other DynamicMethod's referenced by
|
||||
this method as well. Check for an empty method body.
|
||||
|
||||
* ILGenerator.cs (Emit): Handle DynamicMethod's which might not have a
|
||||
declaring type.
|
||||
|
||||
2006-05-15 Zoltan Varga <[email protected]>
|
||||
|
||||
* AssemblyBuilder.cs (MonoResource): Add a 'stream' field.
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace System.Reflection.Emit {
|
||||
private Delegate deleg;
|
||||
private MonoMethod method;
|
||||
private ParameterBuilder[] pinfo;
|
||||
internal bool creating;
|
||||
|
||||
public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Module m) : this (name, returnType, parameterTypes, m, false) {
|
||||
}
|
||||
@@ -110,8 +111,28 @@ namespace System.Reflection.Emit {
|
||||
|
||||
private void CreateDynMethod () {
|
||||
if (mhandle.Value == IntPtr.Zero) {
|
||||
if (ilgen != null)
|
||||
ilgen.label_fixup ();
|
||||
if (ilgen == null)
|
||||
throw new InvalidOperationException ("Method '" + name + "' does not have a method body.");
|
||||
|
||||
ilgen.label_fixup ();
|
||||
|
||||
// Have to create all DynamicMethods referenced by this one
|
||||
try {
|
||||
// Used to avoid cycles
|
||||
creating = true;
|
||||
if (refs != null) {
|
||||
for (int i = 0; i < refs.Length; ++i) {
|
||||
if (refs [i] is DynamicMethod) {
|
||||
DynamicMethod m = (DynamicMethod)refs [i];
|
||||
if (!m.creating)
|
||||
m.CreateDynMethod ();
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
creating = false;
|
||||
}
|
||||
|
||||
create_dynamic_method (this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,8 +705,12 @@ namespace System.Reflection.Emit {
|
||||
int token = token_gen.GetToken (method);
|
||||
make_room (6);
|
||||
ll_emit (opcode);
|
||||
if (method.DeclaringType.Module == module)
|
||||
add_token_fixup (method);
|
||||
Type declaringType = method.DeclaringType;
|
||||
// Might be a DynamicMethod with no declaring type
|
||||
if (declaringType != null) {
|
||||
if (declaringType.Module == module)
|
||||
add_token_fixup (method);
|
||||
}
|
||||
emit_int (token);
|
||||
if (method.ReturnType != void_type)
|
||||
cur_stack ++;
|
||||
@@ -719,8 +723,12 @@ namespace System.Reflection.Emit {
|
||||
{
|
||||
make_room (6);
|
||||
ll_emit (opcode);
|
||||
if (method.DeclaringType.Module == module)
|
||||
add_token_fixup (method);
|
||||
// Might be a DynamicMethod with no declaring type
|
||||
Type declaringType = method.DeclaringType;
|
||||
if (declaringType != null) {
|
||||
if (declaringType.Module == module)
|
||||
add_token_fixup (method);
|
||||
}
|
||||
emit_int (token);
|
||||
if (method.ReturnType != void_type)
|
||||
cur_stack ++;
|
||||
|
||||
@@ -366,6 +366,13 @@ namespace System.Reflection.Emit {
|
||||
ThrowOnUnmappableChar = (bool)value;
|
||||
#endif
|
||||
}
|
||||
|
||||
attrs |= MethodAttributes.PinvokeImpl;
|
||||
if (preserveSig)
|
||||
iattrs |= MethodImplAttributes.PreserveSig;
|
||||
return;
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
if (attrname == "System.Runtime.CompilerServices.SpecialNameAttribute") {
|
||||
attrs |= MethodAttributes.SpecialName;
|
||||
@@ -373,11 +380,6 @@ namespace System.Reflection.Emit {
|
||||
}
|
||||
#endif
|
||||
|
||||
attrs |= MethodAttributes.PinvokeImpl;
|
||||
if (preserveSig)
|
||||
iattrs |= MethodImplAttributes.PreserveSig;
|
||||
return;
|
||||
}
|
||||
if (cattrs != null) {
|
||||
CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
|
||||
cattrs.CopyTo (new_array, 0);
|
||||
|
||||
@@ -271,9 +271,9 @@ namespace System.Runtime.InteropServices
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
[MonoTODO ("SetErrorInfo")]
|
||||
public static int GetHRForException (Exception e) {
|
||||
throw new NotImplementedException ();
|
||||
return e.hresult;
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2006-07-11 Zoltan Varga <[email protected]>
|
||||
|
||||
* Double.cs (Parse): Fix handling of inner whitespace.
|
||||
|
||||
2006-06-28 Kornél Pál <[email protected]>
|
||||
|
||||
* Char.cs: Implemented IsHighSurrogate and IsLowSurrogate methods.
|
||||
|
||||
@@ -197,6 +197,7 @@ namespace System {
|
||||
private const int State_ExponentSign = 4;
|
||||
private const int State_Exponent = 5;
|
||||
private const int State_ConsumeWhiteSpace = 6;
|
||||
private const int State_Exit = 7;
|
||||
|
||||
public static double Parse (string s, NumberStyles style, IFormatProvider provider)
|
||||
{
|
||||
@@ -312,6 +313,7 @@ namespace System {
|
||||
sidx = len;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (state){
|
||||
case State_AllowSign:
|
||||
if ((style & NumberStyles.AllowLeadingSign) != 0){
|
||||
@@ -442,13 +444,18 @@ namespace System {
|
||||
return false;
|
||||
|
||||
case State_ConsumeWhiteSpace:
|
||||
if (allow_trailing_white && Char.IsWhiteSpace (c))
|
||||
if (allow_trailing_white && Char.IsWhiteSpace (c)) {
|
||||
state = State_Exit;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!tryParse)
|
||||
exc = new FormatException ("Unknown char");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (state == State_Exit)
|
||||
break;
|
||||
}
|
||||
|
||||
b [didx] = 0;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace System
|
||||
string stack_trace;
|
||||
string remote_stack_trace;
|
||||
int remote_stack_index;
|
||||
int hresult = unchecked ((int)0x80004005);
|
||||
internal int hresult = unchecked ((int)0x80004005);
|
||||
string source;
|
||||
|
||||
public Exception ()
|
||||
|
||||
@@ -38,6 +38,11 @@ namespace MonoTests.System {
|
||||
"1e-05",
|
||||
"6363883797383966.2933E-726",
|
||||
};
|
||||
|
||||
private string[] string_values_fail = {
|
||||
"", // empty
|
||||
"- 1.0" // Inner whitespace
|
||||
};
|
||||
|
||||
private double[] double_values = {
|
||||
1, .1, 1.1, -12, 44.444432, .000021121,
|
||||
@@ -202,6 +207,15 @@ namespace MonoTests.System {
|
||||
catch (Exception e) {
|
||||
Assertion.AssertEquals("Should be an OverflowException -", typeof(OverflowException), e.GetType());
|
||||
}
|
||||
|
||||
for (i = 0; i < string_values_fail.Length; ++i) {
|
||||
try {
|
||||
Double.Parse (string_values_fail [i]);
|
||||
Assertion.Fail ("Parse () should fail on '" + string_values_fail [i]);
|
||||
}
|
||||
catch (FormatException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -511,13 +525,6 @@ namespace MonoTests.System {
|
||||
NumberStyles.Integer, null, out value));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (FormatException))]
|
||||
public void ParseEmptyString ()
|
||||
{
|
||||
double.Parse (String.Empty);
|
||||
}
|
||||
|
||||
[Test] // bug #77721
|
||||
public void ParseCurrency ()
|
||||
{
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2006-07-11 Zoltan Varga <[email protected]>
|
||||
|
||||
* reflection.c (mono_custom_attrs_free): Fix freeing of dynamic cattr info.
|
||||
|
||||
2006-07-01 Zoltan Varga <[email protected]>
|
||||
|
||||
* marshal.c (mono_marshal_get_runtime_invoke): Fix passing of generic valuetypes.
|
||||
|
||||
@@ -217,6 +217,8 @@ mono_type_get_name_recurse (MonoType *type, GString *str, gboolean is_recursed,
|
||||
mono_type_get_name_recurse (
|
||||
&type->data.array->eklass->byval_arg, str, FALSE, nested_format);
|
||||
g_string_append_c (str, '[');
|
||||
if (rank == 1)
|
||||
g_string_append_c (str, '*');
|
||||
for (i = 1; i < rank; i++)
|
||||
g_string_append_c (str, ',');
|
||||
g_string_append_c (str, ']');
|
||||
|
||||
@@ -1156,10 +1156,8 @@ mono_save_custom_attrs (MonoImage *image, void *obj, MonoArray *cattrs)
|
||||
void
|
||||
mono_custom_attrs_free (MonoCustomAttrInfo *ainfo)
|
||||
{
|
||||
/* they are cached, so we don't free them */
|
||||
if (dynamic_custom_attrs && g_hash_table_lookup (dynamic_custom_attrs, ainfo))
|
||||
return;
|
||||
g_free (ainfo);
|
||||
if (!ainfo->cached)
|
||||
g_free (ainfo);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -9800,6 +9798,12 @@ resolve_object (MonoImage *image, MonoObject *obj, MonoClass **handle_class)
|
||||
|
||||
result = sig;
|
||||
*handle_class = NULL;
|
||||
} else if (strcmp (obj->vtable->klass->name, "DynamicMethod") == 0) {
|
||||
MonoReflectionDynamicMethod *method = (MonoReflectionDynamicMethod*)obj;
|
||||
/* Already created by the managed code */
|
||||
g_assert (method->mhandle);
|
||||
result = method->mhandle;
|
||||
*handle_class = mono_defaults.methodhandle_class;
|
||||
} else {
|
||||
g_print (obj->vtable->klass->name);
|
||||
g_assert_not_reached ();
|
||||
|
||||
@@ -14,7 +14,8 @@ monolist=($(printf "%s\n" "${filelist[@]}" | egrep "\\.(exe|dll)\$"))
|
||||
|
||||
# Only include files with /gac/ in path
|
||||
# (Allows packages to contain private assemblies that don't conflict with other packages)
|
||||
monolist=($(printf "%s\n" "${monolist[@]}" | egrep "/gac/"))
|
||||
#monolist=($(printf "%s\n" "${monolist[@]}" | egrep "/gac/"))
|
||||
# Disabled... see ChangeLog
|
||||
|
||||
a=`which "$0"`
|
||||
d=`dirname "$a"`
|
||||
|
||||
Reference in new issue
Block a user