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

📄 importexportmanager.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc
{
    using Imps.Client.Resource;
    using Imps.Client.Utils;
    using Imps.Client.Utils.Win32;
    using System;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Text;

    public class ImportExportManager : IImportExportManager
    {
        private ExportForm _exportFrom;
        private List<ImportExportPlugin> _exportPlugins;
        private IFrameworkWindow _frameworkWin;
        private ImportForm _importForm;
        private List<ImportExportPlugin> _importPlugins;
        public static Encoding FileEncoding = Encoding.Default;

        public ImportExportManager(IFrameworkWindow frameworkWin)
        {
            this._frameworkWin = frameworkWin;
        }

        public void Export()
        {
            if ((this._importForm != null) && !this._importForm.IsDisposed)
            {
                this._importForm.Close();
            }
            if (this._frameworkWin.AccountManager.CurrentUser.ContactList.Contacts.Count == 0)
            {
                this._frameworkWin.UnifiedMessageBox.ShowInfo(this._frameworkWin.MainWindow, "没有联系人可以导出!");
            }
            else if ((this._exportFrom == null) || this._exportFrom.IsDisposed)
            {
                this._exportFrom = new ExportForm(this._frameworkWin, this);
                ControlHelper.ShowFormCenterOnParent(this._exportFrom, this._frameworkWin.MainWindow);
            }
            else
            {
                NativeMethods.ShowWindow(this._exportFrom.Handle, 9);
            }
        }

        public List<ImportExportPlugin> GetExportPlugins()
        {
            if (this._exportPlugins == null)
            {
                this._exportPlugins = new List<ImportExportPlugin>();
                ImportExportPlugin plugin = new ImportExportPlugin();
                plugin.Name = "导出为普通文本文件(.csv)";
                plugin.TypeName = "Imps.Client.Pc.ExportContactsToCVS";
                plugin.Description = "导出为普通文本文件(.csv)";
                this._exportPlugins.Add(plugin);
                plugin = new ImportExportPlugin();
                plugin.Name = string.Format("导出为{0}联系人文件(.fcl)", AppDictionary.ShortEnglishName);
                plugin.TypeName = "Imps.Client.Pc.ExportContactsToXML";
                plugin.Description = string.Format("导出为{0}联系人文件(.fcl)", AppDictionary.ShortEnglishName);
                this._exportPlugins.Add(plugin);
            }
            return this._exportPlugins;
        }

        public List<ImportExportPlugin> GetImportPlugins()
        {
            if (this._importPlugins == null)
            {
                this._importPlugins = new List<ImportExportPlugin>();
                ImportExportPlugin plugin = new ImportExportPlugin();
                plugin.Name = "从CSV文件导入联系人";
                plugin.TypeName = "Imps.Client.Pc.ImportContactsFromCSV";
                plugin.Description = "从包含有联系人信息的CSV文件中获取信息,并向对方发出添加好友的邀请。";
                this._importPlugins.Add(plugin);
                plugin = new ImportExportPlugin();
                plugin.Name = string.Format("从{0}格式文件导入联系人", AppDictionary.ShortEnglishName);
                plugin.TypeName = "Imps.Client.Pc.ImportContactsFromXML";
                plugin.Description = string.Format("从包含有联系人详细信息的{0}格式文件中获取信息,并向对方发出添加好友的邀请。", AppDictionary.ShortEnglishName);
                this._importPlugins.Add(plugin);
                plugin = new ImportExportPlugin();
                plugin.Name = "从Vcard文件导入联系人";
                plugin.TypeName = "Imps.Client.Pc.ImportContactsFromVcard";
                plugin.Description = "从Vcard文件中获取信息,并向对方发出添加好友的邀请。";
                this._importPlugins.Add(plugin);
                plugin = new ImportExportPlugin();
                plugin.Name = "从Microsoft Office Outlook导入联系人";
                plugin.TypeName = "Imps.Client.Pc.ImportContactsFromOutlook";
                plugin.Description = "从Outlook中读取含有手机号码的联系人信息,并向对方发出添加好友的邀请。";
                this._importPlugins.Add(plugin);
            }
            return this._importPlugins;
        }

        public void Import()
        {
            if ((this._exportFrom != null) && !this._exportFrom.IsDisposed)
            {
                this._exportFrom.Close();
            }
            if ((this._importForm == null) || this._importForm.IsDisposed)
            {
                this._importForm = new ImportForm(this._frameworkWin, this);
                ControlHelper.ShowFormCenterOnParent(this._importForm, this._frameworkWin.MainWindow);
            }
            else
            {
                NativeMethods.ShowWindow(this._importForm.Handle, 9);
            }
        }

        public class ImportExportPlugin
        {
            private string _assemblyName;
            private string _description;
            private object _importExportObject;
            private string _name;
            private string _type;

            public string AssemblyName
            {
                get
                {
                    return this._assemblyName;
                }
                set
                {
                    this._assemblyName = value;
                }
            }

            public string Description
            {
                get
                {
                    return this._description;
                }
                set
                {
                    this._description = value;
                }
            }

            public object ImportExportObject
            {
                get
                {
                    if ((this._importExportObject == null) && (this._importExportObject == null))
                    {
                        Assembly executingAssembly = null;
                        if (this._assemblyName != null)
                        {
                            executingAssembly = Assembly.Load(this._assemblyName);
                        }
                        else
                        {
                            executingAssembly = Assembly.GetExecutingAssembly();
                        }
                        if (executingAssembly != null)
                        {
                            Type type = executingAssembly.GetType(this._type);
                            if (type != null)
                            {
                                this._importExportObject = Activator.CreateInstance(type);
                            }
                        }
                    }
                    return this._importExportObject;
                }
            }

            public string Name
            {
                get
                {
                    return this._name;
                }
                set
                {
                    this._name = value;
                }
            }

            public string TypeName
            {
                get
                {
                    return this._type;
                }
                set
                {
                    this._type = value;
                }
            }
        }
    }
}

⌨️ 快捷键说明

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