Skip to content

Commit

Permalink
FancyZonesEditor: open a tab with the selected layout on startup (#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyoyuppe committed Nov 15, 2019
1 parent 0082f56 commit cb13cfd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Controls:MetroWindow x:Class="FancyZonesEditor.MainWindow"
<Controls:MetroWindow x:Class="FancyZonesEditor.MainWindow"
x:Name="MainWindow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand All @@ -18,6 +18,7 @@
<Window.Resources>
<local:BooleanToBrushConverter x:Key="BooleanToBrushConverter" />
<local:ModelToVisibilityConverter x:Key="ModelToVisibilityConverter" />
<local:BooleanToIntConverter x:Key="BooleanToIntConverter" />

<Style x:Key="titleText" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
Expand Down Expand Up @@ -176,8 +177,8 @@
<StackPanel>

<TextBlock Name="dialog_Title" Text="Choose your layout" Style="{StaticResource titleText}" />
<TabControl BorderThickness="0" x:Name="TemplateTab">

<TabControl BorderThickness="0" x:Name="TemplateTab" SelectedIndex="{Binding IsCustomLayoutActive, Mode=OneWay, Converter={StaticResource BooleanToIntConverter}}">
<TabItem Header="Templates" Template="{StaticResource myTabs}">
<StackPanel>
<StackPanel Margin="0,15,0,8" Orientation="Horizontal" HorizontalAlignment="Center">
Expand Down
24 changes: 22 additions & 2 deletions src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -38,7 +38,8 @@ public MainWindow()
}

private int _WrapPanelItemSize = 262;
public int WrapPanelItemSize {
public int WrapPanelItemSize
{
get
{
return _WrapPanelItemSize;
Expand Down Expand Up @@ -238,4 +239,23 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
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;
}
}
}
15 changes: 15 additions & 0 deletions src/modules/fancyzones/editor/FancyZonesEditor/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ namespace FancyZonesEditor
//
public class Settings : INotifyPropertyChanged
{
public bool IsCustomLayoutActive
{
get
{
foreach (LayoutModel model in CustomModels)
{
if (model.IsSelected)
{
return true;
}
}
return false;
}
}

public Settings()
{
ParseCommandLineArgs();
Expand Down

0 comments on commit cb13cfd

Please sign in to comment.