using Newtonsoft.Json; using AIMSExtension; using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using DevComponents.DotNetBar.Controls; namespace DrawGraph { [Serializable, JsonObject(MemberSerialization.OptOut)] public class BaseInfoBottomManage : AreaManageBase { private OperationRecord myOpeRecord = null; public BaseInfoBottomManage() { } public BaseInfoBottomManage(object _operationRecor, ZedGraphControl _zedControl, TemplateManage _template, string _name) : base(_operationRecor, _zedControl, _template, _name) { init(); } public void init() { //自己要用的手术对象 myOpeRecord = OpeRecord as OperationRecord; } #region 重写的事件 /// /// 鼠标点击画板 /// /// /// 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) { } public SelectWorkerValue aSyncSelectDict = null; public override void Bind() { init(); aSyncSelectDict = SelectWorkerValue.CreateInstance(); List ables = PackManage.ListPob.Where(s => s is AbleEditPackObj).ToList(); foreach (PackObjBase pack in ables) { AbleEditPackObj ableEdit = pack as AbleEditPackObj; SetAbleEditView(ableEdit); } } /// /// 设置可编辑组件的显示样式 /// /// private void SetAbleEditView(AbleEditPackObj ableEdit) { string span = ""; double spanSum = Math.Round((float)(ableEdit.OneUnitCount / 12)); for (int i = 0; i < spanSum; i++) { span += " "; } string text = "", value = ""; if (ableEdit != null) { switch (ableEdit.ControlType) { case EControlType.Directory: value = ableEdit.PackValue; text = DBManage.GetDictionaryValuesById(ableEdit.PackValue, ableEdit.ControlTitleText); //设置属性的值 template.SetObjValue(OpeRecord, ableEdit.ClassDataSourceName, text, value); break; case EControlType.Directorys: value = ableEdit.PackValue; text = DBManage.GetDictionaryValuesById(ableEdit.PackValue, ableEdit.ControlTitleText); //设置属性的值 template.SetObjValue(OpeRecord, ableEdit.ClassDataSourceName, text, value); break; default: break; } } } #endregion 重写的事件结束 /// /// 响应可编辑区域的点击事件 /// /// /// 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; } } SelectWorkerValue.Hidden(); //这句话很重要,只操作自己管理器里的组件 AbleEditPackObj aEdit1 = PackManage.ListPob.FirstOrDefault(s => s.PackTag == aEdit1S.PackTag) as AbleEditPackObj; //指定的组件显示 if (aEdit1 != null) { Control conl = aEdit1.CControl; conl.Leave -= new EventHandler(txt_Leave); aEdit1.IsVisible = !aEdit1.IsVisible; aEdit1S.CControl.MouseDown -= new MouseEventHandler(CControl_MouseDown); aEdit1S.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp); aEdit1S.CControl.TextChanged -= new EventHandler(CControl_TextChanged); aEdit1S.CControl.KeyPress -= new KeyPressEventHandler(CControl_KeyPress); ; //根据数据源名称进行不同的事件处理 switch (aEdit1.ClassDataSourceName) { case "OperationRecord.AnesthesiaDoctor": //麻醉医生 Worker_Click(aEdit1, e, 2); break; case "OperationRecord.OperationDoctor": Worker_Click(aEdit1, e, 0); break; case "OperationRecord.InstrumentNurse": Worker_Click(aEdit1, e, 3); break; case "OperationRecord.Assistant1": Worker_Click(aEdit1, e, 0); break; case "OperationRecord.AnaesthesiaMethodName": Anaes_Click(aEdit1, e); break; case "OperationRecord.OperationSiteId": //手术体位 TYZD_Click(aEdit1, e); break; case "OperationRecord.OperationPositionId": //手术体位 TYZD_Click(aEdit1, e); break; case "OperationRecord.TourNurse": Worker_Click(aEdit1, e, 3); break; case "OperationRecord.Operation": //手术名称 ope_Click(aEdit1, e); break; case "OperationRecord.Diagnose": //手术名称 opeDisease_Click(aEdit1, e); break; case "OperationRecord.OrtherDoctorId": Worker_Click(aEdit1, e, 4); break; case "OperationRecord.OpeRecoverOutInfo.Extend1": ((TextBox)conl).BorderStyle = BorderStyle.Fixed3D; ((TextBox)conl).Focus(); ((TextBox)conl).Select(((TextBox)conl).Text.Length, 1); conl.Leave += new EventHandler(txt_Leave); break; case "OperationRecord.OpeRecoverOutInfo.Extend2": ((TextBox)conl).BorderStyle = BorderStyle.Fixed3D; ((TextBox)conl).Focus(); ((TextBox)conl).Select(((TextBox)conl).Text.Length, 1); conl.Leave += new EventHandler(txt_Leave); break; //default: // //在此处写日志 // aEdit1.IsVisible = !aEdit1.IsVisible; // MessageBox.Show("没找到-" + aEdit1.ClassDataSourceName + "-属性的事件"); // break; } } } catch (Exception exp) { MessageBox.Show(exp.Message); } finally { } } 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; bool updateOk = true; string text = ""; string value = ""; if (!updateOk) { if (ableEdit.ControlType == EControlType.RadioButtonList) ableEdit.IsVisible = true; else ableEdit.IsVisible = !ableEdit.IsVisible; } else { text = control.Text.Trim(); value = control.Text.Trim(); //设置属性的值 ableEdit.IsVisible = !ableEdit.IsVisible; template.SetObjValue(OpeRecord, DataSourceName, text, value, true); ((TextBox)control).BorderStyle = BorderStyle.None; } } catch (Exception ex) { //写日志 PublicMethod.WriteLog(ex); } finally { } } #region 可编辑区域响应事件 private void Worker_Click(AbleEditPackObj sender, EventArgs e, int _workersType) { try { AbleEditPackObj ableEdit = sender; if (ableEdit == null) return; if (myOpeRecord == null) return; if (ableEdit.ControlType == EControlType.Directory) { ableEdit.CControl.MouseDown -= new MouseEventHandler(CControl_MouseDown); ableEdit.CControl.MouseDown += new MouseEventHandler(CControl_MouseDown); ableEdit.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp); ableEdit.CControl.KeyUp += new KeyEventHandler(CControl_KeyUp); ableEdit.CControl.KeyPress -= new KeyPressEventHandler(CControl_KeyPress); ableEdit.CControl.KeyPress += new KeyPressEventHandler(CControl_KeyPress); SelectWorkerValue.ChageText = ""; if (myOpeRecord != null) { Control conl = sender.CControl; if (conl is TextBox) { ((TextBox)conl).BorderStyle = BorderStyle.Fixed3D; ((TextBox)conl).Focus(); if (sender.PackValue != null && sender.PackValue.Trim() != "") { if (((TextBox)conl).Text.LastIndexOf(',') != sender.PackText.Length) ((TextBox)conl).Text = ((TextBox)conl).Text + ","; ((TextBox)conl).Select(((TextBox)conl).Text.Length, 1); } } ableEdit.CControl.TextChanged -= new EventHandler(CControl_TextChanged); ableEdit.CControl.TextChanged += new EventHandler(CControl_TextChanged); aSyncSelectDict.Show(template, OpeRecord, sender, _workersType.ToString()); } } else if (ableEdit.ControlType == EControlType.Directorys) { SetDirectorysMethod(ableEdit); } } catch (Exception ex) { AIMSExtension.PublicMethod.WriteLog(ex); } } private void CControl_TextChanged(object sender, EventArgs e) { if (myOpeRecord != null) { Control conl = sender as Control; aSyncSelectDict.ShowSel(conl, OpeRecord); } } private void CControl_KeyUp(object sender, KeyEventArgs e) { if (myOpeRecord != null) { Control conl = sender as Control; if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back) { if (conl.Text != SelectWorkerValue.Value && SelectWorkerValue.ChageText == "") { aSyncSelectDict.DelSel(conl, OpeRecord); SelectDictValue.ChageText = ""; } } else if (e.KeyCode == Keys.Down) { if (SelectWorkerValue.dgvZd.CurrentRow.Index + 1 != SelectWorkerValue.dgvZd.Rows.Count - 1) { SelectWorkerValue.dgvZd.CurrentCell = SelectWorkerValue.dgvZd.Rows[SelectWorkerValue.dgvZd.CurrentRow.Index + 1].Cells[1]; } } else if (e.KeyCode == Keys.Up) { if (SelectWorkerValue.dgvZd.CurrentRow.Index != 0) { SelectWorkerValue.dgvZd.CurrentCell = SelectWorkerValue.dgvZd.Rows[SelectWorkerValue.dgvZd.CurrentRow.Index - 1].Cells[1]; } } } } private void CControl_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar.ToString() == "\r") { if (SelectWorkerValue.dgvZd.SelectedRows.Count > 0) { SelectWorkerValue.SetContent(SelectWorkerValue.dgvZd.SelectedRows[0].Index); } } } private void CControl_MouseDown(object sender, MouseEventArgs e) { if (myOpeRecord != null) { TextBox conl = sender as TextBox; string leftStr = conl.Text.Substring(0, conl.SelectionStart); string rightStr = conl.Text.Substring(conl.SelectionStart, conl.Text.Length - conl.SelectionStart); int startIndex = 0; int endLength = conl.Text.Length; if (leftStr.Contains(",")) { int beginindex = leftStr.LastIndexOf(','); startIndex = beginindex + 1; if (rightStr.Contains(",")) { endLength = rightStr.IndexOf(",") + (leftStr.Length - beginindex); } } else if (leftStr.Contains("+")) { int beginindex = leftStr.LastIndexOf('+'); startIndex = beginindex + 1; if (rightStr.Contains("+")) { endLength = rightStr.IndexOf("+") + (leftStr.Length - beginindex); } } else { if (rightStr.Contains(",")) { endLength = rightStr.IndexOf(",") + leftStr.Length + 1; } else if (rightStr.Contains("+")) { endLength = rightStr.IndexOf("+") + leftStr.Length + 1; } } conl.Select(startIndex, endLength); } } private void ope_Click(AbleEditPackObj sender, EventArgs e) { try { AbleEditPackObj ableEdit = sender; if (ableEdit == null) return; if (myOpeRecord == null) return; if (ableEdit.ControlType == EControlType.Directory) { SelDict(sender, e, ableEdit.ControlTitleText); } else if (ableEdit.ControlType == EControlType.Directorys) { SetDirectorysMethod(ableEdit); } } catch (Exception ex) { AIMSExtension.PublicMethod.WriteLog(ex); } } private void opeDisease_Click(AbleEditPackObj sender, EventArgs e) { try { AbleEditPackObj ableEdit = sender; if (ableEdit == null) return; if (myOpeRecord == null) return; if (ableEdit.ControlType == EControlType.Directory) { SelDict(sender, e, ableEdit.ControlTitleText); } else if (ableEdit.ControlType == EControlType.Directorys) { SetDirectorysMethod(ableEdit); } } catch (Exception ex) { AIMSExtension.PublicMethod.WriteLog(ex); } } private void Anaes_Click(AbleEditPackObj sender, EventArgs e) { try { AbleEditPackObj ableEdit = sender; if (ableEdit == null) return; if (myOpeRecord == null) return; if (ableEdit.ControlType == EControlType.Directory) { SelDict(sender, e, ableEdit.ControlTitleText); } else if (ableEdit.ControlType == EControlType.Directorys) { SetDirectorysMethod(ableEdit); } } catch (Exception ex) { AIMSExtension.PublicMethod.WriteLog(ex); } } //通用字典分组窗体打开 private void TYZD_Click(AbleEditPackObj sender, EventArgs e, bool isRadio = false) { try { AbleEditPackObj ableEdit = sender; if (ableEdit == null) return; if (myOpeRecord == null) return; if (ableEdit.ControlType == EControlType.Directory) { SelDict(sender, e, ableEdit.ControlTitleText); } else if (ableEdit.ControlType == EControlType.Directorys) { SetDirectorysMethod(ableEdit); } } catch (Exception ex) { AIMSExtension.PublicMethod.WriteLog(ex); } } private void SelDict(AbleEditPackObj sender, EventArgs e, string _DictType) { AbleEditPackObj ableEdit = sender; if (ableEdit == null) return; ableEdit.CControl.MouseDown -= new MouseEventHandler(CControl_MouseDown); ableEdit.CControl.MouseDown += new MouseEventHandler(CControl_MouseDown); ableEdit.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp); ableEdit.CControl.KeyUp += new KeyEventHandler(CControl_KeyUp); ableEdit.CControl.KeyPress -= new KeyPressEventHandler(CControl_KeyPress); ableEdit.CControl.KeyPress += new KeyPressEventHandler(CControl_KeyPress); if (myOpeRecord != null) { Control conl = sender.CControl; if (conl is TextBox) { ((TextBox)conl).BorderStyle = BorderStyle.Fixed3D; ((TextBox)conl).Focus(); if (sender.PackValue != null && sender.PackValue.Trim() != "") { if (ableEdit.ClassDataSourceName == "OperationRecord.AnaesthesiaMethodName") { if (((TextBox)conl).Text.LastIndexOf('+') != sender.PackText.Length) ((TextBox)conl).Text = ((TextBox)conl).Text + "+"; ((TextBox)conl).Select(((TextBox)conl).Text.Length, 1); } else { if (((TextBox)conl).Text.LastIndexOf(',') != sender.PackText.Length) ((TextBox)conl).Text = ((TextBox)conl).Text + ","; ((TextBox)conl).Select(((TextBox)conl).Text.Length, 1); } } } ableEdit.CControl.TextChanged -= new EventHandler(CControl_TextChanged); ableEdit.CControl.TextChanged += new EventHandler(CControl_TextChanged); aSyncSelectDict.Show(template, OpeRecord, sender, _DictType); } } #endregion private void SetDirectorysMethod(AbleEditPackObj ableEdit) { DevComponents.DotNetBar.Controls.TokenEditor tokenEditor = ableEdit.CControl as DevComponents.DotNetBar.Controls.TokenEditor; tokenEditor.EditTextBox.DoubleClick -= EditTextBox_DoubleClick; tokenEditor.EditTextBox.DoubleClick += EditTextBox_DoubleClick; tokenEditor.EditTextBox.TextChanged -= EditTextBox_TextChanged; tokenEditor.EditTextBox.TextChanged += EditTextBox_TextChanged; tokenEditor.Leave -= TokenEditor_Leave; tokenEditor.Leave += TokenEditor_Leave; if (ableEdit.ControlTitleText == "手术" || ableEdit.ControlTitleText == "诊断") { tokenEditor.ValidateToken -= new DevComponents.DotNetBar.Controls.ValidateTokenEventHandler(this.tokenEditor_ValidateToken); tokenEditor.ValidateToken += new DevComponents.DotNetBar.Controls.ValidateTokenEventHandler(this.tokenEditor_ValidateToken); } EditTextBox_DoubleClick(tokenEditor.EditTextBox, null); tokenEditor.EditTextBox.Select(); } private void EditTextBox_DoubleClick(object sender, EventArgs e) { TextBox txt = sender as TextBox; TokenEditorManage.SelectDictList(OpeRecord as OperationRecord, txt); } private void EditTextBox_TextChanged(object sender, EventArgs e) { TextBox txt = sender as TextBox; TokenEditorManage.SelectDictList(OpeRecord as OperationRecord, txt); } private void tokenEditor_ValidateToken(object sender, DevComponents.DotNetBar.Controls.ValidateTokenEventArgs ea) { DevComponents.DotNetBar.Controls.TokenEditor tokenEditor = sender as DevComponents.DotNetBar.Controls.TokenEditor; AbleEditPackObj aEdit = tokenEditor.Tag as AbleEditPackObj; if (ea.IsNewToken) { tokenEditor.EditTextBox.TextChanged -= EditTextBox_TextChanged; string id = TokenEditorManage.GetOperationItemId(ea.Token.Value, aEdit); tokenEditor.SelectedTokens.Add(new EditToken(id, ea.Token.Value)); ea.Token = null; tokenEditor.EditTextBox.Text = ""; tokenEditor.IsPopupOpen = false; tokenEditor.EditTextBox.TextChanged += EditTextBox_TextChanged; } } private void TokenEditor_Leave(object sender, EventArgs e) { DevComponents.DotNetBar.Controls.TokenEditor tokenEditor = sender as DevComponents.DotNetBar.Controls.TokenEditor; AbleEditPackObj aEdit = tokenEditor.Tag as AbleEditPackObj; TokenEditorManage.SaveDictItem(template, OpeRecord as OperationRecord, tokenEditor, aEdit, true); } } }