-
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
41 changed files
with
2,341 additions
and
63 deletions.
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
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"> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="cn.hplzh.blackwhite.app" android:versionCode="17" android:versionName="3.0.17"> | ||
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="31" /> | ||
<application android:label="BlackWhite.App.Android" android:theme="@style/MainTheme"></application> | ||
<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
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,23 @@ | ||
<?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" | ||
Margin="5"> | ||
<ContentView.Content> | ||
<Frame BackgroundColor="{AppThemeBinding Dark=Black,Light=White,Default=White}" BorderColor="Gray" Padding="20" CornerRadius="8"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="1*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Label x:Name="titleLabel" FontSize="Title" TextColor="{AppThemeBinding Dark=White,Light=Black,Default=Black}" Grid.Column="0" Grid.Row="0"></Label> | ||
<Label x:Name="textLabel" FontSize="Default" TextColor="{AppThemeBinding Dark=White,Light=Black,Default=Black}" Grid.Column="0" Grid.Row="1"></Label> | ||
<Button x:Name="button" FontSize="Title" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Clicked="button_Clicked"></Button> | ||
</Grid> | ||
</Frame> | ||
</ContentView.Content> | ||
</ContentView> |
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,45 @@ | ||
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 | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class ButtonCardView : ContentView | ||
{ | ||
public ButtonCardView () | ||
{ | ||
InitializeComponent (); | ||
} | ||
|
||
public string Title | ||
{ | ||
get => titleLabel.Text; | ||
set => titleLabel.Text = value; | ||
} | ||
|
||
public string Text | ||
{ | ||
get => textLabel.Text; | ||
set => textLabel.Text = value; | ||
} | ||
|
||
public string ButtonText | ||
{ | ||
get => button.Text; | ||
set => button.Text = value; | ||
} | ||
|
||
public event EventHandler ButtonClicked; | ||
|
||
private void button_Clicked(object sender, EventArgs e) | ||
{ | ||
ButtonClicked(sender, e); | ||
} | ||
} | ||
} |
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,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xamarin.Forms; | ||
using BlackWhite.Core; | ||
|
||
namespace BlackWhite.App | ||
{ | ||
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)); }; | ||
} | ||
|
||
public event EventHandler<BlockClickedEventArgs> BlockClicked; | ||
|
||
bool _value; | ||
public bool Value | ||
{ | ||
get => _value; | ||
set | ||
{ | ||
_value = value; | ||
this.BackgroundColor = _value ? Color.White : Color.Black; | ||
} | ||
} | ||
|
||
public new uint X { get; set; } | ||
public new uint Y { get; set; } | ||
|
||
Blocks<GameButton> _blocks = null; | ||
public new Blocks<GameButton> Parent | ||
{ | ||
get => _blocks; | ||
set | ||
{ | ||
_blocks = value; | ||
} | ||
} | ||
} | ||
} |
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,20 @@ | ||
<?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:c="clr-namespace:BlackWhite.App" | ||
x:Class="BlackWhite.App.GamePage"> | ||
<ContentPage.Content> | ||
<StackLayout x:Name="pageStack"> | ||
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0"> | ||
<ScrollView x:Name="infoArea"></ScrollView> | ||
</Frame> | ||
<ScrollView Orientation="Both"> | ||
<AbsoluteLayout Padding="{x:Static c:SizeCalculator.LAYOUT_PADDING}" x:Name="absLayout"> | ||
<Grid x:Name="blockGrid" | ||
RowSpacing="{x:Static c:SizeCalculator.SPACING}" | ||
ColumnSpacing="{x:Static c:SizeCalculator.SPACING}"></Grid> | ||
</AbsoluteLayout> | ||
</ScrollView> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
</ContentPage> |
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,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Xamarin.Forms; | ||
using Xamarin.Forms.Xaml; | ||
|
||
using BlackWhite.Core; | ||
|
||
namespace BlackWhite.App | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class GamePage : ContentPage | ||
{ | ||
protected Blocks<GameButton> blocks; | ||
private int gameSize; | ||
private bool open = false; | ||
|
||
protected View InfoContent | ||
{ | ||
get { return infoArea.Content; } | ||
set { infoArea.Content = value; } | ||
} | ||
|
||
public GamePage () | ||
{ | ||
InitializeComponent (); | ||
} | ||
|
||
protected override void OnSizeAllocated(double width, double height) | ||
{ | ||
//if (width <= 0 || height <= 0) return; | ||
pageStack.Orientation = width < height ? StackOrientation.Vertical : StackOrientation.Horizontal; | ||
infoArea.Orientation = width < height ? ScrollOrientation.Horizontal : ScrollOrientation.Vertical; | ||
if (open) | ||
{ | ||
foreach(ColumnDefinition column in blockGrid.ColumnDefinitions) | ||
{ | ||
column.Width = SizeCalculator.GetBlockSize(SizeCalculator.GetTotalSize(width, height), gameSize); | ||
} | ||
foreach(RowDefinition row in blockGrid.RowDefinitions) | ||
{ | ||
row.Height = SizeCalculator.GetBlockSize(SizeCalculator.GetTotalSize(width, height), gameSize); | ||
} | ||
} | ||
base.OnSizeAllocated(width, height); | ||
} | ||
|
||
protected void Initialize(int size) | ||
{ | ||
Close(); | ||
open = true; | ||
gameSize = size; | ||
blocks = new Blocks<GameButton>((uint)size, (uint)size); | ||
for (int i = 0; i < size; i++) | ||
{ | ||
blockGrid.RowDefinitions.Add(new RowDefinition()); | ||
blockGrid.ColumnDefinitions.Add(new ColumnDefinition()); | ||
} | ||
foreach(GameButton button in blocks) | ||
{ | ||
blockGrid.Children.Add(button, (int)button.X, (int)button.Y); | ||
} | ||
} | ||
|
||
protected void Show() | ||
{ | ||
blockGrid.IsVisible = true; | ||
OnSizeAllocated(SizeCalculator.GetMainPage().WindowSize.width, SizeCalculator.GetMainPage().WindowSize.height); | ||
blockGrid.ForceLayout(); | ||
} | ||
|
||
protected void Hide() => blockGrid.IsVisible = false; | ||
|
||
protected void Close() | ||
{ | ||
Hide(); | ||
open = false; | ||
blockGrid.Children.Clear(); | ||
blockGrid.ColumnDefinitions.Clear(); | ||
blockGrid.RowDefinitions.Clear(); | ||
} | ||
} | ||
} |
Oops, something went wrong.