mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 06:29:44 +08:00
moving converters, fixing spacing issues
This commit is contained in:
parent
a187456ac3
commit
24664cc859
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -66,6 +66,8 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Converters\BooleanToBrushConverter.xaml.cs" />
|
||||
<Compile Include="Converters\BooleanToIntConverter.xaml.cs" />
|
||||
<Compile Include="CanvasEditor.xaml.cs">
|
||||
<DependentUpon>CanvasEditor.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -87,6 +89,7 @@
|
||||
<Compile Include="EditorOverlay.xaml.cs">
|
||||
<DependentUpon>EditorOverlay.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Converters\ModelToVisibilityConverter.xaml.cs" />
|
||||
<Compile Include="RowColInfo.cs" />
|
||||
<Compile Include="GridEditorWindow.xaml.cs">
|
||||
<DependentUpon>GridEditorWindow.xaml</DependentUpon>
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace FancyZonesEditor
|
||||
{
|
||||
return _orientation;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_orientation = value;
|
||||
|
@ -35,12 +35,9 @@ namespace FancyZonesEditor
|
||||
set { SetValue(IsSelectedProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double[] VerticalSnapPoints;
|
||||
public double[] HorizontalSnapPoints;
|
||||
|
||||
|
||||
|
||||
public GridZone()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -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();
|
||||
|
@ -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">
|
||||
<Window.Resources>
|
||||
<local:BooleanToBrushConverter x:Key="BooleanToBrushConverter" />
|
||||
<local:ModelToVisibilityConverter x:Key="ModelToVisibilityConverter" />
|
||||
<local:BooleanToIntConverter x:Key="BooleanToIntConverter" />
|
||||
<Converters:BooleanToBrushConverter x:Key="BooleanToBrushConverter" />
|
||||
<Converters:ModelToVisibilityConverter x:Key="ModelToVisibilityConverter" />
|
||||
<Converters:BooleanToIntConverter x:Key="BooleanToIntConverter" />
|
||||
|
||||
<Style x:Key="titleText" TargetType="TextBlock">
|
||||
<Setter Property="FontFamily" Value="Segoe UI" />
|
||||
|
@ -209,57 +209,4 @@ namespace FancyZonesEditor
|
||||
model.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class BooleanToBrushConverter : IValueConverter
|
||||
{
|
||||
private static Brush c_selectedBrush = new SolidColorBrush(Color.FromRgb(0x00, 0x78, 0xD7));
|
||||
private static Brush c_normalBrush = new SolidColorBrush(Color.FromRgb(0xF2, 0xF2, 0xF2));
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return ((bool)value) ? c_selectedBrush : c_normalBrush;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return value == c_selectedBrush;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,6 @@ namespace FancyZonesEditor.Models
|
||||
data[i++] = (byte)(Id % 256);
|
||||
|
||||
// End common
|
||||
|
||||
data[i++] = (byte)(_referenceWidth / 256);
|
||||
data[i++] = (byte)(_referenceWidth % 256);
|
||||
data[i++] = (byte)(_referenceHeight / 256);
|
||||
|
@ -214,7 +214,6 @@ namespace FancyZonesEditor.Models
|
||||
data[i++] = (byte)(Id % 256);
|
||||
|
||||
// End common
|
||||
|
||||
data[i++] = (byte)Rows;
|
||||
data[i++] = (byte)Columns;
|
||||
|
||||
|
@ -276,7 +276,6 @@ namespace FancyZonesEditor
|
||||
{
|
||||
index--;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,7 +312,6 @@ namespace FancyZonesEditor
|
||||
// 4 = X_Y_Width_Height in a dpi-scaled-but-unaware coords (where EditorOverlay shows up)
|
||||
// 5 = resolution key (passed back to engine to persist data)
|
||||
// 6 = monitor DPI (float)
|
||||
|
||||
UniqueKey = args[1];
|
||||
_uniqueRegistryPath += "\\" + UniqueKey;
|
||||
|
||||
@ -347,7 +345,6 @@ namespace FancyZonesEditor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IList<LayoutModel> DefaultModels
|
||||
{
|
||||
get { return _defaultModels; }
|
||||
|
Loading…
Reference in New Issue
Block a user