WindowsVistaRenderer.cs

Description du code

WindowsVistaRenderer.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.Drawing;
  3. using System.Drawing.Drawing2D;
  4. using System.Windows.Forms;
  5.  
  6. namespace be.gaudry.view.style
  7. {
  8. /// <summary>
  9. /// Renders toolstrip items using Windows Vista look and feel
  10. /// </summary>
  11. /// <remarks>
  12. /// 2007 José Manuel Menéndez Poo
  13. /// Visit my blog for upgrades and other renderers - www.menendezpoo.com
  14. /// </remarks>
  15. public class WindowsVistaRenderer
  16. : ToolStripRenderer
  17. {
  18. #region Static
  19.  
  20. /// <summary>
  21. /// Creates the glow of the buttons
  22. /// </summary>
  23. /// <param name="rectangle"></param>
  24. /// <returns></returns>
  25. private static GraphicsPath CreateBottomRadialPath(Rectangle rectangle)
  26. {
  27. GraphicsPath path = new GraphicsPath();
  28. RectangleF rect = rectangle;
  29. rect.X -= rect.Width * .35f;
  30. rect.Y -= rect.Height * .15f;
  31. rect.Width *= 1.7f;
  32. rect.Height *= 2.3f;
  33. path.AddEllipse(rect);
  34. path.CloseFigure();
  35. return path;
  36. }
  37.  
  38. /// <summary>
  39. /// Creates the chevron for the overflow button
  40. /// </summary>
  41. /// <param name="overflowButtonSize"></param>
  42. /// <returns></returns>
  43. private static GraphicsPath CreateOverflowChevron(Size overflowButtonSize)
  44. {
  45. Rectangle r = new Rectangle(Point.Empty, overflowButtonSize);
  46. GraphicsPath path = new GraphicsPath();
  47.  
  48. int segmentWidth = 3;
  49. int segmentHeight = 3;
  50. int segmentSeparation = 5;
  51. int chevronWidth = segmentWidth + segmentSeparation;
  52. int chevronHeight = segmentHeight * 2;
  53. int chevronLeft = (r.Width - chevronWidth) / 2;
  54. int chevronTop = (r.Height - chevronHeight) / 2;
  55.  
  56. // Segment \
  57. path.AddLine(
  58. new Point(chevronLeft, chevronTop),
  59. new Point(chevronLeft + segmentWidth, chevronTop + segmentHeight));
  60.  
  61. // Segment /
  62. path.AddLine(
  63. new Point(chevronLeft + segmentWidth, chevronTop + segmentHeight),
  64. new Point(chevronLeft, chevronTop + segmentHeight * 2));
  65.  
  66. path.StartFigure();
  67.  
  68. // Segment \
  69. path.AddLine(
  70. new Point(segmentSeparation + chevronLeft, chevronTop),
  71. new Point(segmentSeparation + chevronLeft + segmentWidth, chevronTop + segmentHeight));
  72.  
  73. // Segment /
  74. path.AddLine(
  75. new Point(segmentSeparation + chevronLeft + segmentWidth, chevronTop + segmentHeight),
  76. new Point(segmentSeparation + chevronLeft, chevronTop + segmentHeight * 2));
  77.  
  78.  
  79. return path;
  80. }
  81.  
  82. #endregion
  83.  
  84. #region Fields
  85.  
  86. private WindowsVistaColorTable _colorTable;
  87. private bool _glossyEffect;
  88. private bool _bgglow;
  89. private int _toolstripRadius;
  90. private int _buttonRadius;
  91.  
  92. #endregion
  93.  
  94. #region Ctor
  95.  
  96. public WindowsVistaRenderer()
  97. {
  98. ColorTable = new WindowsVistaColorTable();
  99.  
  100. GlossyEffect = true;
  101. BackgroundGlow = true;
  102. ToolStripRadius = 2;
  103. ButtonRadius = 2;
  104. }
  105.  
  106. #endregion
  107.  
  108. #region Properties
  109.  
  110. /// <summary>
  111. /// Gets or sets the buttons rectangle radius
  112. /// </summary>
  113. public int ButtonRadius
  114. {
  115. get { return _buttonRadius; }
  116. set { _buttonRadius = value; }
  117. }
  118.  
  119. /// <summary>
  120. /// Gets or sets the radius of the rectangle of the hole ToolStrip
  121. /// </summary>
  122. public int ToolStripRadius
  123. {
  124. get { return _toolstripRadius; }
  125. set { _toolstripRadius = value; }
  126. }
  127.  
  128. /// <summary>
  129. /// Gets ors sets if background glow should be rendered
  130. /// </summary>
  131. public bool BackgroundGlow
  132. {
  133. get { return _bgglow; }
  134. set { _bgglow = value; }
  135. }
  136.  
  137. /// <summary>
  138. /// Gets or sets if glossy effect should be rendered
  139. /// </summary>
  140. public bool GlossyEffect
  141. {
  142. get { return _glossyEffect; }
  143. set { _glossyEffect = value; }
  144. }
  145.  
  146. /// <summary>
  147. /// Gets or sets the color table of the renderer
  148. /// </summary>
  149. public WindowsVistaColorTable ColorTable
  150. {
  151. get { return _colorTable; }
  152. set { _colorTable = value; }
  153. }
  154.  
  155.  
  156. #endregion
  157.  
  158. #region Methods
  159.  
  160. /// <summary>
  161. /// Initializes properties for ToolStripMenuItem objects
  162. /// </summary>
  163. /// <param name="item"></param>
  164. protected virtual void InitializeToolStripMenuItem(ToolStripMenuItem item)
  165. {
  166. item.AutoSize = false;
  167. item.Height = 26;
  168. item.TextAlign = ContentAlignment.MiddleLeft;
  169.  
  170. foreach (ToolStripItem subitem in item.DropDownItems)
  171. {
  172. if (subitem is ToolStripMenuItem)
  173. {
  174. InitializeToolStripMenuItem(subitem as ToolStripMenuItem);
  175. }
  176. }
  177. }
  178.  
  179. /// <summary>
  180. /// Gets a rounded rectangle representing the hole area of the toolstrip
  181. /// </summary>
  182. /// <param name="toolStrip"></param>
  183. /// <returns></returns>
  184. private GraphicsPath GetToolStripRectangle(ToolStrip toolStrip)
  185. {
  186. return GraphicsTools.CreateRoundRectangle(
  187. new Rectangle(0, 0, toolStrip.Width - 1, toolStrip.Height - 1), ToolStripRadius);
  188. }
  189.  
  190. /// <summary>
  191. /// Draws the glossy effect on the toolbar
  192. /// </summary>
  193. /// <param name="g"></param>
  194. /// <param name="t"></param>
  195. /// <returns></returns>
  196. private void DrawGlossyEffect(Graphics g, ToolStrip t)
  197. {
  198. DrawGlossyEffect(g, t, 0);
  199. }
  200.  
  201. /// <summary>
  202. /// Draws the glossy effect on the toolbar
  203. /// </summary>
  204. /// <param name="g"></param>
  205. /// <param name="t"></param>
  206. /// <returns></returns>
  207. private void DrawGlossyEffect(Graphics g, ToolStrip t, int offset)
  208. {
  209. Rectangle glossyRect = new Rectangle(0, offset,
  210. t.Width - 1,
  211. (t.Height - 1) / 2);
  212.  
  213. using (LinearGradientBrush b = new LinearGradientBrush(
  214. glossyRect.Location, new PointF(0, glossyRect.Bottom),
  215. ColorTable.GlossyEffectNorth,
  216. ColorTable.GlossyEffectSouth))
  217. {
  218. using (GraphicsPath border =
  219. GraphicsTools.CreateTopRoundRectangle(glossyRect, ToolStripRadius))
  220. {
  221. g.FillPath(b, border);
  222. }
  223. }
  224. }
  225.  
  226. /// <summary>
  227. /// Renders the background of a button
  228. /// </summary>
  229. /// <param name="e"></param>
  230. private void DrawVistaButtonBackground(ToolStripItemRenderEventArgs e)
  231. {
  232. bool chk = false;
  233.  
  234. if (e.Item is ToolStripButton)
  235. {
  236. chk = (e.Item as ToolStripButton).Checked;
  237. }
  238.  
  239. DrawVistaButtonBackground(e.Graphics,
  240. new Rectangle(Point.Empty, e.Item.Size),
  241. e.Item.Selected,
  242. e.Item.Pressed,
  243. chk);
  244. }
  245.  
  246. /// <summary>
  247. /// Renders the background of a button on the specified rectangle using the specified device
  248. /// </summary>
  249. /// <param name="e"></param>
  250. private void DrawVistaButtonBackground(Graphics g, Rectangle r, bool selected, bool pressed, bool checkd)
  251. {
  252. g.SmoothingMode = SmoothingMode.AntiAlias;
  253.  
  254. Rectangle outerBorder = new Rectangle(r.Left, r.Top, r.Width - 1, r.Height - 1);
  255. Rectangle border = outerBorder; border.Inflate(-1, -1);
  256. Rectangle innerBorder = border; innerBorder.Inflate(-1, -1);
  257. Rectangle glossy = outerBorder; glossy.Height /= 2;
  258. Rectangle fill = innerBorder; fill.Height /= 2;
  259. Rectangle glow = Rectangle.FromLTRB(outerBorder.Left,
  260. outerBorder.Top + Convert.ToInt32(Convert.ToSingle(outerBorder.Height) * .5f),
  261. outerBorder.Right, outerBorder.Bottom);
  262.  
  263. if (selected || pressed || checkd)
  264. {
  265. #region Layers
  266.  
  267. //Outer border
  268. using (GraphicsPath path =
  269. GraphicsTools.CreateRoundRectangle(outerBorder, ButtonRadius))
  270. {
  271. using (Pen p = new Pen(ColorTable.ButtonOuterBorder))
  272. {
  273. g.DrawPath(p, path);
  274. }
  275. }
  276.  
  277. //Checked fill
  278. if (checkd)
  279. {
  280. using (GraphicsPath path = GraphicsTools.CreateRoundRectangle(innerBorder, 2))
  281. {
  282. using (Brush b = new SolidBrush(selected ? ColorTable.CheckedButtonFillHot : ColorTable.CheckedButtonFill))
  283. {
  284. g.FillPath(b, path);
  285. }
  286. }
  287. }
  288.  
  289. //Glossy effefct
  290. using (GraphicsPath path = GraphicsTools.CreateTopRoundRectangle(glossy, ButtonRadius))
  291. {
  292. using (Brush b = new LinearGradientBrush(
  293. new Point(0, glossy.Top),
  294. new Point(0, glossy.Bottom),
  295. ColorTable.GlossyEffectNorth,
  296. ColorTable.GlossyEffectSouth))
  297. {
  298. g.FillPath(b, path);
  299. }
  300. }
  301.  
  302. //Border
  303. using (GraphicsPath path =
  304. GraphicsTools.CreateRoundRectangle(border, ButtonRadius))
  305. {
  306. using (Pen p = new Pen(ColorTable.ButtonBorder))
  307. {
  308. g.DrawPath(p, path);
  309. }
  310. }
  311.  
  312. Color fillNorth = pressed ? ColorTable.ButtonFillNorthPressed : ColorTable.ButtonFillNorth;
  313. Color fillSouth = pressed ? ColorTable.ButtonFillSouthPressed : ColorTable.ButtonFillSouth;
  314.  
  315. //Fill
  316. using (GraphicsPath path = GraphicsTools.CreateTopRoundRectangle(fill, ButtonRadius))
  317. {
  318. using (Brush b = new LinearGradientBrush(
  319. new Point(0, fill.Top),
  320. new Point(0, fill.Bottom),
  321. fillNorth, fillSouth))
  322. {
  323. g.FillPath(b, path);
  324. }
  325. }
  326.  
  327. Color innerBorderColor = pressed || checkd ? ColorTable.ButtonInnerBorderPressed : ColorTable.ButtonInnerBorder;
  328.  
  329. //Inner border
  330. using (GraphicsPath path =
  331. GraphicsTools.CreateRoundRectangle(innerBorder, ButtonRadius))
  332. {
  333. using (Pen p = new Pen(innerBorderColor))
  334. {
  335. g.DrawPath(p, path);
  336. }
  337. }
  338.  
  339. //Glow
  340. using (GraphicsPath clip = GraphicsTools.CreateRoundRectangle(glow, 2))
  341. {
  342. g.SetClip(clip, CombineMode.Intersect);
  343.  
  344. Color glowColor = ColorTable.Glow;
  345.  
  346. if (checkd)
  347. {
  348. if (selected)
  349. {
  350. glowColor = ColorTable.CheckedGlowHot;
  351. }
  352. else
  353. {
  354. glowColor = ColorTable.CheckedGlow;
  355. }
  356. }
  357.  
  358. using (GraphicsPath brad = CreateBottomRadialPath(glow))
  359. {
  360. using (PathGradientBrush pgr = new PathGradientBrush(brad))
  361. {
  362. {
  363. int opacity = 255;
  364. RectangleF bounds = brad.GetBounds();
  365. pgr.CenterPoint = new PointF((bounds.Left + bounds.Right) / 2f, (bounds.Top + bounds.Bottom) / 2f);
  366. pgr.CenterColor = Color.FromArgb(opacity, glowColor);
  367. pgr.SurroundColors = new Color[] { Color.FromArgb(0, glowColor) };
  368. }
  369. g.FillPath(pgr, brad);
  370. }
  371. }
  372. g.ResetClip();
  373. }
  374.  
  375.  
  376.  
  377.  
  378. #endregion
  379. }
  380. }
  381.  
  382. /// <summary>
  383. /// Draws the background of a menu, vista style
  384. /// </summary>
  385. /// <param name="e"></param>
  386. private void DrawVistaMenuBackground(ToolStripItemRenderEventArgs e)
  387. {
  388.  
  389. DrawVistaMenuBackground(e.Graphics,
  390. new Rectangle(Point.Empty, e.Item.Size),
  391. e.Item.Selected, e.Item.Owner is MenuStrip);
  392.  
  393. }
  394.  
  395. /// <summary>
  396. /// Draws the background of a menu, vista style
  397. /// </summary>
  398. /// <param name="g"></param>
  399. /// <param name="r"></param>
  400. /// <param name="highlighted"></param>
  401. private void DrawVistaMenuBackground(Graphics g, Rectangle r, bool highlighted, bool isMainMenu)
  402. {
  403. //g.Clear(ColorTable.MenuBackground);
  404.  
  405. int margin = 2;
  406. int left = 22;
  407.  
  408. #region IconSeparator
  409.  
  410. if (!isMainMenu)
  411. {
  412. using (Pen p = new Pen(ColorTable.MenuDark))
  413. {
  414. g.DrawLine(p,
  415. new Point(r.Left + left, r.Top),
  416. new Point(r.Left + left, r.Height - margin));
  417. }
  418.  
  419.  
  420. using (Pen p = new Pen(ColorTable.MenuLight))
  421. {
  422. g.DrawLine(p,
  423. new Point(r.Left + left + 1, r.Top),
  424. new Point(r.Left + left + 1, r.Height - margin));
  425. }
  426. }
  427.  
  428. #endregion
  429.  
  430. if (highlighted)
  431. {
  432. #region Draw Rectangle
  433.  
  434. using (GraphicsPath path = GraphicsTools.CreateRoundRectangle(
  435. new Rectangle(r.X + margin, r.Y + margin, r.Width - margin * 2, r.Height - margin * 2), 3))
  436. {
  437.  
  438. using (Brush b = new LinearGradientBrush(
  439. new Point(0, 2), new Point(0, r.Height - 2),
  440. ColorTable.MenuHighlightNorth,
  441. ColorTable.MenuHighlightSouth))
  442. {
  443. g.FillPath(b, path);
  444. }
  445.  
  446. using (Pen p = new Pen(ColorTable.MenuHighlight))
  447. {
  448. g.DrawPath(p, path);
  449. }
  450. }
  451.  
  452. #endregion
  453. }
  454.  
  455. }
  456.  
  457. /// <summary>
  458. /// Draws the border of the vista menu window
  459. /// </summary>
  460. /// <param name="g"></param>
  461. /// <param name="r"></param>
  462. private void DrawVistaMenuBorder(Graphics g, Rectangle r)
  463. {
  464. using (Pen p = new Pen(ColorTable.BackgroundBorder))
  465. {
  466. g.DrawRectangle(p,
  467. new Rectangle(r.Left, r.Top, r.Width - 1, r.Height - 1));
  468. }
  469. }
  470.  
  471. #endregion
  472.  
  473. protected override void Initialize(ToolStrip toolStrip)
  474. {
  475. base.Initialize(toolStrip);
  476.  
  477. toolStrip.AutoSize = false;
  478. toolStrip.Height = 35;
  479. toolStrip.ForeColor = ColorTable.Text;
  480. toolStrip.GripStyle = ToolStripGripStyle.Hidden;
  481. }
  482.  
  483. protected override void InitializeItem(ToolStripItem item)
  484. {
  485. base.InitializeItem(item);
  486.  
  487. //Don't Affect ForeColor of TextBoxes and ComboBoxes
  488. if ( !((item is ToolStripTextBox) || (item is ToolStripComboBox)) )
  489. {
  490. item.ForeColor = ColorTable.Text;
  491. }
  492.  
  493. item.Padding = new Padding(5);
  494.  
  495. if (item is ToolStripSplitButton)
  496. {
  497. ToolStripSplitButton btn = item as ToolStripSplitButton;
  498. btn.DropDownButtonWidth = 18;
  499.  
  500. foreach (ToolStripItem subitem in btn.DropDownItems)
  501. {
  502. if (subitem is ToolStripMenuItem)
  503. {
  504. InitializeToolStripMenuItem(subitem as ToolStripMenuItem);
  505. }
  506. }
  507. }
  508.  
  509. if (item is ToolStripDropDownButton)
  510. {
  511. ToolStripDropDownButton btn = item as ToolStripDropDownButton;
  512. btn.ShowDropDownArrow = false;
  513.  
  514. foreach (ToolStripItem subitem in btn.DropDownItems)
  515. {
  516. if (subitem is ToolStripMenuItem)
  517. {
  518. InitializeToolStripMenuItem(subitem as ToolStripMenuItem);
  519. }
  520. }
  521. }
  522. }
  523.  
  524. protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
  525. {
  526.  
  527. if (e.ToolStrip is ToolStripDropDownMenu)
  528. {
  529. #region Draw Rectangled Border
  530.  
  531. DrawVistaMenuBorder(e.Graphics,
  532. new Rectangle(Point.Empty, e.ToolStrip.Size));
  533.  
  534. #endregion
  535. }
  536. else
  537. {
  538. #region Draw Rounded Border
  539. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  540.  
  541. using (GraphicsPath path = GetToolStripRectangle(e.ToolStrip))
  542. {
  543. using (Pen p = new Pen(ColorTable.BackgroundBorder))
  544. {
  545. e.Graphics.DrawPath(p, path);
  546. }
  547. }
  548. #endregion
  549. }
  550.  
  551.  
  552. }
  553.  
  554. protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
  555. {
  556. if (e.ToolStrip is ToolStripDropDownMenu)
  557. {
  558. return;
  559. }
  560.  
  561. #region Background
  562.  
  563. using (LinearGradientBrush b = new LinearGradientBrush(
  564. Point.Empty, new PointF(0,e.ToolStrip.Height),
  565. ColorTable.BackgroundNorth,
  566. ColorTable.BackgroundSouth))
  567. {
  568. using (GraphicsPath border = GetToolStripRectangle(e.ToolStrip))
  569. {
  570. e.Graphics.FillPath(b, border);
  571. }
  572. }
  573.  
  574. #endregion
  575.  
  576. if (GlossyEffect)
  577. {
  578. #region Glossy Effect
  579.  
  580. DrawGlossyEffect(e.Graphics, e.ToolStrip, 1);
  581.  
  582. #endregion
  583. }
  584.  
  585. if (BackgroundGlow)
  586. {
  587. #region BackroundGlow
  588.  
  589. int glowSize = Convert.ToInt32(Convert.ToSingle(e.ToolStrip.Height) * 0.15f);
  590. Rectangle glow = new Rectangle(0,
  591. e.ToolStrip.Height - glowSize - 1,
  592. e.ToolStrip.Width - 1,
  593. glowSize);
  594.  
  595. using (LinearGradientBrush b = new LinearGradientBrush(
  596. new Point(0, glow.Top -1 ), new PointF(0, glow.Bottom),
  597. Color.FromArgb(0, ColorTable.BackgroundGlow),
  598. ColorTable.BackgroundGlow))
  599. {
  600. using (GraphicsPath border =
  601. GraphicsTools.CreateBottomRoundRectangle(glow, ToolStripRadius))
  602. {
  603. e.Graphics.FillPath(b, border);
  604. }
  605. }
  606.  
  607.  
  608. #endregion
  609. }
  610.  
  611. }
  612.  
  613. protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
  614. {
  615.  
  616. if (e.Item is ToolStripButton)
  617. {
  618. e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  619. }
  620.  
  621. if (e.Item is ToolStripMenuItem
  622. && !(e.Item.Owner is MenuStrip))
  623. {
  624. Rectangle r = new Rectangle(e.TextRectangle.Location, new Size(e.TextRectangle.Width, 24));
  625. e.TextRectangle = r;
  626. e.TextColor = ColorTable.MenuText;
  627. }
  628.  
  629. base.OnRenderItemText(e);
  630. }
  631.  
  632. protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
  633. {
  634. DrawVistaButtonBackground(e);
  635. }
  636.  
  637. protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
  638. {
  639. DrawVistaButtonBackground(e);
  640.  
  641. ToolStripDropDownButton item = e.Item as ToolStripDropDownButton; if (item == null) return;
  642.  
  643. Rectangle arrowBounds = new Rectangle(item.Width - 18, 0, 18, item.Height);
  644.  
  645. DrawArrow(new ToolStripArrowRenderEventArgs(
  646. e.Graphics, e.Item,
  647. arrowBounds,
  648. ColorTable.DropDownArrow, ArrowDirection.Down));
  649. }
  650.  
  651. protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
  652. {
  653. DrawVistaButtonBackground(e);
  654.  
  655. ToolStripSplitButton item = e.Item as ToolStripSplitButton; if(item==null) return;
  656.  
  657. Rectangle arrowBounds = item.DropDownButtonBounds;
  658. Rectangle buttonBounds = new Rectangle(item.ButtonBounds.Location, new Size(item.ButtonBounds.Width + 2, item.ButtonBounds.Height));
  659. Rectangle dropDownBounds = item.DropDownButtonBounds;
  660.  
  661. DrawVistaButtonBackground(e.Graphics, buttonBounds, item.ButtonSelected,
  662. item.ButtonPressed, false);
  663.  
  664. DrawVistaButtonBackground(e.Graphics, dropDownBounds, item.DropDownButtonSelected,
  665. item.DropDownButtonPressed, false);
  666.  
  667. DrawArrow(new ToolStripArrowRenderEventArgs(
  668. e.Graphics, e.Item,
  669. arrowBounds,
  670. ColorTable.DropDownArrow, ArrowDirection.Down));
  671. }
  672.  
  673. protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
  674. {
  675. if (!e.Item.Enabled)
  676. {
  677. base.OnRenderItemImage(e);
  678. }
  679. else
  680. {
  681. if (e.Image != null)
  682. {
  683. e.Graphics.DrawImage(e.Image, e.ImageRectangle);
  684. }
  685. }
  686.  
  687. }
  688.  
  689. protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
  690. {
  691. if (e.Item.Owner is MenuStrip)
  692. {
  693. DrawVistaButtonBackground(e);
  694. }
  695. else
  696. {
  697. DrawVistaMenuBackground(e.Graphics,
  698. new Rectangle(Point.Empty, e.Item.Size),
  699. e.Item.Selected, e.Item.Owner is MenuStrip);
  700.  
  701. }
  702.  
  703.  
  704. }
  705.  
  706. protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
  707. {
  708.  
  709.  
  710.  
  711. if (e.Item.IsOnDropDown)
  712. {
  713. int left = 20;
  714. int right = e.Item.Width - 3;
  715. int top = e.Item.Height / 2; top--;
  716.  
  717. //e.Graphics.Clear(ColorTable.MenuBackground);
  718.  
  719. using (Pen p = new Pen(ColorTable.MenuDark))
  720. {
  721. e.Graphics.DrawLine(p,
  722. new Point(left, top),
  723. new Point(right, top));
  724. }
  725.  
  726. using (Pen p = new Pen(ColorTable.MenuLight))
  727. {
  728. e.Graphics.DrawLine(p,
  729. new Point(left, top + 1),
  730. new Point(right, top + 1));
  731. }
  732. }
  733. else
  734. {
  735. int top = 3;
  736. int left = e.Item.Width / 2; left--;
  737. int height = e.Item.Height - top * 2;
  738. RectangleF separator = new RectangleF(left, top, 0.5f, height);
  739.  
  740. using (Brush b = new LinearGradientBrush(
  741. separator.Location,
  742. new Point(Convert.ToInt32(separator.Left), Convert.ToInt32(separator.Bottom)),
  743. ColorTable.SeparatorNorth, ColorTable.SeparatorSouth))
  744. {
  745. e.Graphics.FillRectangle(b, separator);
  746. }
  747. }
  748. }
  749.  
  750. protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
  751. {
  752. DrawVistaButtonBackground(e);
  753.  
  754. //Chevron is obtained from the character: » (Alt+0187)
  755. using (Brush b = new SolidBrush(e.Item.ForeColor))
  756. {
  757. StringFormat sf = new StringFormat();
  758. sf.Alignment = StringAlignment.Center;
  759. sf.LineAlignment = StringAlignment.Center;
  760.  
  761. Font f = new Font(e.Item.Font.FontFamily, 15);
  762.  
  763. e.Graphics.DrawString("»", f, b, new RectangleF(Point.Empty, e.Item.Size), sf);
  764. }
  765.  
  766. }
  767.  
  768. protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
  769. {
  770. if (e.Item is ToolStripMenuItem && e.Item.Selected)
  771. {
  772. e.ArrowColor = ColorTable.MenuText;
  773. }
  774.  
  775. base.OnRenderArrow(e);
  776. }
  777. }
  778. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/style/vista/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1732307957 22/11/2024 21:39:17
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/style/vista/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csGraphicsTools.cs3.9 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csWindowsVistaRenderer.cs26.15 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csWindowsVistaColorTable.cs9.6 Ko31/10/2018 18:33:22-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.

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 16/10/2009 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/cs-broldev-source-rf-view/style/vista//WindowsVistaRenderer.cs.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.