-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
433 additions
and
9 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
BlackWhite.App/BlackWhite.App.Android/Properties/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="cn.hplzh.blackwhite.app" android:versionCode="22" android:versionName="3.1.22"> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="cn.hplzh.blackwhite.app" android:versionCode="23" android:versionName="3.2.23"> | ||
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="31" /> | ||
<application android:label="BlackWhite.App.Android" android:theme="@style/MainTheme" android:icon="@mipmap/icon"></application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using BlackWhite.App.Game.Base; | ||
using BlackWhite.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xamarin.Forms; | ||
|
||
namespace BlackWhite.App.Game.Main | ||
{ | ||
internal class FreeGamePage : GamePage | ||
{ | ||
private FreeCore<GameButton> core; | ||
private Random random = new Random(); | ||
|
||
private StackLayout toolStack = new StackLayout(); | ||
private StackLayout generateStack = new StackLayout() { HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Vertical }; | ||
private StackLayout clickStack = new StackLayout() { HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Vertical }; | ||
|
||
private Label generateLabel = new Label() { Text = Properties.GamePage.Generate, TextColor = Color.White, FontSize = 20, HorizontalTextAlignment = TextAlignment.Center }; | ||
private Label clickLabel = new Label() { Text = Properties.GamePage.Click, TextColor = Color.White, FontSize = 20, HorizontalTextAlignment = TextAlignment.Center }; | ||
private Button generateButton = new Button() { Text = "..." }; | ||
private Switch clickSwitch = new Switch() { HorizontalOptions = LayoutOptions.Center }; | ||
|
||
public FreeGamePage(int size) | ||
: base() | ||
{ | ||
Initialize(size); | ||
InitializeToolBar(); | ||
core = new FreeCore<GameButton>(blocks); | ||
Show(); | ||
} | ||
|
||
private void InitializeToolBar() | ||
{ | ||
this.InfoContent = toolStack; | ||
toolStack.Children.Add(generateStack); | ||
toolStack.Children.Add(clickStack); | ||
generateStack.Children.Add(generateLabel); | ||
generateStack.Children.Add(generateButton); | ||
clickStack.Children.Add(clickLabel); | ||
clickStack.Children.Add(clickSwitch); | ||
generateButton.Clicked += GenerateButton_Clicked; | ||
clickSwitch.Toggled += ClickSwitch_Toggled; | ||
} | ||
|
||
private void ClickSwitch_Toggled(object sender, ToggledEventArgs e) | ||
{ | ||
if (clickSwitch.IsToggled) | ||
{ | ||
clickLabel.Text = Properties.GamePage.Single; | ||
core.ClickMode = FreeCore<GameButton>.ClickModes.Change; | ||
} | ||
else | ||
{ | ||
clickLabel.Text = Properties.GamePage.Click; | ||
core.ClickMode = FreeCore<GameButton>.ClickModes.Normal; | ||
} | ||
} | ||
|
||
private async void GenerateButton_Clicked(object sender, EventArgs e) | ||
{ | ||
string result = await DisplayActionSheet(Properties.GamePage.Generate, | ||
Properties.GamePage.Msg_Button_Cancel, | ||
null, | ||
Properties.GamePage.Generate_White, | ||
Properties.GamePage.Generate_Black, | ||
Properties.GamePage.Generate_GameRandomize, | ||
Properties.GamePage.Generate_FullRandomize, | ||
Properties.GamePage.Generate_MixRandomize, | ||
Properties.GamePage.Generate_Invert); | ||
if (result == Properties.GamePage.Generate_White) core.Clear(true); | ||
else if (result == Properties.GamePage.Generate_Black) core.Clear(false); | ||
else if (result == Properties.GamePage.Generate_GameRandomize) core.GameRandomize(random); | ||
else if (result == Properties.GamePage.Generate_FullRandomize) core.FullRandomize(random); | ||
else if (result == Properties.GamePage.Generate_MixRandomize) core.MixRandomize(random); | ||
else if (result == Properties.GamePage.Generate_Invert) core.Invert(); | ||
} | ||
|
||
protected override void OnSizeAllocated(double width, double height) | ||
{ | ||
toolStack.Orientation = width < height ? StackOrientation.Horizontal : StackOrientation.Vertical; | ||
base.OnSizeAllocated(width, height); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
using Xamarin.Forms; | ||
|
||
namespace BlackWhite.App.Game.Select | ||
{ | ||
internal class NumberButton : Button | ||
{ | ||
private int _value; | ||
public int Value | ||
{ | ||
get { return _value; } | ||
set | ||
{ | ||
_value = value; | ||
this.Text = _value.ToString(); | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
BlackWhite.App/BlackWhite.App/Game/Select/NumberSizePage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:p="clr-namespace:BlackWhite.App.Properties" | ||
xmlns:c="clr-namespace:BlackWhite.App.Game.Select" | ||
x:Class="BlackWhite.App.Game.Select.NumberSizePage"> | ||
<ContentPage.Content> | ||
<StackLayout> | ||
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0"> | ||
<StackLayout> | ||
<Label x:Name="titleLabel" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/> | ||
<Label x:Name="textLabel" HorizontalTextAlignment="Center" TextColor="White"></Label> | ||
</StackLayout> | ||
</Frame> | ||
<ScrollView> | ||
<StackLayout Padding="20"> | ||
<Label Text="{x:Static p:StartPage.Size_Label}" HorizontalOptions="Center"></Label> | ||
<Label Text="0" x:Name="sizeText" FontSize="Large" HorizontalOptions="Center"></Label> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="1*" /> | ||
<RowDefinition Height="1*" /> | ||
<RowDefinition Height="1*" /> | ||
<RowDefinition Height="1*" /> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="1*" /> | ||
<ColumnDefinition Width="1*" /> | ||
<ColumnDefinition Width="1*" /> | ||
</Grid.ColumnDefinitions> | ||
<Button x:Name="ac" Text="AC" Grid.Row="3" Grid.Column="2" FontSize="Large" Clicked="ac_Clicked"></Button> | ||
<c:NumberButton Value="0" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="3" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
<c:NumberButton Value="1" Grid.Column="0" Grid.Row="2" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
<c:NumberButton Value="2" Grid.Column="1" Grid.Row="2" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
<c:NumberButton Value="3" Grid.Column="2" Grid.Row="2" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
<c:NumberButton Value="4" Grid.Column="0" Grid.Row="1" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
<c:NumberButton Value="5" Grid.Column="1" Grid.Row="1" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
<c:NumberButton Value="6" Grid.Column="2" Grid.Row="1" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
<c:NumberButton Value="7" Grid.Column="0" Grid.Row="0" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
<c:NumberButton Value="8" Grid.Column="1" Grid.Row="0" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
<c:NumberButton Value="9" Grid.Column="2" Grid.Row="0" FontSize="Large" Clicked="NumberButton_Clicked"></c:NumberButton> | ||
</Grid> | ||
<Button x:Name="start" Text="{x:Static p:StartPage.Start_Button}" Clicked="start_Clicked" IsEnabled="False"></Button> | ||
</StackLayout> | ||
</ScrollView> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
</ContentPage> |
70 changes: 70 additions & 0 deletions
70
BlackWhite.App/BlackWhite.App/Game/Select/NumberSizePage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using BlackWhite.App.Game.Base; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Xamarin.Forms; | ||
using Xamarin.Forms.Xaml; | ||
|
||
namespace BlackWhite.App.Game.Select | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class NumberSizePage : ContentPage | ||
{ | ||
private int _size = 0; | ||
|
||
protected virtual void StartGame(int size) { } | ||
|
||
public NumberSizePage(string title, string text) | ||
{ | ||
InitializeComponent(); | ||
titleLabel.Text = title; | ||
textLabel.Text = text; | ||
ChangeValue(0); | ||
} | ||
|
||
private void ac_Clicked(object sender, EventArgs e) | ||
{ | ||
ChangeValue(0); | ||
} | ||
|
||
private void NumberButton_Clicked(object sender, EventArgs e) | ||
{ | ||
ChangeValue(_size * 10 + ((NumberButton)sender).Value); | ||
} | ||
|
||
private void start_Clicked(object sender, EventArgs e) | ||
{ | ||
StartGame(_size); | ||
} | ||
|
||
protected override void OnSizeAllocated(double width, double height) | ||
{ | ||
ChangeValue(_size); | ||
base.OnSizeAllocated(width, height); | ||
} | ||
|
||
private void ChangeValue(int value) | ||
{ | ||
_size = value; | ||
sizeText.Text = value.ToString(); | ||
if (value < 3) | ||
{ | ||
sizeText.TextColor = Color.Red; | ||
start.IsEnabled = false; | ||
} | ||
else if (value > SizeCalculator.GetMax()) | ||
{ | ||
sizeText.TextColor = Color.Orange; | ||
start.IsEnabled = true; | ||
} | ||
else | ||
{ | ||
sizeText.TextColor = Color.Green; | ||
start.IsEnabled = true; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.