Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculator_夏心雨_pku24 #5

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion MAUICalculator/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
namespace MAUICalculator
using Microsoft.Maui.Controls;

namespace YourNamespace
{
public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
Expand Down
5 changes: 5 additions & 0 deletions MAUICalculator/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
namespace MAUICalculator
using System;
using Microsoft.Maui.Controls;

namespace YourNamespace
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute(nameof(SubPage), typeof(SubPage));
}
}
}
10 changes: 4 additions & 6 deletions MAUICalculator/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Microsoft.Extensions.Logging;

using Microsoft.Maui;
using Microsoft.Maui.Hosting;
namespace MAUICalculator
namespace YourNamespace
{
public static class MauiProgram
{
Expand All @@ -12,14 +14,10 @@ public static MauiApp CreateMauiApp()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

#if DEBUG
builder.Logging.AddDebug();
#endif

return builder.Build();
}
}
}

42 changes: 36 additions & 6 deletions MAUICalculator/SubPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
namespace MAUICalculator;
using System;
using Microsoft.Maui.Controls;

public partial class SubPage : ContentPage
namespace YourNamespace
{
public SubPage()
{
InitializeComponent();
}
}
public partial class SubPage : ContentPage
{
public SubPage()
{
InitializeComponent();
}

// Method to handle DEL button click
void OnDelButtonClicked(object sender, EventArgs e)
{
if (displayLabel.Text.Length > 0)
{
if (displayLabel.Text.EndsWith("="))
{
displayLabel.Text = "";
}
else
{
displayLabel.Text = displayLabel.Text.Remove(displayLabel.Text.Length - 1);
}
}
}

// Method to handle AC button click
void OnAcButtonClicked(object sender, EventArgs e)
{
displayLabel.Text = "";
lastNumber = 0;
}

// Other methods for button clicks...
}
}