合并
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@ namespace Interact
|
||||
//登录结果处理事件
|
||||
public static event LoginDoneHandler OnLoginDone;
|
||||
//获取用户列表结果处理事件
|
||||
private static event GetUserListDoneHandler OnGetUserListDone;
|
||||
public static event GetUserListDoneHandler OnGetUserListDone;
|
||||
|
||||
//当前连接状态
|
||||
public static ClientStatus Status
|
||||
|
||||
+37
-16
@@ -11,29 +11,38 @@ namespace StormChatWPF
|
||||
{
|
||||
class Chat
|
||||
{
|
||||
public static List<User> userlist = new List<User>();//联系人集合
|
||||
|
||||
|
||||
internal static void GetUsers(ResultHandler head, User user)
|
||||
public static List<User> ContactsList;//联系人集合
|
||||
public static Chat chat = new Chat();
|
||||
private Chat()
|
||||
{
|
||||
StormClient.OnLoginDone += HaveLogin;
|
||||
StormClient.OnGetUserListDone += GetContactsList;
|
||||
StormClient.OnMessage +=ReciveMessage;
|
||||
}
|
||||
|
||||
}//获取联系人对象
|
||||
internal static void GetUserList(ResultHead head, User[] users)
|
||||
|
||||
private User ChatNow;
|
||||
internal User SetContact
|
||||
{
|
||||
get
|
||||
{
|
||||
return ChatNow;
|
||||
}
|
||||
set
|
||||
{
|
||||
ChatNow = value;
|
||||
}
|
||||
}//设置当前联系人对象
|
||||
internal static void GetContactsList(ResultHead head, User[] users)
|
||||
{
|
||||
if (head.Error != "")
|
||||
{
|
||||
MessageBox.Show("无法获取联系人列表");
|
||||
}
|
||||
else
|
||||
ContactsList =new List<User>( users);
|
||||
return;
|
||||
}//获取用户列表
|
||||
internal static void GetUserPhoto(ResultHead head, Image image)
|
||||
{
|
||||
if (head.Error != "")
|
||||
{
|
||||
MessageBox.Show("无法读取用户图片");
|
||||
}
|
||||
}//对用户头像进行赋值
|
||||
}//获取联系人列表
|
||||
internal void Log(string user,string password)
|
||||
{
|
||||
if (StormClient.Initialize())
|
||||
@@ -55,7 +64,7 @@ namespace StormChatWPF
|
||||
User.Me = user;
|
||||
MainWindow userWindow = new MainWindow();
|
||||
userWindow.Show();
|
||||
LogWindow.a.Close();
|
||||
LogWindow.Instence.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -63,7 +72,19 @@ namespace StormChatWPF
|
||||
}
|
||||
});
|
||||
}//登录完成
|
||||
internal static void ReciveMessage(Message message)
|
||||
{
|
||||
LogWindow.Instence.ShowMessage(message);
|
||||
}//接受到新消息的时候
|
||||
internal static void SendMessage(string text,User target)
|
||||
{
|
||||
// Message msg = new Message(text);
|
||||
// Action<BaseHead> f = delegate(BaseHead head)
|
||||
// {
|
||||
|
||||
|
||||
// };
|
||||
// StormClient.QueueSendMessage(msg, target, f);
|
||||
// LogWindow.Instence.ShowUserMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -21,20 +21,22 @@ namespace StormChatWPF
|
||||
/// </summary>
|
||||
public partial class LogWindow : Window
|
||||
{
|
||||
public static LogWindow a;
|
||||
public static LogWindow Instence;
|
||||
public LogWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
StormClient.OnLoginDone += Chat.HaveLogin;
|
||||
StormClient.OnGetUserListDone += Chat.GetUserList;
|
||||
StormClient.OnGetUserPhotoDone += Chat.GetUserPhoto;
|
||||
a = this;
|
||||
Instence = this;
|
||||
}
|
||||
Chat chat = new Chat();
|
||||
private void Login_button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
chat.Log(AccountBox.Text,passwordBox.Password);
|
||||
Chat.chat.Log(AccountBox.Text,passwordBox.Password);
|
||||
}
|
||||
internal void ShowMessage(Message message)
|
||||
{
|
||||
|
||||
}//将收到的消息展现于UI界面
|
||||
internal void ShowUserMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -34,6 +34,19 @@ namespace StormChatWPF
|
||||
}
|
||||
}//向联系人列表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