xa1883d0b59b7005b.cs
上传用户:xlxx0122
上传日期:2015-04-24
资源大小:3904k
文件大小:12k
- namespace Sunisoft.IrisSkin
- {
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- [ToolboxItem(false)]
- internal class xa1883d0b59b7005b
- {
- protected static ImageList menuImages = x58dd58a96343fde0.LoadBitmapStrip(System.Type.GetType("Sunisoft.IrisSkin.SkinEngine"), "Sunisoft.IrisSkin.ImagesPopupMenu.bmp", new Size(0x10, 0x10), new Point(0, 0));
- private DrawItemEventHandler x2a5f0003704e39da;
- private MeasureItemEventHandler x60e3b5f01780bd33;
- private static Pen x8eaf2b1854fb0bf6 = new Pen(Color.FromArgb(0x84, 130, 0x84), 1f);
- private SkinEngine xcab6a0e662ada486;
- private System.Windows.Forms.Menu xcbf78b15dd820156;
- private static Brush xd4d28a8f36023ad0 = new SolidBrush(Color.Gray);
- public xa1883d0b59b7005b(SkinEngine engine, System.Windows.Forms.Menu menu)
- {
- this.xcab6a0e662ada486 = engine;
- this.xcbf78b15dd820156 = menu;
- if (menu != null)
- {
- this.x60e3b5f01780bd33 = new MeasureItemEventHandler(this.x763e46f2422fcb86);
- this.x2a5f0003704e39da = new DrawItemEventHandler(this.xd590f29a688f99d2);
- this.x5d04f127bbb82004();
- engine.CurrentSkinChanged += new SkinChanged(this.x9a0949aaa2f0a885);
- }
- }
- public static void DrawMenuBackGround(Graphics g, Rectangle rect, Brush brush)
- {
- g.FillRectangle(brush, rect);
- }
- public static void DrawMenuBorder(Graphics g, Rectangle rect, Brush brush)
- {
- Pen pen = new Pen(brush, 1f);
- g.DrawRectangle(pen, Rectangle.FromLTRB(rect.Right, rect.Left, rect.Top, rect.Bottom - 1));
- pen.Dispose();
- }
- public static void DrawMenuLineItem(Graphics g, Rectangle rect, Pen p, int barWidth)
- {
- g.DrawLine(p, (int) ((rect.Left + barWidth) + 4), (int) (rect.Top + 2), (int) (rect.Right - 2), (int) (rect.Top + 2));
- }
- private void x5d04f127bbb82004()
- {
- bool flag = this.xf2140268ef7ddbf7;
- ArrayList list = new ArrayList();
- ArrayList list2 = new ArrayList();
- foreach (MenuItem item2 in this.Menu.MenuItems)
- {
- item2.OwnerDraw = flag;
- list2.Add(item2);
- if (item2.MenuItems.Count > 0)
- {
- list.Add(item2);
- }
- }
- while (list.Count > 0)
- {
- MenuItem item = (MenuItem) list[0];
- list.RemoveAt(0);
- foreach (MenuItem item3 in item.MenuItems)
- {
- item3.OwnerDraw = flag;
- list2.Add(item3);
- if (item3.MenuItems.Count > 0)
- {
- list.Add(item3);
- }
- }
- }
- if (flag)
- {
- this.x76f955f9fcce00c1(list2);
- }
- }
- private void x763e46f2422fcb86(object xe0292b9ed559da7d, MeasureItemEventArgs xfbf34718e704c6bc)
- {
- MenuItem item = xe0292b9ed559da7d as MenuItem;
- if (item != null)
- {
- if ((item.Parent is MainMenu) || (item.Parent is ContextMenu))
- {
- xfbf34718e704c6bc.ItemHeight = 0;
- xfbf34718e704c6bc.ItemWidth = 0;
- }
- Font messageFont = x448fd9ab43628c71.GetMessageFont();
- SizeF ef = xfbf34718e704c6bc.Graphics.MeasureString(item.Text, messageFont, 0, x448fd9ab43628c71.MenuItemStringFormat);
- if (item.Text == "-")
- {
- xfbf34718e704c6bc.ItemHeight = 5;
- }
- else
- {
- xfbf34718e704c6bc.ItemHeight = ((int) ef.Height) + 5;
- }
- xfbf34718e704c6bc.ItemWidth = ((int) ef.Width) + 0x21;
- bool flag = false;
- int width = 0;
- int num2 = 0;
- if (item.Parent != null)
- {
- foreach (MenuItem item2 in item.Parent.MenuItems)
- {
- if (item2.Shortcut != Shortcut.None)
- {
- flag = true;
- width = (int) xfbf34718e704c6bc.Graphics.MeasureString(x448fd9ab43628c71.GetShortCutString(item2.Shortcut), messageFont, 0, x448fd9ab43628c71.MenuItemShortcutFormat).Width;
- if (num2 < width)
- {
- num2 = width;
- }
- }
- }
- }
- if (flag)
- {
- xfbf34718e704c6bc.ItemWidth += num2;
- xfbf34718e704c6bc.ItemWidth += 10;
- }
- }
- }
- private void x76f955f9fcce00c1(ArrayList xf8b54ce7724a27f2)
- {
- foreach (object obj2 in xf8b54ce7724a27f2)
- {
- MenuItem item = (MenuItem) obj2;
- item.OwnerDraw = true;
- item.MeasureItem += this.x60e3b5f01780bd33;
- item.DrawItem += this.x2a5f0003704e39da;
- }
- }
- private void x9a0949aaa2f0a885(object xe0292b9ed559da7d, SkinChangedEventArgs xfbf34718e704c6bc)
- {
- this.x5d04f127bbb82004();
- }
- private void xd590f29a688f99d2(object xe0292b9ed559da7d, DrawItemEventArgs xfbf34718e704c6bc)
- {
- Rectangle rectangle;
- Brush brush;
- if (!this.xf2140268ef7ddbf7)
- {
- return;
- }
- MenuItem item = xe0292b9ed559da7d as MenuItem;
- if (item.Parent is MainMenu)
- {
- return;
- }
- if (item == null)
- {
- return;
- }
- Rectangle bounds = xfbf34718e704c6bc.Bounds;
- x448fd9ab43628c71.GetMessageFont();
- if (!(item.Text == "-"))
- {
- if (((xfbf34718e704c6bc.State & DrawItemState.Selected) == DrawItemState.Selected) && ((xfbf34718e704c6bc.State & DrawItemState.Disabled) != DrawItemState.Disabled))
- {
- DrawMenuBackGround(xfbf34718e704c6bc.Graphics, bounds, this.xcab6a0e662ada486.Res.Brushes.SKIN2_SELECTEDMENUCOLOR);
- DrawMenuBorder(xfbf34718e704c6bc.Graphics, bounds, this.xcab6a0e662ada486.Res.Brushes.SKIN2_SELECTEDMENUBORDERCOLOR);
- goto Label_02CD;
- }
- rectangle = Rectangle.FromLTRB(bounds.Left, bounds.Top, bounds.Left + 0x1a, bounds.Bottom);
- if (this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARSTARTCOLOR != this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARENDCOLOR)
- {
- using (LinearGradientBrush brush3 = new LinearGradientBrush(rectangle, this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARSTARTCOLOR, this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARENDCOLOR, LinearGradientMode.Horizontal))
- {
- xfbf34718e704c6bc.Graphics.FillRectangle(brush3, rectangle);
- goto Label_0287;
- }
- }
- DrawMenuBackGround(xfbf34718e704c6bc.Graphics, rectangle, this.xcab6a0e662ada486.Res.Brushes.SKIN2_LEFTBARSTARTCOLOR);
- goto Label_0287;
- }
- rectangle = Rectangle.FromLTRB(bounds.Left, bounds.Top, bounds.Left + 0x1a, bounds.Bottom);
- if (this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARSTARTCOLOR != this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARENDCOLOR)
- {
- using (LinearGradientBrush brush2 = new LinearGradientBrush(rectangle, this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARSTARTCOLOR, this.xcab6a0e662ada486.Res.Colors.SKIN2_LEFTBARENDCOLOR, LinearGradientMode.Horizontal))
- {
- xfbf34718e704c6bc.Graphics.FillRectangle(brush2, rectangle);
- goto Label_010A;
- }
- }
- DrawMenuBackGround(xfbf34718e704c6bc.Graphics, rectangle, this.xcab6a0e662ada486.Res.Brushes.SKIN2_LEFTBARSTARTCOLOR);
- Label_010A:
- rectangle = Rectangle.FromLTRB(bounds.Left + 0x1a, bounds.Top, bounds.Right, bounds.Bottom);
- DrawMenuBackGround(xfbf34718e704c6bc.Graphics, rectangle, this.xcab6a0e662ada486.Res.Brushes.SKIN2_MENUITEMCOLOR);
- DrawMenuLineItem(xfbf34718e704c6bc.Graphics, bounds, x8eaf2b1854fb0bf6, 0x1a);
- return;
- Label_0287:
- rectangle = Rectangle.FromLTRB(bounds.Left + 0x1a, bounds.Top, bounds.Right, bounds.Bottom);
- DrawMenuBackGround(xfbf34718e704c6bc.Graphics, rectangle, this.xcab6a0e662ada486.Res.Brushes.SKIN2_MENUITEMCOLOR);
- Label_02CD:
- if ((xfbf34718e704c6bc.State & DrawItemState.Disabled) != DrawItemState.Disabled)
- {
- if ((xfbf34718e704c6bc.State & DrawItemState.Selected) == DrawItemState.Selected)
- {
- brush = this.xcab6a0e662ada486.Res.Brushes.SKIN2_SELECTEDMENUFONTCOLOR;
- }
- else
- {
- brush = this.xcab6a0e662ada486.Res.Brushes.SKIN2_MENUITEMFONTCOLOR;
- }
- }
- else
- {
- brush = xd4d28a8f36023ad0;
- }
- DrawItemState state1 = xfbf34718e704c6bc.State & DrawItemState.Default;
- if (item.Checked)
- {
- Image image;
- if (item.RadioCheck)
- {
- image = menuImages.Images[1];
- }
- else
- {
- image = this.xcab6a0e662ada486.Res.Bitmaps.SKIN2_CHECKEDMENUICON;
- }
- xfbf34718e704c6bc.Graphics.DrawImageUnscaled(image, bounds.X, bounds.Y);
- }
- rectangle = Rectangle.FromLTRB(bounds.Left + 30, bounds.Top, bounds.Right, bounds.Bottom);
- ContextMenu contextMenu = item.GetContextMenu();
- if ((contextMenu != null) && ((contextMenu.RightToLeft & RightToLeft.Yes) == RightToLeft.Yes))
- {
- xfbf34718e704c6bc.Graphics.DrawString(item.Text, xfbf34718e704c6bc.Font, brush, rectangle, x448fd9ab43628c71.MenuItemStringFormatR);
- }
- else
- {
- xfbf34718e704c6bc.Graphics.DrawString(item.Text, xfbf34718e704c6bc.Font, brush, rectangle, x448fd9ab43628c71.MenuItemStringFormat);
- }
- if (item.Shortcut != Shortcut.None)
- {
- rectangle = Rectangle.FromLTRB(bounds.Left, bounds.Top, bounds.Right - 10, bounds.Bottom);
- xfbf34718e704c6bc.Graphics.DrawString(x448fd9ab43628c71.GetShortCutString(item.Shortcut), xfbf34718e704c6bc.Font, brush, rectangle, x448fd9ab43628c71.MenuItemShortcutFormat);
- }
- }
- public System.Windows.Forms.Menu Menu
- {
- get
- {
- return this.xcbf78b15dd820156;
- }
- }
- private bool xf2140268ef7ddbf7
- {
- get
- {
- return this.xcab6a0e662ada486.RealActive;
- }
- }
- }
- }