HeaderPanel.cs

Description du code

HeaderPanel.cs est un fichier du projet BrolDev.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/broldev/src/.

Projet BrolDev : Librairie de composants réutilisables pour les applications BrolDev en CSharp.

Code source ou contenu du fichier

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.Drawing.Drawing2D;
  8. using System.Drawing.Text;
  9. using System.Runtime.InteropServices;
  10. using System.Windows.Forms;
  11. using be.gaudry.model.enums;
  12. using be.gaudry.view.style;
  13. using be.gaudry.view;
  14. using be.gaudry.observer;
  15.  
  16. namespace KIS.Controls.Windows
  17. {
  18. [ToolboxBitmap (@"HeaderPanel.offScreenBmp")]
  19. public partial class HeaderPanel : Panel
  20. {
  21. private const int DEFAULT_BORDER_WIDTH = 1;
  22. private const int DEFAULT_SHADOW_WIDTH = 5;
  23. private const int DEFAULT_CAPTION_HEIGHT = 20;//SystemInformation.CaptionHeight;
  24.  
  25. // Window message constants
  26. private const int WM_NCCALCSIZE = 0x0083;
  27. private const int WM_NCPAINT = 0x0085;
  28.  
  29.  
  30. #region Member Variables
  31.  
  32. private int mint_CaptionHeight;
  33. private bool mbln_CaptionVisible = true;
  34. private bool mbln_Antialias = true;
  35. private string mstr_CaptionText;
  36. private Color mclr_CaptionBeginColor;
  37. private Color mclr_CaptionEndColor;
  38. private LinearGradientMode menm_CaptionGradientMode;
  39. private BORDER_POSITION menm_CaptionPosition;
  40.  
  41. private EventHandler rendererChangedEvent;
  42.  
  43. private Icon mico_Icon = null;
  44. private bool mbln_IconVisible = false;
  45.  
  46. private BORDER_STYLE menm_BorderStyle;
  47. private Color mclr_BorderColor;
  48.  
  49. private Color mclr_StartColor;
  50. private Color mclr_EndColor;
  51. private LinearGradientMode menm_GradientMode;
  52.  
  53. private bool useCaptionBrolDevStyle, useContentBrolDevStyle, useContentGradient, useBorderBrolDevStyle;
  54.  
  55. #endregion
  56.  
  57. #region Constructor
  58.  
  59. public HeaderPanel() : base()
  60. {
  61. InitializeComponent();
  62.  
  63. this.Font = new Font(SystemFonts.CaptionFont,
  64. SystemFonts.CaptionFont.Style);
  65. this.mstr_CaptionText = this.GetType().Name;
  66. this.mint_CaptionHeight = SystemInformation.CaptionHeight;
  67. this.mclr_CaptionBeginColor = StyleFactory.CustomSystemColors.ActiveCaption;
  68. this.mclr_CaptionEndColor = StyleFactory.CustomSystemColors.GradientActiveCaption;
  69. this.menm_CaptionGradientMode = LinearGradientMode.Vertical;
  70. this.menm_CaptionPosition = BORDER_POSITION.Top;
  71.  
  72. this.menm_BorderStyle = StyleFactory.BorderStyle;
  73. base.BorderStyle = 0;
  74. this.mclr_BorderColor = StyleFactory.CustomSystemColors.Menu;
  75.  
  76. this.mclr_StartColor = StyleFactory.CustomSystemColors.ControlLightLight;
  77. this.mclr_EndColor = StyleFactory.CustomSystemColors.Control;
  78. this.menm_GradientMode = LinearGradientMode.Vertical;
  79.  
  80. this.SetStyle(ControlStyles.ResizeRedraw, true);
  81. this.SetStyle(ControlStyles.UserPaint, true);
  82. this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  83. this.SetStyle(ControlStyles.DoubleBuffer, true);
  84.  
  85. useCaptionBrolDevStyle = true;
  86. useContentBrolDevStyle = true;
  87. useBorderBrolDevStyle = true;
  88. rendererChangedEvent = new EventHandler(onRendererChanged);
  89. //todo : find method to detach the delegate on dispose (this does not implements dispose)
  90. StyleFactory.Instance.onRendererChanged += rendererChangedEvent;
  91. setBrolDevStyle();
  92. }
  93.  
  94. #endregion
  95.  
  96. #region properties
  97. #region content
  98. [
  99. Description("Enable/Disable using gradient colors for the content. False to use only first color."),
  100. Category("Content"),
  101. DefaultValue(true),
  102. Browsable(true)
  103. ]
  104. public bool UseContentGradient
  105. {
  106. get
  107. {
  108. return useContentGradient;
  109. }
  110. set
  111. {
  112. useContentGradient = value;
  113. //todo : set values from renderer
  114. setBrolDevStyle();
  115. }
  116. }
  117. [
  118. Description("Enable/Disable using parent renderer colors for the content panel"),
  119. Category("Content"),
  120. DefaultValue(true),
  121. Browsable(true)
  122. ]
  123. public bool UseContentBrolDevStyle
  124. {
  125. get
  126. {
  127. return useContentBrolDevStyle;
  128. }
  129. set
  130. {
  131. useContentBrolDevStyle = value;
  132. setBrolDevStyle();
  133. }
  134. }
  135.  
  136. [
  137. Description("Change the starting color of gradient background. Has no effect if UseCustomRenderer is true."),
  138. Category("Content"),
  139. Browsable(true)
  140. ]
  141. public Color GradientStart
  142. {
  143. get
  144. {
  145. return mclr_StartColor;
  146. }
  147. set
  148. {
  149. if (!useContentBrolDevStyle)
  150. {
  151. mclr_StartColor = value;
  152. setBrolDevStyle();
  153. }
  154. }
  155. }
  156.  
  157. [
  158. Description("Change the end color of gradient background. Has no effect if UseCustomRenderer is true."),
  159. Category("Content"),
  160. Browsable(true)
  161. ]
  162. public Color GradientEnd
  163. {
  164. get
  165. {
  166. return mclr_EndColor;
  167. }
  168. set
  169. {
  170. if (!useContentBrolDevStyle)
  171. {
  172. mclr_EndColor = value;
  173. setBrolDevStyle();
  174. }
  175. }
  176. }
  177.  
  178. [
  179. Description("Change the background gradient direction"),
  180. Category("Content"),
  181. DefaultValue(LinearGradientMode.Vertical),
  182. Browsable(true)
  183. ]
  184. public LinearGradientMode GradientDirection
  185. {
  186. get
  187. {
  188. return menm_GradientMode;
  189. }
  190. set
  191. {
  192. menm_GradientMode = value;
  193. setBrolDevStyle();
  194. }
  195. }
  196. #endregion
  197.  
  198. #region border
  199.  
  200. [
  201. Description("Enable/Disable using parent renderer colors for the border"),
  202. Category("Border"),
  203. DefaultValue(true),
  204. Browsable(true)
  205. ]
  206. public bool UseBorderBrolDevStyle
  207. {
  208. get
  209. {
  210. return useBorderBrolDevStyle;
  211. }
  212. set
  213. {
  214. useBorderBrolDevStyle = value;
  215. Invalidate();
  216. }
  217. }
  218. [
  219. Description("Change style of the border"),
  220. Category("Border"),
  221. DefaultValue(BORDER_STYLE.Groove),
  222. Browsable(true)
  223. ]
  224. public new BORDER_STYLE BorderStyle
  225. {
  226. get
  227. {
  228. return menm_BorderStyle;
  229. }
  230. set
  231. {
  232. menm_BorderStyle = value;
  233. PerformLayout();
  234. setBrolDevStyle();
  235. }
  236. }
  237.  
  238. [
  239. Description("Change color of the border. Has no effect if UseCustomRenderer is true."),
  240. Category("Border"),
  241. Browsable(true)
  242. ]
  243. public Color BorderColor
  244. {
  245. get
  246. {
  247. return mclr_BorderColor;
  248. }
  249. set
  250. {
  251. if (!useContentBrolDevStyle)
  252. {
  253. mclr_BorderColor = value;
  254. setBrolDevStyle();
  255. }
  256. }
  257. }
  258. #endregion
  259.  
  260. #region caption
  261. [
  262. Description("Enable/Disable using parent renderer colors for the caption"),
  263. Category("Border"),
  264. DefaultValue(true),
  265. Browsable(true)
  266. ]
  267. public bool UseCaptionBrolDevStyle
  268. {
  269. get
  270. {
  271. return useCaptionBrolDevStyle;
  272. }
  273. set
  274. {
  275. useCaptionBrolDevStyle = value;
  276. //todo : set values from renderer
  277. setBrolDevStyle();
  278. }
  279. }
  280.  
  281. [
  282. Description("Enable/Disable antialiasing"),
  283. Category("Caption"),
  284. DefaultValue(false),
  285. Browsable(true)
  286. ]
  287. public bool TextAntialias
  288. {
  289. get
  290. {
  291. return mbln_Antialias;
  292. }
  293. set
  294. {
  295. mbln_Antialias = value;
  296. Invalidate();
  297. }
  298. }
  299.  
  300. [
  301. Description("Change the caption text to be displayed"),
  302. Category("Caption"),
  303. Browsable(true)
  304. ]
  305. public String CaptionText
  306. {
  307. get
  308. {
  309. return mstr_CaptionText;
  310. }
  311. set
  312. {
  313. mstr_CaptionText = value;
  314. Invalidate();
  315. }
  316. }
  317.  
  318. [
  319. Description("Show or hide the caption"),
  320. Category("Caption"),
  321. DefaultValue(true),
  322. Browsable(true)
  323. ]
  324. public bool CaptionVisible
  325. {
  326. get
  327. {
  328. return mbln_CaptionVisible;
  329. }
  330. set
  331. {
  332. mbln_CaptionVisible = value;
  333. Invalidate();
  334. }
  335. }
  336.  
  337. [
  338. Description("Change the caption height"),
  339. Category("Caption"),
  340. DefaultValue(DEFAULT_CAPTION_HEIGHT),
  341. Browsable(true)
  342. ]
  343. public int CaptionHeight
  344. {
  345. get
  346. {
  347. return mint_CaptionHeight;
  348. }
  349. set
  350. {
  351. mint_CaptionHeight = value;
  352. mbln_IconVisible = (mint_CaptionHeight >= 16);
  353. Invalidate();
  354. }
  355. }
  356.  
  357. [
  358. Description("Change the caption gradient direction. Has no effect if UseCustomRenderer is true."),
  359. Category("Caption"),
  360. DefaultValue(LinearGradientMode.Vertical),
  361. Browsable(true)
  362. ]
  363. public LinearGradientMode CaptionGradientDirection
  364. {
  365. get
  366. {
  367. return menm_CaptionGradientMode;
  368. }
  369. set
  370. {
  371. menm_CaptionGradientMode = value;
  372. Invalidate();
  373. }
  374. }
  375.  
  376. [
  377. Description("Change the caption gradient's start color. Has no effect if UseCustomRenderer is true."),
  378. Category("Caption"),
  379. Browsable(true)
  380. ]
  381. public Color CaptionBeginColor
  382. {
  383. get
  384. {
  385. return mclr_CaptionBeginColor;
  386. }
  387. set
  388. {
  389. if (!useCaptionBrolDevStyle)
  390. {
  391. mclr_CaptionBeginColor = value;
  392. setBrolDevStyle();
  393. }
  394. }
  395. }
  396.  
  397. [
  398. Description("Change the caption gradient's end color. Has no effect if UseCustomRenderer is true."),
  399. Category("Caption"),
  400. Browsable(true)
  401. ]
  402. public Color CaptionEndColor
  403. {
  404. get
  405. {
  406. return mclr_CaptionEndColor;
  407. }
  408. set
  409. {
  410. if (!useCaptionBrolDevStyle)
  411. {
  412. mclr_CaptionEndColor = value;
  413. setBrolDevStyle();
  414. }
  415. }
  416. }
  417.  
  418. [
  419. Description("Change the caption position"),
  420. Category("Caption"),
  421. DefaultValue(BORDER_POSITION.Top),
  422. Browsable(true)
  423. ]
  424. public BORDER_POSITION CaptionPosition
  425. {
  426. get
  427. {
  428. return this.menm_CaptionPosition;
  429. }
  430. set
  431. {
  432. this.menm_CaptionPosition = value;
  433. Invalidate();
  434. }
  435. }
  436.  
  437. [
  438. Description("Change the caption font"),
  439. Category("Caption"),
  440. Browsable(true)
  441. ]
  442. public override Font Font
  443. {
  444. get
  445. {
  446. return base.Font;
  447. }
  448. set
  449. {
  450. base.Font = value;
  451. if (value.GetHeight() > mint_CaptionHeight)
  452. mint_CaptionHeight = Convert.ToInt32(value.GetHeight() + 8.0f);
  453. Invalidate();
  454. }
  455. }
  456.  
  457. #endregion
  458.  
  459. #region icon
  460. [
  461. Description("Change the icon to display in the title"),
  462. Category("Icon"),
  463. Browsable(true)
  464. ]
  465. public Icon PanelIcon
  466. {
  467. get
  468. {
  469. return mico_Icon;
  470. }
  471. set
  472. {
  473. mico_Icon = value;
  474. Invalidate();
  475. }
  476. }
  477.  
  478. [
  479. Description("Enable/Disable the icon"),
  480. Category("Icon"),
  481. DefaultValue(false),
  482. Browsable(true)
  483. ]
  484. public bool PanelIconVisible
  485. {
  486. get
  487. {
  488. return mbln_IconVisible;
  489. }
  490. set
  491. {
  492. mbln_IconVisible = value && (mint_CaptionHeight >= 16);
  493. Invalidate();
  494. }
  495. }
  496. #endregion
  497.  
  498. #endregion
  499.  
  500. #region Overrided Methods
  501. protected override void Dispose(bool disposing)
  502. {
  503. StyleFactory.Instance.onRendererChanged -= rendererChangedEvent;
  504. if (disposing)
  505. {
  506. if (components != null)
  507. {
  508. components.Dispose();
  509. }
  510. }
  511. base.Dispose(disposing);
  512. }
  513.  
  514. protected override void WndProc(ref Message m)
  515. {
  516. switch (m.Msg)
  517. {
  518. case WM_NCCALCSIZE:
  519. WmNCCalcSize(ref m);
  520. break;
  521. case WM_NCPAINT:
  522. IntPtr hDC = NativeMethods.GetWindowDC(m.HWnd);
  523. if (hDC != IntPtr.Zero)
  524. {
  525. using (Graphics canvas = Graphics.FromHdc(hDC))
  526. {
  527. PaintNonClientArea(canvas);
  528. }
  529. NativeMethods.ReleaseDC(m.HWnd, hDC);
  530. }
  531. m.Result = IntPtr.Zero;
  532. break;
  533. }
  534. base.WndProc(ref m);
  535. }
  536.  
  537. protected override void OnResize(EventArgs e)
  538. {
  539. Invalidate();
  540. base.OnResize(e);
  541. }
  542.  
  543. protected override void OnPaint(PaintEventArgs e)
  544. {
  545. if (Width == 0 || Height == 0) return;
  546. base.OnPaint(e);
  547. if (BackgroundImage == null && useContentGradient)
  548. {
  549. DrawBackground(e, menm_BorderStyle);
  550. }
  551. }
  552. #endregion
  553.  
  554. #region Event Handlers
  555. private void HeaderPanel_Scroll(object sender, ScrollEventArgs e)
  556. {
  557. Invalidate();
  558. }
  559.  
  560. private void onRendererChanged(object sender, EventArgs e)
  561. {
  562. setBrolDevStyle();
  563. }
  564. #endregion
  565.  
  566. #region private methods
  567. private void setBrolDevStyle()
  568. {
  569.  
  570. /*if (this.Visible)
  571.   {
  572.   this.SuspendLayout();
  573.   }*/
  574. if (useCaptionBrolDevStyle)
  575. {
  576. mclr_CaptionBeginColor = StyleFactory.CustomSystemColors.ActiveCaption;//StyleFactory.ProfessionalColorTable.ToolStripContentPanelGradientBegin;
  577. mclr_CaptionEndColor = StyleFactory.CustomSystemColors.GradientActiveCaption;//StyleFactory.ProfessionalColorTable.ToolStripContentPanelGradientEnd;
  578. }
  579. if (useContentBrolDevStyle)
  580. {
  581. mclr_StartColor = StyleFactory.CustomSystemColors.ControlLightLight;
  582. mclr_EndColor = StyleFactory.CustomSystemColors.Control;
  583.  
  584. mclr_BorderColor = StyleFactory.CustomSystemColors.ActiveBorder;
  585. }
  586. if (useBorderBrolDevStyle)
  587. {
  588. menm_BorderStyle = StyleFactory.BorderStyle;
  589. }
  590. //does not work as well as we want
  591. //using invalidate seems not the solution!!!
  592.  
  593. if (this.Visible)
  594. {
  595. Invalidate();
  596. //this.OnPaint(new PaintEventArgs(this.grap);
  597. //this.Refresh();
  598. //this.Show();
  599. //this.PerformLayout();
  600. //this.ResumeLayout(true);
  601. //OnResize(null);
  602. be.gaudry.observer.StaticObservable.notify(
  603. new be.gaudry.observer.Notification(
  604. be.gaudry.observer.Notification.VERBOSE.basicOperation,
  605. "H mod",
  606. "\n" + this.CaptionText +
  607. " candidate to invalidate\nStyle : " + EnumHelper.GetDescription(StyleFactory.getStyle()) +
  608. "\n BE CAREFULL :\n\nProblems seems occurs on HeaderPanel Invalidate. It doesn't apply the new style.",
  609. this));
  610. }
  611. }
  612. #endregion
  613.  
  614. #region Helper Routines
  615.  
  616. private void WmNCCalcSize(ref Message m)
  617. {
  618. if (m.WParam == NativeMethods.FALSE)
  619. {
  620. NativeMethods.RECT ncRect = (NativeMethods.RECT)m.GetLParam(typeof(NativeMethods.RECT));
  621. Rectangle proposed = ncRect.Rect;
  622. RecalcNonClientArea(ref proposed);
  623. ncRect = NativeMethods.RECT.FromRectangle(proposed);
  624. Marshal.StructureToPtr(ncRect, m.LParam, false);
  625. }
  626. else if (m.WParam == NativeMethods.TRUE)
  627. {
  628. NativeMethods.NCCALCSIZE_PARAMS ncParams =
  629. (NativeMethods.NCCALCSIZE_PARAMS)m.GetLParam(typeof(NativeMethods.NCCALCSIZE_PARAMS));
  630. Rectangle proposed = ncParams.rectProposed.Rect;
  631. RecalcNonClientArea(ref proposed);
  632. ncParams.rectProposed = NativeMethods.RECT.FromRectangle(proposed);
  633. Marshal.StructureToPtr(ncParams, m.LParam, false);
  634. }
  635. m.Result = IntPtr.Zero;
  636. }
  637.  
  638. private void RecalcNonClientArea(ref Rectangle proposed)
  639. {
  640. int brdWidth = 0;
  641. int shadowWidth = 0;
  642. int captionHight = 0;
  643.  
  644. brdWidth = ComputeBorderWidth();
  645. if (menm_BorderStyle == BORDER_STYLE.Shadow)
  646. shadowWidth = DEFAULT_SHADOW_WIDTH;
  647. if (mbln_CaptionVisible)
  648. captionHight = mint_CaptionHeight;
  649.  
  650. switch (menm_CaptionPosition)
  651. {
  652. case BORDER_POSITION.Top:
  653. proposed = new Rectangle(proposed.Left + brdWidth,
  654. proposed.Top + (brdWidth + captionHight),
  655. proposed.Width - (brdWidth + brdWidth + shadowWidth),
  656. proposed.Height - (brdWidth + brdWidth + shadowWidth +
  657. captionHight));
  658. break;
  659. case BORDER_POSITION.Bottom:
  660. proposed = new Rectangle(proposed.Left + brdWidth,
  661. proposed.Top + brdWidth,
  662. proposed.Width - (brdWidth + brdWidth + shadowWidth),
  663. proposed.Height - (brdWidth + brdWidth + shadowWidth +
  664. captionHight));
  665. break;
  666. case BORDER_POSITION.Left:
  667. proposed = new Rectangle(proposed.Left + (brdWidth + captionHight),
  668. proposed.Top + brdWidth,
  669. proposed.Width - (brdWidth + brdWidth + shadowWidth),
  670. proposed.Height - (brdWidth + brdWidth + shadowWidth));
  671. break;
  672. case BORDER_POSITION.Right:
  673. proposed = new Rectangle(proposed.Left + brdWidth,
  674. proposed.Top + brdWidth,
  675. proposed.Width - (brdWidth + brdWidth + shadowWidth +
  676. captionHight),
  677. proposed.Height - (brdWidth + brdWidth + shadowWidth));
  678. break;
  679. }
  680. }
  681.  
  682. private void PaintNonClientArea(Graphics canvas)
  683. {
  684. if (menm_BorderStyle == BORDER_STYLE.Shadow)
  685. DrawShadow(canvas);
  686.  
  687. if (menm_BorderStyle != BORDER_STYLE.None)
  688. DrawBorder(canvas);
  689.  
  690. if (mbln_CaptionVisible)
  691. DrawCaption(canvas);
  692. }
  693.  
  694. private void DrawShadow(Graphics canvas)
  695. {
  696. Pen pen = null;
  697. Color[] clrArr = null;
  698.  
  699. try
  700. {
  701. clrArr = new Color[] {Color.FromArgb(142, 142, 142),
  702. Color.FromArgb(171, 171, 171),
  703. Color.FromArgb(212, 212, 212),
  704. Color.FromArgb(220, 220, 220)};
  705. for (int cntr = 0; cntr < 4; cntr++)
  706. {
  707. pen = new Pen(clrArr[cntr], 1.0f);
  708. canvas.DrawLine(pen, Width - (5 - cntr), ((cntr + 1) * 2),
  709. Width - (5 - cntr), Height - (5 - cntr));
  710. canvas.DrawLine(pen, ((cntr + 1) * 2), Height - (5 - cntr),
  711. Width - (5 - cntr), Height - (5 - cntr));
  712. pen.Dispose();
  713. pen = null;
  714. }
  715. }
  716. finally
  717. {
  718. if (pen != null)
  719. {
  720. pen.Dispose();
  721. pen = null;
  722. }
  723. clrArr = null;
  724. }
  725. }
  726.  
  727. private void DrawCaption(Graphics canvas)
  728. {
  729. int brdWidth = 0;
  730. int shadowWidth = 0;
  731. Bitmap offScreenBmp = null;
  732. Graphics offScreenDC = null;
  733. Rectangle drawRect;
  734. StringFormat format = null;
  735. LinearGradientBrush brsh = null;
  736.  
  737. try
  738. {
  739. if (menm_BorderStyle == BORDER_STYLE.None)
  740. brdWidth = 0;
  741. else if (menm_BorderStyle == BORDER_STYLE.Groove ||
  742. menm_BorderStyle == BORDER_STYLE.Ridge)
  743. brdWidth = 2;
  744. else
  745. brdWidth = DEFAULT_BORDER_WIDTH;
  746.  
  747. if (menm_BorderStyle == BORDER_STYLE.Shadow)
  748. shadowWidth = DEFAULT_SHADOW_WIDTH;
  749.  
  750. format = new StringFormat();
  751. format.FormatFlags = StringFormatFlags.NoWrap;
  752. format.LineAlignment = StringAlignment.Center;
  753. format.Alignment = StringAlignment.Near;
  754. format.Trimming = StringTrimming.EllipsisCharacter;
  755.  
  756. if (menm_CaptionPosition == BORDER_POSITION.Bottom ||
  757. menm_CaptionPosition == BORDER_POSITION.Top)
  758. offScreenBmp = new Bitmap(Bounds.Width - ((2 * brdWidth) + shadowWidth),
  759. mint_CaptionHeight);
  760. else
  761. offScreenBmp = new Bitmap(Bounds.Height - ((2 * brdWidth) + shadowWidth),
  762. mint_CaptionHeight);
  763.  
  764. offScreenDC = Graphics.FromImage(offScreenBmp);
  765. if (mbln_Antialias)
  766. offScreenDC.TextRenderingHint = TextRenderingHint.AntiAlias;
  767.  
  768. brsh = new LinearGradientBrush(new Rectangle(0, 0,
  769. offScreenBmp.Width,
  770. offScreenBmp.Height),
  771. mclr_CaptionBeginColor,
  772. mclr_CaptionEndColor,
  773. menm_CaptionGradientMode);
  774. offScreenDC.FillRectangle(brsh, 0.0f, 0.0f, offScreenBmp.Width,
  775. offScreenBmp.Height);
  776. if (mico_Icon != null && mbln_IconVisible)
  777. {
  778. offScreenDC.DrawIcon(mico_Icon,
  779. new Rectangle(brdWidth + 2,
  780. (mint_CaptionHeight - 16) / 2,
  781. 16, 16));
  782. offScreenDC.DrawString(mstr_CaptionText, this.Font,
  783. new SolidBrush(this.ForeColor),
  784. new Rectangle(20, 0,
  785. offScreenBmp.Width - 20,
  786. mint_CaptionHeight), format);
  787. }
  788. else
  789. {
  790. offScreenDC.DrawString(mstr_CaptionText, this.Font,
  791. new SolidBrush(this.ForeColor),
  792. new Rectangle(2, 0,
  793. offScreenBmp.Width,
  794. mint_CaptionHeight), format);
  795. }
  796.  
  797. drawRect = new Rectangle();
  798. switch (menm_CaptionPosition)
  799. {
  800. case BORDER_POSITION.Top:
  801. {
  802. drawRect.X = brdWidth;
  803. drawRect.Width = DisplayRectangle.Width;
  804. drawRect.Y = brdWidth;
  805. drawRect.Height = mint_CaptionHeight;
  806. break;
  807. }
  808. case BORDER_POSITION.Bottom:
  809. {
  810. drawRect.X = brdWidth;
  811. drawRect.Width = DisplayRectangle.Width;
  812. drawRect.Y = Height - (shadowWidth + brdWidth +
  813. mint_CaptionHeight);
  814. drawRect.Height = mint_CaptionHeight;
  815. break;
  816. }
  817. case BORDER_POSITION.Left:
  818. {
  819. drawRect.X = brdWidth;
  820. drawRect.Width = mint_CaptionHeight;
  821. drawRect.Y = brdWidth;
  822. drawRect.Height = Height - (shadowWidth + (2 * brdWidth));
  823. offScreenBmp.RotateFlip(RotateFlipType.Rotate270FlipNone);
  824. break;
  825. }
  826. case BORDER_POSITION.Right:
  827. {
  828. drawRect.X = Width - (shadowWidth + brdWidth + mint_CaptionHeight);
  829. drawRect.Width = mint_CaptionHeight;
  830. drawRect.Y = brdWidth;
  831. drawRect.Height = Height - (shadowWidth + (2 * brdWidth));
  832. offScreenBmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
  833. break;
  834. }
  835. }
  836. canvas.DrawImage(offScreenBmp, drawRect);
  837. }
  838. catch (Exception ex)
  839. {
  840. StaticObservable.notify(new Notification(Notification.VERBOSE.debug, ex, this));
  841. }
  842. finally
  843. {
  844. if (brsh != null)
  845. {
  846. brsh.Dispose();
  847. brsh = null;
  848. }
  849.  
  850. if (offScreenDC != null)
  851. {
  852. offScreenDC.Dispose();
  853. offScreenDC = null;
  854. }
  855.  
  856. if (offScreenBmp != null)
  857. {
  858. offScreenBmp.Dispose();
  859. offScreenBmp = null;
  860. }
  861.  
  862. if (format != null)
  863. {
  864. format.Dispose();
  865. format = null;
  866. }
  867. }
  868. }
  869.  
  870. private void DrawBackground(PaintEventArgs peArgs, BORDER_STYLE brdStyle)
  871. {
  872. Brush brsh = null;
  873.  
  874. try
  875. {
  876. if (menm_BorderStyle == BORDER_STYLE.Shadow)
  877. {
  878.  
  879. //if (useContentGradient)
  880. //{
  881. brsh = new LinearGradientBrush(
  882. new Rectangle(0, 0, Width - DEFAULT_SHADOW_WIDTH, Height - DEFAULT_SHADOW_WIDTH), mclr_StartColor,
  883. mclr_EndColor,
  884. menm_GradientMode
  885. );
  886. //}
  887. peArgs.Graphics.FillRectangle(brsh, 0, 0,
  888. Width - DEFAULT_SHADOW_WIDTH,
  889. Height - DEFAULT_SHADOW_WIDTH);
  890. }
  891. else
  892. {
  893. if (useContentGradient)
  894. {
  895. brsh = new LinearGradientBrush(
  896. new Rectangle(0, 0, Width, Height),
  897. mclr_StartColor,
  898. mclr_EndColor,
  899. menm_GradientMode
  900. );
  901. }
  902. else
  903. {
  904. brsh = new SolidBrush(mclr_StartColor);
  905. }
  906. peArgs.Graphics.FillRectangle(brsh, 0, 0, Width, Height);
  907. }
  908. }
  909. finally
  910. {
  911. if (brsh != null)
  912. {
  913. brsh.Dispose();
  914. brsh = null;
  915. }
  916. }
  917. }
  918.  
  919. private void DrawBorder(Graphics canvas)
  920. {
  921. Pen penDark = null;
  922. Pen penLight = null;
  923.  
  924. try
  925. {
  926. switch (menm_BorderStyle)
  927. {
  928. case BORDER_STYLE.Shadow:
  929. penDark = new Pen(mclr_BorderColor);
  930. canvas.DrawRectangle(penDark, 0, 0, Width - 6,
  931. Height - 6);
  932. break;
  933. case BORDER_STYLE.Single:
  934. penDark = new Pen(mclr_BorderColor);
  935. canvas.DrawRectangle(penDark, 0, 0,
  936. Width - DEFAULT_BORDER_WIDTH,
  937. Height - DEFAULT_BORDER_WIDTH);
  938. break;
  939. case BORDER_STYLE.Inset:
  940. penDark = new Pen(SystemColors.ButtonShadow);
  941. penLight = new Pen(SystemColors.ButtonHighlight);
  942. canvas.DrawLine(penLight, 0, 0,
  943. Width - DEFAULT_BORDER_WIDTH, 0);
  944. canvas.DrawLine(penLight, 0, 0, 0,
  945. Height - DEFAULT_BORDER_WIDTH);
  946. canvas.DrawLine(penDark, Width - DEFAULT_BORDER_WIDTH,
  947. 0, Width - DEFAULT_BORDER_WIDTH,
  948. Height - DEFAULT_BORDER_WIDTH);
  949. canvas.DrawLine(penDark, 0, Height - DEFAULT_BORDER_WIDTH,
  950. Width - DEFAULT_BORDER_WIDTH,
  951. Height - DEFAULT_BORDER_WIDTH);
  952. break;
  953. case BORDER_STYLE.Outset:
  954. penDark = new Pen(SystemColors.ButtonShadow);
  955. penLight = new Pen(SystemColors.ButtonHighlight);
  956. canvas.DrawLine(penDark, 0, 0,
  957. Width - DEFAULT_BORDER_WIDTH, 0);
  958. canvas.DrawLine(penDark, 0, 0, 0,
  959. Height - DEFAULT_BORDER_WIDTH);
  960. canvas.DrawLine(penLight, Width - DEFAULT_BORDER_WIDTH,
  961. 0, Width - DEFAULT_BORDER_WIDTH,
  962. Height - DEFAULT_BORDER_WIDTH);
  963. canvas.DrawLine(penLight, 0, Height - DEFAULT_BORDER_WIDTH,
  964. Width - DEFAULT_BORDER_WIDTH,
  965. Height - DEFAULT_BORDER_WIDTH);
  966. break;
  967. case BORDER_STYLE.Groove:
  968. penDark = new Pen(SystemColors.ButtonShadow);
  969. penLight = new Pen(SystemColors.ButtonHighlight);
  970. canvas.DrawRectangle(penLight,
  971. new Rectangle(1, 1, Width - (2 * DEFAULT_BORDER_WIDTH),
  972. Height - (2 * DEFAULT_BORDER_WIDTH)));
  973. canvas.DrawRectangle(penDark,
  974. new Rectangle(0, 0, Width - (2 * DEFAULT_BORDER_WIDTH),
  975. Height - (2 * DEFAULT_BORDER_WIDTH)));
  976. break;
  977. case BORDER_STYLE.Ridge:
  978.  
  979. penDark = new Pen(SystemColors.ButtonShadow);
  980. penLight = new Pen(SystemColors.ButtonHighlight);
  981. canvas.DrawRectangle(penLight,
  982. new Rectangle(0, 0, Width - (2 * DEFAULT_BORDER_WIDTH),
  983. Height - (2 * DEFAULT_BORDER_WIDTH)));
  984. canvas.DrawRectangle(penDark,
  985. new Rectangle(1, 1, Width - (2 * DEFAULT_BORDER_WIDTH),
  986. Height - (2 * DEFAULT_BORDER_WIDTH)));
  987. break;
  988. default:
  989. break;
  990. }
  991. }
  992. finally
  993. {
  994. if (penDark != null)
  995. {
  996. penDark.Dispose();
  997. penDark = null;
  998. }
  999. if (penLight != null)
  1000. {
  1001. penLight.Dispose();
  1002. penLight = null;
  1003. }
  1004. }
  1005. }
  1006.  
  1007. /// <summary>
  1008. /// Helper function to compute the border width
  1009. /// </summary>
  1010. /// <returns>The border width</returns>
  1011. private int ComputeBorderWidth()
  1012. {
  1013. int brdWidth = 0;
  1014.  
  1015. switch (menm_BorderStyle)
  1016. {
  1017. case BORDER_STYLE.Single:
  1018. case BORDER_STYLE.Shadow:
  1019. case BORDER_STYLE.Inset:
  1020. case BORDER_STYLE.Outset:
  1021. brdWidth = DEFAULT_BORDER_WIDTH;
  1022. break;
  1023. case BORDER_STYLE.Groove:
  1024. case BORDER_STYLE.Ridge:
  1025. brdWidth = (DEFAULT_BORDER_WIDTH + DEFAULT_BORDER_WIDTH);
  1026. break;
  1027. default:
  1028. break;
  1029. }
  1030. return brdWidth;
  1031. }
  1032.  
  1033. #endregion
  1034. }
  1035. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/controls/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1732283640 22/11/2024 14:54:00
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/controls/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csToolBarHomeControl.Designer.cs7.41 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csWizardUserControl.Designer.cs6.79 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csHeaderPanel.Designer.cs1.19 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csDGVLayoutOptionsControl.cs7.55 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csXPGroupBox.cs15.83 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csWizardXpUserControl.Designer.cs7.85 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csToolBarHomeControl.cs2.32 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csVersionControl.Designer.cs4.09 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csWizardUserControl.cs2.01 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .resx|.resxWizardXpUserControl.resx5.68 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csBrolBoxUserControl.Designer.cs5.92 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .resx|.resxChartControl.resx6.58 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csHeaderPanel.cs35.93 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csIWizardUC.cs2.35 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxAboutUserControl.resx5.68 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .cs|.csTextBoxDragDrop.cs8.59 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csSystemInfoControl.cs5.46 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxXPGroupBox.resx17.7 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csHeaderPanelNativeMethods.cs21.09 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csToolBarManagerControl.cs6.99 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csTextBoxDragDrop.Designer.cs1.11 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .resx|.resxSystemInfoControl.resx6.22 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csSystemInfoControl.Designer.cs4.79 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .resx|.resxHeaderPanel.resx5.85 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csScrollablePictureBoxUserControl.cs5.55 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csBrolBoxUserControl.cs4.7 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .resx|.resxDGVLayoutOptionsControl.resx5.68 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxWizardUserControl.resx5.68 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csUpdateControl.cs7.55 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csIconList.cs2.68 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csVersionControl.cs463 octets31/10/2018 18:33:12-refusé-
Afficher le fichier .resx|.resxBrolBoxUserControl.resx5.68 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .cs|.csAboutUserControl.cs6.75 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .resx|.resxToolBarManagerControl.resx5.88 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csToolBarManagerControl.Designer.cs10.66 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csIToolBarControl.cs1.07 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csWizardXpUserControl.cs8.11 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csImageCombo.cs15.49 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csAboutUserControl.Designer.cs12.31 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .resx|.resxScrollablePictureBoxUserControl.resx5.68 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csScrollablePictureBoxUserControl.Designer.cs5.64 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxVersionControl.resx5.68 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csChartControl.Designer.cs18.45 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .cs|.csUpdateControl.Designer.cs3.92 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .resx|.resxUpdateControl.resx5.68 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csChartControl.cs15.11 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .cs|.csDGVLayoutOptionsControl.Designer.cs17.39 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csToolStrip.cs1.06 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csIconList.Designer.cs1.1 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxToolBarHomeControl.resx48.51 Ko31/10/2018 18:33:12-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 16/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-broldev-source-rf-view/controls//HeaderPanel.cs.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.