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
def createComboAndCheck(self, grid): panel = StackPanel() label = Label() label.Content = "CheckBox & ComboBox" label.FontSize = 16 label.Margin = Thickness(10) check = CheckBox() check.Content = "CheckBox" check.Margin = Thickness(10) check.FontSize = 16 check.IsChecked = True def action(s, e): checked = check.IsChecked self.label.Content = "CheckBox IsChecked = %s" % checked check.Checked += action check.Unchecked += action combo = ComboBox() for entry in ("A ComboBox", "An Item", "The Next One", "Another"): item = ComboBoxItem() item.Content = entry item.FontSize = 16 combo.Items.Add(item) combo.SelectedIndex = 0 combo.Height = 26 def action(s, e): selected = combo.SelectedIndex self.label.Content = "ComboBox SelectedIndex = %s" % selected combo.SelectionChanged += action combo.FontSize = 16 combo.Margin = Thickness(10) panel.Children.Add(label) panel.Children.Add(combo) panel.Children.Add(check) SetGridChild(grid, panel, 0, 1, "ComboBox & CheckBox")
def onKeyDown(sender, kea): kea.Handled = True postMenuItem = MenuItem() postMenuItem.KeyDown += onKeyDown menuItem.Items.Add(postMenuItem) stackPanel = StackPanel() stackPanel.HorizontalAlignment = HorizontalAlignment.Left stackPanel.VerticalAlignment = VerticalAlignment.Top stackPanel.Orientation = Orientation.Horizontal postMenuItem.Header = stackPanel comboBox = ComboBox() comboBox.IsEditable = True comboBox.Width = 240 comboBox.MouseUp += onMouseUp stack = Stack[String]() for window in Application.Current.Windows: if clr.GetClrType(Agent).IsInstanceOfType(window): for message in window.Balloon.Messages: stack.Push(String.Format("\"{0}: {1}\"", sb.ToString(), Regex.Replace(message.Text, Environment.NewLine, String.Empty, RegexOptions.CultureInvariant))) while stack.Count > 0: comboBoxItem = ComboBoxItem() comboBoxItem.Content = stack.Pop() comboBox.Items.Add(comboBoxItem)
def __init__(self, h): self.ctrl = ComboBox() self.Initialize(h) self.init_ComboBox(h) self.ctrl.IsEditable = True self.ctrl.IsReadOnly = False
def __init__(self, h): self.ctrl = ComboBox() self.Initialize(h) self.init_ComboBox(h)