From 9fa64e6e1f782d072ae87b2a2b1db71d223a7a8e Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Sat, 16 Dec 2017 20:27:27 -0500 Subject: [PATCH] convert SparkWindowView to UserControl and use Xaml instead of code. Also add style to contextmenu --- src/client/spark/Themes/generic.xaml | 956 +++++++++--------- src/client/spark/view/Shell/Launcher.xaml | 1 - .../spark/view/Spark/SparkWindowView.xaml | 33 + .../spark/view/Spark/SparkWindowView.xaml.cs | 38 + src/client/spark/view/SparkWindowView.cs | 45 - 5 files changed, 549 insertions(+), 524 deletions(-) create mode 100644 src/client/spark/view/Spark/SparkWindowView.xaml create mode 100644 src/client/spark/view/Spark/SparkWindowView.xaml.cs delete mode 100644 src/client/spark/view/SparkWindowView.cs diff --git a/src/client/spark/Themes/generic.xaml b/src/client/spark/Themes/generic.xaml index aa18a9dbb..090c34c7f 100644 --- a/src/client/spark/Themes/generic.xaml +++ b/src/client/spark/Themes/generic.xaml @@ -1,480 +1,480 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/client/spark/view/Shell/Launcher.xaml b/src/client/spark/view/Shell/Launcher.xaml index ca7d108cb..49adbcc9c 100644 --- a/src/client/spark/view/Shell/Launcher.xaml +++ b/src/client/spark/view/Shell/Launcher.xaml @@ -4,7 +4,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:shell="clr-namespace:mbts.ui.shell" - xmlns:ui="clr-namespace:mbts.ui" xmlns:mbts="clr-namespace:mbts.ui" xmlns:converters="clr-namespace:mbts.ui.converters" mc:Ignorable="d" diff --git a/src/client/spark/view/Spark/SparkWindowView.xaml b/src/client/spark/view/Spark/SparkWindowView.xaml new file mode 100644 index 000000000..77078d4a3 --- /dev/null +++ b/src/client/spark/view/Spark/SparkWindowView.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/client/spark/view/Spark/SparkWindowView.xaml.cs b/src/client/spark/view/Spark/SparkWindowView.xaml.cs new file mode 100644 index 000000000..1d7b95209 --- /dev/null +++ b/src/client/spark/view/Spark/SparkWindowView.xaml.cs @@ -0,0 +1,38 @@ +using bts.api; +using mbts.ui.controls; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace bts.view { + public partial class SparkWindowView : UserControl { + SparkMenu _menu; + public SparkWindowView(IBus bus, IEnumerable commands, UIElement content) { + InitializeComponent(); + + Grid.SetColumn(content, 1); + Grid.SetRowSpan(content, 2); + _grid.Children.Add(content); + + _menu = new SparkMenu(commands, bus); + Grid.SetColumn(_menu, 0); + Grid.SetRow(_menu, 1); + _grid.Children.Add(_menu); + + if (ContextMenu != null) { + ContextMenu.ItemsSource = commands; + } + } + } +} diff --git a/src/client/spark/view/SparkWindowView.cs b/src/client/spark/view/SparkWindowView.cs deleted file mode 100644 index f68d3595f..000000000 --- a/src/client/spark/view/SparkWindowView.cs +++ /dev/null @@ -1,45 +0,0 @@ -using bts.api; -using mbts.ui.controls; -using System.Collections; -using System.Collections.Generic; -using System.Windows; -using System.Windows.Controls; - -namespace bts.view { - public partial class SparkWindowView : Control { - readonly IBus _bus; - readonly IEnumerable _commands; - UIElement _content; - - public SparkWindowView(IBus bus, IEnumerable commands, UIElement content) { - Template = new ControlTemplate(typeof(SparkWindowView)) { - VisualTree = new FrameworkElementFactory() { - Type = typeof(Grid), - Name = "_grid", - } - }; - _bus = bus; - _commands = commands; - _content = content; - } - - private void assign_children(Grid grid, IBus bus, IEnumerable commands, UIElement content) { - grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); - grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); - var menu = new SparkMenu(commands, bus); - Grid.SetColumn(menu, 0); - grid.Children.Add(menu); - Grid.SetColumn(content, 1); - grid.Children.Add(content); - - ContextMenu = new ContextMenu() { - ItemsSource = commands - }; - } - - public override void OnApplyTemplate() { - var grid = GetTemplateChild("_grid") as Grid; - assign_children(grid, _bus, _commands, _content); - } - } -}