Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ATMarkDTO"/> class.
 /// </summary>
 /// <param name="item">
 /// The entity item.
 /// </param>
 public ATMarkDTO(ATTextItem item)
     : this(item.Mark)
 {
     this.color     = item.Color;
     this.text      = item.Text;
     this.positionX = (float)item.PositionX;
     this.positionY = (float)item.PositionY;
     this.width     = (float)item.Width;
     this.height    = (float)item.Height;
     this.fontSize  = item.FontSize;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Converts <see cref="ATMarkDTO"/> to requested entity type
        /// </summary>
        /// <param name="mark">the mark</param>
        /// <param name="existing">existing item</param>
        /// <returns>corresponding entity</returns>
        public ATTextItem ToTextItem(ATMarkDTO mark, ATTextItem existing)
        {
            var o = existing ?? new ATTextItem();

            o.Mark      = this.ToMark(mark, null != existing ? existing.Mark : null);
            o.Color     = mark.color;
            o.Text      = mark.text;
            o.Height    = mark.height;
            o.PositionX = mark.positionX;
            o.PositionY = mark.positionY;
            o.Width     = mark.width;
            o.FontSize  = mark.fontSize;
            return(o);
        }
Exemplo n.º 3
0
        private void ProcessText(ATTextItem dr, PdfStamper stamper, PdfReader pdfReader)
        {
            var pageHeight = pdfReader.GetPageSizeWithRotation(dr.Mark.PageIndex).Height;
            var cb         = stamper.GetOverContent(dr.Mark.PageIndex);

            var bc = GetColor(dr.Color);

            cb.SetColorStroke(bc);
            cb.SetRGBColorFill(bc.R, bc.G, bc.B);

            cb.BeginText(); // Start working with text.

            // Create a font to work with
            var fontName = !string.IsNullOrEmpty(dr.FontName) ? dr.FontName : "Arial";
            var size     = dr.FontSize > 0 ? dr.FontSize : 14;
            var font     = FontFactory.GetFont(fontName, size, Font.NORMAL);
            var baseFont = font.GetCalculatedBaseFont(false);

            cb.SetFontAndSize(baseFont, size);

            // Note: The x,y of the Pdf Matrix is from bottom left corner.
            // This command tells iTextSharp to write the text at a certain location with a certain angle.
            // Again, this will angle the text from bottom left corner to top right corner and it will
            // place the text in the middle of the page.
            var y = pageHeight - ((float)dr.PositionY + size);

            foreach (var part in dr.Text.Split('\n'))
            {
                cb.ShowTextAligned(
                    PdfContentByte.ALIGN_LEFT,
                    part,
                    (float)dr.PositionX + 3,
                    y,
                    0);
                y -= (size + 4);
            }

            cb.EndText(); // Done working with text
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ATTextItemDTO"/> class.
        /// </summary>
        /// <param name="item">
        /// The textItem.
        /// </param>
        public ATTextItemDTO(ATTextItem item)
        {
            this.displayFormat = item.Mark.DisplayFormat;
            this.pageIndex     = item.Mark.PageIndex;
            this.id            = item.Mark.Id;
            this.type          = item.Mark.Type;
            this.fileId        = item.Mark.File.Id;
            this.datechanged   = item.Mark.DateChanged;
            this.datecreated   = item.Mark.DateCreated;
            this.@readonly     = item.Mark.IsReadonly;
            this.rotation      = item.Mark.Rotation;

            this.positionX = (float)item.PositionX;
            this.positionY = (float)item.PositionY;
            this.width     = (float)item.Width;
            this.height    = (float)item.Height;
            this.color     = item.Color;

            this.text       = item.Text;
            this.fontName   = item.FontName;
            this.fontFamily = item.FontFamily;
            this.fontSize   = item.FontSize;
            this.alignment  = item.Alignment;
        }
Exemplo n.º 5
0
        /// <summary>
        /// The get marks for file.
        /// </summary>
        /// <param name="fileId">
        /// The file id.
        /// </param>
        /// <returns>
        /// The <see cref="Tuple"/>.
        /// </returns>
#pragma warning disable 168
        public Tuple <List <ATShape>, List <ATDrawing>, List <ATHighlightStrikeOut>, List <ATTextItem>, List <ATRotation> > GetMarksForFile(Guid fileId)
        {
            // trick to make NHibernate to load all child instances in one roundtrip to db (if db supports it)
            var result = new Tuple <List <ATShape>, List <ATDrawing>, List <ATHighlightStrikeOut>, List <ATTextItem>, List <ATRotation> >
                             (new List <ATShape>(), new List <ATDrawing>(), new List <ATHighlightStrikeOut>(), new List <ATTextItem>(), new List <ATRotation>());
            ATMark               mark                 = null;
            ATShape              note                 = null;
            ATDrawing            atDrawing            = null;
            ATHighlightStrikeOut atHighlightStrikeOut = null;
            ATTextItem           textItem             = null;
            ATRotation           rotationItem         = null;

            // Query to load the companies
            var marks = this.Repository.Session.QueryOver(() => mark).Where(x => x.File.Id == fileId).Fetch(x => x.File).Eager.Future <ATMark>();

            // Query to load the Notes
            var notes = this.Repository.Session.QueryOver(() => note)
                        .JoinAlias(p => p.Mark, () => mark)
                        .Future <ATShape>();

            // Query to load the Drawings
            var drawings = this.Repository.Session.QueryOver(() => atDrawing)
                           .JoinAlias(p => p.Mark, () => mark)
                           .Future <ATDrawing>();

            // Query to load the Highlights
            var highlights = this.Repository.Session.QueryOver(() => atHighlightStrikeOut)
                             .JoinAlias(p => p.Mark, () => mark)
                             .Future <ATHighlightStrikeOut>();

            // Query to load the TextItems
            var textItems = this.Repository.Session.QueryOver(() => textItem)
                            .JoinAlias(p => p.Mark, () => mark)
                            .Future <ATTextItem>();

            // Query to load the Rotations
            var rotationItems = this.Repository.Session.QueryOver(() => rotationItem)
                                .JoinAlias(p => p.Mark, () => mark)
                                .Future <ATRotation>();

            // when this is executed, the three queries are executed in one roundtrip
            var results = marks.ToList();

            foreach (var joinedMark in results)
            {
                foreach (var joinedNote in joinedMark.Shapes)
                {
                    result.Item1.Add(joinedNote);
                }
                foreach (var joinedDrawing in joinedMark.Drawings)
                {
                    result.Item2.Add(joinedDrawing);
                }
                foreach (var joinedHighlight in joinedMark.HighlightStrikeOuts)
                {
                    result.Item3.Add(joinedHighlight);
                }
                foreach (var joinedText in joinedMark.TextItems)
                {
                    result.Item4.Add(joinedText);
                }
                foreach (var rotation in joinedMark.Rotations)
                {
                    result.Item5.Add(rotation);
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        public IEnumerable <ATMark> GetMarks(Guid fileId)
        {
            ATMark               mark                 = null;
            ATShape              note                 = null;
            ATDrawing            atDrawing            = null;
            ATHighlightStrikeOut atHighlightStrikeOut = null;
            ATTextItem           textItem             = null;
            ATRotation           rotationItem         = null;
            ATPicture            pictureItem          = null;
            ATFormula            formulaItem          = null;
            ATAnnotation         annotationItem       = null;

            // Query to load the companies
            //     var marks = this.Repository.Session.QueryOver(() => mark).Where(x => x.File.Id == fileId).Fetch(x => x.File).Eager.Future<ATMark>();



            var mrs = this.Repository.Session.QueryOver <ATMark>()
                      .Left.JoinAlias(p => p.Annotations, () => annotationItem)
                      .Left.JoinAlias(p => p.Shapes, () => note)
                      .Left.JoinAlias(p => p.Drawings, () => atDrawing)
                      .Left.JoinAlias(p => p.HighlightStrikeOuts, () => atHighlightStrikeOut)
                      .Left.JoinAlias(p => p.TextItems, () => textItem)
                      .Left.JoinAlias(p => p.Rotations, () => rotationItem)
                      .Left.JoinAlias(p => p.Pictures, () => pictureItem)
                      .Left.JoinAlias(p => p.Formulas, () => formulaItem)
                      .Where(p => p.File.Id == fileId)
                      .Fetch(p => p.File).Eager.Future <ATMark>();

            //  .List();

            //// Query to load the Notes
            //var notes = this.Repository.Session.QueryOver(() => note)
            //    .JoinAlias(p => p.Mark, () => mark)
            //    .Future<ATShape>();

            //// Query to load the Drawings
            //var drawings = this.Repository.Session.QueryOver(() => atDrawing)
            //    .JoinAlias(p => p.Mark, () => mark)
            //    .Future<ATDrawing>();

            //// Query to load the Highlights
            //var highlights = this.Repository.Session.QueryOver(() => atHighlightStrikeOut)
            //    .JoinAlias(p => p.Mark, () => mark)
            //    .Future<ATHighlightStrikeOut>();

            //// Query to load the TextItems
            //var textItems = this.Repository.Session.QueryOver(() => textItem)
            //    .JoinAlias(p => p.Mark, () => mark)
            //    .Future<ATTextItem>();

            //// Query to load the Rotations
            //var rotationItems = this.Repository.Session.QueryOver(() => rotationItem)
            //    .JoinAlias(p => p.Mark, () => mark)
            //    .Future<ATRotation>();

            //// Query to load the Pictures
            //var pictureItems = this.Repository.Session.QueryOver(() => pictureItem)
            //    .JoinAlias(p => p.Mark, () => mark)
            //    .Future<ATPicture>();

            //// Query to load the Formulas
            //var formulaItems = this.Repository.Session.QueryOver(() => formulaItem)
            //    .JoinAlias(p => p.Mark, () => mark)
            //    .Future<ATFormula>();

            //// Query to load the Annotations
            //var annotationItems = this.Repository.Session.QueryOver(() => annotationItem)
            //    .JoinAlias(p => p.Mark, () => mark)
            //    .Future<ATAnnotation>();

            return(mrs.OrderBy(x => x.DateChanged).ToList());
        }