added import/export options to KeyManager
This commit is contained in:
parent
3ef67556dd
commit
884e12f980
5 changed files with 71 additions and 5 deletions
|
@ -8,7 +8,7 @@ namespace WeeXnes.Core
|
|||
{
|
||||
public class Information
|
||||
{
|
||||
public const string Version = "4.2.8";
|
||||
public const string Version = "4.3.0";
|
||||
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
|
||||
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
||||
}
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
using System;
|
||||
using System.Windows.Shapes;
|
||||
using WeeXnes.Core;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Wpf.Ui.Controls;
|
||||
using Microsoft.Win32;
|
||||
using Path = System.Windows.Shapes.Path;
|
||||
|
||||
namespace WeeXnes.Views.KeyManager
|
||||
{
|
||||
|
@ -18,5 +25,47 @@ namespace WeeXnes.Views.KeyManager
|
|||
{
|
||||
return this.Name;
|
||||
}
|
||||
|
||||
|
||||
public void Export()
|
||||
{
|
||||
string filePath = Global.AppDataPathKEY.Value + "\\" + this.Filename;
|
||||
Console.WriteLine(filePath);
|
||||
|
||||
SaveFileDialog dialog = new SaveFileDialog()
|
||||
{
|
||||
Filter = "WXFiles (*.wx)|*.wx",
|
||||
Title = "Export KeyFile"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
File.Copy(filePath, dialog.FileName, true);
|
||||
Console.WriteLine("Exported to: " + dialog.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Import()
|
||||
{
|
||||
OpenFileDialog dialog = new OpenFileDialog()
|
||||
{
|
||||
Filter = "WXFiles (*.wx)|*.wx"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
WXFile wxFile = new WXFile(dialog.FileName);
|
||||
KeyItem newItem = new KeyItem(
|
||||
wxFile.GetName(),
|
||||
EncryptionLib.EncryptorLibary.decrypt(
|
||||
Information.EncryptionHash,
|
||||
wxFile.GetValue()
|
||||
)
|
||||
);
|
||||
newItem.Filename = System.IO.Path.GetFileName(dialog.FileName);
|
||||
WXFile newWxFile = new WXFile(Global.AppDataPathKEY.Value + "\\" + newItem.Filename);
|
||||
WXFile.Methods.WriteFile(newItem, newWxFile);
|
||||
KeyManagerView.Data.KeyItemsList.Add(newItem);
|
||||
Console.WriteLine("Imported: " + dialog.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,13 @@
|
|||
<ContextMenu>
|
||||
<MenuItem Header="Remove"
|
||||
Name="btn_context_remove"
|
||||
Click="MenuItem_OnClick"/>
|
||||
Click="ContextMenu_Remove"/>
|
||||
<MenuItem Header="Export"
|
||||
Name="btn_context_export"
|
||||
Click="ContextMenu_Export"/>
|
||||
<MenuItem Header="Import"
|
||||
Name="btn_context_import"
|
||||
Click="ContextMenu_Import"/>
|
||||
</ContextMenu>
|
||||
</ListView.ContextMenu>
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace WeeXnes.Views.KeyManager
|
|||
if(String.IsNullOrEmpty(tb_keyvalue.Text))
|
||||
return;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
KeyItem newKey = new KeyItem(
|
||||
|
@ -43,12 +44,13 @@ namespace WeeXnes.Views.KeyManager
|
|||
WXFile wxFile = new WXFile(
|
||||
Global.AppDataPathKEY.Value + "\\" + newKey.Filename);
|
||||
WXFile.Methods.WriteFile(newKey, wxFile);
|
||||
Data.KeyItemsList.Add(newKey);
|
||||
KeyManagerView.Data.KeyItemsList.Add(newKey);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
ClearInputs();
|
||||
}
|
||||
|
||||
|
@ -74,10 +76,19 @@ namespace WeeXnes.Views.KeyManager
|
|||
}
|
||||
|
||||
}
|
||||
private void MenuItem_OnClick(object sender, RoutedEventArgs e)
|
||||
private void ContextMenu_Remove(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DeleteItem((KeyItem)ListviewKeys.SelectedItem);
|
||||
}
|
||||
private void ContextMenu_Import(object sender, RoutedEventArgs e)
|
||||
{
|
||||
KeyItem.Import();
|
||||
}
|
||||
private void ContextMenu_Export(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var item = (KeyItem)ListviewKeys.SelectedItem;
|
||||
item.Export();
|
||||
}
|
||||
|
||||
private void KeyValue_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<Version>4.2.8</Version>
|
||||
<Version>4.3.0</Version>
|
||||
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>WeeXnes</RootNamespace>
|
||||
|
|
Loading…
Add table
Reference in a new issue