253 lines
		
	
	
		
			8.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			253 lines
		
	
	
		
			8.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| 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 RemarkManage : AreaManageBase
 | ||
|     {
 | ||
|         public RectangleFramePackObj remarkPpack;
 | ||
|         public LinePackObj H3pack;
 | ||
|         public LinePackObj H4pack;
 | ||
|         public LinePackObj H5pack;
 | ||
|         public LinePackObj H6pack;
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 当前手术对象
 | ||
|         /// </summary>
 | ||
|         private OperationRecord myOpeRecord = null;
 | ||
| 
 | ||
|         #region 初始化备注区域
 | ||
|         public RemarkManage() { }
 | ||
|         public RemarkManage(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()
 | ||
|         {
 | ||
|             H3pack = template.GetPackObjectOTag<LinePackObj>("RemarkManage_LinePackObj_4");
 | ||
|             H4pack = template.GetPackObjectOTag<LinePackObj>("RemarkManage_LinePackObj_5");
 | ||
|             H5pack = template.GetPackObjectOTag<LinePackObj>("RemarkManage_LinePackObj_8");
 | ||
|             H6pack = template.GetPackObjectOTag<LinePackObj>("RemarkManage_LinePackObj_9");
 | ||
|             remarkPpack = template.GetPackObjectOTag<RectangleFramePackObj>("RemarkManage_RectangleFramePackObj_2");
 | ||
|         }
 | ||
|         #endregion
 | ||
| 
 | ||
|         #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();
 | ||
|             //DrawRemarkDate();
 | ||
|         }
 | ||
| 
 | ||
|         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;
 | ||
|         }
 | ||
| 
 | ||
|         /// <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="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         public override void editAr_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 //传过来的数据是不是可编辑的
 | ||
|                 AbleEditPackObj aEdit1S = sender as AbleEditPackObj;
 | ||
|                 if (aEdit1S == null) return;
 | ||
| 
 | ||
|                 //先把所有WINFORM组件隐藏
 | ||
|                 foreach (PackObjBase pack in PackManage.ListPob)
 | ||
|                 {
 | ||
|                     AbleEditPackObj aEdit = pack as AbleEditPackObj;
 | ||
|                     if (aEdit != null)
 | ||
|                     {
 | ||
|                         aEdit.IsVisible = false;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 //这句话很重要,只操作自己管理器里的组件
 | ||
|                 AbleEditPackObj aEdit1 = PackManage.ListPob.FirstOrDefault<PackObjBase>(s => s.PackTag == aEdit1S.PackTag) as AbleEditPackObj;
 | ||
|                 //指定的组件显示
 | ||
|                 if (aEdit1 != null)
 | ||
|                 {
 | ||
|                     aEdit1.IsVisible = !aEdit1.IsVisible;
 | ||
|                     Control conl = aEdit1.CControl;
 | ||
|                     conl.Leave -= new EventHandler(txt_Leave);
 | ||
|                     conl.DoubleClick -= Conl_DoubleClick;
 | ||
|                     //根据数据源名称进行不同的事件处理
 | ||
|                     switch (aEdit1.ClassDataSourceName)
 | ||
|                     {
 | ||
|                         case "OperationRecord.Remark": //特殊情况
 | ||
|                             //TYZD_Click(aEdit1, e);
 | ||
|                             conl.Leave += new EventHandler(txt_Leave);
 | ||
|                             conl.DoubleClick += Conl_DoubleClick;
 | ||
|                             break;
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (Exception exp)
 | ||
|             {
 | ||
|                 MessageBox.Show(exp.Message);
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void Conl_DoubleClick(object sender, EventArgs e)
 | ||
|         {
 | ||
|             //frmSelectDictionary fsd = new frmSelectDictionary();
 | ||
|             //fsd._control = sender as TextBox;
 | ||
|             //fsd._dictionaryName = "特殊情况";
 | ||
|             //fsd.isRadio = false;
 | ||
|             //fsd.isShowText = true;
 | ||
|             //fsd.ShowDialog();
 | ||
|         }
 | ||
|         private void txt_Leave(object sender, EventArgs e)
 | ||
|         {
 | ||
|             Control control = (Control)sender;
 | ||
|             if (control == null) return;
 | ||
|             AbleEditPackObj ableEdit = control.Tag as AbleEditPackObj;
 | ||
|             if (ableEdit == null) return;
 | ||
|             try
 | ||
|             {
 | ||
|                 string DataSourceName = ableEdit.ClassDataSourceName;
 | ||
|                 Console.WriteLine(DataSourceName);
 | ||
|                 //拿到数据源(格式:OperationRecord.PatientRef.Bed)
 | ||
|                 bool updateOk = true;
 | ||
| 
 | ||
|                 string text = control.Text.Trim();
 | ||
|                 string value = control.Text.Trim();
 | ||
|                 if (!updateOk)
 | ||
|                 {
 | ||
|                     ableEdit.IsVisible = !ableEdit.IsVisible;
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     //设置属性的值
 | ||
|                     ableEdit.IsVisible = !ableEdit.IsVisible;
 | ||
|                     template.SetObjValue(OpeRecord, DataSourceName, text, value, true);
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|             }
 | ||
|         }
 | ||
|     }
 | ||
| }
 |