Derive nav/content shades from background and make config dialog frameless
This commit is contained in:
@@ -12,9 +12,12 @@
|
||||
MinHeight="540"
|
||||
MinWidth="840"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
UseLayoutRounding="True"
|
||||
SnapsToDevicePixels="True"
|
||||
Background="{DynamicResource backgroundColor}"
|
||||
KeyDown="ConfigInfo_KeyDown"
|
||||
Background="Transparent"
|
||||
Icon="/Customer Panel;component/Resources/icons/logo_CustomerPanel.ico">
|
||||
<Window.Resources>
|
||||
<Style x:Key="ConfigLabelStyle"
|
||||
@@ -103,6 +106,54 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="ConfigHeaderButtonStyle"
|
||||
TargetType="Button">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource navForeground}" />
|
||||
<Setter Property="Background"
|
||||
Value="Transparent" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource inputBorderColor}" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1" />
|
||||
<Setter Property="Width"
|
||||
Value="30" />
|
||||
<Setter Property="Height"
|
||||
Value="30" />
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="ControlBorder"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="9">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter TargetName="ControlBorder"
|
||||
Property="Background"
|
||||
Value="{DynamicResource inactiveButtonColor}" />
|
||||
<Setter TargetName="ControlBorder"
|
||||
Property="BorderBrush"
|
||||
Value="{DynamicResource itemHoverBorderColor}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed"
|
||||
Value="True">
|
||||
<Setter TargetName="ControlBorder"
|
||||
Property="Opacity"
|
||||
Value="0.92" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Margin="14">
|
||||
@@ -119,10 +170,11 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid>
|
||||
<Grid MouseLeftButtonDown="Header_MouseLeftButtonDown">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Orientation="Vertical"
|
||||
VerticalAlignment="Center">
|
||||
@@ -138,10 +190,17 @@
|
||||
<Image Grid.Column="1"
|
||||
Width="150"
|
||||
Height="40"
|
||||
Margin="16,0,0,0"
|
||||
Margin="16,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
Stretch="Uniform"
|
||||
Source="/Customer Panel;component/Resources/consulting4it-header1.png" />
|
||||
<Button Grid.Column="2"
|
||||
Content="X"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
Style="{StaticResource ConfigHeaderButtonStyle}"
|
||||
Click="OnCloseButtonClick"
|
||||
ToolTip="{x:Static resx:Resources.close}" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="2"
|
||||
|
||||
@@ -53,6 +53,23 @@ namespace C4IT_CustomerPanel.forms
|
||||
MessageBox.Show(cc,"Additional Copyrights");
|
||||
}
|
||||
|
||||
private void Header_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
|
||||
DragMove();
|
||||
}
|
||||
|
||||
private void OnCloseButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ConfigInfo_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == System.Windows.Input.Key.Escape)
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
@@ -221,6 +221,37 @@ namespace C4IT_CustomerPanel.libs
|
||||
{
|
||||
return (SolidColorBrush)System.Windows.Application.Current.Resources["backgroundColor"];
|
||||
}
|
||||
|
||||
private static Color BlendColor(Color source, Color target, double amount)
|
||||
{
|
||||
amount = Math.Max(0.0, Math.Min(1.0, amount));
|
||||
return Color.FromArgb(
|
||||
source.A,
|
||||
(byte)Math.Round((source.R * (1.0 - amount)) + (target.R * amount)),
|
||||
(byte)Math.Round((source.G * (1.0 - amount)) + (target.G * amount)),
|
||||
(byte)Math.Round((source.B * (1.0 - amount)) + (target.B * amount)));
|
||||
}
|
||||
|
||||
private static double GetRelativeLuminance(Color color)
|
||||
{
|
||||
return ((0.2126 * color.R) + (0.7152 * color.G) + (0.0722 * color.B)) / 255.0;
|
||||
}
|
||||
|
||||
private static void ApplyBackgroundDerivedResources(Color baseColor)
|
||||
{
|
||||
bool isLightBackground = GetRelativeLuminance(baseColor) >= 0.55;
|
||||
Color panelColor = BlendColor(baseColor, Colors.White, isLightBackground ? 0.06 : 0.08);
|
||||
Color navColor = BlendColor(baseColor, Colors.Black, isLightBackground ? 0.06 : 0.08);
|
||||
Color panelBorder = BlendColor(baseColor, isLightBackground ? Colors.Black : Colors.White, isLightBackground ? 0.16 : 0.22);
|
||||
Color navBorder = BlendColor(baseColor, isLightBackground ? Colors.Black : Colors.White, isLightBackground ? 0.20 : 0.28);
|
||||
|
||||
Application.Current.Resources["backgroundColor"] = new SolidColorBrush(baseColor);
|
||||
Application.Current.Resources["panelBackgroundColor"] = new SolidColorBrush(panelColor);
|
||||
Application.Current.Resources["navigationRailColor"] = new SolidColorBrush(navColor);
|
||||
Application.Current.Resources["panelBorderColor"] = new SolidColorBrush(panelBorder);
|
||||
Application.Current.Resources["navigationRailBorderColor"] = new SolidColorBrush(navBorder);
|
||||
}
|
||||
|
||||
public SolidColorBrush GetHeaderColor()
|
||||
{
|
||||
return (SolidColorBrush)System.Windows.Application.Current.Resources["headerColor"];
|
||||
@@ -958,10 +989,15 @@ namespace C4IT_CustomerPanel.libs
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Windows.Application.Current.Resources["activeButtonColor"] = new SolidColorBrush((Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["activeButtonColor"]));
|
||||
System.Windows.Application.Current.Resources["inactiveButtonColor"] = new SolidColorBrush((Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["inactiveButtonColor"]));
|
||||
System.Windows.Application.Current.Resources["backgroundColor"] = new SolidColorBrush((Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["backgroundColor"]));
|
||||
System.Windows.Application.Current.Resources["headerColor"] = new SolidColorBrush((Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["headerColor"]));
|
||||
Color activeColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["activeButtonColor"]);
|
||||
Color inactiveColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["inactiveButtonColor"]);
|
||||
Color backgroundColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["backgroundColor"]);
|
||||
Color headerColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["headerColor"]);
|
||||
|
||||
System.Windows.Application.Current.Resources["activeButtonColor"] = new SolidColorBrush(activeColor);
|
||||
System.Windows.Application.Current.Resources["inactiveButtonColor"] = new SolidColorBrush(inactiveColor);
|
||||
System.Windows.Application.Current.Resources["headerColor"] = new SolidColorBrush(headerColor);
|
||||
ApplyBackgroundDerivedResources(backgroundColor);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -969,6 +1005,16 @@ namespace C4IT_CustomerPanel.libs
|
||||
cpConfig._uiColors["backgroundColor"] = Properties.Resources.backgroundColor;
|
||||
cpConfig._uiColors["headerColor"] = Properties.Resources.headerColor;
|
||||
cpConfig._uiColors["activeButtonColor"] = Properties.Resources.activeButtonColor;
|
||||
|
||||
Color fallbackActive = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["activeButtonColor"]);
|
||||
Color fallbackInactive = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["inactiveButtonColor"]);
|
||||
Color fallbackBackground = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["backgroundColor"]);
|
||||
Color fallbackHeader = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["headerColor"]);
|
||||
|
||||
System.Windows.Application.Current.Resources["activeButtonColor"] = new SolidColorBrush(fallbackActive);
|
||||
System.Windows.Application.Current.Resources["inactiveButtonColor"] = new SolidColorBrush(fallbackInactive);
|
||||
System.Windows.Application.Current.Resources["headerColor"] = new SolidColorBrush(fallbackHeader);
|
||||
ApplyBackgroundDerivedResources(fallbackBackground);
|
||||
}
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user