📄 pshistroycontrol.cs
字号:
namespace Imps.Client.Pc.Options
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc;
using Imps.Client.Pc.Controls;
using Imps.Client.Resource;
using Imps.Client.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
public class PsHistroyControl : OptionsControlBase
{
private IFrameworkWindow _frameworkWindow;
private XButton btnClearHistory;
private XButton btnModify;
private XButton btnViewHistory;
private CheckBox chkKeepOldDir;
private CheckBox chkRecentHistory;
private CheckBox chkSaveHistory;
private IContainer components;
private FolderBrowserDialog fbMsgHistoryDir;
private FolderBrowserDialog folderBrowserDialogPath;
private GroupBox groupBox1;
private GroupBox groupBox2;
private GroupBox groupBox3;
private Label label1;
private XLabel lbMessage;
private XLabel lbMsgHistoryDirTip;
private XLabel lbQuestion;
private XLabel lbTip;
private RadioButton rbLong;
private RadioButton rbNormal;
private XTextBox txtDir;
private XButton xbtnBrowse;
private XTextBox xtbPath;
public PsHistroyControl(IFrameworkWindow iFrameworkWindow)
{
this._frameworkWindow = iFrameworkWindow;
this.InitializeComponent();
this.InitUiEventHandler();
this.chkSaveHistory.CheckedChanged += new EventHandler(this.chkSaveHistory_CheckedChanged);
this.lbMessage.Text = "如果对方手机不支持长短信功能:\r\n1、发送内容有可能仍被拆分成多条短信\r\n2、接收短信中可能出现乱码\r\n3、少数接收方可能无法收到该条短信";
}
private void btnClearHistory_Click(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWindow, delegate {
if (this._frameworkWindow.MessageHistoryManager.ClearMessageHistory(base.FindForm()))
{
this._frameworkWindow.UnifiedMessageBox.ShowInfo(this, StringTable.MessageHistory.MsgClearSuccessfully);
}
});
}
private void btnModify_Click(object sender, EventArgs e)
{
this.folderBrowserDialogPath.RootFolder = Environment.SpecialFolder.Desktop;
string defaultShareContentSavePath = this._user.Configuration.UserSetting.ConversationSetting.DefaultShareContentSavePath;
if ((defaultShareContentSavePath != null) && (defaultShareContentSavePath.Length != 0))
{
this.folderBrowserDialogPath.SelectedPath = this._user.Configuration.UserSetting.ConversationSetting.DefaultShareContentSavePath;
}
else
{
this.folderBrowserDialogPath.SelectedPath = Environment.SpecialFolder.Personal.ToString();
}
this.folderBrowserDialogPath.Description = StringTable.FileShare.lbFileShareCfgTip;
if (this.folderBrowserDialogPath.ShowDialog() == DialogResult.OK)
{
string path = this.folderBrowserDialogPath.SelectedPath;
if (Directory.Exists(path))
{
this.xtbPath.Text = path;
}
}
}
private void btnViewHistory_Click(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWindow, delegate {
this._frameworkWindow.MessageHistoryManager.ShowMessageHistory(this._frameworkWindow.MainWindow);
});
}
private void c_Click(object sender, EventArgs e)
{
base.Modified = true;
}
private void ChangeMsgHistoryDir(string oldPath, string newPath, bool keepOldDir)
{
lock (ConversationManager.MessageSyncObject)
{
if (Directory.Exists(newPath))
{
Dictionary<string, string> dictionary = null;
try
{
if (Directory.Exists(oldPath))
{
if (newPath[newPath.Length - 1] != '\\')
{
newPath = newPath + '\\';
}
string[] files = Directory.GetFiles(oldPath, "*.xml");
for (int i = 0; i < files.Length; i++)
{
string fileName = Path.GetFileName(files[i]);
string destFileName = newPath + fileName;
try
{
if (keepOldDir)
{
File.Copy(files[i], destFileName, true);
}
else
{
if (File.Exists(destFileName))
{
File.Delete(destFileName);
}
File.Move(files[i], destFileName);
if (dictionary == null)
{
dictionary = new Dictionary<string, string>(files.Length);
}
dictionary.Add(files[i], destFileName);
}
}
catch (Exception exception)
{
ClientLogger.WriteBizOperation("修改消息历史保存目录", exception.ToString(), 10);
}
}
}
this._frameworkWindow.PersistentManager.BaseDirForHistory = newPath;
this._user.Configuration.UserSetting.ConversationSetting.DefaultMsgHistoryDir = newPath;
}
catch (Exception exception2)
{
if (dictionary != null)
{
Dictionary<string, string>.Enumerator enumerator = dictionary.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
KeyValuePair<string, string> pair = enumerator.get_Current();
try
{
File.Move(pair.get_Value(), pair.get_Key());
continue;
}
catch
{
continue;
}
}
}
finally
{
enumerator.Dispose();
}
}
ClientLogger.WriteException(exception2);
}
}
}
}
private void chkSaveHistory_CheckedChanged(object sender, EventArgs e)
{
if (this.chkRecentHistory.Checked && !this.chkSaveHistory.Checked)
{
this.chkRecentHistory.Checked = false;
}
this.chkRecentHistory.Enabled = this.chkSaveHistory.Checked;
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void groupBox2_Enter(object sender, EventArgs e)
{
}
private void InitializeComponent()
{
ComponentResourceManager manager = new ComponentResourceManager(typeof(PsHistroyControl));
this.lbQuestion = new XLabel();
this.chkSaveHistory = new CheckBox();
this.chkRecentHistory = new CheckBox();
this.btnViewHistory = new XButton();
this.btnClearHistory = new XButton();
this.txtDir = new XTextBox();
this.lbMsgHistoryDirTip = new XLabel();
this.xbtnBrowse = new XButton();
this.fbMsgHistoryDir = new FolderBrowserDialog();
this.chkKeepOldDir = new CheckBox();
this.lbTip = new XLabel();
this.groupBox1 = new GroupBox();
this.folderBrowserDialogPath = new FolderBrowserDialog();
this.xtbPath = new XTextBox();
this.btnModify = new XButton();
this.groupBox2 = new GroupBox();
this.label1 = new Label();
this.lbMessage = new XLabel();
this.rbLong = new RadioButton();
this.rbNormal = new RadioButton();
this.groupBox3 = new GroupBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
base.SuspendLayout();
this.lbQuestion.set_AutoSize(true);
this.lbQuestion.BorderColor = Color.Empty;
this.lbQuestion.ButtonBorderStyle = ButtonBorderStyle.None;
this.lbQuestion.Location = new System.Drawing.Point(0x13, 0x17);
this.lbQuestion.Name = "lbQuestion";
this.lbQuestion.Size = new Size(0xa1, 12);
this.lbQuestion.TabIndex = 2;
this.lbQuestion.Text = "您是否希望保存收发的信息?";
this.lbQuestion.UseMnemonic = false;
this.chkSaveHistory.set_AutoSize(true);
this.chkSaveHistory.Location = new System.Drawing.Point(0x15, 0x2d);
this.chkSaveHistory.Name = "chkSaveHistory";
this.chkSaveHistory.Size = new Size(0x90, 0x10);
this.chkSaveHistory.TabIndex = 0;
this.chkSaveHistory.Text = "保存所有消息历史";
this.chkSaveHistory.set_UseVisualStyleBackColor(true);
this.chkRecentHistory.set_AutoSize(true);
this.chkRecentHistory.Location = new System.Drawing.Point(0x15, 0x43);
this.chkRecentHistory.Name = "chkRecentHistory";
this.chkRecentHistory.Size = new Size(180, 0x10);
this.chkRecentHistory.TabIndex = 1;
this.chkRecentHistory.Text = "会话窗口显示最近的消息历史";
this.chkRecentHistory.set_UseVisualStyleBackColor(true);
this.btnViewHistory.AutoSizeToImage = false;
this.btnViewHistory.BackColor = Color.Transparent;
this.btnViewHistory.BackgroundImageDisable = null;
this.btnViewHistory.BackgroundImageDown = null;
this.btnViewHistory.BackgroundImageHover = null;
this.btnViewHistory.ChangeSkin = true;
this.btnViewHistory.Location = new System.Drawing.Point(0x15, 0x5f);
this.btnViewHistory.Name = "btnViewHistory";
this.btnViewHistory.Size = new Size(0x8a, 0x17);
this.btnViewHistory.TabIndex = 5;
this.btnViewHistory.set_UseVisualStyleBackColor(false);
this.btnViewHistory.Visible = false;
this.btnViewHistory.Click += new EventHandler(this.btnViewHistory_Click);
this.btnClearHistory.AutoSizeToImage = false;
this.btnClearHistory.BackColor = Color.Transparent;
this.btnClearHistory.BackgroundImage = (Image) manager.GetObject("btnClearHistory.BackgroundImage");
this.btnClearHistory.BackgroundImageDisable = (Image) manager.GetObject("btnClearHistory.BackgroundImageDisable");
this.btnClearHistory.BackgroundImageDown = (Image) manager.GetObject("btnClearHistory.BackgroundImageDown");
this.btnClearHistory.BackgroundImageHover = (Image) manager.GetObject("btnClearHistory.BackgroundImageHover");
this.btnClearHistory.ChangeSkin = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -