Ejemplo n.º 1
0
        private void backgroundSources()
        {
            Paragraph p = new Paragraph();

            p.Add("Discussion sources:");
            document.Add(p);
            foreach (Attachment at in discussion.Attachment)
            {
                BitmapSource          src        = MiniAttachmentManager.GetAttachmentBitmap2(at);
                System.Drawing.Image  drawingImg = BitmapSourceToBitmap(src);
                iTextSharp.text.Image itextImg   = iTextSharp.text.Image.GetInstance(drawingImg, BaseColor.WHITE);
                itextImg.ScaleToFit(150, 200);
                document.Add(itextImg);

                switch ((AttachmentFormat)at.Format)
                {
                case AttachmentFormat.Pdf:
                    break;

                case AttachmentFormat.Bmp:
                case AttachmentFormat.Jpg:
                case AttachmentFormat.Png:
                    break;

                case AttachmentFormat.Youtube:
                    p = new Paragraph();
                    p.Add("Youtube: " + at.VideoLinkURL);
                    document.Add(p);
                    break;

                default:
                    throw new NotSupportedException();
                }
            }
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }

            return(MiniAttachmentManager.GetAttachmentBitmap2(value as Attachment));
        }
Ejemplo n.º 3
0
        private PdfPTable addArgPoint(ArgPoint pt)
        {
            PdfPTable aTable = new PdfPTable(3);

            BaseColor clr = DiscussionColors.GetSideColor(pt.SideCode);

            PdfPCell c = getColoredTxtCell("Point:  " + string.Format("{0}", pt.Point) + "\n" +
                                           "Description:  " + string.Format("{0}", pt.Point) + "\n" +
                                           "Author(Name/Email):  " +
                                           string.Format("{0}/{1}", pt.Person.Name,
                                                         pt.Person.Email),
                                           clr);

            c.Colspan = 3;

            aTable.AddCell(c);

            foreach (Comment comment in pt.Comment)
            {
                string comm = string.Format("{0} ({1},{2})\n",
                                            comment.Text,
                                            pt.Person.Name,
                                            pt.Person.Email);
                aTable.AddCell(getColoredTxtCell("Comment", clr));
                aTable.AddCell(getColoredTxtCell(comm, clr));
                aTable.AddCell(getColoredTxtCell(string.Format("{0},{1}",
                                                               comment.Person.Name,
                                                               comment.Person.Email), clr));
            }

            foreach (Attachment at in pt.Attachment)
            {
                aTable.AddCell(getColoredTxtCell("Attachment", clr));

                BitmapSource          src        = MiniAttachmentManager.GetAttachmentBitmap2(at);
                System.Drawing.Image  drawingImg = BitmapSourceToBitmap(src);
                iTextSharp.text.Image itextImg   = iTextSharp.text.Image.GetInstance(drawingImg, BaseColor.WHITE);
                itextImg.ScaleToFit(150, 200);
                aTable.AddCell(getColoredImgCell(itextImg));

                aTable.AddCell(getColoredTxtCell("", clr));
            }

            return(aTable);
        }
Ejemplo n.º 4
0
        public static object RunViewer(Attachment a, bool localRequest)
        {
            if (a == null)
            {
                return(null);
            }

            if (a.Format == (int)AttachmentFormat.Pdf && a.MediaData != null)
            {
                string pdfPathName = Utils.RandomFilePath(".pdf");
                try
                {
                    using (var fs = new FileStream(pdfPathName, FileMode.Create))
                    {
                        fs.Write(a.MediaData.Data, 0, a.MediaData.Data.Length);
                    }
                    //Process.Start(pdfPathName);
                    Utils.ReportMediaOpened(StEvent.PdfOpened, a);
                    var pdfReader = ReaderWindow2.Instance(pdfPathName, a.Id, a.ArgPoint != null ? (int?)a.ArgPoint.Topic.Id : null, localRequest);
                    pdfReader.Show();
                    return(pdfReader);
                }
                catch
                {
                }
            }
            else if (MiniAttachmentManager.IsGraphicFormat(a))
            {
                if (a.Format == (int)AttachmentFormat.PngScreenshot)
                {
                    Utils.ReportMediaOpened(StEvent.ScreenshotOpened, a);
                }
                else
                {
                    Utils.ReportMediaOpened(StEvent.ImageOpened, a);
                }

                if (a.MediaData.Data != null)
                {
                    if (!ExplanationModeMediator.Inst.ImageViewerOpen)
                    {
                        var wnd = ImageWindow.Instance(a.Id, a.ArgPoint != null ? a.ArgPoint.Topic.Id : -1, localRequest);
                        wnd.img.Source = LoadImageFromBlob(a.MediaData.Data);
                        wnd.Show();
                        wnd.Activate();
                        return(wnd);
                    }
                }
            }
            else
            {
                //office file
                var    ext      = Path.GetExtension(a.Link).ToLower();
                string pathName = Utils.RandomFilePath(ext);
                try
                {
                    using (var fs = new FileStream(pathName, FileMode.Create))
                    {
                        fs.Write(a.MediaData.Data, 0, a.MediaData.Data.Length);
                    }
                    Process.Start(pathName);
                }
                catch (Exception e)
                {
                    MessageDlg.Show(e.ToString(), "Error");
                }
            }

            return(null);
        }