public AnnotationAppearance(Datalogics.PDFL.Document doc, Datalogics.PDFL.Annotation ann) { document = doc; annotation = ann; properties = new AnnotationProperties(); ReadProperties(); }
/** * Creates rich text box while editing FreeText annotation. */ private void CreateRichTextBox() { if (!docView.EditPermission) { return; } AnnotationProperties props = docView.ActiveProps; Datalogics.PDFL.Rect rect = props.BoundingRect; Datalogics.PDFL.Rect newRect = Utils.Transform(rect, docView.GetPagePdfToWinCoordMatrix(docView.EditPage)); textBox = new RichTextBox(); docView.Controls.Add(textBox); textBox.Bounds = new Rectangle((int)newRect.LLx, (int)newRect.LLy, (int)newRect.Width, (int)newRect.Height); textBox.Text = props.Contents; textBox.BorderStyle = BorderStyle.None; textBox.TextChanged += new EventHandler(TextBoxTextChanged); textBox.Leave += new EventHandler(TextBoxLeaveHandler); textBox.KeyDown += new KeyEventHandler(TextBoxKeyDownHandler); props.Update += UpdateRichTextBox; textBox.Visible = true; textBox.Focus(); UpdateRichTextBox(false); }
public void Init(DocumentView view, BaseAnnotationEditor editor) { position = view.Scroll; pageNum = view.EditPage; index = editor.Index; properties = new AnnotationProperties(editor.Properties); }
public override bool Equals(object obj) { if (!(obj is AnnotationProperties)) { return(false); } AnnotationProperties other = obj as AnnotationProperties; return(properties.Equals(other.properties)); }
private void CopyFrom(AnnotationProperties other, bool onlyDirties) { foreach (string property in other.Available) { if (!onlyDirties || other.properties[property].Dirty) { this.properties.Remove(property); this.properties.Add(property, new Property(other.properties[property].Value, other.properties[property].Type, true, other.properties[property].ChangeData)); } } }
private void UpdateRichTextBox(object unused) { AnnotationProperties props = docView.ActiveProps; textBox.BackColor = props.InteriorColor; textBox.ForeColor = props.TextColor; FontStyle[] possibleStyles = new FontStyle[] { FontStyle.Regular, FontStyle.Italic, FontStyle.Bold, FontStyle.Italic | FontStyle.Bold }; System.Drawing.Font drawFont = null; foreach (FontStyle style in possibleStyles) { try { drawFont = new System.Drawing.Font(props.FontFace, (float)(props.FontSize * docView.Zoom * docView.DPI), style, GraphicsUnit.Pixel); break; } catch (ArgumentException) { // possible exception if font can't be rendered with specified style } } textBox.Font = drawFont; }
public CreateAnnotationMode(DocumentView view, string subType) : base(view) { properties = new AnnotationProperties(subType); }
/** * Creates annotation, type of annotation is taken from given properties */ public static Annotation CreateAnnotation(Document doc, Page page, int index, AnnotationProperties props) { Annotation ann = null; int addAfter = index - 1; switch (props.Subtype) { case "Line": ann = new LineAnnotation(page, props.BoundingRect, props.StartPoint, props.EndPoint, addAfter); break; case "Circle": ann = new CircleAnnotation(page, props.BoundingRect, addAfter); break; case "Square": ann = new SquareAnnotation(page, props.BoundingRect, addAfter); break; case "FreeText": ann = new FreeTextAnnotation(page, props.BoundingRect, "", addAfter); break; case "PolyLine": ann = new PolyLineAnnotation(page, props.BoundingRect, props.Vertices, addAfter); break; case "Polygon": ann = new PolygonAnnotation(page, props.BoundingRect, props.Vertices, addAfter); break; case "Link": ann = new LinkAnnotation(page, props.BoundingRect, addAfter); break; case "Ink": ann = new InkAnnotation(page, props.BoundingRect, addAfter); break; case "Underline": ann = new UnderlineAnnotation(page, addAfter, props.Quads); break; case "Highlight": ann = new HighlightAnnotation(page, addAfter, props.Quads); break; default: throw new Exception("Logic error"); } AnnotationAppearance app = new AnnotationAppearance(doc, ann); app.CaptureAnnotation(); app.Properties.SetFrom(props); app.Properties.Dirty = true; app.UpdateAppearance(); app.ReleaseAnnotation(); return(ann); }
public static BaseAnnotationEditor CreateAnnotationAndEditor(Document doc, Page page, int index, AnnotationProperties props) { CreateAnnotation(doc, page, index, props); return(CreateAnnotationEditor(doc, page, index)); }
public AnnotationProperties(AnnotationProperties other) { CopyFrom(other, false); }
public void UpdateFrom(AnnotationProperties other) { CopyFrom(other, true); }
public void SetFrom(AnnotationProperties other) { properties.Clear(); CopyFrom(other, false); Dirty = false; }