xiongzhu hace 5 años
padre
commit
e8203f1b5a

BIN
.vs/DeviceCenter/v16/.suo


+ 6 - 69
Converter.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Globalization;
 using System.Linq;
 using System.Text;
@@ -8,85 +9,21 @@ using System.Windows.Data;
 
 namespace DeviceCenter
 {
-    [ValueConversion(typeof(Device.Type), typeof(String))]
-    class DeviceTypeConverter : IValueConverter
-    {
-        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            if(value != null)
-            {
-                Device.Type type = (Device.Type)value;
-                switch (type)
-                {
-                    case Device.Type.CAR_CAM:
-                        return "车牌";
-                    case Device.Type.ACS:
-                        return "门禁";
-                }
-            }
-            return "";
-        }
-
-        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            if(value != null)
-            {
-                switch (value as string)
-                {
-                    case "车牌":
-                        return Device.Type.CAR_CAM;
-                    case "门禁":
-                        return Device.Type.ACS;
-                }
-            }
-            return null;
-        }
-    }
-
-    [ValueConversion(typeof(Device.Status), typeof(String))]
-    class DeviceStatusConverter : IValueConverter
-    {
-        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            if (value != null)
-            {
-                Device.Status status = (Device.Status)value;
-                switch (status)
-                {
-                    case Device.Status.IDEL:
-                        return "未连接";
-                    case Device.Status.CONNECTING:
-                        return "正在连接";
-                    case Device.Status.CONNECTED:
-                        return "已连接";
-                    case Device.Status.FAIL:
-                        return "连接失败";
-                }
-            }
-            return "";
-        }
-
-        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            return null;
-        }
-    }
-
-    [ValueConversion(typeof(Device.Status), typeof(String))]
+    [ValueConversion(typeof(DeviceStatus), typeof(String))]
     class DeviceStatusColorConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
             if (value != null)
             {
-                Device.Status status = (Device.Status)value;
+                DeviceStatus status = (DeviceStatus)value;
                 switch (status)
                 {
-                    case Device.Status.CONNECTING:
+                    case DeviceStatus.CONNECTING:
                         return "#E6A23C";
-                    case Device.Status.CONNECTED:
+                    case DeviceStatus.CONNECTED:
                         return "#67C23A";
-                    case Device.Status.FAIL:
+                    case DeviceStatus.FAIL:
                         return "#F56C6C";
                 }
             }

+ 2 - 0
DeviceCenter.csproj

@@ -104,6 +104,7 @@
     <Compile Include="model\CarCamDevice.cs" />
     <Compile Include="Converter.cs" />
     <Compile Include="model\Config.cs" />
+    <Compile Include="enums\DeviceEnums.cs" />
     <Compile Include="model\Floor.cs" />
     <Compile Include="model\GetAreasResponse.cs" />
     <Compile Include="model\GetBuildingResponse.cs" />
@@ -112,6 +113,7 @@
     <Compile Include="utils\AppUtil.cs" />
     <Compile Include="utils\ConfigUtil.cs" />
     <Compile Include="utils\EnumerationExtension.cs" />
+    <Compile Include="utils\EnumItemsSource.cs" />
     <Compile Include="utils\http.cs" />
     <Compile Include="utils\NotificationUtil.cs" />
     <Compile Include="utils\PortUtil.cs" />

BIN
bin/x86/Debug/DeviceCenter.exe


BIN
bin/x86/Debug/DeviceCenter.pdb


+ 29 - 0
enums/DeviceEnums.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeviceCenter
+{
+    public enum DeviceType
+    {
+        [Description("车牌识别")]
+        CAR_CAM,
+        [Description("门禁")]
+        ACS
+    }
+
+    public enum DeviceStatus
+    {
+        [Description("空闲")]
+        IDEL,
+        [Description("连接中")]
+        CONNECTING,
+        [Description("已连接")]
+        CONNECTED,
+        [Description("失败")]
+        FAIL
+    }
+}

+ 1 - 1
model/AcsDevice.cs

@@ -18,7 +18,7 @@ namespace DeviceCenter
         public int userId { get; set; }
         public AcsDevice()
         {
-            type = Device.Type.ACS;
+            type = DeviceType.ACS;
         }
 
         public override void Init()

+ 1 - 1
model/CarCamDevice.cs

@@ -16,7 +16,7 @@ namespace DeviceCenter
         public int userId { get; set; }
        
         public CarCamDevice() {
-            this.type = Device.Type.CAR_CAM;
+            this.type = DeviceType.CAR_CAM;
         }
 
         public override void Init()

+ 5 - 25
model/Device.cs

@@ -1,10 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
+using System.ComponentModel;
 using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace DeviceCenter
 {
@@ -15,24 +10,9 @@ namespace DeviceCenter
         private int _port;
         private string _username;
         private string _password;
-        private Device.Type _type;
-        private Device.Status _status;
+        private DeviceType _type;
+        private DeviceStatus _status;
 
-        public enum Type
-        {
-            [Description("车牌识别")]
-            CAR_CAM,
-            [Description("门禁")]
-            ACS
-        }
-
-        public enum Status
-        {
-            IDEL,
-            CONNECTING,
-            CONNECTED,
-            FAIL
-        }
 
         public string name
         {
@@ -91,7 +71,7 @@ namespace DeviceCenter
                 OnPropertyChanged("password");
             }
         }
-        public Status status
+        public DeviceStatus status
         {
             get
             {
@@ -103,7 +83,7 @@ namespace DeviceCenter
                 OnPropertyChanged();
             }
         }
-        public Type type
+        public DeviceType type
         {
             get
             {

BIN
obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache


+ 1 - 1
obj/x86/Debug/DeviceCenter.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
-2964c93522cef307e925ba682fe317dfd94e78ea
+6c0ce1360fc2c98bf2b82890972a2c5fa6e73695

BIN
obj/x86/Debug/DeviceCenter.csprojAssemblyReference.cache


BIN
obj/x86/Debug/DeviceCenter.exe


BIN
obj/x86/Debug/DeviceCenter.g.resources


BIN
obj/x86/Debug/DeviceCenter.pdb


+ 1 - 1
obj/x86/Debug/DeviceCenter_MarkupCompile.cache

@@ -12,7 +12,7 @@ DEBUG;TRACE
 C:\Users\xiong\Projects\csharp\DeviceCenter\App.xaml
 3-1289623115
 
-331937613292
+351599969651
 24-1854166468
 views\AddDevice.xaml;views\Login.xaml;views\MainWindow.xaml;
 

+ 1 - 1
obj/x86/Debug/DeviceCenter_MarkupCompile.i.cache

@@ -12,7 +12,7 @@ DEBUG;TRACE
 C:\Users\xiong\Projects\csharp\DeviceCenter\App.xaml
 3-1289623115
 
-341925855808
+361588212167
 24-1854166468
 views\AddDevice.xaml;views\Login.xaml;views\MainWindow.xaml;
 

BIN
obj/x86/Debug/views/AddDevice.baml


+ 21 - 14
obj/x86/Debug/views/AddDevice.g.cs

@@ -1,4 +1,4 @@
-#pragma checksum "..\..\..\..\views\AddDevice.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "85F39D28DD717D4D04F300E06156C296FDCA2E74FFF74DFA5E3743CE999F8BDB"
+#pragma checksum "..\..\..\..\views\AddDevice.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "264E1AD96AE3D4ECD7A053156934C1493B70A3D2691239624A95B5911EF83B64"
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
@@ -9,7 +9,7 @@
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-using DeviceCenter.utils;
+using DeviceCenter;
 using System;
 using System.Diagnostics;
 using System.Windows;
@@ -41,7 +41,7 @@ namespace DeviceCenter {
     public partial class AddDevice : System.Windows.Window, System.Windows.Markup.IComponentConnector {
         
         
-        #line 12 "..\..\..\..\views\AddDevice.xaml"
+        #line 21 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.ComboBox cb_area;
         
@@ -49,7 +49,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 17 "..\..\..\..\views\AddDevice.xaml"
+        #line 26 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.ComboBox cb_building;
         
@@ -57,7 +57,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 22 "..\..\..\..\views\AddDevice.xaml"
+        #line 31 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.ComboBox cb_floor;
         
@@ -65,7 +65,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 27 "..\..\..\..\views\AddDevice.xaml"
+        #line 36 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.ComboBox cb_type;
         
@@ -73,7 +73,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 31 "..\..\..\..\views\AddDevice.xaml"
+        #line 40 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_name;
         
@@ -81,7 +81,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 35 "..\..\..\..\views\AddDevice.xaml"
+        #line 44 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_ip;
         
@@ -89,7 +89,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 39 "..\..\..\..\views\AddDevice.xaml"
+        #line 48 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_port;
         
@@ -97,7 +97,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 43 "..\..\..\..\views\AddDevice.xaml"
+        #line 52 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_username;
         
@@ -105,7 +105,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 47 "..\..\..\..\views\AddDevice.xaml"
+        #line 56 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_password;
         
@@ -133,6 +133,13 @@ namespace DeviceCenter {
             #line hidden
         }
         
+        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+        [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal System.Delegate _CreateDelegate(System.Type delegateType, string handler) {
+            return System.Delegate.CreateDelegate(delegateType, this, handler);
+        }
+        
         [System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
@@ -145,7 +152,7 @@ namespace DeviceCenter {
             case 1:
             this.cb_area = ((System.Windows.Controls.ComboBox)(target));
             
-            #line 12 "..\..\..\..\views\AddDevice.xaml"
+            #line 21 "..\..\..\..\views\AddDevice.xaml"
             this.cb_area.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cb_area_SelectionChanged);
             
             #line default
@@ -154,7 +161,7 @@ namespace DeviceCenter {
             case 2:
             this.cb_building = ((System.Windows.Controls.ComboBox)(target));
             
-            #line 17 "..\..\..\..\views\AddDevice.xaml"
+            #line 26 "..\..\..\..\views\AddDevice.xaml"
             this.cb_building.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cb_building_SelectionChanged);
             
             #line default
@@ -183,7 +190,7 @@ namespace DeviceCenter {
             return;
             case 10:
             
-            #line 49 "..\..\..\..\views\AddDevice.xaml"
+            #line 58 "..\..\..\..\views\AddDevice.xaml"
             ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
             
             #line default

+ 21 - 14
obj/x86/Debug/views/AddDevice.g.i.cs

@@ -1,4 +1,4 @@
-#pragma checksum "..\..\..\..\views\AddDevice.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "85F39D28DD717D4D04F300E06156C296FDCA2E74FFF74DFA5E3743CE999F8BDB"
+#pragma checksum "..\..\..\..\views\AddDevice.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "264E1AD96AE3D4ECD7A053156934C1493B70A3D2691239624A95B5911EF83B64"
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
@@ -9,7 +9,7 @@
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-using DeviceCenter.utils;
+using DeviceCenter;
 using System;
 using System.Diagnostics;
 using System.Windows;
@@ -41,7 +41,7 @@ namespace DeviceCenter {
     public partial class AddDevice : System.Windows.Window, System.Windows.Markup.IComponentConnector {
         
         
-        #line 12 "..\..\..\..\views\AddDevice.xaml"
+        #line 21 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.ComboBox cb_area;
         
@@ -49,7 +49,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 17 "..\..\..\..\views\AddDevice.xaml"
+        #line 26 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.ComboBox cb_building;
         
@@ -57,7 +57,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 22 "..\..\..\..\views\AddDevice.xaml"
+        #line 31 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.ComboBox cb_floor;
         
@@ -65,7 +65,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 27 "..\..\..\..\views\AddDevice.xaml"
+        #line 36 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.ComboBox cb_type;
         
@@ -73,7 +73,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 31 "..\..\..\..\views\AddDevice.xaml"
+        #line 40 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_name;
         
@@ -81,7 +81,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 35 "..\..\..\..\views\AddDevice.xaml"
+        #line 44 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_ip;
         
@@ -89,7 +89,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 39 "..\..\..\..\views\AddDevice.xaml"
+        #line 48 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_port;
         
@@ -97,7 +97,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 43 "..\..\..\..\views\AddDevice.xaml"
+        #line 52 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_username;
         
@@ -105,7 +105,7 @@ namespace DeviceCenter {
         #line hidden
         
         
-        #line 47 "..\..\..\..\views\AddDevice.xaml"
+        #line 56 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_password;
         
@@ -133,6 +133,13 @@ namespace DeviceCenter {
             #line hidden
         }
         
+        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+        [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal System.Delegate _CreateDelegate(System.Type delegateType, string handler) {
+            return System.Delegate.CreateDelegate(delegateType, this, handler);
+        }
+        
         [System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
@@ -145,7 +152,7 @@ namespace DeviceCenter {
             case 1:
             this.cb_area = ((System.Windows.Controls.ComboBox)(target));
             
-            #line 12 "..\..\..\..\views\AddDevice.xaml"
+            #line 21 "..\..\..\..\views\AddDevice.xaml"
             this.cb_area.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cb_area_SelectionChanged);
             
             #line default
@@ -154,7 +161,7 @@ namespace DeviceCenter {
             case 2:
             this.cb_building = ((System.Windows.Controls.ComboBox)(target));
             
-            #line 17 "..\..\..\..\views\AddDevice.xaml"
+            #line 26 "..\..\..\..\views\AddDevice.xaml"
             this.cb_building.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cb_building_SelectionChanged);
             
             #line default
@@ -183,7 +190,7 @@ namespace DeviceCenter {
             return;
             case 10:
             
-            #line 49 "..\..\..\..\views\AddDevice.xaml"
+            #line 58 "..\..\..\..\views\AddDevice.xaml"
             ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
             
             #line default

BIN
obj/x86/Debug/views/MainWindow.baml


+ 8 - 1
obj/x86/Debug/views/MainWindow.g.cs

@@ -1,4 +1,4 @@
-#pragma checksum "..\..\..\..\views\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "FD6BF548027B321306EBE1D27131E0B94FB84EA7917AC95DB180DA1B28178783"
+#pragma checksum "..\..\..\..\views\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "9F754B03B98E9BC952FEC19B04F6935FD7DC6438148C3074B13A3BA2F68ECC2B"
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
@@ -85,6 +85,13 @@ namespace DeviceCenter {
             #line hidden
         }
         
+        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+        [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal System.Delegate _CreateDelegate(System.Type delegateType, string handler) {
+            return System.Delegate.CreateDelegate(delegateType, this, handler);
+        }
+        
         [System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]

+ 8 - 1
obj/x86/Debug/views/MainWindow.g.i.cs

@@ -1,4 +1,4 @@
-#pragma checksum "..\..\..\..\views\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "FD6BF548027B321306EBE1D27131E0B94FB84EA7917AC95DB180DA1B28178783"
+#pragma checksum "..\..\..\..\views\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "9F754B03B98E9BC952FEC19B04F6935FD7DC6438148C3074B13A3BA2F68ECC2B"
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
@@ -85,6 +85,13 @@ namespace DeviceCenter {
             #line hidden
         }
         
+        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+        [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal System.Delegate _CreateDelegate(System.Type delegateType, string handler) {
+            return System.Delegate.CreateDelegate(delegateType, this, handler);
+        }
+        
         [System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]

+ 67 - 0
utils/EnumItemsSource.cs

@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Globalization;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace DeviceCenter
+{
+    public class EnumItemsSource : Dictionary<string, object>, IValueConverter
+    {
+
+        Type type;
+
+        IDictionary<Object, Object> valueToNameMap;
+
+        IDictionary<Object, Object> nameToValueMap;
+
+        public Type Type
+        {
+            get { return this.type; }
+            set
+            {
+                if (!value.IsEnum)
+                    throw new ArgumentException("Type is not an enum.", "value");
+                this.type = value;
+                Initialize();
+            }
+        }
+
+        public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
+        {
+            return this.valueToNameMap[value];
+        }
+
+        public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
+        {
+            return this.nameToValueMap[value];
+        }
+
+        void Initialize()
+        { 
+            this.valueToNameMap = this.type
+              .GetFields(BindingFlags.Static | BindingFlags.Public)
+              .ToDictionary(fi => fi.GetValue(null), GetDescription);
+            this.nameToValueMap = this.valueToNameMap
+              .ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
+            Clear();
+            foreach (String name in this.nameToValueMap.Keys)
+            {
+                this[name] = this.nameToValueMap[name];
+            }
+        }
+
+        static Object GetDescription(FieldInfo fieldInfo)
+        {
+            var descriptionAttribute =
+              (DescriptionAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute));
+            return descriptionAttribute != null ? descriptionAttribute.Description : fieldInfo.Name;
+        }
+
+    }
+}

+ 11 - 2
views/AddDevice.xaml

@@ -3,9 +3,18 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:my="clr-namespace:DeviceCenter.utils"
+        xmlns:sys="clr-namespace:System;assembly=mscorlib"
+        xmlns:local="clr-namespace:DeviceCenter"
         mc:Ignorable="d"
         Title="添加设备" Height="400" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
+    <Window.Resources>
+        <ObjectDataProvider x:Key="NameWeek" MethodName="GetNames" ObjectType="{x:Type sys:Enum}">
+            <ObjectDataProvider.MethodParameters>
+                <x:Type TypeName="local:DeviceType"/>
+            </ObjectDataProvider.MethodParameters>
+        </ObjectDataProvider>
+        <local:EnumItemsSource x:Key="DeviceTypeItemsSource" Type="{x:Type local:DeviceType}"/>
+    </Window.Resources>
     <StackPanel Orientation="Vertical">
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
             <Label Content="所在区域" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
@@ -24,7 +33,7 @@
         </StackPanel>
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
             <Label Content="设备类型" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
-            <ComboBox x:Name="cb_type" Width="150" ItemsSource="{Binding Source={my:EnumerationExtension {x:Type my:Device.Type}}}" />
+            <ComboBox x:Name="cb_type" Width="150" ItemsSource="{Binding Source={StaticResource DeviceTypeItemsSource}}"  DisplayMemberPath="Key" SelectedValuePath="Value"/>
         </StackPanel>
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
             <Label Content="设备名称" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>

+ 2 - 2
views/MainWindow.xaml

@@ -7,8 +7,8 @@
         mc:Ignorable="d"
         Title="设备中心" Height="450" Width="800" ResizeMode="NoResize" Closing="Window_Closing" WindowStartupLocation="CenterScreen">
     <Window.Resources>
-        <local:DeviceTypeConverter x:Key="deviceTypeConverter"/>
-        <local:DeviceStatusConverter x:Key="deviceStatusConverter"/>
+        <local:EnumItemsSource x:Key="deviceTypeConverter" Type="{x:Type local:DeviceType}"/>
+        <local:EnumItemsSource x:Key="deviceStatusConverter" Type="{x:Type local:DeviceStatus}"/>
         <local:DeviceStatusColorConverter x:Key="deviceStatusColorConverter"/>
     </Window.Resources>
     <DockPanel VerticalAlignment="Stretch" Height="Auto">

+ 6 - 6
views/MainWindow.xaml.cs

@@ -31,15 +31,15 @@ namespace DeviceCenter
 
             initSdk();
 
-            devices.Add(new CarCamDevice() { name = "Device 1", ip = "192.168.1.10", status = Device.Status.CONNECTING });
-            devices.Add(new AcsDevice() { name = "Device 2", ip = "192.168.1.11", status = Device.Status.FAIL });
-            devices.Add(new AcsDevice() { name = "Device 3", ip = "192.168.1.12", status = Device.Status.CONNECTED });
+            devices.Add(new CarCamDevice() { name = "Device 1", ip = "192.168.1.10", status = DeviceStatus.CONNECTING });
+            devices.Add(new AcsDevice() { name = "Device 2", ip = "192.168.1.11", status = DeviceStatus.FAIL });
+            devices.Add(new AcsDevice() { name = "Device 3", ip = "192.168.1.12", status = DeviceStatus.CONNECTED });
 
             lv_device.ItemsSource = devices;
             Thread t = new Thread(() =>
             {
                 Thread.Sleep(2000);
-                devices[0].status = Device.Status.CONNECTED;
+                devices[0].status = DeviceStatus.CONNECTED;
             });
             t.Start();
         }
@@ -118,7 +118,7 @@ namespace DeviceCenter
 
             foreach (Device device in devices)
             {
-                if (device.type == Device.Type.ACS)
+                if (device.type == DeviceType.ACS)
                 {
                     AcsDevice acsDevice = (AcsDevice)device;
                     if (acsDevice.userId == pAlarmer.lUserID)
@@ -133,7 +133,7 @@ namespace DeviceCenter
         {
             foreach (Device device in devices)
             {
-                if (device.type == Device.Type.ACS)
+                if (device.type == DeviceType.ACS)
                 {
                     CarCamDevice carCamDevice = (CarCamDevice)device;
                     if (tHandle == carCamDevice.userId)