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

Fixes and improvements #83

Open
wants to merge 1 commit 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
7 changes: 3 additions & 4 deletions source/Axiom/Axiom/Controls/Configure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ You should have received a copy of the GNU General Public License
using ViewModel;
using Axiom;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
// Disable XML Comment warnings
#pragma warning disable 1591

Expand Down Expand Up @@ -243,10 +244,8 @@ public static void WriteAxiomConf(string directory,
ConfigFile.conf = new ConfigFile(Path.Combine(directory, filename));

// Write each action in the list
foreach (Action Write in actionsToWrite)
{
Write();
}
foreach (var t in actionsToWrite)
t();
}
// Error
catch
Expand Down
8 changes: 4 additions & 4 deletions source/Axiom/Axiom/CropWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
VerticalAlignment="Top"
Width="60"
Style="{DynamicResource TextBoxStyle}"
KeyDown="tbxVideo_Crop_X_KeyDown"
TextInput="Allow_Only_Numbers"
ToolTipService.ShowOnDisabled="True"
ToolTip="Position of Crop from Left" />

Expand All @@ -82,7 +82,7 @@
VerticalAlignment="Top"
Width="60"
Style="{DynamicResource TextBoxStyle}"
KeyDown="tbxVideo_Crop_Y_KeyDown"
TextInput="Allow_Only_Numbers"
ToolTipService.ShowOnDisabled="True"
ToolTip="Position of Crop from Top" />

Expand All @@ -103,7 +103,7 @@
VerticalAlignment="Top"
Width="60"
Style="{DynamicResource TextBoxStyle}"
KeyDown="tbxVideo_Crop_Width_KeyDown"
TextInput="Allow_Only_Numbers"
ToolTipService.ShowOnDisabled="True"
ToolTip="Width of Cropped Area" />

Expand All @@ -124,7 +124,7 @@
VerticalAlignment="Top"
Width="60"
Style="{DynamicResource TextBoxStyle}"
KeyDown="tbxVideo_Crop_Height_KeyDown"
TextInput="Allow_Only_Numbers"
ToolTipService.ShowOnDisabled="True"
ToolTip="Height of Cropped Area" />

Expand Down
53 changes: 12 additions & 41 deletions source/Axiom/Axiom/CropWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ You should have received a copy of the GNU General Public License
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using ViewModel;
// Disable XML Comment warnings
Expand All @@ -46,7 +48,6 @@ public partial class CropWindow : Window
public static string cropY { get; set; }
public static string crop { get; set; } // Combined Width, Height, X, Y


public CropWindow(MainWindow mainwindow)
{
InitializeComponent();
Expand All @@ -70,55 +71,25 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
this.Close();
}

/// <summary>
/// Crop Width
/// </summary>
private void tbxVideo_Crop_Width_KeyDown(object sender, KeyEventArgs e)
{
// Only allow Numbers or Backspace
if (!(e.Key >= Key.D0 && e.Key <= Key.D9) && e.Key != Key.Back)
{
e.Handled = true;
}
}
private static readonly Regex numsOnlyRegex = new Regex(@"\d+");

/// <summary>
/// Crop Height
/// Allow Only Numbers
/// </summary>
private void tbxVideo_Crop_Height_KeyDown(object sender, KeyEventArgs e)
public void Allow_Only_Numbers(object sender, TextCompositionEventArgs e)
{
// Only allow Numbers or Backspace
if (!(e.Key >= Key.D0 && e.Key <= Key.D9) && e.Key != Key.Back)
var textBox = e.Source as TextBox;
if (textBox != null)
{
e.Handled = true;
}
}
var finalText = (textBox.SelectedText.Length > 0
? textBox.Text.Replace(textBox.SelectedText, "")
: textBox.Text)
+ e.Text;

/// <summary>
/// Crop X
/// </summary>
private void tbxVideo_Crop_X_KeyDown(object sender, KeyEventArgs e)
{
// Only allow Numbers or Backspace
if (!(e.Key >= Key.D0 && e.Key <= Key.D9) && e.Key != Key.Back)
{
e.Handled = true;
}
}

/// <summary>
/// Crop Y
/// </summary>
private void tbxVideo_Crop_Y_KeyDown(object sender, KeyEventArgs e)
{
// Only allow Numbers or Backspace
if (!(e.Key >= Key.D0 && e.Key <= Key.D9) && e.Key != Key.Back)
{
e.Handled = true;
e.Handled = !numsOnlyRegex.IsMatch(finalText);
}
}


/// <summary>
/// SET Button
/// </summary>
Expand Down
Loading