Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OpenFile, SaveFile, Directory pickers style #622

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Orc.Controls">

<Style x:Key="{x:Type controls:DirectoryPicker}"
TargetType="{x:Type controls:DirectoryPicker}">
</Style>

</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,31 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Label Grid.Column="0" Content="{Binding LabelText}" Width="{Binding LabelWidth}" />
<TextBox Grid.Column="1" IsReadOnly="True" Text="{Binding SelectedDirectory}" />
<Label Grid.Column="0" Content="{Binding LabelText}" Width="{Binding LabelWidth}" VerticalAlignment="Center">
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<DataTrigger Binding="{Binding LabelText, Converter={catel:EmptyStringToCollapsingVisibilityConverter}}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does the trigger works without Value property specified? (Same in other cases)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not to use DataTrigger...why not use Content property and simple Trigger? (but as for me it's not critical as long as it would be deprecated)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one: what if LabelWidth would be 0 -> what kind of margin it would be?

<Setter Property="Width" Value="0"/>
<Setter Property="Margin" Value="0"/>
</DataTrigger>
</Style.Triggers>
</Style>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please re-style the code

</Label.Style>
</Label>
<TextBox Grid.Column="1" IsReadOnly="True" Text="{Binding SelectedDirectory}" Margin="0,0,4,0"/>

<Button Grid.Column="2" Margin="0,6,2,6" Width="24" Content="..."
<Button Grid.Column="2" Margin="0" Width="24" Content="..."
ToolTip="{catel:LanguageBinding Controls_BrowseForFile}"
Command="{Binding SelectDirectory}" />

<Button Grid.Column="3" Margin="2,6,2,6" Width="24" ToolTip="{catel:LanguageBinding Controls_OpenFolder}"
<Button Grid.Column="3" Margin="4,0,2,0" Width="24" ToolTip="{catel:LanguageBinding Controls_OpenFolder}"
Command="{Binding OpenDirectory}"
Visibility="{Binding SelectedDirectory, Converter={catel:EmptyStringToCollapsingVisibilityConverter}}">
<Image Source="/Orc.Controls;component/Resources/Images/Folder.png" Width="16" Height="16" />
</Button>

<Button Grid.Column="4" Margin="2,6,0,6" Width="24" ToolTip="{catel:LanguageBinding Controls_Clear}"
<Button Grid.Column="4" Margin="2,0,0,0" Width="24" ToolTip="{catel:LanguageBinding Controls_Clear}"
Command="{Binding Clear}" Visibility="{Binding SelectedDirectory, Converter={catel:EmptyStringToCollapsingVisibilityConverter}}">
<Image Source="/Orc.Controls;component/Resources/Images/Delete.png" Width="16" Height="16" />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public DirectoryPicker()
InitializeComponent();
}

[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
[ViewToViewModel(MappingType = ViewToViewModelMappingType.TwoWayViewWins)]
public double LabelWidth
{
Expand All @@ -30,9 +31,11 @@ public double LabelWidth
}

// Using a DependencyProperty as the backing store for LabelWidth. This enables animation, styling, binding, etc...
[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
public static readonly DependencyProperty LabelWidthProperty = DependencyProperty.Register(nameof(LabelWidth),
typeof(double), typeof(DirectoryPicker), new PropertyMetadata(125d));
typeof(double), typeof(DirectoryPicker), new PropertyMetadata(0d));

[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
[ViewToViewModel(MappingType = ViewToViewModelMappingType.TwoWayViewWins)]
public string LabelText
{
Expand All @@ -41,6 +44,7 @@ public string LabelText
}

// Using a DependencyProperty as the backing store for LabelText. This enables animation, styling, binding, etc...
[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
public static readonly DependencyProperty LabelTextProperty =
DependencyProperty.Register(nameof(LabelText), typeof(string), typeof(DirectoryPicker), new PropertyMetadata(string.Empty));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Orc.Controls">

<Style x:Key="{x:Type controls:OpenFilePicker}"
TargetType="{x:Type controls:OpenFilePicker}">
</Style>

</ResourceDictionary>
24 changes: 18 additions & 6 deletions src/Orc.Controls/Controls/OpenFilePicker/Views/OpenFilePicker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,38 @@

<Label Grid.Column="0"
Content="{Binding LabelText}"
Width="{Binding LabelWidth}" />
Width="{Binding LabelWidth}"
VerticalAlignment="Center">
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<DataTrigger Binding="{Binding LabelText, Converter={catel:EmptyStringToCollapsingVisibilityConverter}}">
<Setter Property="Width" Value="0"/>
<Setter Property="Margin" Value="0"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>

<TextBox AutomationProperties.AutomationId="{x:Static automation:OpenFilePickerMap.SelectedFileTextBoxId}"
Grid.Column="1"
IsReadOnly="True"
Text="{Binding SelectedFileDisplayName, Mode=OneWay}"
Height="{Binding ElementName=OpenFileButton, Path=ActualHeight}"/>
Text="{Binding SelectedFileDisplayName, Mode=OneWay}"
Margin="0,0,4,0"/>

<Button x:Name="OpenFileButton"
AutomationProperties.AutomationId="{x:Static automation:OpenFilePickerMap.OpenFileButtonId}"
Grid.Column="2"
Margin="0,6,2,6"
Margin="0"
Width="24"
Content="..."
ToolTip="{catel:LanguageBinding Controls_BrowseForFile}"
Command="{Binding SelectFile}" />

<Button AutomationProperties.AutomationId="{x:Static automation:OpenFilePickerMap.OpenDirectoryButtonId}"
Grid.Column="3"
Margin="2,6,2,6"
Margin="4,0,2,0"
Width="24"
ToolTip="{catel:LanguageBinding Controls_OpenFolder}"
Command="{Binding OpenDirectory}"
Expand All @@ -51,7 +63,7 @@

<Button AutomationProperties.AutomationId="{x:Static automation:OpenFilePickerMap.ClearButtonId}"
Grid.Column="4"
Margin="2,6,0,6"
Margin="2,0,0,0"
Width="24"
ToolTip="{catel:LanguageBinding Controls_Clear}"
Command="{Binding Clear}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public OpenFilePicker()
}

#region Properties
[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TreatAsErrorFromVersion ="5.0.0"

[ViewToViewModel(MappingType = ViewToViewModelMappingType.TwoWayViewWins)]
public double LabelWidth
{
Expand All @@ -33,9 +34,11 @@ public double LabelWidth
}

// Using a DependencyProperty as the backing store for LabelWidth. This enables animation, styling, binding, etc...
[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TreatAsErrorFromVersion ="5.0.0"

public static readonly DependencyProperty LabelWidthProperty = DependencyProperty.Register(nameof(LabelWidth),
typeof(double), typeof(OpenFilePicker), new PropertyMetadata(125d));
typeof(double), typeof(OpenFilePicker), new PropertyMetadata(0d));

[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TreatAsErrorFromVersion ="5.0.0"

[ViewToViewModel(MappingType = ViewToViewModelMappingType.TwoWayViewWins)]
public string LabelText
{
Expand All @@ -44,6 +47,7 @@ public string LabelText
}

// Using a DependencyProperty as the backing store for LabelText. This enables animation, styling, binding, etc...
[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TreatAsErrorFromVersion ="5.0.0"

public static readonly DependencyProperty LabelTextProperty = DependencyProperty.Register(nameof(LabelText),
typeof(string), typeof(OpenFilePicker), new PropertyMetadata(string.Empty));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
xmlns:controls="clr-namespace:Orc.Controls">

<Style x:Key="{x:Type controls:SaveFilePicker}"
TargetType="{x:Type controls:SaveFilePicker}"/>
TargetType="{x:Type controls:SaveFilePicker}">
</Style>

</ResourceDictionary>
25 changes: 19 additions & 6 deletions src/Orc.Controls/Controls/SaveFilePicker/Views/SaveFilePicker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,36 @@

<Label Grid.Column="0"
Content="{Binding LabelText}"
Width="{Binding LabelWidth}" />
Width="{Binding LabelWidth}"
VerticalAlignment="Center">
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<DataTrigger Binding="{Binding LabelText, Converter={catel:EmptyStringToCollapsingVisibilityConverter}}">
<Setter Property="Width" Value="0"/>
<Setter Property="Margin" Value="0"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>

<TextBox Grid.Column="1"
IsReadOnly="True"
Text="{Binding SelectedFile}"
Height="{Binding ElementName=SaveFileButton, Path=ActualHeight}"/>
Text="{Binding SelectedFile}"
Margin="0,0,4,0"
VerticalAlignment="Center"/>

<Button x:Name="SaveFileButton"
Grid.Column="2"
Margin="0,6,2,6"
Margin="0"
Width="24"
Content="..."
ToolTip="{catel:LanguageBinding Controls_BrowseForFile}"
Command="{Binding SelectFile}" />

<Button Grid.Column="3"
Margin="2,6,2,6"
Margin="4,0,2,0"
Width="24"
ToolTip="{catel:LanguageBinding Controls_OpenFolder}"
Command="{Binding OpenDirectory}"
Expand All @@ -48,7 +61,7 @@
</Button>

<Button Grid.Column="4"
Margin="2,6,0,6"
Margin="2,0,0,0"
Width="24"
ToolTip="{catel:LanguageBinding Controls_Clear}"
Command="{Binding Clear}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,27 @@ public SaveFilePicker()
InitializeComponent();
}

[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TreatAsErrorFromVersion ="5.0.0"

[ViewToViewModel(MappingType = ViewToViewModelMappingType.TwoWayViewWins)]
public double LabelWidth
{
get { return (double)GetValue(LabelWidthProperty); }
set { SetValue(LabelWidthProperty, value); }
}

[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TreatAsErrorFromVersion ="5.0.0"

public static readonly DependencyProperty LabelWidthProperty = DependencyProperty.Register(nameof(LabelWidth), typeof(double),
typeof(SaveFilePicker), new PropertyMetadata(125d));

typeof(SaveFilePicker), new PropertyMetadata(0d));

[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TreatAsErrorFromVersion ="5.0.0"

[ViewToViewModel(MappingType = ViewToViewModelMappingType.TwoWayViewWins)]
public string LabelText
{
get { return (string)GetValue(LabelTextProperty); }
set { SetValue(LabelTextProperty, value); }
}

[ObsoleteEx(Message = "This property will be deprecated", TreatAsErrorFromVersion ="4.9.0", RemoveInVersion = "6.0.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TreatAsErrorFromVersion ="5.0.0"

public static readonly DependencyProperty LabelTextProperty = DependencyProperty.Register(nameof(LabelText), typeof(string),
typeof(SaveFilePicker), new PropertyMetadata(string.Empty));

Expand Down
6 changes: 5 additions & 1 deletion src/Orc.Controls/Themes/Generic.generated.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Orc.Controls" xmlns:catel="http://schemas.catelproject.com" xmlns:automation="clr-namespace:Orc.Controls.Automation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:converters="clr-namespace:Orc.Controls.Converters" xmlns:xamlbehaviors="http://schemas.microsoft.com/xaml/behaviors" xmlns:orctheming="http://schemas.wildgums.com/orc/theming">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Orc.Theming;component/themes/generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/DirectoryPicker/Themes/DirectoryPicker.generic.xaml" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks as it something wrong with generated xaml

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not be merged dictionaries ...because generated.xaml itself solves a problem with merged dictionaries

<ResourceDictionary Source="/Orc.Controls;component/Controls/OpenFilePicker/Themes/OpenFilePicker.generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="{x:Type local:AlignmentGrid}" TargetType="{x:Type local:AlignmentGrid}" />
<Style x:Key="{x:Type local:AnimatedGif}" TargetType="{x:Type local:AnimatedGif}" />
Expand Down Expand Up @@ -58,7 +60,6 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type local:SaveFilePicker}" TargetType="{x:Type local:SaveFilePicker}" />
<Geometry x:Key="RectangleGeometry">M4,2L20,2C21.1,2 22,2.9 22,4L22,20C22,21.1 21.1,22 20,22L4,22C2.9,22 2,21.1 2,20L2,4C2,2.9 2.9,2 4,2ZM4,4L4,20L20,20L20,4L4,4ZM13,15L11,15L11,17L13,17L13,15ZM13,7L11,7L11,13L13,13L13,7Z</Geometry>
<Geometry x:Key="TriangleGeometry">M2,21.9997L12,2.00026L20.6247,19.2199L20.6291,19.2199L22,21.9997L22,21.9997L22,21.9997L2,21.9997ZM5.0287,19.9997L18.9638,19.9997L12,6.11526L5.0287,19.9997ZM12.9376,16.5456L11.2947,16.5456L11.2947,18.2081L12.9376,18.2081L12.9376,16.5456ZM12.9376,11.5581L11.2947,11.5581L11.2947,14.8831L12.9376,14.8831L12.9376,11.5581Z</Geometry>
<Geometry x:Key="ArrowsOutGeometry">M9.5,13.09L10.91,14.5L6.41,19H10V21H3V14H5V17.59L9.5,13.09M10.91,9.5L9.5,10.91L5,6.41V10H3V3H10V5H6.41L10.91,9.5M14.5,13.09L19,17.59V14H21V21H14V19H17.59L13.09,14.5L14.5,13.09M13.09,9.5L17.59,5H14V3H21V10H19V6.41L14.5,10.91L13.09,9.5Z</Geometry>
Expand Down Expand Up @@ -1481,6 +1482,9 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type local:SaveFilePicker}" TargetType="{x:Type local:SaveFilePicker}">
<Setter Property="Margin" Value="{DynamicResource Margin.TextBox}" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also strange...Margin should be only on Default***Style

</Style>
<Style x:Key="{x:Type local:SpinButton}" TargetType="{x:Type local:SpinButton}" BasedOn="{StaticResource Orc.Styles.Control}">
<Setter Property="Template">
<Setter.Value>
Expand Down
27 changes: 27 additions & 0 deletions src/Orc.Controls/Themes/Theming.defaultstyles.orccontrols.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
<ResourceDictionary Source="/Orc.Controls;component/Controls/ColorLegend/Themes/ColorLegend.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/ColorPicker/Themes/ColorPicker.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/DateTimePicker/Themes/DateTimePicker.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/DirectoryPicker/Themes/DirectoryPicker.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/DropDownButton/Themes/DropDownButton.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/Expander/Themes/Expander.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/FilterBox/Themes/FilterBox.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/FluidProgressBar/Themes/FluidProgressBar.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/FluidProgressBar/Themes/FluidProgressBar.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/FontImage/Themes/FontImage.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/OpenFilePicker/Themes/OpenFilePicker.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/SaveFilePicker/Themes/SaveFilePicker.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/HeaderBar/Themes/HeaderBar.generic.xaml" />
<ResourceDictionary Source="/Orc.Controls;component/Controls/LinkLabel/Themes/LinkLabel.generic.xaml" />
Expand Down Expand Up @@ -417,5 +419,30 @@
BasedOn="{StaticResource {x:Type orccontrols:LogViewerControl}}">
<Setter Property="Margin" Value="{DynamicResource Margin.TextBox}"/>
</Style>

<!-- DirectoryPickerControl -->
<Style x:Key="DefaultDirectoryPickerStyle"
TargetType="{x:Type orccontrols:DirectoryPicker}"
BasedOn="{StaticResource {x:Type orccontrols:DirectoryPicker}}">
<Setter Property="Margin" Value="{DynamicResource Margin.TextBox}" />
<Setter Property="Height" Value="{DynamicResource Size.Height}" />
</Style>

<!-- SaveFilePickerControl -->
<Style x:Key="DefaultSaveFilePickerStyle"
TargetType="{x:Type orccontrols:SaveFilePicker}"
BasedOn="{StaticResource {x:Type orccontrols:SaveFilePicker}}">
<Setter Property="Margin" Value="{DynamicResource Margin.TextBox}" />
<Setter Property="Height" Value="{DynamicResource Size.Height}" />
</Style>

<!-- OpenFilePickerControl -->
<Style x:Key="DefaultOpenFilePickerStyle"
TargetType="{x:Type orccontrols:OpenFilePicker}"
BasedOn="{StaticResource {x:Type orccontrols:OpenFilePicker}}">
<Setter Property="Margin" Value="{DynamicResource Margin.TextBox}" />
<Setter Property="Height" Value="{DynamicResource Size.Height}" />
</Style>


</ResourceDictionary>