Fully added File Editor

This commit is contained in:
WeeXnes 2024-06-13 20:27:16 +02:00
parent 5cb3c52ba7
commit 55c753dead
5 changed files with 21 additions and 10 deletions

View file

@ -8,7 +8,7 @@ namespace WeeXnes.Core
{
public class Information
{
public const string Version = "4.5.1.7";
public const string Version = "4.5.2";
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
}

View file

@ -12,7 +12,7 @@
xmlns:profile="clr-namespace:WeeXnes.Views.ProfileView"
xmlns:EncryptedTextEditor="clr-namespace:WeeXnes.Views.EncryptedTextEditor"
mc:Ignorable="d"
Height="400"
Height="540"
Width="500"
Title="WeeXnes"
Background="{DynamicResource ApplicationBackgroundBrush}"
@ -93,7 +93,6 @@
PageTag="Gen"
PageType="{x:Type passwordGenerator:PasswordGenView}"/>
<ui:NavigationItem
Visibility="Collapsed"
Content="Editor"
Icon="DocumentOnePage24"
Name="ButtonEncryptedFileEditor"

View file

@ -23,7 +23,7 @@ namespace WeeXnes
{
if(!App.DebugMode)
return;
ButtonEncryptedFileEditor.Visibility = Visibility.Visible;
//Code to be enabled in Debug mode
}

View file

@ -23,14 +23,16 @@ public partial class TextEditorView : Page
var fileContent = string.Empty;
var filePath = string.Empty;
Console.WriteLine("Calling OpenFileDialog");
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
//openFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
openFileDialog.Filter = "WXN Text Files (*.wtf)|*.wtf";
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
Console.WriteLine("Opening file " + openFileDialog.FileName);
this.currentFilePath = openFileDialog.FileName;
string[] FileContent = File.ReadAllLines(openFileDialog.FileName);
string[] decryptedContent = EncryptorLibary.decryptArray(Information.EncryptionHash, FileContent);
@ -47,19 +49,29 @@ public partial class TextEditorView : Page
{
if(this.currentFilePath == null)
return;
Console.WriteLine("Saving file " + currentFilePath);
TextRange textRange = new TextRange(rtb_FileEditor.Document.ContentStart, rtb_FileEditor.Document.ContentEnd);
string plainText = textRange.Text;
string[] lines = plainText.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
string[] encryptedContent =
EncryptionLib.EncryptorLibary.encryptArray(Information.EncryptionHash, lines);
File.WriteAllLines(this.currentFilePath, encryptedContent);
}
private void Btn_saveFileAs_OnClick(object sender, RoutedEventArgs e)
{
Console.WriteLine("Calling SaveFileDialog");
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
{
this.currentFilePath = saveFileDialog.FileName;
saveFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
//saveFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
saveFileDialog.Filter = "WXN Text Files (*.wtf)|*.wtf";
saveFileDialog.RestoreDirectory = true ;
saveFileDialog.RestoreDirectory = true;
if(saveFileDialog.ShowDialog() == DialogResult.OK)
{
Console.WriteLine("Saving file " + saveFileDialog.FileName);
this.currentFilePath = saveFileDialog.FileName;
TextRange textRange = new TextRange(rtb_FileEditor.Document.ContentStart, rtb_FileEditor.Document.ContentEnd);
string plainText = textRange.Text;
string[] lines = plainText.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

View file

@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Version>4.5.1.7</Version>
<Version>4.5.2</Version>
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WeeXnes</RootNamespace>