444 lines
17 KiB
C#
444 lines
17 KiB
C#
using HelperDB;
|
||
using Newtonsoft.Json;
|
||
using AIMSExtension;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using System.Windows.Forms.Design;
|
||
|
||
namespace DrawGraph
|
||
{
|
||
public class IconManage : AreaManageBase
|
||
{
|
||
public RectangleFramePackObj IconPpack;
|
||
public LinePackObj H5pack;
|
||
public TextPackObj Extend2;
|
||
/// <summary>
|
||
/// 当前手术对象
|
||
/// </summary>
|
||
private OperationRecord myOpeRecord = null;
|
||
|
||
|
||
public IconManage() { }
|
||
public IconManage(object _operationRecor, ZedGraphControl _zedControl, TemplateManage _template, string _name) : base(_operationRecor, _zedControl, _template, _name)
|
||
{
|
||
init();
|
||
}
|
||
public void init()
|
||
{
|
||
//自己要用的手术对象
|
||
myOpeRecord = OpeRecord as OperationRecord;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始画的后置方法
|
||
/// </summary>
|
||
public override void FollowUpMethod()
|
||
{
|
||
H5pack = template.GetPackObjectOTag<LinePackObj>("IconManage_LinePackObj_5");
|
||
if (H5pack != null)
|
||
{
|
||
eventstartX = H5pack.RealX;
|
||
eventy = H5pack.RealY;
|
||
eventendy = H5pack.RealEndY;
|
||
}
|
||
IconPpack = template.GetPackObjectOTag<RectangleFramePackObj>("IconManage_RectangleFramePackObj_2");
|
||
if (IconPpack != null)
|
||
{
|
||
eventy = IconPpack.RealY;
|
||
eventendy = IconPpack.RealEndY;
|
||
eventendX = IconPpack.RealEndX + 0.02;
|
||
}
|
||
LinePackObj line = template.GetPackObjectOTag<LinePackObj>("IconManage_LinePackObj_6");
|
||
if (line != null)
|
||
{
|
||
eventstartX = line.RealX;
|
||
eventendX = line.RealEndX + 0.02;
|
||
}
|
||
}
|
||
|
||
#region 重写的事件
|
||
/// <summary>
|
||
/// 鼠标点击画板
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
public override void MouseDown(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
//if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
||
//{
|
||
// MessageBox.Show(this.GetType().Name + "is Click Left Button");
|
||
//}
|
||
}
|
||
public override void MouseMove(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
}
|
||
public override void MouseUp(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
}
|
||
public override void MouseDoubleClick(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
}
|
||
public override void KeyUp(ZedGraphControl sender, KeyEventArgs e)
|
||
{
|
||
}
|
||
|
||
#endregion 重写的事件结束
|
||
|
||
public override void Bind()
|
||
{
|
||
init();
|
||
|
||
DrawEvent();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 画事件
|
||
/// </summary>
|
||
private void DrawEvent()
|
||
{
|
||
if (myOpeRecord.FactEventsList.Count > 0)
|
||
{
|
||
foreach (FactEvents temp in myOpeRecord.FactEventsList)
|
||
{
|
||
temp.clearAddObj(ZedControl);
|
||
}
|
||
reDrawEvent();
|
||
}
|
||
}
|
||
|
||
double eventy;
|
||
double eventendy;
|
||
double eventendX;
|
||
double eventstartX;
|
||
/// <summary>
|
||
/// 重新画事件文本
|
||
/// </summary>
|
||
private void reDrawEvent()
|
||
{
|
||
//画在第几行
|
||
int rowIndex = 0;
|
||
DateTime? drawDatetime = null;
|
||
FactEvents drawEvent = null;
|
||
string LastNumber = "";
|
||
double span = getYPositionByListIndex(1, eventy, eventendy, 2);
|
||
List<string> eventListstr = new List<string>();
|
||
eventListstr.Add("【事件】");
|
||
myOpeRecord.FactEventsList.Sort(new FactEventsComparer());
|
||
//循环加药集体
|
||
for (int i = 0; i < myOpeRecord.FactEventsList.Count; i++)
|
||
{
|
||
FactEvents temp = myOpeRecord.FactEventsList[i];
|
||
//ShowRespDate(temp, null);
|
||
|
||
//判断该事件是否存在当前时间段
|
||
if (IfInTimeExist(temp.EventBeginTime.Value, temp.EventEndTime.Value) == false) continue;
|
||
|
||
if (temp.EventBeginTime.Value.ToShortTimeString() == temp.EventEndTime.Value.ToShortTimeString())
|
||
{
|
||
eventListstr.Add(string.Format("{0}{1} {2} {3}{4}", getNumber(i), temp.EventBeginTime.Value.ToShortTimeString(), temp.EventName, "", temp.Remark == null ? "" : temp.Remark.ToString()));
|
||
}
|
||
else
|
||
{
|
||
eventListstr.Add(string.Format("{0}{1}->{2} {3} {4}{5}", getNumber(i), temp.EventBeginTime.Value.ToShortTimeString(), temp.EventEndTime.Value.ToShortTimeString(), temp.EventName, "", temp.Remark == null ? "" : temp.Remark.ToString()));
|
||
}
|
||
|
||
temp.setAnasArr(ZedControl, eventstartX, eventendX, myOpeRecord.PageBegin, myOpeRecord.PageBegin.AddMinutes(EVERY_PAGE_TIME_SPAN));
|
||
try
|
||
{
|
||
string EventName = temp.EventName;
|
||
if (EventName == "喉罩") EventName = "插管";
|
||
DataRow[] dr = myOpeRecord.PhysioParamList.Select("Name ='" + EventName + "' ", "");
|
||
if (dr.Length > 0)
|
||
{
|
||
temp.clearDNAndDT(ZedControl);
|
||
string tagName = dr[0]["imgPath"].ToString();
|
||
temp.drawIMG(ZedControl, tagName, eventy, 0.013);
|
||
}
|
||
else
|
||
{
|
||
int DValue = 0;
|
||
string drawNumber = "";
|
||
if (drawDatetime != null && temp.EventBeginTime > drawDatetime.Value.AddMinutes(-1) && temp.EventBeginTime < drawDatetime.Value.AddMinutes(10) && LastNumber != "" && drawEvent != null)
|
||
{
|
||
drawEvent.clearDNAndDT(ZedControl);
|
||
drawEvent = temp;
|
||
drawNumber = LastNumber + "-" + getNumber(i);
|
||
DValue = (int)(((TimeSpan)(temp.EventBeginTime - drawDatetime.Value)).TotalMinutes / 2);
|
||
}
|
||
else
|
||
{
|
||
LastNumber = getNumber(i);
|
||
drawNumber = LastNumber;
|
||
drawEvent = temp;
|
||
drawDatetime = temp.EventBeginTime.Value;
|
||
}
|
||
//画图上的序号
|
||
temp.drawNumber(ZedControl, drawNumber, eventy + span - 0.001, DValue, Color.DarkBlue);
|
||
}
|
||
rowIndex++;
|
||
}
|
||
catch (Exception exp)
|
||
{
|
||
PublicMethod.WriteLog(exp, "");
|
||
}
|
||
}
|
||
myOpeRecord.EventListstr = eventListstr;
|
||
TextPackObj packObj2 = template.GetPackObjectOTag<TextPackObj>("IconManage_TextPackObj_14_OperationRecord_AnalgesiaRecord_Extend2");
|
||
if (packObj2 != null)
|
||
{
|
||
List<string> AfterDrugsListstr = new List<string>();
|
||
myOpeRecord.ClearIconstr(ZedControl) ;
|
||
foreach (var item in myOpeRecord.FactDrugList)
|
||
{
|
||
ListAddDrugs(AfterDrugsListstr, item);
|
||
}
|
||
if (AfterDrugsListstr.Count > 0)
|
||
{
|
||
SetRemarkInfo(AfterDrugsListstr, packObj2, 15, 6.5f, 40,"IconDrugRemarkRow");
|
||
|
||
//packObj2.PackText = "";
|
||
//foreach (var item in AfterDrugsListstr)
|
||
//{
|
||
// packObj2.PackText += item ;//+ "\n"
|
||
//}
|
||
//packObj2.PackValue = packObj2.PackText;
|
||
//packObj2.Draw();
|
||
}
|
||
}
|
||
TextPackObj packObj = template.GetPackObjectOTag<TextPackObj>("IconManage_TextPackObj_40_OperationRecord_AnalgesiaRecord_Extend3");
|
||
if (packObj != null && eventListstr.Count > 1)
|
||
{
|
||
List<string> Eventststr = new List<string>();
|
||
foreach (var item in eventListstr)
|
||
{
|
||
if (item != "【事件】")
|
||
Eventststr.Add(((item.Substring(1, item.Length - 1))));
|
||
}
|
||
if (Eventststr.Count > 0)
|
||
{
|
||
SetRemarkInfo(Eventststr, packObj, 15, 7f, 38, "IconeventRemarkRow");
|
||
}
|
||
|
||
//packObj.PackText = "";
|
||
//foreach (var item in eventListstr)
|
||
//{
|
||
// if (item != "【事件】")
|
||
// packObj.PackText += ((item.Substring(1, item.Length - 1)) + "\n");
|
||
//}
|
||
//packObj.PackValue = packObj.PackText;
|
||
//packObj.Draw();
|
||
}
|
||
}
|
||
private void SetRemarkInfo(List<string> PunctureAndIntubatios, TextPackObj remarkPpack, int remarkRowscount, float fontsize, int fontlength,string TagName )
|
||
{
|
||
int remarkRow = 0;
|
||
int AllRemarkRow = 0;
|
||
double lastIndex = remarkPpack.RealEndY;
|
||
double x = remarkPpack.RealX;
|
||
double y = remarkPpack.RealY + getYPositionByListIndex(remarkRow, remarkPpack.RealY, lastIndex, remarkRowscount);
|
||
|
||
if (PunctureAndIntubatios != null )
|
||
{
|
||
foreach (string item in PunctureAndIntubatios)
|
||
{
|
||
List<string> PunStr = stringformat(item, fontlength);
|
||
for (int m = 0; m < PunStr.Count; m++)
|
||
{
|
||
if (PunStr[m] == null) continue;
|
||
y = remarkPpack.RealY + getYPositionByListIndex(remarkRow, remarkPpack.RealY, lastIndex, remarkRowscount);
|
||
if (PunStr[m] == null || PunStr[m].Trim() == "") break;
|
||
ZUtil.DrawText(PunStr[m], x, y, ZedControl, fontsize, TagName + AllRemarkRow);
|
||
remarkRow++;
|
||
AllRemarkRow++;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private static void ListAddDrugs(List<string> DrugListstr, FactDrug temp)
|
||
{
|
||
string dose = "";
|
||
if (temp.Density != 0)
|
||
{
|
||
dose += ((double)temp.Density).ToString();
|
||
if (temp.DensityUnit != null)
|
||
{
|
||
dose += temp.DensityUnit;
|
||
}
|
||
}
|
||
if (dose.Trim() != "") dose += " ";
|
||
if (temp.Velocity != "")
|
||
{
|
||
dose += temp.Velocity;
|
||
if (temp.VelocityUnit != null)
|
||
{
|
||
dose += temp.VelocityUnit;
|
||
}
|
||
}
|
||
if (dose.Trim() != "") dose += " ";
|
||
if (temp.Dosage != 0)
|
||
{
|
||
dose += ((double)temp.Dosage).ToString();
|
||
if (temp.DosageUnit != null)
|
||
{
|
||
dose += temp.DosageUnit;
|
||
}
|
||
}
|
||
DrugListstr.Add(string.Format("{0}{1} {2} {3}{4}{5}", "", (temp.DrugBeginTime == temp.DrugEndTime) ? temp.DrugBeginTime.ToShortTimeString() : temp.DrugBeginTime.ToShortTimeString() + "->" + temp.DrugEndTime.ToShortTimeString(), temp.DrugName.Trim(), dose, "", temp.DrugChannel == null ? "" : " " + temp.DrugChannel.ToString()));
|
||
//DrugListstr.Append(" ");
|
||
}
|
||
#region 格式化字符串长度
|
||
/// <summary>
|
||
/// 格式化字符串长度
|
||
/// </summary>
|
||
/// <param name="str">输入的字符串</param>
|
||
/// <param name="n">截取的长度</param>
|
||
/// <returns>被截取完的字符串</returns>
|
||
public static List<string> stringformat(string str, int n)
|
||
{
|
||
///
|
||
///格式化字符串长度,超出部分显示省略号,区分汉字跟字母。汉字2个字节,字母数字一个字节
|
||
///
|
||
List<string> strList = new List<string>();
|
||
string temp = string.Empty;
|
||
if (System.Text.Encoding.Default.GetByteCount(str) <= n)//如果长度比需要的长度n小,返回原字符串
|
||
{
|
||
strList.Add(str);
|
||
}
|
||
else
|
||
{
|
||
int t = 0;
|
||
char[] q = str.ToCharArray();
|
||
for (int i = 0; i <= q.Length; i++)
|
||
{
|
||
if (t > n)
|
||
{
|
||
strList.Add(temp);
|
||
temp = "";
|
||
t = 0;
|
||
}
|
||
if (i == q.Length)// - 1
|
||
{
|
||
strList.Add(temp);
|
||
break;
|
||
}
|
||
//判断是否汉字:
|
||
if ((int)q[i] >= 0x4E00 && (int)q[i] <= 0x9FA5)
|
||
{
|
||
temp += q[i];
|
||
t += 2;
|
||
}
|
||
//判断半角如下:
|
||
else if (q[i].ToString().Length == Encoding.Default.GetByteCount(q[i].ToString()))
|
||
{
|
||
temp += q[i];
|
||
t++;
|
||
}
|
||
//判断全角如下:
|
||
else if (2 * q[i].ToString().Length == Encoding.Default.GetByteCount(q[i].ToString()))
|
||
{
|
||
temp += q[i];
|
||
t += 2;
|
||
}
|
||
else
|
||
{
|
||
temp += q[i];
|
||
t++;
|
||
}
|
||
}
|
||
}
|
||
return strList;
|
||
}
|
||
#endregion
|
||
|
||
private bool IfInTimeExist(DateTime Begin, DateTime End)
|
||
{
|
||
DateTime lastime = myOpeRecord.lastPageBegin.AddSeconds(59);
|
||
bool b = false;
|
||
if (End == null)
|
||
{
|
||
if (Begin > myOpeRecord.PageBegin && Begin < lastime)
|
||
{
|
||
b = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (Begin >= myOpeRecord.PageBegin && Begin <= lastime)
|
||
{
|
||
b = true;
|
||
}
|
||
else if (End >= myOpeRecord.PageBegin && End <= lastime)
|
||
{
|
||
b = true;
|
||
}
|
||
else if (Begin < myOpeRecord.PageBegin && End > lastime)
|
||
{
|
||
b = true;
|
||
}
|
||
}
|
||
return b;
|
||
}
|
||
|
||
private DateTime GetInsertTime(DateTime pdTemp, bool IsInRToomTime = false)
|
||
{
|
||
DateTime insTime = pdTemp.Date.AddHours(pdTemp.Hour).AddMinutes(pdTemp.Minute);
|
||
if (collectInterval == 5)
|
||
{
|
||
int minute = pdTemp.Minute % 5;//计算5的整数分钟
|
||
if (minute >= 3)
|
||
insTime = insTime.AddMinutes(5 - minute);
|
||
else if (minute != 0 && IsInRToomTime == true)
|
||
insTime = insTime.AddMinutes(5 - minute);
|
||
else
|
||
insTime = insTime.AddMinutes(0 - minute);
|
||
}
|
||
else if (collectInterval == 10)
|
||
{
|
||
double minute = pdTemp.Minute % 10;//计算5的整数分钟
|
||
if (minute >= 5)
|
||
insTime = insTime.AddMinutes(10 - minute);
|
||
else
|
||
insTime = insTime.AddMinutes(0 - minute);
|
||
}
|
||
return insTime;
|
||
}
|
||
/// <summary>
|
||
/// 根据顶部加药序号,确定数值生命体征的纵向位置(以1为单位)
|
||
/// </summary>
|
||
/// <param name="index"></param>
|
||
/// <returns></returns>
|
||
public double getYPositionByListIndex(double index, double yTop, double yBottom, int rowCount)
|
||
{
|
||
double heightT = ZedControl.Height * (yBottom - yTop);
|
||
double setpTemp = heightT / rowCount;
|
||
//求一格在实际高度中的百分比
|
||
double bfb = (setpTemp / heightT);
|
||
//两线之间度*百分比得到一格的百分比高度
|
||
double ygBFB = (yBottom - yTop) * bfb;
|
||
double y = ygBFB * index;
|
||
return y;
|
||
}
|
||
public static string getNumber(int number)
|
||
{
|
||
try
|
||
{
|
||
string str = "①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮";
|
||
if (number >= 15)
|
||
str = "①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳㉑㉒㉓㉔㉕㉖㉗㉘㉙㉚㉛㉜㉝㉞㉟㊱㊲㊳㊴㊵㊶㊷㊸㊹㊺㊻㊼㊽㊾㊿";
|
||
str = str.Substring(number, 1);
|
||
return str;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
return number.ToString() + ":";
|
||
}
|
||
}
|
||
}
|
||
}
|