using DevExpress.XtraEditors;
|
using DevExpress.XtraRichEdit.API.Native;
|
using IStation.Model;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Linq;
|
using System.Windows.Forms;
|
|
namespace IStation.WinFrmUI.CalcErQu
|
{
|
public partial class AnaSettingMgrDlg : XtraForm
|
{
|
public AnaSettingMgrDlg()
|
{
|
InitializeComponent();
|
}
|
|
public class CurrentViewModel
|
{
|
public bool IsUse { get; set; } = true;
|
public bool IsNexDay { get; set; }
|
public int? StartH { get; set; }
|
public int? StartM { get; set; } = 0;
|
public int? EndH { get; set; }
|
public int? EndM { get; set; } = 0;
|
}
|
private BindingList<CurrentViewModel> list不许换泵时间;
|
private BindingList<CurrentViewModel> list允许开泵时间;
|
|
private void AnaSettingMgrDlg_Load(object sender, EventArgs e)
|
{
|
var anaSetting = IStation.AnaGlobalParas.Setting;
|
if (anaSetting == null)
|
return;
|
spinEditStartHour.EditValue = anaSetting.StartHourPerDay;
|
spinEdit最少切换泵时间.EditValue = anaSetting.MinSwitchTimeMinute;
|
spinEdit最少开泵时间.EditValue = anaSetting.MinOpenTimeMinute;
|
spinEdit分析步长Q.EditValue = anaSetting.CalcSpaceMinuteQ;
|
spinEdit切泵次数Q.EditValue = anaSetting.MaxPumpSwitchCountQ;
|
spinEdit分析步长L.EditValue = anaSetting.CalcSpaceMinuteL;
|
spinEdit切泵次数L.EditValue = anaSetting.MaxPumpSwitchCountL;
|
|
spinEdit长江水位基准.EditValue = anaSetting.RiverWaterLevelBase;
|
|
list不许换泵时间 = new BindingList<CurrentViewModel>();
|
if ( anaSetting.SwitchPumpIgnoreTimes != null)
|
{
|
foreach (var t in anaSetting.SwitchPumpIgnoreTimes)
|
{
|
CurrentViewModel v = new CurrentViewModel();
|
v.IsUse = t.IsUse;
|
v.StartH = t.StartHour;
|
v.StartM = t.StartMinute;
|
v.EndH = t.EndHour;
|
v.EndM = t.EndMinute;
|
|
list不许换泵时间.Add(v);
|
}
|
}
|
this.bindingSource1.DataSource = list不许换泵时间;
|
|
|
|
list允许开泵时间 = new BindingList<CurrentViewModel>();
|
if ( anaSetting.OpenPumpTimes != null)
|
{
|
foreach (var t in anaSetting.OpenPumpTimes)
|
{
|
CurrentViewModel v = new CurrentViewModel();
|
v.IsUse = t.IsUse;
|
v.StartH = t.StartHour;
|
v.StartM = t.StartMinute;
|
v.EndH = t.EndHour;
|
v.EndM = t.EndMinute;
|
|
list允许开泵时间.Add(v);
|
}
|
}
|
this.bindingSource2.DataSource = list允许开泵时间;
|
|
|
var list水库参数 = IStation.AnaGlobalParas.ReservoirParasList;
|
if (list水库参数 != null && list水库参数.Count > 0)
|
{
|
List<Model.ReservoirParas> list水库参数New = new List<Model.ReservoirParas>();
|
foreach (var item in list水库参数)
|
{
|
list水库参数New.Add(new Model.ReservoirParas() { Level = Convert.ToDouble(item.Level), Area = Convert.ToDouble(item.Area), Volume = Convert.ToDouble(item.Volume) });
|
}
|
this.bindingSetting.DataSource = list水库参数New;
|
}
|
|
|
|
btnColor长江水位.BackColor = IStation.Settings.DispSetting.ChartColor长江水位;
|
btnColor前池水位.BackColor = IStation.Settings.DispSetting.ChartColor前池水位;
|
btnColor水库水位.BackColor = IStation.Settings.DispSetting.ChartColor水库水位;
|
btnColor瞬时流量.BackColor = IStation.Settings.DispSetting.ChartColor瞬时流量;
|
btnColor瞬时功率.BackColor = IStation.Settings.DispSetting.ChartColor瞬时功率;
|
}
|
|
private void btnOk_Click(object sender, EventArgs e)
|
{
|
var anaSetting = IStation.AnaGlobalParas.Setting;
|
if (anaSetting == null)
|
return;
|
anaSetting.RiverWaterLevelBase = Convert.ToDouble(spinEdit长江水位基准.EditValue);
|
anaSetting.MinSwitchTimeMinute = Convert.ToInt32(spinEdit最少切换泵时间.EditValue);
|
anaSetting.StartHourPerDay = Convert.ToInt32(spinEditStartHour.EditValue);
|
anaSetting.MinOpenTimeMinute = Convert.ToInt32(spinEdit最少开泵时间.EditValue);
|
anaSetting.CalcSpaceMinuteQ = Convert.ToInt32(spinEdit分析步长Q.EditValue);
|
anaSetting.MaxPumpSwitchCountQ = Convert.ToInt32(spinEdit切泵次数Q.EditValue);
|
anaSetting.CalcSpaceMinuteL = Convert.ToInt32(spinEdit分析步长L.EditValue);
|
anaSetting.MaxPumpSwitchCountL = Convert.ToInt32(spinEdit切泵次数L.EditValue);
|
|
anaSetting.SwitchPumpIgnoreTimes = new List<CalcModel.AnaSetting.TimeRange>();
|
foreach (var m in list不许换泵时间)
|
{
|
if (m.StartH == null || m.EndH == null)
|
{
|
continue;
|
}
|
|
var v = new CalcModel.AnaSetting.TimeRange()
|
{
|
IsUse = m.IsUse,
|
StartHour = m.StartH == null ? 0 : m.StartH.Value,
|
StartMinute = m.StartM == null ? 0 : m.StartM.Value,
|
EndHour = m.EndH == null ? 0 : m.EndH.Value,
|
EndMinute = m.EndM == null ? 0 : m.EndM.Value
|
};
|
if(v.StartHour *60+v.StartMinute >= v.EndHour * 60 + v.EndMinute)
|
{
|
MessageBox.Show("切泵时间限制设置不合理");
|
return;
|
}
|
anaSetting.SwitchPumpIgnoreTimes.Add(v);
|
}
|
|
anaSetting.OpenPumpTimes = new List<CalcModel.AnaSetting.TimeRange>();
|
foreach (var m in list允许开泵时间)
|
{
|
if (m.StartH == null || m.EndH == null)
|
{
|
continue;
|
}
|
|
var v = new CalcModel.AnaSetting.TimeRange()
|
{
|
IsUse = m.IsUse,
|
StartHour = m.StartH == null ? 0 : m.StartH.Value,
|
StartMinute = m.StartM == null ? 0 : m.StartM.Value,
|
EndHour = m.EndH == null ? 0 : m.EndH.Value,
|
EndMinute = m.EndM == null ? 0 : m.EndM.Value
|
};
|
if (v.StartHour * 60 + v.StartMinute >= v.EndHour * 60 + v.EndMinute)
|
{
|
MessageBox.Show("开泵时间限制设置不合理");
|
return;
|
}
|
anaSetting.OpenPumpTimes.Add(v);
|
}
|
|
|
|
|
var list水库参数Old = IStation.AnaGlobalParas.ReservoirParasList;
|
List<Model.ReservoirParas> list水库参数New = this.bindingSetting.DataSource as List<Model.ReservoirParas>;
|
if(!Model.ReservoirParas.IsSample(list水库参数Old, list水库参数New))
|
IStation.BLL.ReservoirParas.SaveList(list水库参数New);
|
|
|
IStation.BLL.AnaSetting.SaveSetting(anaSetting);
|
|
//
|
this.Close();
|
}
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void btnColor长江水位_Click(object sender, EventArgs e)
|
{
|
System.Windows.Forms.ColorDialog colorDialog1 = new System.Windows.Forms.ColorDialog();
|
colorDialog1.Color = IStation.Settings.DispSetting.ChartColor长江水位;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
IStation.Settings.DispSetting.ChartColor长江水位 = colorDialog1.Color;
|
btnColor长江水位.BackColor = colorDialog1.Color;
|
SettingsHelper.Save();
|
}
|
}
|
|
private void btnColor前池水位_Click(object sender, EventArgs e)
|
{
|
System.Windows.Forms.ColorDialog colorDialog1 = new System.Windows.Forms.ColorDialog();
|
colorDialog1.Color = IStation.Settings.DispSetting.ChartColor前池水位;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
IStation.Settings.DispSetting.ChartColor前池水位 = colorDialog1.Color;
|
btnColor前池水位.BackColor = colorDialog1.Color;
|
SettingsHelper.Save();
|
}
|
}
|
|
private void btnColor水库水位_Click(object sender, EventArgs e)
|
{
|
System.Windows.Forms.ColorDialog colorDialog1 = new System.Windows.Forms.ColorDialog();
|
colorDialog1.Color = IStation.Settings.DispSetting.ChartColor水库水位;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
IStation.Settings.DispSetting.ChartColor水库水位 = colorDialog1.Color;
|
btnColor水库水位.BackColor = colorDialog1.Color;
|
SettingsHelper.Save();
|
}
|
}
|
|
private void btnColor瞬时流量_Click(object sender, EventArgs e)
|
{
|
System.Windows.Forms.ColorDialog colorDialog1 = new System.Windows.Forms.ColorDialog();
|
colorDialog1.Color = IStation.Settings.DispSetting.ChartColor瞬时流量;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
IStation.Settings.DispSetting.ChartColor瞬时流量 = colorDialog1.Color;
|
btnColor瞬时流量.BackColor = colorDialog1.Color;
|
SettingsHelper.Save();
|
}
|
}
|
|
private void btnColor瞬时功率_Click(object sender, EventArgs e)
|
{
|
System.Windows.Forms.ColorDialog colorDialog1 = new System.Windows.Forms.ColorDialog();
|
colorDialog1.Color = IStation.Settings.DispSetting.ChartColor瞬时功率;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
IStation.Settings.DispSetting.ChartColor瞬时功率 = colorDialog1.Color;
|
btnColor瞬时功率.BackColor = colorDialog1.Color;
|
SettingsHelper.Save();
|
}
|
}
|
}
|
}
|