StableVersion4.3/HL_FristAidPlatform_Trauma/Page/UserControl_TimeAxis.cs

640 lines
30 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using HL_FristAidPlatform_Public;
using HL_FristAidPlatform_Trauma.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HL_FristAidPlatform_Trauma
{
public partial class UserControl_TimeAxis : UserControl
{
public string patientGUID;
public string hospitalWay;
DataTable Cur_TimeAxisDT;
/// <summary>
/// 图标起始点X坐标
/// </summary>
private int LocationX_Start = 20;
/// <summary>
/// 图标起始点Y坐标
/// </summary>
private int LocationY_Start = 0;
/// <summary>
/// 总行数
/// </summary>
private int TotalLines = 0;
/// <summary>
/// 每行节点总个数
/// </summary>
private int TotalPerRow = 14;
/// <summary>
/// 最后行总个数
/// </summary>
private int LastRowTotal = 0;
///// <summary>
///// 每列X轴递增间隔
///// </summary>
//private int IncrementalInterval_X = 0;
/// <summary>
/// 每行Y轴递增间隔
/// </summary>
private int IncrementalInterval_Y = 50;
public UserControl_TimeAxis()
{
InitializeComponent();
}
private void UserControl_TimeAxis_Load(object sender, EventArgs e)
{
RefreshTimeAxis();
}
public void RefreshTimeAxis()
{
overwritePanel_info.Controls.Clear();
try
{
//120来院方式
string Url = string.Format("api/service/T_Service_Trauma_FirstAidInfo/GetTimeAxis?patientGuid={0}&hospitalWay={1}", patientGUID, hospitalWay);
Cur_TimeAxisDT = DBHelpClass.GetJsonText(Url);
//总行数
TotalLines = (Cur_TimeAxisDT.Rows.Count / TotalPerRow);
//最后行总个数
LastRowTotal = Cur_TimeAxisDT.Rows.Count % TotalPerRow;
if (LastRowTotal > 0) //除不尽时增加一行
{
TotalLines += 1;
}
DrawLine(Cur_TimeAxisDT, overwritePanel_info);
DetailTime(Cur_TimeAxisDT, overwritePanel_info);
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "创伤时间轴:\r\n" + ex);
}
}
/// <summary>
/// 绘制线
/// </summary>
/// <param name="dataTable">数据源</param>
/// <param name="control">容器</param>
private void DrawLine(DataTable dataTable, Control control)
{
int xAdd = LocationX_Start;//线 起始点X坐标
int yAdd = LocationY_Start;//线 起始点Y坐标
#region 线
if (dataTable != null && dataTable.Rows.Count > 0)
{
#region
//有多行
//if (TotalLines > 1)
//{
// //从1开始
// for (int i = 1; i <= TotalLines; i++)
// {
// //奇数线
// if (i % 2 != 0)
// {
// #region 横线 从左向右
// int Point_X = xAdd;//X轴坐标
// int Point_Y = yAdd + IncrementalInterval_Y * (i - 1);//Y轴坐标
// //长度 每个间隔*(总个数-1)
// int Size_W = IncrementalInterval_Y * (TotalPerRow - 1);
// if (i == TotalLines)
// {
// Size_W = IncrementalInterval_Y * (LastRowTotal - 1);
// }
// int Size_H = 1;//高度 横线为1px
// Label label = new Label
// {
// Text = "lbl_line" + i,
// Name = "lbl_line" + i,
// BorderStyle = BorderStyle.FixedSingle,
// Location = new Point(Point_X, Point_Y),
// Size = new Size(Size_W, Size_H)
// };
// control.Controls.Add(label);
// label.SendToBack();//置底
// #endregion
// #region 竖线
// //不是最后一行时绘制竖线
// if (i != TotalLines)
// {
// //竖线
// int Point_Y_Vertical = 13 + IncrementalInterval_X * (TotalPerRow);//X轴坐标
// int Point_X_Vertical = yAdd + IncrementalInterval_Y * (i - 1);//Y轴坐标
// int Size_W_Vertical = 1;//长度 横线为1px
// int Size_H_Vertical = IncrementalInterval_Y;//高度
// Label label_Vertical = new Label
// {
// Text = "lbl_line" + i,
// Name = "lbl_line" + i,
// BorderStyle = BorderStyle.FixedSingle,
// Location = new Point(Point_X_Vertical, Point_Y_Vertical),
// Size = new Size(Size_H_Vertical, Size_W_Vertical)
// };
// control.Controls.Add(label_Vertical);
// label_Vertical.SendToBack();//置底
// }
// #endregion
// }
// //偶数线
// else
// {
// #region 横线 从右向左
// int Point_Y = xAdd;
// //是最后一行时绘制竖线
// if (i == TotalLines)
// {
// //X轴坐标 起始坐标+(每行总个数-当前行个数)*每行间隔
// Point_Y = xAdd + (TotalPerRow - LastRowTotal) * IncrementalInterval_Y;
// }
// //Y轴坐标 起始点Y坐标+间隔*(当前行数-1)
// int Point_X = yAdd + IncrementalInterval_X * (i - 1);
// //长度 每个间隔*(总个数-1)
// int Size_W = IncrementalInterval_Y * (TotalPerRow - 1);
// if (i == TotalLines)
// {
// Size_W = IncrementalInterval_Y * (LastRowTotal - 1);
// }
// int Size_H = 1;//高度 横线为1px
// Label label = new Label
// {
// Text = "lbl_line" + i,
// Name = "lbl_line" + i,
// BorderStyle = BorderStyle.FixedSingle,
// Location = new Point(Point_X, Point_Y),
// Size = new Size(Size_H, Size_W)
// };
// control.Controls.Add(label);
// label.SendToBack();//置底
// #endregion
// #region 竖线
// //不是最后一行时绘制竖线
// if (i != TotalLines)
// {
// //竖线
// int Point_X_Vertical = xAdd - 8;//X轴坐标
// int Point_Y_Vertical = yAdd + IncrementalInterval_Y * (i - 1);//Y轴坐标
// int Size_W_Vertical = 1;//长度 横线为1px
// int Size_H_Vertical = IncrementalInterval_Y;//高度
// Label label_Vertical = new Label
// {
// Text = "lbl_line" + i,
// Name = "lbl_line" + i,
// BorderStyle = BorderStyle.FixedSingle,
// Location = new Point(Point_X_Vertical, Point_Y_Vertical),
// Size = new Size(Size_W_Vertical, Size_H_Vertical)
// };
// control.Controls.Add(label_Vertical);
// label_Vertical.SendToBack();//置底
// }
// #endregion
// }
// }
//}
#endregion
//只有一行
#region 横线
int Point_X = xAdd;//X轴坐标
int Point_Y = yAdd;//Y轴坐标
int Size_H = xAdd + IncrementalInterval_Y * (TotalPerRow - 1);//长度
int Size_W = 1;//高度 横线为1px
Label label = new Label
{
Text = "lbl_line_1",
Name = "lbl_line_1",
BorderStyle = BorderStyle.FixedSingle,
Location = new Point(Point_X, Point_Y),
Size = new Size(Size_W, Size_H)//横线高度为1px
};
control.Controls.Add(label);
label.SendToBack();//置底
#endregion
}
#endregion
}
/// <summary>
/// 图标 先绘制
/// </summary>
/// <param name="_patientTimeAxisDT">数据源</param>
/// <param name="_timeParentID">所属父级节点编号</param>
private void DetailTime(DataTable _patientTimeAxisDT, Control _groupControl)
{
try
{
#region 急救跟踪绘制
int xName = 0;//节点名称X轴坐标对比变量 相对节点坐标而言
int xTime = 0;//实际时间X轴坐标对比变量 相对节点坐标而言
int yName = 0;//节点名称Y轴坐标对比变量 相对节点坐标而言
int yTime = 0;//实际时间Y轴坐标对比变量 相对节点坐标而言
int LineAdd_Y = 26;//每行文字的间隔 1:时间 2:时间节点名称 3:参考时长 4:实际时长
if (_patientTimeAxisDT != null && _patientTimeAxisDT.Rows.Count > 0)
{
if (TotalLines >= 1)
{
int ColorFlag = 0;//颜色标记: 0:黑色(正常) 1:橙色 2:红色
int Interval = 0;
bool ContrastTimeIsDefault = false;//当前节点参考时间是否为默认时间(表示上一个时间节点未填写),如果是则直接显示错误
bool IsCalculateActualLength = true;//是否计算实际时长
string ActualLength = "";//实际时长
string ActualLengthError = "";//错误时提示
DateTime timeControl = new DateTime();//离开现场
DateTime timeControl1 = new DateTime();//到达门急诊时间
DateTime timeControl2 = new DateTime();//会诊签到时间
DateTime timeControl3 = new DateTime();//全身快速CT完成时间 CT完成时间
DateTime timeControl4 = new DateTime();//申请输血时间
DateTime timeControl5 = new DateTime();//执行输血时间
for (int j = 0; j < _patientTimeAxisDT.Columns.Count; j++)
{
int cur_line = j / TotalPerRow;//所在行 +1
int cur_column = j % TotalPerRow;//所在列
int LocationX = 7;//当前单个节点X轴坐标
int LocationY = 0;//当前单个节点Y轴坐标
string RecordingTime = PublicClass.ToString(_patientTimeAxisDT.Rows[0][j], "");//实际发生时间
string TimeName = PublicClass.ToString(_patientTimeAxisDT.Columns[j], "");//时间节点名称
//Y轴坐标 原坐标+递减
LocationY = LocationY_Start + (cur_column * IncrementalInterval_Y);
TimeSpan TimeSpan = new TimeSpan();
DateTime ContrastTime = PublicClass.ToDateTime(RecordingTime, PublicClass.DefaultTime);
if (_patientTimeAxisDT.Columns[j] + "" == "离开现场")
{
timeControl = PublicClass.ToDateTime(_patientTimeAxisDT.Rows[0][j], PublicClass.DefaultTime);
}
else if (_patientTimeAxisDT.Columns[j] + "" == "到达门急诊时间")
{
timeControl1 = PublicClass.ToDateTime(_patientTimeAxisDT.Rows[0][j], PublicClass.DefaultTime);
if (timeControl + "" != "0001/1/1 0:00:00")
{
//Interval = 15;
TimeSpan = PublicClass.DiffMinutes(timeControl, timeControl1);
}
}
else if (_patientTimeAxisDT.Columns[j] + "" == "会诊签到时间")
{
Interval = 10;
timeControl2 = PublicClass.ToDateTime(_patientTimeAxisDT.Rows[0][j], PublicClass.DefaultTime);
if (timeControl1 + "" != "0001/1/1 0:00:00")
{
TimeSpan = PublicClass.DiffMinutes(timeControl1, timeControl2);
}
}
else if (_patientTimeAxisDT.Columns[j] + "" == "CT完成时间")
{
Interval = 30;
timeControl3 = PublicClass.ToDateTime(_patientTimeAxisDT.Rows[0][j], PublicClass.DefaultTime);
if (timeControl1 + "" != "0001/1/1 0:00:00")
{
TimeSpan = PublicClass.DiffMinutes(timeControl1, timeControl3);
}
}
else if (_patientTimeAxisDT.Columns[j] + "" == "申请输血时间")
{
Interval = 0;
timeControl4 = PublicClass.ToDateTime(_patientTimeAxisDT.Rows[0][j], PublicClass.DefaultTime);
}
else if (_patientTimeAxisDT.Columns[j] + "" == "执行输血时间")
{
Interval = 30;
timeControl5 = PublicClass.ToDateTime(_patientTimeAxisDT.Rows[0][j], PublicClass.DefaultTime);
if (timeControl4 + "" != "0001/1/1 0:00:00")
{
TimeSpan = PublicClass.DiffMinutes(timeControl4, timeControl5);
}
}
else
{
Interval = 0;
}
if (ContrastTime == PublicClass.DefaultTime)
{
IsCalculateActualLength = true;
ContrastTimeIsDefault = true;
}
//显示图标
ColorFlag = ShowImage(Interval, TimeSpan, j, LocationX, LocationY, RecordingTime, _groupControl, IsCalculateActualLength, out ActualLength);
#region 颜色
Color color = Color.Black;
if (ColorFlag == 1)
{
color = Color.LightSalmon;
}
else if (ColorFlag == 2)
{
color = Color.Red;
}
#endregion
//实际发生时间不为空时格式化
if (!string.IsNullOrEmpty(RecordingTime))
{
RecordingTime = Convert.ToDateTime(RecordingTime).ToString("MM月dd日 HH:mm");
}
#region 坐标
xName = Convert.ToInt32(TimeName.Length * 3.5);//每个字符12个像素 汉字
xTime = Convert.ToInt32(RecordingTime.Length * 2);//每个字符6个像素 数字
//Y轴 奇数偶数判断 等于0为偶数放图标底下
yName = 0;
yTime = 17;
#endregion
int labelX = 50;
//1:显示节点时间
LabelControl labelTime = new LabelControl
{
Name = "labelTime" + j.ToString(),
Text = RecordingTime,
Location = new Point(labelX, LocationY + yTime),
Size = new Size(20, 30),
ForeColor = color,
Visible = true
};
_groupControl.Controls.Add(labelTime);
//2:显示节点名称
LabelControl labelName = new LabelControl
{
Name = "labelName" + j.ToString(),
Text = TimeName,
Location = new Point(labelX, LocationY + yName),
Size = new Size(20, 30),
Visible = true
};
_groupControl.Controls.Add(labelName);
#region 参考时长
//3:参考时长Label显示
LabelControl referenceTimeLabel = new LabelControl
{
Name = "referenceTimeLabel" + j.ToString(),
Text = Interval != 0 ? Interval + "min" : "",
Location = new Point(labelX + 60, LocationY + LineAdd_Y + 4),
Size = new Size(100, 30),
ForeColor = Color.Green,
Visible = true
};
_groupControl.Controls.Add(referenceTimeLabel);
//如果参考时间为默认时间,直接为红色
if (ContrastTimeIsDefault)
{
ActualLength = ActualLengthError;
color = Color.Red;
}
//4:实际时长Label显示
LabelControl actualTimeLabel = new LabelControl
{
Name = "actualTimeLabel" + j.ToString(),
Text = ActualLength != "0min" ? ActualLength : "",
Location = new Point(labelX, LocationY + LineAdd_Y + 4),
Size = new Size(100, 30),
ForeColor = color,
Visible = true,
};
_groupControl.Controls.Add(actualTimeLabel);
#endregion
}
}
}
#endregion
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "急救跟踪绘制:\r\n" + ex);
}
}
/// <summary>
/// 显示图标
/// </summary>
/// <param name="interval">参考间隔</param>
/// <param name="timeSpan">两个节点间实际间隔</param>
/// <param name="number">第几个:用于图标控件名称,确保唯一性</param>
/// <param name="x">X轴坐标</param>
/// <param name="y">Y轴坐标</param>
/// <param name="recordingTime">发生的时间:控制是否显示灰色图标</param>
/// <param name="overwritePanel">所属绘制控件</param>
/// <param name="isCalculateActualLength">是否计算实际时长</param>
/// <param name="actualLength">实际时长</param>
/// <returns>返回的颜色标记: 0:黑色(正常) 1:橙色 2:红色</returns>
public int ShowImage(int interval, TimeSpan timeSpan, int number, int x, int y, string recordingTime, Control overwritePanel, bool isCalculateActualLength, out string actualLength)
{
//图标的Tag值传递时间节点编号+记录时间+维护界面标记 #分割
//string TagStr = timeAxisID + "#" + recordingTime + "#" + form_Flag;
//返回的颜色标记: 0:黑色(正常) 1:橙色 2:红色
int ColorFlag = 0;
//赋予默认值
actualLength = "";
//未录入:灰色
if (PublicClass.ToDateTime(recordingTime, PublicClass.DefaultTime) == PublicClass.DefaultTime)
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
//Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
//simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
}
//录入--异常:红色;正常:绿色
else
{
if (isCalculateActualLength)
{
//计算已经耗时
actualLength = Convert.ToInt32(timeSpan.TotalMinutes).ToString() + "min";
}
//【没有设置间隔参考】或者
if (interval == 0)
{
//间隔时间超过系统参数设置的参考间隔
int TotalMinutes = PublicClass.ToInt32(PublicClassForDataBase.Config112, 0);
if (TotalMinutes > 0)
{
if (Convert.ToInt32(timeSpan.TotalMinutes) > PublicClass.ToInt32(PublicClassForDataBase.Config112, 0))
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
//Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
//simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
ColorFlag = 2;
actualLength = "警告";
}
else
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
//Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
//simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
}
}
else
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
//Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
//simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
}
}
//【有设置时间间隔】
else
{
//对比时间不早于参考时间
if (timeSpan.TotalMinutes > 0)
{
//【参考间隔>=实际间隔】
if (interval >= Convert.ToInt32(timeSpan.TotalMinutes))
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
//Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
//simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
}
//【参考间隔<实际间隔】
else if (interval < Convert.ToInt32(timeSpan.TotalMinutes))
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
//Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
//simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
ColorFlag = 2;
}
}
//对比时间早于参考时间
else
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
//Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
//simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
ColorFlag = 2;
}
}
}
return ColorFlag;
}
}
}