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

📄 customemotionaddform.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 3 页
字号:
            this.bwBatchAdd.add_DoWork(new DoWorkEventHandler(this, (IntPtr) this.bwBatchAdd_DoWork));
            this.bwBatchAdd.add_RunWorkerCompleted(new RunWorkerCompletedEventHandler(this, (IntPtr) this.bwBatchAdd_RunWorkerCompleted));
            this.bwBatchAdd.add_ProgressChanged(new ProgressChangedEventHandler(this, (IntPtr) this.bwBatchAdd_ProgressChanged));
            this.bwImport.set_WorkerReportsProgress(true);
            this.bwImport.set_WorkerSupportsCancellation(true);
            this.bwImport.add_DoWork(new DoWorkEventHandler(this, (IntPtr) this.bwImport_DoWork));
            this.bwImport.add_RunWorkerCompleted(new RunWorkerCompletedEventHandler(this, (IntPtr) this.bwImport_RunWorkerCompleted));
            this.bwImport.add_ProgressChanged(new ProgressChangedEventHandler(this, (IntPtr) this.bwImport_ProgressChanged));
            this.panel1.Controls.Add(this.lTitle);
            this.panel1.Controls.Add(this.pSingleAdd);
            this.panel1.Controls.Add(this.pBatchAdd);
            this.panel1.Controls.Add(this.tbFileNames);
            this.panel1.Controls.Add(this.btnBrowse);
            this.panel1.Controls.Add(this.lItem1);
            this.panel1.Location = new System.Drawing.Point(2, 12);
            this.panel1.Name = "panel1";
            this.panel1.Size = new Size(0x15b, 0xfe);
            this.panel1.TabIndex = 0;
            base.set_AutoScaleDimensions(new SizeF(6f, 13f));
            this.BackColor = Color.White;
            base.BaseHeight = 0x1d2;
            base.BaseWidth = 0x15f;
            base.CancelButton = this.btnCancel;
            base.ClientSize = new Size(0x15f, 0x1d2);
            base.Controls.Add(this.panel1);
            base.Controls.Add(this.btnOk);
            base.Controls.Add(this.btnCancel);
            base.DisplayLocation = new System.Drawing.Point(15, 15);
            base.DisplaySize = new Size(0x15f, 0x1d2);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.MinimizeBox = false;
            base.Name = "CustomEmotionAddForm";
            base.set_Padding(new Padding(4, 0, 4, 0x2b));
            base.StartPosition = FormStartPosition.Manual;
            base.Text = "Fetion 2008";
            base.add_FormClosed(new FormClosedEventHandler(this, (IntPtr) this.CustomEmotionAddForm_FormClosed));
            base.Load += new EventHandler(this.CustomEmotionAddForm_Load);
            this.pBatchAdd.ResumeLayout(false);
            this.pBatchAdd.PerformLayout();
            this.upPicture.ResumeLayout(false);
            this.pSingleAdd.ResumeLayout(false);
            this.pSingleAdd.PerformLayout();
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            base.ResumeLayout(false);
        }

        private string MakeShortCut(string shortCut)
        {
            if ((shortCut == null) || (shortCut == string.Empty))
            {
                shortCut = StringHelper.RandomString(8);
            }
            for (int i = 0; this.ExistShortCut(shortCut, ""); i++)
            {
                if (i > 0x7a)
                {
                    shortCut = "";
                    return shortCut;
                }
                shortCut = StringHelper.RandomString(8);
            }
            return shortCut;
        }

        private void ResetForm()
        {
            this.pBatchAdd.Top = this.pSingleAdd.Top;
            switch (this._operateType)
            {
                case OperateTypeEnum.Add:
                    this.lItem1.Text = string.Format("1、请选择表情图片位置(文件不要超过{0}K)支持jpg,gif,\r\npng,bmp格式", CustomEmotionUtils.GetMaxEmotionPicSize(this._frameworkWin.AccountManager.CurrentUser));
                    return;

                case OperateTypeEnum.Edit:
                    this.lItem1.Text = string.Format("1、请选择表情图片位置(文件不要超过{0}K)支持jpg,gif,\r\npng,bmp格式", CustomEmotionUtils.GetMaxEmotionPicSize(this._frameworkWin.AccountManager.CurrentUser));
                    this.opdBrowse.Multiselect = false;
                    return;

                case OperateTypeEnum.Import:
                    this.btnOk.Text = "导入";
                    this.lItem1.Text = "请选择飞信表情库文件(*.ffl)";
                    this.lItem4.Text = "您导入表情库里自定义表情,飞信将";
                    this.cbAssignShotCut.Text = "系统分配重复的键盘输入快捷键";
                    this.opdBrowse.Multiselect = false;
                    this.opdBrowse.Filter = "飞信表情文件(*.ffl)|*.ffl";
                    this.pSingleAdd.Visible = false;
                    this.pBatchAdd.Visible = true;
                    this.cbAssignName.Visible = false;
                    return;
            }
        }

        private void SetControlText()
        {
            this.lTitle.Text = StringTable.CustomEmotions.CustomEmotionAdd.Title;
            this.lItem1.Text = StringTable.CustomEmotions.CustomEmotionAdd.Item1;
            this.lItem2.Text = StringTable.CustomEmotions.CustomEmotionAdd.Item2;
            this.lItem3.Text = StringTable.CustomEmotions.CustomEmotionAdd.Item3;
            this.lItem4.Text = StringTable.CustomEmotions.CustomEmotionAdd.Item4;
            this.btnBrowse.Text = StringTable.CustomEmotions.CustomEmotionAdd.Browse;
            this.btnCancel.Text = StringTable.CustomEmotions.CustomEmotionAdd.Cancel;
        }

        private void SetFileNames()
        {
            if (this._fileNames.Length >= 1)
            {
                this.tbFileNames.Text = this._fileNames[0];
                for (int i = 1; i < this._fileNames.Length; i++)
                {
                    this.tbFileNames.Text = this.tbFileNames.Text + ";" + Path.GetFileName(this._fileNames[i]);
                }
            }
        }

        private void SetShotCutAndName()
        {
            if (this._operateType != OperateTypeEnum.Add)
            {
                this.btnOk.Focus();
            }
            else
            {
                int length = this._fileNames.Length;
                this.pSingleAdd.Visible = length == 1;
                this.pBatchAdd.Visible = length > 1;
                if (length > 1)
                {
                    this.lItem4.Text = string.Format("您批量添加了{0}个自定义表情,飞信将", this._fileNames.Length);
                    this.btnOk.Focus();
                }
                else
                {
                    string fileName = this.GetFileName(0);
                    string shortCut = this.GetShortCut(fileName);
                    this.tbShotCut.Text = shortCut;
                    this.tbName.Text = shortCut;
                    this.tbShotCut.Focus();
                }
            }
        }

        private void ShowResult()
        {
            if ((this._ceResultForm != null) && !this._ceResultForm.IsDisposed)
            {
                this._ceResultForm.Close();
                this._ceResultForm.Dispose();
            }
            this._ceResultForm = new CustomEmotionBatchResultForm(this._successCount, this._errList, this);
            ControlHelper.ShowFormCenterOnParent(this._ceResultForm, this);
            this._ceResultForm.Focus();
        }

        private void SingleAdd()
        {
            string filepath = this._fileNames[0];
            string shortCut = this.tbShotCut.Text.Trim();
            string name = this.tbName.Text.Trim();
            try
            {
                Imps.Client.Core.CustomEmotion.CustomEmotion emotionByShortCut = this._iceManager.OwnerEmotions.GetEmotionByShortCut(shortCut);
                if (emotionByShortCut != null)
                {
                    if (this._frameworkWin.UnifiedMessageBox.ShowConfirmation(this, "与其他表情的输入快捷键重复\r\n点击“是”将删除原表情\r\n“否”将重新设置快捷键") != DialogResult.Yes)
                    {
                        return;
                    }
                    this._iceManager.DeleteOwnerEmotion(emotionByShortCut);
                    if (this.RefreshList != null)
                    {
                        this.RefreshList.Invoke(this, new CustomEmotionEventArgs(emotionByShortCut));
                    }
                    this.AddCustomEmotion(shortCut, name, filepath);
                }
                else
                {
                    this.AddCustomEmotion(shortCut, name, filepath);
                }
                if (this._errList.get_Count() > 0)
                {
                    this._frameworkWin.UnifiedMessageBox.ShowError(this, "自定义表情添加失败:" + this._errList.get_Item(0)[1] + "。");
                }
                else
                {
                    base.Close();
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException("自定义表情 -> 添加", exception);
            }
            finally
            {
                this.ChangeControlEnabled(true);
                this.tbShotCut.Focus();
            }
        }

        private void SingleEdit()
        {
            string text = this._fileNames[0];
            string shortCut = this.tbShotCut.Text.Trim();
            string name = this.tbName.Text.Trim();
            try
            {
                Imps.Client.Core.CustomEmotion.CustomEmotion emotionByShortCut = this._iceManager.OwnerEmotions.GetEmotionByShortCut(shortCut);
                if ((emotionByShortCut != null) && (emotionByShortCut.Id != this.EditCustomEmotion.Id))
                {
                    if (this._frameworkWin.UnifiedMessageBox.ShowConfirmation(this, "与其他表情的输入快捷键重复\r\n点击“是”将删除原表情\r\n“否”将重新设置快捷键") != DialogResult.Yes)
                    {
                        return;
                    }
                    this._iceManager.DeleteOwnerEmotion(emotionByShortCut);
                    if (this.RefreshList != null)
                    {
                        FuncDispatcher.InvokeEventHandlerInUiThread<CustomEmotionEventArgs>(this, this.RefreshList, new CustomEmotionEventArgs(emotionByShortCut));
                    }
                }
                if (this.EditCustomEmotion.Name.Equals(text))
                {
                    CustomEmotionStatus ceStatus = this._iceManager.UpdateOwnerEmotion(this.EditCustomEmotion, shortCut, name);
                    if (ceStatus != CustomEmotionStatus.OK)
                    {
                        this._errList.Add(new string[] { text, CustomEmotionUtils.GetCustomEmotionStatusDesc(ceStatus, this._frameworkWin.AccountManager.CurrentUser) });
                    }
                    else if (this.RefreshList != null)
                    {
                        FuncDispatcher.InvokeEventHandlerInUiThread<CustomEmotionEventArgs>(this, this.RefreshList, new CustomEmotionEventArgs(this.EditCustomEmotion));
                    }
                }
                else
                {
                    this._iceManager.DeleteOwnerEmotion(this.EditCustomEmotion);
                    if (this.RefreshList != null)
                    {
                        FuncDispatcher.InvokeEventHandlerInUiThread<CustomEmotionEventArgs>(this, this.RefreshList, new CustomEmotionEventArgs(this.EditCustomEmotion));
                    }
                    this.AddCustomEmotion(shortCut, name, text);
                }
                if (this._errList.get_Count() > 0)
                {
                    this._frameworkWin.UnifiedMessageBox.ShowError(this, "自定义表情编辑失败:" + this._errList.get_Item(0)[1] + "。");
                }
                else
                {
                    base.Close();
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException("自定义表情 -> 修改", exception);
            }
            finally
            {
                this.ChangeControlEnabled(true);
                this.tbShotCut.Focus();
            }
        }

        private void tbFileNames_TextChanged(object sender, EventArgs e)
        {
            this.btnOk.Enabled = !this.tbFileNames.Text.Trim().Equals("");
        }

        private void tbName_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Tab))
            {
                this.btnOk.Focus();
            }
        }

        private void tbShotCut_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Tab))
            {
                this.tbName.Focus();
            }
        }

        private void tbShotCut_TextChanged(object sender, EventArgs e)
        {
            string text = this.tbShotCut.Text.Replace(" ", "");
            this.tbShotCut.Text = text;
        }

        private string TransToImportPath(string fileName, string packageName)
        {
            fileName = Path.GetFileName(fileName);
            packageName = Path.GetFileName(packageName);
            return ("$" + packageName + "/" + fileName);
        }

        public Imps.Client.Core.CustomEmotion.CustomEmotion EditCustomEmotion
        {
            get
            {
                return this._editCustomEmotion;
            }
            set
            {
                this._editCustomEmotion = value;
                this.tbName.Text = this._editCustomEmotion.Name;
                this.tbShotCut.Text = this._editCustomEmotion.ShortCut;
                this.tbFileNames.Text = this._editCustomEmotion.Name;
                this.btnBrowse.Enabled = false;
                this.btnOk.Enabled = true;
                this._fileNames = new string[] { this._editCustomEmotion.Name };
            }
        }

        public OperateTypeEnum OperateType
        {
            get
            {
                return this._operateType;
            }
        }

        private delegate void CustomEmotionAddOperate(string shortCut, string name, string filepath);

        public enum OperateTypeEnum
        {
            Add,
            Edit,
            Import
        }
    }
}

⌨️ 快捷键说明

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