一些新设定
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@ namespace Interact
|
|||||||
//登录结果处理事件
|
//登录结果处理事件
|
||||||
public static event LoginDoneHandler OnLoginDone;
|
public static event LoginDoneHandler OnLoginDone;
|
||||||
//获取用户列表结果处理事件
|
//获取用户列表结果处理事件
|
||||||
private static event GetUserListDoneHandler OnGetUserListDone;
|
public static event GetUserListDoneHandler OnGetUserListDone;
|
||||||
|
|
||||||
//当前连接状态
|
//当前连接状态
|
||||||
public static ClientStatus Status
|
public static ClientStatus Status
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ namespace Interact
|
|||||||
public class User
|
public class User
|
||||||
{
|
{
|
||||||
public static User Me; //当前用户
|
public static User Me; //当前用户
|
||||||
|
public static string Password;//用户的密码
|
||||||
public string Name; //用户名
|
public string Name; //用户名
|
||||||
public string NickName; //昵称
|
public string NickName; //昵称
|
||||||
public string Motto; //个性签名
|
public string Motto; //个性签名
|
||||||
|
|||||||
+18
-25
@@ -11,13 +11,9 @@ namespace StormChatWPF
|
|||||||
{
|
{
|
||||||
class Chat
|
class Chat
|
||||||
{
|
{
|
||||||
public static List<User> userlist = new List<User>();//联系人集合
|
public static User[] userlist;//联系人集合
|
||||||
|
public static User ChatNow = new User();//当前聊天对象
|
||||||
|
|
||||||
internal static void GetUsers(ResultHandler head, User user)
|
|
||||||
{
|
|
||||||
|
|
||||||
}//获取联系人对象
|
|
||||||
internal static void GetUserList(ResultHead head, User[] users)
|
internal static void GetUserList(ResultHead head, User[] users)
|
||||||
{
|
{
|
||||||
if (head.Error != "")
|
if (head.Error != "")
|
||||||
@@ -25,27 +21,24 @@ namespace StormChatWPF
|
|||||||
MessageBox.Show("无法获取联系人列表");
|
MessageBox.Show("无法获取联系人列表");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
userlist = users;
|
||||||
}//获取用户列表
|
}//获取联系人用户列表
|
||||||
internal static void GetUserPhoto(ResultHead head, Image image)
|
|
||||||
{
|
|
||||||
if (head.Error != "")
|
|
||||||
{
|
|
||||||
MessageBox.Show("无法读取用户图片");
|
|
||||||
}
|
|
||||||
}//对用户头像进行赋值
|
|
||||||
internal void Log(string user,string password)
|
internal void Log(string user,string password)
|
||||||
{
|
{
|
||||||
if (StormClient.Initialize())
|
if (StormClient.Initialize())
|
||||||
{
|
{
|
||||||
StormClient.QueueLogin(user,password);
|
StormClient.QueueLogin(user,password);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("连接服务器失败!");
|
MessageBox.Show("连接服务器失败!");
|
||||||
}
|
}
|
||||||
}//登录
|
}//登录
|
||||||
internal static void HaveLogin(ResultHead head, User user)
|
internal static void Reconnect(Exception e)
|
||||||
|
{
|
||||||
|
StormClient.Initialize();
|
||||||
|
}//尝试重连接一次,如果失败,则关闭mainwindow,打开登录窗口
|
||||||
|
internal static void HaveLogin(ResultHead head, User user)
|
||||||
{
|
{
|
||||||
App.Current.Dispatcher.Invoke(
|
App.Current.Dispatcher.Invoke(
|
||||||
(Action)delegate ()
|
(Action)delegate ()
|
||||||
@@ -55,13 +48,13 @@ namespace StormChatWPF
|
|||||||
User.Me = user;
|
User.Me = user;
|
||||||
MainWindow userWindow = new MainWindow();
|
MainWindow userWindow = new MainWindow();
|
||||||
userWindow.Show();
|
userWindow.Show();
|
||||||
LogWindow.a.Close();
|
LogWindow.entry.Close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("登录失败!");
|
MessageBox.Show("登录失败!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}//登录完成
|
}//登录完成
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
xmlns:local="clr-namespace:StormChatWPF"
|
xmlns:local="clr-namespace:StormChatWPF"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="450" Width="800">
|
Title="MainWindow" Height="450" Width="800">
|
||||||
<Grid>
|
<Grid Margin="0,0,-0.4,-1">
|
||||||
<Image x:Name="LogImage" HorizontalAlignment="Left" Height="230" Margin="10,10,0,0" VerticalAlignment="Top" Width="774" Source="/RESOURCES/logFormBackground.jpg" Stretch="None"/>
|
<Image x:Name="LogImage" Margin="0,0,0,181" Source="/RESOURCES/logFormBackground.jpg" Stretch="None"/>
|
||||||
<Button x:Name="Login_button" Content="LogIn" HorizontalAlignment="Left" Margin="240,376,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.664,1.51" Click="Login_button_Click"/>
|
<Button x:Name="Login_button" Content="LogIn" Margin="361,370,361,32" RenderTransformOrigin="0.664,1.51" Click="Login_button_Click"/>
|
||||||
<TextBox x:Name="AccountBox" HorizontalAlignment="Left" Height="23" Margin="240,290,0,0" TextWrapping="Wrap" Text="201701110203" VerticalAlignment="Top" Width="120" />
|
<TextBox x:Name="AccountBox" Margin="346,263,340,0" TextWrapping="Wrap" Text="201701110203" Height="15" VerticalAlignment="Top" />
|
||||||
<PasswordBox x:Name="passwordBox" HorizontalAlignment="Left" Margin="240,332,0,0" VerticalAlignment="Top" Width="120" Password="1233211234567"/>
|
<PasswordBox x:Name="passwordBox" Margin="346,311,0,0" Password="1233211234567" RenderTransformOrigin="0.503,0.59" Height="18" VerticalAlignment="Top" HorizontalAlignment="Left" Width="109"/>
|
||||||
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ namespace StormChatWPF
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class LogWindow : Window
|
public partial class LogWindow : Window
|
||||||
{
|
{
|
||||||
public static LogWindow a;
|
public static LogWindow entry;
|
||||||
public LogWindow()
|
public LogWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
StormClient.OnLoginDone += Chat.HaveLogin;
|
StormClient.OnLoginDone += Chat.HaveLogin;
|
||||||
StormClient.OnGetUserListDone += Chat.GetUserList;
|
StormClient.OnGetUserListDone += Chat.GetUserList;
|
||||||
StormClient.OnGetUserPhotoDone += Chat.GetUserPhoto;
|
StormClient.OnDisconnect += Chat.Reconnect;
|
||||||
a = this;
|
entry = this;
|
||||||
}
|
}
|
||||||
Chat chat = new Chat();
|
Chat chat = new Chat();
|
||||||
private void Login_button_Click(object sender, RoutedEventArgs e)
|
private void Login_button_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -36,5 +36,9 @@ namespace StormChatWPF
|
|||||||
chat.Log(AccountBox.Text,passwordBox.Password);
|
chat.Log(AccountBox.Text,passwordBox.Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,14 @@
|
|||||||
|
|
||||||
>
|
>
|
||||||
<Grid>
|
<Grid>
|
||||||
<ListView x:Name="UsersList" HorizontalAlignment="Left" Height="346" VerticalAlignment="Top" Width="191" Margin="10,64,0,0" IsEnabled="False">
|
<ListView x:Name="UsersList" HorizontalAlignment="Left" Width="201" Margin="0,64,0,10" IsEnabled="True" SelectionChanged="UsersList_SelectionChanged">
|
||||||
<ListView.View>
|
<ListView.View>
|
||||||
<GridView>
|
<GridView>
|
||||||
<GridViewColumn/>
|
<GridViewColumn/>
|
||||||
</GridView>
|
</GridView>
|
||||||
</ListView.View>
|
</ListView.View>
|
||||||
</ListView>
|
</ListView>
|
||||||
|
<TextBox HorizontalAlignment="Left" Height="90" Margin="201,320,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="583" />
|
||||||
|
<Button Content="Button" HorizontalAlignment="Left" Margin="378,262,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
namespace StormChatWPF
|
namespace StormChatWPF
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UserWindow.xaml 的交互逻辑
|
/// UserWindow.xaml 的交互逻辑
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
private void AddUserList()
|
private void AddUserList()
|
||||||
{
|
{
|
||||||
if (Chat.userlist.Any())
|
if (Chat.userlist.Any())
|
||||||
@@ -32,8 +32,21 @@ namespace StormChatWPF
|
|||||||
UsersList.Items.Add(user);
|
UsersList.Items.Add(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//向联系人列表listview中添加元素
|
}//向联系人列表listview中添加元素
|
||||||
|
|
||||||
|
private void UsersList_Selected(object sender, RoutedEventArgs e)
|
||||||
}
|
{
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UsersList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
AddUserList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user