📄 deletehistoryform.cs
字号:
namespace Imps.Client.Pc.MessageHistory2
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class DeleteHistoryForm : XIMDialog
{
private IFrameworkWindow _framework;
private Player _selectPlayer;
private XButton btnCancel;
private XButton btnOK;
private bool canClose;
private bool canDelete;
private IContainer components;
private bool hasDelete;
private XLabel lMessage;
private Panel panel1;
private PictureBox pbDelete;
private ProgressBar prgDelete;
public DeleteHistoryForm(IFrameworkWindow framework, Player selectPlayer)
{
this._selectPlayer = selectPlayer;
this._framework = framework;
this.InitializeComponent();
this.canDelete = true;
this.hasDelete = false;
this.canClose = true;
this.prgDelete.Visible = false;
this.pbDelete.Image = ImpsResources.GetImage("Icons.info_64.png");
switch (selectPlayer.Type)
{
case PlayerType.Contact:
this.lMessage.Text = string.Format("您是否要删除{0} 的所有聊天历史?", selectPlayer.Name);
break;
case PlayerType.User:
this.lMessage.Text = "您是否要删除您发给自己的聊天历史?";
break;
case PlayerType.Group:
this.lMessage.Text = string.Format("您是否要删除{0} 群的所有聊天历史?", selectPlayer.Name);
break;
case PlayerType.System:
this.lMessage.Text = "删除聊天历史错误!您无法删除系统消息!";
this.canDelete = false;
return;
}
if (this.canDelete)
{
this._framework.MessageHistoryManager.HistoryDeleted += new EventHandler(this.MessageHistoryManager_HistoryDeleted);
}
else
{
this.btnOK.Enabled = false;
}
}
private void btnOK_Click(object sender, EventArgs e)
{
if (!this.hasDelete && this.canDelete)
{
this.canClose = false;
this.lMessage.Text = "正在删除聊天历史...";
this.btnOK.Enabled = false;
this.btnCancel.Enabled = false;
this.prgDelete.Visible = true;
this._framework.MessageHistoryManager.DeleteMessageHistory(new string[] { this._selectPlayer.Uri });
}
else
{
this.canClose = true;
base.Close();
}
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.btnOK = new XButton();
this.btnCancel = new XButton();
this.panel1 = new Panel();
this.prgDelete = new ProgressBar();
this.lMessage = new XLabel();
this.pbDelete = new PictureBox();
this.panel1.SuspendLayout();
this.pbDelete.BeginInit();
base.SuspendLayout();
this.btnOK.AutoArrangementX = true;
this.btnOK.AutoSizeToImage = false;
this.btnOK.BackColor = Color.Transparent;
this.btnOK.BackgroundImageDisable = null;
this.btnOK.BackgroundImageDown = null;
this.btnOK.BackgroundImageHover = null;
this.btnOK.ChangeSkin = true;
this.btnOK.Location = new System.Drawing.Point(0x6d, 0x86);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new Size(0x4b, 0x19);
this.btnOK.TabIndex = 0;
this.btnOK.Text = "确定";
this.btnOK.set_UseVisualStyleBackColor(false);
this.btnOK.Click += new EventHandler(this.btnOK_Click);
this.btnCancel.AutoArrangementX = true;
this.btnCancel.AutoSizeToImage = false;
this.btnCancel.BackColor = Color.Transparent;
this.btnCancel.BackgroundImageDisable = null;
this.btnCancel.BackgroundImageDown = null;
this.btnCancel.BackgroundImageHover = null;
this.btnCancel.ChangeSkin = true;
this.btnCancel.DialogResult = DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(190, 0x86);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new Size(0x4b, 0x19);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "取消";
this.btnCancel.set_UseVisualStyleBackColor(false);
this.panel1.BackColor = Color.Transparent;
this.panel1.Controls.Add(this.prgDelete);
this.panel1.Controls.Add(this.lMessage);
this.panel1.Controls.Add(this.pbDelete);
this.panel1.Location = new System.Drawing.Point(12, 3);
this.panel1.Name = "panel1";
this.panel1.Size = new Size(0x10d, 0x60);
this.panel1.TabIndex = 2;
this.prgDelete.Location = new System.Drawing.Point(3, 0x4e);
this.prgDelete.Name = "prgDelete";
this.prgDelete.Size = new Size(0x105, 14);
this.prgDelete.set_Style(2);
this.prgDelete.TabIndex = 2;
this.lMessage.BorderColor = Color.Empty;
this.lMessage.ButtonBorderStyle = ButtonBorderStyle.None;
this.lMessage.Location = new System.Drawing.Point(0x49, 7);
this.lMessage.Name = "lMessage";
this.lMessage.Size = new Size(0xbf, 0x42);
this.lMessage.TabIndex = 1;
this.lMessage.TextAlign = ContentAlignment.MiddleLeft;
this.pbDelete.Location = new System.Drawing.Point(3, 3);
this.pbDelete.Name = "pbDelete";
this.pbDelete.Size = new Size(0x40, 0x45);
this.pbDelete.TabIndex = 0;
this.pbDelete.TabStop = false;
base.AcceptButton = this.btnOK;
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.BaseHeight = 0x10d;
base.BaseWidth = 0x151;
base.CancelButton = this.btnCancel;
base.ClientSize = new Size(0x151, 0x10d);
base.Controls.Add(this.panel1);
base.Controls.Add(this.btnCancel);
base.Controls.Add(this.btnOK);
base.Controls.SetChildIndex(this.panel1, 0);
base.DisplayLocation = new System.Drawing.Point(15, 15);
base.DisplaySize = new Size(0x151, 0x10d);
base.Name = "DeleteHistoryForm";
base.set_Padding(new Padding(4, 0, 4, 0x2f));
base.StartPosition = FormStartPosition.CenterParent;
base.Text = "Fetion 2008";
this.panel1.ResumeLayout(false);
this.pbDelete.EndInit();
base.ResumeLayout(false);
}
private void MessageHistoryManager_HistoryDeleted(object sender, EventArgs e)
{
this.btnOK.Enabled = true;
this.canClose = true;
this.btnCancel.Enabled = true;
this.prgDelete.Visible = false;
this.btnCancel.Visible = false;
switch (this._selectPlayer.Type)
{
case PlayerType.Contact:
this.lMessage.Text = string.Format("已经成功删除{0} 的所有聊天历史。", this._selectPlayer.Name);
break;
case PlayerType.User:
this.lMessage.Text = "已经成功删除您发给自己的聊天历史。";
break;
case PlayerType.Group:
this.lMessage.Text = string.Format("已经成功删除{0} 群的所有聊天历史", this._selectPlayer.Name);
break;
case PlayerType.System:
this.lMessage.Text = "删除聊天历史错误!您无法删除系统消息!";
this.canDelete = false;
return;
}
this.hasDelete = true;
}
protected override void OnClosed(EventArgs e)
{
this._framework.MessageHistoryManager.HistoryDeleted -= new EventHandler(this.MessageHistoryManager_HistoryDeleted);
base.OnClosed(e);
}
protected override void OnClosing(CancelEventArgs e)
{
if (this.canClose)
{
base.OnClosing(e);
}
else
{
e.Cancel = true;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -