diff --git a/eCompanies/App.xaml.cs b/eCompanies/App.xaml.cs
index 10fdb58..69b3350 100644
--- a/eCompanies/App.xaml.cs
+++ b/eCompanies/App.xaml.cs
@@ -1,12 +1,8 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Configuration;
using System.Data;
using System.Linq;
-using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Navigation;
namespace eCompanies
{
diff --git a/eCompanies/Contract.cs b/eCompanies/Contract.cs
index dab3181..8840d5f 100644
--- a/eCompanies/Contract.cs
+++ b/eCompanies/Contract.cs
@@ -1,12 +1,18 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.ComponentModel;
namespace eCompanies
{
- public enum Status { NotReachedYet, Reached, Terminated }
+ [TypeConverter(typeof(EnumDescriptionTypeConverter))]
+ public enum Status
+ {
+ [Description("Еще не заключен")]
+ NotReachedYet,
+ [Description("Заключен")]
+ Reached,
+ [Description("Расторгнут")]
+ Terminated
+ }
+
public class Contract
{
private Companies c;
diff --git a/eCompanies/EnumBindingSourceExtension.cs b/eCompanies/EnumBindingSourceExtension.cs
new file mode 100644
index 0000000..779b834
--- /dev/null
+++ b/eCompanies/EnumBindingSourceExtension.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Windows.Markup;
+
+namespace eCompanies
+{
+ public class EnumBindingSourceExtension : MarkupExtension
+ {
+ private Type _enumType;
+ public Type EnumType
+ {
+ get { return this._enumType; }
+ set
+ {
+ if (value != this._enumType)
+ {
+ if (null != value)
+ {
+ Type enumType = Nullable.GetUnderlyingType(value) ?? value;
+
+ if (!enumType.IsEnum)
+ throw new ArgumentException("Type must be for an Enum.");
+ }
+
+ this._enumType = value;
+ }
+ }
+ }
+
+ public EnumBindingSourceExtension() { }
+
+ public EnumBindingSourceExtension(Type enumType)
+ {
+ this.EnumType = enumType;
+ }
+
+ public override object ProvideValue(IServiceProvider serviceProvider)
+ {
+ if (null == this._enumType)
+ throw new InvalidOperationException("The EnumType must be specified.");
+
+ Type actualEnumType = Nullable.GetUnderlyingType(this._enumType) ?? this._enumType;
+ Array enumValues = Enum.GetValues(actualEnumType);
+
+ if (actualEnumType == this._enumType)
+ return enumValues;
+
+ Array tempArray = Array.CreateInstance(actualEnumType, enumValues.Length + 1);
+ enumValues.CopyTo(tempArray, 1);
+ return tempArray;
+ }
+ }
+}
diff --git a/eCompanies/EnumDescriptoionTypeConverter.cs b/eCompanies/EnumDescriptoionTypeConverter.cs
new file mode 100644
index 0000000..fc4503e
--- /dev/null
+++ b/eCompanies/EnumDescriptoionTypeConverter.cs
@@ -0,0 +1,34 @@
+using System;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace eCompanies
+{
+ public class EnumDescriptionTypeConverter : EnumConverter
+ {
+ public EnumDescriptionTypeConverter(Type type)
+ : base(type)
+ {
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == typeof(string))
+ {
+ if (value != null)
+ {
+ FieldInfo fi = value.GetType().GetField(value.ToString());
+ if (fi != null)
+ {
+ var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
+ return ((attributes.Length > 0) && (!String.IsNullOrEmpty(attributes[0].Description))) ? attributes[0].Description : value.ToString();
+ }
+ }
+
+ return string.Empty;
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+}
diff --git a/eCompanies/MainWindow.xaml b/eCompanies/MainWindow.xaml
index b4a8b26..469b7f0 100644
--- a/eCompanies/MainWindow.xaml
+++ b/eCompanies/MainWindow.xaml
@@ -4,17 +4,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:eCompanies"
- xmlns:core="clr-namespace:System;assembly=mscorlib"
- xmlns:col="clr-namespace:System.Collections;assembly=mscorlib"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
-
-
-
-
-
-
-
@@ -22,7 +13,7 @@
+ ItemsSource="{Binding Source={local:EnumBindingSource {x:Type local:Status}}}">
diff --git a/eCompanies/UsersWindow.xaml b/eCompanies/UsersWindow.xaml
index 72d4a30..9f3de70 100644
--- a/eCompanies/UsersWindow.xaml
+++ b/eCompanies/UsersWindow.xaml
@@ -20,10 +20,7 @@
-
- Еще не заключен
- Заключен
- Расторгнут
+
diff --git a/eCompanies/eCompanies.csproj b/eCompanies/eCompanies.csproj
index 99e9b44..0731fc7 100644
--- a/eCompanies/eCompanies.csproj
+++ b/eCompanies/eCompanies.csproj
@@ -140,6 +140,8 @@
+
+
UsersWindow.xaml