初始化上传
This commit is contained in:
42
常用工具集/Views/05其他/MD5DES.axaml
Normal file
42
常用工具集/Views/05其他/MD5DES.axaml
Normal file
@@ -0,0 +1,42 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="715" d:DesignHeight="600"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._05其他"
|
||||
x:Class="常用工具集.MD5DES"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:MD5DESViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:MD5DESViewModel />
|
||||
</UserControl.DataContext>
|
||||
|
||||
<Grid ColumnDefinitions="*,*">
|
||||
<Border Theme="{StaticResource CardBorder}" Grid.Column="0" Margin="10,10,10,10">
|
||||
<Grid>
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,-20,0,0" TextWrapping="Wrap" Text="信息摘要" VerticalAlignment="Top"/>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="13,28,0,0" TextWrapping="Wrap" Text="内容:" VerticalAlignment="Top"/>
|
||||
<TextBox HorizontalAlignment="Left" Margin="31,48,0,0" Text="{Binding MD5Source}" VerticalAlignment="Top" Width="270" Height="135" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalContentAlignment="Left" VerticalContentAlignment="Top"/>
|
||||
<Button Command="{Binding CalcMD5Cmd}" Content="计算MD5值" HorizontalAlignment="Left" Margin="112,208,0,0" VerticalAlignment="Top" />
|
||||
<TextBlock HorizontalAlignment="Left" Margin="25,240,0,0" TextWrapping="Wrap" Text="MD5:" VerticalAlignment="Top"/>
|
||||
<TextBox HorizontalAlignment="Center" Margin="0,258,0,0" Text="{Binding MD5Dest}" VerticalAlignment="Top" Width="275" Height="135" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalContentAlignment="Left" VerticalContentAlignment="Top"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Theme="{StaticResource CardBorder}" Grid.Column="1" Margin="10,10,10,10">
|
||||
<Grid>
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,-20,0,0" TextWrapping="Wrap" Text="DES加解密" VerticalAlignment="Top"/>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="13,30,0,0" TextWrapping="Wrap" Text="密钥:" VerticalAlignment="Top"/>
|
||||
<TextBox HorizontalAlignment="Left" Margin="49,24,0,0" TextWrapping="Wrap" Text="{Binding DESKey}" VerticalAlignment="Top" Width="252" Watermark="不填,使用内置KEY"/>
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" Margin="13,62,0,0" TextWrapping="Wrap" Text="内容:" VerticalAlignment="Top"/>
|
||||
<TextBox HorizontalAlignment="Left" Margin="31,82,0,0" Text="{Binding DESSource}" VerticalAlignment="Top" Width="270" Height="135" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalContentAlignment="Left" VerticalContentAlignment="Top"/>
|
||||
<Button Command="{Binding DESEncryptCmd}" Content="加密" HorizontalAlignment="Left" Margin="49,235,0,0" VerticalAlignment="Top" Width="69" />
|
||||
<Button Command="{Binding DESDecryptCmd}" Content="解密" HorizontalAlignment="Left" Margin="169,235,0,0" VerticalAlignment="Top" Width="69" />
|
||||
<TextBlock HorizontalAlignment="Left" Margin="25,275,0,0" TextWrapping="Wrap" Text="结果:" VerticalAlignment="Top"/>
|
||||
<TextBox HorizontalAlignment="Center" Margin="0,292,0,0" Text="{Binding DESDest}" VerticalAlignment="Top" Width="275" Height="135" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalContentAlignment="Left" VerticalContentAlignment="Top"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
13
常用工具集/Views/05其他/MD5DES.axaml.cs
Normal file
13
常用工具集/Views/05其他/MD5DES.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class MD5DES : UserControl
|
||||
{
|
||||
public MD5DES()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
35
常用工具集/Views/05其他/SQLStringBuilder封装.axaml
Normal file
35
常用工具集/Views/05其他/SQLStringBuilder封装.axaml
Normal file
@@ -0,0 +1,35 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._05其他"
|
||||
mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="715"
|
||||
x:Class="常用工具集.SQLStringBuilder封装"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:SQLStringBuilder封装ViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:SQLStringBuilder封装ViewModel />
|
||||
</UserControl.DataContext>
|
||||
<Grid>
|
||||
<TextBlock Text="转换前:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,16,0,0" />
|
||||
<TextBox Text="{Binding TextBox1}" Height="160" HorizontalAlignment="Left" Margin="60,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="555" VerticalContentAlignment="Top" HorizontalContentAlignment="Left" AcceptsReturn="True" AcceptsTab="True"/>
|
||||
|
||||
<TextBlock Text="转换后:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,206,0,0" />
|
||||
<TextBox Text="{Binding TextBox2}" Height="160" HorizontalAlignment="Left" Margin="60,200,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="555" VerticalContentAlignment="Top" HorizontalContentAlignment="Left" AcceptsReturn="True" AcceptsTab="True"/>
|
||||
|
||||
|
||||
<TextBlock Text="{Binding Text3Title}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,386,0,0" />
|
||||
<TextBox Text="{Binding TextBox3}" IsVisible="{Binding TextBox3Visiable}" Height="30" HorizontalAlignment="Left" Margin="140,380,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="90" />
|
||||
|
||||
<TextBlock Text="功能:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="227,386,0,0" />
|
||||
<ComboBox HorizontalAlignment="Left" VerticalAlignment="Top" SelectedIndex="{Binding FuncIndex}" ItemsSource="{Binding FuncList}" Margin="257,382,0,0" Width="188" />
|
||||
<RadioButton Height="20" Content="{Binding RadioButton1Text}" IsChecked="{Binding RadioButton1}" IsVisible="{Binding RadioButton1Visiable}" HorizontalAlignment="Left" Margin="470,385,0,0" VerticalAlignment="Top"/>
|
||||
<RadioButton Height="20" Content="{Binding RadioButton2Text}" IsChecked="{Binding RadioButton2}" IsVisible="{Binding RadioButton2Visiable}" HorizontalAlignment="Left" Margin="535,385,0,0" VerticalAlignment="Top"/>
|
||||
<RadioButton Height="20" Content="{Binding RadioButton3Text}" IsChecked="{Binding RadioButton3}" IsVisible="{Binding RadioButton3Visiable}" HorizontalAlignment="Left" Margin="600,385,0,0" VerticalAlignment="Top"/>
|
||||
<CheckBox IsChecked="{Binding CheckBox1}" IsVisible="{Binding CheckBox1Visiable}" Content="格式化" Margin="354,410,274,0" VerticalAlignment="Top" Height="25" />
|
||||
<CheckBox IsChecked="{Binding CheckBox3}" IsVisible="{Binding CheckBox3Visiable}" Content="AppendLine" Margin="437,410,164,0" VerticalAlignment="Top" Height="25" RenderTransformOrigin="0.24,-0.2" />
|
||||
<CheckBox IsChecked="{Binding CheckBox2}" IsVisible="{Binding CheckBox2Visiable}" Content="首尾对齐" Margin="570,410,51,0" VerticalAlignment="Top" Height="25" RenderTransformOrigin="0.24,-0.2" />
|
||||
<Button Content="{Binding Button1Text}" Command="{Binding GenerateCmd}" HorizontalAlignment="Left" Margin="475,455,0,0" VerticalAlignment="Top" Width="76" />
|
||||
<Button Content="清空" Command="{Binding ClearCmd}" HorizontalAlignment="Left" Margin="570,455,0,0" VerticalAlignment="Top" Width="76" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
13
常用工具集/Views/05其他/SQLStringBuilder封装.axaml.cs
Normal file
13
常用工具集/Views/05其他/SQLStringBuilder封装.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class SQLStringBuilder封装 : UserControl
|
||||
{
|
||||
public SQLStringBuilder封装()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
28
常用工具集/Views/05其他/人民币转大写.axaml
Normal file
28
常用工具集/Views/05其他/人民币转大写.axaml
Normal file
@@ -0,0 +1,28 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._05其他"
|
||||
mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="715"
|
||||
x:Class="常用工具集.人民币转大写"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:MD5DESViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:人民币转大写ViewModel />
|
||||
</UserControl.DataContext>
|
||||
<Grid>
|
||||
<TextBlock Text="输入金额:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="37,37,0,0" />
|
||||
<TextBox x:Name="txt1" KeyDown="TextBox_KeyDown" HorizontalAlignment="Left" Margin="97,31,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="108" />
|
||||
<TextBlock Text="×" Margin="207,31,0,0" FontSize="20" HorizontalAlignment="Left" VerticalAlignment="Top" Height="28" Width="28"/>
|
||||
<TextBox x:Name="txt2" Text="30" HorizontalAlignment="Left" Margin="253,31,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="67" />
|
||||
<TextBlock Text="%" Margin="330,31,0,0" FontSize="20" HorizontalAlignment="Left" VerticalAlignment="Top" Height="28" Width="28"/>
|
||||
<Button Content="计算" HorizontalAlignment="Left" Margin="395,30,0,0" VerticalAlignment="Top" Width="76" Click="Button_Click" />
|
||||
<Button Content="转换" HorizontalAlignment="Left" Margin="183,77,0,0" VerticalAlignment="Top" Width="76" Click="Button2_Click" />
|
||||
|
||||
<TextBlock Text="千位分隔:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="42,136,0,0" />
|
||||
<TextBox x:Name="txt3" HorizontalAlignment="Left" Margin="102,130,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="264" />
|
||||
|
||||
<TextBlock Text="输出:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="42,196,0,0" />
|
||||
<TextBox x:Name="txt4" HorizontalAlignment="Left" Margin="102,190,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="264" Height="120" VerticalContentAlignment="Top" HorizontalContentAlignment="Left"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
92
常用工具集/Views/05其他/人民币转大写.axaml.cs
Normal file
92
常用工具集/Views/05其他/人民币转大写.axaml.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class 人民币转大写 : UserControl
|
||||
{
|
||||
public 人民币转大写()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void TextBox_KeyDown(object? sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Avalonia.Input.Key.Enter)
|
||||
{
|
||||
this.Button2_Click(sender, e);//触发button事件
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
if (txt2.Text.Trim().Length == 0)
|
||||
{
|
||||
this.Button2_Click(sender, e);//触发button事件
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
txt1.Text = txt1.Text.Replace(",", "");
|
||||
int num = Convert.ToInt32(txt2.Text.Trim());
|
||||
double rate = num * 1.0 / 100.0;
|
||||
double money = Convert.ToDouble(txt1.Text);
|
||||
money = money * rate;
|
||||
string strMoney = Convert.ToString(money);
|
||||
Show(strMoney);//触发button事件
|
||||
}
|
||||
catch
|
||||
{
|
||||
txt4.Text = "";
|
||||
txt3.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void Button2_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
txt1.Text = txt1.Text.Replace(",", "");
|
||||
decimal money = Convert.ToDecimal(txt1.Text);
|
||||
string str = ConvertToChinese(money);
|
||||
if (!txt1.Text.Contains("."))
|
||||
str += "整";
|
||||
txt4.Text = str;
|
||||
txt3.Text = money.ToString("N0");
|
||||
}
|
||||
catch
|
||||
{
|
||||
txt4.Text = "";
|
||||
txt3.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
public static string ConvertToChinese(decimal number)
|
||||
{
|
||||
var s = number.ToString("#L#E#D#C#K#E#D#C#J#E#D#C#I#E#D#C#H#E#D#C#G#E#D#C#F#E#D#C#.0B0A");
|
||||
var d = Regex.Replace(s, @"((?<=-|^)[^1-9]*)|((?'z'0)[0A-E]*((?=[1-9])|(?'-z'(?=[F-L\.]|$))))|((?'b'[F-L])(?'z'0)[0A-L]*((?=[1-9])|(?'-z'(?=[\.]|$))))", "${b}${z}");
|
||||
var r = Regex.Replace(d, ".", m => "负元空零壹贰叁肆伍陆柒捌玖空空空空空空空分角拾佰仟万亿兆京垓秭穰"[m.Value[0] - '-'].ToString());
|
||||
return r;
|
||||
}
|
||||
|
||||
private void Show(string money1)
|
||||
{
|
||||
try
|
||||
{
|
||||
decimal money = Convert.ToDecimal(money1);
|
||||
string str = ConvertToChinese(money);
|
||||
if (!txt1.Text.Contains("."))
|
||||
str += "整";
|
||||
txt4.Text = str;
|
||||
txt3.Text = money.ToString("N0");
|
||||
}
|
||||
catch
|
||||
{
|
||||
txt4.Text = "";
|
||||
txt3.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
26
常用工具集/Views/05其他/地标写入.axaml
Normal file
26
常用工具集/Views/05其他/地标写入.axaml
Normal file
@@ -0,0 +1,26 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="715"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._05其他"
|
||||
x:Class="常用工具集.地标写入"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:地标写入ViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:地标写入ViewModel />
|
||||
</UserControl.DataContext>
|
||||
<Grid>
|
||||
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="串口:" Margin="50,61,0,0" />
|
||||
<ComboBox IsEnabled="{Binding Enabled1}" HorizontalAlignment="Left" VerticalAlignment="Top" SelectedIndex="{Binding SerialIndex}" ItemsSource="{Binding SerialList}" Margin="80,55,0,0" Width="130" />
|
||||
<Button IsEnabled="{Binding Enabled1}" Content="打开串口" Command="{Binding OpenCmd}" HorizontalAlignment="Left" Margin="55,102,0,0" VerticalAlignment="Top" Width="90" />
|
||||
<Button IsEnabled="{Binding Enabled2}" Content="关闭串口" Command="{Binding CloseCmd}" HorizontalAlignment="Left" Margin="150,102,0,0" VerticalAlignment="Top" Width="90" />
|
||||
|
||||
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="数据:" Margin="50,148,0,0" />
|
||||
<TextBox IsEnabled="{Binding Enabled2}" HorizontalAlignment="Left" Margin="80,142,0,0" TextWrapping="Wrap" Text="{Binding Data}" VerticalAlignment="Top" Width="128" />
|
||||
<Button IsEnabled="{Binding Enabled2}" Content="读取" Command="{Binding ReadCmd}" HorizontalAlignment="Left" Margin="14,200,0,0" VerticalAlignment="Top" Width="76" />
|
||||
<Button IsEnabled="{Binding Enabled2}" Content="写入" Command="{Binding WriteCmd}" HorizontalAlignment="Left" Margin="111,200,0,0" VerticalAlignment="Top" Width="76" />
|
||||
<Button IsEnabled="{Binding Enabled2}" Content="清空" Command="{Binding ClearCmd}" HorizontalAlignment="Left" Margin="219,200,0,0" VerticalAlignment="Top" Width="76" />
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
13
常用工具集/Views/05其他/地标写入.axaml.cs
Normal file
13
常用工具集/Views/05其他/地标写入.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class 地标写入 : UserControl
|
||||
{
|
||||
public 地标写入()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
21
常用工具集/Views/05其他/角度弧度转换.axaml
Normal file
21
常用工具集/Views/05其他/角度弧度转换.axaml
Normal file
@@ -0,0 +1,21 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="715"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._05其他"
|
||||
x:Class="常用工具集.角度弧度转换"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:角度弧度转换ViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:角度弧度转换ViewModel />
|
||||
</UserControl.DataContext>
|
||||
<Grid>
|
||||
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="角度:" Margin="60,43,0,0" />
|
||||
<TextBox Name="txtAngle" KeyDown="txtAngle_KeyDown" HorizontalAlignment="Left" Margin="95,37,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="148" />
|
||||
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="弧度:" Margin="60,93,0,0" />
|
||||
<TextBox Name="txtRad" KeyDown="txtRad_KeyDown" HorizontalAlignment="Left" Margin="95,87,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="148" />
|
||||
<Button Content="转换" HorizontalAlignment="Left" Margin="255,37,0,0" VerticalAlignment="Top" Width="76" Click="Button_Click" />
|
||||
<Button Content="转换" HorizontalAlignment="Left" Margin="255,87,0,0" VerticalAlignment="Top" Width="76" Click="Button_Click_1" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
70
常用工具集/Views/05其他/角度弧度转换.axaml.cs
Normal file
70
常用工具集/Views/05其他/角度弧度转换.axaml.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class 角度弧度转换 : UserControl
|
||||
{
|
||||
public 角度弧度转换()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string strAngle = txtAngle.Text;
|
||||
double angle;
|
||||
bool flag = double.TryParse(strAngle, out angle);
|
||||
if (!flag)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入0~360之间的数字");
|
||||
return;
|
||||
}
|
||||
if (angle < 0 || angle > 360)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入0~360之间的数字");
|
||||
return;
|
||||
}
|
||||
double rad = angle * (Math.PI / 180);
|
||||
txtRad.Text = string.Format("{0:N6}", rad);
|
||||
}
|
||||
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string strRad = txtRad.Text;
|
||||
double rad;
|
||||
bool flag = double.TryParse(strRad, out rad);
|
||||
if (!flag)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入0~2Π之间的数字");
|
||||
return;
|
||||
}
|
||||
if (rad < 0 || rad > (2 * Math.PI))
|
||||
{
|
||||
MessageBox.ShowAsync("请输入0~2Π之间的数字");
|
||||
return;
|
||||
}
|
||||
double angle = rad * 180 / Math.PI;
|
||||
txtAngle.Text = string.Format("{0:N6}", angle);
|
||||
}
|
||||
|
||||
private void txtAngle_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
Button_Click(sender, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void txtRad_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
Button_Click_1(sender, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
68
常用工具集/Views/05其他/进制转换及ASCII转换.axaml
Normal file
68
常用工具集/Views/05其他/进制转换及ASCII转换.axaml
Normal file
@@ -0,0 +1,68 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._05其他"
|
||||
x:Class="常用工具集.进制转换及ASCII转换"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:进制转换及ASCII转换ViewModel" >
|
||||
<UserControl.DataContext>
|
||||
<vm:进制转换及ASCII转换ViewModel />
|
||||
</UserControl.DataContext>
|
||||
|
||||
<Grid>
|
||||
<Border Theme="{StaticResource CardBorder}" Width="345" Height="210" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,40,0,0">
|
||||
<Grid Height="180">
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,-20,0,0" TextWrapping="Wrap" Text="进制转换" VerticalAlignment="Top"/>
|
||||
<TextBlock Text="二进制:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,16,0,0" />
|
||||
<TextBox Name="textBox1" Text="" KeyDown="textBox1_KeyDown" HorizontalAlignment="Left" Margin="70,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="180" />
|
||||
<TextBlock Text="十进制:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,88,0,0" />
|
||||
<TextBox Name="textBox3" Text="" KeyDown="textBox3_KeyDown" HorizontalAlignment="Left" Margin="70,82,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="180" />
|
||||
<TextBlock Text="八进制:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,52,0,0" />
|
||||
<TextBox Name="textBox2" Text="" KeyDown="textBox2_KeyDown" HorizontalAlignment="Left" Margin="70,46,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="180" />
|
||||
<TextBlock Text="十六进制:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,131,0,0" />
|
||||
<TextBox Name="textBox4" Text="" KeyDown="textBox4_KeyDown" HorizontalAlignment="Left" Margin="70,125,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="180" />
|
||||
<Button Name="button1" Content="转换" HorizontalAlignment="Left" Margin="255,10,0,0" VerticalAlignment="Top" Width="75" Click="button1_Click" />
|
||||
<Button Name="button2" Content="转换" HorizontalAlignment="Left" Margin="255,43,0,0" VerticalAlignment="Top" Width="75" Click="button2_Click" />
|
||||
<Button Name="button3" Content="转换" HorizontalAlignment="Left" Margin="255,82,0,0" VerticalAlignment="Top" Width="75" Click="button3_Click" />
|
||||
<Button Name="button4" Content="转换" HorizontalAlignment="Left" Margin="255,125,0,0" VerticalAlignment="Top" Width="75" Click="button4_Click" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Theme="{StaticResource CardBorder}" Width="355" Height="210" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="360,40,0,0">
|
||||
<Grid Height="180">
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,-20,0,0" TextWrapping="Wrap" Text="颜色值转换" VerticalAlignment="Top"/>
|
||||
<TextBlock Text="R:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="13,41,0,0" />
|
||||
<TextBox Name="textBox5" Text="" KeyDown="textBox5_KeyDown" HorizontalAlignment="Left" Margin="33,35,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="55" />
|
||||
<TextBlock Text="B:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="181,41,0,0" />
|
||||
<TextBox Name="textBox7" Text="" KeyDown="textBox7_KeyDown" HorizontalAlignment="Left" Margin="201,35,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="55" />
|
||||
<TextBlock Text="G:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="90,41,0,0" />
|
||||
<TextBox Name="textBox6" Text="" KeyDown="textBox6_KeyDown" HorizontalAlignment="Left" Margin="110,35,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="55" />
|
||||
<Button Name="button5" Content="转换" HorizontalAlignment="Left" Margin="258,35,0,0" VerticalAlignment="Top" Width="75" Click="button5_Click" />
|
||||
<TextBlock HorizontalAlignment="Left" Margin="18,16,0,0" TextWrapping="Wrap" Text="颜色转换10进制" Foreground="Red" VerticalAlignment="Top" Width="192" />
|
||||
<TextBlock HorizontalAlignment="Left" Margin="23,0,0,0" TextWrapping="Wrap" Text="颜色转换16进制" Foreground="Red" VerticalAlignment="Center" Width="192" />
|
||||
<TextBlock Text="#" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="13,109,0,0" />
|
||||
<TextBox Name="textBox8" Text="" KeyDown="textBox8_KeyDown" HorizontalAlignment="Left" Margin="33,103,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" />
|
||||
<Button Name="button6" Content="转换" HorizontalAlignment="Left" Margin="258,103,0,0" VerticalAlignment="Top" Width="75" Click="button6_Click" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Width="700" Height="90" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,255,0,0">
|
||||
<Grid Height="60">
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,-20,0,0" TextWrapping="Wrap" Text="ASCII码转换" VerticalAlignment="Top"/>
|
||||
|
||||
<TextBlock Text="字符:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,16,0,0" />
|
||||
<TextBox Name="textBox9" Text="" KeyDown="textBox9_KeyDown" HorizontalAlignment="Left" Margin="55,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="70" />
|
||||
<Button Name="button7" Content="转换" HorizontalAlignment="Left" Margin="150,10,0,0" VerticalAlignment="Top" Width="75" Click="button7_Click" />
|
||||
|
||||
<TextBlock Text="ASCII码:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="250,17,0,0" />
|
||||
<TextBox Name="textBox10" Text="" KeyDown="textBox10_KeyDown" HorizontalAlignment="Left" Margin="310,11,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="70" />
|
||||
<Button Name="button8" Content="转换" HorizontalAlignment="Left" Margin="385,11,0,0" VerticalAlignment="Top" Width="75" Click="button8_Click" />
|
||||
|
||||
<TextBlock Text="16进制:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="485,16,0,0" />
|
||||
<TextBox Name="textBox11" Text="" KeyDown="textBox11_KeyDown" HorizontalAlignment="Left" Margin="535,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="75" />
|
||||
<Button Name="button9" Content="转换" HorizontalAlignment="Left" Margin="615,10,0,0" VerticalAlignment="Top" Width="75" Click="button9_Click" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
346
常用工具集/Views/05其他/进制转换及ASCII转换.axaml.cs
Normal file
346
常用工具集/Views/05其他/进制转换及ASCII转换.axaml.cs
Normal file
@@ -0,0 +1,346 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Avalonia.Input;
|
||||
using System;
|
||||
using 常用工具集.Base;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class 进制转换及ASCII转换 : UserControl
|
||||
{
|
||||
|
||||
public 进制转换及ASCII转换()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void textBox1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button1_Click(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string bin = textBox1.Text.Trim();
|
||||
if (bin.Length == 0)
|
||||
{
|
||||
bin = "0";
|
||||
}
|
||||
//二进制转换十进制
|
||||
int num = Convert.ToInt32(bin, 2);
|
||||
//十进制转
|
||||
string num8 = Convert.ToString(num, 8);
|
||||
//十进制转16进制
|
||||
string num16 = Convert.ToString(num, 16).ToUpper();
|
||||
textBox1.Text = bin;
|
||||
textBox2.Text = num8;
|
||||
textBox3.Text = Convert.ToString(num);
|
||||
textBox4.Text = num16;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GlobalValues.Error($"转换错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox2_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button2_Click(sender, e);
|
||||
}
|
||||
}
|
||||
private void button2_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string num8 = textBox2.Text.Trim();
|
||||
if (num8.Length == 0)
|
||||
{
|
||||
num8 = "0";
|
||||
}
|
||||
//二进制转换十进制
|
||||
int num10 = Convert.ToInt32(num8, 8);
|
||||
//十进制转
|
||||
string num2 = Convert.ToString(num10, 2);
|
||||
//十进制转16进制
|
||||
string num16 = Convert.ToString(num10, 16).ToUpper();
|
||||
textBox1.Text = num2;
|
||||
textBox2.Text = num8;
|
||||
textBox3.Text = Convert.ToString(num10);
|
||||
textBox4.Text = num16;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GlobalValues.Error($"转换错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox3_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button3_Click(sender, e);
|
||||
}
|
||||
}
|
||||
private void button3_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string strNum10 = textBox3.Text.Trim();
|
||||
if (strNum10.Length == 0)
|
||||
{
|
||||
strNum10 = "0";
|
||||
}
|
||||
//二进制转换十进制
|
||||
int num10 = Convert.ToInt32(strNum10);
|
||||
|
||||
string num2 = Convert.ToString(num10, 2);
|
||||
|
||||
string num8 = Convert.ToString(num10, 8);
|
||||
//十进制转16进制
|
||||
string num16 = Convert.ToString(num10, 16).ToUpper();
|
||||
textBox1.Text = num2;
|
||||
textBox2.Text = num8;
|
||||
textBox3.Text = Convert.ToString(num10);
|
||||
textBox4.Text = num16;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GlobalValues.Error($"转换错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
private void textBox4_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button4_Click(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void button4_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string strNum16 = textBox4.Text.Trim();
|
||||
if (strNum16.Length == 0)
|
||||
{
|
||||
strNum16 = "0";
|
||||
}
|
||||
//二进制转换十进制
|
||||
int num10 = Convert.ToInt32(strNum16, 16);
|
||||
string num2 = Convert.ToString(num10, 2);
|
||||
string num8 = Convert.ToString(num10, 8);
|
||||
//十进制转16进制
|
||||
string num16 = Convert.ToString(num10, 16).ToUpper();
|
||||
textBox1.Text = num2;
|
||||
textBox2.Text = num8;
|
||||
textBox3.Text = Convert.ToString(num10);
|
||||
textBox4.Text = num16;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GlobalValues.Error($"转换错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void textBox5_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button5_Click(sender, e);
|
||||
}
|
||||
}
|
||||
private void textBox6_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button5_Click(sender, e);
|
||||
}
|
||||
}
|
||||
private void textBox7_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button5_Click(sender, e);
|
||||
}
|
||||
}
|
||||
private void button5_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string r = textBox5.Text.Trim();
|
||||
if (r.Length == 0)
|
||||
{
|
||||
textBox5.Text = "0";
|
||||
}
|
||||
int intR = Convert.ToInt32(r);
|
||||
if (intR > 255)
|
||||
{
|
||||
intR = 255;
|
||||
textBox5.Text = "255";
|
||||
}
|
||||
string g = textBox6.Text.Trim();
|
||||
if (g.Length == 0)
|
||||
{
|
||||
textBox6.Text = "0";
|
||||
}
|
||||
int intG = Convert.ToInt32(g);
|
||||
if (intG > 255)
|
||||
{
|
||||
intG = 255;
|
||||
textBox6.Text = "255";
|
||||
}
|
||||
string b = textBox7.Text.Trim();
|
||||
if (b.Length == 0)
|
||||
{
|
||||
textBox7.Text = "0";
|
||||
}
|
||||
int intB = Convert.ToInt32(b);
|
||||
if (intB > 255)
|
||||
{
|
||||
intB = 255;
|
||||
textBox7.Text = "255";
|
||||
}
|
||||
string r16 = Convert.ToString(intR, 16).ToUpper().PadLeft(2, '0');
|
||||
string g16 = Convert.ToString(intG, 16).ToUpper().PadLeft(2, '0');
|
||||
string b16 = Convert.ToString(intB, 16).ToUpper().PadLeft(2, '0');
|
||||
textBox8.Text = r16 + g16 + b16;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GlobalValues.Error($"转换错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void textBox8_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button6_Click(sender, e);
|
||||
}
|
||||
}
|
||||
private void button6_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string value = textBox8.Text.Trim().ToUpper();
|
||||
if (value.Length == 0)
|
||||
{
|
||||
value = "000000";
|
||||
}
|
||||
else if (value.Length > 6)
|
||||
{
|
||||
value = value.Substring(0, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = value.PadLeft(6, '0');
|
||||
}
|
||||
textBox8.Text = value;
|
||||
string strR = value.Substring(0, 2);
|
||||
string strG = value.Substring(2, 2);
|
||||
string strB = value.Substring(4, 2);
|
||||
int intR = Convert.ToInt32(strR, 16);
|
||||
int intG = Convert.ToInt32(strG, 16);
|
||||
int intB = Convert.ToInt32(strB, 16);
|
||||
textBox5.Text = Convert.ToString(intR);
|
||||
textBox6.Text = Convert.ToString(intG);
|
||||
textBox7.Text = Convert.ToString(intB);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GlobalValues.Error($"转换错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void textBox9_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button7_Click(sender, e);
|
||||
}
|
||||
}
|
||||
private void button7_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string strChar = textBox9.Text.Trim();
|
||||
if (strChar.Length == 0)
|
||||
{
|
||||
strChar = "0";
|
||||
}
|
||||
textBox9.Text = strChar;
|
||||
char c = strChar.ToCharArray()[0];
|
||||
int intChar = c;
|
||||
textBox10.Text = Convert.ToString(intChar);
|
||||
textBox11.Text = Convert.ToString(intChar, 16);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GlobalValues.Error($"转换错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
private void textBox10_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button8_Click(sender, e);
|
||||
}
|
||||
}
|
||||
private void button8_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string asc2 = textBox10.Text.Trim();
|
||||
if (asc2.Length == 0)
|
||||
{
|
||||
asc2 = "48";
|
||||
}
|
||||
textBox10.Text = asc2;
|
||||
int num = Convert.ToInt32(asc2);
|
||||
char c = (char)num;
|
||||
textBox9.Text = Convert.ToString(c);
|
||||
textBox11.Text = Convert.ToString(num, 16);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GlobalValues.Error($"转换错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
private void textBox11_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
button9_Click(sender, e);
|
||||
}
|
||||
}
|
||||
private void button9_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string asc16 = textBox11.Text.Trim();
|
||||
if (asc16.Length == 0)
|
||||
{
|
||||
asc16 = "30";
|
||||
}
|
||||
textBox11.Text = asc16;
|
||||
int num = Convert.ToInt32(asc16, 16);
|
||||
char c = (char)num;
|
||||
textBox9.Text = Convert.ToString(c);
|
||||
textBox10.Text = Convert.ToString(num);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GlobalValues.Error($"转换错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user