using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.IO;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
namespace DPumpHydr.WinFrmUI.Volute
|
{
|
/// <summary>
|
/// 断面基本信息(形状等)
|
/// </summary>
|
public partial class ctrlSectionBaseInfo : UserControl
|
{
|
public ctrlSectionBaseInfo()
|
{
|
InitializeComponent();
|
BuildAllTips();
|
BuildIcon();
|
}
|
ViewModel.SectionBaseInfo _paras = null;
|
public void SetBindingData(ViewModel.SectionBaseInfo vm)
|
{
|
this._paras = vm;
|
if (vm == null)
|
{
|
return;
|
}
|
this.mTextBoxEdit蜗室平均速度.Text = vm.V3.ToString();
|
//this.skyTextBox断面VIIIy1.Text = vm.GaMa1.ToString();
|
//this.skyTextBox断面VIIIy2.Text = vm.GaMa2.ToString();
|
if (_paras.ShapeType == 0)
|
{
|
RBtn断面对称梯形.Checked = true;
|
RBtn不对称梯形.Checked = false;
|
RBtn矩形.Checked = false ;
|
}
|
if (_paras.ShapeType == 1)
|
{
|
RBtn断面对称梯形.Checked = false;
|
RBtn不对称梯形.Checked = true;
|
RBtn矩形.Checked = false;
|
}
|
if (_paras.ShapeType == 2)
|
{
|
RBtn断面对称梯形.Checked = false;
|
RBtn不对称梯形.Checked = false;
|
RBtn矩形.Checked = true;
|
}
|
|
}
|
public ViewModel.SectionBaseInfo GetBindingData(out string error)
|
{
|
if (!Verify(out error))
|
{
|
return null;
|
}
|
error = null;
|
if (_paras == null)
|
{
|
_paras = new ViewModel.SectionBaseInfo();
|
}
|
_paras.V3 = Convert.ToDouble(this.mTextBoxEdit蜗室平均速度.Text);
|
//_paras.GaMa1 = Convert.ToDouble(this.skyTextBox断面VIIIy1.Text);
|
//_paras.GaMa2 = Convert.ToDouble(this.skyTextBox断面VIIIy2.Text);
|
if (RBtn断面对称梯形.Checked)
|
{
|
_paras.ShapeType = 0;
|
}
|
if (RBtn不对称梯形.Checked)
|
{
|
_paras.ShapeType = 1;
|
}
|
if (RBtn矩形.Checked)
|
{
|
_paras.ShapeType = 2;
|
}
|
return _paras;
|
}
|
public bool Verify(out string error)
|
{
|
error = "";
|
bool isOk = true;
|
if (string.IsNullOrEmpty(mTextBoxEdit蜗室平均速度.Text) || mTextBoxEdit蜗室平均速度.Text == "请输入" || double.Parse(mTextBoxEdit蜗室平均速度.Text) == 0)
|
{
|
error = "请输入必填项!";
|
isOk = false;
|
mTextBoxEdit蜗室平均速度.TrailingIcon = GlobalResource.GetTipTrailingIcon();
|
skyLabel蜗室平均速度.Visible = true;
|
}
|
if (string.IsNullOrEmpty(skyTextBox断面VIIIy1.Text) || double.Parse(skyTextBox断面VIIIy1.Text) == 0)
|
{
|
error = "请输入必填项!";
|
isOk = false;
|
skyLabel提示y2.Visible = false;
|
skyLabely2.Visible = true;
|
}
|
if (string.IsNullOrEmpty(skyTextBox断面VIIIy2.Text) || double.Parse(skyTextBox断面VIIIy2.Text) == 0)
|
{
|
error = "请输入必填项!";
|
isOk = false;
|
skyLabel提示y1.Visible = false;
|
skyLabely1.Visible = true;
|
}
|
return isOk;
|
}
|
|
private void BuildIcon()
|
{
|
//对话框前缀图片
|
mTextBoxEdit蜗室平均速度.LeadingIcon = GlobalResource.GetLeadingIcon();
|
|
//断面形状图片
|
metroTile对称梯形.BackgroundImage = GlobalResource.BuildImage("duichentixing.png",97,88);
|
metroTile不对称梯形.BackgroundImage = GlobalResource.BuildImage("buduichentixing.png", 97, 88);
|
metroTile矩形.BackgroundImage = GlobalResource.BuildImage("juxing.png", 97, 88);
|
}
|
|
private void BuildAllTips()
|
{
|
metroToolTip第三步提示.SetToolTip(this.metroTile对称梯形, "对称梯形");
|
metroToolTip第三步提示.SetToolTip(this.metroTile不对称梯形, "不对称梯形");
|
metroToolTip第三步提示.SetToolTip(this.metroTile矩形, "矩形");
|
metroToolTip第三步提示.SetToolTip(this.mTextBoxEdit蜗室平均速度, "液体在蜗室内流动\n时的平均速度");
|
metroToolTip第三步提示.SetToolTip(this.skyTextBox断面VIIIy1, "y1 解释");
|
metroToolTip第三步提示.SetToolTip(this.skyTextBox断面VIIIy2, "y2 解释");
|
}
|
private void metroTile断面形状1_Click(object sender, EventArgs e)
|
{
|
RBtn断面对称梯形.Checked = true;
|
RBtn不对称梯形.Checked = false;
|
RBtn矩形.Checked = false;
|
|
}
|
|
private void metroTile断面形状2_Click(object sender, EventArgs e)
|
{
|
RBtn断面对称梯形.Checked = false;
|
RBtn不对称梯形.Checked = true;
|
RBtn矩形.Checked = false;
|
}
|
|
private void metroTile断面形状3_Click(object sender, EventArgs e)
|
{
|
RBtn断面对称梯形.Checked = false;
|
RBtn不对称梯形.Checked = false;
|
RBtn矩形.Checked = true;
|
}
|
|
private void mTextBoxEdit蜗室平均速度_Enter(object sender, EventArgs e)
|
{
|
skyLabel蜗室平均速度.Visible = false;
|
mTextBoxEdit蜗室平均速度.TrailingIcon = null;
|
if (mTextBoxEdit蜗室平均速度.Text == "请输入")
|
{
|
mTextBoxEdit蜗室平均速度.Text = "";
|
}
|
}
|
|
private void mTextBoxEdit蜗室平均速度_Leave(object sender, EventArgs e)
|
{
|
if (string.IsNullOrEmpty(mTextBoxEdit蜗室平均速度.Text) || double.Parse(mTextBoxEdit蜗室平均速度.Text) == 0)
|
{
|
mTextBoxEdit蜗室平均速度.Text = "请输入";
|
}
|
}
|
|
private void mTextBoxEdit蜗室平均速度_TextChanged(object sender, EventArgs e)
|
{
|
foreach (var s in mTextBoxEdit蜗室平均速度.Text)
|
{
|
if (!double.TryParse(mTextBoxEdit蜗室平均速度.Text, out double result) && !string.IsNullOrEmpty(mTextBoxEdit蜗室平均速度.Text) && mTextBoxEdit蜗室平均速度.Text != "请输入")
|
{
|
mTextBoxEdit蜗室平均速度.UseAccent = true;
|
mTextBoxEdit蜗室平均速度.ShowAssistiveText = true;
|
mTextBoxEdit蜗室平均速度.Text = "";
|
break;
|
}
|
else
|
{
|
mTextBoxEdit蜗室平均速度.ShowAssistiveText = false;
|
mTextBoxEdit蜗室平均速度.UseAccent = false;
|
}
|
}
|
}
|
|
|
private void skyTextBox断面VIIIy1_TextChanged(object sender, EventArgs e)
|
{
|
foreach (var s in skyTextBox断面VIIIy1.Text)
|
{
|
if (!double.TryParse(skyTextBox断面VIIIy1.Text, out double result) && !string.IsNullOrEmpty(skyTextBox断面VIIIy1.Text))
|
{
|
skyTextBox断面VIIIy1.Text = "";
|
skyLabel提示y1.Visible = true;
|
break;
|
}
|
}
|
}
|
|
private void skyTextBox断面VIIIy2_TextChanged(object sender, EventArgs e)
|
{
|
foreach (var s in skyTextBox断面VIIIy2.Text)
|
{
|
if (!double.TryParse(skyTextBox断面VIIIy2.Text, out double result) && !string.IsNullOrEmpty(skyTextBox断面VIIIy2.Text))
|
{
|
skyTextBox断面VIIIy2.Text = "";
|
skyLabel提示y2.Visible = true;
|
break;
|
}
|
}
|
}
|
private void skyTextBox断面VIIIy1_Enter(object sender, EventArgs e)
|
{
|
skyLabely1.Visible = false;
|
}
|
|
private void skyTextBox断面VIIIy2_Enter(object sender, EventArgs e)
|
{
|
skyLabely2.Visible = false;
|
}
|
|
|
private void mBtn计算断面面积_Click(object sender, EventArgs e)
|
{
|
if (string.IsNullOrEmpty(mTextBoxEdit蜗室平均速度.Text) || mTextBoxEdit蜗室平均速度.Text != "请输入蜗室平均速度")
|
{
|
skyLabel蜗室平均速度.Visible = true;
|
MessageBox.Show("请先输入蜗室平均速度!");
|
return;
|
}
|
}
|
|
private void mlBtn更改断面角度_Click(object sender, EventArgs e)
|
{
|
if (!RBtn断面对称梯形.Checked && !RBtn不对称梯形.Checked && !RBtn矩形.Checked)
|
{
|
MessageBox.Show("请先选择断面类型!");
|
return;
|
}
|
if (string.IsNullOrEmpty(skyTextBox断面VIIIy1.Text) || string.IsNullOrEmpty(skyTextBox断面VIIIy2.Text))
|
{
|
skyLabel提示y2.Visible = false;
|
skyLabel提示y1.Visible = false;
|
skyLabely1.Visible = true;
|
skyLabely2.Visible = true;
|
MessageBox.Show("请先输入y1、y2!");
|
return;
|
}
|
}
|
|
|
|
}
|
}
|