using DevExpress.Utils.Extensions;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Drawing;
|
using System.Linq;
|
using System.Runtime.InteropServices;
|
using System.Windows.Forms;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
|
|
namespace IStation.WinFrmUI
|
{
|
public partial class TimeBlockRangeContainer : Panel
|
{
|
public TimeBlockRangeContainer()
|
{
|
InitializeComponent();
|
this.BackColor = Color.White;
|
|
_panel = new TimeBlockRangePanel();
|
_panel.Dock = DockStyle.Fill;
|
_panel.BackColor = Color.Red;
|
this.Controls.Add(_panel);
|
_panel.OnFreshPumpRunRange += (list) =>
|
{
|
if (OnFreshPumpRunRange != null)
|
{
|
OnFreshPumpRunRange.Invoke(list);
|
}
|
};
|
}
|
|
private TimeBlockRangePanel _panel = null;
|
|
|
private int _totalCount = 0;
|
private int _calcSpaceMinute = 10;//10分钟一个刻度
|
private bool _onInitialize = true;
|
private DateTime _startTime, _endTime;
|
|
public Action<List<CalcModel.PumpRunRange>> OnFreshPumpRunRange = null;
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public void InitialTimeBlock(DateTime start, DateTime end)
|
{
|
|
var drawBlocks = new List<TimeSmallBlock>();
|
|
|
|
_startTime = start;
|
_endTime = end;
|
|
int blk_index = 0;
|
for (var time = _startTime; time <= this._endTime; time = time.AddMinutes(this._calcSpaceMinute))
|
{
|
var block = new TimeSmallBlock(blk_index, time);
|
|
|
//if (locks.Contains(i))
|
//{
|
// block.DrawType = eDrawType.Lock;
|
//}
|
//else if (middles.Contains(i))
|
//{
|
// block.DrawType = eDrawType.Middle;
|
//}
|
//if (dashLines.Contains(i))
|
//{
|
// block.DottedLine = true;
|
//}
|
blk_index++;
|
|
drawBlocks.Add(block);
|
}
|
|
_totalCount = drawBlocks.Count;
|
_panel.Location = this.Location;
|
CalcSize(_totalCount);
|
_panel.InitialDataSource(drawBlocks);
|
_onInitialize = false;
|
|
#region
|
if (!string.IsNullOrEmpty(IStation.WinFrmUI.CalcErQu.Properties.Settings.Default.SwitchPumpIgnoreTimes))
|
{
|
var ttt = IStation.WinFrmUI.CalcErQu.Properties.Settings.Default.SwitchPumpIgnoreTimes.Split(
|
new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
foreach (var t in ttt)
|
{
|
var ddd = t.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
|
var st = ddd[1].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
var ed = ddd[2].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
|
int ed_h = Convert.ToInt32(ed[0]);
|
|
|
if (Convert.ToBoolean(ddd[0]))
|
{
|
var IsNexDay = ed_h > 23 ? true : false;
|
|
var StartH = Convert.ToInt32(st[0]);
|
var StartM = Convert.ToInt32(st[1]);
|
var EndH = ed_h > 23 ? ed_h - 24 : ed_h;
|
var EndM = Convert.ToInt32(ed[1]);
|
|
//foreach(var b in drawBlocks)
|
//{
|
// if(b.Time.Hour >= StartH && b.Time.Minute)
|
//}
|
}
|
|
|
}
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(IStation.WinFrmUI.CalcErQu.Properties.Settings.Default.OpenPumpIgnoreTimes))
|
{
|
var ttt = IStation.WinFrmUI.CalcErQu.Properties.Settings.Default.OpenPumpIgnoreTimes.Split(
|
new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
foreach (var t in ttt)
|
{
|
var ddd = t.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
|
var st = ddd[1].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
var ed = ddd[2].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
|
int ed_h = Convert.ToInt32(ed[0]);
|
|
//CurrentViewModel v = new CurrentViewModel();
|
//v.IsUse = Convert.ToBoolean(ddd[0]);
|
//v.IsNexDay = ed_h > 23 ? true : false;
|
|
//v.StartH = Convert.ToInt32(st[0]);
|
//v.StartM = Convert.ToInt32(st[1]);
|
//v.EndH = ed_h > 23 ? ed_h - 24 : ed_h;
|
//v.StartM = Convert.ToInt32(ed[1]);
|
|
//list不许开泵时间.Add(v);
|
}
|
}
|
|
|
#endregion
|
|
|
|
_onInitialize = false;
|
}
|
|
|
|
|
/// <summary>
|
/// 计算大小
|
/// </summary>
|
public void CalcSize(int count)
|
{
|
_panel.CalcOptimumSize(this.Width, this.Height, count, out int optimalWidth, out int optimalHeight);
|
if (optimalHeight > this.Height)
|
{
|
optimalWidth -= 30;
|
}
|
_panel.Size = new Size(optimalWidth, optimalHeight);
|
}
|
|
|
|
|
|
protected override void OnResize(EventArgs eventargs)
|
{
|
base.OnResize(eventargs);
|
if (_onInitialize)
|
return;
|
CalcSize(_totalCount);
|
_panel.InitialItemSize();
|
}
|
|
|
/// <summary>
|
/// 切换
|
/// </summary>
|
public void SetSelectBlockPumpCount(int selectedPumpCount)
|
{
|
|
_panel.SetSelectBlockPumpCount(selectedPumpCount);
|
}
|
|
}
|
}
|