using Lskj.Util; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Windows.Forms; namespace Lskj.Control.Model { public class AutoSizeChange { /// /// 缩放比例 /// public static double value = InitSpliterPosition(); private static double widthZoomValue = 1; private static double fontZoomValue = 1; private static double heightZoomValue = 1; #region 方法 #region 递归遍历更改控件大小 /// /// 说明:递归遍历更改控件大小 /// 创建人:唐德馨 /// 创建日期:2021-09-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public static void ControllInitializeSize(System.Windows.Forms.Control Control) { Lskj.Control.Model.ReplaceTranslation.TranslationFixedButton(Control); if (value == 1) return; if (value == 0.842) { fontZoomValue = 0.9; widthZoomValue = 0.842; heightZoomValue = 1; } else { fontZoomValue = widthZoomValue = heightZoomValue = value; } foreach (System.Windows.Forms.Control ctrol in Control.Controls) { if (ctrol.Controls.Count > 0) { if (ctrol is Panel || ctrol is DevExpress.XtraEditors.PanelControl) { if (ctrol.Tag != "NotChangeLocation") { ctrol.Size = new Size(Convert.ToInt32(ctrol.Width * widthZoomValue), Convert.ToInt32(ctrol.Height * heightZoomValue)); ctrol.Location = new Point(Convert.ToInt32(ctrol.Location.X * widthZoomValue), Convert.ToInt32(ctrol.Location.Y * heightZoomValue)); } } if (ctrol is UserControl && !(ctrol is BaseUserControl)) { ctrol.Size = new Size(Convert.ToInt32(ctrol.Width * widthZoomValue), Convert.ToInt32(ctrol.Height * heightZoomValue)); ctrol.Location = new Point(Convert.ToInt32(ctrol.Location.X * widthZoomValue), Convert.ToInt32(ctrol.Location.Y * heightZoomValue)); } if (ctrol is BaseUserControl) { ctrol.Size = new Size(Convert.ToInt32(ctrol.Width * widthZoomValue), Convert.ToInt32(ctrol.Height * heightZoomValue)); ctrol.Location = new Point(Convert.ToInt32(ctrol.Location.X * widthZoomValue), Convert.ToInt32(ctrol.Location.Y * heightZoomValue)); BaseUserControl uControl = ctrol as BaseUserControl; if (uControl != null && uControl.Model != null) { ControlModel model = uControl.Model; switch (model.FieldType) { case ControlType.LabDate: case ControlType.LabDateTime: case ControlType.LabDateTimeShort: case ControlType.LabTime: case ControlType.LabShortTime: // 日期控件 LabelDateEdit dateEdit = uControl as LabelDateEdit; dateEdit.TextEdit.Size = new Size(Convert.ToInt32(dateEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(dateEdit.TextEdit.Height * heightZoomValue)); dateEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(dateEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(dateEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); dateEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(dateEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(dateEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); dateEdit.TextEdit.Font = new Font(dateEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(dateEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); dateEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabComboxValue: case ControlType.LabComboxText: case ControlType.LabComboxValueParam: case ControlType.LabComboxTextParam: // 下拉框 LabelComboxEdit comboxEdit = uControl as LabelComboxEdit; comboxEdit.TextEdit.Size = new Size(Convert.ToInt32(comboxEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(comboxEdit.TextEdit.Height * heightZoomValue)); comboxEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(comboxEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(comboxEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); comboxEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(comboxEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(comboxEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); comboxEdit.TextEdit.Font = new Font(comboxEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(comboxEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); comboxEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabAutoCompleteValue: case ControlType.LabAutoCompleteText: case ControlType.LabAutoCompleteValueParam: case ControlType.LabAutoCompleteTextParam: // 自动搜索框 LabelAutoTextEdit autoEdit = uControl as LabelAutoTextEdit; autoEdit.TextEdit.Size = new Size(Convert.ToInt32(autoEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(autoEdit.TextEdit.Height * heightZoomValue)); autoEdit.TextEdit.Font = new Font(autoEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(autoEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); DevExpress.XtraGrid.Views.Grid.GridView GridView = autoEdit.TextEdit._popup.GridViewObj; GridView.FooterPanelHeight = Convert.ToInt32(GridView.FooterPanelHeight * heightZoomValue); GridView.Appearance.Row.Font = new Font(GridView.Appearance.HeaderPanel.Font.OriginalFontName, Convert.ToSingle(GridView.Appearance.HeaderPanel.Font.Size * fontZoomValue * fontZoomValue)); GridView.Appearance.HeaderPanel.Font = new Font(GridView.Appearance.HeaderPanel.Font.OriginalFontName, Convert.ToSingle(GridView.Appearance.HeaderPanel.Font.Size * fontZoomValue * fontZoomValue)); GridView.Appearance.FooterPanel.Font = new Font(GridView.Appearance.FooterPanel.Font.OriginalFontName, Convert.ToSingle(GridView.Appearance.FooterPanel.Font.Size * fontZoomValue * fontZoomValue)); autoEdit.TextEdit._popup.Tag = "Changed"; break; case ControlType.LabAutoGridValue: case ControlType.LabAutoGridText: case ControlType.LabAutoGridValueParam: case ControlType.LabAutoGridTextParam: // 智能搜索框 LabelAutoGridLook autoGridEdit = uControl as LabelAutoGridLook; autoGridEdit.TextEdit.Size = new Size(Convert.ToInt32(autoGridEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(autoGridEdit.TextEdit.Height * heightZoomValue)); autoGridEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(autoGridEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(autoGridEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); autoGridEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(autoGridEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(autoGridEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); autoGridEdit.TextEdit.Font = new Font(autoGridEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(autoGridEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); autoGridEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabRemark: // 备注框 LabelRemarkEdit remarkEdit = ctrol as LabelRemarkEdit; remarkEdit.TextEdit.Size = new Size(Convert.ToInt32(remarkEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(remarkEdit.TextEdit.Height * heightZoomValue)); remarkEdit.TextEdit.Font = new Font(remarkEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(remarkEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); remarkEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabMemoEdit: // 备注框A LabelMemoEdit memoEdit = ctrol as LabelMemoEdit; memoEdit.TextEdit.Size = new Size(Convert.ToInt32(memoEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(memoEdit.TextEdit.Height * heightZoomValue)); memoEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(memoEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(memoEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); memoEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(memoEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(memoEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); memoEdit.TextEdit.Font = new Font(memoEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(memoEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); memoEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabMemoSpaceEdit: // 备注框A LabelMemoSpaceEdit memoSpaceEdit = ctrol as LabelMemoSpaceEdit; memoSpaceEdit.TextEdit.Size = new Size(Convert.ToInt32(memoSpaceEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(memoSpaceEdit.TextEdit.Height * heightZoomValue)); memoSpaceEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(memoSpaceEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(memoSpaceEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); memoSpaceEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(memoSpaceEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(memoSpaceEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); memoSpaceEdit.TextEdit.Font = new Font(memoSpaceEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(memoSpaceEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); memoSpaceEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabCheckDateEx: case ControlType.LabCheckDateTimeEx: case ControlType.LabCheckDateTimeShort: case ControlType.LabCheckTime: case ControlType.LabCheckShortTime: // 带复选框日期控件 LabelCheckDateEdit checkDateEdit = ctrol as LabelCheckDateEdit; checkDateEdit.TextEdit.Size = new Size(Convert.ToInt32(checkDateEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(checkDateEdit.TextEdit.Height * heightZoomValue)); checkDateEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(checkDateEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(checkDateEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); checkDateEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(checkDateEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(checkDateEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); checkDateEdit.TextEdit.Font = new Font(checkDateEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(checkDateEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); checkDateEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabMultiSelectText: case ControlType.LabMultiSelectTextNew: case ControlType.LabMultiSelectValue: case ControlType.LabMultiSelectValueNew: case ControlType.LabMultiSelectValueParam: case ControlType.LabMultiSelectTextParam: // 多选控件 LabelMultiAutoTextEdit multiAutoEdit = ctrol as LabelMultiAutoTextEdit; multiAutoEdit.TextEdit.Size = new Size(Convert.ToInt32(multiAutoEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(multiAutoEdit.TextEdit.Height * heightZoomValue)); multiAutoEdit.TextEdit.Font = new Font(multiAutoEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(multiAutoEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); multiAutoEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabTreeLookValue: case ControlType.LabTreeLookText: case ControlType.LabCheckTreeLookValue: case ControlType.LabCheckTreeLookText: case ControlType.LabTreeLastlevelValue: case ControlType.LabTreeLastlevelText: case ControlType.LabCheckTreeLastlevelValue: case ControlType.LabCheckTreeLastlevelText: // 多选控件 LabelAutoTreeEdit autoTreeEdit = ctrol as LabelAutoTreeEdit; autoTreeEdit.TextEdit.Size = new Size(Convert.ToInt32(autoTreeEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(autoTreeEdit.TextEdit.Height * heightZoomValue)); autoTreeEdit.TextEdit.Font = new Font(autoTreeEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(autoTreeEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); autoTreeEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabCheckMultiSelectValue: case ControlType.LabCheckMultiSelectText: case ControlType.LabCheckMultiSelectValueParam: case ControlType.LabCheckMultiSelectTextParam: // 带复选框多选控件 LabelCheckMultiAutoTextEdit checkmultiAutoEdit = ctrol as LabelCheckMultiAutoTextEdit; checkmultiAutoEdit.TextEdit.Size = new Size(Convert.ToInt32(checkmultiAutoEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(checkmultiAutoEdit.TextEdit.Height * heightZoomValue)); checkmultiAutoEdit.TextEdit.Font = new Font(checkmultiAutoEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(checkmultiAutoEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); checkmultiAutoEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabCheckComboxText: case ControlType.LabCheckComboxValue: // 带复选框下拉框 LabelCheckComboxEdit checkComboxEdit = ctrol as LabelCheckComboxEdit; checkComboxEdit.TextEdit.Size = new Size(Convert.ToInt32(checkComboxEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(checkComboxEdit.TextEdit.Height * heightZoomValue)); checkComboxEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(checkComboxEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(checkComboxEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); checkComboxEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(checkComboxEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(checkComboxEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); checkComboxEdit.TextEdit.Font = new Font(checkComboxEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(checkComboxEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); checkComboxEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabCheckAutoSeacherValue: case ControlType.LabCheckAutoSeacherText: // 带复选框自动搜索框 LabelCheckAutoTextEdit checkAutoTextEdit = ctrol as LabelCheckAutoTextEdit; checkAutoTextEdit.TextEdit.Size = new Size(Convert.ToInt32(checkAutoTextEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(checkAutoTextEdit.TextEdit.Height * heightZoomValue)); checkAutoTextEdit.TextEdit.Font = new Font(checkAutoTextEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(checkAutoTextEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); checkAutoTextEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabWWW: // 网址框 LabelBrowserEdit browserEdit = ctrol as LabelBrowserEdit; browserEdit.TextEdit.Size = new Size(Convert.ToInt32(browserEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(browserEdit.TextEdit.Height * heightZoomValue)); browserEdit.TextEdit.Font = new Font(browserEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(browserEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); browserEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabQQ: // QQ框 LabelQQEdit qqEdit = ctrol as LabelQQEdit; qqEdit.TextEdit.Size = new Size(Convert.ToInt32(qqEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(qqEdit.TextEdit.Height * heightZoomValue)); qqEdit.TextEdit.Font = new Font(qqEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(qqEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); qqEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabCalcText: // 计算器 LabelCalcEdit calcEdit = ctrol as LabelCalcEdit; calcEdit.TextEdit.Size = new Size(Convert.ToInt32(calcEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(calcEdit.TextEdit.Height * heightZoomValue)); calcEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(calcEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(calcEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); calcEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(calcEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(calcEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); calcEdit.TextEdit.Font = new Font(calcEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(calcEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); calcEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabRichEdit: // 富文本编辑框 LabelRichEdit richEdit = ctrol as LabelRichEdit; richEdit.TextEdit.Size = new Size(Convert.ToInt32(richEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(richEdit.TextEdit.Height * heightZoomValue)); richEdit.TextEdit.Font = new Font(richEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(richEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); richEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabCheckBox: // 复选框 LabelCheckEdit checkEdit = ctrol as LabelCheckEdit; checkEdit.TextEdit.Size = new Size(Convert.ToInt32(checkEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(checkEdit.TextEdit.Height * heightZoomValue)); checkEdit.TextEdit.Font = new Font(checkEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(checkEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); checkEdit.TextEdit.Tag = "Changed"; break; //数字编辑框 case ControlType.LabTextInt: LabelTextEdit textIntEdit = ctrol as LabelTextEdit; textIntEdit.TextEdit.Size = new Size(Convert.ToInt32(textIntEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(textIntEdit.TextEdit.Height * heightZoomValue)); textIntEdit.TextEdit.Font = new Font(textIntEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(textIntEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); textIntEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabComboxPopupValue: case ControlType.LabComboxPopupText: // 弹出下拉列表框 LabelComboxPopupEdit comboxPopupEdit = ctrol as LabelComboxPopupEdit; comboxPopupEdit.TextEdit.Size = new Size(Convert.ToInt32(comboxPopupEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(comboxPopupEdit.TextEdit.Height * heightZoomValue)); comboxPopupEdit.TextEdit.Font = new Font(comboxPopupEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(comboxPopupEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); comboxPopupEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabComboxPopupMutilValue: case ControlType.LabComboxPopupMutilText: // 弹出多选列表框 LabelComboxMutilPopupEdit comboxMutilPopupEdit = ctrol as LabelComboxMutilPopupEdit; comboxMutilPopupEdit.TextEdit.Size = new Size(Convert.ToInt32(comboxMutilPopupEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(comboxMutilPopupEdit.TextEdit.Height * heightZoomValue)); comboxMutilPopupEdit.TextEdit.Font = new Font(comboxMutilPopupEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(comboxMutilPopupEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); comboxMutilPopupEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabRadioGroupValue: case ControlType.LabRadioGroupText: // 单选按钮组 LabelRadioButtonGroupEdit radioButtonGroupEdit = ctrol as LabelRadioButtonGroupEdit; radioButtonGroupEdit.TextEdit.Size = new Size(Convert.ToInt32(radioButtonGroupEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(radioButtonGroupEdit.TextEdit.Height * heightZoomValue)); radioButtonGroupEdit.TextEdit.Font = new Font(radioButtonGroupEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(radioButtonGroupEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); radioButtonGroupEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabIntExtend: // 数字扩展 LabelIntExtendEdit intExtendEdit = ctrol as LabelIntExtendEdit; intExtendEdit.TextEdit.Size = new Size(Convert.ToInt32(intExtendEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(intExtendEdit.TextEdit.Height * heightZoomValue)); intExtendEdit.TextEdit.Font = new Font(intExtendEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(intExtendEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); intExtendEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabGridPopupValue: case ControlType.LabGridPopupText: case ControlType.LabGridPopupMutilValue: case ControlType.LabGridPopupMutilText: LabelGridSelectEdit gridSelectEdit = ctrol as LabelGridSelectEdit; gridSelectEdit.TextEdit.Size = new Size(Convert.ToInt32(gridSelectEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(gridSelectEdit.TextEdit.Height * heightZoomValue)); gridSelectEdit.TextEdit.Font = new Font(gridSelectEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(gridSelectEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); gridSelectEdit.TextEdit.Tag = "Changed"; break; case ControlType.LabSelectReturnId: case ControlType.LabSelectReturnText: LabelMultiAutoTextEdit4 moduleReturnsId = ctrol as LabelMultiAutoTextEdit4; moduleReturnsId.TextEdit.Size = new Size(Convert.ToInt32(moduleReturnsId.TextEdit.Width * widthZoomValue), Convert.ToInt32(moduleReturnsId.TextEdit.Height * heightZoomValue)); moduleReturnsId.TextEdit.Font = new Font(moduleReturnsId.TextEdit.Font.OriginalFontName, Convert.ToSingle(moduleReturnsId.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); moduleReturnsId.TextEdit.Tag = "Changed"; break; case ControlType.LabSelectReturnIdNew: case ControlType.LabSelectReturnTextNew: LabelMultiAutoTextEdit4 moduleReturnsIdNew = ctrol as LabelMultiAutoTextEdit4; moduleReturnsIdNew.TextEdit.Size = new Size(Convert.ToInt32(moduleReturnsIdNew.TextEdit.Width * widthZoomValue), Convert.ToInt32(moduleReturnsIdNew.TextEdit.Height * heightZoomValue)); moduleReturnsIdNew.TextEdit.Font = new Font(moduleReturnsIdNew.TextEdit.Font.OriginalFontName, Convert.ToSingle(moduleReturnsIdNew.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); moduleReturnsIdNew.TextEdit.Tag = "Changed"; break; case ControlType.LabText: // 文本控件 LabelTextEdit textEdit = ctrol as LabelTextEdit; textEdit.TextEdit.Font = new Font(textEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(textEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); textEdit.TextEdit.Size = new Size(Convert.ToInt32(textEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(textEdit.TextEdit.Height * heightZoomValue)); textEdit.TextEdit.Tag = "Changed"; break; } } } if (ctrol is Lskj.Control.AutoGridLookUp) { if ((ctrol as Lskj.Control.AutoGridLookUp)._popup.Tag != "Changed") { ctrol.Width = Convert.ToInt32(ctrol.Width * widthZoomValue); ctrol.Height = Convert.ToInt32(ctrol.Height * heightZoomValue); ctrol.Font = new Font(ctrol.Font.OriginalFontName, Convert.ToSingle(ctrol.Font.Size * fontZoomValue * fontZoomValue)); ctrol.Location = new Point(Convert.ToInt32(ctrol.Location.X * widthZoomValue), Convert.ToInt32(ctrol.Location.Y * heightZoomValue)); DevExpress.XtraGrid.Views.Grid.GridView GridView = (ctrol as Lskj.Control.AutoGridLookUp)._popup.GridViewObj; GridView.FooterPanelHeight = Convert.ToInt32(GridView.FooterPanelHeight * heightZoomValue); GridView.Appearance.Row.Font = new Font(GridView.Appearance.HeaderPanel.Font.OriginalFontName, Convert.ToSingle(GridView.Appearance.HeaderPanel.Font.Size * fontZoomValue * fontZoomValue)); GridView.Appearance.HeaderPanel.Font = new Font(GridView.Appearance.HeaderPanel.Font.OriginalFontName, Convert.ToSingle(GridView.Appearance.HeaderPanel.Font.Size * fontZoomValue * fontZoomValue)); GridView.Appearance.FooterPanel.Font = new Font(GridView.Appearance.FooterPanel.Font.OriginalFontName, Convert.ToSingle(GridView.Appearance.FooterPanel.Font.Size * fontZoomValue * fontZoomValue)); } } if (ctrol is Lskj.Control.LabelDateEdit && (ctrol as Lskj.Control.LabelDateEdit).TextEdit.Tag != "Changed") { Lskj.Control.LabelDateEdit dateEdit = ctrol as Lskj.Control.LabelDateEdit; dateEdit.TextEdit.Size = new Size(Convert.ToInt32(dateEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(dateEdit.TextEdit.Height * heightZoomValue)); dateEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(dateEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(dateEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); dateEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(dateEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(dateEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); dateEdit.TextEdit.Font = new Font(dateEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(dateEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); } if (ctrol is Lskj.Control.LabelComboxEdit && (ctrol as Lskj.Control.LabelComboxEdit).TextEdit.Tag != "Changed") { LabelComboxEdit comboxEdit = ctrol as LabelComboxEdit; comboxEdit.TextEdit.Size = new Size(Convert.ToInt32(comboxEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(comboxEdit.TextEdit.Height * heightZoomValue)); comboxEdit.TextEdit.Properties.PopupFormSize = new System.Drawing.Size(Convert.ToInt32(comboxEdit.TextEdit.Properties.PopupFormSize.Width * widthZoomValue), Convert.ToInt32(comboxEdit.TextEdit.Properties.PopupFormSize.Height * heightZoomValue)); comboxEdit.TextEdit.Properties.AppearanceDropDown.Font = new Font(comboxEdit.TextEdit.Properties.AppearanceDropDown.Font.OriginalFontName, Convert.ToSingle(comboxEdit.TextEdit.Properties.AppearanceDropDown.Font.Size * fontZoomValue * fontZoomValue)); comboxEdit.TextEdit.Font = new Font(comboxEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(comboxEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); } if (ctrol is Lskj.Control.LabelTextEdit && (ctrol as Lskj.Control.LabelTextEdit).TextEdit.Tag != "Changed") { LabelTextEdit textEdit = ctrol as LabelTextEdit; textEdit.TextEdit.Font = new Font(textEdit.TextEdit.Font.OriginalFontName, Convert.ToSingle(textEdit.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); textEdit.TextEdit.Size = new Size(Convert.ToInt32(textEdit.TextEdit.Width * widthZoomValue), Convert.ToInt32(textEdit.TextEdit.Height * heightZoomValue)); } if (ctrol is Lskj.Control.GridControlEx) { Lskj.Control.GridControlEx gridControl = ctrol as Lskj.Control.GridControlEx; gridControl.GridView.FooterPanelHeight = Convert.ToInt32(gridControl.GridView.FooterPanelHeight * heightZoomValue); gridControl.GridView.Appearance.Row.Font = new Font(gridControl.GridView.Appearance.HeaderPanel.Font.OriginalFontName, Convert.ToSingle(gridControl.GridView.Appearance.HeaderPanel.Font.Size * fontZoomValue * fontZoomValue)); gridControl.GridView.Appearance.HeaderPanel.Font = new Font(gridControl.GridView.Appearance.HeaderPanel.Font.OriginalFontName, Convert.ToSingle(gridControl.GridView.Appearance.HeaderPanel.Font.Size * fontZoomValue * fontZoomValue)); gridControl.GridView.Appearance.FooterPanel.Font = new Font(gridControl.GridView.Appearance.FooterPanel.Font.OriginalFontName, Convert.ToSingle(gridControl.GridView.Appearance.FooterPanel.Font.Size * fontZoomValue * fontZoomValue)); } if (ctrol is DevExpress.XtraTab.XtraTabControl) { DevExpress.XtraTab.XtraTabControl tabControl = ctrol as DevExpress.XtraTab.XtraTabControl; tabControl.TabPages.CollectionChanged += TabPages_CollectionChanged; foreach (DevExpress.XtraTab.XtraTabPage tabPage in tabControl.TabPages) { tabPage.Appearance.Header.Font = new Font(tabPage.Appearance.Header.Font.OriginalFontName, Convert.ToSingle(tabPage.Appearance.Header.Font.Size * fontZoomValue * fontZoomValue)); } } ControllInitializeSize(ctrol); } else { if (ctrol is System.Windows.Forms.MenuStrip) { foreach (System.Windows.Forms.ToolStripMenuItem item in (ctrol as System.Windows.Forms.MenuStrip).Items) { item.Font = new Font(item.Font.OriginalFontName, Convert.ToSingle(item.Font.Size * fontZoomValue * fontZoomValue)); ForEachMenu(item); } } SizeChange(ctrol); } } } #endregion #region 更改子控件大小 /// /// 说明:更改子控件大小 /// 创建人:唐德馨 /// 创建日期:2021-09-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private static void SizeChange(System.Windows.Forms.Control Control) { if (Control.BackgroundImage != null) { Image image = Control.BackgroundImage; Size size = new Size(Convert.ToInt32(Control.BackgroundImage.Width * widthZoomValue), Convert.ToInt32(Control.BackgroundImage.Height * heightZoomValue)); Control.BackgroundImage = resizeImage(image, size); } if (Control is DevExpress.XtraEditors.DropDownButton)//下拉按钮 { DevExpress.XtraBars.PopupMenu popMenu = (Control as DevExpress.XtraEditors.DropDownButton).DropDownControl as DevExpress.XtraBars.PopupMenu; popMenu.MenuAppearance.Menu.Font = new Font(popMenu.MenuAppearance.Menu.Font.OriginalFontName, Convert.ToSingle(popMenu.MenuAppearance.Menu.Font.Size * fontZoomValue * fontZoomValue)); popMenu.MenuBarWidth = Convert.ToInt32(popMenu.MenuBarWidth * widthZoomValue); } if (!(Control.Anchor == (AnchorStyles.Bottom | AnchorStyles.Right) || Control.Anchor == (AnchorStyles.Top | AnchorStyles.Right))) Control.Location = new Point(Convert.ToInt32(Control.Location.X * widthZoomValue), Convert.ToInt32(Control.Location.Y * heightZoomValue)); else { double widthValue = Control.Width - Control.Width * widthZoomValue; double locationValue = Control.Location.X - Control.Location.X * widthZoomValue; Control.Location = new Point(Convert.ToInt32(Control.Location.X * widthZoomValue + widthValue + locationValue), Convert.ToInt32(Control.Location.Y * heightZoomValue)); } Control.Width = Convert.ToInt32(Control.Width * widthZoomValue); Control.Height = Convert.ToInt32(Control.Height * heightZoomValue); if (Control.Font.Bold == true) Control.Font = new Font(Control.Font.OriginalFontName, Convert.ToSingle(Control.Font.Size * fontZoomValue * fontZoomValue), FontStyle.Bold); else Control.Font = new Font(Control.Font.OriginalFontName, Convert.ToSingle(Control.Font.Size * fontZoomValue * fontZoomValue)); } #endregion #region 更改控件图片大小 /// /// 说明:更改菜单控件大小 /// 创建人:唐德馨 /// 创建日期:2021-09-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private static System.Drawing.Image resizeImage(System.Drawing.Image imgToResize, Size size) { //获取图片宽度 int sourceWidth = imgToResize.Width; //获取图片高度 int sourceHeight = imgToResize.Height; float nPercent = 0; float nPercentW = 0; float nPercentH = 0; //计算宽度的缩放比例 nPercentW = ((float)size.Width / (float)sourceWidth); //计算高度的缩放比例 nPercentH = ((float)size.Height / (float)sourceHeight); if (nPercentH < nPercentW) nPercent = nPercentH; else nPercent = nPercentW; //期望的宽度 int destWidth = (int)(sourceWidth * nPercent); //期望的高度 int destHeight = (int)(sourceHeight * nPercent); Bitmap b = new Bitmap(destWidth, destHeight); Graphics g = Graphics.FromImage((System.Drawing.Image)b); g.InterpolationMode = InterpolationMode.HighQualityBicubic; //绘制图像 g.DrawImage(imgToResize, 0, 0, destWidth, destHeight); g.Dispose(); return (System.Drawing.Image)b; } #endregion #region 更改菜单控件大小 /// /// 说明:更改菜单控件大小 /// 创建人:唐德馨 /// 创建日期:2021-09-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private static void ForEachMenu(ToolStripMenuItem menuItems) { if (menuItems.DropDownItems.Count > 0) { foreach (ToolStripMenuItem item in menuItems.DropDownItems) { item.Font = new Font(item.Font.OriginalFontName, Convert.ToSingle(item.Font.Size * fontZoomValue)); ForEachMenu(item); } } } #endregion #region 初始化分割条位置 /// /// 说明:初始化缩放比例 /// 创建人:唐德馨 /// 创建日期:2021-09-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private static double InitSpliterPosition() { string spliterPosition = IniHelper.Read(string.Format("DefaultControlScaling_{0}", "Save")); double result = 1; if (!string.IsNullOrEmpty(spliterPosition)) result = Convert.ToDouble(spliterPosition); return result; } #endregion #endregion #region 事件 #region 页签控件个数改变时更改标题字体大小 /// /// 说明:页签控件个数改变时更改标题字体大小 /// 创建人:唐德馨 /// 创建日期:2021-09-03 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private static void TabPages_CollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) { try { DevExpress.XtraTab.XtraTabPage tabPage = e.Element as DevExpress.XtraTab.XtraTabPage; if (e.Action.ToString().Equals("Add")) { tabPage.Appearance.Header.Font = new Font(tabPage.Appearance.Header.Font.OriginalFontName, Convert.ToSingle(tabPage.Appearance.Header.Font.Size * fontZoomValue * fontZoomValue)); } } catch (Exception ex) { string Message = Lskj.Business.Impl.ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } #endregion #endregion } }