Changed implementation of sample data

Creating a new entry does not create an useless history value
WIP import data
This commit is contained in:
BONNEVILLE Geoffroy
2018-09-10 11:13:44 +02:00
parent deec19a60c
commit bbae2c356a
7 changed files with 66 additions and 8 deletions

View File

@@ -0,0 +1,13 @@
using Windows.Storage;
using ModernKeePass.Interfaces;
namespace ModernKeePass.ImportFormats
{
public class CsvImportFormat: IFormat
{
public IPwEntity Import(IStorageFile source)
{
throw new System.NotImplementedException();
}
}
}

View File

@@ -0,0 +1,13 @@
using Windows.Storage;
using ModernKeePass.Interfaces;
namespace ModernKeePass.ImportFormats
{
public class NullImportFormat: IFormat
{
public IPwEntity Import(IStorageFile source)
{
throw new System.NotImplementedException();
}
}
}

View File

@@ -117,6 +117,8 @@
</Compile>
<Compile Include="Converters\IntToSymbolConverter.cs" />
<Compile Include="Exceptions\NavigationException.cs" />
<Compile Include="ImportFormats\CsvImportFormat.cs" />
<Compile Include="ImportFormats\NullImportFormat.cs" />
<Compile Include="Interfaces\IFormat.cs" />
<Compile Include="Interfaces\IImportService.cs" />
<Compile Include="Interfaces\IProxyInvocationHandler.cs" />

View File

@@ -204,7 +204,7 @@ namespace ModernKeePass.ViewModels
private readonly IDatabaseService _database;
private readonly IResourceService _resource;
private bool _isEditMode;
private bool _isDirty;
private bool _isDirty = true;
private bool _isRevealPassword;
private double _passwordLength = 25;
private bool _isVisible = true;

View File

@@ -1,5 +1,7 @@
using Windows.Storage;
using System;
using Windows.Storage;
using Windows.UI.Xaml.Controls;
using ModernKeePass.Converters;
using ModernKeePass.Interfaces;
using ModernKeePassLib;
@@ -23,14 +25,16 @@ namespace ModernKeePass.ViewModels
private void CreateSampleData(IDatabaseService database)
{
var converter = new IntToSymbolConverter();
var bankingGroup = database.RootGroup.AddNewGroup("Banking");
bankingGroup.IconId = (int) Symbol.Calculator;
bankingGroup.IconId = (int)converter.ConvertBack(Symbol.Calculator, null, null, string.Empty);
var emailGroup = database.RootGroup.AddNewGroup("Email");
emailGroup.IconId = (int) Symbol.Mail;
emailGroup.IconId = (int)converter.ConvertBack(Symbol.Mail, null, null, string.Empty);
var internetGroup = database.RootGroup.AddNewGroup("Internet");
internetGroup.IconId = (int) Symbol.World;
internetGroup.IconId = (int)converter.ConvertBack(Symbol.World, null, null, string.Empty);
var sample1 = database.RootGroup.AddNewEntry();
sample1.Name = "Sample Entry";

View File

@@ -32,7 +32,7 @@
<HyperlinkButton Content="Select file..." Style="{StaticResource MainColorHyperlinkButton}" Click="ImportFileButton_OnClick" />
<StackPanel>
<TextBlock Text="Format" Style="{StaticResource BodyTextBlockStyle}" Margin="0,0,0,10" />
<ComboBox Style="{StaticResource MainColorComboBox}" SelectedItem="{Binding ImportFormat}">
<ComboBox Style="{StaticResource MainColorComboBox}" SelectionChanged="Selector_OnSelectionChanged">
<ComboBoxItem>CSV</ComboBoxItem>
</ComboBox>
</StackPanel>

View File

@@ -2,7 +2,10 @@
using System.Collections.Generic;
using Windows.Storage.Pickers;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using ModernKeePass.Events;
using ModernKeePass.ImportFormats;
using ModernKeePass.Services;
using ModernKeePass.ViewModels;
@@ -15,6 +18,8 @@ namespace ModernKeePass.Views
/// </summary>
public sealed partial class NewDatabasePage
{
private Frame _mainFrame;
public NewVm Model => (NewVm)DataContext;
public NewDatabasePage()
@@ -22,6 +27,12 @@ namespace ModernKeePass.Views
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
_mainFrame = e.Parameter as Frame;
}
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
var savePicker = new FileSavePicker
@@ -52,8 +63,23 @@ namespace ModernKeePass.Views
private void CompositeKeyUserControl_OnValidationChecked(object sender, PasswordEventArgs e)
{
Model.PopulateInitialData(DatabaseService.Instance, new SettingsService());
Frame.Navigate(typeof(GroupDetailPage));
Model.PopulateInitialData(DatabaseService.Instance, new SettingsService(), new ImportService());
_mainFrame.Navigate(typeof(GroupDetailPage));
}
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
var comboBox = sender as ComboBox;
switch (comboBox?.SelectedIndex)
{
case 0:
Model.ImportFormat = new CsvImportFormat();
break;
default:
Model.ImportFormat = new NullImportFormat();
break;
}
}
}
}