private void ContextMenuStrip_Opening(object sender, CancelEventArgs e) { // Enable/disable menu items based on the annotation. AnnotationUI annotation = annotationViewer.Annotations.ActiveAnnotation; Type at = annotation.GetType(); borderColorToolStripMenuItem.Enabled = at.GetProperty("Outline") != null; fillColorToolStripMenuItem.Enabled = at.GetProperty("Fill") != null && at.Name != "RubberStampAnnotation"; textColorToolStripMenuItem.Enabled = at.GetProperty("FontBrush") != null; fontToolStripMenuItem.Enabled = at.GetProperty("Font") != null; }
private Atalasoft.Annotate.AnnotationPen GetAnnotationPen(AnnotationUI annotation, string propertyName) { Type at = annotation.GetType(); System.Reflection.PropertyInfo info = at.GetProperty(propertyName); if (info == null) { return(null); } return(info.GetValue(annotation, null) as Atalasoft.Annotate.AnnotationPen); }
private T GetAnnotationProperty <T>(AnnotationUI annotation, string propertyName) where T : class { Type at = annotation.GetType(); PropertyInfo info = at.GetProperty(propertyName); if (info == null) { return(null); } return(info.GetValue(annotation, null) as T); }
private Atalasoft.Annotate.AnnotationBrush GetAnnotationBrush(AnnotationUI annotation, string propertyName) { // Use reflection to see if there is a brush. Type at = annotation.GetType(); System.Reflection.PropertyInfo info = at.GetProperty(propertyName); if (info == null) { return(null); } return(info.GetValue(annotation, null) as Atalasoft.Annotate.AnnotationBrush); }
private void FontToolStripMenuItem_Click(object sender, EventArgs e) { AnnotationUI annotation = annotationViewer.Annotations.ActiveAnnotation; Type at = annotation.GetType(); PropertyInfo info = at.GetProperty("Font"); if (info == null) { return; } AnnotationFont font = info.GetValue(annotation, null) as AnnotationFont; if (font == null) { return; } FontStyle fontStyle = FontStyle.Regular; if (font.Bold) { fontStyle = FontStyle.Bold; } if (font.Italic) { fontStyle |= FontStyle.Italic; } if (font.Strikeout) { fontStyle |= FontStyle.Strikeout; } if (font.Underline) { fontStyle |= FontStyle.Underline; } using (FontDialog dlg = new FontDialog()) { dlg.Font = new Font(font.Name, font.Size, fontStyle); if (dlg.ShowDialog(this) == DialogResult.OK) { font = new AnnotationFont(dlg.Font.Name, dlg.Font.Size, dlg.Font.Bold, dlg.Font.Italic, dlg.Font.Underline, dlg.Font.Strikeout); info.SetValue(annotation, font, null); } } UpdateAnnotationDefault(annotation); }