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

.net编程

开发平台:

C#

  1. namespace Sunisoft.IrisSkin
  2. {
  3.     using System;
  4.     using System.Collections;
  5.     using System.Windows.Forms;
  6.     public class Skin3rdControl : NativeWindow, IDisposable
  7.     {
  8.         protected Control Ctrl;
  9.         protected SkinEngine Engine;
  10.         protected Hashtable skinControlList = new Hashtable();
  11.         private bool x230e512478b11e00 = true;
  12.         public Skin3rdControl(Control control, SkinEngine engine)
  13.         {
  14.             this.Ctrl = control;
  15.             this.Engine = engine;
  16.             this.DoInit();
  17.             this.x172fd1e80a81620d();
  18.         }
  19.         protected virtual void AfterWndProc(ref Message m)
  20.         {
  21.         }
  22.         protected virtual bool BeforeWndProc(ref Message m)
  23.         {
  24.             return true;
  25.         }
  26.         public void Dispose()
  27.         {
  28.         }
  29.         protected virtual void DoInit()
  30.         {
  31.             this.Engine.CurrentSkinChanged += new SkinChanged(this.x8c06ad1b432b98eb);
  32.             base.AssignHandle(this.Ctrl.Handle);
  33.         }
  34.         protected virtual void DoUnInit()
  35.         {
  36.         }
  37.         protected virtual void OnCurrentSkinChanged(object sender, SkinChangedEventArgs e)
  38.         {
  39.             if (this.CanPaint)
  40.             {
  41.                 this.xb1ee1b6293236c5f();
  42.             }
  43.             this.Ctrl.Refresh();
  44.         }
  45.         protected virtual void PaintControl()
  46.         {
  47.         }
  48.         protected override void WndProc(ref Message m)
  49.         {
  50.             if (this.CanPaint)
  51.             {
  52.                 if (this.BeforeWndProc(ref m))
  53.                 {
  54.                     base.WndProc(ref m);
  55.                 }
  56.                 this.AfterWndProc(ref m);
  57.             }
  58.             else
  59.             {
  60.                 base.WndProc(ref m);
  61.             }
  62.         }
  63.         private void x172fd1e80a81620d()
  64.         {
  65.             this.Ctrl.ControlAdded += new ControlEventHandler(this.xd34eabd7bd15b71a);
  66.             this.Ctrl.ControlRemoved += new ControlEventHandler(this.xf8f5e344dcfab3e8);
  67.             if (this.CanPaint)
  68.             {
  69.                 ArrayList list = new ArrayList();
  70.                 foreach (Control control in this.Ctrl.Controls)
  71.                 {
  72.                     if (!this.skinControlList.ContainsKey(control.Handle))
  73.                     {
  74.                         list.Add(control);
  75.                     }
  76.                 }
  77.                 foreach (Control control2 in list)
  78.                 {
  79.                     if (!this.skinControlList.ContainsKey(control2.Handle))
  80.                     {
  81.                         xbd3f2493841f18a1 xbdffa = xf3f6919ac5d158dc.Create(control2, this.Engine);
  82.                         this.skinControlList.Add(control2.Handle, xbdffa);
  83.                     }
  84.                 }
  85.             }
  86.         }
  87.         internal void x52b190e626f65140()
  88.         {
  89.             foreach (object obj2 in this.skinControlList.Values)
  90.             {
  91.                 if (obj2 is xbd3f2493841f18a1)
  92.                 {
  93.                     ((xbd3f2493841f18a1) obj2).x52b190e626f65140();
  94.                 }
  95.             }
  96.             this.x230e512478b11e00 = false;
  97.             this.OnCurrentSkinChanged(null, new SkinChangedEventArgs(false));
  98.         }
  99.         private void x8c06ad1b432b98eb(object xe0292b9ed559da7d, SkinChangedEventArgs xfbf34718e704c6bc)
  100.         {
  101.             this.OnCurrentSkinChanged(xe0292b9ed559da7d, xfbf34718e704c6bc);
  102.         }
  103.         private void xb1ee1b6293236c5f()
  104.         {
  105.             if (this.CanPaint)
  106.             {
  107.                 ArrayList list = new ArrayList();
  108.                 foreach (Control control in this.Ctrl.Controls)
  109.                 {
  110.                     if (!this.skinControlList.ContainsKey(control.Handle))
  111.                     {
  112.                         list.Add(control);
  113.                     }
  114.                 }
  115.                 foreach (Control control2 in list)
  116.                 {
  117.                     if (!this.skinControlList.ContainsKey(control2.Handle))
  118.                     {
  119.                         xbd3f2493841f18a1 xbdffa = xf3f6919ac5d158dc.Create(control2, this.Engine);
  120.                         this.skinControlList.Add(control2.Handle, xbdffa);
  121.                     }
  122.                 }
  123.             }
  124.         }
  125.         private void xd34eabd7bd15b71a(object xe0292b9ed559da7d, ControlEventArgs xfbf34718e704c6bc)
  126.         {
  127.             if (this.CanPaint)
  128.             {
  129.                 Control control = xfbf34718e704c6bc.Control;
  130.                 if (!this.skinControlList.ContainsKey(control.Handle))
  131.                 {
  132.                     xbd3f2493841f18a1 xbdffa = xf3f6919ac5d158dc.Create(control, this.Engine);
  133.                     this.skinControlList.Add(control.Handle, xbdffa);
  134.                 }
  135.             }
  136.         }
  137.         private void xf8f5e344dcfab3e8(object xe0292b9ed559da7d, ControlEventArgs xfbf34718e704c6bc)
  138.         {
  139.         }
  140.         protected bool CanPaint
  141.         {
  142.             get
  143.             {
  144.                 if (!this.x230e512478b11e00)
  145.                 {
  146.                     return false;
  147.                 }
  148.                 if (this.Ctrl.IsDisposed)
  149.                 {
  150.                     return false;
  151.                 }
  152.                 if (!this.Engine.RealActive)
  153.                 {
  154.                     return false;
  155.                 }
  156.                 if (this.Ctrl.Tag is int)
  157.                 {
  158.                     if (((int) this.Ctrl.Tag) == this.Engine.DisableTag)
  159.                     {
  160.                         return false;
  161.                     }
  162.                     return true;
  163.                 }
  164.                 if ((this.Ctrl.Tag is string) && (((string) this.Ctrl.Tag) == this.Engine.DisableTag.ToString()))
  165.                 {
  166.                     return false;
  167.                 }
  168.                 return true;
  169.             }
  170.         }
  171.     }
  172. }