فهرست منبع

Login模块独立出来,登录完成之后通过事件CompositePresentationEvent,通知管理(Robot)模块

tanghai 13 سال پیش
والد
کامیت
abf6005cb1

+ 1 - 1
CSharp/App/DataCenter/DataCenter.csproj

@@ -18,7 +18,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
+    <OutputPath>..\..\Bin\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 2 - 2
CSharp/App/Editor/Bootstrapper.cs

@@ -5,7 +5,7 @@ using Microsoft.Practices.Prism.MefExtensions;
 using Microsoft.Practices.Prism.Regions;
 using Modules.BehaviorTree;
 using Modules.Robot;
-using Modules.WaiGua;
+using Modules.Login;
 
 namespace Editor
 {
@@ -17,7 +17,7 @@ namespace Editor
 			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof (ViewExportAttribute).Assembly));
 			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof (BehaviorTreeModule).Assembly));
 			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof (RobotModule).Assembly));
-			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof (WaiGuaModule).Assembly));
+			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof (LoginModule).Assembly));
 		}
 
 		protected override void InitializeShell()

+ 4 - 4
CSharp/App/Editor/Editor.csproj

@@ -109,14 +109,14 @@
       <Project>{6cd185d1-08e0-4729-a999-2d5b57ba8193}</Project>
       <Name>BehaviorTree</Name>
     </ProjectReference>
+    <ProjectReference Include="..\Modules\Login\Login.csproj">
+      <Project>{5aa48f9a-455d-4cd8-a605-a3ac38283e60}</Project>
+      <Name>Login</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Modules\Robot\Robot.csproj">
       <Project>{5d6ecbcd-be14-4dcb-baec-57089748b164}</Project>
       <Name>Robot</Name>
     </ProjectReference>
-    <ProjectReference Include="..\Modules\WaiGua\WaiGua.csproj">
-      <Project>{5aa48f9a-455d-4cd8-a605-a3ac38283e60}</Project>
-      <Name>WaiGua</Name>
-    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
     <None Include="App.config" />

+ 1 - 0
CSharp/App/Editor/Shell.xaml

@@ -3,6 +3,7 @@
 		xmlns:prism="http://www.codeplex.com/prism" Title="Editor" Height="800" Width="1280"
 		WindowStartupLocation="CenterScreen">
 	<Grid>
+		<ContentControl Name="login" prism:RegionManager.RegionName="LoginRegion" />
 		<ContentControl Name="robot" prism:RegionManager.RegionName="RobotRegion" />
 		<!--<TabControl>
 			<TabItem Height="25" Width="80" Header="机器人">

+ 83 - 0
CSharp/App/Events/Events.csproj

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Events</RootNamespace>
+    <AssemblyName>Events</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Prism.4.1.0.0\lib\NET40\Microsoft.Expression.Interactions.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.Prism, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Prism.4.1.0.0\lib\NET40\Microsoft.Practices.Prism.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.Prism.Interactivity, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Prism.4.1.0.0\lib\NET40\Microsoft.Practices.Prism.Interactivity.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.Prism.MefExtensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Prism.MEFExtensions.4.1.0.0\lib\NET40\Microsoft.Practices.Prism.MefExtensions.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Prism.4.1.0.0\lib\NET40\System.Windows.Interactivity.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="LoginOKEvent.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\BossClient\BossClient.csproj">
+      <Project>{8650195a-7904-4ebc-9d81-b392a7e9b9b3}</Project>
+      <Name>BossClient</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 9 - 0
CSharp/App/Events/LoginOKEvent.cs

@@ -0,0 +1,9 @@
+using BossClient;
+using Microsoft.Practices.Prism.Events;
+
+namespace Events
+{
+	public class LoginOKEvent : CompositePresentationEvent<IMessageChannel>
+	{
+	}
+}

+ 0 - 0
CSharp/App/Modules/WaiGua/Packages.config → CSharp/App/Events/Packages.config


+ 36 - 0
CSharp/App/Events/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("Events")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Events")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("288940c7-28fd-45cd-a5f7-87eaeef4740d")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      生成号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 25 - 8
CSharp/App/Modules/WaiGua/WaiGua.csproj → CSharp/App/Modules/Login/Login.csproj

@@ -7,8 +7,8 @@
     <ProjectGuid>{5AA48F9A-455D-4CD8-A605-A3AC38283E60}</ProjectGuid>
     <OutputType>library</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>WaiGua</RootNamespace>
-    <AssemblyName>WaiGua</AssemblyName>
+    <RootNamespace>Login</RootNamespace>
+    <AssemblyName>Login</AssemblyName>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
@@ -42,6 +42,8 @@
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.Composition" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Configuration" />
     <Reference Include="System.Xml" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xaml">
@@ -50,17 +52,24 @@
     <Reference Include="WindowsBase" />
     <Reference Include="PresentationCore" />
     <Reference Include="PresentationFramework" />
+    <Reference Include="Xceed.Wpf.DataGrid, Version=1.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\packages\Extended.Wpf.Toolkit.1.9.0\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath>
+    </Reference>
+    <Reference Include="Xceed.Wpf.Toolkit, Version=1.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\packages\Extended.Wpf.Toolkit.1.9.0\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="WaiGuaViewModel.cs" />
-    <Page Include="WaiGuaView.xaml">
+    <Compile Include="LoginViewModel.cs" />
+    <Page Include="LoginView.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Compile Include="WaiGua.cs" />
-    <Compile Include="WaiGuaModule.cs" />
-    <Compile Include="WaiGuaView.xaml.cs">
-      <DependentUpon>WaiGuaView.xaml</DependentUpon>
+    <Compile Include="LoginModule.cs" />
+    <Compile Include="LoginView.xaml.cs">
+      <DependentUpon>LoginView.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
   </ItemGroup>
@@ -74,6 +83,14 @@
     <None Include="Packages.config" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\BossClient\BossClient.csproj">
+      <Project>{8650195A-7904-4EBC-9D81-B392A7E9B9B3}</Project>
+      <Name>BossClient</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Events\Events.csproj">
+      <Project>{999910d3-4e7d-45b1-bd2c-47289cd4d1ab}</Project>
+      <Name>Events</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\Infrastructure\Infrastructure.csproj">
       <Project>{48a2e149-0dac-41b4-bb54-dfbccd6d42b3}</Project>
       <Name>Infrastructure</Name>

+ 3 - 3
CSharp/App/Modules/WaiGua/WaiGuaModule.cs → CSharp/App/Modules/Login/LoginModule.cs

@@ -1,10 +1,10 @@
 using Microsoft.Practices.Prism.MefExtensions.Modularity;
 using Microsoft.Practices.Prism.Modularity;
 
-namespace Modules.WaiGua
+namespace Modules.Login
 {
-	[ModuleExport(moduleType: typeof (WaiGuaModule))]
-	public class WaiGuaModule: IModule
+	[ModuleExport(moduleType: typeof (LoginModule))]
+	public class LoginModule: IModule
 	{
 		public void Initialize()
 		{

+ 5 - 3
CSharp/App/Modules/Robot/LoginView.xaml → CSharp/App/Modules/Login/LoginView.xaml

@@ -1,13 +1,15 @@
-<UserControl x:Class="Modules.Robot.LoginView"
+<UserControl x:Class="Modules.Login.LoginView"
 		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 		xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 		xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" 
+		xmlns:Login="clr-namespace:Modules.Login"
 		mc:Ignorable="d" 
-		d:DesignHeight="300" d:DesignWidth="300">
+		d:DesignHeight="300" d:DesignWidth="300" 
+		d:DataContext="{d:DesignInstance Login:LoginViewModel}">
 	<Grid>
-		<xctk:ChildWindow Name="cwLoginWindow"  Visibility="{Binding GridLoginVisiable}" 
+		<xctk:ChildWindow Name="cwLoginWindow"  Visibility="{Binding LoginWindowVisiable}" 
 				HorizontalAlignment="Center" VerticalAlignment="Center" CloseButtonVisibility="Hidden">
 			<Grid Name="gridLogin"  Width="200" Height="120" >
 				<Grid.RowDefinitions>

+ 36 - 36
CSharp/App/Modules/Robot/LoginView.xaml.cs → CSharp/App/Modules/Login/LoginView.xaml.cs

@@ -1,36 +1,36 @@
-using System.ComponentModel.Composition;
-using System.Windows;
-using Infrastructure;
-
-namespace Modules.Robot
-{
-	/// <summary>
-	/// LoginView.xaml 的交互逻辑
-	/// </summary>
-	// [ViewExport(RegionName = "RobotRegion"), PartCreationPolicy(CreationPolicy.Shared)]
-	public partial class LoginView
-	{
-		public LoginView()
-		{
-			InitializeComponent();
-		}
-
-		[Import]
-		private RobotViewModel ViewModel
-		{
-			get
-			{
-				return this.DataContext as RobotViewModel;
-			}
-			set
-			{
-				this.DataContext = value;
-			}
-		}
-
-		private void btnLogin_Click(object sender, RoutedEventArgs e)
-		{
-			this.ViewModel.Login();
-		}
-	}
-}
+using System.ComponentModel.Composition;
+using System.Windows;
+using Infrastructure;
+
+namespace Modules.Login
+{
+	/// <summary>
+	/// LoginView.xaml 的交互逻辑
+	/// </summary>
+	[ViewExport(RegionName = "LoginRegion"), PartCreationPolicy(CreationPolicy.NonShared)]
+	public partial class LoginView
+	{
+		public LoginView()
+		{
+			InitializeComponent();
+		}
+
+		[Import]
+		private LoginViewModel ViewModel
+		{
+			get
+			{
+				return this.DataContext as LoginViewModel;
+			}
+			set
+			{
+				this.DataContext = value;
+			}
+		}
+
+		private async void btnLogin_Click(object sender, RoutedEventArgs e)
+		{
+			await this.ViewModel.Login();
+		}
+	}
+}

+ 94 - 0
CSharp/App/Modules/Login/LoginViewModel.cs

@@ -0,0 +1,94 @@
+using System;
+using System.ComponentModel.Composition;
+using System.Configuration;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Threading;
+using Events;
+using Microsoft.Practices.Prism.Events;
+using Microsoft.Practices.Prism.ViewModel;
+
+namespace Modules.Login
+{
+	[Export(contractType: typeof (LoginViewModel)),
+		PartCreationPolicy(creationPolicy: CreationPolicy.NonShared)]
+	internal class LoginViewModel : NotificationObject
+	{
+		private IEventAggregator EventAggregator { get; set; }
+		private string account = "egametang@163.com";
+		private string password = "163bio1";
+		private Visibility loginWindowVisiable = Visibility.Visible;
+		private readonly BossClient.BossClient bossClient = new BossClient.BossClient();
+		private readonly DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.Normal) 
+		{ Interval = new TimeSpan(0, 0, 0, 0, 50) };
+
+		public Visibility LoginWindowVisiable
+		{
+			get
+			{
+				return this.loginWindowVisiable;
+			}
+			set
+			{
+				if (this.loginWindowVisiable == value)
+				{
+					return;
+				}
+				this.loginWindowVisiable = value;
+				this.RaisePropertyChanged("LoginWindowVisiable");
+			}
+		}
+
+		public string Account
+		{
+			get
+			{
+				return this.account;
+			}
+			set
+			{
+				if (this.account == value)
+				{
+					return;
+				}
+				this.account = value;
+				this.RaisePropertyChanged("Account");
+			}
+		}
+
+		public string Password
+		{
+			get
+			{
+				return this.password;
+			}
+			set
+			{
+				if (this.password == value)
+				{
+					return;
+				}
+				this.password = value;
+				this.RaisePropertyChanged("Password");
+			}
+		}
+
+		[ImportingConstructor]
+		public LoginViewModel(IEventAggregator eventAggregator)
+		{
+			this.EventAggregator = eventAggregator;
+			this.timer.Tick += delegate { this.bossClient.RunOnce(); };
+			this.timer.Start();
+		}
+
+		public async Task Login()
+		{
+			string ip = ConfigurationManager.AppSettings["IP"];
+			ushort port = UInt16.Parse(ConfigurationManager.AppSettings["Port"]);
+			await this.bossClient.Login(ip, port, this.Account, this.Password);
+			this.LoginWindowVisiable = Visibility.Hidden;
+			this.EventAggregator.GetEvent<LoginOKEvent>().Publish(
+				bossClient.GateSession.IMessageChannel);
+		}
+	}
+}

+ 7 - 0
CSharp/App/Modules/Login/Packages.config

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="CommonServiceLocator" version="1.0" targetFramework="net45" />
+  <package id="Extended.Wpf.Toolkit" version="1.9.0" targetFramework="net45" />
+  <package id="Prism" version="4.1.0.0" targetFramework="net45" />
+  <package id="Prism.MEFExtensions" version="4.1.0.0" targetFramework="net45" />
+</packages>

+ 4 - 7
CSharp/App/Modules/Robot/Robot.csproj

@@ -81,9 +81,6 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="LoginView.xaml.cs">
-      <DependentUpon>LoginView.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Robot.cs" />
     <Compile Include="RobotModule.cs" />
     <Compile Include="RobotViewModel.cs" />
@@ -93,10 +90,6 @@
     <Compile Include="ServerViewModel.cs" />
   </ItemGroup>
   <ItemGroup>
-    <Page Include="LoginView.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="RobotView.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -123,6 +116,10 @@
       <Project>{a829a025-5e90-4085-8dd4-e3b8c1282635}</Project>
       <Name>DataCenter</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\Events\Events.csproj">
+      <Project>{999910d3-4e7d-45b1-bd2c-47289cd4d1ab}</Project>
+      <Name>Events</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\Infrastructure\Infrastructure.csproj">
       <Project>{48a2e149-0dac-41b4-bb54-dfbccd6d42b3}</Project>
       <Name>Infrastructure</Name>

+ 4 - 4
CSharp/App/Modules/Robot/RobotView.xaml

@@ -3,10 +3,11 @@
 		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 		xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-		xmlns:Robot="clr-namespace:Modules.Robot" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" 
+		xmlns:Robot="clr-namespace:Modules.Robot"
+		mc:Ignorable="d" 
 		d:DesignHeight="600" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Robot:RobotViewModel}">
 	<Grid>
-		<xctk:ChildWindow Name="cwLoginWindow"  Visibility="{Binding GridLoginVisiable}" 
+		<!--<xctk:ChildWindow Name="cwLoginWindow"  Visibility="{Binding GridLoginVisiable}" 
 				HorizontalAlignment="Center" VerticalAlignment="Center" CloseButtonVisibility="Hidden">
 			<Grid Name="gridLogin"  Width="200" Height="120" >
 				<Grid.RowDefinitions>
@@ -24,8 +25,7 @@
 				<TextBox Text="{Binding Password}" Grid.Row="1" Grid.Column="1" Margin="0,8,0,8" />
 				<Button Name="btnLogin" Content="登录" Click="btnLogin_Click" Grid.Row="2" Grid.Column="1" Margin="12,8" />
 			</Grid>
-		</xctk:ChildWindow>
-
+		</xctk:ChildWindow>-->
 		<DockPanel Name="dock" Visibility="{Binding DockPanelVisiable}">
 			<Menu DockPanel.Dock="Top" >
 				<MenuItem Header="登录" Name="menuLogin" Click="menuLogin_Click" ></MenuItem>

+ 0 - 6
CSharp/App/Modules/Robot/RobotView.xaml.cs

@@ -28,11 +28,6 @@ namespace Modules.Robot
 			}
 		}
 
-		private void btnLogin_Click(object sender, RoutedEventArgs e)
-		{
-			this.ViewModel.Login();
-		}
-
 		private void btnServers_Click(object sender, RoutedEventArgs e)
 		{
 			this.ViewModel.Servers();
@@ -50,7 +45,6 @@ namespace Modules.Robot
 
 		private void menuLogin_Click(object sender, RoutedEventArgs e)
 		{
-			this.ViewModel.GridLoginVisiable = Visibility.Visible;
 		}
 	}
 }

+ 7 - 74
CSharp/App/Modules/Robot/RobotViewModel.cs

@@ -8,8 +8,10 @@ using System.Windows;
 using System.Windows.Threading;
 using BossClient;
 using DataCenter;
+using Events;
 using Helper;
 using Log;
+using Microsoft.Practices.Prism.Events;
 using Microsoft.Practices.Prism.ViewModel;
 
 namespace Modules.Robot
@@ -18,12 +20,9 @@ namespace Modules.Robot
 		PartCreationPolicy(creationPolicy: CreationPolicy.Shared)]
 	internal sealed class RobotViewModel: NotificationObject, IDisposable
 	{
-		private string account = "egametang@163.com";
-		private string password = "163bio1";
 		private int findTypeIndex;
 		private string findType = "";
 		private Visibility dockPanelVisiable = Visibility.Hidden;
-		private Visibility gridLoginVisiable = Visibility.Visible;
 		private readonly BossClient.BossClient bossClient = new BossClient.BossClient();
 		private readonly ObservableCollection<ServerViewModel> serverInfos = 
 			new ObservableCollection<ServerViewModel>();
@@ -31,43 +30,6 @@ namespace Modules.Robot
 		public readonly Dictionary<ushort, Action<byte[]>> messageHandlers =
 			new Dictionary<ushort, Action<byte[]>>();
 
-		private readonly DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.Normal)
-		{ Interval = new TimeSpan(0, 0, 0, 0, 50) };
-
-		public string Account
-		{
-			get
-			{
-				return this.account;
-			}
-			set
-			{
-				if (this.account == value)
-				{
-					return;
-				}
-				this.account = value;
-				this.RaisePropertyChanged("Account");
-			}
-		}
-
-		public string Password
-		{
-			get
-			{
-				return this.password;
-			}
-			set
-			{
-				if (this.password == value)
-				{
-					return;
-				}
-				this.password = value;
-				this.RaisePropertyChanged("Password");
-			}
-		}
-
 		public int FindTypeIndex
 		{
 			get
@@ -119,23 +81,6 @@ namespace Modules.Robot
 			}
 		}
 
-		public Visibility GridLoginVisiable
-		{
-			get
-			{
-				return this.gridLoginVisiable;
-			}
-			set
-			{
-				if (this.gridLoginVisiable == value)
-				{
-					return;
-				}
-				this.gridLoginVisiable = value;
-				this.RaisePropertyChanged("GridLoginVisiable");
-			}
-		}
-
 		public ObservableCollection<ServerViewModel> ServerInfos
 		{
 			get
@@ -144,13 +89,12 @@ namespace Modules.Robot
 			}
 		}
 
-		public RobotViewModel()
+		[ImportingConstructor]
+		public RobotViewModel(IEventAggregator eventAggregator)
 		{
 			this.messageHandlers.Add(
 				MessageOpcode.SMSG_BOSS_SERVERSINFO, Handle_SMSG_Boss_ServersInfo);
-
-			this.timer.Tick += delegate { this.bossClient.RunOnce(); };
-			this.timer.Start();
+			eventAggregator.GetEvent<LoginOKEvent>().Subscribe(this.OnLoginOK);
 		}
 
 		~RobotViewModel()
@@ -169,25 +113,14 @@ namespace Modules.Robot
 			this.bossClient.Dispose();
 		}
 
-		public async void Login()
+		public async void OnLoginOK(IMessageChannel messageChannel)
 		{
-			string ip = ConfigurationManager.AppSettings["IP"];
-			ushort port = UInt16.Parse(ConfigurationManager.AppSettings["Port"]);
-			await this.bossClient.Login(ip, port, this.Account, this.Password);
-
 			this.DockPanelVisiable = Visibility.Visible;
-			this.GridLoginVisiable = Visibility.Hidden;
-
-			this.HandleMessages();
-		}
-
-		public async void HandleMessages()
-		{
 			try
 			{
 				while (true)
 				{
-					var result = await this.bossClient.GateSession.IMessageChannel.RecvMessage();
+					var result = await messageChannel.RecvMessage();
 					ushort opcode = result.Item1;
 					byte[] message = result.Item2;
 					if (!messageHandlers.ContainsKey(opcode))

+ 0 - 6
CSharp/App/Modules/WaiGua/WaiGua.cs

@@ -1,6 +0,0 @@
-namespace Modules.WaiGua
-{
-	public class WaiGua
-	{
-	}
-}

+ 0 - 15
CSharp/App/Modules/WaiGua/WaiGuaView.xaml

@@ -1,15 +0,0 @@
-<UserControl x:Class="Modules.WaiGua.WaiGuaView"
-		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-		xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-		xmlns:WaiGua="clr-namespace:Modules.WaiGua"
-		mc:Ignorable="d" 
-		d:DesignHeight="600" d:DesignWidth="800" 
-		d:DataContext="{d:DesignInstance WaiGua:WaiGuaViewModel}">
-	<Grid>
-		<StackPanel>
-			<Image Height="100"/>
-		</StackPanel>
-	</Grid>
-</UserControl>

+ 0 - 30
CSharp/App/Modules/WaiGua/WaiGuaView.xaml.cs

@@ -1,30 +0,0 @@
-using System.ComponentModel.Composition;
-using Infrastructure;
-
-namespace Modules.WaiGua
-{
-	/// <summary>
-	/// RobotView.xaml 的交互逻辑
-	/// </summary>
-	[ViewExport(RegionName = "WaiGuaRegion"), PartCreationPolicy(CreationPolicy.NonShared)]
-	public partial class WaiGuaView
-	{
-		public WaiGuaView()
-		{
-			this.InitializeComponent();
-		}
-
-		[Import]
-		private WaiGuaViewModel ViewModel
-		{
-			get
-			{
-				return this.DataContext as WaiGuaViewModel;
-			}
-			set
-			{
-				this.DataContext = value;
-			}
-		}
-	}
-}

+ 0 - 35
CSharp/App/Modules/WaiGua/WaiGuaViewModel.cs

@@ -1,35 +0,0 @@
-using System;
-using System.ComponentModel.Composition;
-using Microsoft.Practices.Prism.ViewModel;
-
-namespace Modules.WaiGua
-{
-	[Export(contractType: typeof (WaiGuaViewModel)),
-		PartCreationPolicy(creationPolicy: CreationPolicy.NonShared)]
-	internal class WaiGuaViewModel: NotificationObject
-	{
-		private string logText = "";
-
-		public string LogText
-		{
-			get
-			{
-				return this.logText;
-			}
-			set
-			{
-				if (this.logText == value)
-				{
-					return;
-				}
-				this.logText = value;
-				this.RaisePropertyChanged("LogText");
-			}
-		}
-
-		public void Start()
-		{
-			this.LogText += "11111111111" + Environment.NewLine;
-		}
-	}
-}

+ 29 - 14
CSharp/CSharp.sln

@@ -22,8 +22,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robot", "App\Modules\Robot\
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hooks", "Platform\Hooks\Hooks.csproj", "{3A98B35C-DEA8-489C-9203-263FFB6B065D}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaiGua", "App\Modules\WaiGua\WaiGua.csproj", "{5AA48F9A-455D-4CD8-A605-A3AC38283E60}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "App\Infrastructure\Infrastructure.csproj", "{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Log", "Platform\Log\Log.csproj", "{72E16572-FC1F-4A9E-BC96-035417239298}"
@@ -52,6 +50,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BossClient", "App\BossClien
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataCenter", "App\DataCenter\DataCenter.csproj", "{A829A025-5E90-4085-8DD4-E3B8C1282635}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Login", "App\Modules\Login\Login.csproj", "{5AA48F9A-455D-4CD8-A605-A3AC38283E60}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Events", "App\Events\Events.csproj", "{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -114,18 +116,6 @@ Global
 		{3A98B35C-DEA8-489C-9203-263FFB6B065D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 		{3A98B35C-DEA8-489C-9203-263FFB6B065D}.Release|Win32.ActiveCfg = Release|Any CPU
 		{3A98B35C-DEA8-489C-9203-263FFB6B065D}.Release|x86.ActiveCfg = Release|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Win32.ActiveCfg = Debug|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Any CPU.Build.0 = Release|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Mixed Platforms.Build.0 = Release|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Win32.ActiveCfg = Release|Any CPU
-		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|x86.ActiveCfg = Release|Any CPU
 		{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -260,6 +250,30 @@ Global
 		{A829A025-5E90-4085-8DD4-E3B8C1282635}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 		{A829A025-5E90-4085-8DD4-E3B8C1282635}.Release|Win32.ActiveCfg = Release|Any CPU
 		{A829A025-5E90-4085-8DD4-E3B8C1282635}.Release|x86.ActiveCfg = Release|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|Win32.ActiveCfg = Debug|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|Win32.ActiveCfg = Release|Any CPU
+		{5AA48F9A-455D-4CD8-A605-A3AC38283E60}.Release|x86.ActiveCfg = Release|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Debug|Win32.ActiveCfg = Debug|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Release|Any CPU.Build.0 = Release|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Release|Win32.ActiveCfg = Release|Any CPU
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB}.Release|x86.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -270,6 +284,7 @@ Global
 		{48A2E149-0DAC-41B4-BB54-DFBCCD6D42B3} = {6E9D97F0-4243-452E-B832-1A855B8118EB}
 		{8650195A-7904-4EBC-9D81-B392A7E9B9B3} = {6E9D97F0-4243-452E-B832-1A855B8118EB}
 		{A829A025-5E90-4085-8DD4-E3B8C1282635} = {6E9D97F0-4243-452E-B832-1A855B8118EB}
+		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB} = {6E9D97F0-4243-452E-B832-1A855B8118EB}
 		{3A98B35C-DEA8-489C-9203-263FFB6B065D} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 		{72E16572-FC1F-4A9E-BC96-035417239298} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 		{24233CD5-A5DF-484B-A482-B79CB7A0D9CB} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}