Skip to content

Commit

Permalink
Standardize default constructors (needed for xaml), pass null as gene…
Browse files Browse the repository at this point in the history
…rator instead of Generator.Current for better flexibility in the future (e.g. design mode)
  • Loading branch information
cwensley committed Nov 14, 2013
1 parent 56a913a commit 5d7701d
Show file tree
Hide file tree
Showing 70 changed files with 275 additions and 228 deletions.
2 changes: 1 addition & 1 deletion Source/Eto/Drawing/Bitmap.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static Bitmap FromResource (Assembly asm, string resourceName)
/// </summary> /// </summary>
[Obsolete ("use Bitmap.FromResource instead")] [Obsolete ("use Bitmap.FromResource instead")]
public Bitmap (Assembly asm, string resourceName) public Bitmap (Assembly asm, string resourceName)
: this (Generator.Current) : this (null)
{ {
if (asm == null) asm = Assembly.GetCallingAssembly (); if (asm == null) asm = Assembly.GetCallingAssembly ();
using (var stream = asm.GetManifestResourceStream (resourceName)) { using (var stream = asm.GetManifestResourceStream (resourceName)) {
Expand Down
7 changes: 6 additions & 1 deletion Source/Eto/Drawing/GraphicsPath.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -365,11 +365,16 @@ public static IGraphicsPath Create (Generator generator = null)
return generator.Create<IGraphicsPathHandler> (); return generator.Create<IGraphicsPathHandler> ();
} }


public GraphicsPath()
: this((Generator)null)
{
}

/// <summary> /// <summary>
/// Initializes a new instance of the GraphicsPath class /// Initializes a new instance of the GraphicsPath class
/// </summary> /// </summary>
/// <param name="generator">Platform generator for the object, or null to use the current generator</param> /// <param name="generator">Platform generator for the object, or null to use the current generator</param>
public GraphicsPath (Generator generator = null) public GraphicsPath (Generator generator)
{ {
Handler = Create (generator); Handler = Create (generator);
} }
Expand Down
14 changes: 7 additions & 7 deletions Source/Eto/Drawing/Icon.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Icon (Generator generator, IIcon handler) : base(generator, handler)
/// Initializes a new instance of the Icon class with the contents of the specified <paramref name="stream"/> /// Initializes a new instance of the Icon class with the contents of the specified <paramref name="stream"/>
/// </summary> /// </summary>
/// <param name="stream">Stream to load the content from</param> /// <param name="stream">Stream to load the content from</param>
public Icon (Stream stream) : base(Generator.Current, typeof(IIcon)) public Icon (Stream stream, Generator generator = null) : base(generator, typeof(IIcon))
{ {
Handler.Create (stream); Handler.Create (stream);
} }
Expand All @@ -59,7 +59,7 @@ public Icon (Stream stream) : base(Generator.Current, typeof(IIcon))
/// Intitializes a new instanc of the Icon class with the contents of the specified <paramref name="fileName"/> /// Intitializes a new instanc of the Icon class with the contents of the specified <paramref name="fileName"/>
/// </summary> /// </summary>
/// <param name="fileName">Name of the file to loat the content from</param> /// <param name="fileName">Name of the file to loat the content from</param>
public Icon (string fileName) : base(Generator.Current, typeof(IIcon)) public Icon (string fileName, Generator generator = null) : base(generator, typeof(IIcon))
{ {
Handler.Create (fileName); Handler.Create (fileName);
} }
Expand All @@ -70,14 +70,14 @@ public Icon (string fileName) : base(Generator.Current, typeof(IIcon))
/// <param name="assembly">Assembly to load the resource from</param> /// <param name="assembly">Assembly to load the resource from</param>
/// <param name="resourceName">Fully qualified name of the resource to load</param> /// <param name="resourceName">Fully qualified name of the resource to load</param>
/// <returns>A new instance of an Icon loaded with the contents of the specified resource</returns> /// <returns>A new instance of an Icon loaded with the contents of the specified resource</returns>
public static Icon FromResource (Assembly assembly, string resourceName) public static Icon FromResource (Assembly assembly, string resourceName, Generator generator = null)
{ {
if (assembly == null) if (assembly == null)
assembly = Assembly.GetCallingAssembly (); assembly = Assembly.GetCallingAssembly ();
using (var stream = assembly.GetManifestResourceStream(resourceName)) { using (var stream = assembly.GetManifestResourceStream(resourceName)) {
if (stream == null) if (stream == null)
throw new ResourceNotFoundException (assembly, resourceName); throw new ResourceNotFoundException (assembly, resourceName);
return new Icon (stream); return new Icon (stream, generator);
} }
} }


Expand All @@ -90,17 +90,17 @@ public static Icon FromResource (Assembly assembly, string resourceName)
/// </remarks> /// </remarks>
/// <param name="resourceName">Fully qualified name of the resource to load</param> /// <param name="resourceName">Fully qualified name of the resource to load</param>
/// <returns>A new instance of an Icon loaded with the contents of the specified resource</returns> /// <returns>A new instance of an Icon loaded with the contents of the specified resource</returns>
public static Icon FromResource (string resourceName) public static Icon FromResource (string resourceName, Generator generator = null)
{ {
var asm = Assembly.GetCallingAssembly (); var asm = Assembly.GetCallingAssembly ();
return FromResource (asm, resourceName); return FromResource (asm, resourceName, generator);
} }


/// <summary> /// <summary>
/// Obsolete. Do not use. /// Obsolete. Do not use.
/// </summary> /// </summary>
[Obsolete("Use Icon.FromResource instead")] [Obsolete("Use Icon.FromResource instead")]
public Icon (Assembly asm, string resourceName) : base(Generator.Current, typeof(IIcon)) public Icon (Assembly asm, string resourceName) : base(null, typeof(IIcon))
{ {
if (asm == null) if (asm == null)
asm = Assembly.GetCallingAssembly (); asm = Assembly.GetCallingAssembly ();
Expand Down
4 changes: 2 additions & 2 deletions Source/Eto/Drawing/IndexedBitmap.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public class IndexedBitmap : Image
/// <param name="width">Width of the bitmap in pixels</param> /// <param name="width">Width of the bitmap in pixels</param>
/// <param name="height">Height of the bitmap in pixels</param> /// <param name="height">Height of the bitmap in pixels</param>
/// <param name="bitsPerPixel">Number of bits per pixel, usually 4 (16 colours), 8 (64 colours), or 8 (256 colours)</param> /// <param name="bitsPerPixel">Number of bits per pixel, usually 4 (16 colours), 8 (64 colours), or 8 (256 colours)</param>
public IndexedBitmap (int width, int height, int bitsPerPixel) public IndexedBitmap (int width, int height, int bitsPerPixel, Generator generator = null)
: this(Generator.Current, width, height, bitsPerPixel) : this(generator, width, height, bitsPerPixel)
{ {
} }


Expand Down
4 changes: 2 additions & 2 deletions Source/Eto/Drawing/Region.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class Region : InstanceWidget
/// <summary> /// <summary>
/// Initializes a new instance of the Region class /// Initializes a new instance of the Region class
/// </summary> /// </summary>
public Region () public Region()
: this (Generator.Current) : this((Generator)null)
{ {
} }


Expand Down
6 changes: 3 additions & 3 deletions Source/Eto/Forms/Actions/ActionCollection.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public class ActionCollection : KeyedCollection<string, BaseAction>
{ {
readonly Generator generator; readonly Generator generator;


public ActionCollection () public ActionCollection()
: this(Generator.Current) : this((Generator)null)
{ {
} }

public ActionCollection (Generator generator) public ActionCollection (Generator generator)
: this(generator, null) : this(generator, null)
{ {
Expand Down
2 changes: 1 addition & 1 deletion Source/Eto/Forms/Actions/RadioAction.desktop.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial class RadioAction


public override MenuItem GenerateMenuItem(Generator generator) public override MenuItem GenerateMenuItem(Generator generator)
{ {
var mi = new RadioMenuItem(generator, (Controller != null) ? Controller.menuItem : null); var mi = new RadioMenuItem((Controller != null) ? Controller.menuItem : null, generator);
mi.Text = MenuText; mi.Text = MenuText;
mi.Shortcut = Accelerator; mi.Shortcut = Accelerator;
mi.Enabled = Enabled; mi.Enabled = Enabled;
Expand Down
10 changes: 5 additions & 5 deletions Source/Eto/Forms/Cells/CheckBoxCell.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public CheckBoxCell (string property)
Binding = new PropertyBinding (property); Binding = new PropertyBinding (property);
} }


public CheckBoxCell () public CheckBoxCell()
: this(Generator.Current) : this((Generator)null)
{ {
} }

public CheckBoxCell (Generator g) public CheckBoxCell (Generator generator)
: base(g, typeof(ICheckBoxCell), true) : base(generator, typeof(ICheckBoxCell), true)
{ {
} }
} }
Expand Down
6 changes: 3 additions & 3 deletions Source/Eto/Forms/Cells/ComboBoxCell.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public ComboBoxCell (string property)
{ {
Binding = new PropertyBinding (property); Binding = new PropertyBinding (property);
} }

public ComboBoxCell () public ComboBoxCell()
: this (Generator.Current) : this((Generator)null)
{ {
} }


Expand Down
8 changes: 4 additions & 4 deletions Source/Eto/Forms/Cells/DrawableCell.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public class DrawableCell : Cell
{ {
public Action<DrawableCellPaintArgs> PaintHandler { get; set; } public Action<DrawableCellPaintArgs> PaintHandler { get; set; }


public DrawableCell () public DrawableCell()
: this(Generator.Current) : this((Generator)null)
{ {
} }


public DrawableCell(Generator g) public DrawableCell(Generator generator)
: base(g, typeof(IDrawableCell), true) : base(generator, typeof(IDrawableCell), true)
{ {
} }
} }
Expand Down
10 changes: 5 additions & 5 deletions Source/Eto/Forms/Cells/ImageTextCell.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public ImageTextCell (string imageProperty, string textProperty)
TextBinding = new PropertyBinding(textProperty); TextBinding = new PropertyBinding(textProperty);
} }


public ImageTextCell () public ImageTextCell()
: this(Generator.Current) : this((Generator)null)
{ {
} }

public ImageTextCell (Generator g) public ImageTextCell (Generator generator)
: base(g, typeof(IImageTextCell), true) : base(generator, typeof(IImageTextCell), true)
{ {
} }
} }
Expand Down
10 changes: 5 additions & 5 deletions Source/Eto/Forms/Cells/ImageViewCell.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public ImageViewCell (string property)
Binding = new PropertyBinding (property); Binding = new PropertyBinding (property);
} }


public ImageViewCell () public ImageViewCell()
: this(Generator.Current) : this((Generator)null)
{ {
} }

public ImageViewCell (Generator g) public ImageViewCell (Generator generator)
: base(g, typeof(IImageViewCell), true) : base(generator, typeof(IImageViewCell), true)
{ {
} }
} }
Expand Down
10 changes: 5 additions & 5 deletions Source/Eto/Forms/Cells/TextBoxCell.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public TextBoxCell (string property)
Binding = new PropertyBinding (property); Binding = new PropertyBinding (property);
} }


public TextBoxCell () public TextBoxCell()
: this(Generator.Current) : this((Generator)null)
{ {
} }

public TextBoxCell (Generator g) public TextBoxCell (Generator generator)
: base(g, typeof(ITextBoxCell), true) : base(generator, typeof(ITextBoxCell), true)
{ {
} }
} }
Expand Down
6 changes: 3 additions & 3 deletions Source/Eto/Forms/Clipboard.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public class Clipboard : InstanceWidget
{ {
new IClipboard Handler { get { return (IClipboard)base.Handler; } } new IClipboard Handler { get { return (IClipboard)base.Handler; } }


public Clipboard () public Clipboard()
: this(Generator.Current) : this((Generator)null)
{ {
} }

public Clipboard (Generator generator) public Clipboard (Generator generator)
: base(generator, typeof(IClipboard)) : base(generator, typeof(IClipboard))
{ {
Expand Down
10 changes: 5 additions & 5 deletions Source/Eto/Forms/ColorDialog.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public virtual void OnColorChanged (EventArgs e)
ColorChanged (this, e); ColorChanged (this, e);
} }


public ColorDialog () public ColorDialog()
: this (Generator.Current) : this((Generator)null)
{ {
} }

public ColorDialog (Generator g) public ColorDialog (Generator generator)
: this (g, typeof(IColorDialog)) : this (generator, typeof(IColorDialog))
{ {
} }


Expand Down
9 changes: 5 additions & 4 deletions Source/Eto/Forms/Controls/CheckBox.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ public virtual void OnCheckedChanged(EventArgs e)
Properties.TriggerEvent(CheckedChangedKey, this, e); Properties.TriggerEvent(CheckedChangedKey, this, e);
} }


public CheckBox() : this(Generator.Current) public CheckBox()
: this((Generator)null)
{ {
} }


public CheckBox(Generator g) : this(g, typeof(ICheckBox)) public CheckBox(Generator generator) : this(generator, typeof(ICheckBox))
{ {
} }


protected CheckBox(Generator g, Type type, bool initialize = true) protected CheckBox(Generator generator, Type type, bool initialize = true)
: base(g, type, initialize) : base(generator, type, initialize)
{ {
} }


Expand Down
14 changes: 8 additions & 6 deletions Source/Eto/Forms/Controls/ComboBox.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ namespace Eto.Forms
public interface IComboBox : IListControl public interface IComboBox : IListControl
{ {
} }

public class ComboBox : ListControl public class ComboBox : ListControl
{ {
public ComboBox () : this (Generator.Current) public ComboBox()
: this((Generator)null)
{ {
} }


public ComboBox (Generator g) : this (g, typeof(IComboBox)) public ComboBox(Generator generator)
: this(generator, typeof(IComboBox))
{ {
} }

protected ComboBox (Generator g, Type type, bool initialize = true) protected ComboBox(Generator generator, Type type, bool initialize = true)
: base (g, type, initialize) : base(generator, type, initialize)
{ {
} }
} }
Expand Down
6 changes: 3 additions & 3 deletions Source/Eto/Forms/Controls/DateTimePicker.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public virtual void OnValueChanged (EventArgs e)
ValueChanged (this, e); ValueChanged (this, e);
} }


public DateTimePicker () public DateTimePicker()
: this (Generator.Current) : this((Generator)null)
{ {
} }

public DateTimePicker (Generator generator) public DateTimePicker (Generator generator)
: this (generator, typeof(IDateTimePicker)) : this (generator, typeof(IDateTimePicker))
{ {
Expand Down
2 changes: 1 addition & 1 deletion Source/Eto/Forms/Controls/Drawable.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public partial class Drawable : DockContainer
public event EventHandler<PaintEventArgs> Paint; public event EventHandler<PaintEventArgs> Paint;


public Drawable() public Drawable()
: this(Generator.Current) : this((Generator)null)
{ {
} }


Expand Down
4 changes: 2 additions & 2 deletions Source/Eto/Forms/Controls/Drawable.mobile.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public partial interface IDrawable
public partial class Drawable public partial class Drawable
{ {
public Drawable (bool largeCanvas) public Drawable (bool largeCanvas)
: this(Generator.Current, largeCanvas) : this(null, largeCanvas)
{ {
} }


public Drawable (Generator g, bool largeCanvas) : base(g, typeof(IDrawable)) public Drawable (Generator generator, bool largeCanvas) : base(generator, typeof(IDrawable))
{ {
Handler.Create (largeCanvas); Handler.Create (largeCanvas);
} }
Expand Down
6 changes: 3 additions & 3 deletions Source/Eto/Forms/Controls/EnumComboBox.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ protected virtual void OnAddValue (AddValueEventArgs<T> e)
/// <summary> /// <summary>
/// Initializes a new instance of the EnumComboBox /// Initializes a new instance of the EnumComboBox
/// </summary> /// </summary>
public EnumComboBox () public EnumComboBox()
: this (Generator.Current) : this((Generator)null)
{ {
} }


/// <summary> /// <summary>
/// Initializes a new instance of the EnumComboBox with the specified generator /// Initializes a new instance of the EnumComboBox with the specified generator
/// </summary> /// </summary>
/// <param name="generator">platform generator</param> /// <param name="generator">platform generator</param>
protected EnumComboBox (Generator generator) public EnumComboBox (Generator generator)
: base (generator) : base (generator)
{ {
} }
Expand Down
Loading

0 comments on commit 5d7701d

Please sign in to comment.