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

📄 conversationwindow.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 5 页
字号:
            {
                try
                {
                    if (!this.BeActivated || (base.WindowState == FormWindowState.Minimized))
                    {
                        ControlHelper.FlashWindow(this);
                        this._manager.PlayMessageReceiveSource();
                    }
                }
                catch (Exception exception)
                {
                    this.HandleException(exception);
                }
                try
                {
                    if ((this.CurrentConversation == null) || (this.CurrentConversation.CurrentDialog == null))
                    {
                        this.initConversation();
                    }
                    this._historyChatManager.SelectionStart = this._historyChatManager.Length;
                    if ((msg is IMMessage) || (msg is SMSMessage))
                    {
                        this.AppendIMOrSMSMessage(msg);
                    }
                    else
                    {
                        if (msg is CommonMessage)
                        {
                            this._historyChatManager.SelectionIdent = 0;
                            this._historyChatManager.AppentString(msg.Content);
                        }
                        else if (msg is ShareContentMessage)
                        {
                            this.AppendShareContentMessage(msg as ShareContentMessage);
                        }
                        else if (msg is ParticipantJoinAndLeftMessage)
                        {
                            this.AppendParticipantJoinAndLeftMessage(msg as ParticipantJoinAndLeftMessage);
                        }
                        else
                        {
                            this._historyChatManager.SelectionIdent = 0;
                            this._historyChatManager.AppentString(msg.Content);
                        }
                        if ((this.CurrentConversation != null) && (this.CurrentConversation.CurrentDialog != null))
                        {
                            this.CurrentConversation.CurrentDialog.MsgManager.SetNextNewLine();
                        }
                    }
                    this._historyChatManager.AppendCRLF();
                    this._historyChatManager.ScrollToEnd();
                }
                catch (Exception exception2)
                {
                    this.HandleException(exception2);
                }
            }
        }

        private void AppendParticipantJoinAndLeftMessage(ParticipantJoinAndLeftMessage msg)
        {
            this._historyChatManager.SelectionIdent = 0;
            Bitmap image = Bitmap.FromHicon(ImpsTrayIcons.Online.Handle);
            this._historyChatManager.AppendImage(image, "", OleKeyManager.Instance.NewKey, image.Size);
            this._historyChatManager.AppentString(msg.Content);
            this._historyChatManager.AppendCRLF();
            this._historyChatManager.AppendImage(this._separate, "", OleKeyManager.Instance.NewKey, this._separate.Size);
            this._historyChatManager.AppendCRLF();
        }

        private void AppendSendMessageError(string message, string error)
        {
            try
            {
                message = Imps.Utils.TagParser.TagParser.Create(message, false).Text;
                if (message.Length > 15)
                {
                    message = message.Substring(0, 15) + "...";
                }
                message = message + " ";
                message = StringHelper.EncodString(message);
                message = string.Format(StringTable.Conversation.MsgMessageSendFailed, message, error);
                this.AppendMessage(new CommonMessage(null, message));
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }

        private void AppendShareContentMessage(ShareContentMessage msg)
        {
            this._historyChatManager.SelectionIdent = 0;
            this._historyChatManager.AppendImage(this._separate, "", OleKeyManager.Instance.NewKey, this._separate.Size);
            this._historyChatManager.AppendCRLF();
            this._historyChatManager.AppendCRLF();
            Image image = ImpsResources.GetImage("Images.Sending.png");
            if (msg.IsFailed)
            {
                image = ImpsResources.GetImage("Images.SendFailed.png");
            }
            this._historyChatManager.AppendImage(image, "", OleKeyManager.Instance.NewKey, image.Size);
            this._historyChatManager.AppentString(" " + msg.Content);
            if (msg.IsDownloadComplete)
            {
                this._historyChatManager.AppendCRLF();
                OleKey newKey = OleKeyManager.Instance.NewKey;
                newKey.Tag = Path.GetDirectoryName(msg.Context.FilePath);
                this._historyChatManager.AppentString("  ");
                this._historyChatManager.InsertLink(this._historyChatManager.Length - 1, newKey, "打开目录", "SYSTEM");
                this._historyChatManager.AppentString("  ");
                this._historyChatManager.InsertLink(this._historyChatManager.Length - 1, OleKeyManager.Instance.NewKey, msg.Context.FilePath, "SYSTEM");
            }
            this._historyChatManager.AppendCRLF();
            this._historyChatManager.AppendImage(this._separate, "", OleKeyManager.Instance.NewKey, this._separate.Size);
            this._historyChatManager.AppendCRLF();
        }

        private void BlockContact(Imps.Client.Core.Contact contact)
        {
            AsyncBizOperation op = new AsyncBizOperation();
            if (contact.IsBlocked)
            {
                this.CurrentUser.ContactList.AsyncRemoveFromBlackList(contact.Uri, op);
            }
            else
            {
                this.CurrentUser.ContactList.AsyncAddToBlackList(contact.Uri, op);
            }
        }

        private void btnSend_ButtonClick(object sender, EventArgs e)
        {
            this.SendMessage();
        }

        private void BuildShareContent(ShareContent sc)
        {
            if (!sc.IsCancel)
            {
                OleKey newKey = OleKeyManager.Instance.NewKey;
                this._dicShareContent.Add(newKey, sc);
                Image defaultPortrait = null;
                AmigoImage image2 = null;
                if (sc.PreviewImageBase64String != null)
                {
                    defaultPortrait = ImageHelper.Base64ToImage(sc.PreviewImageBase64String);
                }
                if (defaultPortrait == null)
                {
                    try
                    {
                        Bitmap bitmap;
                        if (this._syncObjTempImageFile == null)
                        {
                            this._syncObjTempImageFile = new object();
                        }
                        lock (this._syncObjTempImageFile)
                        {
                            string filePath = sc.FilePath;
                            if (!File.Exists(sc.FilePath))
                            {
                                string path = ((string) this.CurrentUser.Configuration.UserSetting.ConversationSetting.DefaultShareContentSavePath) + @"\temp";
                                if (!Directory.Exists(path))
                                {
                                    Directory.CreateDirectory(path);
                                }
                                filePath = path + @"\" + sc.FileName;
                                if (!File.Exists(filePath))
                                {
                                    File.Create(filePath);
                                }
                            }
                            Icon icon = ImpsFileType.GetIcon(filePath);
                            bitmap = new Bitmap(icon.Width, icon.Height);
                            using (Graphics graphics = Graphics.FromImage(bitmap))
                            {
                                graphics.Clear(Color.White);
                                graphics.DrawIcon(icon, 0, 0);
                            }
                        }
                        defaultPortrait = bitmap;
                    }
                    catch
                    {
                        defaultPortrait = ImpsPortrait.GetDefaultPortrait(30, 30);
                    }
                }
                if (defaultPortrait != null)
                {
                    Bitmap image = new Bitmap(defaultPortrait.Width + 2, defaultPortrait.Height + 2);
                    using (Graphics graphics2 = Graphics.FromImage(image))
                    {
                        graphics2.Clear(Color.White);
                        graphics2.DrawImage(defaultPortrait, 1, 1);
                    }
                    image2 = new AmigoImage(image);
                }
                string text = string.Format("{0}({1})", sc.FileName, StringHelper.GetFileSize(sc.FileSize));
                this._historyChatManager.SelectionIdent = 0;
                if (sc is DownLoadShareContent)
                {
                    DownLoadShareContent content = sc as DownLoadShareContent;
                    this.AppendMessage(new CommonMessage(null, string.Format(StringTable.Conversation.MsgSendShareContentInfo, ConvertString(content.From.DisplayName))));
                    this._historyChatManager.AppendProgressbar(newKey, text, image2, sc.FileName);
                    this._historyChatManager.AppendCRLF();
                    this.InserShareContentLinkButton(ShareContentLinkValue.Accept.ToString(), StringTable.Conversation.BtnAccept, Keys.P, sc);
                    this.InserShareContentLinkButton(ShareContentLinkValue.SaveAs.ToString(), StringTable.Conversation.BtnSaveAs, Keys.S, sc);
                    this.InserShareContentLinkButton(ShareContentLinkValue.Decline.ToString(), StringTable.Conversation.BtnRefuse, Keys.D, sc);
                    this._historyChatManager.AppendCRLF();
                }
                else
                {
                    this.AppendMessage(new CommonMessage(null, string.Format(StringTable.Conversation.MsgSendShareContentInfo, ConvertString(this.CurrentUser.Nickname))));
                    this._historyChatManager.AppendProgressbar(newKey, text, image2, sc.FileName);
                    this._historyChatManager.AppendCRLF();
                    this.InserShareContentLinkButton(ShareContentLinkValue.Cancel.ToString(), StringTable.Conversation.BtnCancel, Keys.C, sc);
                    this._historyChatManager.AppendCRLF();
                }
                this._historyChatManager.ScrollToEnd();
            }
        }

        private void CalculateMultiLstHeight()
        {
            if ((this._lstContacts != null) && (this._buddy_list_drawer != null))
            {
                int num = (this.scMain.Height - this.picOwner.Height) - this._buddy_list_drawer.itemheight;
                if (num > 0)
                {
                    if ((this._lstContacts.Items.Count * this._buddy_list_drawer.itemheight) > num)
                    {
                        this._lstContacts.Parent.Height = num;
                    }
                    else
                    {
                        this._lstContacts.Parent.Height = ((this._lstContacts.Items.Count * this._buddy_list_drawer.itemheight) + this._lstContacts.Parent.Padding.Top) + this._lstContacts.Parent.Padding.Bottom;
                    }
                }
            }
        }

        private void contact_IsBlockChanged(object sender, BlockEventArgs e)
        {
            Imps.Client.Core.Contact contact = sender as Imps.Client.Core.Contact;
            if (this.IsMultiConversation)
            {
                foreach (ToolStripMenuItem item in this.menuBlockUsers.Items)
                {
                    if (item.Tag == contact)
                    {
                        item.Checked = contact.IsBlocked;
                    }
                }
                foreach (ToolStripMenuItem item2 in this.tsOperationBlock.DropDown.Items)
                {
                    if (item2.Tag == contact)
                    {
                        item2.Checked = contact.IsBlocked;
                    }
                }
                this.FormatTooltipInfo();
            }
            else
            {
                if ((contact.IsBlocked && (this.CurrentConversation != null)) && (this.CurrentConversation.CurrentDialog != null))
                {
                    try
                    {
                        for (int i = this.CurrentConversation.Dialogs.Count - 1; i >= 0; i--)
                        {
                            Dialog dialog = this.CurrentConversation.Dialogs[i];
                            if ((dialog.Participants.Count == 1) && (dialog.Participants[0].Contact == contact))
                            {
                                dialog.ShareContents.Clear();
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        ClientLogger.WriteException(exception);
                    }
                }
                this.tsMain.SuspendLayout();
                this.tsInvite.Enabled = this.CanInviteNewContact;
                this.FormatControlEnable(contact);
                if (((this.CurrentConversation == null) || (this.CurrentConversation.CurrentDialog == null)) || (this.CurrentConversation.CurrentDialog.Status != DialogStatus.Invited))
                {
                    this.tsStopHistory.Enabled = false;
                }
                if (contact.IsBlocked)
                {
                    this.tsOperationBlock.Text = StringTable.Conversation.MsgCancelPreventContact + "(&B)";
                    this.tsBlock.Text = StringTable.Conversation.MsgCancelPreventContact;
                    this.tsBlock.Image = ImpsResources.GetImage("Images.Unblock.png");
                }
                else

⌨️ 快捷键说明

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