Skip to content

Commit

Permalink
整理文件
Browse files Browse the repository at this point in the history
  • Loading branch information
HPLZH committed Oct 8, 2022
1 parent a00af55 commit 6289ad7
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 65 deletions.
8 changes: 4 additions & 4 deletions BlackWhite.App/BlackWhite.App/BlackWhite.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="ButtonCardView.xaml">
<EmbeddedResource Update="Game\Select\ButtonCardView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="GamePage.xaml">
<EmbeddedResource Update="Game\Base\GamePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Properties\App.resx">
Expand Down Expand Up @@ -86,10 +86,10 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>VersionPage.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="SizePage.xaml">
<EmbeddedResource Update="Game\Select\SizePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="StartPage.xaml">
<EmbeddedResource Update="Game\Select\StartPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="StatisticsPage.xaml">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
using Xamarin.Forms;
using BlackWhite.Core;

namespace BlackWhite.App
namespace BlackWhite.App.Game.Base
{
public class GameButton : Button, IBlock<GameButton>
{
public GameButton()
: base()
{
this.BorderColor = Color.Gray;
this.BorderWidth = 2;
this.Clicked += (object sender, EventArgs e) => { BlockClicked(this, new BlockClickedEventArgs(X, Y)); };
BorderColor = Color.Gray;
BorderWidth = 2;
Clicked += (sender, e) => { BlockClicked(this, new BlockClickedEventArgs(X, Y)); };
}

public event EventHandler<BlockClickedEventArgs> BlockClicked;
Expand All @@ -25,7 +25,7 @@ public bool Value
set
{
_value = value;
this.BackgroundColor = _value ? Color.White : Color.Black;
BackgroundColor = _value ? Color.White : Color.Black;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:c="clr-namespace:BlackWhite.App"
x:Class="BlackWhite.App.GamePage">
x:Class="BlackWhite.App.Game.Base.GamePage">
<ContentPage.Content>
<StackLayout x:Name="pageStack">
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
using Xamarin.Forms.Xaml;

using BlackWhite.Core;
using BlackWhite.App.Game.Base;

namespace BlackWhite.App
namespace BlackWhite.App.Game.Base
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class GamePage : ContentPage
{
protected Blocks<GameButton> blocks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

using Xamarin.Forms;

namespace BlackWhite.App
namespace BlackWhite.App.Game.Base
{
public static class SizeCalculator
{
//padding=0

public static MainPage GetMainPage() => (MainPage)((NavigationPage)App.Current.MainPage).RootPage;
public static MainPage GetMainPage() => (MainPage)((NavigationPage)Application.Current.MainPage).RootPage;

public static double GetTotal() => GetTotalSize(GetMainPage().WindowSize.width, GetMainPage().WindowSize.height);
public static int GetMax() => GetMaxSize(GetTotal());
public static double GetBlock(int size) => GetBlockSize(GetTotal(), size);

public static double GetBlockSizeM(double total, int size)
{
double result = GetBlockSize(total, size);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;

using BlackWhite.App.Game.Base;
using BlackWhite.Core;

using Xamarin.Forms;

namespace BlackWhite.App
namespace BlackWhite.App.Game.Main
{
internal class NormalGamePage : GamePage
{
Expand Down Expand Up @@ -55,7 +55,7 @@ private void InitializeInfoArea()
newGameButton.Clicked += NewGameClicked;
}

private async void NewGameClicked(object sender,EventArgs e)
private async void NewGameClicked(object sender, EventArgs e)
{
bool result = await DisplayAlert(Properties.GamePage.Msg_Title_NewGame,
Properties.GamePage.Msg_Text_NewGame,
Expand All @@ -69,7 +69,7 @@ private async void GameEndMsg()
bool result = await DisplayAlert(Properties.GamePage.Msg_Title_Finished,
Properties.StringTools.MultiLine(
Properties.GamePage.Msg_Text_Finished,
Properties.StringTools.Replace(Properties.GamePage.Msg_Text_Count,core.Count.ToString())),
string.Format(Properties.GamePage.Msg_Text_Count, core.Count.ToString())),
Properties.GamePage.Msg_Button_NewGame,
Properties.GamePage.Msg_Button_OK);
if (result) NewGame();
Expand All @@ -84,29 +84,29 @@ private void NewGame()
}
if (randomMode)
{
MainPage mainPage = (MainPage)((NavigationPage)App.Current.MainPage).RootPage;
MainPage mainPage = (MainPage)((NavigationPage)Application.Current.MainPage).RootPage;
int maxSize = SizeCalculator.GetMaxSize(SizeCalculator.GetTotalSize(mainPage.WindowSize.width, mainPage.WindowSize.height));
if (maxSize > 9) maxSize = 9;
gameSize = random1.Next(3, 1 + maxSize);
}
counter.Text = "0";
stateLabel.Text = Properties.GamePage.State_Preparing;
Initialize(gameSize);
core = new GameCore<GameButton>(blocks,new Random());
core = new GameCore<GameButton>(blocks, new Random());
core.BlockClicked += BlockClicked;
core.GameEnded += Ended;
stateLabel.Text = Properties.GamePage.State_Unfinished;
Statistics.Normal.AddGame(gameSize);
Show();
}

private void BlockClicked(object sender,EventArgs e)
private void BlockClicked(object sender, EventArgs e)
{
counter.Text = core.Count.ToString();
Statistics.Normal.AddClick(gameSize);
}

private void Ended(object sender,EventArgs e)
private void Ended(object sender, EventArgs e)
{
stateLabel.Text = Properties.GamePage.State_Finished;
Statistics.Normal.AddWin(gameSize);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;

using BlackWhite.App.Game.Base;
using BlackWhite.Core;

using Xamarin.Forms;

namespace BlackWhite.App
namespace BlackWhite.App.Game.Main
{
internal class PerfectGamePage : GamePage
{
Expand Down Expand Up @@ -61,7 +61,7 @@ private void InitializeInfoArea()
newGameButton.Clicked += NewGameClicked;
}

private async void NewGameClicked(object sender,EventArgs e)
private async void NewGameClicked(object sender, EventArgs e)
{
bool result = await DisplayAlert(Properties.GamePage.Msg_Title_NewGame,
Properties.GamePage.Msg_Text_NewGame,
Expand All @@ -75,8 +75,8 @@ private async void GameEndMsg()
bool result = await DisplayAlert(Properties.GamePage.Msg_Title_Finished,
Properties.StringTools.MultiLine(
Properties.GamePage.Msg_Text_Finished,
Properties.StringTools.Replace(Properties.GamePage.Msg_Text_Count,core.Count.ToString()),
Properties.StringTools.Replace(Properties.GamePage.Msg_Text_Remaining,core.Remaining.ToString())),
string.Format(Properties.GamePage.Msg_Text_Count, core.Count.ToString()),
string.Format(Properties.GamePage.Msg_Text_Remaining, core.Remaining.ToString())),
Properties.GamePage.Msg_Button_NewGame,
Properties.GamePage.Msg_Button_OK);
if (result) NewGame();
Expand All @@ -101,15 +101,15 @@ private void NewGame()
}
if (randomMode)
{
MainPage mainPage = (MainPage)((NavigationPage)App.Current.MainPage).RootPage;
MainPage mainPage = (MainPage)((NavigationPage)Application.Current.MainPage).RootPage;
int maxSize = SizeCalculator.GetMaxSize(SizeCalculator.GetTotalSize(mainPage.WindowSize.width, mainPage.WindowSize.height));
if (maxSize > 9) maxSize = 9;
gameSize = random1.Next(3, 1 + maxSize);
}
counter.Text = "0";
stateLabel.Text = Properties.GamePage.State_Preparing;
Initialize(gameSize);
core = new PerfectCore<GameButton>(blocks,new Random());
core = new PerfectCore<GameButton>(blocks, new Random());
core.BlockClicked += BlockClicked;
core.GameEnded += Ended;
core.GameStopped += GameStopMsg;
Expand All @@ -119,14 +119,14 @@ private void NewGame()
Show();
}

private void BlockClicked(object sender,EventArgs e)
private void BlockClicked(object sender, EventArgs e)
{
counter.Text = core.Count.ToString();
remainCounter.Text = core.Remaining.ToString();
Statistics.Perfect.AddClick(gameSize);
}

private void Ended(object sender,EventArgs e)
private void Ended(object sender, EventArgs e)
{
stateLabel.Text = Properties.GamePage.State_Finished;
Statistics.Perfect.AddWin(gameSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
using System.Collections.Generic;
using System.Text;
using System.Threading;
using BlackWhite.App.Game.Base;
using BlackWhite.Core;

using Xamarin.Forms;

namespace BlackWhite.App
namespace BlackWhite.App.Game.Main
{
internal class TimedGamePage : GamePage
{
Expand All @@ -25,7 +26,7 @@ internal class TimedGamePage : GamePage
private Label timeLabel = new Label() { Text = Properties.GamePage.Time, TextColor = Color.White, FontSize = 20, HorizontalTextAlignment = TextAlignment.Center };
private Label timerLabel = new Label() { TextColor = Color.White, FontSize = 20, HorizontalTextAlignment = TextAlignment.Center };

private System.Threading.Thread timer;
private Thread timer;
private uint timeCount = 0;
private StopControler stopControler = new StopControler();

Expand Down Expand Up @@ -59,7 +60,7 @@ private void InitializeInfoArea()
newGameButton.Clicked += NewGameClicked;
}

private async void NewGameClicked(object sender,EventArgs e)
private async void NewGameClicked(object sender, EventArgs e)
{
bool result = await DisplayAlert(Properties.GamePage.Msg_Title_NewGame,
Properties.GamePage.Msg_Text_NewGame,
Expand All @@ -73,7 +74,7 @@ private async void GameEndMsg()
bool result = await DisplayAlert(Properties.GamePage.Msg_Title_Finished,
Properties.StringTools.MultiLine(
Properties.GamePage.Msg_Text_Finished,
Properties.StringTools.Replace(Properties.GamePage.Msg_Text_Time,timeCount.ToString())),
string.Format(Properties.GamePage.Msg_Text_Time, timeCount.ToString())),
Properties.GamePage.Msg_Button_NewGame,
Properties.GamePage.Msg_Button_OK);
if (result) NewGame();
Expand All @@ -86,13 +87,13 @@ private void NewGame()
core.Close();
core = null;
}
if(timer != null)
if (timer != null)
{
timer = null;
}
if (randomMode)
{
MainPage mainPage = (MainPage)((NavigationPage)App.Current.MainPage).RootPage;
MainPage mainPage = (MainPage)((NavigationPage)Application.Current.MainPage).RootPage;
int maxSize = SizeCalculator.GetMaxSize(SizeCalculator.GetTotalSize(mainPage.WindowSize.width, mainPage.WindowSize.height));
if (maxSize > 9) maxSize = 9;
gameSize = random1.Next(3, 1 + maxSize);
Expand All @@ -102,12 +103,12 @@ private void NewGame()
stopControler = new StopControler() { stop = false };
stateLabel.Text = Properties.GamePage.State_Preparing;
Initialize(gameSize);
core = new GameCore<GameButton>(blocks,new Random());
core = new GameCore<GameButton>(blocks, new Random());
core.BlockClicked += BlockClicked;
core.GameEnded += Ended;
stateLabel.Text = Properties.GamePage.State_Unfinished;
Statistics.Timed.AddGame(gameSize);
timer = new System.Threading.Thread((object stopCtrl) =>
timer = new Thread((stopCtrl) =>
{
StopControler stopControler1 = (StopControler)stopCtrl;
while (true)
Expand All @@ -123,12 +124,12 @@ private void NewGame()
Show();
}

private void BlockClicked(object sender,EventArgs e)
private void BlockClicked(object sender, EventArgs e)
{
Statistics.Timed.AddClick(gameSize);
}

private void Ended(object sender,EventArgs e)
private void Ended(object sender, EventArgs e)
{
stopControler.stop = true;
stateLabel.Text = Properties.GamePage.State_Finished;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BlackWhite.App.ButtonCardView"
x:Class="BlackWhite.App.Game.Select.ButtonCardView"
Margin="5">
<ContentView.Content>
<Frame BackgroundColor="{AppThemeBinding Dark=Black,Light=White,Default=White}" BorderColor="Gray" Padding="20" CornerRadius="8">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace BlackWhite.App
namespace BlackWhite.App.Game.Select
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ButtonCardView : ContentView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:p="clr-namespace:BlackWhite.App.Properties"
x:Class="BlackWhite.App.SizePage">
x:Class="BlackWhite.App.Game.Select.SizePage">
<ContentPage.Content>
<StackLayout>
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using BlackWhite.App.Game.Base;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace BlackWhite.App
namespace BlackWhite.App.Game.Select
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SizePage : ContentPage
{
protected Button[] buttons;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using BlackWhite.App.Game.Main;
using System;
using System.Collections.Generic;
using System.Text;

namespace BlackWhite.App
namespace BlackWhite.App.Game.Select
{
internal class NormalSizePage : SizePage
{
Expand All @@ -11,7 +12,7 @@ public NormalSizePage()

protected override void StartGame(int size)
{
if(size == -1)
if (size == -1)
{
Navigation.PushAsync(new NormalGamePage(new Random()));
}
Expand All @@ -26,7 +27,7 @@ protected override void StartGame(int size)
internal class PerfectSizePage : SizePage
{
public PerfectSizePage()
:base(Properties.StartPage.Perfect, Properties.StartPage.Perfect_Text) { }
: base(Properties.StartPage.Perfect, Properties.StartPage.Perfect_Text) { }

protected override void StartGame(int size)
{
Expand Down
Loading

0 comments on commit 6289ad7

Please sign in to comment.