private void SendButtonsInitialize() { this.sendButton = new Button(); this.sendButton.Image = new Bitmap(FileResources.Icon("sendButton.png"), new Size(this.nuntiasTextBox.Height, this.nuntiasTextBox.Height)); this.sendButton.Font = this.nuntiasTextBox.Font; this.sendButton.Size = this.sendButton.Image.Size; this.sendButton.Left = this.nuntiasTextBox.Width + 15; this.sendButton.FlatStyle = FlatStyle.Flat; this.sendButton.FlatAppearance.BorderSize = 0; this.sendButton.Click += new EventHandler(this.OnClick); this.typingSpaceBar.Controls.Add(this.sendButton); this.chooseFileButton = new Button(); this.chooseFileButton.Image = GraphicsStudio.ResizeImageByHeight(FileResources.Icon("choosefiles.png"), sendButton.Image.Height); this.chooseFileButton.Font = this.nuntiasTextBox.Font; this.chooseFileButton.Size = this.chooseFileButton.Image.Size; this.chooseFileButton.Left = this.sendButton.Right + 15; this.chooseFileButton.FlatStyle = FlatStyle.Flat; this.chooseFileButton.FlatAppearance.BorderSize = 0; this.chooseFileButton.Click += new EventHandler(this.OnClick); this.typingSpaceBar.Controls.Add(this.chooseFileButton); this.snapshotButton = new Button(); this.snapshotButton.Image = GraphicsStudio.ResizeImageByHeight(FileResources.Icon("snapshot.png"), sendButton.Image.Height); this.snapshotButton.Font = this.nuntiasTextBox.Font; this.snapshotButton.Size = this.snapshotButton.Image.Size; this.snapshotButton.Left = this.chooseFileButton.Right + 15; this.snapshotButton.FlatStyle = FlatStyle.Flat; this.snapshotButton.FlatAppearance.BorderSize = 0; this.snapshotButton.Click += new EventHandler(this.OnClick); this.typingSpaceBar.Controls.Add(this.snapshotButton); }
private void ShowNuntiasContentPreview(string choosenSafeFileName, string localPath) { this.nuntiasTextBox.Multiline = false; this.nuntiasTextBox.Multiline = true; this.nuntiasTextBox.Visible = false; this.sendButton.Visible = false; int availableTop = 0; string extension = Path.GetExtension(localPath).ToLower(); if (extension == ".jpg" || extension == ".jpeg" || extension == ".png" || extension == ".gif" || extension == ".bmp") { int targetHeight = sendButton.Height * 5; imgPreview = new Label(); imgPreview.Image = GraphicsStudio.ResizeImageByHeight(Image.FromFile(localPath), targetHeight); imgPreview.Size = imgPreview.Image.Size; FilePreviewPanelHeight(imgPreview.Height + 40); imgPreview.Location = new Point(10, 5); availableTop = 5 + imgPreview.Height; this.filePreviewPanel.Controls.Add(imgPreview); } else { FilePreviewPanelHeight(40); } fileNameLabel = new Label(); fileNameLabel.Text = this.ReformatFileNameString(choosenSafeFileName); fileNameLabel.Font = CustomFonts.New(CustomFonts.SmallerSize, 'i'); fileNameLabel.ForeColor = Color.FromArgb(102, 51, 0); fileNameLabel.Size = fileNameLabel.PreferredSize; this.filePreviewPanel.Controls.Add(fileNameLabel); Label attachmentLabel = new Label(); Image attachImg = FileResources.Icon("attachment.png"); double attachHght = attachImg.Size.Height, targetHght = fileNameLabel.Height; attachmentLabel.Image = new Bitmap(attachImg, new Size((int)((targetHght / attachHght) * attachImg.Size.Width), (int)targetHght)); attachmentLabel.Size = attachmentLabel.Image.Size; attachmentLabel.Location = new Point(10, availableTop + 5); fileNameLabel.Location = new Point(attachmentLabel.Right + 5, availableTop + 5); this.filePreviewPanel.Controls.Add(attachmentLabel); Size fileButtonSize = new Size(filePreviewPanel.Height * 7 / 10, filePreviewPanel.Height * 7 / 10); if (imgPreview != null && imgPreview.Visible) { fileButtonSize = new Size(filePreviewPanel.Height * 2 / 5, filePreviewPanel.Height * 2 / 5); } sendFileButton = FileButtonsDefine("sendfile", fileButtonSize); this.parent.AcceptButton = sendFileButton; sendFileButton.Location = new Point(filePreviewPanel.Right - sendFileButton.Width - 30, (filePreviewPanel.Height - sendFileButton.Height) / 2); sendFileButton.Click += (s, e) => { this.SendChoosenFile(choosenSafeFileName, localPath, extension); }; cancelFileButton = this.FileButtonsDefine("cancelfile", fileButtonSize); this.parent.CancelButton = cancelFileButton; cancelFileButton.Location = new Point(sendFileButton.Left - cancelFileButton.Width, (filePreviewPanel.Height - cancelFileButton.Height) / 2); cancelFileButton.Click += delegate(Object sender, EventArgs e) { this.FilePreviewPanelHeight(0); }; }