te
This commit is contained in:
parent
01151e679b
commit
57b2f0400e
265 changed files with 22828 additions and 6 deletions
229
Unused/Decal.Adapter.Wrappers/ButtonWrapper.cs
Normal file
229
Unused/Decal.Adapter.Wrappers/ButtonWrapper.cs
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using Decal.Adapter.Support;
|
||||
using Decal.Interop.Inject;
|
||||
|
||||
namespace Decal.Adapter.Wrappers;
|
||||
|
||||
public class ButtonWrapper : ControlWrapperBase<ButtonClass>
|
||||
{
|
||||
private EventHandler<ControlEventArgs> evtClick;
|
||||
|
||||
private EventHandler<ControlEventArgs> evtCancel;
|
||||
|
||||
private EventHandler<ControlEventArgs> evtDestroy;
|
||||
|
||||
private EventHandler<ControlEventArgs> evtHit;
|
||||
|
||||
private EventHandler<ControlEventArgs> evtUnhit;
|
||||
|
||||
private int myBackground;
|
||||
|
||||
public Color Matte
|
||||
{
|
||||
get
|
||||
{
|
||||
return Util.ColorFromBGR(base.Control.Matte);
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Control.Matte = Util.ColorToBGR(value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Background
|
||||
{
|
||||
get
|
||||
{
|
||||
return myBackground;
|
||||
}
|
||||
set
|
||||
{
|
||||
myBackground = value;
|
||||
base.Control.SetBackground(myBackground);
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<ControlEventArgs> Click
|
||||
{
|
||||
add
|
||||
{
|
||||
if (evtClick == null)
|
||||
{
|
||||
base.Control.Accepted += ClickEvent;
|
||||
}
|
||||
evtClick = (EventHandler<ControlEventArgs>)Delegate.Combine(evtClick, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
evtClick = (EventHandler<ControlEventArgs>)Delegate.Remove(evtClick, value);
|
||||
if (evtClick == null)
|
||||
{
|
||||
base.Control.Accepted -= ClickEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<ControlEventArgs> Canceled
|
||||
{
|
||||
add
|
||||
{
|
||||
if (evtCancel == null)
|
||||
{
|
||||
base.Control.Canceled += CanceledEvent;
|
||||
}
|
||||
evtCancel = (EventHandler<ControlEventArgs>)Delegate.Combine(evtCancel, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
evtCancel = (EventHandler<ControlEventArgs>)Delegate.Remove(evtCancel, value);
|
||||
if (evtCancel == null)
|
||||
{
|
||||
base.Control.Canceled -= CanceledEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<ControlEventArgs> Destroy
|
||||
{
|
||||
add
|
||||
{
|
||||
if (evtDestroy == null)
|
||||
{
|
||||
base.Control.Destroy += DestroyEvent;
|
||||
}
|
||||
evtDestroy = (EventHandler<ControlEventArgs>)Delegate.Combine(evtDestroy, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
evtDestroy = (EventHandler<ControlEventArgs>)Delegate.Remove(evtDestroy, value);
|
||||
if (evtDestroy == null)
|
||||
{
|
||||
base.Control.Destroy -= DestroyEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<ControlEventArgs> Hit
|
||||
{
|
||||
add
|
||||
{
|
||||
if (evtHit == null)
|
||||
{
|
||||
base.Control.Hit += HitEvent;
|
||||
}
|
||||
evtHit = (EventHandler<ControlEventArgs>)Delegate.Combine(evtHit, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
evtHit = (EventHandler<ControlEventArgs>)Delegate.Remove(evtHit, value);
|
||||
if (evtHit == null)
|
||||
{
|
||||
base.Control.Hit -= HitEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<ControlEventArgs> Unhit
|
||||
{
|
||||
add
|
||||
{
|
||||
if (evtUnhit == null)
|
||||
{
|
||||
base.Control.Unhit += UnhitEvent;
|
||||
}
|
||||
evtUnhit = (EventHandler<ControlEventArgs>)Delegate.Combine(evtUnhit, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
evtUnhit = (EventHandler<ControlEventArgs>)Delegate.Remove(evtUnhit, value);
|
||||
if (evtUnhit == null)
|
||||
{
|
||||
base.Control.Unhit -= UnhitEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (evtClick != null)
|
||||
{
|
||||
evtClick = (EventHandler<ControlEventArgs>)Delegate.Remove(evtClick, evtClick);
|
||||
base.Control.Accepted -= ClickEvent;
|
||||
}
|
||||
if (evtCancel != null)
|
||||
{
|
||||
evtCancel = (EventHandler<ControlEventArgs>)Delegate.Remove(evtCancel, evtCancel);
|
||||
base.Control.Canceled -= CanceledEvent;
|
||||
}
|
||||
if (evtDestroy != null)
|
||||
{
|
||||
evtDestroy = (EventHandler<ControlEventArgs>)Delegate.Remove(evtDestroy, evtDestroy);
|
||||
base.Control.Destroy -= DestroyEvent;
|
||||
}
|
||||
if (evtHit != null)
|
||||
{
|
||||
evtHit = (EventHandler<ControlEventArgs>)Delegate.Remove(evtHit, evtHit);
|
||||
base.Control.Hit -= HitEvent;
|
||||
}
|
||||
if (evtUnhit != null)
|
||||
{
|
||||
evtUnhit = (EventHandler<ControlEventArgs>)Delegate.Remove(evtUnhit, evtUnhit);
|
||||
base.Control.Unhit -= UnhitEvent;
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public void SetImages(int released, int pressed)
|
||||
{
|
||||
SetImages(0, released, pressed);
|
||||
}
|
||||
|
||||
public void SetImages(int module, int released, int pressed)
|
||||
{
|
||||
base.Control.SetImages(module, released, pressed);
|
||||
}
|
||||
|
||||
private void ClickEvent(int ID)
|
||||
{
|
||||
if (evtClick != null)
|
||||
{
|
||||
evtClick(this, new ControlEventArgs(ID));
|
||||
}
|
||||
}
|
||||
|
||||
private void UnhitEvent(int ID)
|
||||
{
|
||||
if (evtUnhit != null)
|
||||
{
|
||||
evtUnhit(this, new ControlEventArgs(ID));
|
||||
}
|
||||
}
|
||||
|
||||
private void HitEvent(int ID)
|
||||
{
|
||||
if (evtHit != null)
|
||||
{
|
||||
evtHit(this, new ControlEventArgs(ID));
|
||||
}
|
||||
}
|
||||
|
||||
private void DestroyEvent(int ID)
|
||||
{
|
||||
if (evtDestroy != null)
|
||||
{
|
||||
evtDestroy(this, new ControlEventArgs(ID));
|
||||
}
|
||||
}
|
||||
|
||||
private void CanceledEvent(int ID)
|
||||
{
|
||||
if (evtCancel != null)
|
||||
{
|
||||
evtCancel(this, new ControlEventArgs(ID));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue