?? messagehistoryform.cs
字號:
?namespace Imps.Client.Pc
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using Imps.Client.Resource;
using Imps.Client.Utils;
using Imps.Utils;
using Imps.Utils.TagParser;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
public class MessageHistoryForm : XIMChatHistory
{
private Imps.Client.Core.Contact _contact;
private IFrameworkWindow _framework;
private bool _isSearch;
private ChatEditCtrlManager _rtfManager;
private BindingNavigator bindingNavigator;
private ToolStripButton bindingNavigatorDeleteItem;
private ToolStripButton bindingNavigatorMoveFirstItem;
private ToolStripButton bindingNavigatorMoveLastItem;
private ToolStripButton bindingNavigatorMoveNextItem;
private ToolStripButton bindingNavigatorMovePreviousItem;
private ToolStripSeparator bindingNavigatorSeparator;
private ToolStripSeparator bindingNavigatorSeparator2;
private ToolStripButton btnDeleteAll;
private ToolStripButton btnRefresh;
private IContainer components;
private DataGridViewTextBoxColumn contentDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn dateDataGridViewTextBoxColumn;
private menu_widget dgMenu;
private ToolStripMenuItem dgMenuCopy;
private ToolStripMenuItem dgMenuDelete;
private ToolStripMenuItem dgMenuSelectAll;
private DataGridViewTextBoxColumn fromDataGridViewTextBoxColumn;
private DataGridView gdHistory;
private ImageList imageList;
private XLabel lblMessageInfo;
private ToolStripLabel lblNavigatePageInfo;
private Panel panel1;
private Panel panel2;
private Panel pnlMain;
private ChatRichTextBox rtfContent;
private BindingSource sourceMessages;
private DataGridViewTextBoxColumn timeDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn To;
private ToolStripLabel toolStripLabel1;
private ToolStripSeparator toolStripSeparator1;
private TreeView treeNavigate;
private ToolStripButton tsSearch;
private ToolStripTextBox tsSearchContent;
private XSplitContainer xSplitContainer1;
private XSplitContainer xSplitContainer2;
public MessageHistoryForm(IFrameworkWindow framework) : this(framework, null)
{
}
public MessageHistoryForm(IFrameworkWindow framework, Imps.Client.Core.Contact contact)
{
this.InitializeComponent();
this._framework = framework;
this._contact = contact;
Imps.Client.Core.Contact contact1 = this._contact;
this.lblMessageInfo.UseMnemonic = false;
this._rtfManager = new ChatEditCtrlManager(this.rtfContent, true);
this._rtfManager.LinkClick += new ChatEditClickEventHandler(this._rtfManager_LinkClick);
this._rtfManager.ConvertSympol = true;
this.lblNavigatePageInfo.Text = "";
}
private int _rtfManager_LinkClick(object sender, ChatEditClickEventArgs e)
{
if (e.EventType == ChatEditEventType.Link)
{
try
{
string text = e.Text;
TreeNode selectedNode = this.treeNavigate.SelectedNode;
if (((selectedNode != null) && (selectedNode.Tag is Imps.Client.Core.Contact)) && ConversationManagerImp.IsShareContentUrl(this.CurrentUser, (selectedNode.Tag as Imps.Client.Core.Contact).Uri.Raw, text))
{
text = text + "&c=" + HttpWebRequestHelper.UrlEncode(this.CurrentUser.SsiCredential);
}
ConversationManagerImp.ExecuteFile(this, text);
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
return 1;
}
private void BindContacts(List<Imps.Client.Core.Contact> listContacts, TreeNode parent)
{
try
{
foreach (Imps.Client.Core.Contact contact in listContacts)
{
TreeNode node = new TreeNode(contact.DisplayName);
node.Tag = contact;
parent.Nodes.Add(node);
if (contact == this._contact)
{
node.Parent.Expand();
this.treeNavigate.SelectedNode = node;
node.Checked = true;
if (parent.Parent != null)
{
node.Parent.ImageKey = "OpenfolderHS";
node.Parent.SelectedImageKey = "OpenfolderHS";
}
}
this.imageList.Images.Add(contact.Uri.Raw, contact.PersonalInfo.Portrait);
node.ImageKey = contact.Uri.Raw;
node.SelectedImageKey = contact.Uri.Raw;
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void BindGridView(List<Imps.Client.Core.Contact> contacts)
{
try
{
if (contacts.Count != 0)
{
this.lblMessageInfo.Text = "";
this.rtfContent.Text = "";
MessageList messages = new MessageList(this._framework);
messages.InitMessageHistoryList(contacts, this._isSearch ? this.tsSearchContent.Text.Trim() : string.Empty);
messages.DataSourceInit += new EventHandler(this.messages_DataSourceInit);
this.FormatNavigateInfo(messages);
this.sourceMessages.DataSource = messages.DataSource;
this.gdHistory.Tag = messages;
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void BindGridView(Imps.Client.Core.Contact contact)
{
List<Imps.Client.Core.Contact> contacts = new List<Imps.Client.Core.Contact>();
contacts.Add(contact);
this.BindGridView(contacts);
}
private void BindGroups(TreeNode parent)
{
try
{
this.treeNavigate.SuspendLayout();
this.treeNavigate.BeginUpdate();
lock (this.CurrentUser.ContactList.Groups.SyncRoot)
{
foreach (Imps.Client.Core.ContactGroup group in this.CurrentUser.ContactList.Groups)
{
TreeNode node = new TreeNode(group.Name);
node.Tag = group;
parent.Nodes.Add(node);
node.ImageKey = "NewFolderHS";
node.SelectedImageKey = "NewFolderHS";
this.BindContacts(group.Contacts.ListContacts, node);
}
}
List<Imps.Client.Core.Contact> listContacts = new List<Imps.Client.Core.Contact>();
foreach (Imps.Client.Core.Contact contact in this.CurrentUser.ContactList.Contacts)
{
if (contact.BelongToGroups.Count == 0)
{
listContacts.Add(contact);
}
}
if (listContacts.Count != 0)
{
this.BindContacts(listContacts, parent);
}
this.treeNavigate.EndUpdate();
this.treeNavigate.ResumeLayout();
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
{
this.DeleteSelectedItems();
}
private void bindingNavigatorMoveFirstItem_Click(object sender, EventArgs e)
{
(this.gdHistory.Tag as MessageList).CurrentPage = 1;
}
private void bindingNavigatorMoveLastItem_Click(object sender, EventArgs e)
{
MessageList tag = this.gdHistory.Tag as MessageList;
tag.CurrentPage = tag.PageCount;
}
private void bindingNavigatorMoveNextItem_Click(object sender, EventArgs e)
{
MessageList tag = this.gdHistory.Tag as MessageList;
tag.CurrentPage++;
}
private void bindingNavigatorMovePreviousItem_Click(object sender, EventArgs e)
{
MessageList tag = this.gdHistory.Tag as MessageList;
tag.CurrentPage--;
}
private void btnDeleteAll_Click(object sender, EventArgs e)
{
TreeNode selectedNode = this.treeNavigate.SelectedNode;
if (selectedNode != null)
{
if (selectedNode.Tag is Imps.Client.Core.Contact)
{
this.DeleteContactAllHistory(selectedNode.Tag as Imps.Client.Core.Contact);
}
else if (selectedNode.Tag is Imps.Client.Core.ContactGroup)
{
this.DeleteGroupsAllContactsHistory(selectedNode.Tag as Imps.Client.Core.ContactGroup);
}
else if (this.treeNavigate.SelectedNode == this.treeNavigate.Nodes[1])
{
this.DeleteAllContacstHistory();
}
}
}
private void btnRefresh_Click(object sender, EventArgs e)
{
TreeNode selectedNode = this.treeNavigate.SelectedNode;
if ((selectedNode != null) && (selectedNode.Tag is Imps.Client.Core.Contact))
{
this.BindGridView(selectedNode.Tag as Imps.Client.Core.Contact);
}
}
private void CurrentUser_StatusChanged(object sender, UserSatusChangedEventArgs e)
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -