From 249c09c583da9e7066809a24639edecaee6cfa47 Mon Sep 17 00:00:00 2001 From: amaitland Date: Thu, 9 Jul 2015 12:21:59 +1000 Subject: [PATCH] Add menu to WPF example Can now easily open binding test example TODO: Import tests from cefclient example --- CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj | 1 + .../Controls/CefSharpCommands.cs | 15 +++++++++++++++ CefSharp.Wpf.Example/MainWindow.xaml | 14 ++++++++++++-- CefSharp.Wpf.Example/MainWindow.xaml.cs | 16 ++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 CefSharp.Wpf.Example/Controls/CefSharpCommands.cs diff --git a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj index 6933819b2..00f27d37a 100644 --- a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj +++ b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj @@ -122,6 +122,7 @@ MSBuild:Compile Designer + diff --git a/CefSharp.Wpf.Example/Controls/CefSharpCommands.cs b/CefSharp.Wpf.Example/Controls/CefSharpCommands.cs new file mode 100644 index 000000000..c458a1c8f --- /dev/null +++ b/CefSharp.Wpf.Example/Controls/CefSharpCommands.cs @@ -0,0 +1,15 @@ +// Copyright © 2010-2015 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + + +using System.Windows.Input; + +namespace CefSharp.Wpf.Example.Controls +{ + public static class CefSharpCommands + { + public static RoutedUICommand Exit = new RoutedUICommand("Exit", "Exit", typeof(CefSharpCommands)); + public static RoutedUICommand OpenTabBindingTest = new RoutedUICommand("OpenTabBindingTest", "OpenTabBindingTest", typeof(CefSharpCommands)); + } +} diff --git a/CefSharp.Wpf.Example/MainWindow.xaml b/CefSharp.Wpf.Example/MainWindow.xaml index eeaa0271c..bee4e50a1 100644 --- a/CefSharp.Wpf.Example/MainWindow.xaml +++ b/CefSharp.Wpf.Example/MainWindow.xaml @@ -8,7 +8,17 @@ - + + + + + + + + + + + - + diff --git a/CefSharp.Wpf.Example/MainWindow.xaml.cs b/CefSharp.Wpf.Example/MainWindow.xaml.cs index aba3e6a98..3f3e96db3 100644 --- a/CefSharp.Wpf.Example/MainWindow.xaml.cs +++ b/CefSharp.Wpf.Example/MainWindow.xaml.cs @@ -7,6 +7,7 @@ using System.Collections.ObjectModel; using System.Windows; using System.Windows.Input; using CefSharp.Example; +using CefSharp.Wpf.Example.Controls; using CefSharp.Wpf.Example.ViewModels; namespace CefSharp.Wpf.Example @@ -27,6 +28,9 @@ namespace CefSharp.Wpf.Example CommandBindings.Add(new CommandBinding(ApplicationCommands.New, OpenNewTab)); CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CloseTab)); + CommandBindings.Add(new CommandBinding(CefSharpCommands.Exit, Exit)); + CommandBindings.Add(new CommandBinding(CefSharpCommands.OpenTabBindingTest, OpenTabBindingTest)); + Loaded += MainWindowLoaded; var bitness = Environment.Is64BitProcess ? "x64" : "x86"; @@ -74,5 +78,17 @@ namespace CefSharp.Wpf.Example { BrowserTabs.Add(new BrowserTabViewModel(url) { ShowSidebar = showSideBar }); } + + private void OpenTabBindingTest(object sender, ExecutedRoutedEventArgs e) + { + CreateNewTab(CefExample.BindingTestUrl, true); + + TabControl.SelectedIndex = TabControl.Items.Count - 1; + } + + private void Exit(object sender, ExecutedRoutedEventArgs e) + { + Close(); + } } }