Code cleanup

This commit is contained in:
2017-10-12 17:45:37 +02:00
committed by BONNEVILLE Geoffroy
parent cddda7adcd
commit 0ded991673
10 changed files with 18 additions and 27 deletions

View File

@@ -334,11 +334,6 @@
</UserControl.Resources>
<StackPanel>
<PasswordBox x:Name="PasswordBox" Width="300" IsPasswordRevealButtonEnabled="True" KeyDown="PasswordBox_KeyDown" PlaceholderText="Password" Style="{StaticResource PasswordBoxWithButtonStyle}"/>
<!--<StackPanel Orientation="Horizontal" Margin="0,-1,0,-1" >
<Button Click="OpenButton_OnClick" Width="auto" Padding="2,0">
<SymbolIcon Symbol="Forward" />
</Button>
</StackPanel>-->
<TextBlock x:Name="StatusTextBlock" Height="32" Width="auto" Foreground="#FFBF6969" FontSize="16" FontWeight="Bold" />
</StackPanel>
</UserControl>

View File

@@ -3,7 +3,6 @@ using System.Threading.Tasks;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using ModernKeePass.Common;
using ModernKeePass.Events;
@@ -12,7 +11,7 @@ using ModernKeePass.Events;
namespace ModernKeePass.Controls
{
public sealed partial class OpenDatabaseUserControl : UserControl
public sealed partial class OpenDatabaseUserControl
{
public bool CreateNew
{

View File

@@ -9,7 +9,7 @@ namespace ModernKeePass
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
public sealed partial class MainPage
{
public MainPage()
{
@@ -25,7 +25,7 @@ namespace ModernKeePass
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var mainVm = DataContext as MainVm;
mainVm.SelectedItem?.Destination.Navigate(mainVm.SelectedItem.PageType, mainVm.SelectedItem.Parameter);
mainVm?.SelectedItem?.Destination.Navigate(mainVm.SelectedItem.PageType, mainVm.SelectedItem.Parameter);
}
}
}

View File

@@ -14,7 +14,7 @@ namespace ModernKeePass.Pages
/// Page affichant les détails d'un élément au sein d'un groupe, offrant la possibilité de
/// consulter les autres éléments qui appartiennent au même groupe.
/// </summary>
public sealed partial class EntryDetailPage : Page
public sealed partial class EntryDetailPage
{
private NavigationHelper navigationHelper;

View File

@@ -15,7 +15,7 @@ namespace ModernKeePass.Pages
/// A page that displays an overview of a single group, including a preview of the items
/// within the group.
/// </summary>
public sealed partial class GroupDetailPage : Page
public sealed partial class GroupDetailPage
{
/// <summary>
/// NavigationHelper is used on each page to aid in navigation and
@@ -139,7 +139,7 @@ namespace ModernKeePass.Pages
{
var viewModel = DataContext as GroupVm;
var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx://Assets/Logo.scale-80.png"));
var results = viewModel.Entries.Skip(1).Where(e => e.Title.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);
var results = viewModel?.Entries.Skip(1).Where(e => e.Title.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);
foreach (var result in results)
{
args.Request.SearchSuggestionCollection.AppendResultSuggestion(result.Title, result.ParentGroup.Name, result.Id, imageUri, string.Empty);
@@ -149,7 +149,7 @@ namespace ModernKeePass.Pages
private void SearchBox_OnResultSuggestionChosen(SearchBox sender, SearchBoxResultSuggestionChosenEventArgs args)
{
var viewModel = DataContext as GroupVm;
var entry = viewModel.Entries.Skip(1).FirstOrDefault(e => e.Id == args.Tag);
var entry = viewModel?.Entries.Skip(1).FirstOrDefault(e => e.Id == args.Tag);
Frame.Navigate(typeof(EntryDetailPage), entry);
}

View File

@@ -4,7 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:ModernKeePass.Controls"
xmlns:local="using:ModernKeePass.Controls"
xmlns:converters="using:ModernKeePass.Converters"
xmlns:viewModels="using:ModernKeePass.ViewModels"
mc:Ignorable="d">
@@ -18,6 +18,6 @@
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<HyperlinkButton Content="Create new..." Click="ButtonBase_OnClick" />
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" Height="auto" Width="auto" FontSize="16" Margin="10,7,0,6" />
<controls:OpenDatabaseUserControl CreateNew="True" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
<local:OpenDatabaseUserControl CreateNew="True" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
</StackPanel>
</Page>

View File

@@ -14,7 +14,7 @@ namespace ModernKeePass.Pages
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class NewDatabasePage : Page
public sealed partial class NewDatabasePage
{
private Frame _mainFrame;
@@ -41,7 +41,7 @@ namespace ModernKeePass.Pages
var file = await savePicker.PickSaveFileAsync();
if (file == null) return;
var viewModel = DataContext as OpenVm;
viewModel.OpenFile(file);
viewModel?.OpenFile(file);
}
private void PasswordUserControl_PasswordChecked(object sender, PasswordEventArgs e)

View File

@@ -1,11 +1,8 @@
using System;
using Windows.Storage.Pickers;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
using ModernKeePass.Common;
using ModernKeePass.Events;
using ModernKeePass.ViewModels;
@@ -16,7 +13,7 @@ namespace ModernKeePass.Pages
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class OpenDatabasePage : Page
public sealed partial class OpenDatabasePage
{
private Frame _mainFrame;
@@ -43,7 +40,7 @@ namespace ModernKeePass.Pages
var viewModel = DataContext as OpenVm;
// Application now has read/write access to the picked file
viewModel.OpenFile(await picker.PickSingleFileAsync());
viewModel?.OpenFile(await picker.PickSingleFileAsync());
}
private void PasswordUserControl_PasswordChecked(object sender, PasswordEventArgs e)

View File

@@ -12,7 +12,7 @@ namespace ModernKeePass.Pages
/// <summary>
/// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
/// </summary>
public sealed partial class RecentDatabasesPage : Page
public sealed partial class RecentDatabasesPage
{
private Frame _mainFrame;
@@ -37,7 +37,7 @@ namespace ModernKeePass.Pages
//throw new NotImplementedException();
var viewModel = DataContext as RecentVm;
var app = (App)Application.Current;
app.Database.DatabaseFile = viewModel.SelectedItem.DatabaseFile;
app.Database.DatabaseFile = viewModel?.SelectedItem.DatabaseFile;
}
}
}

View File

@@ -13,7 +13,7 @@ namespace ModernKeePass.Pages
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SaveDatabasePage : Page
public sealed partial class SaveDatabasePage
{
private Frame _mainFrame;
public SaveDatabasePage()
@@ -30,7 +30,7 @@ namespace ModernKeePass.Pages
private void SaveButton_OnClick(object sender, RoutedEventArgs e)
{
var viewModel = DataContext as SaveVm;
viewModel.Save();
viewModel?.Save();
_mainFrame.Navigate(typeof(MainPage));
}
@@ -46,7 +46,7 @@ namespace ModernKeePass.Pages
var file = await savePicker.PickSaveFileAsync();
if (file == null) return;
var viewModel = DataContext as SaveVm;
viewModel.Save(file);
viewModel?.Save(file);
_mainFrame.Navigate(typeof(MainPage));
}