Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
RoutedEventHandlerInfo.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.Paradox.UI.Events
6 {
7  internal abstract class RoutedEventHandlerInfo
8  {
9  public bool HandledEventToo { get; private set; }
10 
11  public abstract void Invoke(object sender, RoutedEventArgs args);
12 
13  public abstract Delegate Handler { get; }
14 
15  protected RoutedEventHandlerInfo(bool handledEventToo)
16  {
17  HandledEventToo = handledEventToo;
18  }
19 
20  public override bool Equals(object obj)
21  {
22  var castedObj = (RoutedEventHandlerInfo)obj;
23  return Handler.Equals(castedObj.Handler);
24  }
25 
26  public override int GetHashCode()
27  {
28  return Handler.GetHashCode();
29  }
30  }
31 
32  internal class RoutedEventHandlerInfo<T> : RoutedEventHandlerInfo where T : RoutedEventArgs
33  {
34  public EventHandler<T> RoutedEventHandler { get; private set; }
35 
36  public RoutedEventHandlerInfo(EventHandler<T> routedEventHandler, bool handledEventToo = false)
37  : base(handledEventToo)
38  {
39  RoutedEventHandler = routedEventHandler;
40  }
41 
42  public override void Invoke(object sender, RoutedEventArgs args)
43  {
44  RoutedEventHandler(sender, (T)args);
45  }
46 
47  public override Delegate Handler
48  {
49  get { return RoutedEventHandler; }
50  }
51  }
52 }