private void SetState(State state) { view.Scroll = state.position; view.EditPage = state.pageNum; Annotation anno = view.GetEditPage().GetAnnotation(state.index); AnnotationAppearance app = new AnnotationAppearance(view.Document, anno); app.CaptureAnnotation(); app.Properties.SetFrom(state.properties); app.Properties.Dirty = true; app.ReleaseAnnotation(); view.EditPage = -1; }
/** * 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); }