mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Icons work again
Colors work again
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ModernKeePass.Extensions;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
@@ -9,19 +10,15 @@ namespace ModernKeePass.Converters
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var color = value is Color ? (Color?) value : Color.Empty;
|
||||
var color = value as Color? ?? Color.Empty;
|
||||
if (color == Color.Empty && parameter is SolidColorBrush) return (SolidColorBrush) parameter;
|
||||
return new SolidColorBrush(Windows.UI.Color.FromArgb(
|
||||
color.Value.A,
|
||||
color.Value.R,
|
||||
color.Value.G,
|
||||
color.Value.B));
|
||||
return color.ToSolidColorBrush();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var brush = value as SolidColorBrush;
|
||||
return brush == null ? new Color() : Color.FromArgb(brush.Color.A, brush.Color.R, brush.Color.G, brush.Color.B);
|
||||
return brush?.ToColor() ?? new Color();
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,7 +9,8 @@ namespace ModernKeePass.Converters
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var icon = (Icon)value;
|
||||
return Enum.Parse(typeof(Symbol), value.ToString());
|
||||
/*var icon = (Icon)value;
|
||||
switch (icon)
|
||||
{
|
||||
case Icon.Delete: return Symbol.Delete;
|
||||
@@ -62,12 +63,12 @@ namespace ModernKeePass.Converters
|
||||
case Icon.Stop: return Symbol.Stop;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var symbol = (Symbol)value;
|
||||
/*var symbol = (Symbol)value;
|
||||
var defaultIcon = parameter != null ? int.Parse(parameter as string) : -1;
|
||||
switch (symbol)
|
||||
{
|
||||
@@ -120,7 +121,9 @@ namespace ModernKeePass.Converters
|
||||
case Symbol.ReportHacked: return Icon.ReportHacked;
|
||||
case Symbol.Stop: return Icon.Stop;
|
||||
default: return defaultIcon;
|
||||
}
|
||||
}*/
|
||||
|
||||
return Enum.Parse(typeof(Icon), value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
18
ModernKeePass/Extensions/ColorExtensions.cs
Normal file
18
ModernKeePass/Extensions/ColorExtensions.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Drawing;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace ModernKeePass.Extensions
|
||||
{
|
||||
public static class ColorExtensions
|
||||
{
|
||||
public static Color ToColor(this SolidColorBrush brush)
|
||||
{
|
||||
return Color.FromArgb(brush.Color.A, brush.Color.R, brush.Color.G, brush.Color.B);
|
||||
}
|
||||
|
||||
public static SolidColorBrush ToSolidColorBrush(this Color color)
|
||||
{
|
||||
return new SolidColorBrush(Windows.UI.Color.FromArgb(color.A, color.R, color.G, color.B));
|
||||
}
|
||||
}
|
||||
}
|
@@ -244,6 +244,22 @@
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{TemplateBinding ButtonTooltip}" />
|
||||
</ToolTipService.ToolTip>
|
||||
<!--<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
<VisualState x:Name="MouseOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Cursor)">
|
||||
<DiscreteObjectKeyFrame KeyTime="00:00:00">
|
||||
<DiscreteObjectKeyFrame.Value>
|
||||
<Cursor>Hand</Cursor>
|
||||
</DiscreteObjectKeyFrame.Value>
|
||||
</DiscreteObjectKeyFrame>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>-->
|
||||
</Button>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||
@@ -23,6 +23,7 @@ using ModernKeePass.Domain.Enums;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Extensions;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
@@ -64,8 +65,8 @@ namespace ModernKeePass.ViewModels
|
||||
get { return _entry.Title; }
|
||||
set
|
||||
{
|
||||
SetFieldValue(nameof(Title), value).Wait();
|
||||
_entry.Title = value;
|
||||
SetFieldValue(nameof(Title), value).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +81,8 @@ namespace ModernKeePass.ViewModels
|
||||
get { return _entry.Password; }
|
||||
set
|
||||
{
|
||||
SetFieldValue(nameof(Password), value).Wait();
|
||||
_entry.Password = value;
|
||||
SetFieldValue(nameof(Password), value).Wait();
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(PasswordComplexityIndicator));
|
||||
}
|
||||
@@ -92,8 +93,8 @@ namespace ModernKeePass.ViewModels
|
||||
get { return _entry.Url?.ToString(); }
|
||||
set
|
||||
{
|
||||
SetFieldValue(nameof(Url), value).Wait();
|
||||
_entry.Url = new Uri(value);
|
||||
SetFieldValue(nameof(Url), value).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,22 +103,18 @@ namespace ModernKeePass.ViewModels
|
||||
get { return _entry.Notes; }
|
||||
set
|
||||
{
|
||||
SetFieldValue(nameof(Notes), value).Wait();
|
||||
_entry.Notes = value;
|
||||
SetFieldValue(nameof(Notes), value).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public Symbol Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
if (HasExpired) return Symbol.ReportHacked;
|
||||
return (Symbol) _entry.Icon;
|
||||
}
|
||||
get { return (Symbol)Enum.Parse(typeof(Symbol), _entry.Icon.ToString()); }
|
||||
set
|
||||
{
|
||||
SetFieldValue(nameof(Icon), value).Wait();
|
||||
_entry.Icon = (Icon)value;
|
||||
_entry.Icon = (Icon)Enum.Parse(typeof(Icon), value.ToString());
|
||||
SetFieldValue(nameof(Icon), _entry.Icon).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,8 +125,8 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
if (!HasExpirationDate) return;
|
||||
|
||||
SetFieldValue("ExpirationDate", value).Wait();
|
||||
_entry.ExpirationDate = value.Date;
|
||||
SetFieldValue("ExpirationDate", _entry.ExpirationDate).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,8 +137,8 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
if (!HasExpirationDate) return;
|
||||
|
||||
SetFieldValue("ExpirationDate", value).Wait();
|
||||
_entry.ExpirationDate = _entry.ExpirationDate.Date.Add(value);
|
||||
SetFieldValue("ExpirationDate", _entry.ExpirationDate).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,35 +147,29 @@ namespace ModernKeePass.ViewModels
|
||||
get { return _entry.HasExpirationDate; }
|
||||
set
|
||||
{
|
||||
SetFieldValue(nameof(HasExpirationDate), value).Wait();
|
||||
_entry.HasExpirationDate = value;
|
||||
OnPropertyChanged();
|
||||
SetFieldValue(nameof(HasExpirationDate), value).Wait();
|
||||
OnPropertyChanged(nameof(HasExpirationDate));
|
||||
}
|
||||
}
|
||||
|
||||
public Color? BackgroundColor
|
||||
public SolidColorBrush BackgroundColor
|
||||
{
|
||||
get { return _entry?.BackgroundColor; }
|
||||
get { return _entry?.BackgroundColor.ToSolidColorBrush(); }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
SetFieldValue(nameof(BackgroundColor), value).Wait();
|
||||
_entry.BackgroundColor = (Color)value;
|
||||
}
|
||||
_entry.BackgroundColor = value.ToColor();
|
||||
SetFieldValue(nameof(BackgroundColor), _entry.BackgroundColor).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public Color? ForegroundColor
|
||||
public SolidColorBrush ForegroundColor
|
||||
{
|
||||
get { return _entry?.ForegroundColor; }
|
||||
get { return _entry?.ForegroundColor.ToSolidColorBrush(); }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
SetFieldValue(nameof(ForegroundColor), value).Wait();
|
||||
_entry.ForegroundColor = (Color)value;
|
||||
}
|
||||
_entry.ForegroundColor = value.ToColor();
|
||||
SetFieldValue(nameof(ForegroundColor), _entry.ForegroundColor).Wait();
|
||||
}
|
||||
}
|
||||
public IEnumerable<EntryVm> History { get; }
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
@@ -67,8 +68,8 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public Symbol Icon
|
||||
{
|
||||
get { return (Symbol) _group.Icon; }
|
||||
set { _group.Icon = (Icon)value; }
|
||||
get { return (Symbol) Enum.Parse(typeof(Symbol), _group.Icon.ToString()); }
|
||||
set { _group.Icon = (Icon) Enum.Parse(typeof(Icon), value.ToString()); }
|
||||
}
|
||||
|
||||
public bool IsEditMode
|
||||
|
@@ -19,7 +19,6 @@
|
||||
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" />
|
||||
<converters:ProgressBarLegalValuesConverter x:Key="ProgressBarLegalValuesConverter" />
|
||||
<converters:DoubleToSolidColorBrushConverter x:Key="DoubleToForegroundBrushComplexityConverter" />
|
||||
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter" />
|
||||
<converters:IconToSymbolConverter x:Key="IconToSymbolConverter"/>
|
||||
<Style TargetType="PasswordBox" x:Name="PasswordBoxWithButtonStyle">
|
||||
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
|
||||
@@ -460,11 +459,11 @@
|
||||
<StackPanel x:Name="EditDesign" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}" Orientation="Horizontal">
|
||||
<StackPanel Width="250" HorizontalAlignment="Left">
|
||||
<TextBlock x:Uid="EntryBackgroundColor" />
|
||||
<userControls:ColorPickerUserControl SelectedColor="{Binding BackgroundColor, Converter={StaticResource ColorToBrushConverter}, Mode=TwoWay}" IsEnabled="{Binding IsSelected}" />
|
||||
<userControls:ColorPickerUserControl SelectedColor="{Binding BackgroundColor, Mode=TwoWay}" IsEnabled="{Binding IsSelected}" />
|
||||
</StackPanel>
|
||||
<StackPanel Width="250" HorizontalAlignment="Left">
|
||||
<TextBlock x:Uid="EntryForegroundColor" />
|
||||
<userControls:ColorPickerUserControl SelectedColor="{Binding ForegroundColor, Converter={StaticResource ColorToBrushConverter}, Mode=TwoWay}" IsEnabled="{Binding IsSelected}" />
|
||||
<userControls:ColorPickerUserControl SelectedColor="{Binding ForegroundColor, Mode=TwoWay}" IsEnabled="{Binding IsSelected}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
@@ -497,13 +496,14 @@
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="20" />
|
||||
</Grid.RowDefinitions>
|
||||
<Viewbox MaxHeight="30" Width="50" Grid.Column="0" Grid.Row="0" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<userControls:SymbolPickerUserControl Width="80" Height="40" SelectedSymbol="{Binding Icon, Mode=TwoWay}" />
|
||||
<Viewbox MaxHeight="200" Width="200" Grid.Column="0" Grid.Row="0" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<userControls:SymbolPickerUserControl Width="100" Height="70" SelectedSymbol="{Binding Icon, Mode=TwoWay}" />
|
||||
</Viewbox>
|
||||
<Viewbox MaxHeight="30" Width="50" Grid.Column="0" Grid.Row="0" Visibility="{Binding IsEditMode, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
|
||||
<SymbolIcon Symbol="{Binding Icon, Converter={StaticResource IconToSymbolConverter}}" Width="80" Height="40" />
|
||||
<Viewbox MaxHeight="200" Width="200" Grid.Column="0" Grid.Row="0" Visibility="{Binding IsEditMode, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
|
||||
<SymbolIcon Symbol="{Binding Icon}" Width="100" Height="70" />
|
||||
</Viewbox>
|
||||
<TextBox Grid.Column="1" Grid.Row="0"
|
||||
x:Name="TitleTextBox"
|
||||
Text="{Binding Title, Mode=TwoWay}"
|
||||
Foreground="{ThemeResource DefaultTextForegroundThemeBrush}"
|
||||
Background="Transparent"
|
||||
|
@@ -205,11 +205,11 @@
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="20" />
|
||||
</Grid.RowDefinitions>
|
||||
<Viewbox MaxHeight="30" Width="50" Grid.Column="0" Grid.Row="0" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<userControls:SymbolPickerUserControl Width="80" Height="40" SelectedSymbol="{Binding Icon, Mode=TwoWay}" />
|
||||
<Viewbox MaxHeight="200" Width="200" Grid.Column="0" Grid.Row="0" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<userControls:SymbolPickerUserControl Width="100" Height="70" SelectedSymbol="{Binding Icon, Mode=TwoWay}" />
|
||||
</Viewbox>
|
||||
<Viewbox MaxHeight="30" Width="50" Grid.Column="0" Grid.Row="0" Visibility="{Binding IsEditMode, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
|
||||
<SymbolIcon Symbol="{Binding Icon, Converter={StaticResource IconToSymbolConverter}}" Width="80" Height="40" />
|
||||
<Viewbox MaxHeight="200" Width="200" Grid.Column="0" Grid.Row="0" Visibility="{Binding IsEditMode, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
|
||||
<SymbolIcon Symbol="{Binding Icon}" Width="100" Height="70" />
|
||||
</Viewbox>
|
||||
<TextBox Grid.Column="1" Grid.Row="0"
|
||||
x:Name="TitleTextBox"
|
||||
|
@@ -5,12 +5,18 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<ComboBox x:Name="ComboBox" ItemsSource="{Binding Symbols, ElementName=UserControl}" SelectedItem="{Binding SelectedSymbol, ElementName=UserControl, Mode=TwoWay}" Loaded="ComboBox_OnLoaded" ItemContainerStyle="{StaticResource MainColorComboBoxItem}" Style="{StaticResource MainColorComboBox}">
|
||||
<ComboBox
|
||||
x:Name="ComboBox"
|
||||
ItemsSource="{Binding Symbols, ElementName=UserControl}"
|
||||
SelectedItem="{Binding SelectedSymbol, ElementName=UserControl, Mode=TwoWay}"
|
||||
Loaded="ComboBox_OnLoaded"
|
||||
ItemContainerStyle="{StaticResource MainColorComboBoxItem}"
|
||||
Style="{StaticResource MainColorComboBox}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,10,0">
|
||||
<Border>
|
||||
<SymbolIcon Symbol="{Binding}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
@@ -43,7 +43,7 @@
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<StackPanel x:Name="OverflowButtons" Orientation="Horizontal">
|
||||
<Button Command="{Binding MoveCommand, ElementName=UserControl}" IsEnabled="{Binding IsMoveButtonEnabled, ElementName=UserControl}" Click="MoveButton_Click" Style="{StaticResource MenuButtonStyle}">
|
||||
<SymbolIcon Symbol="Undo">
|
||||
<SymbolIcon Symbol="MoveToFolder">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip x:Uid="TopMenuMoveButton" />
|
||||
</ToolTipService.ToolTip>
|
||||
|
@@ -101,6 +101,7 @@
|
||||
<Compile Include="Common\ResourceHelper.cs" />
|
||||
<Compile Include="Converters\IconToSymbolConverter.cs" />
|
||||
<Compile Include="DependencyInjection.cs" />
|
||||
<Compile Include="Extensions\ColorExtensions.cs" />
|
||||
<Compile Include="TemplateSelectors\SelectableDataTemplateSelector.cs" />
|
||||
<Compile Include="ViewModels\Items\SettingsSaveVm.cs" />
|
||||
<Compile Include="Views\MainPageFrames\DonatePage.xaml.cs">
|
||||
|
Reference in New Issue
Block a user