From 515a652685f86b762060b88b4838d68f2feb3efa Mon Sep 17 00:00:00 2001 From: Nikhil Agrawal Date: Sat, 9 Dec 2017 19:41:03 +0530 Subject: [PATCH] UI Changes 1. Made more space for links hover in statusbar - Moved Progress Bar below addressbar. a) Thinly visible when loading, hides when loaded. b) No flickering as progress bar and browser share same row. 2. Behaviour to load page when hit Enter in Addressbar - Behaviour for that. 2. Refactor. --- CefSharp.MinimalExample.Wpf/App.xaml | 1 + .../TextBoxBindingUpdateOnEnterBehaviour.cs | 28 +++++++++++++++++ .../CefSharp.MinimalExample.Wpf.csproj | 1 + .../Converter/TitleConverter.cs | 7 ++--- CefSharp.MinimalExample.Wpf/MainWindow.xaml | 30 ++++++++++--------- 5 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 CefSharp.MinimalExample.Wpf/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs diff --git a/CefSharp.MinimalExample.Wpf/App.xaml b/CefSharp.MinimalExample.Wpf/App.xaml index b53d4c4..2632003 100644 --- a/CefSharp.MinimalExample.Wpf/App.xaml +++ b/CefSharp.MinimalExample.Wpf/App.xaml @@ -6,5 +6,6 @@ + diff --git a/CefSharp.MinimalExample.Wpf/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs b/CefSharp.MinimalExample.Wpf/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs new file mode 100644 index 0000000..1dcafd7 --- /dev/null +++ b/CefSharp.MinimalExample.Wpf/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs @@ -0,0 +1,28 @@ +using System.Windows.Interactivity; +using System.Windows.Controls; +using System.Windows.Input; + +namespace CefSharp.MinimalExample.Wpf.Behaviours +{ + public class TextBoxBindingUpdateOnEnterBehaviour : Behavior + { + protected override void OnAttached() + { + AssociatedObject.KeyDown += OnTextBoxKeyDown; + } + + protected override void OnDetaching() + { + AssociatedObject.KeyDown -= OnTextBoxKeyDown; + } + + private void OnTextBoxKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + var txtBox = sender as TextBox; + txtBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); + } + } + } +} diff --git a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj index 2904c57..c1348cd 100644 --- a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj +++ b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj @@ -103,6 +103,7 @@ Code + diff --git a/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs b/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs index 567e558..d78aadc 100644 --- a/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs +++ b/CefSharp.MinimalExample.Wpf/Converter/TitleConverter.cs @@ -6,15 +6,14 @@ namespace CefSharp.MinimalExample.Wpf.Converter { public class TitleConverter : IValueConverter { - object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return "CefSharp.MinimalExample.Wpf - " + (value ?? "No Title Specified"); } - object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - return System.Windows.Data.Binding.DoNothing; + return Binding.DoNothing; } } } diff --git a/CefSharp.MinimalExample.Wpf/MainWindow.xaml b/CefSharp.MinimalExample.Wpf/MainWindow.xaml index e5ba808..3b1c2c3 100644 --- a/CefSharp.MinimalExample.Wpf/MainWindow.xaml +++ b/CefSharp.MinimalExample.Wpf/MainWindow.xaml @@ -31,25 +31,35 @@