parent
497e6a7e11
commit
9039c49ad3
@ -0,0 +1,16 @@ |
||||
<?xml version="1.0" encoding="utf-8" ?> |
||||
<ContentPage x:Class="NotesNet8.Pages.NotePage" |
||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
||||
Title="NotePage"> |
||||
<VerticalStackLayout Margin="5" Spacing="10"> |
||||
<Editor x:Name="TextEditor" |
||||
HeightRequest="100" Placeholder="Enter your note" /> |
||||
<Grid ColumnDefinitions="*,*" ColumnSpacing="4"> |
||||
<Button Grid.Column="0" |
||||
Clicked="SaveButton_Clicked" Text="Save" /> |
||||
<Button Grid.Column="1" |
||||
Clicked="DeleteButton_Clicked" Text="Delete" /> |
||||
</Grid> |
||||
</VerticalStackLayout> |
||||
</ContentPage> |
@ -0,0 +1,27 @@ |
||||
namespace NotesNet8.Pages; |
||||
|
||||
public partial class NotePage : ContentPage |
||||
{ |
||||
string _fileName = Path.Combine(FileSystem.AppDataDirectory, "notes.txt"); |
||||
|
||||
public NotePage() |
||||
{ |
||||
InitializeComponent(); |
||||
|
||||
if (File.Exists(_fileName)) |
||||
TextEditor.Text = File.ReadAllText(_fileName); |
||||
} |
||||
|
||||
private void SaveButton_Clicked(object sender, EventArgs e) |
||||
{ |
||||
File.WriteAllText(_fileName, TextEditor.Text); |
||||
} |
||||
|
||||
private void DeleteButton_Clicked(object sender, EventArgs e) |
||||
{ |
||||
if (File.Exists(_fileName)) |
||||
File.Delete(_fileName); |
||||
|
||||
TextEditor.Text = string.Empty; |
||||
} |
||||
} |
Loading…
Reference in new issue