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)]
///
/// 区域管理类的基础类
///
public class AreaManageBase : IEquatable
{
///
/// 当前手术状态
///
public DoAnesOpeStatus AnesOpeStatue = DoAnesOpeStatus.VIEW;
///
/// 生理数据的时间间隔
///
public int collectInterval = 5;
///
/// 分页绘图的页时间间隔,以分钟为单位
///
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 = "";
public delegate void MouseWheelHandler(object sender, MouseEventArgs e);
public event MouseWheelHandler MouseWheelParam;
[JsonIgnore]
[XmlIgnore]
///
/// 手术记录
///
public object OpeRecord
{
get { return opeRecord; }
set { opeRecord = value; }
}
[JsonIgnore]
[XmlIgnore]
///
/// 画板组件包管理器
///
public PackObjManager PackManage
{
get { return packManage; }
set { packManage = value; }
}
[JsonIgnore]
[XmlIgnore]
///
/// 消息内容
///
public string MsgStr
{
get
{
return msgStr;
}
set
{
msgStr = value;
}
}
[JsonIgnore]
[XmlIgnore]
///
/// 画板的组件
///
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;
}
}
///
/// 画板组件包管理器原件
///
public string PackManagerFileName
{
get
{
return packManagerFileName;
}
set
{
packManagerFileName = value;
}
}
///
/// 区域管理器中文名称
///
public string Name
{
get
{
return name;
}
set
{
name = value;
if (packManage != null)
{
packManage.Name = name;
}
}
}
///
/// 类名称
///
public string ClassName
{
get
{
return className;
}
set
{
className = value;
if (packManage != null)
{
packManage.ClassName = className;
}
}
}
///
/// 仅自己改动时可以刷新
///
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 bool Verification()
{
return true;
}
//取消滚轮事件
public void numericUpDown1_MouseWheel(object sender, MouseEventArgs e)
{
try
{
if (MouseWheelParam != null)
MouseWheelParam(sender, e);
}
catch (Exception)
{
}
}
///
/// 把OperationRecord 里的数据绑定到到画板上
///
public virtual void Bind()
{
}
public virtual void initChart()
{
}
public virtual void BindTempData()
{
}
#endregion
///
/// 格式画到板上,没有数据的格式
///
public void Draw(bool isNoDrwsBoard = false)
{
if (packManage != null)
{
//先组件自己的刷新关闭
IsSelfFresh = false;
//画的前置方法
PrepositiveMethod();
packManage.DrawPackObj(isNoDrwsBoard);
//画完的后续方法
FollowUpMethod();
//组件自己的刷新打开
IsSelfFresh = true;
}
}
///
/// 后续方法
///
public virtual void FollowUpMethod()
{
}
///
/// 前置方法
///
public virtual void PrepositiveMethod()
{
}
public virtual void clearSelectCouve_Click()
{
}
public virtual void frmInstance_ConfigParam()
{
}
///
/// 根据标签查找指定的绘图组件
///
/// 标签名,使用类.属性就可以了
///
public PackObjBase GetPackObjectOTag(string tagName)
{
PackObjBase pack = null;
if (packManage != null)
{
pack = PackManage.ListPob.FirstOrDefault(s => s.PackTag.EndsWith(tagName.Replace('.', '_')));
}
return pack;
}
public List GetPackObjeOfParentName(string parentName)
{
List subPobs = PackManage.ListPob.FindAll((c) => { return c.ParentName == parentName; });
return subPobs;
}
///
/// 保存
///
///
public bool Save()
{
bool reVal = false;
if (packManage != null)
{
GetFileName();
reVal = packManage.SaveFile(packManagerFileName, Id);
msgStr = packManage.MsgStr;
}
return reVal;
}
///
/// 获取文件名
///
private void GetFileName()
{
packManagerFileName = this.className + BoardUtil.tagFlag + this.name;
}
public int ParentId { get; set; }
///
/// 加载实例
///
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;
}
///
/// 设置画板组件,因为在打开区域管理器窗体时,使用自己窗体里的画板组件,但在返回父窗体时要把所有区域画到主窗体里,这里要更改画板组件
///
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;
}
///
/// 响应可编辑组件的单击事件,由具体区域实现
///
///
///
public virtual void editAr_Click(object sender, EventArgs e)
{
}
///
/// false为打印模式
///
///
public virtual void setPrint(bool isVisible) { }
}
public class PropertyObject
{
public PropertyObject()
{
subPropertyList = new List();
parentProperty = null;
}
private string key = "";
private string text = "";
private string value = "";
private string description = "";
private List subPropertyList = new List();
private PropertyObject parentProperty = null;
public string Key
{
get
{
return key;
}
set
{
key = value;
}
}
///
/// 子属性列表
///
public List SubPropertyList
{
get
{
return subPropertyList;
}
set
{
foreach (PropertyObject obj in value)
{
obj.ParentProperty = this;
}
subPropertyList = value;
}
}
public string Description
{
get
{
return description;
}
set
{
description = value;
}
}
///
/// 显示到树组件里的文本
///
public string ViewTreeNode
{
get
{
return description + ":" + key;
}
}
///
/// 显示到设计组件的TAG上
///
public string ViewDesignTag()
{
return ((parentProperty != null) ? (parentProperty.ViewDesignTag() + BoardUtil.tagFlag) : "") + key;
}
///
/// 父属性对象
///
public PropertyObject ParentProperty
{
get
{
return parentProperty;
}
set
{
parentProperty = value;
}
}
///
/// 真正用的值
///
public string Value
{
get
{
return value;
}
set
{
this.value = value;
}
}
///
/// 显示的文本
///
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
}
}