Procházet zdrojové kódy

BOSS管理工具界面增加操作日志显示

tanghai před 13 roky
rodič
revize
980bc1f22f

+ 8 - 0
CSharp/App/Modules/Robot/Robot.csproj

@@ -53,6 +53,14 @@
     <Reference Include="System.Xaml" />
     <Reference Include="System.Xml" />
     <Reference Include="WindowsBase" />
+    <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="Robot.cs" />

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

@@ -1,26 +1,27 @@
-<UserControl x:Class="Modules.Robot.RobotView"
+<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:Robot="clr-namespace:Modules.Robot"
+		xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Class="Modules.Robot.RobotView"
 		mc:Ignorable="d" 
-		d:DesignHeight="750" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Robot:RobotViewModel}">
+		d:DesignHeight="750" d:DesignWidth="1280" d:DataContext="{d:DesignInstance {x:Type Robot:RobotViewModel}}">
 	<Grid>
-		<DockPanel Name="dock" Visibility="{Binding DockPanelVisiable}">
+		<DockPanel x:Name="dock" Visibility="{Binding DockPanelVisiable}">
 			<Menu DockPanel.Dock="Top" Margin="0,2" >
-				<MenuItem Header="登录" Name="menuLogin" Click="menuLogin_Click" ></MenuItem>
+				<MenuItem Header="登录" x:Name="menuLogin" Click="menuLogin_Click" />
 				<MenuItem Header="服务器"  >
-					<MenuItem Name="menuServers" Header="显示服务器" Click="menuServers_Click"></MenuItem>
-					<MenuItem Name="menuReload" Header="Reload World" Click="menuReload_Click"></MenuItem>
+					<MenuItem x:Name="menuServers" Header="显示服务器" Click="menuServers_Click"/>
+					<MenuItem x:Name="menuReload" Header="Reload World" Click="menuReload_Click"/>
 				</MenuItem>
 			</Menu>
 			<ListBox Height="723" Width="119" SelectionMode="Multiple" ItemsSource="{Binding ServerInfos}" 
-					d:DataContext="{d:DesignInstance Robot:RobotViewModel}" 
-					BorderThickness="3" BorderBrush="BurlyWood" >
+				d:DataContext="{d:DesignInstance {x:Type Robot:RobotViewModel}}" 
+				BorderThickness="3" BorderBrush="BurlyWood" >
 				<ListBox.ItemTemplate>
 					<DataTemplate>
-						<Label Content="{Binding Name}" ></Label>
+						<Label Content="{Binding Name}" />
 					</DataTemplate>
 				</ListBox.ItemTemplate>
 			</ListBox>
@@ -34,7 +35,7 @@
 								<ComboBoxItem Content="GUID"/>
 							</ComboBox>
 							<TextBox Width="166" Text="{Binding FindType}" Canvas.Left="88" Canvas.Top="23" Height="25"/>
-							<Button Name="btnFindPlayer" Content="查询" Click="btnFindPlayer_Click" RenderTransformOrigin="9.161,1.435" Canvas.Left="261" Canvas.Top="23" Height="25"></Button>
+							<Button x:Name="btnFindPlayer" Content="查询" Click="btnFindPlayer_Click" RenderTransformOrigin="9.161,1.435" Canvas.Left="261" Canvas.Top="23" Height="25"/>
 							<Label Content="帐 号:" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="52" />
 							<TextBox Text="{Binding Account}"  Grid.Row="1" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="53" Width="204"/>
 							<Label Content="名 字:" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="83" />
@@ -52,20 +53,19 @@
 									<Grid/>
 								</TabItem>
 								<TabItem Header="装备">
-									<Canvas>
-
-									</Canvas>
+									<Canvas/>
 								</TabItem>
 								<TabItem Header="GM">
 									<Canvas>
-										<Button Name="btnForbiddenBuy" Content="禁止交易" Canvas.Left="11" Canvas.Top="10" Width="75" Click="btnForbiddenBuy_Click"/>
-										<Button Name="btnAllowBuy" Content="允许交易" Canvas.Left="11" Canvas.Top="38" Width="75" Click="btnAllowBuy_Click" />
+										<Button x:Name="btnForbiddenBuy" Content="禁止交易" Canvas.Left="11" Canvas.Top="10" Width="75" Click="btnForbiddenBuy_Click"/>
+										<Button x:Name="btnAllowBuy" Content="允许交易" Canvas.Left="11" Canvas.Top="38" Width="75" Click="btnAllowBuy_Click" />
 									</Canvas>
 								</TabItem>
 							</TabControl>
-							<Label Name="lblErrorInfo" Content="{Binding ErrorInfo}" Canvas.Left="315" Canvas.Top="114" Width="201" Height="25"/>
 						</Canvas>
 					</GroupBox>
+					<TextBox Name="tbLog" Height="703" Canvas.Left="749" TextWrapping="Wrap" Text="" 
+							Canvas.Top="10" Width="402" IsReadOnly="True" />
 				</Canvas>
 			</Grid>
 		</DockPanel>

+ 16 - 7
CSharp/App/Modules/Robot/RobotView.xaml.cs

@@ -1,4 +1,5 @@
-using System.ComponentModel.Composition;
+using System;
+using System.ComponentModel.Composition;
 using System.Windows;
 using Infrastructure;
 
@@ -36,25 +37,33 @@ namespace Modules.Robot
 		private void btnFindPlayer_Click(object sender, RoutedEventArgs e)
 		{
 			this.ViewModel.FindPlayer();
+			this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
+			this.tbLog.ScrollToEnd();
 		}
 
 		private void menuLogin_Click(object sender, RoutedEventArgs e)
 		{
 		}
 
-		private void menuServers_Click(object sender, RoutedEventArgs e)
+		private async void menuServers_Click(object sender, RoutedEventArgs e)
 		{
-			this.ViewModel.Servers();
+			await this.ViewModel.Servers();
+			this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
+			this.tbLog.ScrollToEnd();
 		}
 
-		private void btnForbiddenBuy_Click(object sender, RoutedEventArgs e)
+		private async void btnForbiddenBuy_Click(object sender, RoutedEventArgs e)
 		{
-			this.ViewModel.ForbiddenBuy();
+			await this.ViewModel.ForbiddenBuy();
+			this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
+			this.tbLog.ScrollToEnd();
 		}
 
-		private void btnAllowBuy_Click(object sender, RoutedEventArgs e)
+		private async void btnAllowBuy_Click(object sender, RoutedEventArgs e)
 		{
-			this.ViewModel.AllowBuy();
+			await this.ViewModel.AllowBuy();
+			this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
+			this.tbLog.ScrollToEnd();
 		}
 	}
 }

+ 20 - 43
CSharp/App/Modules/Robot/RobotViewModel.cs

@@ -28,35 +28,11 @@ namespace Modules.Robot
 		private Visibility dockPanelVisiable = Visibility.Hidden;
 		private readonly BossClient.BossClient bossClient = new BossClient.BossClient();
 		private readonly ObservableCollection<ServerViewModel> serverInfos = 
-			new ObservableCollection<ServerViewModel>();
-
-		private DataCenterEntities entities = new DataCenterEntities();
-
-		private IMessageChannel iMessageChannel;
-
-		public DataCenterEntities Entities
-		{
-			get
-			{
-				return this.entities;
-			}
-			set
-			{
-				this.entities = value;
-			}
-		}
-
-		public IMessageChannel IMessageChannel
-		{
-			get
-			{
-				return this.iMessageChannel;
-			}
-			set
-			{
-				this.iMessageChannel = value;
-			}
-		}
+			new ObservableCollection<ServerViewModel>();
+
+		public DataCenterEntities Entities { get; set; }
+
+		public IMessageChannel IMessageChannel { get; set; }
 
 		public int FindTypeIndex
 		{
@@ -203,8 +179,9 @@ namespace Modules.Robot
 		}
 
 		[ImportingConstructor]
-		public RobotViewModel(IEventAggregator eventAggregator)
-		{
+		public RobotViewModel(IEventAggregator eventAggregator)
+		{
+			this.Entities = new DataCenterEntities();
 			eventAggregator.GetEvent<LoginOKEvent>().Subscribe(this.OnLoginOK);
 		}
 
@@ -221,7 +198,7 @@ namespace Modules.Robot
 
 		private void Disposing(bool disposing)
 		{
-			this.entities.Dispose();
+			this.Entities.Dispose();
 			this.bossClient.Dispose();
 		}
 
@@ -229,9 +206,9 @@ namespace Modules.Robot
 		{
 			this.DockPanelVisiable = Visibility.Visible;
 			this.IMessageChannel = messageChannel;
-		}
-
-		public async void Servers()
+		}
+
+		public async Task Servers()
 		{
 			ABossCommand bossCommand = new BCServerInfo(this.IMessageChannel, this.Entities);
 			var result = await bossCommand.DoAsync();
@@ -249,14 +226,14 @@ namespace Modules.Robot
 				this.ServerInfos.Add(new ServerViewModel { Name = nm });
 			}
 			this.ErrorInfo = "查询服务器成功!";
-		}
-
+		}
+
 		public void Reload()
 		{
 			ABossCommand bossCommand = new BCReloadWorld(this.IMessageChannel, this.Entities);
 			bossCommand.Do();
-		}
-
+		}
+
 		public void FindPlayer()
 		{
 			ABossCommand bossCommand = new BCFindPlayer(this.IMessageChannel, this.Entities)
@@ -279,7 +256,7 @@ namespace Modules.Robot
 			this.ErrorInfo = "查询成功";
 		}
 
-		public async void ForbiddenBuy()
+		public async Task ForbiddenBuy()
 		{
 			if (this.Guid == "")
 			{
@@ -301,9 +278,9 @@ namespace Modules.Robot
 				return;
 			}
 			this.ErrorInfo = string.Format("禁止交易失败, error code: {0}", errorCode);
-		}
-
-		public async void AllowBuy()
+		}
+
+		public async Task AllowBuy()
 		{
 			if (this.Guid == "")
 			{