mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
New color to brush converter
New boolean to visibility converter Base class to handle property changes notifications for all View Models Template selector to handle a different first item in listviews or gridviews
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
MainPackage=C:\Users\bg45\source\repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.1.0.6_AnyCPU.appx
|
MainPackage=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.1.0.10_AnyCPU.appx
|
||||||
SymbolPackage=C:\Users\bg45\source\repos\ModernKeePass\ModernKeePass\AppPackages\ModernKeePass_1.1.0.6_Test\ModernKeePass_1.1.0.6_AnyCPU.appxsym
|
SymbolPackage=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\AppPackages\ModernKeePass_1.1.0.10_Test\ModernKeePass_1.1.0.10_AnyCPU.appxsym
|
||||||
ResourcePack=C:\Users\bg45\source\repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.1.0.6_scale-140.appx
|
ResourcePack=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.1.0.10_scale-140.appx
|
||||||
ResourcePack=C:\Users\bg45\source\repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.1.0.6_scale-180.appx
|
ResourcePack=C:\Users\GBE\Source\Repos\ModernKeePass\ModernKeePass\bin\Release\ModernKeePass_1.1.0.10_scale-180.appx
|
||||||
|
28
ModernKeePass/Common/NotifyPropertyChangedBase.cs
Normal file
28
ModernKeePass/Common/NotifyPropertyChangedBase.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace ModernKeePass.Common
|
||||||
|
{
|
||||||
|
public class NotifyPropertyChangedBase : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
||||||
|
{
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool SetProperty<T>(ref T property, T value, [CallerMemberName] string propertyName = "")
|
||||||
|
{
|
||||||
|
if (EqualityComparer<T>.Default.Equals(property, value))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
property = value;
|
||||||
|
OnPropertyChanged(propertyName);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -46,6 +46,14 @@ namespace ModernKeePass.Common
|
|||||||
this.Add(item.Key, item.Value);
|
this.Add(item.Key, item.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddRange(IEnumerable<KeyValuePair<string, object>> values)
|
||||||
|
{
|
||||||
|
foreach (var value in values)
|
||||||
|
{
|
||||||
|
Add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool Remove(string key)
|
public bool Remove(string key)
|
||||||
{
|
{
|
||||||
if (this._dictionary.Remove(key))
|
if (this._dictionary.Remove(key))
|
||||||
|
18
ModernKeePass/Controls/FirstItemDataTemplateSelector.cs
Normal file
18
ModernKeePass/Controls/FirstItemDataTemplateSelector.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
|
||||||
|
namespace ModernKeePass.Controls
|
||||||
|
{
|
||||||
|
public class FirstItemDataTemplateSelector: DataTemplateSelector
|
||||||
|
{
|
||||||
|
public DataTemplate FirstItem { get; set; }
|
||||||
|
public DataTemplate OtherItem { get; set; }
|
||||||
|
|
||||||
|
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
|
||||||
|
{
|
||||||
|
var itemsControl = ItemsControl.ItemsControlFromItemContainer(container);
|
||||||
|
var returnTemplate = itemsControl.IndexFromContainer(container) == 0 ? FirstItem : OtherItem;
|
||||||
|
return returnTemplate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
ModernKeePass/Converters/BooleanToVisibilityConverter.cs
Normal file
28
ModernKeePass/Converters/BooleanToVisibilityConverter.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Data;
|
||||||
|
|
||||||
|
namespace ModernKeePass.Converters
|
||||||
|
{
|
||||||
|
public class BooleanToVisibilityConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
var boolean = value is bool ? (bool) value : false;
|
||||||
|
return boolean ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No need to implement this
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
var visibility = value is Visibility ? (Visibility) value : Visibility.Visible;
|
||||||
|
switch (visibility)
|
||||||
|
{
|
||||||
|
case Visibility.Visible: return true;
|
||||||
|
case Visibility.Collapsed: return false;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
ModernKeePass/Converters/ColorToBrushConverter.cs
Normal file
26
ModernKeePass/Converters/ColorToBrushConverter.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using Windows.UI.Xaml.Data;
|
||||||
|
using Windows.UI.Xaml.Media;
|
||||||
|
|
||||||
|
namespace ModernKeePass.Converters
|
||||||
|
{
|
||||||
|
public class ColorToBrushConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
var color = value is Color ? (Color?) value : 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Windows.UI.Xaml.Data;
|
using Windows.UI.Xaml.Data;
|
||||||
|
|
||||||
namespace ModernKeePass.Converters
|
namespace ModernKeePass.Converters
|
||||||
|
@@ -14,7 +14,8 @@
|
|||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<CollectionViewSource
|
<CollectionViewSource
|
||||||
x:Name="MenuItemsSource"
|
x:Name="MenuItemsSource"
|
||||||
Source="{Binding MainMenuItems}" IsSourceGrouped="True" />
|
Source="{Binding MainMenuItems}"
|
||||||
|
IsSourceGrouped="True" />
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
|
||||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" >
|
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" >
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Windows.Storage.AccessCache;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
@@ -32,11 +33,23 @@ namespace ModernKeePass
|
|||||||
};
|
};
|
||||||
var app = (App)Application.Current;
|
var app = (App)Application.Current;
|
||||||
if (app.Database != null && app.Database.IsOpen)
|
if (app.Database != null && app.Database.IsOpen)
|
||||||
mainMenuItems.Add(new MainMenuItemVm { Title = app.Database.Name, PageType = typeof(GroupDetailPage), Destination = Frame, Parameter = app.Database.RootGroup, Group = 1, SymbolIcon = Symbol.ProtectedDocument});
|
mainMenuItems.Add(new MainMenuItemVm
|
||||||
|
{
|
||||||
|
Title = app.Database.Name,
|
||||||
|
PageType = typeof(GroupDetailPage),
|
||||||
|
Destination = Frame,
|
||||||
|
Parameter = app.Database.RootGroup,
|
||||||
|
Group = 1,
|
||||||
|
SymbolIcon = Symbol.ProtectedDocument
|
||||||
|
});
|
||||||
var mainVm = DataContext as MainVm;
|
var mainVm = DataContext as MainVm;
|
||||||
mainVm.MainMenuItems = from item in mainMenuItems group item by item.Group into grp orderby grp.Key select grp;
|
mainVm.MainMenuItems = from item in mainMenuItems group item by item.Group into grp orderby grp.Key select grp;
|
||||||
mainVm.NotifyPropertyChanged("MainMenuItems");
|
/*if (app.Database == null || !app.Database.IsOpen)
|
||||||
|
{
|
||||||
|
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
||||||
|
if (mru.Entries.Count > 0) MenuListView.SelectedIndex = 3;
|
||||||
|
}*/
|
||||||
|
//mainVm.NotifyPropertyChanged("MainMenuItems");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
@@ -112,13 +112,17 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Common\DatabaseHelper.cs" />
|
<Compile Include="Common\DatabaseHelper.cs" />
|
||||||
<Compile Include="Common\NavigationHelper.cs" />
|
<Compile Include="Common\NavigationHelper.cs" />
|
||||||
|
<Compile Include="Common\NotifyPropertyChangedBase.cs" />
|
||||||
<Compile Include="Common\ObservableDictionary.cs" />
|
<Compile Include="Common\ObservableDictionary.cs" />
|
||||||
<Compile Include="Common\RelayCommand.cs" />
|
<Compile Include="Common\RelayCommand.cs" />
|
||||||
<Compile Include="Common\SuspensionManager.cs" />
|
<Compile Include="Common\SuspensionManager.cs" />
|
||||||
|
<Compile Include="Controls\FirstItemDataTemplateSelector.cs" />
|
||||||
<Compile Include="Controls\ListViewWithDisable.cs" />
|
<Compile Include="Controls\ListViewWithDisable.cs" />
|
||||||
<Compile Include="Controls\OpenDatabaseUserControl.xaml.cs">
|
<Compile Include="Controls\OpenDatabaseUserControl.xaml.cs">
|
||||||
<DependentUpon>OpenDatabaseUserControl.xaml</DependentUpon>
|
<DependentUpon>OpenDatabaseUserControl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Converters\BooleanToVisibilityConverter.cs" />
|
||||||
|
<Compile Include="Converters\ColorToBrushConverter.cs" />
|
||||||
<Compile Include="Converters\PluralizationConverter.cs" />
|
<Compile Include="Converters\PluralizationConverter.cs" />
|
||||||
<Compile Include="Interfaces\IIsEnabled.cs" />
|
<Compile Include="Interfaces\IIsEnabled.cs" />
|
||||||
<Compile Include="MainPage.xaml.cs">
|
<Compile Include="MainPage.xaml.cs">
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
|
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
|
||||||
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.1.0.9" />
|
<Identity Name="wismna.ModernKeePass" Publisher="CN=0719A91A-C322-4EE0-A257-E60733EECF06" Version="1.1.0.10" />
|
||||||
<Properties>
|
<Properties>
|
||||||
<DisplayName>ModernKeePass</DisplayName>
|
<DisplayName>ModernKeePass</DisplayName>
|
||||||
<PublisherDisplayName>wismna</PublisherDisplayName>
|
<PublisherDisplayName>wismna</PublisherDisplayName>
|
||||||
|
@@ -5,16 +5,56 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||||
xmlns:converters="using:ModernKeePass.Converters"
|
xmlns:converters="using:ModernKeePass.Converters"
|
||||||
|
xmlns:local="using:ModernKeePass.Controls"
|
||||||
x:Name="PageRoot"
|
x:Name="PageRoot"
|
||||||
x:Class="ModernKeePass.Pages.GroupDetailPage"
|
x:Class="ModernKeePass.Pages.GroupDetailPage"
|
||||||
mc:Ignorable="d" >
|
mc:Ignorable="d" >
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
|
<SolidColorBrush x:Key="Transparent" Color="Transparent"/>
|
||||||
|
<SolidColorBrush x:Key="White" Color="White"/>
|
||||||
|
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
|
||||||
<converters:PluralizationConverter x:Key="PluralizationConverter"/>
|
<converters:PluralizationConverter x:Key="PluralizationConverter"/>
|
||||||
|
<DataTemplate x:Name="GroupFirstItem">
|
||||||
|
<Border
|
||||||
|
BorderThickness="2"
|
||||||
|
BorderBrush="DimGray"
|
||||||
|
Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
|
||||||
|
Margin="0,10,0,0" >
|
||||||
|
<Grid Height="110" Width="480" >
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<SymbolIcon Grid.Column="0" Symbol="{Binding IconSymbol}" Width="100" Height="100" />
|
||||||
|
<TextBlock Grid.Column="1" Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap" VerticalAlignment="Center" Margin="13,0,0,5"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
<DataTemplate x:Name="GroupOtherItem">
|
||||||
|
<Border
|
||||||
|
BorderThickness="2"
|
||||||
|
BorderBrush="DimGray"
|
||||||
|
Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
|
||||||
|
Margin="0,10,0,0" >
|
||||||
|
<Grid Height="110" Width="480" >
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<SymbolIcon Grid.Column="0" Symbol="{Binding IconSymbol}" Width="100" Height="100" />
|
||||||
|
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0" >
|
||||||
|
<TextBlock Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap"/>
|
||||||
|
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap"/>
|
||||||
|
<TextBlock Text="{Binding EntryCount, ConverterParameter=entry\,entries, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
|
||||||
|
<TextBlock Text="{Binding GroupCount, ConverterParameter=group\,groups, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
<Page.DataContext>
|
<Page.DataContext>
|
||||||
<viewModels:GroupVm />
|
<viewModels:GroupVm />
|
||||||
</Page.DataContext>
|
</Page.DataContext>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Resources>
|
<Grid.Resources>
|
||||||
<CollectionViewSource
|
<CollectionViewSource
|
||||||
@@ -47,30 +87,11 @@
|
|||||||
IsSwipeEnabled="false"
|
IsSwipeEnabled="false"
|
||||||
SelectionChanged="groups_SelectionChanged"
|
SelectionChanged="groups_SelectionChanged"
|
||||||
IsSynchronizedWithCurrentItem="False" >
|
IsSynchronizedWithCurrentItem="False" >
|
||||||
<GridView.ItemTemplate>
|
<GridView.ItemTemplateSelector>
|
||||||
<DataTemplate>
|
<local:FirstItemDataTemplateSelector
|
||||||
<Border
|
FirstItem="{StaticResource GroupFirstItem}"
|
||||||
BorderThickness="2"
|
OtherItem="{StaticResource GroupOtherItem}" />
|
||||||
BorderBrush="DimGray"
|
</GridView.ItemTemplateSelector>
|
||||||
Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
|
|
||||||
Margin="0,10,0,0" >
|
|
||||||
<Grid Height="110" Width="480" >
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<SymbolIcon Grid.Column="0" Symbol="{Binding IconSymbol}" Width="100" Height="100" />
|
|
||||||
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0" Visibility="{Binding DetailsVisibility}" >
|
|
||||||
<TextBlock Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap"/>
|
|
||||||
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap"/>
|
|
||||||
<TextBlock Text="{Binding EntryCount, ConverterParameter=entry\,entries, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
|
|
||||||
<TextBlock Text="{Binding GroupCount, ConverterParameter=group\,groups, Converter={StaticResource PluralizationConverter}}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
|
|
||||||
</StackPanel>
|
|
||||||
<TextBlock Grid.Column="1" Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap" Visibility="{Binding NewVisibility}" VerticalAlignment="Center" Margin="13,0,0,5"/>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</DataTemplate>
|
|
||||||
</GridView.ItemTemplate>
|
|
||||||
<GridView.Header>
|
<GridView.Header>
|
||||||
<ListView
|
<ListView
|
||||||
Height="auto"
|
Height="auto"
|
||||||
@@ -82,9 +103,18 @@
|
|||||||
IsSynchronizedWithCurrentItem="False" >
|
IsSynchronizedWithCurrentItem="False" >
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal" Background="{Binding BackgroundColor}">
|
<StackPanel
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Background="{Binding BackgroundColor, ConverterParameter={StaticResource Transparent}, Converter={StaticResource ColorToBrushConverter}}">
|
||||||
<SymbolIcon Symbol="{Binding IconSymbol}" />
|
<SymbolIcon Symbol="{Binding IconSymbol}" />
|
||||||
<TextBlock Text="{Binding Title}" FontWeight="{Binding FontWeight}" TextWrapping="NoWrap" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="30,0,0,0" Foreground="{Binding ForegroundColor}"/>
|
<TextBlock
|
||||||
|
Text="{Binding Title}"
|
||||||
|
FontWeight="{Binding FontWeight}"
|
||||||
|
TextWrapping="NoWrap"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="30,0,0,0"
|
||||||
|
Foreground="{Binding ForegroundColor, ConverterParameter={StaticResource White}, Converter={StaticResource ColorToBrushConverter}}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
@@ -117,14 +147,16 @@
|
|||||||
IsSynchronizedWithCurrentItem="False" >
|
IsSynchronizedWithCurrentItem="False" >
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Name}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap"/>
|
<TextBlock
|
||||||
|
Text="{Binding Name}"
|
||||||
|
Style="{StaticResource TitleTextBlockStyle}"
|
||||||
|
TextWrapping="NoWrap"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</ListView>
|
</ListView>
|
||||||
</SemanticZoom.ZoomedOutView>
|
</SemanticZoom.ZoomedOutView>
|
||||||
</SemanticZoom>
|
</SemanticZoom>
|
||||||
|
|
||||||
|
|
||||||
<!-- Back button and page title -->
|
<!-- Back button and page title -->
|
||||||
<Grid Grid.Row="0">
|
<Grid Grid.Row="0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -132,17 +164,31 @@
|
|||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="200"/>
|
<ColumnDefinition Width="200"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
<Button Margin="39,59,39,0"
|
||||||
|
Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
|
||||||
Style="{StaticResource NavigationBackButtonNormalStyle}"
|
Style="{StaticResource NavigationBackButtonNormalStyle}"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AutomationProperties.Name="Back"
|
AutomationProperties.Name="Back"
|
||||||
AutomationProperties.AutomationId="BackButton"
|
AutomationProperties.AutomationId="BackButton"
|
||||||
AutomationProperties.ItemType="Navigation Button"/>
|
AutomationProperties.ItemType="Navigation Button"/>
|
||||||
<TextBlock Text="{Binding Name}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
|
<TextBlock
|
||||||
IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
|
Grid.Column="1"
|
||||||
<CommandBar Grid.Column="2" Margin="0,40,0,0" Background="Transparent" IsOpen="True">
|
Text="{Binding Name}"
|
||||||
|
Style="{StaticResource HeaderTextBlockStyle}"
|
||||||
|
IsHitTestVisible="false"
|
||||||
|
TextWrapping="NoWrap"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Margin="0,0,30,40"/>
|
||||||
|
<CommandBar
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="0,40,0,0"
|
||||||
|
Background="Transparent"
|
||||||
|
IsOpen="True">
|
||||||
|
<AppBarButton Icon="Save" Label="Save" />
|
||||||
|
<CommandBar.SecondaryCommands>
|
||||||
<AppBarButton Icon="Edit" Label="Edit" />
|
<AppBarButton Icon="Edit" Label="Edit" />
|
||||||
<AppBarButton Icon="Delete" Label="Delete" IsEnabled="{Binding IsNotRoot}" Click="AppBarButton_Click" />
|
<AppBarButton Icon="Delete" Label="Delete" IsEnabled="{Binding IsNotRoot}" Click="AppBarButton_Click" />
|
||||||
|
</CommandBar.SecondaryCommands>
|
||||||
</CommandBar>
|
</CommandBar>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@@ -63,8 +63,6 @@ namespace ModernKeePass.Pages
|
|||||||
if (databaseVm == null) return;
|
if (databaseVm == null) return;
|
||||||
databaseVm.SelectedVisibility = Visibility.Visible;
|
databaseVm.SelectedVisibility = Visibility.Visible;
|
||||||
databaseVm.Name = file.Name;
|
databaseVm.Name = file.Name;
|
||||||
databaseVm.NotifyPropertyChanged("SelectedVisibility");
|
|
||||||
databaseVm.NotifyPropertyChanged("Name");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PasswordUserControl_PasswordChecked(object sender, EventArgs e)
|
private void PasswordUserControl_PasswordChecked(object sender, EventArgs e)
|
||||||
|
@@ -5,27 +5,29 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||||
xmlns:local="using:ModernKeePass.Controls"
|
xmlns:local="using:ModernKeePass.Controls"
|
||||||
|
xmlns:Converters="using:ModernKeePass.Converters"
|
||||||
x:Class="ModernKeePass.Pages.RecentDatabasesPage"
|
x:Class="ModernKeePass.Pages.RecentDatabasesPage"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.DataContext>
|
|
||||||
<viewModels:RecentVm/>
|
|
||||||
</Page.DataContext>
|
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
|
<Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||||
<CollectionViewSource
|
<CollectionViewSource
|
||||||
x:Name="RecentItemsSource"
|
x:Name="RecentItemsSource"
|
||||||
Source="{Binding RecentItems}" />
|
Source="{Binding RecentItems}" />
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
|
<Page.DataContext>
|
||||||
|
<viewModels:RecentVm/>
|
||||||
|
</Page.DataContext>
|
||||||
<ListView
|
<ListView
|
||||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||||
ItemsSource="{Binding Source={StaticResource RecentItemsSource}}"
|
ItemsSource="{Binding Source={StaticResource RecentItemsSource}}"
|
||||||
x:Name="RecentListView"
|
x:Name="RecentListView"
|
||||||
SelectionChanged="RecentListView_SelectionChanged"
|
SelectionChanged="RecentListView_SelectionChanged"
|
||||||
IsSynchronizedWithCurrentItem="False">
|
SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="{Binding Name}" Width="350" Padding="5" />
|
<TextBlock Text="{Binding Name}" Width="350" Padding="5" />
|
||||||
<local:OpenDatabaseUserControl Visibility="{Binding PasswordVisibility}" ValidationChecked="PasswordUserControl_PasswordChecked" />
|
<local:OpenDatabaseUserControl Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
|
@@ -34,20 +34,17 @@ namespace ModernKeePass.Pages
|
|||||||
recentVm.RecentItems = new ObservableCollection<RecentItemVm>(
|
recentVm.RecentItems = new ObservableCollection<RecentItemVm>(
|
||||||
from entry in mru.Entries
|
from entry in mru.Entries
|
||||||
select new RecentItemVm {Name = entry.Metadata, Token = entry.Token});
|
select new RecentItemVm {Name = entry.Metadata, Token = entry.Token});
|
||||||
recentVm.NotifyPropertyChanged("RecentItems");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void RecentListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private async void RecentListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var recentItem = e.AddedItems[0] as RecentItemVm;
|
var recentVm = DataContext as RecentVm;
|
||||||
|
if (recentVm.SelectedItem == null) return;
|
||||||
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
||||||
if (recentItem == null) return;
|
var file = await mru.GetFileAsync(recentVm.SelectedItem.Token);
|
||||||
var file = await mru.GetFileAsync(recentItem.Token);
|
|
||||||
|
|
||||||
var app = (App)Application.Current;
|
var app = (App)Application.Current;
|
||||||
app.Database = new DatabaseHelper(file);
|
app.Database = new DatabaseHelper(file);
|
||||||
recentItem.PasswordVisibility = Visibility.Visible;
|
|
||||||
recentItem.NotifyPropertyChanged("PasswordVisibility");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PasswordUserControl_PasswordChecked(object sender, EventArgs e)
|
private void PasswordUserControl_PasswordChecked(object sender, EventArgs e)
|
||||||
|
@@ -41,7 +41,6 @@ namespace ModernKeePass.Pages
|
|||||||
private void UpdateDatabaseStatus(App app, DatabaseVm databaseVm)
|
private void UpdateDatabaseStatus(App app, DatabaseVm databaseVm)
|
||||||
{
|
{
|
||||||
databaseVm.IsOpen = app.Database.IsOpen;
|
databaseVm.IsOpen = app.Database.IsOpen;
|
||||||
databaseVm.NotifyPropertyChanged("IsOpen");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,25 +1,29 @@
|
|||||||
using System;
|
using Windows.UI.Xaml;
|
||||||
using System.ComponentModel;
|
using ModernKeePass.Common;
|
||||||
using Windows.UI.Xaml;
|
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
public class DatabaseVm : INotifyPropertyChanged
|
public class DatabaseVm : NotifyPropertyChangedBase
|
||||||
{
|
{
|
||||||
private string _name;
|
private string _name;
|
||||||
public Visibility SelectedVisibility { get; set; } = Visibility.Collapsed;
|
private Visibility _selectedVisibility = Visibility.Collapsed;
|
||||||
|
private bool _isOpen;
|
||||||
|
|
||||||
|
public Visibility SelectedVisibility
|
||||||
|
{
|
||||||
|
get { return _selectedVisibility; }
|
||||||
|
set { SetProperty(ref _selectedVisibility, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsOpen
|
||||||
|
{
|
||||||
|
get { return _isOpen; }
|
||||||
|
set { SetProperty(ref _isOpen, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsOpen { get; set; }
|
|
||||||
public string Name {
|
public string Name {
|
||||||
get { return string.IsNullOrEmpty(_name) ? string.Empty : $"Database {_name} selected"; }
|
get { return string.IsNullOrEmpty(_name) ? string.Empty : $"Database {_name} selected"; }
|
||||||
set { _name = value; }
|
set { SetProperty(ref _name, value); }
|
||||||
}
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
|
||||||
|
|
||||||
public void NotifyPropertyChanged(string propertyName)
|
|
||||||
{
|
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,10 +42,9 @@ namespace ModernKeePass.ViewModels
|
|||||||
get { return GetEntryValue(PwDefs.NotesField); }
|
get { return GetEntryValue(PwDefs.NotesField); }
|
||||||
set { SetEntryValue(PwDefs.NotesField, value); }
|
set { SetEntryValue(PwDefs.NotesField, value); }
|
||||||
}
|
}
|
||||||
|
public System.Drawing.Color? BackgroundColor => _pwEntry?.BackgroundColor;
|
||||||
|
|
||||||
public SolidColorBrush BackgroundColor => CreateFromColor(_pwEntry?.BackgroundColor, Colors.Transparent);
|
public System.Drawing.Color? ForegroundColor => _pwEntry?.ForegroundColor;
|
||||||
|
|
||||||
public SolidColorBrush ForegroundColor => CreateFromColor(_pwEntry?.ForegroundColor, Colors.White);
|
|
||||||
|
|
||||||
public FontWeight FontWeight => _pwEntry == null ? FontWeights.Bold : FontWeights.Normal;
|
public FontWeight FontWeight => _pwEntry == null ? FontWeights.Bold : FontWeights.Normal;
|
||||||
|
|
||||||
@@ -82,15 +81,5 @@ namespace ModernKeePass.ViewModels
|
|||||||
{
|
{
|
||||||
_pwEntry?.Strings.Set(key, new ProtectedString(true, newValue));
|
_pwEntry?.Strings.Set(key, new ProtectedString(true, newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private SolidColorBrush CreateFromColor(System.Drawing.Color? color, Windows.UI.Color defaultValue)
|
|
||||||
{
|
|
||||||
if (!color.HasValue || color.Value == System.Drawing.Color.Empty) return new SolidColorBrush(defaultValue);
|
|
||||||
return new SolidColorBrush(Windows.UI.Color.FromArgb(
|
|
||||||
color.Value.A,
|
|
||||||
color.Value.R,
|
|
||||||
color.Value.G,
|
|
||||||
color.Value.B));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +1,13 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Windows.UI.Xaml;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using ModernKeePass.Common;
|
||||||
using ModernKeePass.Mappings;
|
using ModernKeePass.Mappings;
|
||||||
using ModernKeePassLib;
|
using ModernKeePassLib;
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
public class GroupVm : INotifyPropertyChanged
|
public class GroupVm : NotifyPropertyChangedBase
|
||||||
{
|
{
|
||||||
public GroupVm ParentGroup { get; }
|
public GroupVm ParentGroup { get; }
|
||||||
public ObservableCollection<EntryVm> Entries { get; set; } = new ObservableCollection<EntryVm>();
|
public ObservableCollection<EntryVm> Entries { get; set; } = new ObservableCollection<EntryVm>();
|
||||||
@@ -19,9 +18,6 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public int GroupCount => Groups.Count - 1;
|
public int GroupCount => Groups.Count - 1;
|
||||||
|
|
||||||
public Visibility DetailsVisibility => _pwGroup == null ? Visibility.Collapsed : Visibility.Visible;
|
|
||||||
public Visibility NewVisibility => _pwGroup == null ? Visibility.Visible : Visibility.Collapsed;
|
|
||||||
|
|
||||||
public Symbol IconSymbol
|
public Symbol IconSymbol
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -74,12 +70,5 @@ namespace ModernKeePass.ViewModels
|
|||||||
_pwGroup.Entries.Remove(entry.Entry);
|
_pwGroup.Entries.Remove(entry.Entry);
|
||||||
Entries.Remove(entry);
|
Entries.Remove(entry);
|
||||||
}
|
}
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
|
||||||
|
|
||||||
public void NotifyPropertyChanged(string propertyName)
|
|
||||||
{
|
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
|
using ModernKeePass.Common;
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
public class RecentItemVm: INotifyPropertyChanged
|
public class RecentItemVm: NotifyPropertyChangedBase
|
||||||
{
|
{
|
||||||
|
private bool _isSelected;
|
||||||
public string Token { get; set; }
|
public string Token { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public Visibility PasswordVisibility { get; set; } = Visibility.Collapsed;
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public bool IsSelected
|
||||||
|
|
||||||
public void NotifyPropertyChanged(string propertyName)
|
|
||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
get { return _isSelected; }
|
||||||
|
internal set { SetProperty(ref _isSelected, value); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,16 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Linq;
|
||||||
using System.ComponentModel;
|
using ModernKeePass.Common;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
public class MainVm : INotifyPropertyChanged
|
public class MainVm : NotifyPropertyChangedBase
|
||||||
{
|
{
|
||||||
public IOrderedEnumerable<IGrouping<int, MainMenuItemVm>> MainMenuItems { get; set; }
|
private IOrderedEnumerable<IGrouping<int, MainMenuItemVm>> _mainMenuItems;
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public IOrderedEnumerable<IGrouping<int, MainMenuItemVm>> MainMenuItems
|
||||||
public void NotifyPropertyChanged(string propertyName)
|
|
||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
get { return _mainMenuItems; }
|
||||||
|
set { SetProperty(ref _mainMenuItems, value); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,37 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using ModernKeePass.Common;
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
public class RecentVm : INotifyPropertyChanged
|
public class RecentVm : NotifyPropertyChangedBase
|
||||||
{
|
{
|
||||||
public ObservableCollection<RecentItemVm> RecentItems { get; set; }
|
private RecentItemVm _selectedItem;
|
||||||
|
private ObservableCollection<RecentItemVm> _recentItems;
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public ObservableCollection<RecentItemVm> RecentItems
|
||||||
|
|
||||||
public void NotifyPropertyChanged(string propertyName)
|
|
||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
get { return _recentItems; }
|
||||||
|
set { SetProperty(ref _recentItems, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecentItemVm SelectedItem
|
||||||
|
{
|
||||||
|
get { return _selectedItem; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_selectedItem == value) return;
|
||||||
|
if (_selectedItem != null)
|
||||||
|
{
|
||||||
|
_selectedItem.IsSelected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetProperty(ref _selectedItem, value);
|
||||||
|
|
||||||
|
if (_selectedItem != null)
|
||||||
|
{
|
||||||
|
_selectedItem.IsSelected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user