main
syneffort 1 year ago
parent 497e6a7e11
commit 9039c49ad3
  1. 2
      MyFirstMauiApp/NotesNet8/AppShell.xaml
  2. 36
      MyFirstMauiApp/NotesNet8/MainPage.xaml
  3. 25
      MyFirstMauiApp/NotesNet8/MainPage.xaml.cs
  4. 3
      MyFirstMauiApp/NotesNet8/NotesNet8.csproj
  5. 16
      MyFirstMauiApp/NotesNet8/Pages/NotePage.xaml
  6. 27
      MyFirstMauiApp/NotesNet8/Pages/NotePage.xaml.cs

@ -9,7 +9,7 @@
<TabBar> <TabBar>
<ShellContent Title="Notes" <ShellContent Title="Notes"
ContentTemplate="{DataTemplate local:MainPage}" ContentTemplate="{DataTemplate page:NotePage}"
Icon="{OnPlatform 'icon_notes.png'}" /> Icon="{OnPlatform 'icon_notes.png'}" />
<ShellContent Title="About" <ShellContent Title="About"

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="NotesNet8.MainPage">
<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Image
Source="dotnet_bot.png"
HeightRequest="185"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />
<Label
Text="Hello, World!"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1" />
<Label
Text="Welcome to &#10;.NET Multi-platform App UI"
Style="{StaticResource SubHeadline}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>

@ -1,25 +0,0 @@
namespace NotesNet8
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
}
}
}

@ -71,6 +71,9 @@
<MauiXaml Update="Pages\AboutPage.xaml"> <MauiXaml Update="Pages\AboutPage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
<MauiXaml Update="Pages\NotePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -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…
Cancel
Save