-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to change number of sound buttons per page (with undo)
- Loading branch information
Showing
14 changed files
with
802 additions
and
247 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<soundBoard:ChildWindowBase x:Class="SoundBoard.ButtonGridDialog" x:ClassModifier="internal" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow" | ||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" | ||
xmlns:soundBoard="clr-namespace:SoundBoard" | ||
mc:Ignorable="d" | ||
|
||
Title="Change Button Grid" | ||
IsModal="true" | ||
Padding="100" | ||
ShowCloseButton="true" | ||
AllowMove="true" | ||
CloseByEscape="true"> | ||
|
||
<simpleChildWindow:ChildWindow.OverlayBrush> | ||
<SolidColorBrush Opacity="0.7" Color="{StaticResource BlackColor}" /> | ||
</simpleChildWindow:ChildWindow.OverlayBrush> | ||
|
||
<!-- Content --> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="50"/> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="20"/> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="50"/> | ||
<RowDefinition Height="Auto"/> | ||
</Grid.RowDefinitions> | ||
|
||
<Grid Grid.Row="1"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="100"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="10"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="20"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="100"/> | ||
</Grid.ColumnDefinitions> | ||
|
||
<xctk:IntegerUpDown x:Name="RowUpDown" | ||
Grid.Column="1" | ||
Minimum="1" | ||
ValueChanged="RowUpDown_ValueChanged" | ||
DefaultValue="5" | ||
DisplayDefaultValueOnEmptyText="true" | ||
KeyUp="RowUpDown_KeyUp"/> | ||
<Label Grid.Column="2" Content="Row(s)"/> | ||
<Label Grid.Column="4" Content="✖"/> | ||
<xctk:IntegerUpDown x:Name="ColumnUpDown" | ||
Grid.Column="6" | ||
Minimum="1" | ||
ValueChanged="ColumnUpDown_ValueChanged" | ||
DefaultValue="2" | ||
DisplayDefaultValueOnEmptyText="true" | ||
KeyUp="ColumnUpDown_KeyUp"/> | ||
<Label Grid.Column="7" Content="Column(s)"/> | ||
</Grid> | ||
|
||
<Label x:Name="WarningLabel" | ||
HorizontalAlignment="Center" | ||
Grid.Row="4" Content="Warning! Removing row(s) or column(s) could result in losing sounds!" | ||
Foreground="Red" | ||
FontWeight="Medium" | ||
Visibility="Hidden"/> | ||
|
||
<Grid Grid.Row="5" Margin="20, 20, 20, 20"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="10"/> | ||
<ColumnDefinition Width="Auto"/> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Button Grid.Column="1" Content="OK" Style="{StaticResource MyAccentedSquareButtonStyle}" Width="80" Height="35" Click="OKButton_Click"/> | ||
<Button Grid.Column="3" Content="Cancel" Style="{StaticResource MySquareButtonStyle}" Width="80" Height="35" Click="CancelButton_Click"/> | ||
</Grid> | ||
</Grid> | ||
</soundBoard:ChildWindowBase> |
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,132 @@ | ||
#region Usings | ||
|
||
using System.Windows; | ||
using System.Windows.Forms; | ||
using System.Windows.Input; | ||
|
||
#endregion | ||
|
||
namespace SoundBoard | ||
{ | ||
/// <summary> | ||
/// Interaction logic for ButtonGridDialog.xaml | ||
/// </summary> | ||
internal partial class ButtonGridDialog | ||
{ | ||
#region Constructor | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
public ButtonGridDialog() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
/// <param name="startingRowCount"></param> | ||
/// <param name="startingColumnCount"></param> | ||
public ButtonGridDialog(int startingRowCount, int startingColumnCount) : this() | ||
{ | ||
RowCount = _startingRowCount = startingRowCount; | ||
ColumnCount = _startingColumnCount = startingColumnCount; | ||
} | ||
|
||
#endregion | ||
|
||
#region Public properties | ||
|
||
/// <summary> | ||
/// The result of the dialog | ||
/// </summary> | ||
public DialogResult DialogResult; | ||
|
||
/// <summary> | ||
/// Number of rows | ||
/// </summary> | ||
public int RowCount | ||
{ | ||
get => RowUpDown.Value ?? default; | ||
set => RowUpDown.Value = value; | ||
} | ||
|
||
/// <summary> | ||
/// Number of columns | ||
/// </summary> | ||
public int ColumnCount | ||
{ | ||
get => ColumnUpDown.Value ?? default; | ||
set => ColumnUpDown.Value = value; | ||
} | ||
|
||
#endregion | ||
|
||
#region Private fields | ||
|
||
private readonly int _startingRowCount; | ||
|
||
private readonly int _startingColumnCount; | ||
|
||
#endregion | ||
|
||
#region Event handlers | ||
|
||
private void OKButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
DialogResult = DialogResult.OK; | ||
Close(); | ||
} | ||
|
||
private void CancelButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
DialogResult = DialogResult.Cancel; | ||
Close(); | ||
} | ||
|
||
private void ColumnUpDown_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) | ||
{ | ||
if (e.Key == Key.Enter) | ||
{ | ||
DialogResult = DialogResult.OK; | ||
Close(); | ||
} | ||
} | ||
|
||
private void RowUpDown_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) | ||
{ | ||
if (e.Key == Key.Enter) | ||
{ | ||
DialogResult = DialogResult.OK; | ||
Close(); | ||
} | ||
} | ||
|
||
private void RowUpDown_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e) | ||
{ | ||
ShowHideWarningLabel(); | ||
} | ||
|
||
private void ColumnUpDown_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e) | ||
{ | ||
ShowHideWarningLabel(); | ||
} | ||
|
||
#endregion | ||
|
||
#region Private methods | ||
|
||
private void ShowHideWarningLabel() | ||
{ | ||
if (WarningLabel is null == false) | ||
{ | ||
WarningLabel.Visibility = RowUpDown.Value < _startingRowCount || ColumnUpDown.Value < _startingColumnCount | ||
? Visibility.Visible | ||
: Visibility.Hidden; | ||
} | ||
} | ||
|
||
#endregion | ||
} | ||
} |
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,39 @@ | ||
#region Usings | ||
|
||
using System.Collections.Generic; | ||
using MahApps.Metro.SimpleChildWindow; | ||
|
||
#endregion | ||
|
||
namespace SoundBoard | ||
{ | ||
/// <summary> | ||
/// Defines a ChildWindow from which all other ChildWindows in this project shall derive | ||
/// </summary> | ||
internal class ChildWindowBase : ChildWindow | ||
{ | ||
#region Constructor | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
public ChildWindowBase() | ||
{ | ||
_instances.Add(this); | ||
} | ||
|
||
#endregion | ||
|
||
#region Public properties | ||
|
||
public static IEnumerable<ChildWindowBase> Instances => _instances; | ||
|
||
#endregion | ||
|
||
#region Private fields | ||
|
||
private static readonly List<ChildWindowBase> _instances = new List<ChildWindowBase>(); | ||
|
||
#endregion | ||
} | ||
} |
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.