📄 conversationwindow.cs
字号:
namespace Imps.Client.Pc
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.BizControls.Conversation;
using Imps.Client.Resource;
using Imps.Client.Utils;
using Imps.Common;
using Imps.Utils;
using Imps.Utils.TagParser;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Windows.Forms;
public class ConversationWindow : XConversationForm
{
private bool _activated;
private buddylist_drawer<string> _buddy_list_drawer;
private Imps.Client.Core.Conversation _curConversation;
private int _decimalCount;
private Size _defaultEmotionSize;
private Dictionary<OleKey, OleKey> _dicLinkButtonSaveHistory;
private Dictionary<OleKey, ShareContent> _dicLinkButtonShareContent;
private Dictionary<OleKey, ShareContent> _dicShareContent;
private IFrameworkWindow _frameworkWnd;
private List<Imps.Client.Core.Contact> _hasEventContacts;
private ChatEditCtrlManager _historyChatManager;
private ChatEditCtrlManager _inputChatManager;
private bool _isSendMessage;
private listbox_widget_t<buddylistbox_item<string>> _lstContacts;
private ConversationManagerImp _manager;
private Size _messageEmotionSize;
private string _moibleNo;
private string _myUri;
private AsyncBizOperation _op;
private int _richIdentity;
private Image _separate;
private AsyncBizOperation _smsOperation;
private object _syncObjTempImageFile;
private string _uri;
private SendMessageButton btnSend;
private IContainer components;
private ToolTip contactToolTip;
private CollapseExpandButton controlButton;
private DisplayEmoticons de;
private FontDialog fontDialog;
private bool isExpanded;
private HtmlLabel lblSMSSendInfo;
private XConversationTip lblTooltip;
private MenuStrip mainMenu;
private menu_widget mainMenuHelp;
private menu_widget mainMenuOperate;
private menu_widget mainMenuTools;
private menu_widget menuBlockUsers;
private menu_widget menuHistoryChat;
private menu_widget menuInputChat;
private menu_widget menuSendFile;
private ToolStripMenuItem menuSendFileDirect;
private ToolStripMenuItem menuSendFileToMobile;
private menu_widget menuSendType;
private ToolStripMenuItem miEdit;
private ToolStripMenuItem miHelp;
private ToolStripMenuItem miOperate;
private ToolStripMenuItem miTools;
private ToolTip myToolTip;
private OpenFileDialog openFileDialog;
private Panel panel1;
private ContactInfoControl picContact;
private DisplayPortrait picOwner;
private Panel pnlForWhiteBackground;
private Panel pnlRight;
private int pnlRightWidth;
private BPanel pnlTop;
private ChatRichTextBox rtfHistory;
private ChatRichTextBox rtfInput;
private SaveFileDialog saveFileDialog;
private const string SaveHistoryAgree = "SaveHistoryAgree";
private const string SaveHistoryRefuse = "SaveHistoryRefuse";
private IMSplitContainer scMain;
private int splitContainerPadding;
private string tipInfo;
private ToolStripMenuItem toolStripMenuItem1;
private ToolStripSeparator toolStripSeparator1;
private ToolStripSeparator toolStripSeparator10;
private ToolStripSeparator toolStripSeparator2;
private ToolStripSeparator toolStripSeparator3;
private ToolStripSeparator toolStripSeparator4;
private ToolStripSeparator toolStripSeparator5;
private ToolStripSeparator toolStripSeparator6;
private ToolStripSeparator toolStripSeparator7;
private ToolStripSeparator toolStripSeparator8;
private ToolStripSeparator toolStripSeparator9;
private ToolStripButton tsbEmoticons;
private ToolStripDropDownButton tsBlock;
private ToolStripButton tsFont;
private ToolStripDropDownButton tsHistory;
private ToolStripMenuItem tsHistoryChatCopy;
private ToolStripMenuItem tsHistoryChatSelectAll;
private ToolStripMenuItem tsInputChangeFont;
private ToolStripMenuItem tsInputChatCopy;
private ToolStripMenuItem tsInputChatCut;
private ToolStripMenuItem tsInputChatDelete;
private ToolStripMenuItem tsInputChatPaste;
private ToolStripMenuItem tsInputChatSelectALl;
private ToolStripMenuItem tsInputChatUndo;
private ToolStripButton tsInvite;
private ToolStripButton tsIVR;
private IMToolstrip tsMain;
private ToolStripMenuItem tsMainHelpAbout;
private ToolStripMenuItem tsMainHelpTopic;
private ToolStripMenuItem tsOperationBlock;
private ToolStripMenuItem tsOperationClose;
private ToolStripMenuItem tsOperationContactInfo;
private ToolStripMenuItem tsOperationInvite;
private ToolStripMenuItem tsOperationIVR;
private ToolStripMenuItem tsOperationMessageHistory;
private ToolStripMenuItem tsOperationSendFile;
private menu_radioitem tsOperationSendMessage;
private menu_radioitem tsOperationSendSMS;
private ToolStripMenuItem tsSendCtrlEnter;
private ToolStripMenuItem tsSendEnter;
private ToolStripSplitButton tsSendFile;
private IMToolstrip tsSendMessage;
private ToolStripButton tsSendSMS;
private ToolStripButton tsStopHistory;
private ToolStripMenuItem tsToolsFront;
private ToolStripMenuItem tsToolsOptions;
private Rectangle workAreaRectangle;
public ConversationWindow(ConversationManagerImp manager, Imps.Client.Core.Conversation conv)
{
DragEventHandler handler = null;
DragEventHandler handler2 = null;
this._richIdentity = 12;
this._separate = ImpsResources.GetImage("Images.line.png");
this.contactToolTip = new ToolTip();
this.myToolTip = new ToolTip();
this._messageEmotionSize = Size.Empty;
this._defaultEmotionSize = Size.Empty;
this.isExpanded = true;
this.pnlRightWidth = 0x76;
this.InitializeComponent();
this._manager = manager;
this._frameworkWnd = manager.FrameworkWnd;
this._op = new AsyncBizOperation();
this._dicShareContent = new Dictionary<OleKey, ShareContent>();
this._dicLinkButtonShareContent = new Dictionary<OleKey, ShareContent>();
this._curConversation = conv;
this._hasEventContacts = new List<Imps.Client.Core.Contact>();
this._myUri = this.CurrentUser.Uri.Raw;
this.InitChatControl();
this.InitEnableChangeEvent();
this.picContact.AllowDrop = true;
if (handler == null)
{
handler = delegate (object sender, DragEventArgs e) {
this.DoContactDragEnter(e);
};
}
this.picContact.DragEnter += handler;
if (handler2 == null)
{
handler2 = delegate (object sender, DragEventArgs e) {
this.DoContactDragDrop(e);
};
}
this.picContact.DragDrop += handler2;
this.miEdit.DropDown = this.menuInputChat;
this.controlButton.ToolTipText = "显示/隐藏参与者";
this.btnSend.Disabled = true;
this.btnSend.ToolTipText = StringTable.Conversation.MsgSendMessageTip;
base.StatusBarBox = true;
this.miTools.Visible = false;
this.lblTooltip.LinkButtonClick += new ChatEditClickEventHandler(this.lblTooltip_LinkButtonClick);
base.initComponentRegion();
this.lblSMSSendInfo.ShowBackgroundImage = true;
this.lblSMSSendInfo.Visible = false;
}
private void _curConversation_Closed(object sender, EventArgs e)
{
if ((sender as Imps.Client.Core.Conversation) == this._curConversation)
{
try
{
this._curConversation.AddDialog -= new EventHandler<DialogEventArgs>(this.Dialogs_AddDialog);
this._curConversation.Closed -= new EventHandler(this._curConversation_Closed);
this._curConversation = null;
}
catch (Exception exception)
{
this.HandleException(exception);
}
}
}
private int _historyChatManager_BeforeContextMenuShow(object sender, ChatEditEventArgs e)
{
try
{
this._historyChatManager.Focus();
this.tsHistoryChatSelectAll.Enabled = this.rtfHistory.Text != "";
this.tsHistoryChatCopy.Enabled = this._historyChatManager.CanCopy;
}
catch (Exception exception)
{
this.HandleException(exception);
}
return 1;
}
private int _historyChatManager_DoubleClick(object sender, ChatEditClickEventArgs e)
{
try
{
if (e.EventType == ChatEditEventType.PROGRESSBAR)
{
this.ProgressbarDoubleClick(e.Key);
}
}
catch (Exception exception)
{
this.HandleException(exception);
}
return 1;
}
private int _historyChatManager_DragDrop(object sender, ChatEditDropEventArgs e)
{
if ((e.EventType == ChatEditDropType.Contact) && (e.Contact != null))
{
this.TryAddContact(e.Contact);
}
return 1;
}
private int _inputChatManager_BeforeContextMenuShow(object sender, ChatEditEventArgs e)
{
if (this.rtfInput.RectangleToScreen(this.rtfInput.ClientRectangle).Contains(Control.MousePosition))
{
this._inputChatManager.Focus();
this.FormtEditMenu();
}
return 1;
}
private int _inputChatManager_DoubleClick(object sender, ChatEditClickEventArgs e)
{
try
{
if (e.EventType == ChatEditEventType.PROGRESSBAR)
{
this.ProgressbarDoubleClick(e.Key);
}
}
catch (Exception exception)
{
this.HandleException(exception);
}
return 1;
}
private int _inputChatManager_DragDrop(object sender, ChatEditDropEventArgs e)
{
try
{
if (e.EventType == ChatEditDropType.FILE)
{
if (this.tsSendFile.Enabled)
{
foreach (string str in e.Files)
{
this.SendFile(str);
}
}
}
else if (e.EventType == ChatEditDropType.Contact)
{
this.TryAddContact(e.Contact);
}
base.Activate();
}
catch (Exception exception)
{
this.HandleException(exception);
}
return 1;
}
private void _inputChatManager_KeyDown(object sender, KeyEventArgs e)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -