Skip to content

Commit

Permalink
fixed rest of info items
Browse files Browse the repository at this point in the history
  • Loading branch information
crutkas committed Dec 12, 2019
1 parent 63cb5ab commit 360a22c
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 65 deletions.
19 changes: 10 additions & 9 deletions src/modules/fancyzones/editor/FancyZonesEditor/CanvasZone.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ namespace FancyZonesEditor
/// </summary>
public partial class CanvasZone : UserControl
{
public CanvasLayoutModel Model { get; set; }

public int ZoneIndex { get; set; }

private readonly Settings _settings = ((App)Application.Current).ZoneSettings;

private static readonly int _minZoneWidth = 64;
private static readonly int _minZoneHeight = 72;
private static int _zIndex = 0;

public CanvasZone()
{
InitializeComponent();
Panel.SetZIndex(this, _zIndex++);
}

public CanvasLayoutModel Model;
public int ZoneIndex;

private void Move(double xDelta, double yDelta)
{
Int32Rect rect = Model.Zones[ZoneIndex];
Expand Down Expand Up @@ -138,10 +145,6 @@ private void Size(double xDelta, double yDelta)
Model.Zones[ZoneIndex] = rect;
}

private static int _zIndex = 0;
private static int _minZoneWidth = 64;
private static int _minZoneHeight = 72;

protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
{
Panel.SetZIndex(this, _zIndex++);
Expand Down Expand Up @@ -200,7 +203,5 @@ private void OnClose(object sender, RoutedEventArgs e)
((Panel)Parent).Children.Remove(this);
Model.RemoveZoneAt(ZoneIndex);
}

private Settings _settings = ((App)Application.Current).ZoneSettings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ 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));
private static readonly Brush _selectedBrush = new SolidColorBrush(Color.FromRgb(0x00, 0x78, 0xD7));
private static readonly Brush _normalBrush = new SolidColorBrush(Color.FromRgb(0xF2, 0xF2, 0xF2));

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace FancyZonesEditor
public partial class EditorOverlay : Window
{
public static EditorOverlay Current { get; set; }
private readonly Settings _settings = ((App)Application.Current).ZoneSettings;
private LayoutPreview _layoutPreview;
private UserControl _editor;

public Int32Rect[] GetZoneRects()
{
Expand Down Expand Up @@ -128,9 +131,5 @@ public void Edit()

Content = _editor;
}

private Settings _settings = ((App)Application.Current).ZoneSettings;
private LayoutPreview _layoutPreview;
private UserControl _editor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ namespace FancyZonesEditor
/// </summary>
public partial class GridResizer : Thumb
{
private static readonly RotateTransform _rotateTransform = new RotateTransform(90, 24, 24);

public int Index;
public LayoutModel Model;

private Orientation _orientation;

public GridResizer()
{
InitializeComponent();
Expand Down Expand Up @@ -44,12 +51,5 @@ public Orientation Orientation
}
}
}

private static RotateTransform _rotateTransform = new RotateTransform(90, 24, 24);

public int Index;
public LayoutModel Model;

private Orientation _orientation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class GridZone : UserControl

public double[] HorizontalSnapPoints { get; set; }

private Rectangle _splitter;
private readonly Rectangle _splitter;
private bool _switchOrientation = false;
private Point _lastPos = new Point(-1, -1);
private Point _mouseDownPos = new Point(-1, -1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public partial class LayoutPreview : UserControl
{
public static readonly DependencyProperty IsActualSizeProperty = DependencyProperty.Register("IsActualSize", typeof(bool), typeof(LayoutPreview), new PropertyMetadata(false));

private LayoutModel _model;

public LayoutPreview()
{
InitializeComponent();
Expand Down Expand Up @@ -192,7 +194,5 @@ private void RenderCanvasPreview(CanvasLayoutModel canvas)
frame.Children.Add(rect);
}
}

private LayoutModel _model;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ public partial class MainWindow : MetroWindow
{
// TODO: share the constants b/w C# Editor and FancyZoneLib
public const int MaxZones = 40;
private static string _defaultNamePrefix = "Custom Layout ";
private readonly Settings _settings = ((App)Application.Current).ZoneSettings;
private static readonly string _defaultNamePrefix = "Custom Layout ";
private bool _editing = false;

public int WrapPanelItemSize { get; set; } = 262;

public MainWindow()
{
InitializeComponent();
Expand All @@ -33,7 +36,7 @@ public MainWindow()
}
}

public int WrapPanelItemSize { get; set; } = 262;


private void DecrementZones_Click(object sender, RoutedEventArgs e)
{
Expand All @@ -51,8 +54,6 @@ private void IncrementZones_Click(object sender, RoutedEventArgs e)
}
}

private Settings _settings = ((App)Application.Current).ZoneSettings;

private void NewCustomLayoutButton_Click(object sender, RoutedEventArgs e)
{
WindowLayout window = new WindowLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace FancyZonesEditor.Models
// Free form Layout Model, which specifies independent zone rects
public class CanvasLayoutModel : LayoutModel
{
private static readonly ushort _latestVersion = 0;

public CanvasLayoutModel(ushort version, string name, ushort id, byte[] data)
: base(name, id)
{
Expand Down Expand Up @@ -180,7 +182,5 @@ protected override byte[] GetPersistData()

return data;
}

private static ushort _latestVersion = 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace FancyZonesEditor.Models
// Grid-styled Layout Model, which specifies rows, columns, percentage sizes, and row/column spans
public class GridLayoutModel : LayoutModel
{
private static ushort _latestVersion = 0;
private static readonly ushort _latestVersion = 0;

// Rows - number of rows in the Grid
public int Rows
Expand Down
66 changes: 33 additions & 33 deletions src/modules/fancyzones/editor/FancyZonesEditor/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,39 @@ namespace FancyZonesEditor
// Other UIs in the editor will subscribe to change events on the properties to stay up to date as these properties change
public class Settings : INotifyPropertyChanged
{
private readonly CanvasLayoutModel _blankCustomModel;
private readonly CanvasLayoutModel _focusModel;
private readonly GridLayoutModel _rowsModel;
private readonly GridLayoutModel _columnsModel;
private readonly GridLayoutModel _gridModel;
private readonly GridLayoutModel _priorityGridModel;

private static readonly ushort _focusModelId = 0xFFFF;
private static readonly ushort _rowsModelId = 0xFFFE;
private static readonly ushort _columnsModelId = 0xFFFD;
private static readonly ushort _gridModelId = 0xFFFC;
private static readonly ushort _priorityGridModelId = 0xFFFB;
private static readonly ushort _blankCustomModelId = 0xFFFA;
private static readonly ushort _lastPrefinedId = _blankCustomModelId;

// hard coded data for all the "Priority Grid" configurations that are unique to "Grid"
private static readonly byte[][] _priorityData = new byte[][]
{
new byte[] { 0, 0, 0, 0, 0, 1, 1, 39, 16, 39, 16, 0 },
new byte[] { 0, 0, 0, 0, 0, 1, 2, 39, 16, 26, 11, 13, 5, 0, 1 },
new byte[] { 0, 0, 0, 0, 0, 1, 3, 39, 16, 9, 196, 19, 136, 9, 196, 0, 1, 2 },
new byte[] { 0, 0, 0, 0, 0, 2, 3, 19, 136, 19, 136, 9, 196, 19, 136, 9, 196, 0, 1, 2, 0, 1, 3 },
new byte[] { 0, 0, 0, 0, 0, 2, 3, 19, 136, 19, 136, 9, 196, 19, 136, 9, 196, 0, 1, 2, 3, 1, 4 },
new byte[] { 0, 0, 0, 0, 0, 3, 3, 13, 5, 13, 6, 13, 5, 9, 196, 19, 136, 9, 196, 0, 1, 2, 0, 1, 3, 4, 1, 5 },
new byte[] { 0, 0, 0, 0, 0, 3, 3, 13, 5, 13, 6, 13, 5, 9, 196, 19, 136, 9, 196, 0, 1, 2, 3, 1, 4, 5, 1, 6 },
new byte[] { 0, 0, 0, 0, 0, 3, 4, 13, 5, 13, 6, 13, 5, 9, 196, 9, 196, 9, 196, 9, 196, 0, 1, 2, 3, 4, 1, 2, 5, 6, 1, 2, 7 },
new byte[] { 0, 0, 0, 0, 0, 3, 4, 13, 5, 13, 6, 13, 5, 9, 196, 9, 196, 9, 196, 9, 196, 0, 1, 2, 3, 4, 1, 2, 5, 6, 1, 7, 8 },
new byte[] { 0, 0, 0, 0, 0, 3, 4, 13, 5, 13, 6, 13, 5, 9, 196, 9, 196, 9, 196, 9, 196, 0, 1, 2, 3, 4, 1, 5, 6, 7, 1, 8, 9 },
new byte[] { 0, 0, 0, 0, 0, 3, 4, 13, 5, 13, 6, 13, 5, 9, 196, 9, 196, 9, 196, 9, 196, 0, 1, 2, 3, 4, 1, 5, 6, 7, 8, 9, 10 },
};

private const int _multiplier = 10000;

public bool IsCustomLayoutActive
{
get
Expand Down Expand Up @@ -378,38 +411,5 @@ protected virtual void FirePropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

private CanvasLayoutModel _focusModel;
private GridLayoutModel _rowsModel;
private GridLayoutModel _columnsModel;
private GridLayoutModel _gridModel;
private GridLayoutModel _priorityGridModel;
private CanvasLayoutModel _blankCustomModel;

private static readonly ushort _focusModelId = 0xFFFF;
private static readonly ushort _rowsModelId = 0xFFFE;
private static readonly ushort _columnsModelId = 0xFFFD;
private static readonly ushort _gridModelId = 0xFFFC;
private static readonly ushort _priorityGridModelId = 0xFFFB;
private static readonly ushort _blankCustomModelId = 0xFFFA;
private static readonly ushort _lastPrefinedId = _blankCustomModelId;

// hard coded data for all the "Priority Grid" configurations that are unique to "Grid"
private static byte[][] _priorityData = new byte[][]
{
new byte[] { 0, 0, 0, 0, 0, 1, 1, 39, 16, 39, 16, 0 },
new byte[] { 0, 0, 0, 0, 0, 1, 2, 39, 16, 26, 11, 13, 5, 0, 1 },
new byte[] { 0, 0, 0, 0, 0, 1, 3, 39, 16, 9, 196, 19, 136, 9, 196, 0, 1, 2 },
new byte[] { 0, 0, 0, 0, 0, 2, 3, 19, 136, 19, 136, 9, 196, 19, 136, 9, 196, 0, 1, 2, 0, 1, 3 },
new byte[] { 0, 0, 0, 0, 0, 2, 3, 19, 136, 19, 136, 9, 196, 19, 136, 9, 196, 0, 1, 2, 3, 1, 4 },
new byte[] { 0, 0, 0, 0, 0, 3, 3, 13, 5, 13, 6, 13, 5, 9, 196, 19, 136, 9, 196, 0, 1, 2, 0, 1, 3, 4, 1, 5 },
new byte[] { 0, 0, 0, 0, 0, 3, 3, 13, 5, 13, 6, 13, 5, 9, 196, 19, 136, 9, 196, 0, 1, 2, 3, 1, 4, 5, 1, 6 },
new byte[] { 0, 0, 0, 0, 0, 3, 4, 13, 5, 13, 6, 13, 5, 9, 196, 9, 196, 9, 196, 9, 196, 0, 1, 2, 3, 4, 1, 2, 5, 6, 1, 2, 7 },
new byte[] { 0, 0, 0, 0, 0, 3, 4, 13, 5, 13, 6, 13, 5, 9, 196, 9, 196, 9, 196, 9, 196, 0, 1, 2, 3, 4, 1, 2, 5, 6, 1, 7, 8 },
new byte[] { 0, 0, 0, 0, 0, 3, 4, 13, 5, 13, 6, 13, 5, 9, 196, 9, 196, 9, 196, 9, 196, 0, 1, 2, 3, 4, 1, 5, 6, 7, 1, 8, 9 },
new byte[] { 0, 0, 0, 0, 0, 3, 4, 13, 5, 13, 6, 13, 5, 9, 196, 9, 196, 9, 196, 9, 196, 0, 1, 2, 3, 4, 1, 5, 6, 7, 8, 9, 10 },
};

private const int _multiplier = 10000;
}
}

0 comments on commit 360a22c

Please sign in to comment.