예제 #1
0
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            // Enable/disable menu items based on the annotation.
            Atalasoft.Annotate.UI.AnnotationUI annotation = this.documentAnnotationViewer1.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);
        }
예제 #2
0
        private void fontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Atalasoft.Annotate.UI.AnnotationUI annotation = this.documentAnnotationViewer1.Annotations.ActiveAnnotation;
            Type at = annotation.GetType();

            System.Reflection.PropertyInfo info = at.GetProperty("Font");
            if (info == null)
            {
                return;
            }

            Atalasoft.Annotate.AnnotationFont font = info.GetValue(annotation, null) as Atalasoft.Annotate.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 Atalasoft.Annotate.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);
        }