using Muchinfo.MTPClient.Data.Model.Delivery;
using Muchinfo.MTPClient.Delivery.ViewModels;
using System;
using System.Text;
using System.Windows;
using System.Windows.Input;
using Xceed.Wpf.Toolkit;
namespace Muchinfo.MTPClient.Delivery.Views
{
///
/// Description for DeliveryMatchView.
///
public partial class DeliveryMatchView : Window
{
public bool occur = false;
///
/// Initializes a new instance of the DeliveryMatchView class.
///
public DeliveryMatchView(DeliveryEntrustOrder model)
{
InitializeComponent();
this.DataContext = new DeliveryMatchViewModel(model);
}
public void drag_MouseLeftButtonDown(object sender, MouseButtonEventArgs args)
{
this.DragMove();
}
private void SelectQty_KeyDown(object sender, KeyEventArgs e)
{
var txtInput = (DecimalUpDown)sender;
if ((e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9) || (e.Key >= Key.D0 && e.Key <= Key.D9))
{
e.Handled = false;
}
else if ((e.Key == Key.Decimal || e.Key == Key.OemPeriod))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
if (txtInput.Text.Contains(".") && txtInput.Text.Length >= 8)
{
e.Handled = true;
}
else if (!txtInput.Text.Contains(".") && txtInput.Text.Length >= 6)
{
e.Handled = true;
}
}
private bool IsNumberKey(Key inKey)
{
if (inKey < Key.D0 || inKey > Key.D9)
{
if (inKey < Key.NumPad0 || inKey > Key.NumPad9)
{
return false;
}
}
return true;
}
private bool IsDelOrBackspaceOrTabKey(Key inKey)
{
return inKey == Key.Delete || inKey == Key.Back || inKey == Key.Tab;
}
private string LeaveOnlyNumbers(String inString)
{
occur = false;
StringBuilder ans = new StringBuilder();
for (int i = 0; i < inString.Length; ++i)
{
if (System.Text.RegularExpressions.Regex.IsMatch(inString[i].ToString(), "^[0-9\\.]*$"))
{
if (inString[i] == '.')
{
if (!occur)
{
occur = true;
ans.Append(inString[i]);
}
}
else ans.Append(inString[i]);
}
}
return ans.ToString();
}
}
}