Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion src/Glazier.UI/CommandTextBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">

<Border Style="{DynamicResource CommandTextBoxBorder}">
<Border Style="{DynamicResource CommandTextBoxBorder}" AutomationProperties.Name="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InsetText, Mode=OneWay}">
<DockPanel LastChildFill="True">
<Button
x:Name="SearchButton"
DockPanel.Dock="Right"
Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=Command, Mode=OneWay}"
ToolTip="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InsetText, Mode=OneWay}"
AutomationProperties.Name="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InsetText, Mode=OneWay}"
Visibility="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsSingleButton, Mode=OneWay, Converter={StaticResource boolToVisibility}}"
BorderBrush="Transparent"
Background="Transparent"
>
<Image Source="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=CommandIcon, Mode=OneWay}" Style="{DynamicResource Icon}" />
</Button>

<ContentPresenter x:Name="ButtonsPresenter" DockPanel.Dock="Right" />


<Grid>
<TextBlock x:Name="InsetLabel" Style="{DynamicResource CommandTextBoxInsetLabelStyle}">
<Image
Expand Down
55 changes: 53 additions & 2 deletions src/Glazier.UI/CommandTextBox.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Windows;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
Expand Down Expand Up @@ -33,17 +36,22 @@ public partial class CommandTextBox : UserControl
typeof(string), typeof(CommandTextBox), new PropertyMetadata(string.Empty)
);


public static readonly DependencyProperty CommandProperty =
DependencyProperty.Register("Command",
typeof(ICommand), typeof(CommandTextBox), new PropertyMetadata(null)
);

public static readonly DependencyProperty ButtonsProperty =
DependencyProperty.Register("Buttons",
typeof(ObservableCollection<Button>), typeof(CommandTextBox), new PropertyMetadata(null)
);

#endregion

public CommandTextBox()
{
this.InitializeComponent();
this.Buttons = [];
}

#region Dependency Properties (Getters/Setters)
Expand Down Expand Up @@ -78,6 +86,49 @@ public ICommand Command
set { SetValue(CommandProperty, value); }
}

public ObservableCollection<Button> Buttons
{
get { return (ObservableCollection<Button>)GetValue(ButtonsProperty); }
set
{
if (this.Buttons != null)
{
this.Buttons.CollectionChanged -= this.Buttons_CollectionChanged;
}

SetValue(ButtonsProperty, value);

if (value != null)
{
value.CollectionChanged += this.Buttons_CollectionChanged;
}

this.UpdateContentPresenter();
}
}

public bool IsSingleButton => this.Buttons is null || this.Buttons.Count == 0;

private void Buttons_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
this.UpdateContentPresenter();
}

private void UpdateContentPresenter()
{
var panel = new StackPanel { Orientation = Orientation.Horizontal };

foreach (var button in Buttons)
{
var parent = LogicalTreeHelper.GetParent(button) as Panel;
parent?.Children.Remove(button);
panel.Children.Add(button);
}

this.ButtonsPresenter.Content = panel;
this.ButtonsPresenter.UpdateLayout();
}

#endregion
}
}
27 changes: 23 additions & 4 deletions src/Glazier.UI/LoadImageForm.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,31 @@
Margin="0,4,0,0"
InsetText="{x:Static local:Resources.Label_SourceFile}"
InsetIcon="/Images/Icons/FolderOpenBlue.png"
CommandIcon="/Images/Icons/FolderOpened.png"
Command="{Binding BrowseForImageFileCommand}"
Opacity=".7"
UserText="{Binding SourceFilename}"
Visibility="{Binding IsImageNeeded, Converter={StaticResource boolToVisibility}}"
/>
Visibility="{Binding IsImageNeeded, Converter={StaticResource boolToVisibility}}">
<local:CommandTextBox.Buttons>
<Button
Command="{Binding EditSettingsCommand, Mode=OneWay}"
ToolTip="{x:Static local:Resources.Settings}"
AutomationProperties.Name="{x:Static local:Resources.Settings}"
BorderBrush="Transparent"
Background="Transparent"
>
<Image Source="/Images/Icons/Settings.png" Style="{DynamicResource Icon}" />
</Button>

<Button
Command="{Binding BrowseForImageFileCommand, Mode=OneWay}"
ToolTip="{x:Static local:Resources.Label_SourceFile}"
AutomationProperties.Name="{x:Static local:Resources.Label_SourceFile}"
BorderBrush="Transparent"
Background="Transparent"
>
<Image Source="/Images/Icons/FolderOpened.png" Style="{DynamicResource Icon}" />
</Button>
</local:CommandTextBox.Buttons>
</local:CommandTextBox>


<Border Background="{DynamicResource AlgorithmSelectorButtonBackgroundBrush}" Margin="0,40,0,4" CornerRadius="12">
Expand Down
10 changes: 9 additions & 1 deletion src/Glazier.UI/WorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class WorkspaceViewModel : ViewModel
private IThemeListener themeListener;
private IFileDialogProvider dialogProvider;

private DelegateCommand browseForImageFile, saveImageData, viewLargePreviewCommand, viewMaskCommand;
private DelegateCommand browseForImageFile, saveImageData, viewLargePreviewCommand, viewMaskCommand, editSettingsCommand;

#endregion

Expand Down Expand Up @@ -299,6 +299,8 @@ public bool IsMaskVisible

public ICommand ViewMaskCommand => this.viewMaskCommand ??= new(this.ViewMaskImplementation);

public ICommand EditSettingsCommand => this.editSettingsCommand ??= new(this.EditSettingsImplementation);

#endregion


Expand Down Expand Up @@ -511,6 +513,12 @@ internal void ViewLargePreviewImplementation()
previewWindow.ShowDialog();
}

internal void EditSettingsImplementation()
{
this.IsSettingsPageVisible = true;
this.SettingsViewModel.IsSettingsPageOpen = true;
}

#endregion

#region Event Handlers
Expand Down
Loading