时间:2016年10月15日 | 作者 : aaronyang | 分类 : AY梦 | 浏览: 4520次 | 评论 2 人
2016-10-17 18:04:19
发布5.1.1
VS2015用户,在vs2015中的扩展与更新搜索ayui,安装即可,或者
直接下载vsix安装即可 http://pan.baidu.com/s/1o7DYGNg
其他visual studio2012,2013的用户(2016-10-17 18:03:07更新),自己手动下载模板 http://pan.baidu.com/s/1c3OcOY
拷贝到C:\Users\AY\Documents\Visual Studio 2015\Templates\ProjectTemplates目录下。然后新建项目即可
这里AY是我的用户名,你自己换成你自己的,Visual Studio 2015,你自己换成你的vs
2016-10-16 18:20:25
已经发布ayui5.1 修复部分bug
2016-10-15
AYUI5.0
AYUI5 不支持vs2012以下的编译器。
[2016-10-15]AYUI5.0客户定制医疗DEMO
[2016-10-15]AYUI5.0 官方DEMO下载
重点:优化控件模板结构,风格统一,轻量界面,表单模块,更加贴近企业的开发需求
AyWindow支持AllowTransparent=true或者false,修复大量问题,修复任务栏点击界面,白线问题等
内置全局的异常捕获模块,AY表达式(掩码和验证),AY微动画库,第三方字体,图标库换成4.6.3最新(2016-10-15日)
新增大量控件38枚,包含语音,绘图相关功能暂不提供,目前增加3个dialog行为,文件选择,文件夹选择,颜色选择。gridservice更方便
包括弹窗AyLayer的快速使用,AyFormInput,一切验证都能解决,AyComboBox编辑状态下也支持验证了。
DPI适应,全新MVVM框架,更简洁的model,可视化开发,优化颜色系统,方便的颜色记忆
下面的$符号代表0-20之间的数字,*代表0-9之间的数字
纯色(SolidColorBrush)
Ay.Brush$ 其中$等于14的时候,是中间色,数字越大,颜色越亮
Ay.Op*.Brush$ 每个纯色之间的透明度,比如*号等于3,代表30%的透明度,同理9,就是90%的透明度。
纯色对应的画刷的Color类型,因为WPF中动画过渡需要Color类型,没有SolidColorBrush的动画过渡的,只有Color
Ay.Brush$.Color 其中$等于14的时候,是中间色,数字越大,颜色越亮
Ay.Op*.Brush$.Color 每个纯色之间的透明度,比如*号等于3,代表30%的透明度,同理9,就是90%的透明度。
特色渐变
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush1" ></SolidColorBrush> 这个其实是Ay.A.Brush.80的意思,因为以前框架用到了这个颜色,名字不方便改
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush.20" ></SolidColorBrush>
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush.40" ></SolidColorBrush>
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush.60" ></SolidColorBrush>
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush.100" ></SolidColorBrush>
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush.120" ></SolidColorBrush>
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush.140" ></SolidColorBrush>
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush.160" ></SolidColorBrush>
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush.180" ></SolidColorBrush>
<SolidColorBrush po:Freeze="True" x:Key="Ay.A.Brush.200" ></SolidColorBrush>
<!--
AyWindow部分接口
上面的-24 是titlebar的高度,如果想内容移动到标题栏,设置负数即可。
如果你不想使用默认aywindow的按钮,TitleBarClickMode="0" 这里0代表 双击标题栏放大,1 代表移动,双击最大化 2 代表移动 0 代表 不做任何操作
IsCoverTaskBar="False" 最大化是否遮盖任务栏
RightButtonWidth设置默认窗体右侧按钮的宽度
WindowEntranceBackgroundMode="3" 窗体入场模式
0 默认 啥都有
1 啥都没
2 没有阴影
3 没有背景,方便自定义固定背景
4 没有背景,方便自定义固定背景,同时也没有顶部右侧自带的按钮
5 没有背景,方便自定义固定背景,有顶部右侧自带的按钮
TitleVisibility="Collapsed" 标题栏不可见
TitleBarHeight="0" 标题栏高度0
WindowState="Maximized" 可以选择
xmlns:ayi="http://www.ayjs.net/behavior" 如果你想使用ayui5的行为
WindowStartupLocation="CenterScreen"
MinButtonVisibility="Collapsed" 默认最小化按钮可见情况设置
MaxButtonVisibility="Collapsed" 默认最大化和还原按钮可见情况设置
SkinButtonVisibility="Collapsed" 默认皮肤按钮可见情况设置
CloseButtonVisibility="Collapsed" 默认关闭按钮可见情况设置
WindowMenuVisibility 默认窗体menu可见性设置
AyWindow.WindowMenu设置了,就会显示窗体菜单按钮,不设置就不显示
如果你想diy窗体右侧的按钮,又想默认自定义按钮,调用这些行为效果,下面列举了方法
ShowWindowMenu 显示窗体菜单
DoMaxOrReStoreWindow 最大化和还原默认状态的方法
OpenSkinWindowShow 打开皮肤设置窗口
DoMinWindow 最小化窗口
DoCloseWindow 关闭或者隐藏窗口
AYUI的aywindow拥有Session对象,在任意窗口共享数据,其他类文件使用AYUI.Session设置和共享数据
设置窗体边框 BorderThickness="1" BorderBrush="{DynamicResource Ay.Brush14}" 默认aywindow有边框的边距,如果不想边距,内容区域多增加个margin的各个方向多减去1
Height="740" Width="1366" MinWidth="1024" MinHeight="620" 宽高设置
CloseButtonMargin="0,0,8,0"右侧关闭按钮的边距
CloseIsHideWindow="False" 默认单击ayui的按钮,是否是隐藏窗口
WindowTitleBarBg="{x:Null}" 默认移动标题栏目移不动,如果设置了具体颜色,就有双击,移动,颜色等效果的附加
CornerRadius是设置默认设置圆角,你的内容也要额外设置圆角
ToolBarContent设置窗体右侧,按钮区域左侧的额外内容,支持后台C#对象,也支持wpf对象
ToolBarContentDataTemplate 按钮区域左侧的额外内容的数据模板,是DataTemplate
Icon是窗体左上角图标
WindowIconWidth窗体左上角图标的宽度
WindowIconVisibility窗体左上角图标的可见方式
Title是窗体左上角的图标文本,也是窗体的title
AyResizeMode调整窗体是否支持调整大小,不要使用自带的ResizeMode
maxWindowVisibility和restoreWindowVisibility不要去设置
IsPinBackground设置是否固定背景,true代表固定背景,不随切换主题而变化背景,设置了后在后台InitializeComponent();上面设置IsLoadedDefaultBackground=false,然后在InitializeComponent();下面
if (!IsLoadedDefaultBackground){ base.SetBackgroundFromName(localFilename);}加入自己的固定背景
AYUI支持重写默认的右侧按钮的行为事件,从而保留ayui的按钮外观,重写这些委托,窗体右侧按钮单击,就会调用这些重写后的操作
public Action CloseWindowMethodOverride;
public Action MinWindowMethodOverride;
public Action MaxWindowMethodOverride;
public Action SkinWindowMethodOverride;
public Action MenuWindowMethodOverride;
这里ResizeWindowInvokeMethod是用于调整窗体大小时候触发委托
还有其他功能请自己探索吧(比如支持自定义背景下方层次)
-->
ViewModel请继承AyPropertyChanged
示例,请查看Models/SampleViewModel.cs文件
如果是ItemsControl型的,可以继承AyUIEntity,AyUIEntity是继承AyPropertyChanged的,只不过添加了常用的属性通知
public abstract class AyUIEntity : AyPropertyChanged
{
protected AyUIEntity();
public bool IsChecked { get; set; }
public bool? IsCheckedThree { get; set; }
public bool IsEnabled { get; set; }
public bool IsExpanded { get; set; }
public bool IsMouseOver { get; set; }
public bool Selected { get; set; }
}
命令方式,顶部引入
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:ayi="http://www.ayjs.net/behavior"
然后
model中 public ICommand CheckedCommand { get; set; }
构造函数实例化命令,带参数的命令使用SimpleCommand,示例如下:
CheckedCommand = new SimpleCommand
{
ExecuteDelegate = emptime =>
{
}
};
xaml用法示例
<ToggleButton Focusable="False" IsChecked="{Binding IsChecked}">
<ayi:CommandBehaviorCollection.Behaviors>
<ayi:BehaviorBinding Event="Checked" Command="{Binding DataContext.CheckedCommand,ElementName=layout}" CommandParameter="{Binding}"/>
<ayi:BehaviorBinding Event="Unchecked" Command="{Binding DataContext.UnCheckedCommand,ElementName=layout}" CommandParameter="{Binding}"/>
</ayi:CommandBehaviorCollection.Behaviors>
</ToggleButton>
也可以直接使用,有无参数都可以使用
<control:AyIconAllButton Padding="0" x:Name="btnOkUpdate" Width="120" Height="38" Content="确认" Icon="fa_check" Style="{DynamicResource Button.Primary}"
ayi:CommandBehavior.Event="Click"
ayi:CommandBehavior.Command="{Binding model.UpdatePassword}"
ayi:CommandBehavior.CommandParameter="{Binding ElementName=mother}"
>
</control:AyIconAllButton>
后台是
也可以使用Action,不带参数的。直接ayi:CommandBehavior.Action={Binding Action的}
通知模块使用
在AyWindow自带Session,HashTable类型的
在其他地方使用AYUI.Session获取和设置,必须引用Ay.Framework.WPF.dll
SaveFileDialog dlg = new SaveFileDialog();
dlg.Filter = "jpg 文件 (*.jpg)|*.jpg" +
"|Bitmap files (*.bmp)|*.bmp"
+ "|png 文件 (*.png)|*.png";
if ((bool)dlg.ShowDialog(this))
{
控件截图 WpfTreeHelper.CreateBitmapFromVisual(这是一个visual, dlg.FileName);
}
############AY表达式DEMO #############
//2016-7-25 15:24:44 测试掩码规则
#region AY表达式- 掩码DEMO 演示
//new AyExpression().Version();
//new AyExpression().Helper();
//Console.WriteLine("www.ayjs.net AY表达式2016-7-28 ");
//string viewMask = "#### #### #### #### ####";
//string userText = "6228480402564890018";
//var d = AyExpression.GetMaskedValue(viewMask, userText);
//Console.WriteLine(d.ToString());
//string viewMask1 = @"\U\U\L## ## ## ##\U";
//string userText1 = "dzA87555600a03";
//var d1 = userText1.ToAyExpressionValue(viewMask1);
//Console.WriteLine(d1.ToString());
//string viewMask2 = @"AY-\U\U\L*(8)@AYUI**\(来自www.ayjs.net\)";
//string userText2 = "dzA87555600a03";
//var d2 = AyExpression.GetMaskedValue(viewMask2, userText2);
//Console.WriteLine(d2.ToString());
//string viewMask3 = @"##*(4 -> \(\))###";
//string userText3 = "875556003";
//var d3 = AyExpression.GetMaskedValue(viewMask3, userText3);
//Console.WriteLine(d3.ToString());
//string viewMask3_0 = @"##*(4 -> \*)###";
//string userText3_0 = "875556003";
//var d3_0 = AyExpression.GetMaskedValue(viewMask3_0, userText3_0);
//Console.WriteLine(d3_0.ToString());
//string viewMask4 = @"###*(4 -> \*)*(?)";
//string userText4 = "15255112050";
//var d4 = AyExpression.GetMaskedValue(viewMask4, userText4);
//Console.WriteLine(d4.ToString());
//Console.WriteLine(d4.Length);
//string viewMask5 = @"##########*(4 -> \*)*(?)";
//string userText5 = "650101198604183434";
//var d5 = AyExpression.GetMaskedValue(viewMask5, userText5);
//Console.WriteLine(d5.ToString());
//使用*(? -> \*)
//string viewMask6 = @"**(? -> \*)";
//string userText6 = "张杨洋";
//var d6 = AyExpression.GetMaskedValue(viewMask6, userText6);
//Console.WriteLine(d6.ToString());
//string userText7 = "杨洋";
//var d7 = AyExpression.GetMaskedValue(viewMask6, userText7);
//Console.WriteLine(d7.ToString());
////时间掩码
//string viewMask8 = @"####年##月##日 ##:##:##";
//string userText8 = "20160812235759";
//var d8 = AyExpression.GetMaskedValue(viewMask8, userText8);
//Console.WriteLine(d8.ToString());
//string viewMask8_1 = @"#(4)年#(2)月#(2)日 ##:##:##";
//string userText8_1 = "20160812235759";
//var d8_1 = AyExpression.GetMaskedValue(viewMask8_1, userText8_1);
//Console.WriteLine(d8_1.ToString());
//string viewMask9 = @"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%";
//string userText9 = "88679C65-ADB1-42E2-9D3B-10589CACD276";
//var d9 = AyExpression.GetMaskedValue(viewMask9, userText9);
//Console.WriteLine(d9.ToString());
//Console.WriteLine(d9.Length);
//string viewMask10 = @"###*(4 -> \*)*(2)$";
//string userText10 = "15255112050";
//var d10 = AyExpression.GetMaskedValue(viewMask10, userText10);
//Console.WriteLine(d10.ToString());
//Console.WriteLine(d10.Length);
//string viewMask11 = "#(4) #(4) #(4) #(4) #(4)";
//string userText11 = "6228480402564890018";
//var d11 = AyExpression.GetMaskedValue(viewMask11, userText11);
//Console.WriteLine(d11.ToString());
string viewMask12 = @"AY-@(2) @(3) *(4) #(21)";
string userText12 = "AB22016CDE";
var d12 = AyExpression.GetMaskedValue(viewMask12, userText12);
Console.WriteLine(d12.ToString());
Console.WriteLine(d12.ToString() + "12");
//string viewMask13 = @"%(32)";
//string userText13 = "88679C65-ADB1-42E2-9D3B-10589CACD276";
//var d13 = AyExpression.GetMaskedValue(viewMask13, userText13);
//Console.WriteLine(d13.ToString());
//Console.WriteLine(d13.Length);
//string viewMask14 = @"%(32)";
//string userText14 = "88679C65-ADB1-42E2-9D3B-10589CACD276";
//var d14 = userText14.ToAyExpressionValue(viewMask14).ToAyExpressionValue("#(1000)");
//Console.WriteLine(d14.ToString());
//string ss = "16466539871".ToAyExpressionValue(@"#\(###\) ###-#(4)");
//Console.WriteLine(ss);
//string ss1 = " 02158455299".ToAyExpressionValue(@"#(3)-*(?)");
//Console.WriteLine(ss1);
//string ss2 = " 9".ToAyExpressionValue(@"人口所占比:#(3)%");
//Console.WriteLine(ss2);
//string ss3 = " 99".ToAyExpressionValue(@"人口所占比:#(3)%");
//Console.WriteLine(ss3);
//string ss4 = " 100".ToAyExpressionValue(@"人口所占比:#(3)%");
//Console.WriteLine(ss4);
#region 前置替换和后置替换
/// 前置/后置 替换规则 *(处理的字符数 处理方向 [+N,表示处理N个符合要求的字符串,不含有+号,表示处理第N个字符串]^被替换的字符串 -> 被替换后的字符串 )
/// 如果N等于 ? 表示 所有匹配到的字符串都要处理
//string demo20 = "测试人员、开发人员、管理人员、15,17,19,20,100";
//string ayexpression1 = "*(? ^< 1^, -> 和)";
//string ayexpression2 = "*(? ^< 2^, -> 和)";
//string ayexpression3 = "*(? ^< 1^, -> and )";
//string ayexpression4 = "*(? ^> 1^, -> 和)";
//string ayexpression5 = "*(? ^> 2^, -> 和)";
//string ayexpression6 = "*(? ^> 1^, -> and )";
//Console.WriteLine("原字符串:" + demo20);
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression1);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression1));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression2);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression2));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression3);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression3));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression4);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression4));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression5);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression5));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression6);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression6));
////处理接下来所有的字符串,从左往右处理 处理前2个","字符串,找到后替换成"和" 返回处理后的字符串
//string ayexpression7 = "*(? ^> +2^, -> 和)";
////处理接下来所有的字符串,从右往左处理 处理前2个","字符串,找到后替换成"和" 返回处理后的字符串
//string ayexpression8 = "*(? ^< +2^, -> 和)";
////处理接下来所有的字符串,从右往左处理 处理所有","字符串,找到后替换成" and " 返回处理后的字符串
//string ayexpression9 = "*(? ^< ?^, -> and )";
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression7);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression7));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression8);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression8));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression9);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression9));
////处理接下来7个字符长度的字符串,截取7个字符串后,从左往右处理 处理前2个","字符串,找到后替换成" and " 返回处理后的字符串
//string ayexpression10 = "*(7 ^> +2^, -> 和)";
////处理接下来8个字符长度的字符串,截取8个字符串后,从右往左处理 处理前2个","字符串,找到后替换成" and " 返回处理后的字符串
//string ayexpression11 = "*(8 ^< +2^, -> 和)";
////处理接下来9个字符长度的字符串,截取9个字符串后,从右往左处理 第2个","字符串,找到后替换成" and " 返回处理后的字符串
//string ayexpression12 = "*(9 ^< 2^, -> and )";
////处理接下来10个字符长度的字符串,截取10个字符串后,从左往右处理 第2个","字符串,找到后替换成" and " 返回处理后的字符串
//string ayexpression13 = "*(10 ^> 2^, -> and )";
////处理接下来40个字符长度的字符串,截取40个字符串后,从左往右处理 第2个","字符串,找到后替换成" and " 返回处理后的字符串
//string ayexpression14 = "*(40 ^> 2^, -> and )";
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression10);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression10));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression11);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression11));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression12);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression12));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression13);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression13));
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression14);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression14));
////尝试2 20的长度 “测试人员、开发人员、管理人员、15,17” 第21位是, 按照规则,从左往右 第1个替换
////就是17后面的 逗号被替换
//string ayexpression15 = "*(20)*(? ^> 1^, -> ☆开心AY☆)";
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression15);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression15));
//string ayexpression16 = "*(? ^> ?^人员 -> 工程师)";
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression16);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression16));
//string ayexpression17 = @"*(? ^> ?^人员 -> \(职位\))";
//Console.WriteLine();
//Console.WriteLine("AY表达式:" + ayexpression17);
//Console.WriteLine(demo20.ToAyExpressionValue(ayexpression17));
#endregion
#endregion
#region 表单验证表达式测试
//Console.Title = "AY表单表达式,DEMO";
//string text = "1525513212050";
//string express = "required;tel;";
//AyFormResult result = text.ToAyExpressionFormResult(express);
//if (result.Result)
// Console.WriteLine("验证通过");
//else
// Console.WriteLine("验证失败! " + result.Error);
//string text1 = "";
//string express1 = "required;length[9]";
//AyFormResult result1 = text1.ToAyExpressionFormResult(express1);
//Console.WriteLine();
//Console.WriteLine("原字符串:" + text1);
//Console.WriteLine("AY表单表达式:" + express1);
//if (result1.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result1.Error);
//string text2 = "helloAY杨洋";
//string express2 = "required;length[9]";
//AyFormResult result2 = text2.ToAyExpressionFormResult(express2);
//Console.WriteLine();
//Console.WriteLine("原字符串:" + text2);
//Console.WriteLine("AY表单表达式:" + express2);
//if (result2.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result2.Error);
//string text3 = "helloAY";
//string express3 = "required;length[15]";
//AyFormResult result3 = text3.ToAyExpressionFormResult(express3);
//Console.WriteLine();
//Console.WriteLine("原字符串:" + text3);
//Console.WriteLine("AY表单表达式:" + express3);
//if (result3.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result3.Error);
//string text4 = "helloAY";
//string express4 = "required;length[15|18|32]";
//AyFormResult result4 = text4.ToAyExpressionFormResult(express4);
//Console.WriteLine();
//Console.WriteLine("原字符串:" + text4);
//Console.WriteLine("AY表单表达式:" + express4);
//if (result4.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result4.Error);
//string text5 = "helloAY";
//string express5 = "required;length[(8,16)]";
//AyFormResult result5 = text5.ToAyExpressionFormResult(express5);
//Console.WriteLine();
//Console.WriteLine("原字符串:" + text5);
//Console.WriteLine("AY表单表达式:" + express5);
//if (result5.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result5.Error);
//string text6 = "helloAY";
//string express6 = "required;length[(,5)]";
//AyFormResult result6 = text6.ToAyExpressionFormResult(express6);
//Console.WriteLine();
//Console.WriteLine("原字符串:" + text6);
//Console.WriteLine("AY表单表达式:" + express6);
//if (result6.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result6.Error);
//string text7 = "helloAY";
//string express7 = "required;length[(8,)]";
//AyFormResult result7 = text7.ToAyExpressionFormResult(express7);
//Console.WriteLine();
//Console.WriteLine("原字符串:" + text7);
//Console.WriteLine("AY表单表达式:" + express7);
//if (result7.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result7.Error);
//string text8 = "helloAY";
//string express8 = "required;length[(6,8)|(10,20)|(30,)]";
//AyFormResult result8 = text8.ToAyExpressionFormResult(express8);
//Console.WriteLine();
//Console.WriteLine("原字符串:" + text8);
//Console.WriteLine("AY表单表达式:" + express8);
//if (result8.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result8.Error);
//Console.WriteLine();
//string text9 = "helloAY-AVAVAVAVAYAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAV";
//Console.WriteLine("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 下面的字符串实际长度" + text9.Length + " ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓");
//string express9 = "required;length[(6,8)|(10,20)|(30,)]";
//AyFormResult result9 = text9.ToAyExpressionFormResult(express9);
//Console.WriteLine("原字符串:" + text9);
//Console.WriteLine("AY表单表达式:" + express9);
//if (result9.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result9.Error);
//Console.WriteLine();
//string text10 = "helloAY-AVAVAVAVAVAVAVAVAVAV";
//Console.WriteLine("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 下面的字符串实际长度" + text10.Length + " ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓");
//string express10 = "required;length[(6,8)|(10,20)|(30,)]";
//AyFormResult result10 = text10.ToAyExpressionFormResult(express10);
//Console.WriteLine("原字符串:" + text10);
//Console.WriteLine("AY表单表达式:" + express10);
//if (result10.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result10.Error);
//Console.WriteLine("\r\n换个表达式,加上text10的长度:");
//string express11 = "required;length[(6,8)|(10,20)|(30,)|" + text10.Length + "]";
//AyFormResult result11 = text10.ToAyExpressionFormResult(express11);
//Console.WriteLine("AY表单表达式:" + express11);
//if (result11.Result)
// Console.WriteLine("验证结果:通过");
//else
// Console.WriteLine("验证结果:失败! " + result11.Error);
#endregion
Console.WriteLine();
//string text1 = "+3770.77";
//string express1 = "required;num";
//AyValidate(text1, express1);
//string text20 = "-770.0";
//string express20 = "required;num(3)";
//AyValidate(text20, express20);
//string text2 = "-370.7";
//string express2 = "required;num(3,2)";
//AyValidate(text2, express2);
//string text3 = "580";
//string express3 = "required;num(3)[@ge 0,@le 200]";
//AyValidate(text3, express3);
//string text4 = "3132";
//string express4 = "required;num[@g 0,@le 1000]";
//AyValidate(text4, express4);
//string text5 = "377077_qq@";
//string express5 = "required;username";
//AyValidate(text5, express5);
//string text6 = "0211-2587125f";
//string express6 = "required;chinaTel";
//AyValidate(text6, express6);
//string text7 = "258744";
//string express7 = "required;zip";
//AyValidate(text7, express7);
//string text8 = "352";
//string expres8 = "required;age";
//AyValidate(text8, expres8);
//string text9 = "888877";
//string expres9 = "QQ";
//AyValidate(text9, expres9);
//拓展验证规则
//AyExpression.CustomValidators.Add("nor", new AyFormNormalValidator());
//string text10 = "13";
//string expres10 = "nor";
//AyValidate(text10, expres10);
//AyExpression.CustomValidators.Add("nor2", new AyFormNormal2Validator());
//string text11 = "1";
//string expres11 = "nor2";
//AyValidate(text11, expres11);
//AyExpression.CustomValidators.Add("nor3", new AyFormDiff3Validator());
//string text12 = "1";
//string expres12 = "nor3";
//AyValidate(text12, expres12);
Console.ReadLine();
}
private static void AyValidate(string text4, string express4)
{
AyFormResult result4 = text4.ToAyExpressionFormResult(express4);
Console.WriteLine("原字符串:" + text4);
Console.WriteLine("AY表单表达式:" + express4);
if (result4.Result)
Console.WriteLine("验证结果:通过");
else
Console.WriteLine("验证结果:失败! " + result4.Error);
Console.WriteLine();
}
}
public class AyFormNormalValidator : AyFormValidator
{
public AyFormNormalValidator()
{
Example = "测试验证";
ErrorInfo = "测试用的,你输入错误了";
RegexExpression = @"^[0-9]$";
}
}
public class AyFormNormal2Validator : AyFormValidator
{
public AyFormNormal2Validator()
{
Example = "测试验证2";
ErrorInfo = "测试用的,你输入错误了2";
CustomFunc = (text) =>
{
int dd = text.Length;
if (dd < 3)
{
return true;
}
else
{
ErrorInfo = "输入的文本不能超过3个字符";
return false;
}
};
}
}
public class AyFormDiff3Validator : AyFormValidator
{
public AyFormDiff3Validator()
{
Example = "完全自定义自己的规则";
ErrorInfo = "这规则太难";
}
public override bool Validate(string text, string expression = "")
{
//expression 这里可以获取你定义的表达式,自己在这里可以额外处理
int dd = text.Length;
if (dd < 3)
{
return true;
}
else
{
ErrorInfo = "输入的文本不能超过3个字符";
return false;
}
}
}
############AY表达式DEMO #############
推荐您阅读更多有关于“AYUI5.X,”的文章
抖音:wpfui 工作wpf,兴趣学习flutter
目前在合肥市某公司上班,已经厌弃,如果你的公司看的上我,加我QQ私聊
AYUI8全源码 Github地址:前往获取
杨洋(AaronYang简称AY,安徽六安人)和AY交流
高中学历,2010年开始web开发,2015年1月17日开始学习WPF
声明:AYUI7个人与商用免费,源码可购买。部分DEMO不免费
不是从我处购买的ayui7源码,我不提供任何技术服务,如果你举报从哪里买的,我可以帮你转正为我的客户,并送demo
查看捐赠AYUI7.X MVC教程 更新如下:
第一课 第二课 程序加密教程
已有2位网友发表了看法:
非常好,杨洋,啥时候回来啊?
你是谁?留个名字啊,合肥的吗
发表评论