WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
NamedItemBase.cs
Go to the documentation of this file.
1 using System;
3 
4 namespace DirectOutput.General.Generic
5 {
10  public abstract class NamedItemBase : INamedItem
11  {
12  #region Name
13  private string _Name;
22  public string Name
23  {
24  get { return _Name; }
25  set
26  {
27  if (_Name != value)
28  {
29  string OldName = _Name;
30  OnBeforeNameChanged(OldName, value);
31  BeforeNameChange(OldName, value);
32  _Name = value;
33  AfterNameChange(OldName, value);
34  OnAfterNameChanged(OldName, value);
35 
36 
37  }
38  }
39  }
40 
41  protected virtual void AfterNameChange(string OldName, string NewName)
42  {
43 
44  }
45 
46  protected virtual void BeforeNameChange(string OldName, string NewName)
47  {
48 
49  }
50 
51  private void OnAfterNameChanged(string OldName,String NewName)
52  {
53  if (AfterNameChanged != null)
54  {
55  AfterNameChanged(this, new NameChangeEventArgs(OldName, NewName));
56  }
57  }
58 
59  private void OnBeforeNameChanged(string OldName, String NewName)
60  {
61  if (BeforeNameChanged != null)
62  {
63  BeforeNameChanged(this, new NameChangeEventArgs(OldName, NewName));
64  }
65  }
66 
70  public event EventHandler<NameChangeEventArgs> AfterNameChanged;
71 
75  public event EventHandler<NameChangeEventArgs> BeforeNameChanged;
76  #endregion
77 
78  public event PropertyChangedEventHandler PropertyChanged;
79 
80  protected virtual void OnPropertyChanged(string propertyName)
81  {
82  if (PropertyChanged != null)
83  {
84  PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
85  }
86  }
87 
88  public event PropertyChangingEventHandler PropertyChanging;
89 
90 
91  protected virtual void OnPropertyChanging(string propertyName)
92  {
93  if (PropertyChanging != null)
94  {
95  PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
96  }
97 
98  }
99 
100  }
101 }
Abstract base class for named items. Implements the name property and the necessary events...
PropertyChangingEventHandler PropertyChanging
virtual void OnPropertyChanging(string propertyName)
EventHandler< NameChangeEventArgs > BeforeNameChanged
Event is fired before the value of the property Name is changed.
virtual void OnPropertyChanged(string propertyName)
EventHandler< NameChangeEventArgs > AfterNameChanged
Event is fired after the value of the property Name has changed.
Interface for items which can be added the the NamedItemList.
Definition: INamedItem.cs:8
PropertyChangedEventHandler PropertyChanged
virtual void AfterNameChange(string OldName, string NewName)
virtual void BeforeNameChange(string OldName, string NewName)