Exemplo n.º 1
0
def create_paragraph(file_lines):
    #Create a "Paragraph" object to hold all text from the file
    paragraph = Paragraph()
    #Text in the paragraph will have a font size of 16
    paragraph.FontSize = 16.0

    #Go through every line in the file passed in from the command
    #line...
    for x in file_lines:
        #...looking for Python/Ruby/PowerShell style comments
        if "#" in x:

            #Split the line whenever a comment is found
            first, second = x.split("#", 1)

            #Add the first part of the line to the paragraph
            paragraph.Inlines.Add(Run(first + "#"))

            #Split the second part of the line based on whitespace
            for y in second.split():
                #If the word is misspelled...
                if not check_word(y):
                    #Add a drop down menu to offer alternative
                    #spelling suggestions
                    c = ComboBox()
                    c.Background = Red
                    c.HorizontalAlignment = HorizontalAlignment.Left
                    #Add the misspelled word to the drop down menu
                    #and make is the first item
                    c.AddText(y)
                    c.SelectedItem = y
                    #Offer alternative spellings in the drop down menu
                    for suggest in suggestions(y):
                        c.AddText(suggest)
                    #Add the combo box to the drop down menu
                    paragraph.Inlines.Add(c)
                else:
                    paragraph.Inlines.Add(Run(y))
                paragraph.Inlines.Add(" ")
            paragraph.Inlines.Add(Run("\n"))
        else:
            #If there's no comment in the line, just directly
            #add it to the paragraph
            paragraph.Inlines.Add(Run(x))
    return paragraph
Exemplo n.º 2
0
    def _getTextBlock(rss):

        result = TextBlock()
        for item in rss:
            run = Run(item.Title)
            hlink = Hyperlink(run)

            hlink.NavigateUri = Uri(item.Url)
            hlink.Foreground = harriet.Setting.ChatWindowColor.Foreground
            hlink.RequestNavigate += _OnRequestNavigate

            result.Inlines.Add(hlink)
            result.Inlines.Add(LineBreak())
            result.Inlines.Add(LineBreak())

        return result
Exemplo n.º 3
0
def get_run(text, foreground):
    run = Run()
    run.Text = text
    if foreground is not None:
        run.Foreground = foreground
    return run
Exemplo n.º 4
0
def get_prompt(prompt):
    run = Run()
    run.Text = prompt
    run.Foreground = blue
    return run
Exemplo n.º 5
0
def get_run(text, foreground):
    run = Run()
    run.Text = text
    if foreground is not None:
        run.Foreground = foreground
    return run
Exemplo n.º 6
0
def get_prompt(prompt):
    run = Run()
    run.Text = prompt
    run.Foreground = blue
    return run