⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pshistroycontrol.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace Imps.Client.Pc.Options
{
    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 btnViewHistory;
        private CheckBox chkKeepOldDir;
        private CheckBox chkRecentHistory;
        private CheckBox chkSaveHistory;
        private IContainer components;
        private FolderBrowserDialog fbMsgHistoryDir;
        private XLabel lbMsgHistory;
        private XLabel lbMsgHistoryDirTip;
        private XLabel lbQuestion;
        private XLabel lbTip;
        private XTextBox txtDir;
        private XButton xbtnBrowse;

        public PsHistroyControl(IFrameworkWindow iFrameworkWindow)
        {
            this._frameworkWindow = iFrameworkWindow;
            this.InitializeComponent();
            this.InitUiEventHandler();
            this.chkSaveHistory.CheckedChanged += new EventHandler(this.chkSaveHistory_CheckedChanged);
        }

        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 btnViewHistory_Click(object sender, EventArgs e)
        {
            UiErrorHelper.HandEventSafely(this._frameworkWindow, delegate {
                this._frameworkWindow.MessageHistoryManager.ShowMessageHistory(this._frameworkWindow as Form);
            });
        }

        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)
                        {
                            foreach (KeyValuePair<string, string> pair in dictionary)
                            {
                                try
                                {
                                    File.Move(pair.Value, pair.Key);
                                    continue;
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                        }
                        ClientLogger.WriteException(exception2);
                    }
                }
            }
        }

        private void chkSaveHistory_CheckedChanged(object sender, EventArgs e)
        {
            base.Modified = true;
            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 InitializeComponent()
        {
            this.lbMsgHistory = new XLabel();
            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();
            XLabel label = new XLabel();
            base.SuspendLayout();
            label.AutoEllipsis = false;
            label.BorderColor = Color.Black;
            label.BorderStyle = BorderStyle.Fixed3D;
            label.ButtonBorderStyle = ButtonBorderStyle.Solid;
            label.Location = new Point(0x70, 15);
            label.Name = "lbLine";
            label.Size = new Size(280, 2);
            label.TabIndex = 1;
            label.TextAlign = ContentAlignment.TopLeft;
            label.UseMnemonic = false;
            this.lbMsgHistory.AutoEllipsis = false;
            this.lbMsgHistory.AutoSize = true;
            this.lbMsgHistory.BorderColor = Color.Black;
            this.lbMsgHistory.BorderStyle = BorderStyle.None;
            this.lbMsgHistory.ButtonBorderStyle = ButtonBorderStyle.Solid;
            this.lbMsgHistory.Location = new Point(5, 9);
            this.lbMsgHistory.Name = "lbMsgHistory";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -