日常察看
This commit is contained in:
@@ -1,104 +1,101 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using Interact;
|
||||||
using System.Text;
|
using System.Windows;
|
||||||
using System.Threading.Tasks;
|
using System.IO;
|
||||||
using Interact;
|
|
||||||
using System.Drawing;
|
namespace StormChatWPF
|
||||||
using System.Windows;
|
{
|
||||||
using System.IO;
|
class Chat
|
||||||
|
{
|
||||||
namespace StormChatWPF
|
public static List<User> ContactsList;//联系人集合
|
||||||
{
|
public static Chat chat=new Chat();
|
||||||
class Chat
|
private Chat()
|
||||||
{
|
{
|
||||||
public static List<User> ContactsList;//联系人集合
|
StormClient.OnLoginDone += OnHaveLogin;
|
||||||
public static Chat chat=new Chat();
|
StormClient.OnGetUserListDone += OnGetContactsList;
|
||||||
private Chat()
|
StormClient.OnMessage +=OnMessage;//事件挂接
|
||||||
{
|
User.DefaultPhoto = new MemoryStream(File.ReadAllBytes(@"../../UI/Resources/默认头像.png"));//设定默认头像
|
||||||
StormClient.OnLoginDone += OnHaveLogin;
|
}
|
||||||
StormClient.OnGetUserListDone += OnGetContactsList;
|
internal static User CurrentContact { get;
|
||||||
StormClient.OnMessage +=OnMessage;//事件挂接
|
set; }//设置当前联系人对象
|
||||||
User.DefaultPhoto = new MemoryStream(File.ReadAllBytes(@"../../UI/Resources/默认头像.png"));//设定默认头像
|
/// <summary>
|
||||||
}
|
/// 获取联系人列表(完成后打开主窗体)
|
||||||
internal static User CurrentContact { get; set; }//设置当前联系人对象
|
/// </summary>
|
||||||
/// <summary>
|
private void OnGetContactsList(ResultHead head, User[] users)
|
||||||
/// 获取联系人列表(完成后打开主窗体)
|
{
|
||||||
/// </summary>
|
if (head.Error != "")
|
||||||
private void OnGetContactsList(ResultHead head, User[] users)
|
{
|
||||||
{
|
MessageBox.Show("无法获取联系人列表");
|
||||||
if (head.Error != "")
|
return;
|
||||||
{
|
}
|
||||||
MessageBox.Show("无法获取联系人列表");
|
App.Current.Dispatcher.Invoke(
|
||||||
return;
|
(Action)delegate ()
|
||||||
}
|
{
|
||||||
App.Current.Dispatcher.Invoke(
|
ContactsList = new List<User>(users);
|
||||||
(Action)delegate ()
|
MainWindow mainWindow = new MainWindow();
|
||||||
{
|
mainWindow.Show();
|
||||||
ContactsList = new List<User>(users);
|
LogWindow.Instence.Close();
|
||||||
MainWindow mainWindow = new MainWindow();
|
});
|
||||||
mainWindow.Show();
|
}//获取联系人列表完成
|
||||||
LogWindow.Instence.Close();
|
private void OnHaveLogin(ResultHead head, User user)
|
||||||
});
|
{
|
||||||
}//获取联系人列表完成
|
if (head.Error == "")
|
||||||
private void OnHaveLogin(ResultHead head, User user)
|
{
|
||||||
{
|
User.Me = user;
|
||||||
if (head.Error == "")
|
StormClient.QueueGetUserList();
|
||||||
{
|
}
|
||||||
User.Me = user;
|
else
|
||||||
StormClient.QueueGetUserList();
|
{
|
||||||
}
|
App.Current.Dispatcher.Invoke(
|
||||||
else
|
(Action)delegate ()
|
||||||
{
|
{
|
||||||
App.Current.Dispatcher.Invoke(
|
LogWindow.Instence.Login_button.IsEnabled = true;
|
||||||
(Action)delegate ()
|
});
|
||||||
{
|
MessageBox.Show("请核对账号密码!");
|
||||||
LogWindow.Instence.Login_button.IsEnabled = true;
|
}
|
||||||
});
|
}//登录完成
|
||||||
MessageBox.Show("请核对账号密码!");
|
private void OnMessage(Message message)
|
||||||
}
|
{
|
||||||
}//登录完成
|
if (MainWindow.Instence != null)
|
||||||
private void OnMessage(Message message)
|
{
|
||||||
{
|
MainWindow.Instence.ShowMessage(message);
|
||||||
if (MainWindow.Instence != null)
|
}
|
||||||
{
|
}//接受到新消息
|
||||||
MainWindow.Instence.ShowMessage(message);
|
|
||||||
}
|
internal void SendMessage(string text,User target)
|
||||||
}//接受到新消息
|
{
|
||||||
|
Message msg = new Message(text,target);
|
||||||
internal void SendMessage(string text,User target)
|
Action<ResultHead> f = delegate (ResultHead head)
|
||||||
{
|
{
|
||||||
Message msg = new Message(text,target);
|
MainWindow.Instence.ShowMessage(msg);
|
||||||
Action<ResultHead> f = delegate (ResultHead head)
|
};
|
||||||
{
|
StormClient.QueueSendMessage(msg,f);
|
||||||
MainWindow.Instence.ShowMessage(msg);
|
}//发送消息
|
||||||
};
|
internal static void Log(string user, string password)
|
||||||
StormClient.QueueSendMessage(msg,f);
|
{
|
||||||
}//发送消息
|
if (StormClient.Initialize())
|
||||||
internal static void Log(string user, string password)
|
{
|
||||||
{
|
if (!StormClient.QueueLogin(user, password))
|
||||||
if (StormClient.Initialize())
|
{
|
||||||
{
|
App.Current.Dispatcher.Invoke(
|
||||||
if (!StormClient.QueueLogin(user, password))
|
(Action)delegate ()
|
||||||
{
|
{
|
||||||
App.Current.Dispatcher.Invoke(
|
LogWindow.Instence.Login_button.IsEnabled = true;
|
||||||
(Action)delegate ()
|
});
|
||||||
{
|
MessageBox.Show("登录失败");
|
||||||
LogWindow.Instence.Login_button.IsEnabled = true;
|
}
|
||||||
});
|
}
|
||||||
MessageBox.Show("登录失败");
|
else
|
||||||
}
|
{
|
||||||
}
|
App.Current.Dispatcher.Invoke(
|
||||||
else
|
(Action)delegate ()
|
||||||
{
|
{
|
||||||
App.Current.Dispatcher.Invoke(
|
LogWindow.Instence.Login_button.IsEnabled = true;
|
||||||
(Action)delegate ()
|
});
|
||||||
{
|
MessageBox.Show("连接服务器失败!");
|
||||||
LogWindow.Instence.Login_button.IsEnabled = true;
|
}
|
||||||
});
|
}//登录
|
||||||
MessageBox.Show("连接服务器失败!");
|
|
||||||
}
|
}
|
||||||
}//登录
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace StormChatWPF.UI
|
|||||||
VerticalAlignment = VerticalAlignment.Bottom
|
VerticalAlignment = VerticalAlignment.Bottom
|
||||||
};
|
};
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 生成聊天气泡
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="msg">传入消息体</param>
|
/// <param name="msg">传入消息体</param>
|
||||||
/// <param name="alignment">设置水平对齐方式,参数为HorizontalAlignment枚举类型</param>
|
/// <param name="alignment">设置水平对齐方式,参数为HorizontalAlignment枚举类型</param>
|
||||||
|
|||||||
Reference in New Issue
Block a user