一些新设定

This commit is contained in:
Kaniu Tayou
2018-12-18 19:38:27 +08:00
parent 29b281a71f
commit ad745595e8
7 changed files with 78 additions and 67 deletions
+18 -25
View File
@@ -11,13 +11,9 @@ namespace StormChatWPF
{
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)
{
if (head.Error != "")
@@ -25,27 +21,24 @@ namespace StormChatWPF
MessageBox.Show("无法获取联系人列表");
}
else
return;
}//获取用户列表
internal static void GetUserPhoto(ResultHead head, Image image)
{
if (head.Error != "")
{
MessageBox.Show("无法读取用户图片");
}
}//对用户头像进行赋值
userlist = users;
}//获取联系人用户列表
internal void Log(string user,string password)
{
if (StormClient.Initialize())
{
StormClient.QueueLogin(user,password);
}
else
{
MessageBox.Show("连接服务器失败!");
if (StormClient.Initialize())
{
StormClient.QueueLogin(user,password);
}
else
{
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(
(Action)delegate ()
@@ -55,13 +48,13 @@ namespace StormChatWPF
User.Me = user;
MainWindow userWindow = new MainWindow();
userWindow.Show();
LogWindow.a.Close();
LogWindow.entry.Close();
}
else
{
MessageBox.Show("登录失败!");
}
});
});
}//登录完成
+5 -5
View File
@@ -6,11 +6,11 @@
xmlns:local="clr-namespace:StormChatWPF"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Image x:Name="LogImage" HorizontalAlignment="Left" Height="230" Margin="10,10,0,0" VerticalAlignment="Top" Width="774" 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"/>
<TextBox x:Name="AccountBox" HorizontalAlignment="Left" Height="23" Margin="240,290,0,0" TextWrapping="Wrap" Text="201701110203" VerticalAlignment="Top" Width="120" />
<PasswordBox x:Name="passwordBox" HorizontalAlignment="Left" Margin="240,332,0,0" VerticalAlignment="Top" Width="120" Password="1233211234567"/>
<Grid Margin="0,0,-0.4,-1">
<Image x:Name="LogImage" Margin="0,0,0,181" Source="/RESOURCES/logFormBackground.jpg" Stretch="None"/>
<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" Margin="346,263,340,0" TextWrapping="Wrap" Text="201701110203" Height="15" VerticalAlignment="Top" />
<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>
+7 -3
View File
@@ -21,14 +21,14 @@ namespace StormChatWPF
/// </summary>
public partial class LogWindow : Window
{
public static LogWindow a;
public static LogWindow entry;
public LogWindow()
{
InitializeComponent();
StormClient.OnLoginDone += Chat.HaveLogin;
StormClient.OnGetUserListDone += Chat.GetUserList;
StormClient.OnGetUserPhotoDone += Chat.GetUserPhoto;
a = this;
StormClient.OnDisconnect += Chat.Reconnect;
entry = this;
}
Chat chat = new Chat();
private void Login_button_Click(object sender, RoutedEventArgs e)
@@ -36,5 +36,9 @@ namespace StormChatWPF
chat.Log(AccountBox.Text,passwordBox.Password);
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
}
}
}
+3 -2
View File
@@ -9,13 +9,14 @@
>
<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>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
</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>
</Window>
+43 -30
View File
@@ -1,28 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Shapes;
namespace StormChatWPF
{
/// <summary>
/// UserWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Shapes;
namespace StormChatWPF
{
/// <summary>
/// UserWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void AddUserList()
{
if (Chat.userlist.Any())
@@ -32,8 +32,21 @@ namespace StormChatWPF
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();
}
}
}