|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.IO;
|
using System.Linq;
|
using System.Reflection;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace DPumpHydr.WinFrmUI.Volute
|
{
|
/// <summary>
|
/// 1-8断面设计
|
/// </summary>
|
public partial class ctrlSectionShapeInfo18 : ParasInfoBaseCtrl
|
{
|
public ctrlSectionShapeInfo18()
|
{
|
InitializeComponent();
|
BuildIcon();
|
BuildAllTips();
|
}
|
ViewModel.SectionShapePara _paras = null;
|
public void SetBindingData(ViewModel.SectionShapePara vm)
|
{
|
this._paras = vm;
|
if (vm == null)
|
{
|
return;
|
}
|
this.mTextBoxEdity1.Text = vm.Gama_Left.ToString();
|
this.mTextBoxEdity2.Text = vm.Gama_Right.ToString();
|
this.mTextBoxEditR1.Text = vm.R_Left.ToString();
|
this.mTextBoxEditR2.Text = vm.R_Right.ToString();
|
this.mTextBoxEditH.Text = vm.H.ToString();
|
this.mTextBoxEditR4.Text = vm.R_out.ToString();
|
this.crownLabelindex.Text = "第" + vm.Index;
|
|
InitialModule();
|
}
|
public void RefreshSectPara(ViewModel.SectionShapePara paras)
|
{
|
SetBindingData(paras);
|
// paras.ii
|
}
|
public ViewModel.SectionShapePara GetBindingData(out string error)
|
{
|
if (!Verify(out error))
|
{
|
return null;
|
}
|
error = null;
|
if (_paras == null)
|
{
|
return null;
|
}
|
_paras.Gama_Left = Convert.ToDouble(this.mTextBoxEdity1.Text);
|
_paras.Gama_Right = Convert.ToDouble(this.mTextBoxEdity2.Text);
|
_paras.R_Left = Convert.ToDouble(this.mTextBoxEditR1.Text);
|
_paras.R_Right = Convert.ToDouble(this.mTextBoxEditR2.Text);
|
_paras.H = Convert.ToDouble(this.mTextBoxEditH.Text);
|
_paras.R_out = Convert.ToDouble(this.mTextBoxEditR4.Text);
|
return _paras;
|
}
|
|
|
|
|
public bool Verify(out string error)
|
{
|
error = "";
|
bool isOk = true;
|
if (string.IsNullOrEmpty(mTextBoxEditR1.Text) || double.Parse(mTextBoxEditR1.Text) == 0)
|
{
|
isOk = false;
|
error = "请输入必填项!";
|
mTextBoxEditR1.TrailingIcon = GlobalResource.GetTipTrailingIcon();
|
skyLabelW4.Visible = true;
|
}
|
if (RBtnW1.Checked)
|
{
|
if (string.IsNullOrEmpty(mTextBoxEditW1.Text) || mTextBoxEditW1.Text == "请输入" || double.Parse(mTextBoxEditW1.Text) == 0)
|
{
|
isOk = false;
|
error = "请输入W1!";
|
mTextBoxEditW1.TrailingIcon = GlobalResource.GetTipTrailingIcon();
|
skyLabelW1.Visible = true;
|
}
|
if (string.IsNullOrEmpty(mTextBoxEditu.Text) || mTextBoxEditu.Text == "请输入" || double.Parse(mTextBoxEditu.Text) == 0)
|
{
|
isOk = false;
|
error = "请输入U!";
|
mTextBoxEditu.TrailingIcon = GlobalResource.GetTipTrailingIcon();
|
skyLabelU.Visible = true;
|
}
|
}
|
if (string.IsNullOrEmpty(mTextBoxEdity1.Text) || double.Parse(mTextBoxEdity1.Text) == 0)
|
{
|
isOk = false;
|
error = "请输入V1!";
|
mTextBoxEdity1.TrailingIcon = GlobalResource.GetTipTrailingIcon();
|
skyLabely1.Visible = true;
|
}
|
if (string.IsNullOrEmpty(mTextBoxEdity2.Text) || double.Parse(mTextBoxEdity2.Text) == 0)
|
{
|
isOk = false;
|
error = "请输入V2!";
|
mTextBoxEdity2.TrailingIcon = GlobalResource.GetTipTrailingIcon();
|
skyLabely2.Visible = true;
|
}
|
if (RBtnW4.Checked)
|
{
|
if (string.IsNullOrEmpty(mTextBoxEditW4.Text) || mTextBoxEditW4.Text == "请输入W4" || double.Parse(mTextBoxEditW4.Text) == 0)
|
{
|
isOk = false;
|
error = "请输入W4!";
|
mTextBoxEditW4.TrailingIcon = GlobalResource.GetTipTrailingIcon();
|
skyLabelW4.Visible = true;
|
}
|
}
|
return isOk;
|
}
|
|
|
private void BuildIcon()
|
{
|
//断面形状图片
|
metroTile断面形状.BackgroundImage = GlobalResource.BuildImage("duanmian.png", 190, 190);
|
|
//输入框前缀
|
mTextBoxEditW1.LeadingIcon = GlobalResource.GetLeadingIcon();
|
mTextBoxEditu.LeadingIcon = GlobalResource.GetLeadingIcon();
|
mTextBoxEdity1.LeadingIcon = GlobalResource.GetLeadingIcon();
|
mTextBoxEditR1.LeadingIcon = GlobalResource.GetLeadingIcon();
|
}
|
|
private void BuildAllTips()
|
{
|
metroToolTip第四步提示.SetToolTip(this.metroTile断面形状, "断面图");
|
metroToolTip第四步提示.SetToolTip(this.mTextBoxEditW1, "W1 解释");
|
metroToolTip第四步提示.SetToolTip(this.mTextBoxEditu, "u 解释");
|
metroToolTip第四步提示.SetToolTip(this.mTextBoxEdity1, "V1 解释");
|
metroToolTip第四步提示.SetToolTip(this.mTextBoxEdity2, "V2 解释");
|
metroToolTip第四步提示.SetToolTip(this.mTextBoxEditW4, "W4 解释");
|
metroToolTip第四步提示.SetToolTip(this.mTextBoxEditR1, "R1 解释");
|
}
|
private void InitialModule()
|
{
|
if (_paras.ShapeType == ViewModel.eSectionShapeType.对称)
|
{
|
mTextBoxEdity1.Enabled = true;
|
mTextBoxEdity2.Enabled = false;
|
}
|
if (_paras.ShapeType == ViewModel.eSectionShapeType.矩形)
|
{
|
mTextBoxEdity2.Enabled = false;
|
mTextBoxEdity1.Enabled = false;
|
}
|
if (_paras.ShapeType == ViewModel.eSectionShapeType.不对称)
|
{
|
mTextBoxEdity1.Enabled = true;
|
mTextBoxEdity2.Enabled = true;
|
}
|
}
|
|
|
private void mTextBoxEditW1_Enter(object sender, EventArgs e)
|
{
|
skyLabelW1.Visible = false;
|
mTextBoxEditW1.TrailingIcon = null;
|
if (mTextBoxEditW1.Text == "请输入")
|
{
|
mTextBoxEditW1.Text = "";
|
}
|
}
|
|
private void mTextBoxEditW1_Leave(object sender, EventArgs e)
|
{
|
if ((string.IsNullOrEmpty(mTextBoxEditW1.Text) || double.Parse(mTextBoxEditW1.Text) == 0) && mTextBoxEditW1.Enabled == true)
|
{
|
mTextBoxEditW1.Text = "请输入";
|
}
|
}
|
|
private void mTextBoxEditW1_TextChanged(object sender, EventArgs e)
|
{
|
if (mTextBoxEditW1.Enabled)
|
{
|
foreach (var s in mTextBoxEditW1.Text)
|
{
|
if (!double.TryParse(mTextBoxEditW1.Text, out double result) && !string.IsNullOrEmpty(mTextBoxEditW1.Text) && mTextBoxEditW1.Text != "请输入")
|
{
|
mTextBoxEditW1.UseAccent = true;
|
mTextBoxEditW1.ShowAssistiveText = true;
|
mTextBoxEditW1.Text = "";
|
break;
|
}
|
else
|
{
|
mTextBoxEditW1.ShowAssistiveText = false;
|
mTextBoxEditW1.UseAccent = false;
|
}
|
}
|
}
|
}
|
|
private void mTextBoxEditu_TextChanged(object sender, EventArgs e)
|
{
|
if (mTextBoxEditu.Enabled)
|
{
|
foreach (var s in mTextBoxEditu.Text)
|
{
|
if (!double.TryParse(mTextBoxEditu.Text, out double result) && !string.IsNullOrEmpty(mTextBoxEditu.Text) && mTextBoxEditu.Text != "请输入")
|
{
|
mTextBoxEditu.UseAccent = true;
|
mTextBoxEditu.ShowAssistiveText = true;
|
mTextBoxEditu.Text = "";
|
break;
|
}
|
else
|
{
|
mTextBoxEditu.ShowAssistiveText = false;
|
mTextBoxEditu.UseAccent = false;
|
}
|
}
|
}
|
}
|
|
private void mTextBoxEditu_Enter(object sender, EventArgs e)
|
{
|
skyLabelU.Visible = false;
|
mTextBoxEditu.TrailingIcon = null;
|
if (mTextBoxEditu.Text == "请输入")
|
{
|
mTextBoxEditu.Text = "";
|
}
|
}
|
|
private void mTextBoxEditu_Leave(object sender, EventArgs e)
|
{
|
if ((string.IsNullOrEmpty(mTextBoxEditu.Text) || double.Parse(mTextBoxEditu.Text) == 0) && mTextBoxEditu.Enabled == true)
|
{
|
mTextBoxEditu.Text = "请输入";
|
}
|
}
|
|
private void mTextBoxEditv1_Enter(object sender, EventArgs e)
|
{
|
skyLabely1.Visible = false;
|
mTextBoxEdity1.TrailingIcon = null;
|
}
|
|
private void mTextBoxEditv1_Leave(object sender, EventArgs e)
|
{
|
if ((string.IsNullOrEmpty(mTextBoxEdity1.Text) || double.Parse(mTextBoxEdity1.Text) == 0) && mTextBoxEdity1.Enabled == true)
|
{
|
mTextBoxEdity1.Text = _paras.Gama_Left.ToString();
|
}
|
}
|
|
private void mTextBoxEditv1_TextChanged(object sender, EventArgs e)
|
{
|
if (mTextBoxEdity1.Enabled)
|
{
|
foreach (var s in mTextBoxEdity1.Text)
|
{
|
if (!double.TryParse(mTextBoxEdity1.Text, out double result) && !string.IsNullOrEmpty(mTextBoxEdity1.Text))
|
{
|
mTextBoxEdity1.UseAccent = true;
|
mTextBoxEdity1.ShowAssistiveText = true;
|
mTextBoxEdity1.Text = "";
|
break;
|
}
|
else
|
{
|
mTextBoxEdity1.ShowAssistiveText = false;
|
mTextBoxEdity1.UseAccent = false;
|
}
|
}
|
if (_paras.ShapeType == ViewModel.eSectionShapeType.对称)
|
{
|
mTextBoxEdity2.Text = mTextBoxEdity1.Text;
|
}
|
}
|
}
|
|
private void mTextBoxEditv2_Enter(object sender, EventArgs e)
|
{
|
skyLabely1.Visible = false;
|
mTextBoxEdity2.TrailingIcon = null;
|
}
|
|
private void mTextBoxEditv2_Leave(object sender, EventArgs e)
|
{
|
if ((string.IsNullOrEmpty(mTextBoxEdity2.Text) || double.Parse(mTextBoxEdity2.Text) == 0) && mTextBoxEdity2.Enabled == true)
|
{
|
mTextBoxEdity2.Text = _paras.Gama_Right.ToString();
|
}
|
}
|
|
private void mTextBoxEditv2_TextChanged(object sender, EventArgs e)
|
{
|
if (mTextBoxEdity2.Enabled)
|
{
|
foreach (var s in mTextBoxEdity2.Text)
|
{
|
if (!double.TryParse(mTextBoxEdity2.Text, out double result) && !string.IsNullOrEmpty(mTextBoxEdity2.Text))
|
{
|
mTextBoxEdity2.UseAccent = true;
|
mTextBoxEdity2.ShowAssistiveText = true;
|
mTextBoxEdity2.Text = "";
|
break;
|
}
|
else
|
{
|
mTextBoxEdity2.ShowAssistiveText = false;
|
mTextBoxEdity2.UseAccent = false;
|
}
|
}
|
}
|
}
|
|
private void mTextBoxEditW4_Enter(object sender, EventArgs e)
|
{
|
if (mTextBoxEditW4.Text == "请输入W4")
|
{
|
mTextBoxEditW4.Text = "";
|
}
|
}
|
|
private void mTextBoxEditW4_Leave(object sender, EventArgs e)
|
{
|
if ((string.IsNullOrEmpty(mTextBoxEditW4.Text) || double.Parse(mTextBoxEditW4.Text) == 0) && mTextBoxEditW4.Enabled == true)
|
{
|
mTextBoxEditW4.Text = "请输入W4";
|
}
|
}
|
|
private void mTextBoxEditW4_TextChanged(object sender, EventArgs e)
|
{
|
if (mTextBoxEditW4.Enabled)
|
{
|
foreach (var s in mTextBoxEditW4.Text)
|
{
|
if (!double.TryParse(mTextBoxEditW4.Text, out double result) && !string.IsNullOrEmpty(mTextBoxEditW4.Text) && mTextBoxEditW4.Text != "请输入W4")
|
{
|
mTextBoxEditW4.UseAccent = true;
|
mTextBoxEditW4.ShowAssistiveText = true;
|
mTextBoxEditW4.Text = "";
|
break;
|
}
|
else
|
{
|
mTextBoxEditW4.ShowAssistiveText = false;
|
mTextBoxEditW4.UseAccent = false;
|
}
|
}
|
}
|
}
|
|
|
private void mTextBoxEditR1_Enter(object sender, EventArgs e)
|
{
|
skyLabelR1.Visible = false;
|
mTextBoxEditR1.TrailingIcon = null;
|
}
|
|
private void mTextBoxEditR1_Leave(object sender, EventArgs e)
|
{
|
if ((string.IsNullOrEmpty(mTextBoxEditR1.Text) || double.Parse(mTextBoxEditR1.Text) == 0) && mTextBoxEditR1.Enabled == true)
|
{
|
mTextBoxEditR1.Text = _paras.R_Left.ToString();
|
}
|
}
|
|
private void mTextBoxEditR1_TextChanged(object sender, EventArgs e)
|
{
|
if (mTextBoxEditR1.Enabled)
|
{
|
foreach (var s in mTextBoxEditR1.Text)
|
{
|
if (!double.TryParse(mTextBoxEditR1.Text, out double result) && !string.IsNullOrEmpty(mTextBoxEditR1.Text))
|
{
|
mTextBoxEditR1.UseAccent = true;
|
mTextBoxEditR1.ShowAssistiveText = true;
|
mTextBoxEditR1.Text = "";
|
break;
|
}
|
else
|
{
|
mTextBoxEditR1.ShowAssistiveText = false;
|
mTextBoxEditR1.UseAccent = false;
|
}
|
}
|
}
|
if (_paras.ShapeType == ViewModel.eSectionShapeType.对称)
|
{
|
mTextBoxEditR2.Text = mTextBoxEditR1.Text;
|
}
|
}
|
|
|
|
private void RBtnW1_CheckedChanged(object sender)
|
{
|
if (RBtnW1.Checked)
|
{
|
mTextBoxEditW1.Enabled = true;
|
mTextBoxEditu.Enabled = true;
|
mTextBoxEditW1.LeadingIcon = GlobalResource.GetLeadingIcon();
|
mTextBoxEditu.LeadingIcon = GlobalResource.GetLeadingIcon();
|
mTextBoxEditW1.Text = "请输入";
|
mTextBoxEditu.Text = "请输入";
|
}
|
else
|
{
|
mTextBoxEditW1.Enabled = false;
|
mTextBoxEditu.Enabled = false;
|
mTextBoxEditW1.LeadingIcon = null;
|
mTextBoxEditu.LeadingIcon = null;
|
mTextBoxEditW1.Text = "W1";
|
mTextBoxEditu.Text = "u";
|
}
|
}
|
|
|
|
private void RBtnW4_CheckedChanged(object sender)
|
{
|
if (RBtnW4.Checked)
|
{
|
mTextBoxEditW4.Enabled = true;
|
mTextBoxEditW4.LeadingIcon = GlobalResource.GetLeadingIcon();
|
mTextBoxEditW4.Text = "请输入W4";
|
}
|
else
|
{
|
mTextBoxEditW4.Enabled = false;
|
mTextBoxEditW4.LeadingIcon = null;
|
mTextBoxEditW4.Text = "w4";
|
}
|
}
|
|
private void mTextBoxEdity1_EnabledChanged(object sender, EventArgs e)
|
{
|
if (mTextBoxEdity1.Enabled)
|
{
|
mTextBoxEdity1.LeadingIcon = GlobalResource.GetLeadingIcon();
|
}
|
else
|
{
|
mTextBoxEdity1.LeadingIcon = null;
|
}
|
}
|
|
private void mTextBoxEdity2_EnabledChanged(object sender, EventArgs e)
|
{
|
if (mTextBoxEdity2.Enabled)
|
{
|
mTextBoxEdity2.LeadingIcon = GlobalResource.GetLeadingIcon();
|
}
|
else
|
{
|
mTextBoxEdity2.LeadingIcon = null;
|
}
|
}
|
public Action<ViewModel.SectionShapePara> OnRefreshShape = null;
|
private void mBtn更新模型_Click(object sender, EventArgs e)
|
{
|
if (OnRefreshShape == null)
|
return;
|
string error;
|
var paras = GetBindingData(out error);
|
if(paras == null)
|
{
|
MessageBox.Show(error);
|
return;
|
}
|
OnRefreshShape.Invoke(paras);
|
}
|
}
|
}
|