172 lines
6.3 KiB
C#
172 lines
6.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Statistics.Resources;
|
|
|
|
namespace Statistics.UserControls
|
|
{
|
|
public partial class MidOrWaterMetersCtrl : UserControl
|
|
{
|
|
public MidId MidId;
|
|
public StatisticsDlg Parent;
|
|
|
|
public bool Flow1Enabled { get { return flow1CheckBox.Checked; } }
|
|
public double Flow1From { get { return flow1From; } }
|
|
public double Flow1To { get { return flow1To; } }
|
|
|
|
public bool Flow2Enabled { get { return flow2CheckBox.Checked; } }
|
|
public double Flow2From { get { return flow2From; } }
|
|
public double Flow2To { get { return flow2To; } }
|
|
|
|
public bool Flow3Enabled { get { return flow3CheckBox.Checked; } }
|
|
public double Flow3From { get { return flow3From; } }
|
|
public double Flow3To { get { return flow3To; } }
|
|
|
|
/// All flows are in m3/h
|
|
double flow1From;
|
|
double flow1To;
|
|
double flow2From;
|
|
double flow2To;
|
|
double flow3From;
|
|
double flow3To;
|
|
|
|
|
|
StatisticsCtrl GetStatistics(int i)
|
|
{
|
|
if ((i >= 0) && (i < benchesTabControl.TabPages.Count) && benchesTabControl.TabPages[i].Controls.Count > 0)
|
|
{
|
|
return benchesTabControl.TabPages[i].Controls[0] as StatisticsCtrl;
|
|
}
|
|
else return null;
|
|
}
|
|
|
|
|
|
public void UpdateRequest(int benchId)
|
|
{
|
|
Parent.UpdateRequest(benchId, MidId);
|
|
}
|
|
|
|
|
|
public MidOrWaterMetersCtrl()
|
|
{
|
|
InitializeComponent();
|
|
|
|
ManageCheckGroupBox(flow1CheckBox, flow1GroupBox);
|
|
ManageCheckGroupBox(flow2CheckBox, flow2GroupBox);
|
|
ManageCheckGroupBox(flow3CheckBox, flow3GroupBox);
|
|
|
|
for (int i = 0; i < benchesTabControl.TabPages.Count; i++ )
|
|
{
|
|
TabPage tp = benchesTabControl.TabPages[i];
|
|
if ((tp.Controls.Count > 0) && (tp.Controls[0] is StatisticsCtrl))
|
|
{
|
|
(tp.Controls[0] as StatisticsCtrl).Id = i;
|
|
(tp.Controls[0] as StatisticsCtrl).BenchesCtrl = this;
|
|
}
|
|
}
|
|
}
|
|
|
|
void Localize()
|
|
{
|
|
flow1CheckBox.Text = string.Format("{0} 1", Strings.Flow);
|
|
flow2CheckBox.Text = string.Format("{0} 2", Strings.Flow);
|
|
flow3CheckBox.Text = string.Format("{0} 3", Strings.Flow);
|
|
fromLabel2.Text = Strings.From;
|
|
fromLabel3.Text = Strings.From;
|
|
fromLabel4.Text = Strings.From;
|
|
toLabel2.Text = Strings.To;
|
|
toLabel3.Text = Strings.To;
|
|
toLabel4.Text = Strings.To;
|
|
}
|
|
|
|
private void flow1CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow1CheckBox, flow1GroupBox); }
|
|
private void flow2CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow2CheckBox, flow2GroupBox); }
|
|
private void flow3CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow3CheckBox, flow3GroupBox); }
|
|
|
|
private void ManageCheckGroupBox(CheckBox chk, GroupBox grp)
|
|
{
|
|
/// Make sure the CheckBox isn't in the GroupBox. This will only happen the first time.
|
|
if (chk.Parent == grp)
|
|
{
|
|
grp.Parent.Controls.Add(chk); /// Reparent the CheckBox so it's not in the GroupBox.
|
|
chk.Location = new Point(chk.Left + grp.Left, chk.Top + grp.Top); /// Adjust the CheckBox's location.
|
|
chk.BringToFront(); /// Move the CheckBox to the top of the stacking order.
|
|
}
|
|
|
|
/// Enable or disable the GroupBox.
|
|
grp.Enabled = chk.Checked;
|
|
}
|
|
|
|
private void flow1FromTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(flow1FromTextBox.Text))
|
|
{
|
|
flow1From = 0;
|
|
flow1FromExclamation.Visible = false;
|
|
}
|
|
else
|
|
flow1FromExclamation.Visible = !(double.TryParse(flow1FromTextBox.Text, out flow1From) && (flow1From >= 0));
|
|
}
|
|
|
|
private void flow1ToTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(flow1ToTextBox.Text))
|
|
{
|
|
flow1To = 0;
|
|
flow1ToExclamation.Visible = false;
|
|
}
|
|
else
|
|
flow1ToExclamation.Visible = !(double.TryParse(flow1ToTextBox.Text, out flow1To) && (flow1To >= 0));
|
|
}
|
|
|
|
private void flow2FromTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(flow2FromTextBox.Text))
|
|
{
|
|
flow2From = 0;
|
|
flow2FromExclamation.Visible = false;
|
|
}
|
|
else
|
|
flow2FromExclamation.Visible = !(double.TryParse(flow2FromTextBox.Text, out flow2From) && (flow2From >= 0));
|
|
}
|
|
|
|
private void flow2ToTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(flow2ToTextBox.Text))
|
|
{
|
|
flow2To = 0;
|
|
flow2ToExclamation.Visible = false;
|
|
}
|
|
else
|
|
flow2ToExclamation.Visible = !(double.TryParse(flow2ToTextBox.Text, out flow2To) && (flow2To >= 0));
|
|
}
|
|
|
|
private void flow3FromTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(flow3FromTextBox.Text))
|
|
{
|
|
flow3From = 0;
|
|
flow3FromExclamation.Visible = false;
|
|
}
|
|
else
|
|
flow3FromExclamation.Visible = !(double.TryParse(flow3FromTextBox.Text, out flow3From) && (flow3From >= 0));
|
|
}
|
|
|
|
private void flow3ToTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(flow3ToTextBox.Text))
|
|
{
|
|
flow3To = 0;
|
|
flow3ToExclamation.Visible = false;
|
|
}
|
|
else
|
|
flow3ToExclamation.Visible = !(double.TryParse(flow3ToTextBox.Text, out flow3To) && (flow3To >= 0));
|
|
}
|
|
}
|
|
}
|