81 lines
1.9 KiB
C#
81 lines
1.9 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
|
|
namespace FrameworkTest.PropertyGridTest
|
|
{
|
|
public class Person : INotifyPropertyChanged
|
|
{
|
|
private string _firstname;
|
|
[Browsable(true)]
|
|
public string FirstName
|
|
{
|
|
get { return _firstname; }
|
|
set
|
|
{
|
|
_firstname = value;
|
|
OnPropertyChanged("FirstName");
|
|
}
|
|
}
|
|
|
|
private string _surname;
|
|
[Browsable(true)]
|
|
public string SurName
|
|
{
|
|
get { return _surname; }
|
|
set
|
|
{
|
|
_surname = value;
|
|
OnPropertyChanged("SurName");
|
|
}
|
|
}
|
|
|
|
private Person _spouse;
|
|
[Browsable(true)]
|
|
public Person Spouse
|
|
{
|
|
get { return _spouse; }
|
|
set
|
|
{
|
|
_spouse = value;
|
|
OnPropertyChanged("Spouse");
|
|
}
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
if (!string.IsNullOrEmpty(FirstName) && !string.IsNullOrEmpty(SurName))
|
|
return FirstName + " " + SurName;
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public override bool Equals(Object obj)
|
|
{
|
|
Person personObj = obj as Person;
|
|
if (personObj == null)
|
|
return false;
|
|
else
|
|
return ToString().Equals(personObj.ToString());
|
|
}
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
{
|
|
PropertyChangedEventHandler handler = PropertyChanged;
|
|
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
|
|
public class Man : Person
|
|
{
|
|
|
|
}
|
|
|
|
public class Woman : Person
|
|
{
|
|
|
|
}
|
|
}
|