Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to v2.1 Support some experimental features Add install key mode (without activate) Add manual enter key mode
- Loading branch information
Showing
22 changed files
with
2,032 additions
and
152 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,82 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Text.RegularExpressions; | ||
using System.Windows.Controls; | ||
|
||
namespace CMWTAT_DIGITAL.Domain | ||
{ | ||
class IsSN : ValidationRule | ||
{ | ||
#region 匹配方法 | ||
|
||
/// <summary> | ||
/// 验证字符串是否匹配正则表达式描述的规则 | ||
/// </summary> | ||
/// <param name="inputStr">待验证的字符串</param> | ||
/// <param name="patternStr">正则表达式字符串</param> | ||
/// <returns>是否匹配</returns> | ||
public static bool IsMatch(string inputStr, string patternStr) | ||
{ | ||
return IsMatch(inputStr, patternStr, false, false); | ||
} | ||
|
||
/// <summary> | ||
/// 验证字符串是否匹配正则表达式描述的规则 | ||
/// </summary> | ||
/// <param name="inputStr">待验证的字符串</param> | ||
/// <param name="patternStr">正则表达式字符串</param> | ||
/// <param name="ifIgnoreCase">匹配时是否不区分大小写</param> | ||
/// <returns>是否匹配</returns> | ||
public static bool IsMatch(string inputStr, string patternStr, bool ifIgnoreCase) | ||
{ | ||
return IsMatch(inputStr, patternStr, ifIgnoreCase, false); | ||
} | ||
|
||
/// <summary> | ||
/// 验证字符串是否匹配正则表达式描述的规则 | ||
/// </summary> | ||
/// <param name="inputStr">待验证的字符串</param> | ||
/// <param name="patternStr">正则表达式字符串</param> | ||
/// <param name="ifIgnoreCase">匹配时是否不区分大小写</param> | ||
/// <param name="ifValidateWhiteSpace">是否验证空白字符串</param> | ||
/// <returns>是否匹配</returns> | ||
public static bool IsMatch(string inputStr, string patternStr, bool ifIgnoreCase, bool ifValidateWhiteSpace) | ||
{ | ||
if (!ifValidateWhiteSpace && string.IsNullOrEmpty(inputStr)) | ||
return false;//如果不要求验证空白字符串而此时传入的待验证字符串为空白字符串,则不匹配 | ||
Regex regex = null; | ||
if (ifIgnoreCase) | ||
regex = new Regex(patternStr, RegexOptions.IgnoreCase);//指定不区分大小写的匹配 | ||
else | ||
regex = new Regex(patternStr); | ||
return regex.IsMatch(inputStr); | ||
} | ||
|
||
#endregion | ||
|
||
public override ValidationResult Validate(object value, CultureInfo cultureInfo) | ||
{ | ||
//Console.WriteLine("\""+value+"\""); | ||
//return string.IsNullOrWhiteSpace((value ?? "").ToString()) | ||
// ? new ValidationResult(false, "Key is required.") | ||
// : ValidationResult.ValidResult; | ||
|
||
string pattern = @"^[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}$"; | ||
|
||
if (IsMatch((value ?? "").ToString(), pattern)) | ||
{ | ||
return ValidationResult.ValidResult; | ||
|
||
} | ||
else if (string.IsNullOrWhiteSpace((value ?? "").ToString())) | ||
{ | ||
return new ValidationResult(false, "Please enter the key for the current edition."); | ||
} | ||
else | ||
{ | ||
return new ValidationResult(false, "Invalid format."); | ||
} | ||
|
||
} | ||
} | ||
} |
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,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CMWTAT_DIGITAL.Domain | ||
{ | ||
public static class NotifyPropertyChangedExtension | ||
{ | ||
public static void MutateVerbose<TField>(this INotifyPropertyChanged instance, ref TField field, TField newValue, Action<PropertyChangedEventArgs> raise, [CallerMemberName] string propertyName = null) | ||
{ | ||
if (EqualityComparer<TField>.Default.Equals(field, newValue)) return; | ||
field = newValue; | ||
raise?.Invoke(new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} | ||
} |
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,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CMWTAT_DIGITAL.Domain | ||
{ | ||
class ViewModel : INotifyPropertyChanged | ||
{ | ||
private string _sn; | ||
|
||
public ViewModel() | ||
{ | ||
LongListToTestComboVirtualization = new List<int>(Enumerable.Range(0, 1000)); | ||
} | ||
|
||
public string SN | ||
{ | ||
get { return _sn; } | ||
set | ||
{ | ||
this.MutateVerbose(ref _sn, value, RaisePropertyChanged()); | ||
} | ||
} | ||
|
||
public IList<int> LongListToTestComboVirtualization { get; } | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
private Action<PropertyChangedEventArgs> RaisePropertyChanged() | ||
{ | ||
return args => PropertyChanged?.Invoke(this, args); | ||
} | ||
} | ||
} |
Oops, something went wrong.