BaseContentsFormMain.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.ComponentLibrary
  10. {
  11. /// <summary>
  12. /// 所有内容窗体的基窗体
  13. /// </summary>
  14. public partial class BaseContentsFormMain : BaseFormRelease, LYFZ.StandardInterface.IFormMain
  15. {
  16. UCNavigationTool currentUcNavigationTool = new UCNavigationTool();
  17. public BaseContentsFormMain()
  18. {
  19. InitializeComponent();
  20. // this.ctlScrollBarH.Scroll += new EventHandler(ctlScrollBarH_Scroll);
  21. // this.ctlScrollBarV.Scroll += new EventHandler(ctlScrollBarV_Scroll);
  22. this.plExMainContainer.Resize += new EventHandler(plExMainContainer_Resize);
  23. this.plFormMainContent.Resize += new EventHandler(plFormMainContent_Resize);
  24. this.plExMainContainer.MouseMove += plExMainContainer_MouseMove;
  25. this.plExMainContainer.Click += plExMainContainer_Click;
  26. this.Resize += new EventHandler(BaseContentsFormRelease_Resize);
  27. this.Shown += new EventHandler(BaseContentsFormRelease_Shown);
  28. this.isOverrideOnPaint = true;
  29. IsCustomScrollBar = false;
  30. this.plExMainContainer.MouseWheel += new MouseEventHandler(plExMainContainer_MouseWheel);
  31. // this.ctlScrollBarV.MouseWheel += new MouseEventHandler(ctlScrollBarV_MouseWheel);
  32. this.plExMainContainer.BackColor = LYFZ.ComponentLibrary.GetUIResources.FrmContentBackgroundColor;
  33. this.FormClosing += BaseContentsFormMain_FormClosing;
  34. this.FormClosed += BaseContentsFormMain_FormClosed;
  35. //this.ctlScrollBarV.MouseEnter += ctlScrollBarV_MouseEnter;
  36. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
  37. }
  38. bool isShowWelcomeForm = true;
  39. public void ClosThisForm()
  40. {
  41. isShowWelcomeForm = false;
  42. this.Close();
  43. }
  44. /// <summary>
  45. /// 等待释放的控件集合
  46. /// </summary>
  47. static List<Form> WaitDisposeAllControls = new List<Form>();
  48. void BaseContentsFormMain_FormClosed(object sender, FormClosedEventArgs e)
  49. {
  50. /* try
  51. {
  52. // this.SuspendLayout();
  53. // ControlsDispose(this.Controls);
  54. }
  55. catch { }*/
  56. //
  57. }
  58. public static void ControlsDispose(System.Windows.Forms.Control.ControlCollection controls)
  59. {
  60. int count = controls.Count;
  61. if (count > 0)
  62. {
  63. List<System.Windows.Forms.Control> delList = new List<Control>();
  64. for (int i = 0; i < count; i++)
  65. {
  66. System.Windows.Forms.Control control = controls[i];
  67. /* if (control.Controls.Count > 0)
  68. {
  69. ControlsDispose(control.Controls);
  70. }*/
  71. if (control.GetType() == typeof(System.Windows.Forms.Panel)
  72. || control.GetType() == typeof(System.Windows.Forms.Label)
  73. || control.GetType() == typeof(LYFZ.ComponentLibrary.PanelEx)
  74. || control.GetType() == typeof(LYFZ.ComponentLibrary.LabelEx)
  75. || control.GetType() == typeof(LYFZ.ComponentLibrary.CheckBoxEx)
  76. || control.GetType() == typeof(System.Windows.Forms.CheckBox))
  77. {
  78. if (control != null && !control.IsDisposed)
  79. {
  80. delList.Add(control);
  81. }
  82. }
  83. }
  84. count = delList.Count;
  85. for (int i = 0; i < count; i++)
  86. {
  87. delList[i].Dispose();
  88. }
  89. delList.Clear();
  90. delList = null;
  91. }
  92. }
  93. void ctlScrollBarV_MouseEnter(object sender, EventArgs e)
  94. {
  95. RefreshCtlScrollBarValue();
  96. }
  97. /// <summary>
  98. /// 刷新滚动条值
  99. /// </summary>
  100. void RefreshCtlScrollBarValue() {
  101. // this.ctlScrollBarV.Value = Math.Abs(this.plExMainContainer.AutoScrollPosition.Y);
  102. // this.ctlScrollBarH.Value = Math.Abs(this.plExMainContainer.AutoScrollPosition.X);
  103. // scrollY = ctlScrollBarV.Value;
  104. // scrollX = ctlScrollBarH.Value;
  105. }
  106. void plExMainContainer_Click(object sender, EventArgs e)
  107. {
  108. this.plExMainContainer.Focus();
  109. }
  110. void plExMainContainer_MouseMove(object sender, MouseEventArgs e)
  111. {
  112. LoginAgain();
  113. RefreshCtlScrollBarValue();
  114. }
  115. bool isClosedLoadWelcomeForm = true;
  116. public bool IsClosedLoadWelcomeForm
  117. {
  118. get { return isClosedLoadWelcomeForm; }
  119. set { isClosedLoadWelcomeForm = value; }
  120. }
  121. void BaseContentsFormMain_FormClosing(object sender, FormClosingEventArgs e)
  122. { //typeof(LYFZ.StandardInterface.IToolMenuClick).IsAssignableFrom(this.ParentForm.GetType())
  123. //用于判断父窗体是否实现了指定的LYFZ.StandardInterface.IToolMenuClick接口
  124. try
  125. {
  126. if (this.GetType().FullName != "LYFZ.Software.PhotoStudio.frmWelcomeForm" && isShowWelcomeForm)
  127. {
  128. if (this.ParentForm != null)
  129. {
  130. if (typeof(LYFZ.StandardInterface.IToolMenuClick).IsAssignableFrom(this.ParentForm.GetType()))
  131. {
  132. LYFZ.StandardInterface.IToolMenuClick iParentForm = (LYFZ.StandardInterface.IToolMenuClick)this.ParentForm;
  133. iParentForm.ShowForm("LYFZ.Software.PhotoStudio.frmWelcomeForm", "SPS", "ShowEmbedded");
  134. }
  135. }
  136. }
  137. if (this.IsLoginValidation)
  138. {
  139. LYFZ.BLL.BLL_ErpUser.UpdateDynamicTimeAccount();
  140. }
  141. }
  142. catch { }
  143. finally {
  144. isShowWelcomeForm = true;
  145. }
  146. }
  147. void InitializeUcNavigationTool()
  148. {
  149. if (isShowUcNavigationTool)
  150. {
  151. if (this.plFormMainContent.Controls.Find("currentUcNavigationTool01", false).Length <= 0)
  152. {
  153. currentUcNavigationTool.Width = this.plFormMainContent.Width;
  154. currentUcNavigationTool.Visible = this.isShowUcNavigationTool;
  155. currentUcNavigationTool.Location = new Point(0, 0);
  156. currentUcNavigationTool.Name = "currentUcNavigationTool01";
  157. this.plFormMainContent.Controls.Add(currentUcNavigationTool);
  158. }
  159. }
  160. else {
  161. try
  162. {
  163. this.plFormMainContent.Controls.Remove(currentUcNavigationTool);
  164. }
  165. catch { }
  166. }
  167. }
  168. void SetUcNavigationTool()
  169. {
  170. if (this.isShowUcNavigationTool)
  171. {
  172. currentUcNavigationTool.Width = this.plFormMainContent.Width;
  173. this.plExMainContainer.Location = new Point(0, 40);
  174. }
  175. else
  176. {
  177. this.plExMainContainer.Location = new Point(0, 0);
  178. }
  179. }
  180. /// <summary>
  181. /// 设置导航
  182. /// </summary>
  183. public UCNavigationTool UcNavigationTool
  184. {
  185. get { return this.currentUcNavigationTool; }
  186. }
  187. bool isShowUcNavigationTool = false;
  188. /// <summary>
  189. /// 是否显示导航栏
  190. /// </summary>
  191. public bool IsShowUcNavigationTool
  192. {
  193. get { return isShowUcNavigationTool; }
  194. set { isShowUcNavigationTool = value;
  195. InitializeUcNavigationTool();
  196. plFormMainContent_Resize(null,null);
  197. Invalidate(false); }
  198. }
  199. /// <summary>
  200. /// 重载新窗体
  201. /// </summary>
  202. /// <param name="objNewForm"></param>
  203. public void ReloadNewForm(object objNewForm)
  204. {
  205. LYFZ.ComponentLibrary.BaseContentsFormMain frm = (LYFZ.ComponentLibrary.BaseContentsFormMain)objNewForm;
  206. frm.TopLevel = this.TopLevel;
  207. frm.IsShadow = this.IsShadow;
  208. frm.MaximizeBox = this.MaximizeBox;
  209. frm.MinimizeBox = this.MinimizeBox;
  210. frm.IsShowCloseBox = this.IsShowCloseBox;
  211. frm.TitleBgImageHeight = this.TitleBgImageHeight;
  212. frm.BottomBgImageHeight = this.BottomBgImageHeight;
  213. frm.IsMaximized = this.IsMaximized;
  214. frm.FormMobile = this.FormMobile;
  215. frm.IsUserControlsSize = this.IsUserControlsSize;
  216. frm.Dock = this.Dock;
  217. frm.IsCustomScrollBar = this.IsCustomScrollBar;
  218. frm.Parent = this.Parent;
  219. frm.IsShowBtnFormMenu = this.IsShowBtnFormMenu;
  220. frm.IsShowBtnFormSkin = this.IsShowBtnFormMenu;
  221. frm.IsCloseForm = this.IsCloseForm;
  222. frm.IsMinimize = this.IsMinimize;
  223. if (!frm.IsMaximized && !frm.IsMinimize && !frm.IsCloseForm)
  224. {
  225. frm.SetCoverageTitleButtonEvent();
  226. }
  227. frm.Show();
  228. this.Close();
  229. this.Dispose();
  230. }
  231. /// <summary>
  232. /// 设置发生错误时显示信息
  233. /// </summary>
  234. /// <param name="msg"></param>
  235. public void SetError(string msg)
  236. {
  237. LabelEx tryLabMsg = new LabelEx();
  238. tryLabMsg.Text = msg;
  239. tryLabMsg.ForeColor =Color.Red;
  240. tryLabMsg.Font = new System.Drawing.Font("宋体", 12);
  241. tryLabMsg.Padding = new Padding(10);
  242. tryLabMsg.Dock = DockStyle.Fill;
  243. this.plExMainContainer.Controls.Add(tryLabMsg);
  244. }
  245. /// <summary>
  246. /// 公共plExMainContainer对象
  247. /// </summary>
  248. // public LYFZ.ComponentLibrary.PanelEx PublicContainer = null;
  249. /// <summary>
  250. /// 系统菜单事件接口
  251. /// </summary>
  252. public LYFZ.StandardInterface.IMenuClick iMenuClick = null;
  253. /// <summary>
  254. /// 系统菜单事件设置
  255. /// </summary>
  256. /// <param name="menuItem"></param>
  257. protected override void SetMenuItem_Click(ToolStripMenuItem menuItem)
  258. {
  259. if (iMenuClick != null)
  260. iMenuClick.SetIMenuItem_Click(menuItem);
  261. }
  262. /// <summary>
  263. /// 覆盖窗体标题栏上最小化、最大化和关闭按钮的事件
  264. /// </summary>
  265. public void SetCoverageTitleButtonEvent()
  266. {
  267. this.btnAppFormExit.Click += new EventHandler(ParentFormBtnAppFormExit_Click);
  268. this.btnAppFormMaximize.Click += new EventHandler(ParentFormBtnAppFormMaximize_Click);
  269. this.btnAppFormMinimize.Click += new EventHandler(ParentFormBtnAppFormMinimize_Click);
  270. isCoverageTitleButtonEvent = true;
  271. }
  272. bool isCoverageTitleButtonEvent = false;
  273. protected override void btnAppFormMaximize_Move(object sender, EventArgs e)
  274. {
  275. if (isCoverageTitleButtonEvent)
  276. {
  277. this.SetFormMzximizeBtn(this.ParentForm.WindowState);
  278. }
  279. else
  280. {
  281. base.btnAppFormMaximize_Move(sender, e);
  282. }
  283. }
  284. /// <summary>
  285. /// 最小化父窗体
  286. /// </summary>
  287. /// <param name="sender"></param>
  288. /// <param name="e"></param>
  289. protected virtual void ParentFormBtnAppFormMinimize_Click(object sender, EventArgs e)
  290. {
  291. this.ParentForm.WindowState = FormWindowState.Minimized;
  292. }
  293. /// <summary>
  294. /// 最大化父窗体
  295. /// </summary>
  296. /// <param name="sender"></param>
  297. /// <param name="e"></param>
  298. protected virtual void ParentFormBtnAppFormMaximize_Click(object sender, EventArgs e)
  299. {
  300. if (this.ParentForm.WindowState == FormWindowState.Normal)
  301. {
  302. this.ParentForm.WindowState = FormWindowState.Maximized;
  303. }
  304. else {
  305. this.ParentForm.WindowState = FormWindowState.Normal;
  306. }
  307. }
  308. /// <summary>
  309. /// 关闭父窗体
  310. /// </summary>
  311. /// <param name="sender"></param>
  312. /// <param name="e"></param>
  313. protected virtual void ParentFormBtnAppFormExit_Click(object sender, EventArgs e)
  314. {
  315. this.ParentForm.Close();
  316. }
  317. #region 滚动轮滚动时滚动窗体
  318. /// <summary>
  319. /// 获取滚动轮滚动的值
  320. /// </summary>
  321. /// <param name="e"></param>
  322. /// <returns></returns>
  323. int getMouseWheelDelta(MouseEventArgs e)
  324. {
  325. // this.Text = this.ctlScrollBarV.Maximum + "/" + this.ctlScrollBarV.LargeChange.ToString() + "*" + ctlScrollBarV.Value;
  326. //e.Delta 在正负 120 之间
  327. //滚动条要滚动的值在 0 到 this.ctlScrollBarV.Maximum - this.ctlScrollBarV.LargeChange 之间
  328. int tempDelta = -(e.Delta);
  329. // if (tempDelta < this.ctlScrollBarV.Minimum)
  330. // {
  331. // tempDelta = this.ctlScrollBarV.Minimum;
  332. // }
  333. //int tempDifference = this.ctlScrollBarV.Maximum - this.ctlScrollBarV.LargeChange;
  334. // int tempScrollBar = tempDifference / 120;
  335. /* if (tempScrollBar <= 0)
  336. {
  337. tempScrollBar = 1;
  338. }
  339. if (tempDelta == 120)
  340. {
  341. tempDelta = tempDifference;
  342. }
  343. else
  344. {
  345. tempDelta = tempDelta * tempScrollBar;
  346. if (tempDelta > tempDifference)
  347. {
  348. tempDelta = tempDifference;
  349. }
  350. }*/
  351. return tempDelta;
  352. }
  353. void ctlScrollBarV_MouseWheel(object sender, MouseEventArgs e)
  354. {
  355. //this.ctlScrollBarV.Value = getMouseWheelDelta(e);
  356. //垂直滚动
  357. // scrollY = ctlScrollBarV.Value;
  358. // this.plExMainContainer.AutoScrollPosition = new Point(scrollX, ctlScrollBarV.Value);
  359. }
  360. void plExMainContainer_MouseWheel(object sender, MouseEventArgs e)
  361. {
  362. // this.ctlScrollBarV.Value = getMouseWheelDelta(e);
  363. //垂直滚动
  364. // scrollY = ctlScrollBarV.Value;
  365. }
  366. #endregion
  367. /// <summary>
  368. /// 记录滚动条显示时需要的宽度
  369. /// </summary>
  370. int PanlOffset = 0;
  371. /// <summary>
  372. /// 首次显示时
  373. /// </summary>
  374. /// <param name="sender"></param>
  375. /// <param name="e"></param>
  376. void BaseContentsFormRelease_Shown(object sender, EventArgs e)
  377. {
  378. if (IsCustomScrollBar)
  379. {
  380. PanlOffset = 20;
  381. }
  382. InitializeUcNavigationTool();
  383. ResetControls();
  384. SetUcNavigationTool();
  385. }
  386. /// <summary>
  387. /// 窗体大小变化时
  388. /// </summary>
  389. /// <param name="sender"></param>
  390. /// <param name="e"></param>
  391. void BaseContentsFormRelease_Resize(object sender, EventArgs e)
  392. {
  393. isSetplExMainContainerFocus = true;
  394. ResetControls();
  395. }
  396. /// <summary>
  397. /// 父panl大小变化时
  398. /// </summary>
  399. /// <param name="sender"></param>
  400. /// <param name="e"></param>
  401. void plFormMainContent_Resize(object sender, EventArgs e)
  402. {
  403. isSetplExMainContainerFocus = true;
  404. ResetControls();
  405. SetUcNavigationTool();
  406. }
  407. /// <summary>
  408. /// 子panl大小变化时
  409. /// </summary>
  410. /// <param name="sender"></param>
  411. /// <param name="e"></param>
  412. void plExMainContainer_Resize(object sender, EventArgs e)
  413. {
  414. if (!this.TopLevel)
  415. {
  416. ResetControls();
  417. }
  418. isSetplExMainContainerFocus = true;
  419. }
  420. /// <summary>
  421. /// 重设相关控件
  422. /// </summary>
  423. void ResetControls()
  424. {
  425. SetplExMainContainerSize(PanlOffset);
  426. SetScrollBarAttr();
  427. InitializeScrollBar();
  428. }
  429. //两个变量记录水平或垂直方向的滚动条位置,已达到同步效果
  430. //int scrollX = 0;
  431. //int scrollY = 0;
  432. bool isShowCtlScrollBarV = false;//记录是否显示垂直滚动条
  433. bool isShowCtlScrollBarH = false;//记录是否显示水平滚动条
  434. void ctlScrollBarV_Scroll(object sender, EventArgs e)
  435. {
  436. //垂直滚动
  437. // scrollY = ctlScrollBarV.Value;
  438. // this.plExMainContainer.AutoScrollPosition = new Point(scrollX, ctlScrollBarV.Value);
  439. if (this.IsLoginValidation)
  440. {
  441. LYFZ.BLL.BLL_ErpUser.UpdateDynamicTimeAccount();
  442. }
  443. }
  444. void ctlScrollBarH_Scroll(object sender, EventArgs e)
  445. {
  446. //水平滚动
  447. // scrollX = ctlScrollBarH.Value;
  448. // this.plExMainContainer.AutoScrollPosition = new Point(ctlScrollBarH.Value, scrollY);
  449. if (this.IsLoginValidation)
  450. {
  451. LYFZ.BLL.BLL_ErpUser.UpdateDynamicTimeAccount();
  452. }
  453. }
  454. /// <summary>
  455. /// 重绘控件
  456. /// </summary>
  457. /// <param name="e"></param>
  458. protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  459. {
  460. base.OnPaint(e);
  461. SetplExMainContainerSize(PanlOffset);
  462. }
  463. /// <summary>
  464. /// 设置内容容器的大小和位置
  465. /// </summary>
  466. public void SetplExMainContainerSize(int offset = 0)
  467. {
  468. //父panl大小和位置
  469. this.plFormMainContent.Location = new Point(0, this.TitleBgImageHeight);
  470. //子panl大小和位置
  471. isShowCtlScrollBarH = this.plExMainContainer.HorizontalScroll.Visible;
  472. isShowCtlScrollBarV = this.plExMainContainer.VerticalScroll.Visible;
  473. //导航工具栏高度
  474. int UcNavigationToolHeight = 0;
  475. if (this.isShowUcNavigationTool) {
  476. UcNavigationToolHeight = this.currentUcNavigationTool.Height;
  477. }
  478. if (IsCustomScrollBar)
  479. {
  480. if (isShowCtlScrollBarV)
  481. {
  482. // this.ctlScrollBarV.Visible = true;
  483. this.plFormMainContent.Width = this.Width - offset;
  484. this.plExMainContainer.Width = this.plFormMainContent.Width + offset - 4;
  485. }
  486. else
  487. {
  488. // this.ctlScrollBarV.Visible = false;
  489. this.plFormMainContent.Width = this.Width;
  490. this.plExMainContainer.Width = this.plFormMainContent.Width;
  491. }
  492. if (isShowCtlScrollBarH)
  493. {
  494. // this.ctlScrollBarH.Visible = true;
  495. this.plFormMainContent.Height = this.Height - this.TitleBgImageHeight - this.BottomBgImageHeight - offset;
  496. this.plExMainContainer.Height = this.plFormMainContent.Height + offset - 4 - UcNavigationToolHeight;
  497. }
  498. else
  499. {
  500. // this.ctlScrollBarH.Visible = false;
  501. this.plFormMainContent.Height = this.Height - this.TitleBgImageHeight - this.BottomBgImageHeight;
  502. this.plExMainContainer.Height = this.plFormMainContent.Height - UcNavigationToolHeight;
  503. }
  504. }
  505. else
  506. {
  507. this.plFormMainContent.Width = this.Width;
  508. this.plFormMainContent.Height = this.Height - this.TitleBgImageHeight - this.BottomBgImageHeight;
  509. this.plExMainContainer.Width = this.plFormMainContent.Width;
  510. this.plExMainContainer.Height = this.plFormMainContent.Height - UcNavigationToolHeight;
  511. }
  512. }
  513. /// <summary>
  514. /// 初始化滚动条
  515. /// </summary>
  516. public void InitializeScrollBar()
  517. {
  518. // this.plExMainContainer.AutoScrollPosition = new Point(scrollX, scrollY);
  519. /* this.ctlScrollBarV.Minimum = 0;
  520. this.ctlScrollBarV.Maximum = this.plExMainContainer.DisplayRectangle.Height;
  521. this.ctlScrollBarV.LargeChange = ctlScrollBarV.Maximum / ctlScrollBarV.Height + this.plExMainContainer.Height - 20;
  522. this.ctlScrollBarV.Value = Math.Abs(this.plExMainContainer.AutoScrollPosition.Y);
  523. this.ctlScrollBarH.Minimum = 0;
  524. this.ctlScrollBarH.Maximum = this.plExMainContainer.DisplayRectangle.Width;
  525. this.ctlScrollBarH.LargeChange = ctlScrollBarH.Maximum / ctlScrollBarH.Width + this.plExMainContainer.Width - 20;
  526. this.ctlScrollBarH.Value = Math.Abs(this.plExMainContainer.AutoScrollPosition.X);*/
  527. }
  528. /// <summary>
  529. /// 设置滚动条属性
  530. /// </summary>
  531. void SetScrollBarAttr()
  532. {
  533. if (IsCustomScrollBar)
  534. {
  535. // this.ctlScrollBarV.Location = new Point(this.plFormMainContent.Width, this.plFormMainContent.Location.Y);
  536. // this.ctlScrollBarH.Location = new Point(0, this.plFormMainContent.Location.Y + this.plFormMainContent.Height);
  537. // this.ctlScrollBarV.Size = new Size(this.ctlScrollBarV.Width, this.plFormMainContent.Height);
  538. // this.ctlScrollBarH.Size = new Size(this.plFormMainContent.Width, this.ctlScrollBarH.Height);
  539. // scrollX = this.ctlScrollBarH.Value;
  540. // scrollY = this.ctlScrollBarV.Value;
  541. }
  542. }
  543. bool isCustomScrollBar = false;
  544. /// <summary>
  545. /// 设置是否使用自定义滚动条
  546. /// </summary>
  547. [Browsable(false), Category("自定义窗体属性"), Description("设置是否使用自定义滚动条")]
  548. public bool IsCustomScrollBar
  549. {
  550. get { return isCustomScrollBar; }
  551. set { isCustomScrollBar = false; }
  552. }
  553. private bool isSetplExMainContainerFocus = true;
  554. bool isMouseEnterSetFocus = false;
  555. /// <summary>
  556. /// 是否鼠标进入窗体内容框时自动获取焦点
  557. /// </summary>
  558. [Browsable(false), Category("自定义窗体属性"), Description("是否鼠标进入窗体内容框时自动获取焦点")]
  559. public bool IsMouseEnterSetFocus
  560. {
  561. get { return isMouseEnterSetFocus; }
  562. set { isMouseEnterSetFocus = value; }
  563. }
  564. private void plExMainContainer_MouseEnter(object sender, EventArgs e)
  565. {
  566. if (IsMouseEnterSetFocus)
  567. {
  568. if (isSetplExMainContainerFocus)
  569. this.plExMainContainer.Focus();
  570. isSetplExMainContainerFocus = false;
  571. }
  572. }
  573. protected override void CreateHandle()
  574. {
  575. if (!IsHandleCreated)
  576. {
  577. try
  578. {
  579. base.CreateHandle();
  580. }
  581. catch { }
  582. finally
  583. {
  584. if (!IsHandleCreated)
  585. {
  586. base.RecreateHandle();
  587. }
  588. }
  589. }
  590. }
  591. }
  592. }