Пример #1
0
 private void SelectionUpdate(FormatChanges fc)
 {
     if (m_selected.Count == 1)
         ReformatOne(fc);
     else
         ReformatAll(fc);
 }
Пример #2
0
 private void ReformatOne(FormatChanges fc)
 {
     RichTextBox2 rtb = GetActiveEditor();
     rtb.SetFormatChanges(fc);
 }
Пример #3
0
 private void ReformatAll(FormatChanges fc)
 {
     foreach (Elem elem in m_selected)
         ReformatElement(elem, IsLexicalOperation(), fc);
 }
Пример #4
0
        public void ReformatElement(Elem elem, bool lexical, FormatChanges fc)
        {
            Node node = elem.GetNode();
            Dummy richtext = Dummy.GetInstance();
            richtext.Reset();
            richtext.Rtf = lexical ? node.GetLexicalRtf() : node.GetLabelRtf();

            richtext.SelectAll();

            richtext.SetFormatChanges(fc);

            if (lexical)
                node.SetLexicalRtfAndText(richtext.Rtf, richtext.Text);
            else
                node.SetLabelRtfAndText(richtext.Rtf, richtext.Text);
            elem.FreeCache();
        }
Пример #5
0
        public void SetFormatChanges(FormatChanges fc)
        {
            if (fc.color != Color.Empty)
                SelectionColor = fc.color;
            if (fc.font != null)
                SelectionFont = fc.font;

            STRUCT_CHARFORMAT2 cf2 = new STRUCT_CHARFORMAT2();
            if (fc.fontfamily != String.Empty)
            {
                cf2.dwMask |= CFM_FACE;
                cf2.szFaceName = fc.fontfamily;
            }
            if (fc.fontsize != 0f)
            {
                cf2.dwMask |= CFM_SIZE;
                cf2.yHeight = (int)(fc.fontsize * 20f); /*no idea if this is correct conversion*/
            }
            if (fc.bold != Ternary.Indeterminate)
            {
                cf2.dwMask |= CFM_BOLD;
                if (fc.bold == Ternary.Yes)
                    cf2.dwEffects |= CFE_BOLD;
            }
            if (fc.italic != Ternary.Indeterminate)
            {
                cf2.dwMask |= CFM_ITALIC;
                if (fc.italic == Ternary.Yes)
                    cf2.dwEffects |= CFE_ITALIC;
            }
            if (fc.underline != Ternary.Indeterminate)
            {
                cf2.dwMask |= CFM_UNDERLINE;
                if (fc.underline == Ternary.Yes)
                    cf2.dwEffects |= CFE_UNDERLINE;
            }
            if (fc.strikeout != Ternary.Indeterminate)
            {
                cf2.dwMask |= CFM_STRIKEOUT;
                if (fc.strikeout == Ternary.Yes)
                    cf2.dwEffects |= CFE_STRIKEOUT;
            }
            if (fc.superscript != Ternary.Indeterminate)
            {
                cf2.dwMask |= CFM_SUPERSCRIPT;
                if (fc.superscript == Ternary.Yes)
                    cf2.dwEffects |= CFE_SUPERSCRIPT;
            }
            if (fc.subscript != Ternary.Indeterminate)
            {
                cf2.dwMask |= CFM_SUBSCRIPT;
                if (fc.subscript == Ternary.Yes)
                    cf2.dwEffects |= CFE_SUBSCRIPT;
            }
            if (cf2.dwMask != 0)
                SetCharFormat(ref cf2);
        }
Пример #6
0
 public FormatChanges GetFormatChanges()
 {
     FormatChanges fc = new FormatChanges();
     fc.color = SelectionColor;
     fc.font = SelectionFont;
     STRUCT_CHARFORMAT2 cf2 = new STRUCT_CHARFORMAT2();
     GetCharFormat(ref cf2);
     if ((cf2.dwMask & CFM_BOLD) != 0)
         fc.bold = ((cf2.dwEffects & CFE_BOLD) != 0) ? Ternary.Yes : Ternary.No;
     if ((cf2.dwMask & CFM_ITALIC) != 0)
         fc.italic = ((cf2.dwEffects & CFE_ITALIC) != 0) ? Ternary.Yes : Ternary.No;
     if ((cf2.dwMask & CFM_UNDERLINE) != 0)
         fc.underline = ((cf2.dwEffects & CFE_UNDERLINE) != 0) ? Ternary.Yes : Ternary.No;
     if ((cf2.dwMask & CFM_SUPERSCRIPT) != 0)
         fc.superscript = ((cf2.dwEffects & CFE_SUPERSCRIPT) != 0) ? Ternary.Yes : Ternary.No;
     if ((cf2.dwMask & CFM_SUBSCRIPT) != 0)
         fc.subscript = ((cf2.dwEffects & CFE_SUBSCRIPT) != 0) ? Ternary.Yes : Ternary.No;
     if ((cf2.dwMask & CFM_STRIKEOUT) != 0)
         fc.strikeout = ((cf2.dwEffects & CFE_STRIKEOUT) != 0) ? Ternary.Yes : Ternary.No;
     if ((cf2.dwMask & CFM_FACE) != 0)
         fc.fontfamily = cf2.szFaceName;
     if ((cf2.dwMask & CFM_SIZE) != 0)
         fc.fontsize = cf2.yHeight / 20f; /*again, this may not be right. why 20?*/
     return fc;
 }