?? messagehistoryform.cs
字號:
if ((e.NewStatus == UserAccountStatus.Logoff) || (e.NewStatus == UserAccountStatus.Disconnected))
{
base.Close();
}
}
private void DeleteAllContacstHistory()
{
try
{
if (this._framework.MessageHistoryManager.ClearMessageHistory(this))
{
this.lblMessageInfo.Text = "";
this.rtfContent.Text = "";
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void DeleteContactAllHistory(Imps.Client.Core.Contact contact)
{
try
{
if (this._framework.UnifiedMessageBox.ShowConfirmation(this, string.Format(StringTable.Conversation.MsgConfirmDeleteContact, contact.DisplayName)) == DialogResult.Yes)
{
this._framework.MessageHistoryManager.AsyncDeleteMessageHistory(new string[] { contact.Uri.Raw });
this.BindGridView(contact);
this.lblMessageInfo.Text = "";
this.rtfContent.Text = "";
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void DeleteGroupsAllContactsHistory(Imps.Client.Core.ContactGroup group)
{
try
{
if (this._framework.UnifiedMessageBox.ShowConfirmation(this, string.Format(StringTable.Conversation.MsgConfirmDeleteGroup, group.Name)) == DialogResult.Yes)
{
string[] contactUris = new string[group.Contacts.Count];
int index = 0;
foreach (Imps.Client.Core.Contact contact in group.Contacts)
{
contactUris[index] = contact.Uri.Raw;
index++;
}
this._framework.MessageHistoryManager.AsyncDeleteMessageHistory(contactUris);
this.lblMessageInfo.Text = "";
this.rtfContent.Text = "";
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void DeleteSelectedItems()
{
try
{
if ((this.gdHistory.SelectedRows.Count != 0) && (this._framework.UnifiedMessageBox.ShowConfirmation(this, StringTable.Conversation.MsgConfirmDelete) == DialogResult.Yes))
{
this.lblMessageInfo.Text = "";
this.rtfContent.Text = "";
MessageList tag = this.gdHistory.Tag as MessageList;
Dictionary<Imps.Client.Core.Contact, List<string>> dictionary = new Dictionary<Imps.Client.Core.Contact, List<string>>();
foreach (DataGridViewRow row in this.gdHistory.SelectedRows)
{
Imps.Client.Pc.Message dataBoundItem = row.DataBoundItem as Imps.Client.Pc.Message;
if (!dictionary.ContainsKey(dataBoundItem.OwnerContact))
{
List<string> list2 = new List<string>();
dictionary.Add(dataBoundItem.OwnerContact, list2);
}
dictionary[dataBoundItem.OwnerContact].Add(dataBoundItem.MessageId);
}
foreach (Imps.Client.Core.Contact contact in dictionary.Keys)
{
tag.DeleteMessages(contact, dictionary[contact]);
}
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void dgMenu_Opening(object sender, CancelEventArgs e)
{
this.gdHistory.Focus();
this.dgMenuCopy.Enabled = this.gdHistory.SelectedRows.Count > 0;
this.dgMenuDelete.Enabled = this.gdHistory.SelectedRows.Count > 0;
this.dgMenuSelectAll.Enabled = this.gdHistory.Rows.Count > 0;
}
private void dgMenuCopy_Click(object sender, EventArgs e)
{
this.DoCopy();
}
private void dgMenuDelete_Click(object sender, EventArgs e)
{
this.DeleteSelectedItems();
}
private void dgMenuSelectAll_Click(object sender, EventArgs e)
{
this.gdHistory.Focus();
SendKeys.Send("^a");
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void DoCopy()
{
DataObject clipboardContent = this.gdHistory.GetClipboardContent();
DataObject data = new DataObject();
data.SetText(clipboardContent.GetText(TextDataFormat.Text), TextDataFormat.Text);
data.SetText(clipboardContent.GetText(TextDataFormat.UnicodeText), TextDataFormat.UnicodeText);
data.SetText(clipboardContent.GetText(TextDataFormat.CommaSeparatedValue), TextDataFormat.CommaSeparatedValue);
Clipboard.SetDataObject(data);
}
private void FormatNavigateInfo(MessageList messages)
{
try
{
this.bindingNavigator.SuspendLayout();
this.btnDeleteAll.Enabled = true;
this.bindingNavigatorDeleteItem.Enabled = true;
if ((messages == null) || (messages.Count == 0))
{
this.bindingNavigatorMoveFirstItem.Enabled = false;
this.bindingNavigatorMovePreviousItem.Enabled = false;
this.bindingNavigatorMoveLastItem.Enabled = false;
this.bindingNavigatorMoveNextItem.Enabled = false;
this.bindingNavigatorDeleteItem.Enabled = false;
this.btnDeleteAll.Enabled = false;
}
else if (messages.PageCount == 1)
{
this.bindingNavigatorMoveFirstItem.Enabled = false;
this.bindingNavigatorMovePreviousItem.Enabled = false;
this.bindingNavigatorMoveLastItem.Enabled = false;
this.bindingNavigatorMoveNextItem.Enabled = false;
}
else
{
this.bindingNavigatorMoveFirstItem.Enabled = messages.CurrentPage > 1;
this.bindingNavigatorMovePreviousItem.Enabled = messages.CurrentPage > 1;
this.bindingNavigatorMoveLastItem.Enabled = messages.CurrentPage < messages.PageCount;
this.bindingNavigatorMoveNextItem.Enabled = messages.CurrentPage < messages.PageCount;
}
this.bindingNavigator.ResumeLayout();
this.lblNavigatePageInfo.Text = string.Format(StringTable.Conversation.MsgNavigaePager, messages.CurrentPage, messages.PageCount);
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void gdHistory_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (this.gdHistory.Columns[e.ColumnIndex].Name == this.contentDataGridViewTextBoxColumn.Name)
{
e.Value = Imps.Utils.TagParser.TagParser.Create(e.Value.ToString(), true).Text;
Imps.Client.Pc.Message dataBoundItem = this.gdHistory.Rows[e.RowIndex].DataBoundItem as Imps.Client.Pc.Message;
if (dataBoundItem.FromUri == this.CurrentUser.Uri.Raw)
{
this.gdHistory.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(0xf1, 240, 0xf8);
}
}
}
private void gdHistory_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
this.DeleteSelectedItems();
}
if (e.Control && (e.KeyCode == Keys.C))
{
this.DoCopy();
e.Handled = true;
}
}
private void gdHistory_RowEnter(object sender, DataGridViewCellEventArgs e)
{
try
{
this.rtfContent.Clear();
Imps.Client.Pc.Message dataBoundItem = this.gdHistory.Rows[e.RowIndex].DataBoundItem as Imps.Client.Pc.Message;
string from = dataBoundItem.From;
string to = dataBoundItem.To;
if (from.Length > 20)
{
from = from.Substring(0, 20) + "...";
}
if (to.Length > 50)
{
to = to.Substring(0, 50) + "...";
}
this.lblMessageInfo.Text = string.Format(StringTable.Conversation.MsgMessageInfo, new object[] { dataBoundItem.Date, dataBoundItem.Time, from, to });
Thread.Sleep(50);
this._rtfManager.AppentString(dataBoundItem.Content);
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void InitializeComponent()
{
this.components = new Container();
TreeNode node = new TreeNode("聯系人");
ComponentResourceManager manager = new ComponentResourceManager(typeof(MessageHistoryForm));
this.xSplitContainer1 = new XSplitContainer();
this.treeNavigate = new TreeView();
this.imageList = new ImageList(this.components);
this.xSplitContainer2 = new XSplitContainer();
this.gdHistory = new DataGridView();
this.fromDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
this.dateDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
this.timeDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
this.To = new DataGridViewTextBoxColumn();
this.contentDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
this.dgMenu = new menu_widget(this.components);
this.dgMenuSelectAll = new ToolStripMenuItem();
this.dgMenuCopy = new ToolStripMenuItem();
this.dgMenuDelete = new ToolStripMenuItem();
this.sourceMessages = new BindingSource(this.components);
this.panel2 = new Panel();
this.rtfContent = new ChatRichTextBox();
this.lblMessageInfo = new XLabel();
this.panel1 = new Panel();
this.bindingNavigator = new BindingNavigator(this.components);
this.bindingNavigatorMoveFirstItem = new ToolStripButton();
this.bindingNavigatorSeparator = new ToolStripSeparator();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -