using AIMSExtension; using DevComponents.DotNetBar; using DevComponents.DotNetBar.Controls; using DevComponents.Editors; using DevComponents.Editors.DateTimeAdv; using DrawGraph; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Configuration; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Windows.Forms; namespace DrawGraph { [JsonObject(MemberSerialization.OptOut)] [Serializable] public class AbleEditPackObj : TextPackObj { public delegate void ClickEventHandler(object sender, EventArgs e); private Control control = null; private bool isVisible = false; //private int realUnit = 0; private int oneUnitCount = 36; private int editOneUnitCount = 36; private EIsBool dfArrangement = EIsBool.False; private float editFontSize = 12f; private bool isDoubleClick = false; private EControlType controlType = EControlType.TextBox; private EValidType validType = 0; private int textLength = 0; private EIsBool isDateNull = EIsBool.False; private Image pickImage = null; [method: CompilerGenerated] //[DebuggerBrowsable(DebuggerBrowsableState.Never), CompilerGenerated] public event AbleEditPackObj.ClickEventHandler Click; [ClassAttributs(CName = "显示控件", Description = "是否显示控件,TRUE显示"), NoCreatControlAttributs] public bool IsVisible { get { return this.isVisible; } set { this.isVisible = value; bool flag = this.control != null; if (flag) { this.control.Visible = this.isVisible; bool flag2 = this.IsVisible; if (flag2) { bool flag3 = this.ControlType == EControlType.RadioButtonList || this.ControlType == EControlType.CheckBox; if (flag3) { int dfHzjpyl = base.DfHzjpyl; } int num = Convert.ToInt32((float)this.baseZed.Width * base.RealX) + base.Hzjpyl; int y = Convert.ToInt32((float)this.baseZed.Height * base.RealY) - base.Zjpyl; bool flag4 = base.AlignType == EAlignType.Center; if (flag4) { num -= this.CControl.Width / 2; } this.control.Location = new Point(num, y); } } } } [NoCreatControlAttributs, JsonIgnore] public Control CControl { get { return this.control; } set { this.control = value; } } [ClassAttributs(CName = "控件字体", Description = "编辑区域的字体")] public float EditFontSize { get { return this.editFontSize; } set { this.editFontSize = value; } } [NoCreatControlAttributs, JsonIgnore] public bool IsDoubleClick { get { return this.isDoubleClick; } set { this.isDoubleClick = value; } } [ClassAttributs(CName = "控件类型", Description = "控件类型,文本,多选字典等")] public EControlType ControlType { get { return this.controlType; } set { this.controlType = value; } } [ClassAttributs(CName = "验证类型", Description = "验证类型")] public EValidType ValidType { get { return this.validType; } set { this.validType = value; } } [ClassAttributs(CName = "多控件间距", Description = "复选框的组件间距")] public int EditOneUnitCount { get { return this.editOneUnitCount; } set { this.editOneUnitCount = value; } } [ClassAttributs(CName = "控件等宽排列", Description = "复选框的组件排列方式,为真时每个组件宽度相同")] public EIsBool DfArrangement { get { return this.dfArrangement; } set { this.dfArrangement = value; } } [ClassAttributs(CName = "文本最大长度", Description = "文本最大输入长度")] public int TextLength { get { return this.textLength; } set { this.textLength = value; } } [ClassAttributs(CName = "多组文本间距", Description = "复选框的文本间距")] public int OneUnitCount { get { return this.oneUnitCount; } set { this.oneUnitCount = value; } } [ClassAttributs(CName = "日期可空", Description = "允许日期为空")] public EIsBool IsDateNull { get { return this.isDateNull; } set { this.isDateNull = value; } } [NoCreatControlAttributs, JsonIgnore] public Image PickImage { get { return this.pickImage; } set { this.pickImage = value; } } private float GetFontSize() { float result; try { string text = null;// ConfigurationManager.AppSettings["FontSize"]; bool flag = text == null; if (flag) { result = 8f; } else { result = float.Parse(text); } } catch (Exception) { result = 8f; } return result; } private int jskd(int val) { double value = Convert.ToDouble(val) * (Convert.ToDouble(Screen.PrimaryScreen.Bounds.Width) / Convert.ToDouble(1920)); return Convert.ToInt32(value); } public AbleEditPackObj(ZedGraphControl zgc, PackObjManager poManager) : base(zgc, poManager) { this.baseZed = zgc; base.PackText = "可编辑" + this.index.ToString(); base.IsMultiline = EIsBool.True; base.RowSpan = 0.0124f; base.FontSize = this.GetFontSize(); } public void onClick(EventArgs e) { bool flag = this.Click != null && this.control != null; if (flag) { this.Click(this, e); } } public override void Draw() { bool flag = this.baseZed == null; if (!flag) { this.Clear(); bool flag2 = this.control != null; if (flag2) { bool flag3 = this.controlType == EControlType.RadioButtonList; if (flag3) { foreach (Control control in this.control.Controls) { CheckBox radioButton = control as CheckBox; bool flag4 = base.PackValue == ""; if (flag4) { radioButton.Checked = false; } else { bool flag5 = base.PackValue == radioButton.Text; if (flag5) { radioButton.Checked = true; } } } } else { bool flag6 = this.controlType == EControlType.CheckBox; if (flag6) { foreach (Control control2 in this.control.Controls) { CheckBox checkBox = control2 as CheckBox; List list = base.PackValue.Replace(',', ',').Split(new char[] { ',' }).ToList(); foreach (string current in list) { bool flag7 = base.PackValue == ""; if (flag7) { checkBox.Checked = false; } else { bool flag8 = current == checkBox.Text; if (flag8) { checkBox.Checked = true; } } } } } else { bool flag9 = this.controlType == EControlType.DateTimePicker; if (flag9) { DateTimeInput dateTimeInput = this.control as DateTimeInput; bool flag10 = dateTimeInput != null; if (flag10) { bool flag11 = this.IsDateNull == EIsBool.False; if (flag11) { bool flag12 = base.PackText == ""; if (flag12) { dateTimeInput.Text = DateTime.Now.ToString(); } else { dateTimeInput.Text = base.PackText; } dateTimeInput.MonthCalendar.ClearButtonVisible = false; string str = "yyyy-MM-dd"; bool flag13 = base.ControlTitleText.Trim() != ""; if (flag13) { str = base.ControlTitleText.Trim(); } base.PackText = string.Format("{0:" + str + "}", DateTime.Parse(dateTimeInput.Text)); } else { try { dateTimeInput.Text = base.PackText; dateTimeInput.MonthCalendar.ClearButtonVisible = true; } catch (Exception) { } } } } else { if (this.controlType == (EControlType)5) { ComboBox comboBox = this.control as ComboBox; bool flag15 = comboBox != null; if (flag15) { comboBox.Text = base.PackText; } } else if (this.controlType == EControlType.Directorys) { DevComponents.DotNetBar.Controls.TokenEditor comboBox = this.control as DevComponents.DotNetBar.Controls.TokenEditor; if (comboBox != null) { comboBox.DropDownWidth = comboBox.Width; if (base.ClassDataSourceName == "OperationRecord.OpeRecordInfo.NeuroPlexusAround") //手术诊断 comboBox.MaxHeightLines = 1; comboBox.SelectedTokens.Clear(); if (base.PackValue.Contains(",")) { string[] strArray1 = base.PackValue.Split(','); string[] strArray = base.PackText.Split(','); for (int i = 0; i < strArray1.Length; i++) { comboBox.SelectedTokens.Add(new DevComponents.DotNetBar.Controls.EditToken(strArray1[i], strArray[i])); } } else if (base.PackText.Contains("+") && this.ControlTitleText == "麻醉方式")// { string[] strArray1 = base.PackValue.Split('+'); string[] strArray = base.PackText.Split('+'); for (int i = 0; i < strArray.Length; i++) { comboBox.SelectedTokens.Add(new DevComponents.DotNetBar.Controls.EditToken(strArray1[i], strArray[i])); } } else if (base.PackText != "") { comboBox.SelectedTokens.Add(new DevComponents.DotNetBar.Controls.EditToken(base.PackValue, base.PackText)); } } } else { TextBox textBox = this.control as TextBox; bool flag16 = textBox != null; if (flag16) { this.control.Text = base.PackText; textBox.Multiline = true; ((TextBox)this.control).BorderStyle = BorderStyle.FixedSingle; } } } } } } bool flag17 = this.IsVisible; if (!flag17) { this.SetPackContent(); bool flag18 = this.controlType == EControlType.Directory ;//&& base.ControlTitleText.Contains("CA人员") if (flag18) { try { bool flag20 = this.PickImage != null; if (flag20) { try { ImageObj imageObj = new ImageObj(this.PickImage, (double)base.RealX, (double)base.RealY, (double)(base.RealEndX - base.RealX), (double)(base.RealEndY - base.RealY)); imageObj.IsVisible = true; imageObj.ZOrder = ZOrder.A_InFront; imageObj.Tag = base.PackTag; imageObj.Location.CoordinateFrame = CoordType.PaneFraction; imageObj.Location.AlignH = 0; imageObj.Location.AlignV = 0; ZUtil.DrawImage(imageObj, this.baseZed); } catch (Exception ex) { PublicMethod.WriteLog(ex); } } else { bool flag21 = base.PackValue != ""; if (flag21) { base.Draw(); } } } catch (Exception ) { bool flag22 = base.PackValue != ""; if (flag22) { base.Draw(); } } //string text = Application.StartupPath; //text += "\\PrintWorkerImage\\"; //text = text + base.PackValue + ".png"; //bool flag19 = File.Exists(text); //if (flag19) //{ // try // { // FileStream fileStream = new FileStream(text, FileMode.Open, FileAccess.Read); // Image image = Image.FromStream(fileStream); // fileStream.Close(); // ZUtil.DrawImage(new ImageObj(image, (double)base.RealX, (double)base.RealY, (double)(base.RealEndX - base.RealX), (double)(base.RealEndY - base.RealY)) // { // IsVisible = true, // ZOrder = ZOrder.A_InFront, // Tag = base.PackTag, // Location = // { // CoordinateFrame = CoordType.PaneFraction, // AlignH = AlignH.Left, // AlignV = AlignV.Top // }, // //IsVisible = true, // //ZOrder = ZOrder.A_InFront // }, this.baseZed); // } // catch (Exception) // { // } //} //else //{ // bool flag20 = base.PackValue != ""; // if (flag20) // { // base.Draw(); // } //} } else { base.Draw(); } } } } public void SetPackContent() { bool flag = this.baseZed == null; if (!flag) { bool flag2 = base.PackText != ""; if (flag2) { bool flag3 = this.ControlType == EControlType.CheckBox || this.ControlType == EControlType.RadioButtonList; if (flag3) { bool flag4 = base.PackText == "1"; if (flag4) { base.PackText = "是"; } bool flag5 = base.PackText == "0"; if (flag5) { base.PackText = "否"; } } Color color = base.FontColor; bool isSelect = base.IsSelect; if (isSelect) { color = Color.Red; } string text = ""; bool flag6 = text == ""; if (flag6) { text = base.PackText.Clone().ToString(); } bool flag7 = this.ControlType == EControlType.DateTimePicker; if (flag7) { try { bool flag8 = base.PackText == ""; if (!flag8) { string str = "yyyy-MM-dd"; bool flag9 = base.ControlTitleText.Trim() != ""; if (flag9) { str = base.ControlTitleText.Trim(); } text = string.Format("{0:" + str + "}", DateTime.Parse(text)); } } catch (Exception) { } } } } } public void SetControl() { try { int num = 0; bool flag = this.ControlType == EControlType.RadioButtonList || this.ControlType == EControlType.CheckBox; if (flag) { num = base.DfHzjpyl; } int x = Convert.ToInt32((float)this.baseZed.Width * base.RealX) + base.Hzjpyl + num; int y = Convert.ToInt32((float)this.baseZed.Height * base.RealY) - base.Zjpyl; int x2 = Convert.ToInt32((float)this.baseZed.Width * base.RealEndX); int y2 = Convert.ToInt32((float)this.baseZed.Height * base.RealEndY) - base.Zjpyl; Control[] array = this.baseZed.Parent.Controls.Find("conl" + base.PackTag, false); bool flag2 = array.Length == 0; if (flag2) { Control control = null; bool flag3 = this.controlType == EControlType.RadioButtonList; if (flag3) { this.control = new Panel(); List list = base.ControlTitleText.Replace(',', ',').Split(new char[] { ',' }).ToList(); int num2 = 1; int x3 = 0; int num3 = 0; for (int i = 0; i < list.Count; i++) { CheckBox radioButton = new CheckBox(); radioButton.Text = list[i]; radioButton.Tag = this; radioButton.Name = PackTag + "rdo" + list[i] + i; radioButton.AutoSize = true; bool flag4 = i > base.Unit * num2 - 1; if (flag4) { bool flag5 = control != null; if (flag5) { num3 = num3 + control.Height * i + this.jskd(this.EditOneUnitCount); } x3 = 0; num2++; } else { bool flag6 = control != null; if (flag6) { x3 = control.Location.X + control.Width + this.jskd(this.EditOneUnitCount); } } this.control.Controls.Add(radioButton); this.control.BackColor = Color.White; radioButton.Location = new Point(x3, num3); control = radioButton; } } else { bool flag7 = this.controlType == EControlType.CheckBox; if (flag7) { this.control = new Panel(); List list2 = base.ControlTitleText.Replace(',', ',').Split(new char[] { ',' }).ToList(); for (int j = 0; j < list2.Count; j++) { CheckBox checkBox = new CheckBox(); checkBox.Text = list2[j]; checkBox.AutoSize = true; checkBox.Tag = this; int num4 = 0; int num5 = 0; bool flag8 = j > base.Unit - 1; if (flag8) { bool flag9 = control != null; if (flag9) { num5 = num5 + control.Height * j + this.jskd(this.EditOneUnitCount); } num4 = 0; } else { bool flag10 = control != null; if (flag10) { num4 = num4 + control.Width * j + this.jskd(this.EditOneUnitCount); } } this.control.Controls.Add(checkBox); this.control.BackColor = Color.White; checkBox.Location = new Point(num4, num5); control = checkBox; } } else { bool flag11 = this.controlType == (EControlType)5; if (flag11) { ComboBox comboBox = new ComboBox(); List list3 = base.ControlTitleText.Replace(',', ',').Split(new char[] { ',' }).ToList(); for (int k = 0; k < list3.Count; k++) { comboBox.Items.Add(list3[k]); } this.control = comboBox; } else { bool flag12 = this.controlType == EControlType.DateTimePicker; if (flag12) { DateTimeInput dateTimeInput = new DateTimeInput(); dateTimeInput.BackgroundStyle.Class = "DateTimeInputBackground"; dateTimeInput.BackgroundStyle.CornerType = eCornerType.Square; dateTimeInput.ButtonDropDown.Shortcut = eShortcut.AltDown; dateTimeInput.ButtonDropDown.Visible = true; dateTimeInput.IsPopupCalendarOpen = false; dateTimeInput.MonthCalendar.BackgroundStyle.CornerType = eCornerType.Square; dateTimeInput.MonthCalendar.CalendarDimensions = new Size(1, 1); bool flag13 = this.IsDateNull == EIsBool.False; if (flag13) { dateTimeInput.MonthCalendar.ClearButtonVisible = false; } else { dateTimeInput.MonthCalendar.ClearButtonVisible = true; } dateTimeInput.MonthCalendar.CommandsBackgroundStyle.BackColor2SchemePart = eColorSchemePart.BarBackground2; dateTimeInput.MonthCalendar.CommandsBackgroundStyle.BackColorGradientAngle = 90; dateTimeInput.MonthCalendar.CommandsBackgroundStyle.BackColorSchemePart = eColorSchemePart.BarBackground; dateTimeInput.MonthCalendar.CommandsBackgroundStyle.BorderTop = eStyleBorderType.Solid; dateTimeInput.MonthCalendar.CommandsBackgroundStyle.BorderTopColorSchemePart = eColorSchemePart.BarDockedBorder; dateTimeInput.MonthCalendar.CommandsBackgroundStyle.BorderTopWidth = 1; dateTimeInput.MonthCalendar.CommandsBackgroundStyle.CornerType = eCornerType.Square; dateTimeInput.MonthCalendar.DisplayMonth = new DateTime(2021, 1, 1, 0, 0, 0, 0); dateTimeInput.MonthCalendar.FirstDayOfWeek = DayOfWeek.Monday; dateTimeInput.MonthCalendar.NavigationBackgroundStyle.BackColor2SchemePart = eColorSchemePart.PanelBackground2; dateTimeInput.MonthCalendar.NavigationBackgroundStyle.BackColorGradientAngle = 90; dateTimeInput.MonthCalendar.NavigationBackgroundStyle.BackColorSchemePart = eColorSchemePart.PanelBackground; dateTimeInput.MonthCalendar.NavigationBackgroundStyle.CornerType = eCornerType.Square; dateTimeInput.MonthCalendar.TodayButtonVisible = false; dateTimeInput.Style = eDotNetBarStyle.StyleManagerControlled; dateTimeInput.TabIndex = 0; dateTimeInput.TimeSelectorTimeFormat = eTimeSelectorFormat.Time24H; dateTimeInput.Value = new DateTime(2021, 1, 11, 14, 15, 51, 460); dateTimeInput.Format = eDateTimePickerFormat.Custom; dateTimeInput.CustomFormat = ((base.ControlTitleText == "") ? "yyyy-MM-dd" : base.ControlTitleText); this.control = dateTimeInput; } else { if (this.controlType == EControlType.Directory) { this.control = new TextBox(); } else if (this.controlType == EControlType.Directorys) { DevComponents.DotNetBar.Controls.TokenEditor tokenEditor = new DevComponents.DotNetBar.Controls.TokenEditor(); tokenEditor.BackgroundStyle.Class = "DateTimeInputBackground"; tokenEditor.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Rounded; //tokenEditor.Separators.Add(","); this.control = tokenEditor; } else { bool flag15 = this.controlType == (EControlType)6; if (flag15) { this.control = new Panel(); } else { this.control = BoardUtil.CreatFormControlFactory(this.controlType.ToString()); } } } } } } this.baseZed.Parent.Controls.Add(this.control); this.control.AutoSize = false; this.control.Name = "conl" + base.PackTag; this.control.Font = new Font(PackObjBase.fontFamily, this.EditFontSize); this.control.ForeColor = Color.DarkBlue; this.control.Tag = this; } bool flag16 = this.control == null; if (flag16) { bool flag17 = array.Length != 0; if (!flag17) { return; } this.control = array[0]; } bool flag18 = this.controlType == EControlType.RadioButtonList; if (flag18) { Control control2 = null; int num6 = 1; int x4 = 0; int num7 = 0; for (int l = 0; l < this.control.Controls.Count; l++) { bool flag19 = l > base.Unit * num6 - 1; if (flag19) { bool flag20 = control2 != null; if (flag20) { num7 += this.jskd(this.EditOneUnitCount); } x4 = 0; num6++; } else { bool flag21 = control2 != null; if (flag21) { int num8 = 0; bool flag22 = this.DfArrangement == EIsBool.False; if (flag22) { num8 = control2.Width; } x4 = control2.Location.X + num8 + this.jskd(this.EditOneUnitCount); } } this.control.Controls[l].Location = new Point(x4, num7); control2 = this.control.Controls[l]; } } else { bool flag23 = this.controlType == EControlType.CheckBox; if (flag23) { Control control3 = null; int num9 = 1; int x5 = 0; int num10 = 0; for (int m = 0; m < this.control.Controls.Count; m++) { bool flag24 = m > base.Unit * num9 - 1; if (flag24) { bool flag25 = control3 != null; if (flag25) { num10 += this.jskd(this.EditOneUnitCount); } x5 = 0; num9++; } else { bool flag26 = control3 != null; if (flag26) { int num11 = 0; bool flag27 = this.DfArrangement == EIsBool.False; if (flag27) { num11 = control3.Width; } x5 = control3.Location.X + num11 + this.jskd(this.EditOneUnitCount); } } this.control.Controls[m].Location = new Point(x5, num10); control3 = this.control.Controls[m]; } } } this.control.Location = new Point(x, y); Point point = new Point(x2, y2); int width = point.X - this.control.Location.X; int height = point.Y - this.control.Location.Y; this.control.AutoSize = false; this.control.Size = new Size(width, height); this.control.Font = new Font(PackObjBase.fontFamily, this.EditFontSize); this.control.Visible = this.isVisible; this.control.TabIndex = base.TabIndex; this.control.BringToFront(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } public override void Clear() { base.Clear(); for (int i = 0; i <= 20; i++) { string tag = base.PackTag + i.ToString(); bool flag = this.baseZed.MasterPane != null; if (flag) { GraphObj graphObj = this.baseZed.MasterPane.GraphObjList[tag]; bool flag2 = graphObj != null; if (flag2) { this.baseZed.MasterPane.GraphObjList.Remove(graphObj); } } } bool flag3 = this.CControl != null; if (flag3) { } } public void ClearControl() { Control[] array = this.baseZed.Parent.Controls.Find("conl" + base.PackTag, false); Control[] array2 = array; for (int i = 0; i < array2.Length; i++) { Control value = array2[i]; this.baseZed.Parent.Controls.Remove(value); } } } }