mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-04-26 01:36:38 +03:00
Update MainWindow.axaml.cs
This commit is contained in:
@@ -1,11 +1,105 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KeyKeeper.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
namespace KeyKeeper.Views
|
||||
{
|
||||
public MainWindow()
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
LoadRecentVaults();
|
||||
}
|
||||
|
||||
private void LoadRecentVaults()
|
||||
{
|
||||
var recentFiles = new List<RecentVault>
|
||||
{
|
||||
new RecentVault { Path = "C:\\Users\\User\\Documents\\passwords.kdbx", LastOpened = DateTime.Now.AddDays(-1) },
|
||||
new RecentVault { Path = "C:\\Users\\User\\Desktop\\work_passwords.kdbx", LastOpened = DateTime.Now.AddDays(-3) }
|
||||
};
|
||||
|
||||
RecentVaultsList.ItemsSource = recentFiles;
|
||||
}
|
||||
|
||||
private async void CreateNewVault_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
if (topLevel == null) return;
|
||||
|
||||
var file = await topLevel.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
SuggestedFileName = "passwords.kdbx",
|
||||
DefaultExtension = "kdbx",
|
||||
FileTypeChoices = new[]
|
||||
{
|
||||
new FilePickerFileType("KeyKeeper Database")
|
||||
{
|
||||
Patterns = new[] { "*.kdbx" }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (file != null)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ShowMessage($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {file.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
private async void OpenExistingVault_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
if (topLevel == null) return;
|
||||
|
||||
var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new[]
|
||||
{
|
||||
new FilePickerFileType("KeyKeeper Database")
|
||||
{
|
||||
Patterns = new[] { "*.kdbx", "*.kkdb" }
|
||||
},
|
||||
new FilePickerFileType("KeePass Database")
|
||||
{
|
||||
Patterns = new[] { "*.kdbx" }
|
||||
},
|
||||
new FilePickerFileType("All Files")
|
||||
{
|
||||
Patterns = new[] { "*.*" }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (files.Count > 0)
|
||||
{
|
||||
var file = files[0];
|
||||
ShowMessage($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {file.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowMessage(string message)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var messageBox = new Window
|
||||
{
|
||||
Title = "KeyKeeper",
|
||||
Content = new TextBlock { Text = message, Margin = new Thickness(20) },
|
||||
SizeToContent = SizeToContent.WidthAndHeight,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner
|
||||
};
|
||||
messageBox.ShowDialog(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user