Removed half-baked import feature for now

No views depend on services anymore
Dirty status fully handled by behavior
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-27 11:14:29 +02:00
parent 59ab43ca9c
commit 8e06bf4bb0
11 changed files with 34 additions and 113 deletions

View File

@@ -5,10 +5,7 @@ using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using GalaSoft.MvvmLight.Views;
using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Application.Entry.Models;
using ModernKeePass.Common;
using ModernKeePass.Models;
using ModernKeePass.ViewModels;
@@ -22,15 +19,11 @@ namespace ModernKeePass.Views
/// </summary>
public sealed partial class GroupDetailPage
{
private readonly INavigationService _navigation;
public GroupDetailVm Model => (GroupDetailVm)DataContext;
public GroupDetailPage(): this (App.Services.GetRequiredService<INavigationService>()) { }
public GroupDetailPage(INavigationService navigation)
public GroupDetailPage()
{
InitializeComponent();
_navigation = navigation;
}
#region NavigationHelper registration
@@ -58,7 +51,7 @@ namespace ModernKeePass.Views
return;
default:
var group = listView?.SelectedItem as Application.Group.Models.GroupVm;
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem { Id = group?.Id });
Model.GoToGroup(group?.Id);
break;
}
}
@@ -71,7 +64,7 @@ namespace ModernKeePass.Views
return;
default:
var entry = GridView.SelectedItem as EntryVm;
_navigation.NavigateTo(Constants.Navigation.EntryPage, new NavigationItem { Id = entry?.Id });
Model.GoToEntry(entry?.Id);
break;
}
}
@@ -103,7 +96,7 @@ namespace ModernKeePass.Views
private void SearchBox_OnResultSuggestionChosen(SearchBox sender, SearchBoxResultSuggestionChosenEventArgs args)
{
_navigation.NavigateTo(Constants.Navigation.EntryPage, new NavigationItem { Id = args.Tag });
Model.GoToEntry(args.Tag);
}
private void GroupDetailPage_OnSizeChanged(object sender, SizeChangedEventArgs e)

View File

@@ -21,30 +21,6 @@
<userControls:SetCredentialsUserControl x:Uid="CompositeKeyNewButton" />
</StackPanel>
</Border>
<CheckBox x:Name="CheckBox" x:Uid="NewImportCheckbox" Margin="15,10,0,0" IsChecked="{Binding IsImportChecked, Mode=TwoWay}" Visibility="{Binding IsFileSelected, Converter={StaticResource BooleanToVisibilityConverter}}" />
<Border HorizontalAlignment="Left" BorderThickness="1" BorderBrush="AliceBlue" Width="550" Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=CheckBox}">
<StackPanel Margin="25,0,25,0">
<StackPanel Orientation="Horizontal">
<TextBlock x:Uid="NewImportFormat" Margin="0,15,0,10" Style="{StaticResource BodyTextBlockStyle}" />
<ComboBox Style="{StaticResource MainColorComboBox}" Margin="15,15,0,0" SelectionChanged="ImportFormatComboBox_OnSelectionChanged">
<ComboBoxItem>CSV</ComboBoxItem>
</ComboBox>
<Button Margin="5,10,0,0" Style="{StaticResource TextBlockButtonStyle}">
<SymbolIcon Symbol="Help" RenderTransformOrigin="0.5,0.5" >
<SymbolIcon.RenderTransform>
<CompositeTransform ScaleX="0.7" ScaleY="0.7"/>
</SymbolIcon.RenderTransform>
</SymbolIcon>
<Button.Flyout>
<Flyout>
<TextBlock Text="{Binding ImportFormatHelp}" TextWrapping="WrapWholeWords" MaxWidth="400" />
</Flyout>
</Button.Flyout>
</Button>
</StackPanel>
<HyperlinkButton x:Name="ImportFileLink" x:Uid="NewImportFile" Margin="-15,0,0,0" Style="{StaticResource MainColorHyperlinkButton}" Click="ImportFileButton_OnClick" />
</StackPanel>
</Border>
</StackPanel>
</Page>

View File

@@ -3,11 +3,7 @@ using System.Collections.Generic;
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Domain.Dtos;
using ModernKeePass.Infrastructure.File;
using ModernKeePass.ViewModels;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
@@ -19,13 +15,10 @@ namespace ModernKeePass.Views
/// </summary>
public sealed partial class NewDatabasePage
{
private readonly IResourceProxy _resource;
private NewVm Model => (NewVm)DataContext;
public NewDatabasePage(): this(App.Services.GetRequiredService<IResourceProxy>()) { }
public NewDatabasePage(IResourceProxy resource)
public NewDatabasePage()
{
_resource = resource;
InitializeComponent();
}
@@ -50,33 +43,5 @@ namespace ModernKeePass.Views
};
Model.OpenFile(fileInfo);
}
private void ImportFormatComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
var comboBox = sender as ComboBox;
switch (comboBox?.SelectedIndex)
{
case 0:
Model.ImportFormat = new CsvImportFormat();
Model.ImportFileExtensionFilter = ".csv";
Model.ImportFormatHelp = _resource.GetResourceValue("NewImportFormatHelpCSV");
break;
}
}
private async void ImportFileButton_OnClick(object sender, RoutedEventArgs e)
{
var picker = new FileOpenPicker
{
ViewMode = PickerViewMode.List,
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
};
if (!string.IsNullOrEmpty(Model.ImportFileExtensionFilter))
picker.FileTypeFilter.Add(Model.ImportFileExtensionFilter);
// Application now has read/write access to the picked file
Model.ImportFile = await picker.PickSingleFileAsync().AsTask();
if (Model.ImportFile != null) ImportFileLink.Content = Model.ImportFile.Name;
}
}
}