diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.Library/Eto.Library.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.Library/Eto.Library.vstemplate index 94c84373db..4a827f5dd5 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.Library/Eto.Library.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.Library/Eto.Library.vstemplate @@ -26,7 +26,7 @@ - + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Combined/Eto.Desktop/Eto.Desktop.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Combined/Eto.Desktop/Eto.Desktop.vstemplate index 716bf642f1..09320a0a0f 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Combined/Eto.Desktop/Eto.Desktop.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Combined/Eto.Desktop/Eto.Desktop.vstemplate @@ -25,13 +25,13 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Combined/Eto/Eto.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Combined/Eto/Eto.vstemplate index 2c25f89b89..3e98995d26 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Combined/Eto/Eto.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Combined/Eto/Eto.vstemplate @@ -26,7 +26,7 @@ - + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Gtk2/Eto.Gtk2.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Gtk2/Eto.Gtk2.vstemplate index b2dd77d952..1ad9c14bae 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Gtk2/Eto.Gtk2.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Gtk2/Eto.Gtk2.vstemplate @@ -25,8 +25,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Gtk3/Eto.Gtk3.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Gtk3/Eto.Gtk3.vstemplate index 4ce0e8d743..7b108e80c8 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Gtk3/Eto.Gtk3.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Gtk3/Eto.Gtk3.vstemplate @@ -25,8 +25,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Mac/Eto.Mac.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Mac/Eto.Mac.vstemplate index 421d37f239..c09bd23239 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Mac/Eto.Mac.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Mac/Eto.Mac.vstemplate @@ -25,9 +25,9 @@ - - - + + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.WinForms/Eto.WinForms.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.WinForms/Eto.WinForms.vstemplate index 88caaac0f8..836bcbe5d7 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.WinForms/Eto.WinForms.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.WinForms/Eto.WinForms.vstemplate @@ -25,8 +25,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Wpf/Eto.Wpf.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Wpf/Eto.Wpf.vstemplate index 8a06a0de99..d3020c483e 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Wpf/Eto.Wpf.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.Wpf/Eto.Wpf.vstemplate @@ -25,8 +25,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.XamMac2/Eto.XamMac2.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.XamMac2/Eto.XamMac2.vstemplate index b2c13c5238..cab6c6d2ce 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.XamMac2/Eto.XamMac2.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto.XamMac2/Eto.XamMac2.vstemplate @@ -26,8 +26,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto/Eto.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto/Eto.vstemplate index 2c25f89b89..3e98995d26 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto/Eto.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.PCL.Separate/Eto/Eto.vstemplate @@ -26,7 +26,7 @@ - + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Combined/Eto.Desktop/Eto.Desktop.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Combined/Eto.Desktop/Eto.Desktop.vstemplate index 716bf642f1..09320a0a0f 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Combined/Eto.Desktop/Eto.Desktop.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Combined/Eto.Desktop/Eto.Desktop.vstemplate @@ -25,13 +25,13 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Gtk2/Eto.Gtk2.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Gtk2/Eto.Gtk2.vstemplate index b2dd77d952..1ad9c14bae 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Gtk2/Eto.Gtk2.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Gtk2/Eto.Gtk2.vstemplate @@ -25,8 +25,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Gtk3/Eto.Gtk3.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Gtk3/Eto.Gtk3.vstemplate index 4ce0e8d743..7b108e80c8 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Gtk3/Eto.Gtk3.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Gtk3/Eto.Gtk3.vstemplate @@ -25,8 +25,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Mac/Eto.Mac.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Mac/Eto.Mac.vstemplate index 421d37f239..c09bd23239 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Mac/Eto.Mac.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Mac/Eto.Mac.vstemplate @@ -25,9 +25,9 @@ - - - + + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.WinForms/Eto.WinForms.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.WinForms/Eto.WinForms.vstemplate index 88caaac0f8..836bcbe5d7 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.WinForms/Eto.WinForms.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.WinForms/Eto.WinForms.vstemplate @@ -25,8 +25,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Wpf/Eto.Wpf.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Wpf/Eto.Wpf.vstemplate index 8a06a0de99..d3020c483e 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Wpf/Eto.Wpf.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.Wpf/Eto.Wpf.vstemplate @@ -25,8 +25,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.XamMac2/Eto.XamMac2.vstemplate b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.XamMac2/Eto.XamMac2.vstemplate index b2c13c5238..cab6c6d2ce 100644 --- a/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.XamMac2/Eto.XamMac2.vstemplate +++ b/Source/Addins/Eto.Addin.VisualStudio/Eto.SAL.Separate/Eto.XamMac2/Eto.XamMac2.vstemplate @@ -26,8 +26,8 @@ - - + + \ No newline at end of file diff --git a/Source/Addins/Eto.Addin.XamarinStudio/Eto.Addin.XamarinStudio.csproj b/Source/Addins/Eto.Addin.XamarinStudio/Eto.Addin.XamarinStudio.csproj index 45b33bea9c..a7c6c9d826 100644 --- a/Source/Addins/Eto.Addin.XamarinStudio/Eto.Addin.XamarinStudio.csproj +++ b/Source/Addins/Eto.Addin.XamarinStudio/Eto.Addin.XamarinStudio.csproj @@ -112,68 +112,68 @@ PreserveNewest - - Packages\Eto.Forms.2.0.3.nupkg + + Packages\Eto.Forms.2.0.5.nupkg PreserveNewest - - Packages\Eto.Forms.Sample.2.0.3.nupkg + + Packages\Eto.Forms.Sample.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.Direct2D.2.0.3.nupkg + + Packages\Eto.Platform.Direct2D.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.Gtk.2.0.3.nupkg + + Packages\Eto.Platform.Gtk.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.Gtk3.2.0.3.nupkg + + Packages\Eto.Platform.Gtk3.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.iOS.2.0.3.nupkg + + Packages\Eto.Platform.iOS.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.Mac.2.0.3.nupkg + + Packages\Eto.Platform.Mac.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.Mac.Template.2.0.3.nupkg + + Packages\Eto.Platform.Mac.Template.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.Mac64.2.0.3.nupkg + + Packages\Eto.Platform.Mac64.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.Windows.2.0.3.nupkg + + Packages\Eto.Platform.Windows.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.WinRT.2.0.3.nupkg + + Packages\Eto.Platform.WinRT.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.Wpf.2.0.3.nupkg + + Packages\Eto.Platform.Wpf.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.XamMac.2.0.3.nupkg + + Packages\Eto.Platform.XamMac.2.0.5.nupkg PreserveNewest - - Packages\Eto.Platform.XamMac2.2.0.3.nupkg + + Packages\Eto.Platform.XamMac2.2.0.5.nupkg PreserveNewest - - Packages\Eto.Serialization.Json.2.0.3.nupkg + + Packages\Eto.Serialization.Json.2.0.5.nupkg PreserveNewest - - Packages\Eto.Serialization.Xaml.2.0.3.nupkg + + Packages\Eto.Serialization.Xaml.2.0.5.nupkg PreserveNewest diff --git a/Source/Eto.Gtk/Forms/GtkFileDialog.cs b/Source/Eto.Gtk/Forms/GtkFileDialog.cs index 5b3bab7b63..c33caed38e 100644 --- a/Source/Eto.Gtk/Forms/GtkFileDialog.cs +++ b/Source/Eto.Gtk/Forms/GtkFileDialog.cs @@ -21,6 +21,7 @@ public string FileName { Control.SetCurrentFolder(Path.GetDirectoryName(value)); Control.SetFilename(value); + Control.CurrentName = Path.GetFileName(value); } } diff --git a/Source/Eto.Mac/Forms/Controls/DrawableHandler.cs b/Source/Eto.Mac/Forms/Controls/DrawableHandler.cs index 70dec7efae..8a1abda167 100644 --- a/Source/Eto.Mac/Forms/Controls/DrawableHandler.cs +++ b/Source/Eto.Mac/Forms/Controls/DrawableHandler.cs @@ -44,9 +44,9 @@ public class DrawableHandler : MacPanel 0f) dirtyRect.Height += 1; ApplicationHandler.QueueResizing = true; - drawable.Update(Rectangle.Ceiling(dirtyRect.ToEto())); + drawable.DrawRegion(Rectangle.Ceiling(dirtyRect.ToEto())); ApplicationHandler.QueueResizing = false; } @@ -128,7 +128,7 @@ public override void Invalidate(Rectangle rect) base.Invalidate(rect); } - public void Update(Rectangle rect) + void DrawRegion(Rectangle rect) { var context = NSGraphicsContext.CurrentContext; if (context != null) @@ -145,5 +145,10 @@ public void Update(Rectangle rect) } } } + + public void Update(Rectangle rect) + { + Control.DisplayRect(rect.ToSDRectangleF()); + } } } diff --git a/Source/Eto.Test/Eto.Test/Sections/Controls/TabControlSection.cs b/Source/Eto.Test/Eto.Test/Sections/Controls/TabControlSection.cs index dbfdcb9adf..e78fd3173d 100644 --- a/Source/Eto.Test/Eto.Test/Sections/Controls/TabControlSection.cs +++ b/Source/Eto.Test/Eto.Test/Sections/Controls/TabControlSection.cs @@ -11,8 +11,8 @@ public class TabControlSection : Panel protected override void OnPreLoad(EventArgs e) { - base.OnPreLoad(e); Content = Create(); + base.OnPreLoad(e); } public virtual Control Create() diff --git a/Source/Eto.WinForms/Forms/Controls/WebViewHandler.cs b/Source/Eto.WinForms/Forms/Controls/WebViewHandler.cs index 568b149cf7..dcb44ef721 100644 --- a/Source/Eto.WinForms/Forms/Controls/WebViewHandler.cs +++ b/Source/Eto.WinForms/Forms/Controls/WebViewHandler.cs @@ -1,5 +1,7 @@ using System; -using SWF = System.Windows.Forms; +using System.Linq; +using SHDocVw; +using swf = System.Windows.Forms; using Eto.Forms; using Eto.CustomControls; using System.Runtime.InteropServices; @@ -7,7 +9,7 @@ namespace Eto.WinForms.Forms.Controls { - public class WebViewHandler : WindowsControl, WebView.IHandler + public class WebViewHandler : WindowsControl, WebView.IHandler { [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("6d5140c1-7436-11ce-8034-00aa006009fa")] @@ -17,14 +19,14 @@ internal interface IServiceProvider object QueryService(ref Guid guidService, ref Guid riid); } - HashSet delayedEvents = new HashSet(); + readonly HashSet delayedEvents = new HashSet(); - SHDocVw.WebBrowser_V1 WebBrowserV1 + WebBrowser_V1 WebBrowserV1 { - get { return (SHDocVw.WebBrowser_V1)Control.ActiveXInstance; } + get { return (WebBrowser_V1)Control.ActiveXInstance; } } - public void AttachEvent(SHDocVw.WebBrowser_V1 control, string handler) + public void AttachEvent(WebBrowser_V1 control, string handler) { switch (handler) { @@ -34,26 +36,50 @@ public void AttachEvent(SHDocVw.WebBrowser_V1 control, string handler) } } + static readonly string[] ValidInputTags = { "input", "textarea" }; + public WebViewHandler() { - this.Control = new SWF.WebBrowser + Control = new swf.WebBrowser { IsWebBrowserContextMenuEnabled = false, WebBrowserShortcutsEnabled = false, AllowWebBrowserDrop = false, ScriptErrorsSuppressed = true }; - this.Control.HandleCreated += (sender, e) => + Control.HandleCreated += (sender, e) => HookDocumentEvents(); + Control.PreviewKeyDown += (sender, args) => { - HookDocumentEvents(); + var doc = Control.Document; + if (!Control.WebBrowserShortcutsEnabled && doc != null) + { + // implement shortcut keys for copy/paste + switch (args.KeyData) + { + case (swf.Keys.C | swf.Keys.Control): + doc.ExecCommand("Copy", false, null); + break; + case (swf.Keys.V | swf.Keys.Control): + if (doc.ActiveElement != null && ValidInputTags.Contains(doc.ActiveElement.TagName.ToLowerInvariant())) + doc.ExecCommand("Paste", false, null); + break; + case (swf.Keys.X | swf.Keys.Control): + if (doc.ActiveElement != null && ValidInputTags.Contains(doc.ActiveElement.TagName.ToLowerInvariant())) + doc.ExecCommand("Cut", false, null); + break; + case (swf.Keys.A | swf.Keys.Control): + doc.ExecCommand("SelectAll", false, null); + break; + } + } }; } - void WebBrowserV1_NewWindow(string URL, int Flags, string TargetFrameName, ref object PostData, string Headers, ref bool Processed) + void WebBrowserV1_NewWindow(string url, int flags, string targetFrameName, ref object postData, string headers, ref bool processed) { - var e = new WebViewNewWindowEventArgs(new Uri(URL), TargetFrameName); + var e = new WebViewNewWindowEventArgs(new Uri(url), targetFrameName); Callback.OnOpenNewWindow(Widget, e); - Processed = e.Cancel; + processed = e.Cancel; } public override void AttachEvent(string handler) @@ -163,7 +189,7 @@ public void LoadHtml(string html, Uri baseUri) { if (server == null) server = new HttpServer(); - server.SetHtml(html, baseUri != null ? baseUri.LocalPath : null); + server.SetHtml(html, baseUri.LocalPath); Control.Navigate(server.Url); } else diff --git a/Source/Eto.Wpf/Forms/Controls/ColorPickerHandler.cs b/Source/Eto.Wpf/Forms/Controls/ColorPickerHandler.cs index 699f338f7f..88df6f3b8c 100644 --- a/Source/Eto.Wpf/Forms/Controls/ColorPickerHandler.cs +++ b/Source/Eto.Wpf/Forms/Controls/ColorPickerHandler.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Eto.Drawing; using xwt = Xceed.Wpf.Toolkit; using swc = System.Windows.Controls; using Eto.Forms; @@ -10,9 +11,13 @@ namespace Eto.Wpf.Forms.Controls { public class ColorPickerHandler : WpfControl, ColorPicker.IHandler { + protected override Size DefaultSize { get { return new Size(60, -1); } } + + protected override bool PreventUserResize { get { return true; } } + public ColorPickerHandler() { - Control = new xwt.ColorPicker { Focusable = true, IsTabStop = true, MaxWidth = 60 }; + Control = new xwt.ColorPicker { Focusable = true, IsTabStop = true }; } public override void AttachEvent(string id) diff --git a/Source/Eto.Wpf/Forms/Controls/ComboBoxHandler.cs b/Source/Eto.Wpf/Forms/Controls/ComboBoxHandler.cs index c2187d1fd3..1962e192df 100644 --- a/Source/Eto.Wpf/Forms/Controls/ComboBoxHandler.cs +++ b/Source/Eto.Wpf/Forms/Controls/ComboBoxHandler.cs @@ -12,9 +12,12 @@ public class ComboBoxHandler : DropDownHandler HandleTextChanged())); @@ -88,15 +91,6 @@ public override void AttachEvent(string id) } } - protected override Size DefaultSize - { - get - { - var size = base.DefaultSize; - return new Size(100, size.Height); - } - } - public string Text { get { return Control.Text; } diff --git a/Source/Eto.Wpf/Forms/Controls/DateTimePickerHandler.cs b/Source/Eto.Wpf/Forms/Controls/DateTimePickerHandler.cs index da066a321f..ca6939531b 100644 --- a/Source/Eto.Wpf/Forms/Controls/DateTimePickerHandler.cs +++ b/Source/Eto.Wpf/Forms/Controls/DateTimePickerHandler.cs @@ -13,10 +13,7 @@ public class DateTimePickerHandler : WpfControl, NumericUpDown.IHandler { - public class EtoDoubleUpDown : mwc.DoubleUpDown - { - protected override sw.Size MeasureOverride(sw.Size constraint) - { - if (IsLoaded && IsVisible) - { - constraint.Width = !double.IsNaN(constraint.Width) ? Math.Min(constraint.Width, ActualWidth) : ActualWidth; - } - return base.MeasureOverride(constraint); - } - } + protected override Size DefaultSize { get { return new Size(80, -1); } } - protected override Size DefaultSize - { - get { return new Size(80, base.DefaultSize.Height); } - } + protected override bool PreventUserResize { get { return true; } } public NumericUpDownHandler() { - Control = new EtoDoubleUpDown(); + Control = new mwc.DoubleUpDown(); Control.ValueChanged += (sender, e) => Callback.OnValueChanged(Widget, EventArgs.Empty); DecimalPlaces = 0; } diff --git a/Source/Eto.Wpf/Forms/Controls/PasswordBoxHandler.cs b/Source/Eto.Wpf/Forms/Controls/PasswordBoxHandler.cs index 7d4942059f..d37f4f72b6 100644 --- a/Source/Eto.Wpf/Forms/Controls/PasswordBoxHandler.cs +++ b/Source/Eto.Wpf/Forms/Controls/PasswordBoxHandler.cs @@ -10,16 +10,13 @@ public class PasswordBoxHandler : WpfControl + { + var doc = Browser.Document; + if (!Browser.WebBrowserShortcutsEnabled && doc != null) + { + // implement shortcut keys for copy/paste + switch (args.KeyData) + { + case (swf.Keys.C | swf.Keys.Control): + doc.ExecCommand("Copy", false, null); + break; + case (swf.Keys.V | swf.Keys.Control): + if (doc.ActiveElement != null && ValidInputTags.Contains(doc.ActiveElement.TagName.ToLowerInvariant())) + doc.ExecCommand("Paste", false, null); + break; + case (swf.Keys.X | swf.Keys.Control): + if (doc.ActiveElement != null && ValidInputTags.Contains(doc.ActiveElement.TagName.ToLowerInvariant())) + doc.ExecCommand("Cut", false, null); + break; + case (swf.Keys.A | swf.Keys.Control): + doc.ExecCommand("SelectAll", false, null); + break; + } + } + }; } void WebBrowserV1_NewWindow(string URL, int Flags, string TargetFrameName, ref object PostData, string Headers, ref bool Processed) diff --git a/Source/Eto.Wpf/Forms/Controls/TextAreaHandler.cs b/Source/Eto.Wpf/Forms/Controls/TextAreaHandler.cs index 184557120a..46120ebfac 100644 --- a/Source/Eto.Wpf/Forms/Controls/TextAreaHandler.cs +++ b/Source/Eto.Wpf/Forms/Controls/TextAreaHandler.cs @@ -10,27 +10,15 @@ public class TextAreaHandler : WpfControl, TextBox.IHandler { bool textChanging; + protected override Size DefaultSize { get { return new Size(80, -1); } } - class EtoWatermarkTextBox : mwc.WatermarkTextBox - { - protected override sw.Size MeasureOverride(sw.Size constraint) - { - if (IsLoaded && IsVisible) - { - constraint.Width = !double.IsNaN(constraint.Width) ? Math.Min(constraint.Width, ActualWidth) : ActualWidth; - } - return base.MeasureOverride(constraint); - } - } + protected override bool PreventUserResize { get { return true; } } public TextBoxHandler () { - Control = new EtoWatermarkTextBox(); + Control = new mwc.WatermarkTextBox(); Control.GotKeyboardFocus += Control_GotKeyboardFocus; } diff --git a/Source/Eto.Wpf/Forms/TableLayoutHandler.cs b/Source/Eto.Wpf/Forms/TableLayoutHandler.cs index 4ccea18ddb..f2be7a2b41 100644 --- a/Source/Eto.Wpf/Forms/TableLayoutHandler.cs +++ b/Source/Eto.Wpf/Forms/TableLayoutHandler.cs @@ -45,6 +45,8 @@ public override Color BackgroundColor public override sw.Size GetPreferredSize(sw.Size constraint) { + if (columnScale == null || rowScale == null) + return base.GetPreferredSize(constraint); var widths = new double[columnScale.Length]; double height = 0; for (int y = 0; y < rowScale.Length; y++) @@ -88,13 +90,7 @@ public void CreateControl(int cols, int rows) border.Child = Control; - Control.SizeChanged += Control_SizeChanged; - Control.Loaded += Control_SizeChanged; - } - - void Control_SizeChanged(object sender, EventArgs e) - { - SetChildrenSizes(); + Control.LayoutUpdated += (sender, args) => SetChildrenSizes(); } sw.FrameworkElement EmptyCell(int x, int y) diff --git a/Source/Eto.Wpf/Forms/WpfFrameworkElement.cs b/Source/Eto.Wpf/Forms/WpfFrameworkElement.cs index e62675bcf0..b1747700f4 100644 --- a/Source/Eto.Wpf/Forms/WpfFrameworkElement.cs +++ b/Source/Eto.Wpf/Forms/WpfFrameworkElement.cs @@ -29,7 +29,6 @@ public static IWpfFrameworkElement GetWpfFrameworkElement(this Control control) return handler; var controlObject = control.ControlObject as Control; return controlObject != null ? controlObject.GetWpfFrameworkElement() : null; - } public static IWpfContainer GetWpfContainer(this Container control) @@ -41,7 +40,6 @@ public static IWpfContainer GetWpfContainer(this Container control) return handler; var controlObject = control.ControlObject as Container; return controlObject != null ? controlObject.GetWpfContainer() : null; - } public static sw.FrameworkElement GetContainerControl(this Control control) @@ -76,7 +74,7 @@ public static class WpfFrameworkElementHelper public abstract class WpfFrameworkElement : WidgetHandler, Control.IHandler, IWpfFrameworkElement where TControl : System.Windows.FrameworkElement where TWidget : Control - where TCallback: Control.ICallback + where TCallback : Control.ICallback { sw.Size preferredSize = new sw.Size(double.NaN, double.NaN); Size? newSize; @@ -91,6 +89,15 @@ public abstract class WpfFrameworkElement : Widget protected virtual Size DefaultSize { get { return Size.Empty; } } + /// + /// This property, when set to true, will prevent the control from growing/shrinking based on user input. + /// Typically, this will be accompanied by overriding the as well. + /// + /// For example, when the user types into a text box, it will grow to fit the content if it is auto sized. + /// This doesn't happen on any other platform, so we need to disable this behaviour on WPF. + /// + protected virtual bool PreventUserResize { get { return false; } } + public abstract Color BackgroundColor { get; set; } public virtual bool UseMousePreview { get { return false; } } @@ -135,11 +142,38 @@ public virtual void SetScale(bool xscale, bool yscale) protected virtual void SetSize() { - ContainerControl.Width = XScale && Control.IsLoaded ? double.NaN : Math.Max(preferredSize.Width, parentMinimumSize.Width); - ContainerControl.Height = YScale && Control.IsLoaded ? double.NaN : Math.Max(preferredSize.Height, parentMinimumSize.Height); var defaultSize = DefaultSize; - ContainerControl.MinWidth = XScale && Control.IsLoaded ? 0 : Math.Max(0, double.IsNaN(preferredSize.Width) ? defaultSize.Width : preferredSize.Width); - ContainerControl.MinHeight = YScale && Control.IsLoaded ? 0 : Math.Max(0, double.IsNaN(preferredSize.Height) ? defaultSize.Height : preferredSize.Height); + if (XScale && Control.IsLoaded) + { + ContainerControl.Width = double.NaN; + ContainerControl.MinWidth = 0; + } + else + { + var containerWidth = PreventUserResize && double.IsNaN(preferredSize.Width) + ? defaultSize.Width <= 0 + ? double.NaN + : defaultSize.Width + : preferredSize.Width; + ContainerControl.Width = Math.Max(containerWidth, parentMinimumSize.Width); + ContainerControl.MinWidth = Math.Max(0, double.IsNaN(preferredSize.Width) ? defaultSize.Width : preferredSize.Width); + } + + if (YScale && Control.IsLoaded) + { + ContainerControl.Height = double.NaN; + ContainerControl.MinHeight = 0; + } + else + { + var containerHeight = PreventUserResize && double.IsNaN(preferredSize.Height) + ? defaultSize.Height <= 0 + ? double.NaN + : defaultSize.Height + : preferredSize.Height; + ContainerControl.Height = Math.Max(containerHeight, parentMinimumSize.Height); + ContainerControl.MinHeight = Math.Max(0, double.IsNaN(preferredSize.Height) ? defaultSize.Height : preferredSize.Height); + } } public virtual sw.Size GetPreferredSize(sw.Size constraint) diff --git a/Source/Eto/Forms/Layout/TableLayout.cs b/Source/Eto/Forms/Layout/TableLayout.cs index f05aa186e9..d69142f07a 100644 --- a/Source/Eto/Forms/Layout/TableLayout.cs +++ b/Source/Eto/Forms/Layout/TableLayout.cs @@ -606,7 +606,7 @@ public Padding Padding [OnDeserialized] void OnDeserialized(StreamingContext context) { - OnDeserialized(); + OnDeserialized(false); } /// @@ -628,7 +628,18 @@ protected override void OnPreLoad(EventArgs e) base.OnPreLoad(e); } - void OnDeserialized(bool direct = false) + /// + /// Raises the event, and recursed to this container's children + /// + /// Event arguments + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + // ensure we've been deserialized, in case something was done in load or pre-load event + OnDeserialized(false); + } + + void OnDeserialized(bool direct) { if (Loaded || direct) { diff --git a/Source/Shared/GlobalAssemblyInfo.cs b/Source/Shared/GlobalAssemblyInfo.cs index 56d9d48abd..f55cb1805a 100644 --- a/Source/Shared/GlobalAssemblyInfo.cs +++ b/Source/Shared/GlobalAssemblyInfo.cs @@ -7,5 +7,5 @@ [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.3.0")] -[assembly: AssemblyInformationalVersion("2.0.3")] +[assembly: AssemblyFileVersion("2.0.5.0")] +[assembly: AssemblyInformationalVersion("2.0.5")]