Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a textblock that overlines a string, is there a way to save the string inside the textblock with the overline to another string.
My end goal is to be able to stack overlines on top of eachother, im trying to make a boolean expression writer and i cant really find anything on how to draw stacked lines on top of text.

What I have tried:

C#
private void setExpressionSegment(parentControl x)
        {
            if (x.GetType() == typeof(OUTPUT)) return;
            if (x.GetType() == typeof(AND))
            {
                x.boolean = "(" + x.inp1Boolean + "." + x.inp2Boolean + ")";
                expressionBox.TextDecorations = null;
            }
            else if (x.GetType() == typeof(OR))
            {
                x.boolean = "(" + x.inp1Boolean + "+" + x.inp2Boolean + ")";
                expressionBox.TextDecorations = null;
            }
            else if (x.GetType() == typeof(XOR))
            {
                x.boolean = "(" + x.inp1Boolean + "⊕" + x.inp2Boolean + ")";
                expressionBox.TextDecorations = null;
            }
            else if (x.GetType() == typeof(NAND))
            {
                x.boolean = "!(" + x.inp1Boolean + "." + x.inp2Boolean + ")";
                expressionBox.TextDecorations = TextDecorations.OverLine;
            }
            else if (x.GetType() == typeof(NOR))
            {
                x.boolean = "!(" + x.inp1Boolean + "+" + x.inp2Boolean + ")";
                expressionBox.TextDecorations = TextDecorations.OverLine;
            }
            else if (x.GetType() == typeof(NOT))
            {
                x.boolean = "!" + x.inp2Boolean;
                expressionBox.TextDecorations = TextDecorations.OverLine;
            }
            expressionBox.Text = x.boolean;
        }

if i could save the overlined text to a string then i could add it back to the textblock and overline it, just not sure how.
Posted
Updated 6-Nov-22 19:29pm

1 solution

You can create your own markup when you save the text, and remove it when you restore. e.g.

Plain: text
Overline: .ol text

C#
string s = "text";
s = ".ol " + s;

if ( s.StartsWith( ".ol " ) ) {
   s = s.Substring( 4 );
   // etc.
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900