Skip to content

Commit

Permalink
发布预览版本17
Browse files Browse the repository at this point in the history
  • Loading branch information
HPLZH committed Aug 14, 2022
1 parent 71c3d75 commit 00a3879
Show file tree
Hide file tree
Showing 41 changed files with 2,341 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
<Compile Include="OrientationService.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
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>
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,4 @@
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: MetaData("android:versionName", Value = AppVersion.MainVersion+"." + AppVersion.SubVersion + "." + AppVersion.Build)]
[assembly: MetaData("android:versionCode", Value = AppVersion.Build)]

#if DEBUG
[assembly: MetaData("package", Value = "cn.hplzh.blackwhite.app.debug")]
#else
[assembly: MetaData("package", Value = "cn.hplzh.blackwhite.app")]
#endif

// Add some common permissions, these can be removed if not needed
26 changes: 25 additions & 1 deletion BlackWhite.App/BlackWhite.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,36 @@ public partial class App : Application
{
public App()
{
//App.Current.Properties.Clear();

InitializeComponent();

//MainPage = new MainPage();
ChangeLanguage();

MainPage = new NavigationPage(new MainPage());
}

public static void ChangeLanguage()
{
System.Globalization.CultureInfo culture;
if (Settings.Language == null)
{
culture = System.Globalization.CultureInfo.CurrentCulture;
}
else
{
culture = new System.Globalization.CultureInfo(Settings.Language);
}

System.Globalization.CultureInfo.CurrentUICulture = culture;

BlackWhite.App.Properties.App.Culture = culture;
BlackWhite.App.Properties.MainPage.Culture = culture;
BlackWhite.App.Properties.VersionPage.Culture = culture;
BlackWhite.App.Properties.StartPage.Culture = culture;
BlackWhite.App.Properties.GamePage.Culture = culture;
}

protected override void OnStart()
{
}
Expand Down
9 changes: 4 additions & 5 deletions BlackWhite.App/BlackWhite.App/AppVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ namespace BlackWhite.App
{
public static class AppVersion
{
public static Version Version => new Version($"{MainVersion}.{SubVersion}.{Build}");
public const string MainVersion = "3";
public const string SubVersion = "0";
public const string Build = "17";
public static Version Version => new Version(3,0,17);

public static DateTime ReleaseDate => new DateTime(2022, 8, 7);
public static DateTime ReleaseDate => new DateTime(2022, 8, 14);

public static bool Preview => true;
}
}
46 changes: 46 additions & 0 deletions BlackWhite.App/BlackWhite.App/BlackWhite.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,36 @@
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\BlackWhite.Core\BlackWhite.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\App.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>App.resx</DependentUpon>
</Compile>
<Compile Update="Properties\GamePage.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>GamePage.resx</DependentUpon>
</Compile>
<Compile Update="Properties\MainPage.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>MainPage.resx</DependentUpon>
</Compile>
<Compile Update="Properties\StartPage.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>StartPage.resx</DependentUpon>
</Compile>
<Compile Update="Properties\StatisticsPage.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>StatisticsPage.resx</DependentUpon>
</Compile>
<Compile Update="Properties\VersionPage.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand All @@ -34,18 +53,45 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="ButtonCardView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="GamePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Properties\App.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>App.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Properties\GamePage.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>GamePage.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Properties\MainPage.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>MainPage.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Properties\StartPage.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>StartPage.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Properties\StatisticsPage.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>StatisticsPage.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Properties\VersionPage.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>VersionPage.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="SizePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="StartPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="StatisticsPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="VersionPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
Expand Down
23 changes: 23 additions & 0 deletions BlackWhite.App/BlackWhite.App/ButtonCardView.xaml
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>
45 changes: 45 additions & 0 deletions BlackWhite.App/BlackWhite.App/ButtonCardView.xaml.cs
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);
}
}
}
45 changes: 45 additions & 0 deletions BlackWhite.App/BlackWhite.App/GameButton.cs
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;
}
}
}
}
20 changes: 20 additions & 0 deletions BlackWhite.App/BlackWhite.App/GamePage.xaml
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>
86 changes: 86 additions & 0 deletions BlackWhite.App/BlackWhite.App/GamePage.xaml.cs
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();
}
}
}
Loading

0 comments on commit 00a3879

Please sign in to comment.