浏览代码

放弃mvvmlight,准备使用Prism

tanghai 14 年之前
父节点
当前提交
d97544436d

+ 31 - 10
CSharp/CSharp.sln

@@ -1,26 +1,47 @@
 
 Microsoft Visual Studio Solution File, Format Version 11.00
 # Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Editor", "Editor\Editor.csproj", "{B29100C8-6E7F-4C7D-91AB-0153D0D28663}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Editor", "Editor\Editor.csproj", "{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thread", "Thread\Thread.csproj", "{01AE803B-71F3-4DD6-BEAA-6BA7C2D13E23}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Login", "Modules\LoginModule\Login.csproj", "{7CC7BF9C-13BE-470E-BC35-6A1944767899}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
+		Debug|Mixed Platforms = Debug|Mixed Platforms
+		Debug|x86 = Debug|x86
 		Release|Any CPU = Release|Any CPU
+		Release|Mixed Platforms = Release|Mixed Platforms
+		Release|x86 = Release|x86
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{B29100C8-6E7F-4C7D-91AB-0153D0D28663}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{B29100C8-6E7F-4C7D-91AB-0153D0D28663}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{B29100C8-6E7F-4C7D-91AB-0153D0D28663}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{B29100C8-6E7F-4C7D-91AB-0153D0D28663}.Release|Any CPU.Build.0 = Release|Any CPU
-		{01AE803B-71F3-4DD6-BEAA-6BA7C2D13E23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{01AE803B-71F3-4DD6-BEAA-6BA7C2D13E23}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{01AE803B-71F3-4DD6-BEAA-6BA7C2D13E23}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{01AE803B-71F3-4DD6-BEAA-6BA7C2D13E23}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Debug|Any CPU.ActiveCfg = Debug|x86
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Debug|Mixed Platforms.Build.0 = Debug|x86
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Debug|x86.ActiveCfg = Debug|x86
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Debug|x86.Build.0 = Debug|x86
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Release|Any CPU.ActiveCfg = Release|x86
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Release|Mixed Platforms.ActiveCfg = Release|x86
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Release|Mixed Platforms.Build.0 = Release|x86
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Release|x86.ActiveCfg = Release|x86
+		{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}.Release|x86.Build.0 = Release|x86
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899}.Release|x86.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{7CC7BF9C-13BE-470E-BC35-6A1944767899} = {C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}
+	EndGlobalSection
 EndGlobal

+ 5 - 10
CSharp/Editor/App.xaml

@@ -1,12 +1,7 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Application x:Class="Egametang.App" 
-		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
-		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
-		xmlns:vm="clr-namespace:Egametang" 
-		xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-		StartupUri="MainWindow.xaml" mc:Ignorable="d">
+<Application x:Class="Editor.App"
+		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 	<Application.Resources>
-		<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
+
 	</Application.Resources>
-</Application>
+</Application>

+ 9 - 21
CSharp/Editor/App.xaml.cs

@@ -1,32 +1,20 @@
-using System.Threading.Tasks.Schedulers;
-using System.Windows;
-using GalaSoft.MvvmLight.Threading;
-using NLog;
+using System.Windows;
 
-namespace Egametang
+namespace Editor
 {
-	/// <summary>
-	/// Interaction logic for App.xaml
-	/// </summary>
 	public partial class App : Application
 	{
-		static App()
+		protected override void OnStartup(StartupEventArgs e)
 		{
-			DispatcherHelper.Initialize();
-			OrderedTaskScheduler = new OrderedTaskScheduler();
-			Logger = LogManager.GetLogger("Editor");
+			base.OnStartup(e);
+			RunInDebugMode();
+			this.ShutdownMode = ShutdownMode.OnMainWindowClose;
 		}
 
-		public static OrderedTaskScheduler OrderedTaskScheduler
+		private static void RunInDebugMode()
 		{
-			get;
-			private set;
-		}
-
-		public static Logger Logger
-		{
-			get;
-			private set;
+			Bootstrapper bootstrapper = new Bootstrapper();
+			bootstrapper.Run();
 		}
 	}
 }

+ 33 - 0
CSharp/Editor/Bootstrapper.cs

@@ -0,0 +1,33 @@
+using System.ComponentModel.Composition.Hosting;
+using System.Windows;
+using Microsoft.Practices.Prism.MefExtensions;
+using Module.Login;
+
+namespace Editor
+{
+	public partial class Bootstrapper : MefBootstrapper
+	{
+		protected override void ConfigureAggregateCatalog()
+		{
+			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly));
+			this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(LoginModule).Assembly));
+		}
+
+		protected override void ConfigureContainer()
+		{
+			base.ConfigureContainer();
+		}
+
+		protected override void InitializeShell()
+		{
+			base.InitializeShell();
+			Application.Current.MainWindow = (Shell)this.Shell;
+			Application.Current.MainWindow.Show();
+		}
+
+		protected override DependencyObject CreateShell()
+		{
+			return this.Container.GetExportedValue<Shell>();
+		}
+	}
+}

+ 19 - 55
CSharp/Editor/Editor.csproj

@@ -2,10 +2,10 @@
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
     <ProductVersion>8.0.30703</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{B29100C8-6E7F-4C7D-91AB-0153D0D28663}</ProjectGuid>
+    <ProjectGuid>{C46F3337-0F48-4A72-84AD-8FDD1F159BB0}</ProjectGuid>
     <OutputType>WinExe</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>Editor</RootNamespace>
@@ -16,7 +16,8 @@
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
@@ -24,9 +25,9 @@
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
-    <RunCodeAnalysis>true</RunCodeAnalysis>
   </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
@@ -35,32 +36,11 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="AsyncCtpLibrary">
-      <HintPath>..\Packages\AsynCtp\AsyncCtpLibrary.dll</HintPath>
-    </Reference>
-    <Reference Include="GalaSoft.MvvmLight.Extras.WPF4, Version=3.0.0.32852, Culture=neutral, PublicKeyToken=1673db7d5906b0ad, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\packages\MvvmLight.3.0.3\lib\net40\GalaSoft.MvvmLight.Extras.WPF4.dll</HintPath>
-    </Reference>
-    <Reference Include="GalaSoft.MvvmLight.WPF4, Version=3.0.0.32852, Culture=neutral, PublicKeyToken=63eb5c012e0b3c1c, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\packages\MvvmLight.3.0.3\lib\net40\GalaSoft.MvvmLight.WPF4.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Practices.ServiceLocation">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WPF4\Microsoft.Practices.ServiceLocation.dll</HintPath>
-    </Reference>
-    <Reference Include="NLog">
-      <HintPath>..\packages\NLog.2.0.0.0\lib\NET40\NLog.dll</HintPath>
-    </Reference>
-    <Reference Include="NLog.Extended">
-      <HintPath>..\packages\NLog.2.0.0.0\lib\NET40\NLog.Extended.dll</HintPath>
-    </Reference>
+    <Reference Include="Microsoft.Practices.Prism, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+    <Reference Include="Microsoft.Practices.Prism.MefExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
     <Reference Include="System" />
+    <Reference Include="System.ComponentModel.Composition" />
     <Reference Include="System.Data" />
-    <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
-      <HintPath>..\packages\MvvmLight.3.0.3\lib\net40\System.Windows.Interactivity.dll</HintPath>
-    </Reference>
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />
@@ -78,32 +58,18 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
-    <None Include="NLog.config">
-      <SubType>Designer</SubType>
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-    <Compile Include="Logical\LoginRealm.cs" />
-    <Compile Include="Model\Main.cs" />
-    <Compile Include="ViewModel\MainViewModel.cs" />
-    <Compile Include="ViewModel\ViewModelLocator.cs" />
-    <Compile Include="View\MainView.xaml.cs">
-      <DependentUpon>MainView.xaml</DependentUpon>
+    <Compile Include="Bootstrapper.cs" />
+    <Compile Include="Shell.xaml.cs">
+      <DependentUpon>Shell.xaml</DependentUpon>
     </Compile>
-    <Page Include="MainWindow.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </Page>
+    <Compile Include="ShellViewModel.cs" />
     <Compile Include="App.xaml.cs">
       <DependentUpon>App.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="MainWindow.xaml.cs">
-      <DependentUpon>MainWindow.xaml</DependentUpon>
-      <SubType>Code</SubType>
-    </Compile>
-    <Page Include="View\MainView.xaml">
-      <SubType>Designer</SubType>
+    <Page Include="Shell.xaml">
       <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
     </Page>
   </ItemGroup>
   <ItemGroup>
@@ -113,15 +79,13 @@
     <Folder Include="Properties\" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\Thread\Thread.csproj">
-      <Project>{01AE803B-71F3-4DD6-BEAA-6BA7C2D13E23}</Project>
-      <Name>Thread</Name>
+    <ProjectReference Include="..\Modules\LoginModule\Login.csproj">
+      <Project>{7CC7BF9C-13BE-470E-BC35-6A1944767899}</Project>
+      <Name>Login</Name>
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <None Include="Packages.config">
-      <SubType>Designer</SubType>
-    </None>
+    <None Include="NLog.config" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 0 - 75
CSharp/Editor/Logical/LoginRealm.cs

@@ -1,75 +0,0 @@
-using System;
-using System.Net.Sockets;
-using GalaSoft.MvvmLight.Threading;
-using System.Security.Cryptography;
-using System.Threading.Tasks;
-using System.Text;
-using GalaSoft.MvvmLight.Messaging;
-
-namespace Egametang
-{
-	enum RealmLoginState: byte
-	{
-		RealmAuthLoginChallenge = 0,
-		RealmAuthLonginProof = 1,
-		AuthReconnectChallenge = 2,
-		AuthReconnectProof = 3,
-		AuthLoginPermit = 4,
-		RealmList = 10,
-		Surver = 48,
-	}
-
-	class RealmLogin
-	{
-		private MainViewModel mainViewModel = null;
-
-		public RealmLogin(MainViewModel mainViewModel)
-		{
-			this.mainViewModel = mainViewModel;
-		}
-
-		public async void Login()
-		{
-			using (TcpClient tcpClient = new TcpClient())
-			{
-				// 异步连接
-				await tcpClient.ConnectAsync("192.168.10.246", 19000);
-				var stream = tcpClient.GetStream();
-
-				// 验证通行证
-				await LoginPermit(stream);
-			}
-		}
-
-		public async Task LoginPermit(NetworkStream stream)
-		{
-			byte[] opcodeBuffer = new byte[1] { (byte)RealmLoginState.AuthLoginPermit };
-			await stream.WriteAsync(opcodeBuffer, 0, opcodeBuffer.Length);
-			
-			string username = mainViewModel.Username;
-			username += new string(' ', 128 - username.Length);
-			byte[] usernameBuffer = System.Text.Encoding.Default.GetBytes(username);
-			await stream.WriteAsync(usernameBuffer, 0, usernameBuffer.Length);
-			
-			MD5 md5 = new MD5CryptoServiceProvider();
-			byte[] password = System.Text.Encoding.Default.GetBytes(mainViewModel.Password);
-			byte[] passMD5Buffer = md5.ComputeHash(password);
-			
-			string passMD5 = BitConverter.ToString(passMD5Buffer);
-			passMD5 = passMD5.Replace("-", "");
-			passMD5 = passMD5.ToLower();
-			App.Logger.Debug(string.Format("username: {0}, passMD5: {1}", username, passMD5));
-			
-			passMD5Buffer = System.Text.Encoding.Default.GetBytes(passMD5);
-			await stream.WriteAsync(passMD5Buffer, 0, passMD5Buffer.Length);
-
-			await DispatcherHelper.UIDispatcher.InvokeAsync(new Action(() =>
-			{
-				mainViewModel.LoginInfo += "Login Permit!" + Environment.NewLine;
-
-				// 让textbox自动向下滚动
-				Messenger.Default.Send(new NotificationMessage("ScrollDown"));
-			}));
-		}
-	}
-}

+ 0 - 15
CSharp/Editor/MainWindow.xaml

@@ -1,15 +0,0 @@
-<Window x:Class="Egametang.MainWindow"
-		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-		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:v="clr-namespace:Egametang"
-		mc:Ignorable="d" Height="600" Width="800" Title="MVVM Light Application">
-	<Grid x:Name="LayoutRoot">
-		<TabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
-			<TabItem Header="Main" Name="mainTabItem">
-				<v:MainView />
-			</TabItem>
-		</TabControl>
-	</Grid>
-</Window>

+ 0 - 19
CSharp/Editor/MainWindow.xaml.cs

@@ -1,19 +0,0 @@
-using System.Windows;
-
-namespace Egametang
-{
-	/// <summary>
-	/// Interaction logic for MainWindow.xaml
-	/// </summary>
-	public partial class MainWindow : Window
-	{
-		/// <summary>
-		/// Initializes a new instance of the MainWindow class.
-		/// </summary>
-		public MainWindow()
-		{
-			InitializeComponent();
-			Closing += (s, e) => ViewModelLocator.Cleanup();
-		}
-	}
-}

+ 0 - 54
CSharp/Editor/Model/Main.cs

@@ -1,54 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Egametang
-{
-	public class Main
-	{
-		private string loginResult = "";
-		private string username = "";
-		private string password = "";
-
-		public Main()
-		{
-		}
-
-		public string LoginInfo
-		{
-			get
-			{
-				return loginResult;
-			}
-			set
-			{
-				loginResult = value;
-			}
-		}
-
-		public string Username
-		{
-			get
-			{
-				return username;
-			}
-			set
-			{
-				username = value;
-			}
-		}
-
-		public string Password
-		{
-			get
-			{
-				return password;
-			}
-			set
-			{
-				password = value;
-			}
-		}
-	}
-}

+ 0 - 5
CSharp/Editor/Packages.config

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-	<package id="MvvmLight" version="3.0.3" />
-	<package id="NLog" version="2.0.0.0" />
-</packages>

+ 9 - 0
CSharp/Editor/Shell.xaml

@@ -0,0 +1,9 @@
+<Window x:Class="Editor.Shell"
+	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+	xmlns:cal="http://www.codeplex.com/CompositeWPF" 
+	Title="Editor" Height="600" Width="800" WindowStartupLocation="CenterScreen">
+	<Grid>
+		
+	</Grid>
+</Window>

+ 24 - 0
CSharp/Editor/Shell.xaml.cs

@@ -0,0 +1,24 @@
+using System.Windows;
+using System.ComponentModel.Composition;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Editor
+{
+	[Export]
+	public partial class Shell : Window
+	{
+		public Shell()
+		{
+			InitializeComponent();
+		}
+
+		[Import]
+		ShellViewModel ViewModel
+		{
+			set
+			{
+				this.DataContext = value;
+			}
+		}
+	}
+}

+ 11 - 0
CSharp/Editor/ShellViewModel.cs

@@ -0,0 +1,11 @@
+using System.ComponentModel.Composition;
+using Microsoft.Practices.Prism.ViewModel;
+
+namespace Editor
+{
+	[Export]
+	public class ShellViewModel : NotificationObject
+	{
+		// This is where any view model logic for the shell would go.
+	}
+}

+ 0 - 22
CSharp/Editor/View/MainView.xaml

@@ -1,22 +0,0 @@
-<UserControl
-		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:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4" x:Class="Egametang.MainView" 
-		mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="800"
-		DataContext="{Binding MainViewModel, Source={StaticResource Locator}}" >
-	<Grid>		
-		<StackPanel Grid.Column="0">
-			<StackPanel Orientation="Horizontal">
-				<Label Content="用户名: "/>
-				<TextBox Width="150" x:Name="tBUsername" Text="{Binding Username}" />
-				<Label Content="密码: "/>
-				<TextBox Width="150" x:Name="tBPassword" Text="{Binding Password}" />
-				<Button Content="登录" HorizontalAlignment="Center" VerticalAlignment="Center" Command="{Binding LoginCmd}" />
-			</StackPanel>
-			<TextBox x:Name="tBInfo" Margin="10" Padding="1" Height="200" VerticalScrollBarVisibility="Visible" 
-					 Text="{Binding LoginInfo}" />
-		</StackPanel>
-	</Grid>
-</UserControl>

+ 0 - 22
CSharp/Editor/View/MainView.xaml.cs

@@ -1,22 +0,0 @@
-using GalaSoft.MvvmLight.Messaging;
-using System.Windows.Controls;
-
-namespace Egametang
-{
-	/// <summary>
-	/// MainView.xaml 的交互逻辑
-	/// </summary>
-	public partial class MainView : UserControl
-	{
-		public MainView()
-		{
-			InitializeComponent();
-			Messenger.Default.Register<NotificationMessage>(this, TextBoxInfoScrollToEnd);
-		}
-
-		private void TextBoxInfoScrollToEnd(NotificationMessage msg)
-		{
-			tBInfo.ScrollToEnd();
-		}
-	}
-}

+ 0 - 87
CSharp/Editor/ViewModel/MainViewModel.cs

@@ -1,87 +0,0 @@
-using GalaSoft.MvvmLight;
-using GalaSoft.MvvmLight.Command;
-
-namespace Egametang
-{
-	public class MainViewModel : ViewModelBase
-	{
-		private Main main = new Main();
-		private RelayCommand loginCmd = null;
-		private RealmLogin loginRealm = null;
-
-		public MainViewModel()
-		{
-			loginCmd = new RelayCommand(Login);
-			loginRealm = new RealmLogin(this);
-		}
-
-		public string LoginInfo
-		{
-			get
-			{
-				return main.LoginInfo;
-			}
-			set
-			{
-				if (main.LoginInfo == value)
-				{
-					return;
-				}
-				main.LoginInfo = value;
-				RaisePropertyChanged("LoginInfo");
-			}
-		}
-
-		public string Username
-		{
-			get
-			{
-				return main.Username;
-			}
-			set
-			{
-				if (main.Username == value)
-				{
-					return;
-				}
-				main.Username = value;
-				RaisePropertyChanged("Username");
-			}
-		}
-
-		public string Password
-		{
-			get
-			{
-				return main.Password;
-			}
-			set
-			{
-				if (main.Password == value)
-				{
-					return;
-				}
-				main.Password = value;
-				RaisePropertyChanged("Password");
-			}
-		}
-
-		public RelayCommand LoginCmd
-		{
-			get
-			{
-				return loginCmd;
-			}
-		}
-
-		private void Login()
-		{
-			loginRealm.Login();
-		}
-
-		public override void Cleanup()
-		{
-		    base.Cleanup();
-		}
-	}
-}

+ 0 - 20
CSharp/Editor/ViewModel/ViewModelLocator.cs

@@ -1,20 +0,0 @@
-
-namespace Egametang
-{
-	public class ViewModelLocator
-	{
-		static private MainViewModel mainViewModel = new MainViewModel();
-
-		public static MainViewModel MainViewModel
-		{
-			get
-			{
-				return mainViewModel;
-			}
-		}
-
-		public static void Cleanup()
-		{
-		}
-	}
-}

+ 32 - 9
CSharp/Thread/Thread.csproj → CSharp/Modules/LoginModule/Login.csproj

@@ -5,13 +5,16 @@
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <ProductVersion>8.0.30703</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{01AE803B-71F3-4DD6-BEAA-6BA7C2D13E23}</ProjectGuid>
-    <OutputType>Library</OutputType>
+    <ProjectGuid>{7CC7BF9C-13BE-470E-BC35-6A1944767899}</ProjectGuid>
+    <OutputType>library</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Thread</RootNamespace>
-    <AssemblyName>Thread</AssemblyName>
+    <RootNamespace>Module.Login</RootNamespace>
+    <AssemblyName>Module.Login</AssemblyName>
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
     <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -31,17 +34,37 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Microsoft.Practices.Prism, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+    <Reference Include="Microsoft.Practices.Prism.MefExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
     <Reference Include="System" />
+    <Reference Include="System.ComponentModel.Composition" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
+    <Reference Include="System.Xaml">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="WindowsBase" />
+    <Reference Include="PresentationCore" />
+    <Reference Include="PresentationFramework" />
+  </ItemGroup>
+  <ItemGroup>
+    <Page Include="LoginView.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
+    <Compile Include="LoginModule.cs" />
+    <Compile Include="LoginView.xaml.cs">
+      <DependentUpon>LoginView.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="LimitedConcurrencyLevelTaskScheduler.cs" />
-    <Compile Include="OrderedTaskScheduler.cs" />
+    <Compile Include="LoginViewModel.cs" />
+    <AppDesigner Include="Properties\" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Properties\" />

+ 32 - 0
CSharp/Modules/LoginModule/LoginModule.cs

@@ -0,0 +1,32 @@
+using System;
+using System.ComponentModel.Composition;
+using Microsoft.Practices.Prism.Logging;
+using Microsoft.Practices.Prism.MefExtensions.Modularity;
+using Microsoft.Practices.Prism.Modularity;
+
+namespace Module.Login
+{
+	/// <summary>
+	/// A module for the quickstart.
+	/// </summary>
+	[ModuleExport(typeof(LoginModule))]
+	public class LoginModule : IModule
+	{
+		/// <summary>
+		/// Initializes a new instance of the <see cref="ModuleA"/> class.
+		/// </summary>
+		/// <param name="logger">The logger.</param>
+		/// <param name="moduleTracker">The module tracker.</param>
+		[ImportingConstructor]
+		public LoginModule()
+		{
+		}
+
+		/// <summary>
+		/// Notifies the module that it has be initialized.
+		/// </summary>
+		public void Initialize()
+		{
+		}
+	}
+}

+ 21 - 0
CSharp/Modules/LoginModule/LoginView.xaml

@@ -0,0 +1,21 @@
+<UserControl x:Class="Module.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" 
+			 mc:Ignorable="d" 
+			 d:DesignHeight="600" d:DesignWidth="800">
+	<Grid>
+		<StackPanel>
+			<StackPanel Orientation="Horizontal">
+				<Label Content="用户名: "/>
+				<TextBox Width="150" x:Name="tBUsername" Text="{Binding Username}" />
+				<Label Content="密码: "/>
+				<TextBox Width="150" x:Name="tBPassword" Text="{Binding Password}" />
+				<Button Content="登录" HorizontalAlignment="Center" VerticalAlignment="Center" Command="{Binding LoginCmd}" />
+			</StackPanel>
+			<TextBox x:Name="tBInfo" Margin="10" Padding="1" Height="200" VerticalScrollBarVisibility="Visible" 
+					 Text="{Binding LoginInfo}" />
+		</StackPanel>
+	</Grid>
+</UserControl>

+ 27 - 0
CSharp/Modules/LoginModule/LoginView.xaml.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Module.Login
+{
+	/// <summary>
+	/// UserControl1.xaml 的交互逻辑
+	/// </summary>
+	public partial class LoginView : UserControl
+	{
+		public LoginView()
+		{
+			InitializeComponent();
+		}
+	}
+}

+ 11 - 0
CSharp/Modules/LoginModule/LoginViewModel.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Module.Login
+{
+	class LoginViewModel
+	{
+	}
+}

+ 0 - 172
CSharp/Thread/LimitedConcurrencyLevelTaskScheduler.cs

@@ -1,172 +0,0 @@
-//--------------------------------------------------------------------------
-// 
-//  Copyright (c) Microsoft Corporation.  All rights reserved. 
-// 
-//  File: LimitedConcurrencyTaskScheduler.cs
-//
-//--------------------------------------------------------------------------
-
-using System.Collections.Generic;
-using System.Linq;
-
-namespace System.Threading.Tasks.Schedulers
-{
-	/// <summary>
-	/// Provides a task scheduler that ensures a maximum concurrency level while
-	/// running on top of the ThreadPool.
-	/// </summary>
-	public class LimitedConcurrencyLevelTaskScheduler : TaskScheduler
-	{
-		/// <summary>Whether the current thread is processing work items.</summary>
-		[ThreadStatic]
-		private static bool currentThreadIsProcessingItems;
-		/// <summary>The list of tasks to be executed.</summary>
-		private readonly LinkedList<Task> tasks = new LinkedList<Task>(); // protected by lock(tasks)
-		/// <summary>The maximum concurrency level allowed by this scheduler.</summary>
-		private readonly int maxDegreeOfParallelism;
-		/// <summary>Whether the scheduler is currently processing work items.</summary>
-		private int delegatesQueuedOrRunning = 0; // protected by lock(tasks)
-
-		/// <summary>
-		/// Initializes an instance of the LimitedConcurrencyLevelTaskScheduler class with the
-		/// specified degree of parallelism.
-		/// </summary>
-		/// <param name="maxDegreeOfParallelism">The maximum degree of parallelism provided by this scheduler.</param>
-		public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism)
-		{
-			if (maxDegreeOfParallelism < 1)
-			{
-				throw new ArgumentOutOfRangeException("maxDegreeOfParallelism");
-			}
-			this.maxDegreeOfParallelism = maxDegreeOfParallelism;
-		}
-
-		/// <summary>Queues a task to the scheduler.</summary>
-		/// <param name="task">The task to be queued.</param>
-		protected sealed override void QueueTask(Task task)
-		{
-			// Add the task to the list of tasks to be processed.  If there aren't enough
-			// delegates currently queued or running to process tasks, schedule another.
-			lock (tasks)
-			{
-				tasks.AddLast(task);
-				if (delegatesQueuedOrRunning < maxDegreeOfParallelism)
-				{
-					++delegatesQueuedOrRunning;
-					NotifyThreadPoolOfPendingWork();
-				}
-			}
-		}
-
-		/// <summary>
-		/// Informs the ThreadPool that there's work to be executed for this scheduler.
-		/// </summary>
-		private void NotifyThreadPoolOfPendingWork()
-		{
-			ThreadPool.UnsafeQueueUserWorkItem(_ =>
-			{
-				// Note that the current thread is now processing work items.
-				// This is necessary to enable inlining of tasks into this thread.
-				currentThreadIsProcessingItems = true;
-				try
-				{
-					// Process all available items in the queue.
-					while (true)
-					{
-						Task item;
-						lock (tasks)
-						{
-							// When there are no more items to be processed,
-							// note that we're done processing, and get out.
-							if (tasks.Count == 0)
-							{
-								--delegatesQueuedOrRunning;
-								break;
-							}
-
-							// Get the next item from the queue
-							item = tasks.First.Value;
-							tasks.RemoveFirst();
-						}
-
-						// Execute the task we pulled out of the queue
-						base.TryExecuteTask(item);
-					}
-				}
-				// We're done processing items on the current thread
-				finally 
-				{ 
-					currentThreadIsProcessingItems = false; 
-				}
-			}, null);
-		}
-
-		/// <summary>Attempts to execute the specified task on the current thread.</summary>
-		/// <param name="task">The task to be executed.</param>
-		/// <param name="taskWasPreviouslyQueued"></param>
-		/// <returns>Whether the task could be executed on the current thread.</returns>
-		protected sealed override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
-		{
-			// If this thread isn't already processing a task, we don't support inlining
-			if (!currentThreadIsProcessingItems)
-			{
-				return false;
-			}
-
-			// If the task was previously queued, remove it from the queue
-			if (taskWasPreviouslyQueued)
-			{
-				TryDequeue(task);
-			}
-
-			// Try to run the task.
-			return base.TryExecuteTask(task);
-		}
-
-		/// <summary>Attempts to remove a previously scheduled task from the scheduler.</summary>
-		/// <param name="task">The task to be removed.</param>
-		/// <returns>Whether the task could be found and removed.</returns>
-		protected sealed override bool TryDequeue(Task task)
-		{
-			lock (tasks)
-			{
-				return tasks.Remove(task);
-			}
-		}
-
-		/// <summary>Gets the maximum concurrency level supported by this scheduler.</summary>
-		public sealed override int MaximumConcurrencyLevel 
-		{ 
-			get 
-			{ 
-				return maxDegreeOfParallelism; 
-			} 
-		}
-
-		/// <summary>Gets an enumerable of the tasks currently scheduled on this scheduler.</summary>
-		/// <returns>An enumerable of the tasks currently scheduled.</returns>
-		protected sealed override IEnumerable<Task> GetScheduledTasks()
-		{
-			bool lockTaken = false;
-			try
-			{
-				Monitor.TryEnter(tasks, ref lockTaken);
-				if (lockTaken)
-				{
-					return tasks.ToArray();
-				}
-				else
-				{
-					throw new NotSupportedException();
-				}
-			}
-			finally
-			{
-				if (lockTaken)
-				{
-					Monitor.Exit(tasks);
-				}
-			}
-		}
-	}
-}

+ 0 - 20
CSharp/Thread/OrderedTaskScheduler.cs

@@ -1,20 +0,0 @@
-//--------------------------------------------------------------------------
-// 
-//  Copyright (c) Microsoft Corporation.  All rights reserved. 
-// 
-//  File: OrderedTaskScheduler.cs
-//
-//--------------------------------------------------------------------------
-
-namespace System.Threading.Tasks.Schedulers
-{
-    /// <summary>
-    /// Provides a task scheduler that ensures only one task is executing at a time, and that tasks
-    /// execute in the order that they were queued.
-    /// </summary>
-    public sealed class OrderedTaskScheduler : LimitedConcurrencyLevelTaskScheduler
-    {
-        /// <summary>Initializes an instance of the OrderedTaskScheduler class.</summary>
-        public OrderedTaskScheduler() : base(1) { }
-    }
-}