添加项目文件。
This commit is contained in:
108
MetroGauges/WpfTurnout.xaml.cs
Normal file
108
MetroGauges/WpfTurnout.xaml.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace MetroGauges
|
||||
{
|
||||
/// <summary>
|
||||
/// Forks.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class WpfTurnout
|
||||
{
|
||||
public WpfTurnout()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void previewTextInput(object sender, TextCompositionEventArgs e)//禁止文本输入
|
||||
{
|
||||
e.Handled = !IsTextAllowed(e.Text);
|
||||
}
|
||||
|
||||
private void TextBoxPasting(object sender, DataObjectPastingEventArgs e)//禁用黏贴
|
||||
{
|
||||
if (e.DataObject.GetDataPresent(typeof(String)))
|
||||
{
|
||||
String text = (String)e.DataObject.GetData(typeof(String));
|
||||
if (!IsTextAllowed(text))
|
||||
{
|
||||
e.CancelCommand();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
e.CancelCommand();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsTextAllowed(string text)//只能输入数字
|
||||
{
|
||||
Regex regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text
|
||||
return !regex.IsMatch(text);
|
||||
}
|
||||
|
||||
private void setAMetroParam()
|
||||
{
|
||||
//TO.a = 15700; TO.p = 2500; TO.hsc = 1800; TO.bp = 1940; TO.bs = 1880; TO.cp = 1350; TO.cs = 600; TO.hcp = 500;
|
||||
//TO.hcs = 850; TO.np = 4; TO.ns = 2; TO.kφn = 4900; TO.g = 9.81; TO.mB = 47920;
|
||||
}
|
||||
|
||||
private void setBMetroParam()
|
||||
{
|
||||
//TO.a = 12600; TO.p = 2200; TO.hsc = 1500; TO.bp = 1930; TO.bs = 1850; TO.cp = 1800; TO.cs = 480; TO.hcp = 510;
|
||||
//TO.hcs = 905; TO.np = 4; TO.ns = 2; TO.kφn = 4900; TO.g = 9.81; TO.mB = 42600;
|
||||
}
|
||||
|
||||
private void rbA_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
setAMetroParam();
|
||||
}
|
||||
|
||||
private void rbB_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
setBMetroParam();
|
||||
}
|
||||
|
||||
private void btnCal_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var children = WpPanel.Children;
|
||||
foreach (var item in children)
|
||||
{
|
||||
if (item is TextBox)
|
||||
{
|
||||
TextBox t = item as TextBox;
|
||||
if (t.Text.Equals(""))
|
||||
{
|
||||
//this.ShowMessageAsync("提示", "请输入计算所需参数" + t.Text);
|
||||
t.Focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TO.V = Convert.ToDouble(V.Text); TO.R = Convert.ToDouble(R.Text);
|
||||
|
||||
//a.Text = Convert.ToString(TO.A()); F.Text = Convert.ToString(TO.F());
|
||||
//ΔXqa.Text = Convert.ToString(TO.ΔXqa(Convert.ToDouble(Y.Text)));
|
||||
}
|
||||
|
||||
private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
e.Cancel = true;
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void Help_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Process.Start(".\\HelpFile.pdf");
|
||||
}
|
||||
|
||||
private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
setAMetroParam();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user