Parcourir la source

重新布局了查询帐号信息的界面,使用Canvas布局

tanghai il y a 13 ans
Parent
commit
dc6f7fc404

+ 0 - 9
CSharp/App/BossClient/BossClient.cs

@@ -56,14 +56,5 @@ namespace BossClient
 				Logger.Trace("session: {0}, exception: {1}", loginSessionId, e.ToString());
 			}
 		}
-
-		public void SendCommand(string command)
-		{
-			var cmsgBossGm = new CMSG_Boss_Gm
-			{
-				Message = command
-			};
-			this.GateSession.SendMessage(MessageOpcode.CMSG_BOSS_GM, cmsgBossGm);
-		}
 	}
 }

+ 31 - 28
CSharp/App/Modules/Robot/RobotView.xaml

@@ -7,25 +7,6 @@
 		mc:Ignorable="d" 
 		d:DesignHeight="600" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Robot:RobotViewModel}">
 	<Grid>
-		<!--<xctk:ChildWindow Name="cwLoginWindow"  Visibility="{Binding GridLoginVisiable}" 
-				HorizontalAlignment="Center" VerticalAlignment="Center" CloseButtonVisibility="Hidden">
-			<Grid Name="gridLogin"  Width="200" Height="120" >
-				<Grid.RowDefinitions>
-					<RowDefinition></RowDefinition>
-					<RowDefinition></RowDefinition>
-					<RowDefinition></RowDefinition>
-				</Grid.RowDefinitions>
-				<Grid.ColumnDefinitions>
-					<ColumnDefinition Width="10*"></ColumnDefinition>
-					<ColumnDefinition Width="40*"></ColumnDefinition>
-				</Grid.ColumnDefinitions>
-				<Label Content="帐号: " Grid.Row="0" Grid.Column="0" Margin="0,8"/>
-				<TextBox Text="{Binding Account}" Grid.Row="0" Grid.Column="1" Margin="0,8,0,8" />
-				<Label Content="密码: " Grid.Row="1" Grid.Column="0" Margin="0,8"/>
-				<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>-->
 		<DockPanel Name="dock" Visibility="{Binding DockPanelVisiable}">
 			<Menu DockPanel.Dock="Top" >
 				<MenuItem Header="登录" Name="menuLogin" Click="menuLogin_Click" ></MenuItem>
@@ -33,15 +14,8 @@
 			<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Height="27" >
 				<Button Name="btnServers" Content="服务器列表" Click="btnServers_Click" ></Button>
 				<Button Name="btnReload" Content="Reload" Click="btnReload_Click" ></Button>
-				<ComboBox Name="cbFindType" SelectedIndex="{Binding FindTypeIndex}">
-					<ComboBoxItem Content="帐号"></ComboBoxItem>
-					<ComboBoxItem Content="名字"></ComboBoxItem>
-					<ComboBoxItem Content="GUID"></ComboBoxItem>
-				</ComboBox>
-				<TextBox Width="120" Text="{Binding FindType}" />
-				<Button Name="btnFind" Content="查询" Click="btnFind_Click" ></Button>
 			</StackPanel>
-			<ListBox Width="100" SelectionMode="Multiple" ItemsSource="{Binding ServerInfos}" 
+			<ListBox Width="119" SelectionMode="Multiple" ItemsSource="{Binding ServerInfos}" 
 					d:DataContext="{d:DesignInstance Robot:RobotViewModel}" >
 				<ListBox.ItemTemplate>
 					<DataTemplate>
@@ -49,7 +23,36 @@
 					</DataTemplate>
 				</ListBox.ItemTemplate>
 			</ListBox>
-			<Grid />
+			<Grid>
+				<Canvas>
+					<ComboBox x:Name="cbFindType" SelectedIndex="{Binding FindTypeIndex}" Canvas.Left="42" Canvas.Top="19">
+						<ComboBoxItem Content="帐号"/>
+						<ComboBoxItem Content="名字"/>
+						<ComboBoxItem Content="GUID"/>
+					</ComboBox>
+					<TextBox Width="120" Text="{Binding FindType}" Canvas.Left="103" Canvas.Top="20" />
+					<Button Name="btnFind" Content="查询" Click="btnFind_Click" Canvas.Left="239" Canvas.Top="20" ></Button>
+					<GroupBox Header="角色信息" Canvas.Left="42" Canvas.Top="57" Height="163" Width="243">
+						<Grid Margin="0,10,0,0">
+							<Grid.RowDefinitions>
+								<RowDefinition></RowDefinition>
+								<RowDefinition></RowDefinition>
+								<RowDefinition></RowDefinition>
+							</Grid.RowDefinitions>
+							<Grid.ColumnDefinitions>
+								<ColumnDefinition Width="67*"></ColumnDefinition>
+								<ColumnDefinition Width="190*"></ColumnDefinition>
+							</Grid.ColumnDefinitions>
+							<Label Content="帐号:" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Height="26" Width="36" />
+							<TextBox Text="{Binding Account}"  Grid.Row="0" Grid.Column="1" Margin="0,8" />
+							<Label Content="名字:" Grid.Row="1" Grid.Column="0" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Height="23" Width="36" />
+							<TextBox Text="{Binding Name}" Grid.Row="1" Grid.Column="1" Margin="0,8" />
+							<Label Content="GUID:" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Height="26" Width="44" />
+							<TextBox Text="{Binding Guid}" Grid.Row="2" Grid.Column="1" Margin="0,8"/>
+						</Grid>
+					</GroupBox>
+				</Canvas>
+			</Grid>
 		</DockPanel>
 	</Grid>
 </UserControl>

+ 79 - 10
CSharp/App/Modules/Robot/RobotViewModel.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel.Composition;
 using System.Configuration;
+using System.Globalization;
 using System.Linq;
 using System.Windows;
 using System.Windows.Threading;
@@ -21,7 +22,10 @@ namespace Modules.Robot
 	internal sealed class RobotViewModel: NotificationObject, IDisposable
 	{
 		private int findTypeIndex;
+		private string account = "";
 		private string findType = "";
+		private string name = "";
+		private string guid = "";
 		private Visibility dockPanelVisiable = Visibility.Hidden;
 		private readonly BossClient.BossClient bossClient = new BossClient.BossClient();
 		private readonly ObservableCollection<ServerViewModel> serverInfos = 
@@ -30,6 +34,8 @@ namespace Modules.Robot
 		public readonly Dictionary<ushort, Action<byte[]>> messageHandlers =
 			new Dictionary<ushort, Action<byte[]>>();
 
+		public IMessageChannel IMessageChannel { get; set; }
+
 		public int FindTypeIndex
 		{
 			get
@@ -89,6 +95,57 @@ namespace Modules.Robot
 			}
 		}
 
+		public string Account
+		{
+			get
+			{
+				return this.account;
+			}
+			set
+			{
+				if (this.account == value)
+				{
+					return;
+				}
+				this.account = value;
+				this.RaisePropertyChanged("Account");
+			}
+		}
+
+		public string Name
+		{
+			get
+			{
+				return this.name;
+			}
+			set
+			{
+				if (this.name == value)
+				{
+					return;
+				}
+				this.name = value;
+				this.RaisePropertyChanged("Name");
+			}
+		}
+
+		public string Guid
+		{
+			get
+			{
+				return this.guid;
+			}
+			set
+			{
+				if (this.guid == value)
+				{
+					return;
+				}
+				this.guid = value;
+				this.RaisePropertyChanged("Guid");
+			}
+		}
+
 		[ImportingConstructor]
 		public RobotViewModel(IEventAggregator eventAggregator)
 		{
@@ -116,11 +173,12 @@ namespace Modules.Robot
 		public async void OnLoginOK(IMessageChannel messageChannel)
 		{
 			this.DockPanelVisiable = Visibility.Visible;
+			this.IMessageChannel = messageChannel;
 			try
 			{
 				while (true)
 				{
-					var result = await messageChannel.RecvMessage();
+					var result = await this.IMessageChannel.RecvMessage();
 					ushort opcode = result.Item1;
 					byte[] message = result.Item2;
 					if (!messageHandlers.ContainsKey(opcode))
@@ -138,9 +196,19 @@ namespace Modules.Robot
 			}
 		}
 
+		public void SendCommand(string command)
+		{
+			var cmsgBossGm = new CMSG_Boss_Gm
+			{
+				Message = command
+			};
+
+			this.IMessageChannel.SendMessage(MessageOpcode.CMSG_BOSS_GM, cmsgBossGm);
+		}
+
 		public void Servers()
 		{
-			this.bossClient.SendCommand("servers");
+			this.SendCommand("servers");
 		}
 
 		public void Handle_SMSG_Boss_ServersInfo(byte[] message)
@@ -148,15 +216,15 @@ namespace Modules.Robot
 			var smsgBossServersInfo = ProtobufHelper.FromBytes<SMSG_Boss_ServersInfo>(message);
 
 			this.ServerInfos.Clear();
-			foreach (var name in smsgBossServersInfo.Name)
+			foreach (var nm in smsgBossServersInfo.Name)
 			{
-				this.ServerInfos.Add(new ServerViewModel { Name = name });
+				this.ServerInfos.Add(new ServerViewModel { Name = nm });
 			}
 		}
 
 		public void Reload()
 		{
-			this.bossClient.SendCommand("reload");
+			this.SendCommand("reload");
 		}
 
 		public void Find()
@@ -180,9 +248,9 @@ namespace Modules.Robot
 					}
 					case 2:
 					{
-						var guid = Decimal.Parse(this.FindType);
+						var findGuid = Decimal.Parse(this.FindType);
 						result = entitys.t_character.FirstOrDefault(
-							c => c.character_guid == guid);
+							c => c.character_guid == findGuid);
 						break;
 					}
 				}
@@ -192,9 +260,10 @@ namespace Modules.Robot
 					Logger.Debug("not find charactor info!");
 					return;
 				}
-				
-				Logger.Debug("Account: {0}, Name: {1}, GUID: {2}", 
-					result.account, result.character_name, result.character_guid);
+
+				this.Account = result.account;
+				this.Name = result.character_name;
+				this.Guid = result.character_guid.ToString(CultureInfo.InvariantCulture);
 			}
 		}
 	}