Skip to content

Commit

Permalink
Progres bar for all platforms.
Browse files Browse the repository at this point in the history
Slight tweak to remove the private events in Window.
  • Loading branch information
carlokok committed Feb 28, 2012
1 parent e680a5c commit f59958e
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 3 deletions.
1 change: 1 addition & 0 deletions Source/Eto.Platform.Gtk/Eto.Platform.Gtk.csproj
Expand Up @@ -111,6 +111,7 @@
<ItemGroup>
<Compile Include="Forms\Controls\ComboBoxCellHandler.cs" />
<Compile Include="Forms\Controls\PasswordBoxHandler.cs" />
<Compile Include="Forms\Controls\ProgressBarHandler.cs" />
<Compile Include="Generator.cs">
<SubType>Code</SubType>
</Compile>
Expand Down
31 changes: 31 additions & 0 deletions Source/Eto.Platform.Gtk/Forms/Controls/ProgressBarHandler.cs
@@ -0,0 +1,31 @@
using System;
using Eto.Forms;

namespace Eto.Platform.GtkSharp.Forms.Controls
{
public class ProgressBarHandler : GtkControl<Gtk.ProgressBar, ProgressBar>, IProgressBar
{
public ProgressBarHandler()
{
this.Control = new Gtk.ProgressBar ();
MinValue = 0;
MaxValue = 100;
this.Control.Fraction = 0;
}


public int MaxValue { get; set; }

public int MinValue { get;set; }

public int Value {
get {
return (int)((Control.Fraction * MaxValue) + MinValue);
}
set {
Control.Fraction = ((double)value - MinValue) / (double)MaxValue;
}
}
}
}

1 change: 1 addition & 0 deletions Source/Eto.Platform.Mac/Eto.Platform.Mac.csproj
Expand Up @@ -68,6 +68,7 @@
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Forms\Controls\PasswordBoxHandler.cs" />
<Compile Include="Forms\Controls\ProgressBarHandler.cs" />
<Compile Include="Generator.cs">
<SubType>Code</SubType>
</Compile>
Expand Down
57 changes: 57 additions & 0 deletions Source/Eto.Platform.Mac/Forms/Controls/ProgressBarHandler.cs
@@ -0,0 +1,57 @@
using System;
using MonoMac.AppKit;
using Eto.Forms;
using Eto.Drawing;

namespace Eto.Platform.Mac.Forms.Controls
{
public class ProgressBarHandler : MacView<NSProgressIndicator, ProgressBar>, IProgressBar
{
public class EtoSlider : NSProgressIndicator, IMacControl
{
public object Handler { get; set; }

}

public ProgressBarHandler ()
{
Control = new EtoSlider { Handler = this };

MinValue = 0;
MaxValue = 100;
}

protected override Size GetNaturalSize()
{
return new Size(80, 30);
}


public override bool Enabled
{
get { return true; }
set { }
}


public int MaxValue {
get { return (int)Control.MaxValue; }
set {
Control.MaxValue = value;
}
}

public int MinValue {
get { return (int)Control.MinValue; }
set {
Control.MinValue = value;
}
}

public int Value {
get { return (int)Control.DoubleValue; }
set { Control.DoubleValue = value; }
}
}
}

1 change: 1 addition & 0 deletions Source/Eto.Platform.Windows/Eto.Platform.Windows.csproj
Expand Up @@ -114,6 +114,7 @@
</Compile>
<Compile Include="Forms\Controls\ComboBoxCellHandler.cs" />
<Compile Include="Forms\Controls\PasswordBoxHandler.cs" />
<Compile Include="Forms\Controls\ProgressBarHandler.cs" />
<Compile Include="Generator.cs">
<SubType>Code</SubType>
</Compile>
Expand Down
38 changes: 38 additions & 0 deletions Source/Eto.Platform.Windows/Forms/Controls/ProgressBarHandler.cs
@@ -0,0 +1,38 @@
using System;
using SWF = System.Windows.Forms;
using Eto.Forms;

namespace Eto.Platform.Windows.Forms.Controls
{
public class ProgressBarHandler : WindowsControl<SWF.ProgressBar, ProgressBar>, IProgressBar
{

public ProgressBarHandler()
{
this.Control = new SWF.ProgressBar {
Maximum = 100
};
}

public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}

public int MaxValue {
get { return this.Control.Maximum; }
set { this.Control.Maximum = value; }
}

public int MinValue {
get { return this.Control.Minimum; }
set { this.Control.Minimum = value; }
}

public int Value {
get { return this.Control.Value; }
set { this.Control.Value = value; }
}
}
}

1 change: 1 addition & 0 deletions Source/Eto.Platform.Wpf/Eto.Platform.Wpf.csproj
Expand Up @@ -117,6 +117,7 @@
<Compile Include="Forms\Controls\NumericUpDownHandler.cs" />
<Compile Include="Forms\Controls\PanelHandler.cs" />
<Compile Include="Forms\Controls\PasswordBoxHandler.cs" />
<Compile Include="Forms\Controls\ProgressBarHandler.cs" />
<Compile Include="Forms\Controls\RadioButtonHandler.cs" />
<Compile Include="Forms\Controls\ScrollableHandler.cs" />
<Compile Include="Forms\Controls\SliderHandler.cs" />
Expand Down
39 changes: 39 additions & 0 deletions Source/Eto.Platform.Wpf/Forms/Controls/ProgressBarHandler.cs
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using swc = System.Windows.Controls;
using Eto.Forms;

namespace Eto.Platform.Wpf.Forms.Controls
{
public class ProgressBarHandler : WpfControl<swc.ProgressBar, ProgressBar>, IProgressBar
{
public ProgressBarHandler()
{
Control = new swc.ProgressBar {
Minimum = 0,
Maximum = 100
};
}

public int MaxValue
{
get { return (int)Control.Maximum; }
set { Control.Maximum = value; }
}

public int MinValue
{
get { return (int)Control.Minimum; }
set { Control.Minimum = value; }
}

public int Value
{
get { return (int)Control.Value; }
set { Control.Value = value; }
}

}
}
3 changes: 2 additions & 1 deletion Source/Eto/Eto.csproj
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
Expand Down Expand Up @@ -110,6 +110,7 @@
<Compile Include="Forms\Controls\GridColumnCollection.cs" />
<Compile Include="Forms\Controls\ImageCell.cs" />
<Compile Include="Forms\Controls\PasswordBox.cs" />
<Compile Include="Forms\Controls\ProgressBar.cs" />
<Compile Include="Forms\Controls\TextCell.cs" />
<Compile Include="Forms\DataStoreVirtualCollection.cs" />
<Compile Include="Forms\Layout\DynamicControl.cs" />
Expand Down
48 changes: 48 additions & 0 deletions Source/Eto/Forms/Controls/ProgressBar.cs
@@ -0,0 +1,48 @@
using System;

namespace Eto.Forms
{

public interface IProgressBar : IControl
{
int MaxValue { get; set; }

int MinValue { get; set; }

int Value { get; set; }
}

public class ProgressBar : Control
{
IProgressBar inner;

public ProgressBar ()
: this(Generator.Current)
{
}

public ProgressBar(Generator generator)
: base(generator, typeof(IProgressBar), true)
{
inner = (IProgressBar)Handler;
}


public int MaxValue {
get { return inner.MaxValue; }
set { inner.MaxValue = value; }
}

public int MinValue {
get { return inner.MinValue; }
set { inner.MinValue = value; }
}

public int Value {
get { return inner.Value; }
set { inner.Value = value; }
}

}
}

4 changes: 2 additions & 2 deletions Source/Eto/Forms/Window.cs
Expand Up @@ -29,7 +29,7 @@ public abstract partial class Window : Container

public const string ClosedEvent = "Window.Closed";

event EventHandler<EventArgs> closed;
EventHandler<EventArgs> closed;

public event EventHandler<EventArgs> Closed {
add {
Expand All @@ -48,7 +48,7 @@ public virtual void OnClosed (EventArgs e)

public const string ClosingEvent = "Window.Closing";

event EventHandler<CancelEventArgs> closing;
EventHandler<CancelEventArgs> closing;

public event EventHandler<CancelEventArgs> Closing {
add {
Expand Down

0 comments on commit f59958e

Please sign in to comment.