AIMS/DrawGraph/AreaManage/AreaManageBase.cs
2022-09-29 19:39:02 +08:00

571 lines
14 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 Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace DrawGraph
{
[Serializable, JsonObject(MemberSerialization.OptOut)]
/// <summary>
/// 区域管理类的基础类
/// </summary>
public class AreaManageBase : IEquatable<AreaManageBase>
{
/// <summary>
/// 当前手术状态
/// </summary>
public DoAnesOpeStatus AnesOpeStatue = DoAnesOpeStatus.VIEW;
/// <summary>
/// 生理数据的时间间隔
/// </summary>
public int collectInterval = 5;
/// <summary>
/// 分页绘图的页时间间隔,以分钟为单位
/// </summary>
public double EVERY_PAGE_TIME_SPAN = 240.0; //minutes
public AreaManageBase()
{
OpeRecord = new object();
}
public AreaManageBase(object _operationRecor, ZedGraphControl _zedControl, TemplateManage _template, string _name)
{
OpeRecord = _operationRecor;
ZedControl = _zedControl;
template = _template;
Name = _name;
}
#region
[JsonIgnore]
protected TemplateManage template = new TemplateManage(); //根的模板管理器对象
[JsonIgnore]
private PackObjManager packManage = new PackObjManager();
[JsonIgnore]
private ZedGraphControl zedControl = null;
[JsonIgnore]
private object opeRecord = null;
[JsonIgnore]
private string packManagerFileName = "";
private string name = "";
private string className = "";
private string msgStr = "";
private string direct = "";
private int id;
private bool isSelfFresh = true; //仅自己改动时可以刷新
private string dllName = "";
private string nameSpace = "";
private string instanceName = "";
[JsonIgnore]
[XmlIgnore]
/// <summary>
/// 手术记录
/// </summary>
public object OpeRecord
{
get { return opeRecord; }
set { opeRecord = value; }
}
[JsonIgnore]
[XmlIgnore]
/// <summary>
/// 画板组件包管理器
/// </summary>
public PackObjManager PackManage
{
get { return packManage; }
set { packManage = value; }
}
[JsonIgnore]
[XmlIgnore]
/// <summary>
/// 消息内容
/// </summary>
public string MsgStr
{
get
{
return msgStr;
}
set
{
msgStr = value;
}
}
[JsonIgnore]
[XmlIgnore]
/// <summary>
/// 画板的组件
/// </summary>
public ZedGraphControl ZedControl
{
get
{
return zedControl;
}
set
{
zedControl = value;
}
}
[JsonIgnore]
[XmlIgnore]
public int Id
{
get
{
return id;
}
set
{
id = value;
}
}
[JsonIgnore]
[XmlIgnore]
public string Direct
{
get
{
return direct;
}
set
{
direct = value;
}
}
/// <summary>
/// 画板组件包管理器原件
/// </summary>
public string PackManagerFileName
{
get
{
return packManagerFileName;
}
set
{
packManagerFileName = value;
}
}
/// <summary>
/// 区域管理器中文名称
/// </summary>
public string Name
{
get
{
return name;
}
set
{
name = value;
if (packManage != null)
{
packManage.Name = name;
}
}
}
/// <summary>
/// 类名称
/// </summary>
public string ClassName
{
get
{
return className;
}
set
{
className = value;
if (packManage != null)
{
packManage.ClassName = className;
}
}
}
/// <summary>
/// 仅自己改动时可以刷新
/// </summary>
public bool IsSelfFresh
{
get
{
return isSelfFresh;
}
set
{
isSelfFresh = value;
foreach (PackObjBase packObj in packManage.ListPob)
{
packObj.IsSelfFresh = value;
}
}
}
public string DllName
{
get
{
return dllName.Trim();
}
set
{
dllName = value;
}
}
public string NameSpace
{
get
{
return nameSpace.Trim();
}
set
{
nameSpace = value;
}
}
public string InstanceName
{
get
{
return instanceName.Trim();
}
set
{
instanceName = value;
}
}
#endregion
#region
public virtual void MouseMove(ZedGraphControl sender, MouseEventArgs e)
{
}
public virtual void MouseDown(ZedGraphControl sender, MouseEventArgs e)
{
}
public virtual void MouseUp(ZedGraphControl sender, MouseEventArgs e)
{
}
public virtual void MouseDoubleClick(ZedGraphControl sender, MouseEventArgs e)
{
}
public virtual void KeyUp(ZedGraphControl sender, KeyEventArgs e)
{
}
public virtual void zgcAnaesRecord_ContextMenuBuilder(ZedGraphControl sender, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
{
}
/// <summary>
/// 验证数据,正确返回真,如果子类不继承就直接返回真
/// </summary>
/// <returns></returns>
public virtual bool Verification()
{
return true;
}
/// <summary>
/// 把OperationRecord 里的数据绑定到到画板上
/// </summary>
public virtual void Bind()
{
}
public virtual void initChart()
{
}
#endregion
/// <summary>
/// 格式画到板上,没有数据的格式
/// </summary>
public void Draw(bool isNoDrwsBoard = false)
{
if (packManage != null)
{
//先组件自己的刷新关闭
IsSelfFresh = false;
//画的前置方法
PrepositiveMethod();
packManage.DrawPackObj(isNoDrwsBoard);
//画完的后续方法
FollowUpMethod();
//组件自己的刷新打开
IsSelfFresh = true;
}
}
/// <summary>
/// 后续方法
/// </summary>
public virtual void FollowUpMethod()
{
}
/// <summary>
/// 前置方法
/// </summary>
public virtual void PrepositiveMethod()
{
}
public virtual void clearSelectCouve_Click()
{
}
public virtual void frmInstance_ConfigParam()
{
}
/// <summary>
/// 根据标签查找指定的绘图组件
/// </summary>
/// <param name="tagName">标签名,使用类.属性就可以了</param>
/// <returns></returns>
public PackObjBase GetPackObjectOTag(string tagName)
{
PackObjBase pack = null;
if (packManage != null)
{
pack = PackManage.ListPob.FirstOrDefault<PackObjBase>(s => s.PackTag.EndsWith(tagName.Replace('.', '_')));
}
return pack;
}
public List<PackObjBase> GetPackObjeOfParentName(string parentName)
{
List<PackObjBase> subPobs = PackManage.ListPob.FindAll((c) => { return c.ParentName == parentName; });
return subPobs;
}
/// <summary>
/// 保存
/// </summary>
/// <returns></returns>
public bool Save()
{
bool reVal = false;
if (packManage != null)
{
GetFileName();
reVal = packManage.SaveFile(packManagerFileName,Id);
msgStr = packManage.MsgStr;
}
return reVal;
}
/// <summary>
/// 获取文件名
/// </summary>
private void GetFileName()
{
packManagerFileName = this.className + BoardUtil.tagFlag + this.name;
}
public int ParentId { get; set; }
/// <summary>
/// 加载实例
/// </summary>
public bool Load(int parentId)
{
bool reVal = true;
try
{
GetFileName();
ParentId = parentId;
packManage = new PackObjManager(zedControl);
packManage.AllClear();
reVal = packManage.LoadContent(packManagerFileName,ParentId );
packManage.ClassName = className;
msgStr = packManage.MsgStr;
}
catch (Exception exp)
{
msgStr = exp.Message;
reVal = false;
}
return reVal;
}
/// <summary>
/// 设置画板组件,因为在打开区域管理器窗体时,使用自己窗体里的画板组件,但在返回父窗体时要把所有区域画到主窗体里,这里要更改画板组件
/// </summary>
public void SetZedControl(ZedGraphControl _zedControl)
{
if (packManage != null)
{
zedControl = _zedControl;
packManage.SetZedControl(zedControl);
}
}
public bool Equals(AreaManageBase other)
{
if (null == other) return false;
if (ReferenceEquals(this, other)) return true;
return this.Name.Equals(other.Name) && this.ClassName.Equals(other.ClassName);
}
public override int GetHashCode()
{
int hashCode = this.ClassName.GetHashCode() + this.Name.GetHashCode();
return hashCode;
}
/// <summary>
/// 响应可编辑组件的单击事件,由具体区域实现
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public virtual void editAr_Click(object sender, EventArgs e)
{
}
/// <summary>
/// false为打印模式
/// </summary>
/// <param name="isVisible"></param>
public virtual void setPrint(bool isVisible) { }
}
public class PropertyObject
{
public PropertyObject()
{
subPropertyList = new List<PropertyObject>();
parentProperty = null;
}
private string key = "";
private string text = "";
private string value = "";
private string description = "";
private List<PropertyObject> subPropertyList = new List<PropertyObject>();
private PropertyObject parentProperty = null;
public string Key
{
get
{
return key;
}
set
{
key = value;
}
}
/// <summary>
/// 子属性列表
/// </summary>
public List<PropertyObject> SubPropertyList
{
get
{
return subPropertyList;
}
set
{
foreach (PropertyObject obj in value)
{
obj.ParentProperty = this;
}
subPropertyList = value;
}
}
public string Description
{
get
{
return description;
}
set
{
description = value;
}
}
/// <summary>
/// 显示到树组件里的文本
/// </summary>
public string ViewTreeNode
{
get
{
return description + "" + key;
}
}
/// <summary>
/// 显示到设计组件的TAG上
/// </summary>
public string ViewDesignTag()
{
return ((parentProperty != null) ? (parentProperty.ViewDesignTag() + BoardUtil.tagFlag) : "") + key;
}
/// <summary>
/// 父属性对象
/// </summary>
public PropertyObject ParentProperty
{
get
{
return parentProperty;
}
set
{
parentProperty = value;
}
}
/// <summary>
/// 真正用的值
/// </summary>
public string Value
{
get
{
return value;
}
set
{
this.value = value;
}
}
/// <summary>
/// 显示的文本
/// </summary>
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
}
}