AIMS/AIMSEntity/AreaManage/IconManage.cs
2022-08-23 21:12:59 +08:00

266 lines
8.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DrawGraph;
using DrawGraph.AreaManage;
using DrawGraph.BoardPack;
using DrawGraph.GUtil;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AIMS.EF
{
public class IconManage : AreaManageBase
{
public RectangleFramePackObj IconPpack;
public LinePackObj H5pack;
/// <summary>
/// 当前手术对象
/// </summary>
private OperationRecord myOpeRecord = null;
private XmlUtil xmlOpe = new XmlUtil("");
private string EVENTPARAMPATH = "main/eventParams/eventParam";
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");
IconPpack = template.GetPackObjectOTag<RectangleFramePackObj>("IconManage_RectangleFramePackObj_2");
}
#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();
//MessageBox.Show("RemarkManage重新绑定");
}
#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
public bool isCgtime(string key, DateTime time)
{
bool b = false;
try
{
if (key == "自主呼吸")
{
if (myOpeRecord.InCGTime != null && myOpeRecord.OutCGTime != null)
{
if (time > myOpeRecord.InCGTime && time < myOpeRecord.OutCGTime)
b = true;
}
if (myOpeRecord.InCGTime != null && myOpeRecord.OutCGTime == null)
{
if (time > myOpeRecord.InCGTime)
b = true;
}
}
else
{
b = false;
}
}
catch (Exception ex)
{
throw;
}
return b;
}
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;
}
/// <summary>
/// 根据生理参数名称获取对应的目标值
/// </summary>
/// <param name="strPath">生理参数XML路径</param>
/// <param name="typeValue">生理参数名称</param>
/// <param name="targetName">目标生理参数项目</param>
/// <returns>生理参数项的值</returns>
private string getSiblingName(string strPath, string typeValue, string targetName)
{
string result = "";
try
{
result = xmlOpe.GetNode("name", typeValue, strPath, targetName);
}
catch (Exception)
{
throw new Exception("读取XML发生错误");
}
return result;
}
}
}