void LocationChanged() { int preX = 0; if (_serverStopRender.Visible)//计算服务停用标识占据的宽度 { _serverStopRender.Size = new Size(OrderContext.ServerStopWidth, OrderConstAssist.OrderRenderHeight); preX = OrderContext.ServerStopWidth + OrderContext.ServerStopPreX; } //剂量宽度 _xUnitTextBox.Size = new Size(70, 24); SizeF serverNameSie = TextCellRender.MeasureText(this._serverNameLabel.ValueText, this._serverNameLabel.Font); int serverNameLabelWidth = 0; if (this.DrawLeftPre + serverNameSie.Width + OrderContext.ElementSpaceWidth + _xUnitTextBox.Size.Width + preX > this.TotalWidth) { serverNameLabelWidth = this.TotalWidth - (int)(OrderContext.ElementSpaceWidth + _xUnitTextBox.Size.Width + this.DrawLeftPre + preX); _serverNameLabel.IsShowTip = true; } else { serverNameLabelWidth = (int)(serverNameSie.Width) + 1; } _serverNameLabel.Location = new Point(this.Location.X + this.DrawLeftPre, this.Location.Y + OrderConstAssist.SimpleUserDefinePreY); _serverNameLabel.Size = new Size(serverNameLabelWidth, 24); _xUnitTextBox.Location = new Point(_serverNameLabel.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y + OrderConstAssist.SimpleUnitPreY); _serverStopRender.Location = new Point(_xUnitTextBox.Bound.Right + OrderContext.ServerStopWidth, this.Location.Y + OrderConstAssist.ServerStopPre); }
//位置发生变更时,对上面的元素的位置同时进行调整 void LocationChanged() { int preX = 0; if (_serverStopRender.Visible) { _serverStopRender.Size = new Size(OrderContext.ServerStopWidth, OrderConstAssist.OrderRenderHeight); preX = OrderContext.ServerStopWidth + OrderContext.ServerStopPreX; } _xUnitTextBox.Size = new Size(70, 24); SizeF sizeF = TextCellRender.MeasureText(this._serverNameLabel.ValueText, this._serverNameLabel.Font); if (this.TotalWidth - this.DrawLeftPre - preX > 0) { _serverNameLabel.Size = new Size((int)sizeF.Width + 1, 24); } else { _serverNameLabel.Size = new Size(this.Size.Width - this.DrawLeftPre - preX, 24); _serverNameLabel.IsShowTip = true; } _serverNameLabel.Location = new Point(this.Location.X + this.DrawLeftPre, this.Location.Y + OrderConstAssist.SimpleUserDefinePreY); _xUnitTextBox.Location = new Point(_serverNameLabel.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y + OrderConstAssist.SimpleUnitPreY); _serverStopRender.Location = new Point(_serverNameLabel.Bound.Right + OrderContext.ServerStopPreX, this.Location.Y + OrderConstAssist.ServerStopPre); }
//位置变化触发 void LocationChanged() { SizeF checkSizeF = TextCellRender.MeasureText(_checkBox.Text, _checkBox.Font); //服务名称 SizeF orderLabelSizeF = TextCellRender.MeasureText(_orderLabel.ValueText, _orderLabel.Font); //单价,分类 _unitTextBox.Size = new Size(OrderContext.SingleDrugDosageWidth, this.Size.Height); if ((orderLabelSizeF.Width + 1) + (OrderContext.SingleDrugDosageWidth) + OrderContext.OrderNameMinWidth + OrderContext.ElementSpaceWidth * 2 + OrderContext.CheckBoxWidth > this.Size.Width) { _checkBox.Size = new Size(OrderContext.OrderNameMinWidth + 16, this.Size.Height); _checkBox.IsShowToolTip = true; _orderLabel.Size = new Size(this.Size.Width - (int)((70) + OrderContext.OrderNameMinWidth + OrderContext.ElementSpaceWidth * 2), this.Size.Height); } else { _checkBox.Size = new Size((int)checkSizeF.Width + 16, this.Size.Height); _orderLabel.Size = new Size(this.Size.Width - (int)((70) + (_checkBox.Size.Width) + OrderContext.ElementSpaceWidth * 2), this.Size.Height); } //if (TextCellRender.MeasureText(_checkBox.Text, _checkBox.Font).Width > this._checkBox.Size.Width) //{ // _checkBox.IsShowToolTip = true; //} _checkBox.Location = new Point(this.Location.X, this.Location.Y); _orderLabel.Location = new Point(_checkBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _unitTextBox.Location = new Point(_orderLabel.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); }
//位置变化触发 void LocationChanged() { _unitTextBox.Size = new Size(OrderContext.SingleDrugDosageWidth, this.Size.Height); int orderLabelWidth = (int)TextCellRender.MeasureText(_orderLabel.ValueText, _orderLabel.Font).Width + 1; _orderLabel.Size = new Size(orderLabelWidth, this.Size.Height); int checkBoxWidth = (int)TextCellRender.MeasureText(_checkBox.Text, _checkBox.Font).Width + 1; int totalWidth = orderLabelWidth + OrderContext.SingleDrugDosageWidth + OrderContext.ElementSpaceWidth * 2 + (checkBoxWidth + OrderContext.CheckBoxWidth); if (totalWidth < this.Size.Width) { _checkBox.Size = new Size(checkBoxWidth + OrderContext.CheckBoxWidth, this.Size.Height); } else { _checkBox.Size = new Size(this.Size.Width - OrderContext.SingleDrugDosageWidth - (_orderLabel.Size.Width + 1) - OrderContext.ElementSpaceWidth * 2, this.Size.Height); _checkBox.IsShowToolTip = true; } _checkBox.Location = new Point(this.Location.X, this.Location.Y); _orderLabel.Location = new Point(_checkBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _unitTextBox.Location = new Point(_orderLabel.Bound.Right + +OrderContext.ElementSpaceWidth, this.Location.Y); }
//Size发生变更时 void SizeChanged() { _checkBox.Size = new Size(this.Size.Width - 2 - 1, 24); if (TextCellRender.MeasureText(_checkBox.Text, _checkBox.Font).Width > this._checkBox.Size.Width) { _checkBox.IsShowToolTip = true; } }
//位置发生变更时,对上面的元素的位置同时进行调整 void LocationChanged() { _checkBox.Location = new Point(this.Location.X + 2, this.Location.Y); int checkBoxWidth = (int)TextCellRender.MeasureText(_checkBox.Text, _checkBox.Font).Width + 1; //服务名称 int orderLabelWidth = (int)TextCellRender.MeasureText(_orderLabel.ValueText, _orderLabel.Font).Width + 1; //单价,分类 int departmentWidth = (int)TextCellRender.MeasureText(_departmentLabel.ValueText, _departmentLabel.Font).Width + 1; //执行科室 int totalWidth = (checkBoxWidth + OrderContext.CheckBoxWidth) + orderLabelWidth + departmentWidth + OrderContext.ElementSpaceWidth * 2; if (totalWidth < this.Size.Width)//展示元素的总宽度<可用于显示的宽度(科室居右对齐,其他元素从左往右平铺) { _checkBox.Size = new Size(checkBoxWidth + OrderContext.CheckBoxWidth, this.Size.Height); _orderLabel.Size = new Size(orderLabelWidth, this.Size.Height); } else { //分两种情况 //1:如果用于服务名称可显示的宽度大于最小保留宽度(OrderContext.OrderNameMinWidth+ OrderContext.CheckBoxWidth) 则压缩服务名称(...) //2:如果用于服务名称可显示的宽度小于最小保留宽度(OrderContext.OrderNameMinWidth+ OrderContext.CheckBoxWidth) 则压缩(单价分类)的显示区域(...) _checkBox.IsShowToolTip = true; int minCheckBoxWidth = this.Size.Width - orderLabelWidth - departmentWidth - OrderContext.ElementSpaceWidth * 2; if (minCheckBoxWidth > (OrderContext.OrderNameMinWidth + OrderContext.CheckBoxWidth)) { _checkBox.Size = new Size(minCheckBoxWidth + OrderContext.CheckBoxWidth, this.Size.Height); _orderLabel.Size = new Size(orderLabelWidth, this.Size.Height); } else { _checkBox.Size = new Size(OrderContext.OrderNameMinWidth + OrderContext.CheckBoxWidth, this.Size.Height); int minOrderLabelWidth = this.Size.Width - (OrderContext.OrderNameMinWidth + OrderContext.CheckBoxWidth) - OrderContext.ElementSpaceWidth * 2 - orderLabelWidth - departmentWidth; _orderLabel.Size = new Size(minOrderLabelWidth, this.Size.Height); } } _departmentLabel.Size = new Size(departmentWidth, this.Size.Height); _checkBox.Location = new Point(this.Location.X, this.Location.Y); _orderLabel.Location = new Point(_checkBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _departmentLabel.Location = new Point(this.Bound.Right - departmentWidth, this.Location.Y); }
//位置发生变化,重设上面的其他Render的位置 void LocationChanged() { //_excuteDepartment.ValueText = "中医科"; _useNum.Size = new Size(48, this.Size.Height); _userMethod.Size = new Size(60, this.Size.Height); _comboBox.Size = new Size(80, this.Size.Height); _userMethod1.Size = new Size(48, this.Size.Height); int executeDepartWidth = (int)TextCellRender.MeasureText(_excuteDepartment.ValueText, _excuteDepartment.Font).Width + 1; _excuteDepartment.Size = new Size(executeDepartWidth, this.Size.Height); int checkBoxWidth = (int)TextCellRender.MeasureText(_medicalNameCheckBox.Text, _medicalNameCheckBox.Font).Width + 1; int totalWidth = 48 + 60 + 80 + 48 + executeDepartWidth + OrderContext.ElementSpaceWidth * 5 + (checkBoxWidth + OrderContext.CheckBoxWidth); if (totalWidth < this.Size.Width) { _medicalNameCheckBox.Size = new Size(checkBoxWidth + OrderContext.CheckBoxWidth, this.Size.Height); } else { _medicalNameCheckBox.Size = new Size(this.Size.Width - 48 - 60 - 80 - 48 - executeDepartWidth - OrderContext.ElementSpaceWidth * 5, this.Size.Height); _medicalNameCheckBox.IsShowToolTip = true; } /* if ( > this._medicalNameCheckBox.Size.Width) * { * * }*/ _medicalNameCheckBox.Location = new Point(this.Location.X, this.Location.Y); _useNum.Location = new Point(_medicalNameCheckBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _userMethod.Location = new Point(_useNum.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _comboBox.Location = new Point(_userMethod.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _userMethod1.Location = new Point(_comboBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _excuteDepartment.Location = new Point(this.Bound.Right - executeDepartWidth, this.Location.Y); }
//位置发生变更时 void LocationChanged() { int preX = 0; if (_serverStopRender.Visible)//计算服务停用标识占据的宽度 { _serverStopRender.Size = new Size(OrderContext.ServerStopWidth, OrderConstAssist.OrderRenderHeight); preX = OrderContext.ServerStopWidth + OrderContext.ServerStopPreX; } _xUnitTextBox.Size = new Size(70, 24); SizeF serverNameSie = TextCellRender.MeasureText(this._serverNameLabel.ValueText, this._serverNameLabel.Font); //服务器名称 SizeF userDaySize = TextCellRender.MeasureText(this._label.ValueText, this._serverNameLabel.Font); //使用天数 int preXLabel = 0; //使用天数的偏移,因为使用天数为空,不需要拼接。。。故 if (!_label.Visible) { userDaySize = new SizeF(0, 0); preXLabel = -OrderContext.ElementSpaceWidth; } _label.Size = new Size((int)userDaySize.Width + 1, 24); int serverNameLabelWidth = 0; if (this.DrawLeftPre + serverNameSie.Width + OrderContext.ElementSpaceWidth + _xUnitTextBox.Size.Width + OrderContext.ElementSpaceWidth + _label.Size.Width + preX + OrderContext.ElementSpaceWidth + preXLabel > this.TotalWidth) { serverNameLabelWidth = this.TotalWidth - (int)(this.DrawLeftPre + OrderContext.ElementSpaceWidth * 3 + _xUnitTextBox.Size.Width + _label.Size.Width + preX + preXLabel); _serverNameLabel.IsShowTip = true; } else { serverNameLabelWidth = (int)(serverNameSie.Width) + 1; } _serverNameLabel.Size = new Size(serverNameLabelWidth, 24); _serverNameLabel.Location = new Point(this.Location.X + this.DrawLeftPre, this.Location.Y + OrderConstAssist.SimpleUserDefinePreY); _xUnitTextBox.Location = new Point(_serverNameLabel.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y + OrderConstAssist.SimpleUnitPreY); _label.Location = new Point(_xUnitTextBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y + OrderConstAssist.SimpleUserDefinePreY); _serverStopRender.Location = new Point(_label.Bound.Right + OrderContext.ServerStopPreX, this.Location.Y + OrderConstAssist.ServerStopPre); }
//位置发生变化,重设上面的其他Render的位置 void LocationChanged() { int userMethodWidth = (int)TextCellRender.MeasureText(_userMethodCheckBox.Text, _userMethodCheckBox.Font).Width + 1; int executeDepaerMentWidth = (int)TextCellRender.MeasureText(_excuteDepartment.ValueText, _excuteDepartment.Font).Width + 1; int totalWidth = OrderContext.UserDaysWidth + OrderContext.FreqOrderWidth + executeDepaerMentWidth + (userMethodWidth + OrderContext.CheckBoxWidth) + OrderContext.ElementSpaceWidth * 3; if (totalWidth < this.Size.Width) { _userMethodCheckBox.Size = new Size((userMethodWidth + OrderContext.CheckBoxWidth), this.Size.Height); _userDaysTextBox.Size = new Size(OrderContext.UserDaysWidth, this.Size.Height); _comboBox.Size = new Size(OrderContext.FreqOrderWidth, this.Size.Height); _excuteDepartment.Size = new Size(executeDepaerMentWidth, this.Size.Height); } else { int minCheckBoxWidth = this.Size.Width - OrderContext.UserDaysWidth - OrderContext.FreqOrderWidth - OrderContext.ElementSpaceWidth * 3; _userMethodCheckBox.Size = new Size(minCheckBoxWidth, this.Size.Height); _userDaysTextBox.Size = new Size(OrderContext.UserDaysWidth, this.Size.Height); _comboBox.Size = new Size(OrderContext.FreqOrderWidth, this.Size.Height); _excuteDepartment.Size = new Size(executeDepaerMentWidth, this.Size.Height); } // _userMethodCheckBox.Size = new Size(this.Size.Width - _userDaysTextBox.Size.Width - _comboBox.Size.Width - _excuteDepartment.Size.Width - OrderContext.ElementSpaceWidth * 3, this.Size.Height); if (TextCellRender.MeasureText(_userMethodCheckBox.Text, _userMethodCheckBox.Font).Width > this._userMethodCheckBox.Size.Width) { _userMethodCheckBox.IsShowToolTip = true; } _userMethodCheckBox.Location = new Point(this.Location.X, this.Location.Y); _comboBox.Location = new Point(_userMethodCheckBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _userDaysTextBox.Location = new Point(_comboBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _excuteDepartment.Location = new Point(this.Bound.Right - executeDepaerMentWidth, this.Location.Y); }
void LocationChanged() { _userDaysTextBox.Size = new Size(OrderContext.UserDaysWidth, this.Size.Height); _comboBox.Size = new Size(OrderContext.FreqOrderWidth, this.Size.Height); _excuteDepartment.Size = new Size(OrderContext.ExecuteDepartmentWidth, this.Size.Height); int userMethodWidth = (int)TextCellRender.MeasureText(_userMethod.ValueText, _userMethod.Font).Width + 1; int totalWidth = OrderContext.UserDaysWidth + OrderContext.FreqOrderWidth + OrderContext.ExecuteDepartmentWidth + userMethodWidth + OrderContext.ElementSpaceWidth * 3; if (totalWidth > this.Size.Width) { _userMethod.Size = new Size(this.Size.Width - _userDaysTextBox.Size.Width - _comboBox.Size.Width - _excuteDepartment.Size.Width - OrderContext.ElementSpaceWidth * 3, this.Size.Height); } else { _userMethod.Size = new Size(userMethodWidth, this.Size.Height); } _userMethod.Location = new Point(this.Location.X, this.Location.Y); _comboBox.Location = new Point(_userMethod.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _userDaysTextBox.Location = new Point(_comboBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _excuteDepartment.Location = new Point(_userDaysTextBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); }
//位置变化时 void LocationChanged() { if (String.IsNullOrEmpty(this.TreatStyle) || (this.TreatStyle.Equals("1")))//诊疗模式为1或者空(默认) { _userNum.Size = new Size(OrderContext.SingleDrugDosageWidth, this.Size.Height); _excuteProject.Size = new Size(OrderContext.ExecuteDepartmentWidth, this.Size.Height); int orderLabelWidth = (int)TextCellRender.MeasureText(_orderLabel.ValueText, _orderLabel.Font).Width + 1; int treatCheckBoxWidth = (int)TextCellRender.MeasureText(_treatNameCheckBox.Text, _treatNameCheckBox.Font).Width + 1; int totalWidth = OrderContext.SingleDrugDosageWidth + OrderContext.ExecuteDepartmentWidth + orderLabelWidth + treatCheckBoxWidth + OrderContext.ElementSpaceWidth * 3 + OrderContext.CheckBoxWidth;//16复选框的宽度 if (totalWidth > this.Size.Width) { int surplusWidth = this.Size.Width - (OrderContext.SingleDrugDosageWidth + OrderContext.ExecuteDepartmentWidth + orderLabelWidth + OrderContext.ElementSpaceWidth * 3);//16复选框的宽度 //如果除了CheckBox自身宽度 剩余宽度 <(_treatNameCheckBox)服务名称的安全宽度的话 if (surplusWidth < (OrderContext.OrderNameMinWidth + OrderContext.CheckBoxWidth)) { _treatNameCheckBox.Size = new Size(OrderContext.OrderNameMinWidth + OrderContext.CheckBoxWidth, this.Size.Height); int orderLabelMinWidth = this.Size.Width - OrderContext.SingleDrugDosageWidth - OrderContext.ExecuteDepartmentWidth - OrderContext.ElementSpaceWidth * 3 - _treatNameCheckBox.Size.Width; _orderLabel.Size = new Size(orderLabelMinWidth, this.Size.Height); } else { int trateNameMinWidth = this.Size.Width - OrderContext.SingleDrugDosageWidth - OrderContext.ExecuteDepartmentWidth - OrderContext.ElementSpaceWidth * 3 - orderLabelWidth; _treatNameCheckBox.Size = new Size(trateNameMinWidth, this.Size.Height); _orderLabel.Size = new Size(orderLabelWidth, this.Size.Height); } _treatNameCheckBox.IsShowToolTip = true; } else { _treatNameCheckBox.Size = new Size(treatCheckBoxWidth + OrderContext.CheckBoxWidth, this.Size.Height); _orderLabel.Size = new Size(this.Size.Width - (totalWidth - orderLabelWidth), this.Size.Height); } //_treatNameCheckBox.Size = new Size(this.Size.Width - 70 - 4 - _excuteProject.Bound.Width, this.Size.Height); _treatNameCheckBox.Location = new Point(this.Location.X, this.Location.Y); _orderLabel.Location = new Point(_treatNameCheckBox.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _userNum.Location = new Point(_orderLabel.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); _excuteProject.Location = new Point(_userNum.Bound.Right + OrderContext.ElementSpaceWidth, this.Location.Y); } //TODO 后续如果支持这种模式的话,再去调整 else if (this.TreatStyle.Equals("0")) { _userNum.Size = new Size(60, this.Size.Height); _freqXComboBox.Size = new Size(70, this.Size.Height); _userDays.Size = new Size(60, this.Size.Height); _excuteProject.Size = new Size(OrderContext.ExecuteDepartmentWidth, this.Size.Height); _treatNameCheckBox.Size = new Size(this.Size.Width - 70 - 70 - 48 - 4 * 3 - _excuteProject.Bound.Width, this.Size.Height); if (TextCellRender.MeasureText(_treatNameCheckBox.Text, _treatNameCheckBox.Font).Width > _treatNameCheckBox.Size.Width) { _treatNameCheckBox.IsShowToolTip = true; } _treatNameCheckBox.Location = new Point(this.Location.X, this.Location.Y); _userNum.Location = new Point(_treatNameCheckBox.Bound.Right + 4, this.Location.Y); _freqXComboBox.Location = new Point(_userNum.Bound.Right + 4, this.Location.Y); _userDays.Location = new Point(_freqXComboBox.Bound.Right + 4, this.Location.Y); _excuteProject.Location = new Point(_userDays.Bound.Right + 4, this.Location.Y); } }