コード例 #1
0
        public void OpenMessageTest()
        {
            IPst     target   = CreateIPst(); // TODO: Initialize to an appropriate value
            NodeID   nodeID   = new NodeID(); // TODO: Initialize to an appropriate value
            IMessage expected = null;         // TODO: Initialize to an appropriate value
            IMessage actual;

            actual = target.OpenMessage(nodeID);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: zhonghai66/pstsdknet
        private void messagesListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (messagesListBox.SelectedIndices.Count < 1)
            {
                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                var nodeId = new NodeID {
                    Value = (uint)messagesListBox.SelectedItems[0].Tag
                };
                IMessage message = _pst.OpenMessage(nodeId);

                if (message.HasHtmlBody)
                {
                    var htmlBody = message.HtmlBody;

                    webBrowser1.Visible        = true;
                    messageBodyTextBox.Visible = false;

                    // reset webBrowser control...
                    // (hackhackhack -- this is a silly workaround for framework bug) -th
                    if (webBrowser1.Document != null)
                    {
                        webBrowser1.Document.OpenNew(true);
                    }
                    else
                    {
                        webBrowser1.Navigate("about:blank");
                    }

                    _htmlBodyStream = message.HtmlBodyStream; //new MemoryStream(htmlBody);
                    //webBrowser1.DocumentStream = _htmlBodyStream;


                    webBrowser1.DocumentText = message.HtmlBodyString;
                }
                else if (message.HasBody)
                {
                    messageBodyTextBox.Visible = true;
                    webBrowser1.Visible        = false;
                    messageBodyTextBox.Text    = message.Body;
                }
                else
                {
                    messageBodyTextBox.Visible = true;
                    webBrowser1.Visible        = false;
                    messageBodyTextBox.Text    = "";
                }

                var uid = message.Uid;

                attachCountLabel.Text    = "Attachments (" + message.AttachmentCount + ")";
                recipientCountLabel.Text = "Recipients (" + message.RecipientCount + ")";

                messageBodyLabel.Text = "Message Body (" +
                                        (message.HasHtmlBody
                    ? "text/html, " + message.HtmlBodySize
                    : message.HasBody
                        ? "text/plain, " + message.BodySize.ToString()
                        : "n/a") + " bytes)";


                recipientsListBox.Items.Clear();
                if (message.RecipientCount > 0)
                {
                    foreach (IRecipient recipient in message.Recipients)
                    {
                        recipientsListBox.Items.Add(
                            (recipient.HasAccountName ? recipient.AccountName : recipient.Name) +
                            (recipient.HasEmailAddress ? " <" + recipient.EmailAddress + ">" :""));
                        Application.DoEvents();
                    }
                }

                attachmentListBox.Items.Clear();
                if (message.AttachmentCount > 0)
                {
                    foreach (IAttachment attachment in message.Attachments)
                    {
                        string filename;
                        try
                        {
                            filename = attachment.Filename;
                        }
                        catch
                        {
                            filename = "<error retrieving attachment name>";
                        }
                        attachmentListBox.Items.Add(filename);
                        Application.DoEvents();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error completing requested action.\r\n\r\n" + ex.Message + "\r\n" + ex.StackTrace);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }