public SqlEditor(Configuration cfg, ConnectionProvider provider, FileLink link) { InitializeComponent(cfg); this.cfg = cfg; this.provider = provider; textBox.Document.Blocks.Clear(); if (link != null) { this.link = link; string text = link.ReadAllText(); textBox.Document.Blocks.Add(new Paragraph(new Run(text))); } else { this.link = FileLink.CreateLink(untitled); } UpdateTitle(); tabControl.SelectionChanged += TabControl_SelectionChanged; textBox.SelectionChanged += TextBox_SelectionChanged; textBox.TextChanged += TextBox_TextChanged; textBox.Focus(); }
public void Open() { var openFile = new Microsoft.Win32.OpenFileDialog { Filter = "Sql Script Files (*.sql)|*.sql|Text Files (*.txt)|*.txt|All Files (*.*)|*.*", FileName = link.Url }; if (openFile.ShowDialog(this) == true) { link = FileLink.CreateLink(openFile.FileName); string text = link.ReadAllText(); textBox.Document.Blocks.Clear(); textBox.Document.Blocks.Add(new Paragraph(new Run(text))); UpdateTitle(); isDirty = false; } }