483 lines
18 KiB
C#
483 lines
18 KiB
C#
using AIMSBLL;
|
||
using AIMSModel;
|
||
using DrawGraph;
|
||
using HelperDB;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Reflection;
|
||
using System.Windows.Forms;
|
||
|
||
namespace DrawGraphManagement
|
||
{
|
||
public partial class Main : Form
|
||
{
|
||
TemplateManage templateManage = new TemplateManage();
|
||
object operationRecor = new DrawGraph.OperationRecord();
|
||
AreaManageBase areaManageBase = new AreaManageBase();
|
||
|
||
public Main()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void Main_Load(object sender, EventArgs e)
|
||
{
|
||
//Hospitals hospital = BHospitals.GetHospitalsById(BWorkers.SelectSingle(1).DepartmentRef.HospitalId.Value);
|
||
//PublicMethod.hospitals = hospital;
|
||
//PublicMethod.Operator = BWorkers.SelectSingle(1);
|
||
//templateManage.HospitalName = PublicMethod.hospitals.Name;
|
||
myPanel1.MouseWheel += new System.Windows.Forms.MouseEventHandler(panel1_MouseWheel);
|
||
LoadManageList();
|
||
}
|
||
/// <summary>
|
||
/// 加载管理器列表
|
||
/// </summary>
|
||
private void LoadManageList()
|
||
{
|
||
Assembly assembly = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + "DrawGraph.dll");//你的loadfile
|
||
Type baseType = typeof(AreaManageBase);
|
||
List<Type> types = assembly.GetTypes().Where<Type>(t => t.IsSubclassOf(baseType)).ToList<Type>();
|
||
List<Type> viewTypes = types.Where<Type>(s => s.FullName.IndexOf(".document.") < 0).ToList<Type>();
|
||
List<Type> wsTypes = types.Where<Type>(s => s.FullName.IndexOf(".document.") >= 0).ToList<Type>();
|
||
|
||
cmbManageList.Items.Clear();
|
||
foreach (Type t in viewTypes)
|
||
{
|
||
cmbManageList.Items.Add(t.Name);
|
||
}
|
||
cmbManageList.Items.Add("-------------------");
|
||
foreach (Type t in wsTypes)
|
||
{
|
||
cmbManageList.Items.Add(t.Name);
|
||
}
|
||
bindTitle();
|
||
}
|
||
|
||
private void bindTitle()
|
||
{
|
||
//txtProjectName.DataBindings.Clear();
|
||
//txtProjectName.DataBindings.Add("text", templateManage, "ProjectName");
|
||
//txtHospitalName.DataBindings.Clear();
|
||
//txtHospitalName.DataBindings.Add("text", "", "Name");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置界面自适应
|
||
/// </summary>
|
||
private void AutoSizeF()
|
||
{
|
||
#region 设置界面自适应
|
||
if (templateManage.ZedControl == null) return;
|
||
|
||
if (templateManage.Typesetting == TypesettingEnum.Horizontal)
|
||
{
|
||
//在此处可随时设置板子的属性
|
||
templateManage.ZedControl.Height = templateManage.GetPageWidth();
|
||
templateManage.ZedControl.Width = Convert.ToInt32(templateManage.ZedControl.Height * 1.414) + 2;
|
||
}
|
||
else
|
||
{
|
||
//在此处可随时设置板子的属性
|
||
templateManage.ZedControl.Width = templateManage.GetPageWidth();// templateManage.ZedControl.Parent.Width - 54;
|
||
templateManage.ZedControl.Height = Convert.ToInt32(templateManage.ZedControl.Width * 1.414) + 2;
|
||
}
|
||
templateManage.ZedControl.AxisChange();
|
||
templateManage.ZedControl.Refresh();
|
||
//最后还要调整图表进行自适应
|
||
PackObjBase pack = templateManage.GetPackObjectOTag<PackObjBase>("PhysioDataManage_ChartPackObj_6");
|
||
if (pack != null)
|
||
pack.Draw();
|
||
#endregion
|
||
}
|
||
|
||
/// <summary>
|
||
/// 全部刷新
|
||
/// </summary>
|
||
private void AllRefresh()
|
||
{
|
||
treeView1.Nodes.Clear();
|
||
foreach (AreaManageBase area in templateManage.ManageList)
|
||
{
|
||
//把管理器增加到树控件里
|
||
InsertPackObjTree(area);
|
||
List<PackObjBase> ables = area.PackManage.ListPob.Where<PackObjBase>(s => s is AbleEditPackObj).ToList<PackObjBase>();
|
||
foreach (PackObjBase pack in ables)
|
||
{
|
||
AbleEditPackObj ableEdit = pack as AbleEditPackObj;
|
||
if (ableEdit != null) ableEdit.IsVisible = false;
|
||
}
|
||
}
|
||
//画区域
|
||
drawArea();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新建管理器
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btnCreate_Click(object sender, EventArgs e)
|
||
{
|
||
string instanceName = cmbManageList.Text.Trim();
|
||
string name = txtManageName.Text.Trim();
|
||
string projectName = txtProjectName.Text.Trim();
|
||
if (instanceName == "" || name == "" || projectName == "")
|
||
{
|
||
MessageBox.Show("类名称及区域名称或项目名称不能为空!!!");
|
||
return;
|
||
}
|
||
|
||
areaManageBase = BoardFormUtil.AreaManageFactory(instanceName, templateManage.OpeRecord, zedGraphMain, templateManage, name);
|
||
bool isAddOk = templateManage.AddManage(areaManageBase);
|
||
if (isAddOk)
|
||
{
|
||
templateManage.ProjectName = projectName;
|
||
Point point = templateManage.GetBorderPackWH();
|
||
AreaManageForm form = form = new AreaManageForm(areaManageBase, PageStatus.Create, point.X, point.Y);
|
||
form.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AreaManageForm_FormClosed);
|
||
form.Show();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("不能增加重复的管理器名称或管理器类名称");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 插入指定树结点的管理器控件内容
|
||
/// </summary>
|
||
/// <param name="areaManage"></param>
|
||
private void InsertPackObjTree(AreaManageBase areaManage)
|
||
{
|
||
TreeNode tnSub = new TreeNode();
|
||
tnSub.Name = areaManage.Name;
|
||
tnSub.Tag = areaManage;
|
||
tnSub.Text = areaManage.ClassName + "-" + areaManage.Name;
|
||
treeView1.Nodes.Add(tnSub);
|
||
//treeView1.SelectedNode = tnSub;
|
||
TreeNodeMouseClickEventArgs e = new TreeNodeMouseClickEventArgs(tnSub, 0, 0, 0, 0);
|
||
//treeView1_NodeMouseClick(treeView1, e);
|
||
}
|
||
|
||
private void drawArea()
|
||
{
|
||
templateManage.ZedControl = zedGraphMain;
|
||
templateManage.DrawArea();
|
||
}
|
||
|
||
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||
{
|
||
if (e.Button == MouseButtons.Right)
|
||
{
|
||
//选中点击的节点
|
||
treeView1.SelectedNode = e.Node;
|
||
//获取节点区域的右下角坐标值
|
||
Point pos = new Point(e.Node.Bounds.X + e.Node.Bounds.Width, e.Node.Bounds.Y + e.Node.Bounds.Height);
|
||
//在选中的节点的右下角,弹出右键菜单,并设定控制者为treeView
|
||
contextMenuStrip1.Show(treeView1, pos);
|
||
}
|
||
if (e.Button == MouseButtons.Left)
|
||
{
|
||
TreeNode tn = e.Node;
|
||
AreaManageBase area = (AreaManageBase)tn.Tag;
|
||
if (area != null)
|
||
{
|
||
txtAreaX.DataBindings.Clear();
|
||
txtAreaX.DataBindings.Add("text", area.PackManage, "X");
|
||
txtAreaY.DataBindings.Clear();
|
||
txtAreaY.DataBindings.Add("text", area.PackManage, "Y");
|
||
}
|
||
}
|
||
}
|
||
|
||
private void EditAreaMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
TreeNode treeNode = treeView1.SelectedNode;
|
||
AreaManageBase selectAreaManage = treeNode.Tag as AreaManageBase;
|
||
|
||
Point point = templateManage.GetBorderPackWH();
|
||
AreaManageForm form = new AreaManageForm(selectAreaManage, PageStatus.Edit, point.X, point.Y);
|
||
form.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AreaManageForm_FormClosed);
|
||
form.Show();
|
||
}
|
||
private void AreaManageForm_FormClosed(object sender, EventArgs e)
|
||
{
|
||
AreaManageForm form = sender as AreaManageForm;
|
||
if (form != null && form.pageStatus == PageStatus.Create)
|
||
{
|
||
InsertPackObjTree(areaManageBase);
|
||
}
|
||
//画区域
|
||
drawArea();
|
||
|
||
AutoSizeF();
|
||
}
|
||
|
||
private void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
bool reVal = templateManage.Save();
|
||
if (reVal)
|
||
{
|
||
MessageBox.Show("保存成功");
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show(templateManage.MsgStr);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 删除区域
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void ToolStripMenuItem2_Click(object sender, EventArgs e)
|
||
{
|
||
DialogResult result = MessageBox.Show("确认要删除所有内容吗", "删除", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||
if (result == DialogResult.Yes)
|
||
{
|
||
TreeNode node = treeView1.SelectedNode;
|
||
if (node != null)
|
||
{
|
||
AreaManageBase area = node.Tag as AreaManageBase;
|
||
if (area != null)
|
||
{
|
||
templateManage.DelManage(area);
|
||
treeView1.Nodes.Remove(node);
|
||
//画区域
|
||
drawArea();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private bool zedGraphMain_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
if (templateManage != null)
|
||
{
|
||
templateManage.zedControl_MouseDownEvent(sender, e);
|
||
}
|
||
return default(bool);
|
||
}
|
||
|
||
private bool zedGraphMain_MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
if (templateManage != null)
|
||
{
|
||
templateManage.zedControl_MouseMoveEvent(sender, e);
|
||
}
|
||
return default(bool);
|
||
}
|
||
|
||
private bool zedGraphMain_MouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
if (templateManage != null)
|
||
{
|
||
templateManage.zedControl_MouseUpEvent(sender, e);
|
||
}
|
||
return default(bool);
|
||
}
|
||
|
||
private void zedGraphMain_MouseDoubleClick(object sender, MouseEventArgs e)
|
||
{
|
||
if (templateManage != null)
|
||
{
|
||
ZedGraphControl send = sender as ZedGraphControl;
|
||
templateManage.zedControl_MouseDoubleClick(send, e);
|
||
}
|
||
}
|
||
|
||
private void zedGraphMain_KeyUp(object sender, KeyEventArgs e)
|
||
{
|
||
if (templateManage != null)
|
||
{
|
||
ZedGraphControl send = sender as ZedGraphControl;
|
||
templateManage.zedControl_KeyUp(send, e);
|
||
}
|
||
}
|
||
|
||
private void BtnBind_Click(object sender, EventArgs e)
|
||
{
|
||
#region 绑定所有手术记录的值
|
||
int id = 14;
|
||
if (textBox1.Text != "") id = int.Parse(textBox1.Text);
|
||
//operationRecor = BOperationRecord.SelectSingle(id, RecursiveType.Parent, 3);
|
||
templateManage.OpeRecord = operationRecor;
|
||
|
||
//指定对象的所有值属性的绑定
|
||
templateManage.BindOperationRecordValueAll(templateManage.OpeRecord);
|
||
//非值对象的数据绑定
|
||
templateManage.Bind();
|
||
#endregion
|
||
|
||
#region 单独赋值绑定
|
||
//设置对象属性的值,单独属性付值
|
||
//EntityObjectChangeNotifier.SetValue(templateManage.OpeRecord, "OperationRecord .MZQYY", "麻醉前用药文本", "麻醉前用药值");
|
||
//EntityObjectChangeNotifier.SetValue(templateManage.OpeRecord, "PatientRef.Bed", "12", "12值");
|
||
//EntityObjectChangeNotifier<OperationRecord>.SetValue(operationRecor, "OperationSiteId", "体位1", "TY1");
|
||
//EntityObjectChangeNotifier<OperationRecord>.SetValue(operationRecor, "InRoomTime", "2020-08-20 16:09");
|
||
//EntityObjectChangeNotifier<OperationRecord>.SetValue(operationRecor, "OperationApplyRef.ApplyDepartmentRef.HospitalName", "dep234");
|
||
#endregion
|
||
//templateManage.NotificationAreaBindingUpdate("备注区域").NotificationAreaBindingUpdate("监测区域");
|
||
zedGraphMain.Refresh();
|
||
}
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
this.Close();
|
||
this.Close();
|
||
}
|
||
catch (Exception )
|
||
{
|
||
}
|
||
}
|
||
private void panel1_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
|
||
{
|
||
templateManage.SetPYL();
|
||
}
|
||
private void myPanel1_Scroll(object sender, ScrollEventArgs e)
|
||
{
|
||
templateManage.SetPYL();
|
||
}
|
||
|
||
private void button1_Click_1(object sender, EventArgs e)
|
||
{
|
||
if (templateManage != null && templateManage.ManageList.Count > 0)
|
||
{
|
||
int OperationApplyId = 10;
|
||
if (textBox1.Text.Trim() != "") OperationApplyId = int.Parse(textBox1.Text.Trim());
|
||
DocumentParent documentParent = new DocumentParent();
|
||
documentParent.OperationApplyId = OperationApplyId;
|
||
//documentParent.OpeRecord = BOperationRecord.SelectSingle("OperationApplyId=@OperationApplyId", new ParameterList("@OperationApplyId", OperationApplyId), RecursiveType.Parent, 3);
|
||
|
||
if (templateManage.OpeRecord == null) return;
|
||
//指定对象的所有值属性的绑定
|
||
templateManage.BindOperationRecordValueAll(templateManage.OpeRecord);
|
||
templateManage.SetPYL(); //得设置一下偏移量
|
||
//非值对象的数据绑定
|
||
templateManage.Bind();
|
||
}
|
||
}
|
||
|
||
private void button3_Click(object sender, EventArgs e)
|
||
{
|
||
string txtFont = txtFontSize.Text.Trim();
|
||
foreach (AreaManageBase manage in templateManage.ManageList) {
|
||
List<PackObjBase> ables = manage.PackManage.ListPob.Where<PackObjBase>(s => s is AbleEditPackObj).ToList<PackObjBase>();
|
||
foreach (PackObjBase pack in ables)
|
||
{
|
||
AbleEditPackObj ableEdit = pack as AbleEditPackObj;
|
||
ableEdit.EditFontSize = int.Parse(txtFont);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void button4_Click(object sender, EventArgs e)
|
||
{
|
||
templateManage.BindDefaultValue();
|
||
}
|
||
|
||
private void button5_Click(object sender, EventArgs e)
|
||
{
|
||
templateManage.ClearEdit();
|
||
}
|
||
|
||
private void cmbTypesetting_SelectedValueChanged(object sender, EventArgs e)
|
||
{
|
||
if (templateManage != null) {
|
||
string typeset = cmbTypesetting.Text;
|
||
if (typeset == "横向")
|
||
{
|
||
templateManage.Typesetting = TypesettingEnum.Horizontal;
|
||
}
|
||
else
|
||
{
|
||
templateManage.Typesetting = TypesettingEnum.Vertical;
|
||
}
|
||
AutoSizeF();
|
||
}
|
||
}
|
||
|
||
private void cmbPageType_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
if (templateManage != null)
|
||
{
|
||
string pageType = cmbPageType.Text;
|
||
if (pageType == "A4")
|
||
{
|
||
templateManage.PageType = PageTypeEnum.A4;
|
||
}
|
||
else
|
||
{
|
||
templateManage.PageType = PageTypeEnum.A3;
|
||
}
|
||
AutoSizeF();
|
||
}
|
||
}
|
||
|
||
private void button2_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
if (templateManage != null)
|
||
{
|
||
templateManage.ControlClear();
|
||
}
|
||
|
||
try
|
||
{
|
||
|
||
string jsonStr = DBHelper.ExecuteScalar("SELECT [JsonDate] FROM [dbo].[OperationRecordTemplate] where id=1").ToString();
|
||
if (jsonStr != null && jsonStr != "")
|
||
{
|
||
templateManage = JsonConvert.DeserializeObject<TemplateManage>(jsonStr);
|
||
templateManage.ZedControl = zedGraphMain;
|
||
templateManage.OpeRecord = operationRecor;
|
||
templateManage.Id = 1;
|
||
bool reVal = templateManage.Load();
|
||
if (reVal)
|
||
{
|
||
AllRefresh();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show(templateManage.MsgStr);
|
||
}
|
||
#region 测试
|
||
|
||
AutoSizeF();
|
||
#endregion
|
||
}
|
||
bindTitle();
|
||
|
||
//设置排版值
|
||
if (templateManage.Typesetting == TypesettingEnum.Vertical)
|
||
{
|
||
cmbTypesetting.Text = "竖向";
|
||
}
|
||
else
|
||
{
|
||
cmbTypesetting.Text = "横向";
|
||
}
|
||
//设置纸张类型
|
||
if (templateManage.PageType == PageTypeEnum.A4)
|
||
{
|
||
cmbPageType.Text = "A4";
|
||
}
|
||
else
|
||
{
|
||
cmbPageType.Text = "A3";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show(ex.Message);
|
||
}
|
||
}
|
||
}
|
||
}
|