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

Fix help modal display and added mobile help window #5

Open
wants to merge 3 commits into
base: master
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
13 changes: 10 additions & 3 deletions Scrabble/Scrabble.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@
<Compile Include="View\BlankTileForm.xaml.cs">
<DependentUpon>BlankTileForm.xaml</DependentUpon>
</Compile>
<Compile Include="View\HelpWindow.xaml.cs">
<DependentUpon>HelpWindow.xaml</DependentUpon>
<Compile Include="View\MobileHelpWindow.xaml.cs">
<DependentUpon>MobileHelpWindow.xaml</DependentUpon>
</Compile>
<Compile Include="View\DesktopHelpWindow.xaml.cs">
<DependentUpon>DesktopHelpWindow.xaml</DependentUpon>
</Compile>
<Compile Include="View\TextWindow.xaml.cs">
<DependentUpon>TextWindow.xaml</DependentUpon>
Expand All @@ -101,7 +104,11 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\HelpWindow.xaml">
<Page Include="View\MobileHelpWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="View\DesktopHelpWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Window x:Class="Scrabble.View.HelpWindow"
<Window x:Class="Scrabble.View.DesktopHelpWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down
14 changes: 14 additions & 0 deletions Scrabble/View/DesktopHelpWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Windows;

namespace Scrabble.View
{
public partial class DesktopHelpWindow : Window
{
public DesktopHelpWindow()
{
InitializeComponent();
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
Topmost = true;
}
}
}
2 changes: 1 addition & 1 deletion Scrabble/View/DesktopWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
mc:Ignorable="d"
Title="Scrabble" Height="720" Width="1280"
Background="AntiqueWhite"
ResizeMode="CanMinimize"
Topmost="False"
KeyDown="Window_KeyDown"
>

Expand Down
32 changes: 29 additions & 3 deletions Scrabble/View/DesktopWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
using Scrabble.Model;
using Scrabble.Controller;
using Scrabble.Model.Game;
using System.Linq;
using System.Diagnostics;


namespace Scrabble
{
Expand All @@ -25,6 +28,7 @@ public DesktopWindow(int P, Game g)
{
InitializeComponent();
ThisPlayer = P;
this.Topmost= false;
game = g;
game.Subs(this);
GameState.GSInstance.OnStateChanged += OnStateChanged;
Expand Down Expand Up @@ -378,10 +382,32 @@ private void Window_KeyDown(object sender, KeyEventArgs e)
}
}

private void HelpButton_Click(object sender, RoutedEventArgs e)
private async void HelpButton_Click(object sender, RoutedEventArgs e)
{
HelpWindow hw = new HelpWindow();
hw.ShowDialog();
bool isfound = false;
foreach (var item in Application.Current.Windows)
{
Debug.WriteLine(item.GetType());
if (item.GetType()==typeof(DesktopHelpWindow))
{
((DesktopHelpWindow)item).Top = (System.Windows.SystemParameters.WorkArea.Height / 2)-(((DesktopHelpWindow)item).Height/2);
((DesktopHelpWindow)item).Left = (System.Windows.SystemParameters.WorkArea.Width / 2) - (((DesktopHelpWindow)item).Width / 2);
((DesktopHelpWindow)item).Topmost=false;
((DesktopHelpWindow)item).Topmost = true;
return;
}
}
if (!isfound)
{
DesktopHelpWindow hw = new DesktopHelpWindow();
hw.Show();
}





}

}
}
12 changes: 0 additions & 12 deletions Scrabble/View/HelpWindow.xaml.cs

This file was deleted.

17 changes: 17 additions & 0 deletions Scrabble/View/MobileHelpWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Window x:Class="Scrabble.View.MobileHelpWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Scrabble.View"
mc:Ignorable="d"
ResizeMode="CanMinimize"
Title="Board Tile Types" Height="200" Width="150">
<Grid>
<Button ToolTip="Covering this tile will get 3 times word score" Content="3xWord" Background="OrangeRed" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="50" Height="50"/>
<Button Content="2xWord" ToolTip="Covering this tile will get 2 times word score" Background="Coral" HorizontalAlignment="Left" Margin="80,10,0,0" VerticalAlignment="Top" Width="50" Height="50"/>
<Button Content="3xLetter" ToolTip="Covering this tile will get 3 times the letter score" Background="MediumBlue" HorizontalAlignment="Left" Margin="10,80,0,0" VerticalAlignment="Top" Width="50" Height="50"/>
<Button Content="2xLetter" ToolTip="Covering this tile will get 2 times the letter score" Background="LightSkyBlue" HorizontalAlignment="Left" Margin="81,79,0,0" VerticalAlignment="Top" Width="50" Height="50"/>

</Grid>
</Window>
14 changes: 14 additions & 0 deletions Scrabble/View/MobileHelpWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Windows;

namespace Scrabble.View
{
public partial class MobileHelpWindow : Window
{
public MobileHelpWindow()
{
InitializeComponent();
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
Topmost = true;
}
}
}
13 changes: 8 additions & 5 deletions Scrabble/View/MobileWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
ResizeMode="CanMinimize"
>

<Grid>
<Button x:Name="ValidateButton" FontSize="15" Background="Green" Foreground="White" IsEnabled="True" Content="DONE" HorizontalAlignment="Left" Margin="151,243,0,0" VerticalAlignment="Top" Width="69" Height="24" Click="ValidateButton_Click"/>
<Button x:Name="SwapButton" FontSize="15" Background="Tomato" Foreground="White" IsEnabled="True" Content="SWAP" HorizontalAlignment="Left" Margin="12,243,0,0" VerticalAlignment="Top" Width="70" Height="24" Click="SwapButton_Click"/>
<Button x:Name="ReloadButton" FontSize="15" Background="PaleVioletRed" Foreground="White" IsEnabled="True" Content="RELOAD" HorizontalAlignment="Left" Margin="82,243,0,0" VerticalAlignment="Top" Width="69" Height="24" Click="ReloadButton_Click"/>
<UniformGrid x:Name="BoardGrid" Columns="15" Rows="15" HorizontalAlignment="Left" Height="235" VerticalAlignment="Top" Width="233" Margin="0,6,0,0">
<Grid Margin="-1,1,1,-1" RenderTransformOrigin="0.844,0.686">

<Button x:Name="ValidateButton" FontSize="15" Background="Green" Foreground="White" IsEnabled="True" Content="DONE" HorizontalAlignment="Left" Margin="130,243,0,0" VerticalAlignment="Top" Width="50" Height="24" Click="ValidateButton_Click"/>
<Button x:Name="SwapButton" FontSize="15" Background="Tomato" Foreground="White" IsEnabled="True" Content="SWAP" HorizontalAlignment="Left" Margin="12,243,0,0" VerticalAlignment="Top" Width="50" Height="24" Click="SwapButton_Click"/>
<Button x:Name="ReloadButton" FontSize="15" Background="PaleVioletRed" Foreground="White" IsEnabled="True" Content="RELOAD" HorizontalAlignment="Left" Margin="67,243,0,0" VerticalAlignment="Top" Width="58" Height="24" Click="ReloadButton_Click"/>
<Button x:Name="HelpButton" Width="25" Height="24" FontSize="15" Background="Blue" Foreground="White" Margin="185,243,30,0" IsEnabled="True" VerticalAlignment="Top" FontFamily="Segoe MDL2 Assets" Content="&#xE897;" RenderTransformOrigin="1.9,-1.965" Click="HelpButton_Click"/>
<UniformGrid x:Name="BoardGrid" Columns="15" Rows="15" HorizontalAlignment="Left" Height="235" VerticalAlignment="Top" Width="233" Margin="0,6,0,0" >

<UniformGrid.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="0.5"/>
Expand Down
22 changes: 22 additions & 0 deletions Scrabble/View/MobileWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Scrabble.View;
using Scrabble.Model;
using Scrabble.Controller;
using System.Diagnostics;

namespace Scrabble
{
Expand Down Expand Up @@ -337,5 +338,26 @@ public void OnStateChanged()
WriteToLabel(null);
}

private void HelpButton_Click(object sender, RoutedEventArgs e)
{
bool isfound = false;
foreach (var item in Application.Current.Windows)
{
Debug.WriteLine(item.GetType());
if (item.GetType()==typeof(MobileHelpWindow))
{
((MobileHelpWindow)item).Top = (System.Windows.SystemParameters.WorkArea.Height / 2)-(((MobileHelpWindow)item).Height/2);
((MobileHelpWindow)item).Left = (System.Windows.SystemParameters.WorkArea.Width / 2) - (((MobileHelpWindow)item).Width / 2);
((MobileHelpWindow)item).Topmost=false;
((MobileHelpWindow)item).Topmost = true;
return;
}
}
if (!isfound)
{
MobileHelpWindow hw = new MobileHelpWindow();
hw.Show();
}
}
}
}