diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Converters/BooleanToBrushConverter.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Converters/BooleanToBrushConverter.xaml.cs new file mode 100644 index 0000000000..5a290da8b8 --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Converters/BooleanToBrushConverter.xaml.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Windows.Data; +using System.Windows.Media; + +namespace FancyZonesEditor.Converters +{ + public class BooleanToBrushConverter : IValueConverter + { + private static Brush _selectedBrush = new SolidColorBrush(Color.FromRgb(0x00, 0x78, 0xD7)); + private static Brush _normalBrush = new SolidColorBrush(Color.FromRgb(0xF2, 0xF2, 0xF2)); + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return ((bool)value) ? _selectedBrush : _normalBrush; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return value == _selectedBrush; + } + } +} diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Converters/BooleanToIntConverter.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Converters/BooleanToIntConverter.xaml.cs new file mode 100644 index 0000000000..6569dd1f2e --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Converters/BooleanToIntConverter.xaml.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Windows.Data; + +namespace FancyZonesEditor.Converters +{ + public class BooleanToIntConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + if (value is bool) + { + return (bool)value == true ? 1 : 0; + } + + return 0; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + if (value is int) + { + return (int)value == 1; + } + + return false; + } + } +} diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Converters/ModelToVisibilityConverter.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Converters/ModelToVisibilityConverter.xaml.cs new file mode 100644 index 0000000000..fee4cfb5b9 --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Converters/ModelToVisibilityConverter.xaml.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Windows; +using System.Windows.Data; +using FancyZonesEditor.Models; + +namespace FancyZonesEditor.Converters +{ + public class ModelToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return Settings.IsPredefinedLayout((LayoutModel)value) ? Visibility.Collapsed : Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return null; + } + } +} diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/EditorOverlay.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/EditorOverlay.xaml.cs index eb693d8ffd..e7d6cff72f 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/EditorOverlay.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/EditorOverlay.xaml.cs @@ -2,22 +2,10 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using FancyZonesEditor.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.NetworkInformation; -using System.Security.RightsManagement; -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.Shapes; +using FancyZonesEditor.Models; namespace FancyZonesEditor { @@ -70,6 +58,7 @@ namespace FancyZonesEditor } public static EditorOverlay Current; + public EditorOverlay() { InitializeComponent(); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/FancyZonesEditor.csproj b/src/modules/fancyzones/editor/FancyZonesEditor/FancyZonesEditor.csproj index 530431dd62..4b676aa78a 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/FancyZonesEditor.csproj +++ b/src/modules/fancyzones/editor/FancyZonesEditor/FancyZonesEditor.csproj @@ -66,6 +66,8 @@ MSBuild:Compile Designer + + CanvasEditor.xaml @@ -87,6 +89,7 @@ EditorOverlay.xaml + GridEditorWindow.xaml diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs index 6aae43956b..6e71fadc2b 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs @@ -212,7 +212,6 @@ namespace FancyZonesEditor break; } } - } private void OnSplit(object o, SplitEventArgs e) @@ -246,12 +245,10 @@ namespace FancyZonesEditor } } - int newChildIndex = AddZone(); double offset = e.Offset; - if (e.Orientation == Orientation.Vertical) { if (splitee.VerticalSnapPoints != null) @@ -385,7 +382,6 @@ namespace FancyZonesEditor } offset -= _rowInfo[foundRow].Start; - } AddDragHandle(Orientation.Horizontal, rows - 1); @@ -919,7 +915,6 @@ namespace FancyZonesEditor return returnSize; } - Point _mouseDownPos = new Point(-1, -1); private RowColInfo[] _rowInfo; private RowColInfo[] _colInfo; @@ -927,8 +922,5 @@ namespace FancyZonesEditor private int _endRow = -1; private int _startCol = -1; private int _endCol = -1; - - private const int c_multiplier = 10000; - } } diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridResizer.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/GridResizer.xaml.cs index ae4985fa1c..7e32d04284 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridResizer.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridResizer.xaml.cs @@ -26,6 +26,7 @@ namespace FancyZonesEditor { return _orientation; } + set { _orientation = value; diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridZone.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/GridZone.xaml.cs index 3bdc968bc3..5e0d9fcd43 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridZone.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridZone.xaml.cs @@ -35,12 +35,9 @@ namespace FancyZonesEditor set { SetValue(IsSelectedProperty, value); } } - public double[] VerticalSnapPoints; public double[] HorizontalSnapPoints; - - public GridZone() { InitializeComponent(); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs index b98af7ad1e..4cf6b9ad3b 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs @@ -17,6 +17,7 @@ namespace FancyZonesEditor public partial class LayoutPreview : UserControl { public static readonly DependencyProperty IsActualSizeProperty = DependencyProperty.Register("IsActualSize", typeof(bool), typeof(LayoutPreview), new PropertyMetadata(false)); + public LayoutPreview() { InitializeComponent(); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml index 694bc06b0d..5954343447 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml +++ b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml @@ -6,6 +6,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:local="clr-namespace:FancyZonesEditor" + xmlns:Converters="clr-namespace:FancyZonesEditor.Converters" mc:Ignorable="d" Title="" Width="810" @@ -16,9 +17,9 @@ Initialized="InitializedEventHandler" Closed="OnClosed"> - - - + + +