Skip to content

Commit

Permalink
Merge pull request #117 from atc-net/feature/DialogBox-Header
Browse files Browse the repository at this point in the history
feat: Improve dialogBox's on HeaderContent
  • Loading branch information
davidkallesen authored Mar 22, 2024
2 parents 0a607ef + 14d175c commit 3881f0e
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:atc="https://github.com/atc-net/atc-wpf/tree/main/schemas"
xmlns:atcTranslation="https://github.com/atc-net/atc-wpf/tree/main/schemas/translations"
xmlns:atcValueConverters="https://github.com/atc-net/atc-wpf/tree/main/schemas/value-converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dialogs="clr-namespace:Atc.Wpf.Theming.Themes.Dialogs;assembly=Atc.Wpf.Theming"
xmlns:local="clr-namespace:Atc.Wpf.Controls.Dialogs"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:settingsControls="clr-namespace:Atc.Wpf.Controls.SettingsControls"
x:Name="DialogApplicationSettings"
Title="{atcTranslation:Resx ResxName=Atc.Wpf.Controls.Resources.Miscellaneous,
Key=ApplicationSettings}"
Title="{Binding Path=TitleBarText}"
Width="550"
Height="300"
Height="360"
d:DataContext="{d:DesignInstance Type=local:BasicApplicationSettingsDialogBoxViewModel}"
ShowCloseButton="False"
ShowMaxRestoreButton="False"
Expand All @@ -22,9 +21,25 @@
WindowStyle="SingleBorderWindow"
mc:Ignorable="d">

<dialogs:NiceDialogBox.Resources>
<atcValueConverters:ObjectNotNullToVisibilityVisibleValueConverter x:Key="ObjectNotNullToVisibilityVisibleValueConverter" />
</dialogs:NiceDialogBox.Resources>

<DockPanel>

<Border
x:Name="ContentTop"
Height="50"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground1}"
BorderBrush="{DynamicResource AtcApps.Brushes.Accent}"
BorderThickness="0,0,0,1"
DockPanel.Dock="Top"
Visibility="{Binding Path=HeaderControl, Converter={StaticResource ObjectNotNullToVisibilityVisibleValueConverter}}">
<ContentControl Content="{Binding Path=HeaderControl}" />
</Border>

<Border
x:Name="ContentButton"
Height="50"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground1}"
BorderBrush="{DynamicResource AtcApps.Brushes.Accent}"
Expand Down Expand Up @@ -55,7 +70,12 @@
</atc:UniformSpacingPanel>
</Border>

<settingsControls:BasicApplicationSettingsView Margin="20" DataContext="{Binding Path=ApplicationSettings}" />
<ScrollViewer x:Name="ContentCenter" Padding="20">
<settingsControls:BasicApplicationSettingsView
Margin="20"
VerticalAlignment="Center"
DataContext="{Binding Path=ApplicationSettings}" />
</ScrollViewer>

</DockPanel>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public BasicApplicationSettingsDialogBoxViewModel(
ApplicationSettings = basicApplicationSettingsViewModel.Clone();
applicationSettingsBackup = basicApplicationSettingsViewModel.Clone();

TitleBarText = Miscellaneous.ApplicationSettings;

ThemeManager.Current.ThemeChanged += OnThemeChanged;
CultureManager.UiCultureChanged += OnUiCultureChanged;
}
Expand All @@ -34,8 +36,27 @@ public BasicApplicationSettingsDialogBoxViewModel(
dataDirectory = applicationDataDirectory;
}

public string TitleBarText { get; set; }

public ContentControl? HeaderControl { get; set; }

public BasicApplicationSettingsViewModel ApplicationSettings { get; set; }

public void SetHeaderControlInsteadOfTitleBarText()
{
TitleBarText = string.Empty;
HeaderControl = new ContentControl
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Content = new TextBlock
{
Text = Miscellaneous.ApplicationSettings,
FontSize = 24,
},
};
}

public string ToJson()
{
var file = new FileInfo(
Expand Down
4 changes: 3 additions & 1 deletion src/Atc.Wpf.Controls/Dialogs/InfoDialogBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@
<DockPanel>

<Border
x:Name="ContentTop"
Height="50"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground1}"
BorderBrush="{DynamicResource AtcApps.Brushes.Accent}"
BorderThickness="0,0,0,1"
DockPanel.Dock="Top"
Visibility="{Binding Path=HeaderControl, Converter={StaticResource ObjectNotNullToVisibilityVisibleValueConverter}}">
<ContentControl Margin="30" Content="{Binding Path=HeaderControl}" />
<ContentControl Content="{Binding Path=HeaderControl}" />
</Border>

<Border
x:Name="ContentButton"
Height="50"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground1}"
BorderBrush="{DynamicResource AtcApps.Brushes.Accent}"
Expand Down
22 changes: 22 additions & 0 deletions src/Atc.Wpf.Controls/Dialogs/InfoDialogBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ public InfoDialogBox(
Settings.TitleBarText = titleBarText;
}

public InfoDialogBox(
Window owningWindow,
string titleBarText,
string headerText,
string contentText)
: this(
owningWindow,
titleBarText,
contentText)
{
HeaderControl = new ContentControl
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Content = new TextBlock
{
Text = headerText,
FontSize = 24,
},
};
}

public InfoDialogBox(
Window owningWindow,
DialogBoxSettings settings,
Expand Down
4 changes: 3 additions & 1 deletion src/Atc.Wpf.Controls/Dialogs/InputDialogBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@
<DockPanel>

<Border
x:Name="ContentTop"
Height="50"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground1}"
BorderBrush="{DynamicResource AtcApps.Brushes.Accent}"
BorderThickness="0,0,0,1"
DockPanel.Dock="Top"
Visibility="{Binding Path=HeaderControl, Converter={StaticResource ObjectNotNullToVisibilityVisibleValueConverter}}">
<ContentControl Margin="30" Content="{Binding Path=HeaderControl}" />
<ContentControl Content="{Binding Path=HeaderControl}" />
</Border>

<Border
x:Name="ContentButton"
Height="50"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground1}"
BorderBrush="{DynamicResource AtcApps.Brushes.Accent}"
Expand Down
22 changes: 22 additions & 0 deletions src/Atc.Wpf.Controls/Dialogs/InputDialogBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ public InputDialogBox(
Settings.TitleBarText = titleBarText;
}

public InputDialogBox(
Window owningWindow,
string titleBarText,
string headerText,
ILabelControlBase labelControl)
: this(
owningWindow,
titleBarText,
labelControl)
{
HeaderControl = new ContentControl
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Content = new TextBlock
{
Text = headerText,
FontSize = 24,
},
};
}

public InputDialogBox(
Window owningWindow,
DialogBoxSettings settings,
Expand Down
2 changes: 1 addition & 1 deletion src/Atc.Wpf.Controls/Dialogs/InputFormDialogBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
BorderThickness="0,0,0,1"
DockPanel.Dock="Top"
Visibility="{Binding Path=HeaderControl, Converter={StaticResource ObjectNotNullToVisibilityVisibleValueConverter}}">
<ContentControl Margin="30" Content="{Binding Path=HeaderControl}" />
<ContentControl Content="{Binding Path=HeaderControl}" />
</Border>

<Border
Expand Down
24 changes: 24 additions & 0 deletions src/Atc.Wpf.Controls/Dialogs/InputFormDialogBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ public InputFormDialogBox(
Settings.TitleBarText = titleBarText;
}

public InputFormDialogBox(
Window owningWindow,
string titleBarText,
string headerText,
ILabelControlsForm labelControlsForm)
: this(
owningWindow,
titleBarText,
labelControlsForm)
{
HeaderControl = new ContentControl
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Content = new TextBlock
{
Text = headerText,
FontSize = 24,
},
};

UpdateWidthAndHeight();
}

public InputFormDialogBox(
Window owningWindow,
LabelInputFormPanelSettings formPanelSettings,
Expand Down
5 changes: 4 additions & 1 deletion src/Atc.Wpf.Controls/Dialogs/QuestionDialogBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@
<DockPanel>

<Border
x:Name="ContentTop"
Height="50"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground1}"
BorderBrush="{DynamicResource AtcApps.Brushes.Accent}"
BorderThickness="0,0,0,1"
DockPanel.Dock="Top"
Visibility="{Binding Path=HeaderControl, Converter={StaticResource ObjectNotNullToVisibilityVisibleValueConverter}}">
<ContentControl Margin="30" Content="{Binding Path=HeaderControl}" />
<ContentControl Content="{Binding Path=HeaderControl}" />
</Border>

<Border
x:Name="ContentButton"
Height="50"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground1}"
BorderBrush="{DynamicResource AtcApps.Brushes.Accent}"
Expand Down
22 changes: 22 additions & 0 deletions src/Atc.Wpf.Controls/Dialogs/QuestionDialogBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ public QuestionDialogBox(
Settings.TitleBarText = titleBarText;
}

public QuestionDialogBox(
Window owningWindow,
string titleBarText,
string headerText,
string contentText)
: this(
owningWindow,
titleBarText,
contentText)
{
HeaderControl = new ContentControl
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Content = new TextBlock
{
Text = headerText,
FontSize = 24,
},
};
}

public QuestionDialogBox(
Window owningWindow,
DialogBoxSettings settings,
Expand Down

0 comments on commit 3881f0e

Please sign in to comment.