Posted
public void Addtab(string text = "")
{
TabItem tabItem = new TabItem();
this.tabcontrol.Items.Add(tabItem);
tabItem.IsSelected = true;
TextEditor textEditor = new TextEditor();
textEditor.FontFamily = new FontFamily("Segoe UI");
textEditor.FontSize = 13.0;
textEditor.Background = new SolidColorBrush(Color.FromRgb(23, 23, 23));
textEditor.LineNumbersForeground = new SolidColorBrush(Color.FromRgb(128, 128, 128));
textEditor.BorderBrush = new SolidColorBrush(Color.FromRgb(100, 100, 100));
textEditor.BorderThickness = new Thickness(1.0, 1.0, 1.0, 1.0);
textEditor.Foreground = new SolidColorBrush(Color.FromRgb(byte.MaxValue, byte.MaxValue, byte.MaxValue));
textEditor.ShowLineNumbers = true;
textEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
textEditor.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
textEditor.Style = (base.TryFindResource("TextEditorStyle1") as Style);
tabItem.Style = (base.TryFindResource("tub") as Style);
tabItem.Content = textEditor;
tabItem.Header = "Script_" + (this.tabcontrol.Items.Count + 1).ToString() + ".lua";
tabItem.IsSelected = true;
tabItem.Loaded += delegate(object sender, RoutedEventArgs e)
{
tabItem.ApplyTemplate();
System.Windows.Controls.Button button = tabItem.Template.FindName("closebooton", tabItem) as System.Windows.Controls.Button;
((button != null) ? button : null).Click += delegate(object btn_sender, RoutedEventArgs btn_e)
{
this.tabcontrol.Items.Remove(tabItem);
};
};
textEditor.Options.EnableHyperlinks = false;
textEditor.Text = text;
textEditor.Options.ShowSpaces = false;
textEditor.Options.ShowTabs = true;
}
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post