xa1883d0b59b7005b.cs
上传用户:xlxx0122
上传日期:2015-04-24
资源大小:3904k
文件大小:12k
源码类别:

.net编程

开发平台:

C#

  1. namespace Sunisoft.IrisSkin
  2. {
  3.     using System;
  4.     using System.Collections;
  5.     using System.ComponentModel;
  6.     using System.Drawing;
  7.     using System.Drawing.Drawing2D;
  8.     using System.Windows.Forms;
  9.     [ToolboxItem(false)]
  10.     internal class xa1883d0b59b7005b
  11.     {
  12.         protected static ImageList menuImages = x58dd58a96343fde0.LoadBitmapStrip(System.Type.GetType("Sunisoft.IrisSkin.SkinEngine"), "Sunisoft.IrisSkin.ImagesPopupMenu.bmp", new Size(0x10, 0x10), new Point(0, 0));
  13.         private DrawItemEventHandler x2a5f0003704e39da;
  14.         private MeasureItemEventHandler x60e3b5f01780bd33;
  15.         private static Pen x8eaf2b1854fb0bf6 = new Pen(Color.FromArgb(0x84, 130, 0x84), 1f);
  16.         private SkinEngine xcab6a0e662ada486;
  17.         private System.Windows.Forms.Menu xcbf78b15dd820156;
  18.         private static Brush xd4d28a8f36023ad0 = new SolidBrush(Color.Gray);
  19.         public xa1883d0b59b7005b(SkinEngine engine, System.Windows.Forms.Menu menu)
  20.         {
  21.             this.xcab6a0e662ada486 = engine;
  22.             this.xcbf78b15dd820156 = menu;
  23.             if (menu != null)
  24.             {
  25.                 this.x60e3b5f01780bd33 = new MeasureItemEventHandler(this.x763e46f2422fcb86);
  26.                 this.x2a5f0003704e39da = new DrawItemEventHandler(this.xd590f29a688f99d2);
  27.                 this.x5d04f127bbb82004();
  28.                 engine.CurrentSkinChanged += new SkinChanged(this.x9a0949aaa2f0a885);
  29.             }
  30.         }
  31.         public static void DrawMenuBackGround(Graphics g, Rectangle rect, Brush brush)
  32.         {
  33.             g.FillRectangle(brush, rect);
  34.         }
  35.         public static void DrawMenuBorder(Graphics g, Rectangle rect, Brush brush)
  36.         {
  37.             Pen pen = new Pen(brush, 1f);
  38.             g.DrawRectangle(pen, Rectangle.FromLTRB(rect.Right, rect.Left, rect.Top, rect.Bottom - 1));
  39.             pen.Dispose();
  40.         }
  41.         public static void DrawMenuLineItem(Graphics g, Rectangle rect, Pen p, int barWidth)
  42.         {
  43.             g.DrawLine(p, (int) ((rect.Left + barWidth) + 4), (int) (rect.Top + 2), (int) (rect.Right - 2), (int) (rect.Top + 2));
  44.         }
  45.         private void x5d04f127bbb82004()
  46.         {
  47.             bool flag = this.xf2140268ef7ddbf7;
  48.             ArrayList list = new ArrayList();
  49.             ArrayList list2 = new ArrayList();
  50.             foreach (MenuItem item2 in this.Menu.MenuItems)
  51.             {
  52.                 item2.OwnerDraw = flag;
  53.                 list2.Add(item2);
  54.                 if (item2.MenuItems.Count > 0)
  55.                 {
  56.                     list.Add(item2);
  57.                 }
  58.             }
  59.             while (list.Count > 0)
  60.             {
  61.                 MenuItem item = (MenuItem) list[0];
  62.                 list.RemoveAt(0);
  63.                 foreach (MenuItem item3 in item.MenuItems)
  64.                 {
  65.                     item3.OwnerDraw = flag;
  66.                     list2.Add(item3);
  67.                     if (item3.MenuItems.Count > 0)
  68.                     {
  69.                         list.Add(item3);
  70.                     }
  71.                 }
  72.             }
  73.             if (flag)
  74.             {
  75.                 this.x76f955f9fcce00c1(list2);
  76.             }
  77.         }
  78.         private void x763e46f2422fcb86(object xe0292b9ed559da7d, MeasureItemEventArgs xfbf34718e704c6bc)
  79.         {
  80.             MenuItem item = xe0292b9ed559da7d as MenuItem;
  81.             if (item != null)
  82.             {
  83.                 if ((item.Parent is MainMenu) || (item.Parent is ContextMenu))
  84.                 {
  85.                     xfbf34718e704c6bc.ItemHeight = 0;
  86.                     xfbf34718e704c6bc.ItemWidth = 0;
  87.                 }
  88.                 Font messageFont = x448fd9ab43628c71.GetMessageFont();
  89.                 SizeF ef = xfbf34718e704c6bc.Graphics.MeasureString(item.Text, messageFont, 0, x448fd9ab43628c71.MenuItemStringFormat);
  90.                 if (item.Text == "-")
  91.                 {
  92.                     xfbf34718e704c6bc.ItemHeight = 5;
  93.                 }
  94.                 else
  95.                 {
  96.                     xfbf34718e704c6bc.ItemHeight = ((int) ef.Height) + 5;
  97.                 }
  98.                 xfbf34718e704c6bc.ItemWidth = ((int) ef.Width) + 0x21;
  99.                 bool flag = false;
  100.                 int width = 0;
  101.                 int num2 = 0;
  102.                 if (item.Parent != null)
  103.                 {
  104.                     foreach (MenuItem item2 in item.Parent.MenuItems)
  105.                     {
  106.                         if (item2.Shortcut != Shortcut.None)
  107.                         {
  108.                             flag = true;
  109.                             width = (int) xfbf34718e704c6bc.Graphics.MeasureString(x448fd9ab43628c71.GetShortCutString(item2.Shortcut), messageFont, 0, x448fd9ab43628c71.MenuItemShortcutFormat).Width;
  110.                             if (num2 < width)
  111.                             {
  112.                                 num2 = width;
  113.                             }
  114.                         }
  115.                     }
  116.                 }
  117.                 if (flag)
  118.                 {
  119.                     xfbf34718e704c6bc.ItemWidth += num2;
  120.                     xfbf34718e704c6bc.ItemWidth += 10;
  121.                 }
  122.             }
  123.         }
  124.         private void x76f955f9fcce00c1(ArrayList xf8b54ce7724a27f2)
  125.         {
  126.             foreach (object obj2 in xf8b54ce7724a27f2)
  127.             {
  128.                 MenuItem item = (MenuItem) obj2;
  129.                 item.OwnerDraw = true;
  130.                 item.MeasureItem += this.x60e3b5f01780bd33;
  131.                 item.DrawItem += this.x2a5f0003704e39da;
  132.             }
  133.         }
  134.         private void x9a0949aaa2f0a885(object xe0292b9ed559da7d, SkinChangedEventArgs xfbf34718e704c6bc)
  135.         {
  136.             this.x5d04f127bbb82004();
  137.         }
  138.         private void xd590f29a688f99d2(object xe0292b9ed559da7d, DrawItemEventArgs xfbf34718e704c6bc)
  139.         {
  140.             Rectangle rectangle;
  141.             Brush brush;
  142.             if (!this.xf2140268ef7ddbf7)
  143.             {
  144.                 return;
  145.             }
  146.             MenuItem item = xe0292b9ed559da7d as MenuItem;
  147.             if (item.Parent is MainMenu)
  148.             {
  149.                 return;
  150.             }
  151.             if (item == null)
  152.             {
  153.                 return;
  154.             }
  155.             Rectangle bounds = xfbf34718e704c6bc.Bounds;
  156.             x448fd9ab43628c71.GetMessageFont();
  157.             if (!(item.Text == "-"))
  158.             {
  159.                 if (((xfbf34718e704c6bc.State & DrawItemState.Selected) == DrawItemState.Selected) && ((xfbf34718e704c6bc.State & DrawItemState.Disabled) != DrawItemState.Disabled))
  160.                 {
  161.                     DrawMenuBackGround(xfbf34718e704c6bc.Graphics, bounds, this.xcab6a0e662ada486.Res.Brushes.SKIN2_SELECTEDMENUCOLOR);
  162.                     DrawMenuBorder(xfbf34718e704c6bc.Graphics, bounds, this.xcab6a0e662ada486.Res.Brushes.SKIN2_SELECTEDMENUBORDERCOLOR);
  163.                     goto Label_02CD;
  164.                 }
  165.                 rectangle = Rectangle.FromLTRB(bounds.Left, bounds.Top, bounds.Left + 0x1a, bounds.Bottom);
  166.                 if (this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARSTARTCOLOR != this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARENDCOLOR)
  167.                 {
  168.                     using (LinearGradientBrush brush3 = new LinearGradientBrush(rectangle, this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARSTARTCOLOR, this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARENDCOLOR, LinearGradientMode.Horizontal))
  169.                     {
  170.                         xfbf34718e704c6bc.Graphics.FillRectangle(brush3, rectangle);
  171.                         goto Label_0287;
  172.                     }
  173.                 }
  174.                 DrawMenuBackGround(xfbf34718e704c6bc.Graphics, rectangle, this.xcab6a0e662ada486.Res.Brushes.SKIN2_LEFTBARSTARTCOLOR);
  175.                 goto Label_0287;
  176.             }
  177.             rectangle = Rectangle.FromLTRB(bounds.Left, bounds.Top, bounds.Left + 0x1a, bounds.Bottom);
  178.             if (this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARSTARTCOLOR != this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARENDCOLOR)
  179.             {
  180.                 using (LinearGradientBrush brush2 = new LinearGradientBrush(rectangle, this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARSTARTCOLOR, this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARENDCOLOR, LinearGradientMode.Horizontal))
  181.                 {
  182.                     xfbf34718e704c6bc.Graphics.FillRectangle(brush2, rectangle);
  183.                     goto Label_010A;
  184.                 }
  185.             }
  186.             DrawMenuBackGround(xfbf34718e704c6bc.Graphics, rectangle, this.xcab6a0e662ada486.Res.Brushes.SKIN2_LEFTBARSTARTCOLOR);
  187.         Label_010A:
  188.             rectangle = Rectangle.FromLTRB(bounds.Left + 0x1a, bounds.Top, bounds.Right, bounds.Bottom);
  189.             DrawMenuBackGround(xfbf34718e704c6bc.Graphics, rectangle, this.xcab6a0e662ada486.Res.Brushes.SKIN2_MENUITEMCOLOR);
  190.             DrawMenuLineItem(xfbf34718e704c6bc.Graphics, bounds, x8eaf2b1854fb0bf6, 0x1a);
  191.             return;
  192.         Label_0287:
  193.             rectangle = Rectangle.FromLTRB(bounds.Left + 0x1a, bounds.Top, bounds.Right, bounds.Bottom);
  194.             DrawMenuBackGround(xfbf34718e704c6bc.Graphics, rectangle, this.xcab6a0e662ada486.Res.Brushes.SKIN2_MENUITEMCOLOR);
  195.         Label_02CD:
  196.             if ((xfbf34718e704c6bc.State & DrawItemState.Disabled) != DrawItemState.Disabled)
  197.             {
  198.                 if ((xfbf34718e704c6bc.State & DrawItemState.Selected) == DrawItemState.Selected)
  199.                 {
  200.                     brush = this.xcab6a0e662ada486.Res.Brushes.SKIN2_SELECTEDMENUFONTCOLOR;
  201.                 }
  202.                 else
  203.                 {
  204.                     brush = this.xcab6a0e662ada486.Res.Brushes.SKIN2_MENUITEMFONTCOLOR;
  205.                 }
  206.             }
  207.             else
  208.             {
  209.                 brush = xd4d28a8f36023ad0;
  210.             }
  211.             DrawItemState state1 = xfbf34718e704c6bc.State & DrawItemState.Default;
  212.             if (item.Checked)
  213.             {
  214.                 Image image;
  215.                 if (item.RadioCheck)
  216.                 {
  217.                     image = menuImages.Images[1];
  218.                 }
  219.                 else
  220.                 {
  221.                     image = this.xcab6a0e662ada486.Res.Bitmaps.SKIN2_CHECKEDMENUICON;
  222.                 }
  223.                 xfbf34718e704c6bc.Graphics.DrawImageUnscaled(image, bounds.X, bounds.Y);
  224.             }
  225.             rectangle = Rectangle.FromLTRB(bounds.Left + 30, bounds.Top, bounds.Right, bounds.Bottom);
  226.             ContextMenu contextMenu = item.GetContextMenu();
  227.             if ((contextMenu != null) && ((contextMenu.RightToLeft & RightToLeft.Yes) == RightToLeft.Yes))
  228.             {
  229.                 xfbf34718e704c6bc.Graphics.DrawString(item.Text, xfbf34718e704c6bc.Font, brush, rectangle, x448fd9ab43628c71.MenuItemStringFormatR);
  230.             }
  231.             else
  232.             {
  233.                 xfbf34718e704c6bc.Graphics.DrawString(item.Text, xfbf34718e704c6bc.Font, brush, rectangle, x448fd9ab43628c71.MenuItemStringFormat);
  234.             }
  235.             if (item.Shortcut != Shortcut.None)
  236.             {
  237.                 rectangle = Rectangle.FromLTRB(bounds.Left, bounds.Top, bounds.Right - 10, bounds.Bottom);
  238.                 xfbf34718e704c6bc.Graphics.DrawString(x448fd9ab43628c71.GetShortCutString(item.Shortcut), xfbf34718e704c6bc.Font, brush, rectangle, x448fd9ab43628c71.MenuItemShortcutFormat);
  239.             }
  240.         }
  241.         public System.Windows.Forms.Menu Menu
  242.         {
  243.             get
  244.             {
  245.                 return this.xcbf78b15dd820156;
  246.             }
  247.         }
  248.         private bool xf2140268ef7ddbf7
  249.         {
  250.             get
  251.             {
  252.                 return this.xcab6a0e662ada486.RealActive;
  253.             }
  254.         }
  255.     }
  256. }