private void OnClick_LoadScript(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.AddExtension = true; dlg.DefaultExt = ".bql"; dlg.Title = "Specify the script file"; dlg.Filter = "Building Query Language|*.bql"; dlg.FilterIndex = 0; dlg.ValidateNames = true; dlg.FileOk += delegate(object s, System.ComponentModel.CancelEventArgs eArg) { Stream file = null; string dataFormat = "Text"; try { file = dlg.OpenFile(); TextRange txtRange = new TextRange(ScriptText.Document.ContentStart, ScriptText.Document.ContentEnd); if (txtRange.CanLoad(dataFormat)) { txtRange.Load(file, dataFormat); } this.Title = "BQL Console - " + System.IO.Path.GetFileName(dlg.FileName); } catch (Exception ex) { System.Windows.MessageBox.Show(string.Format("Loading script from file failed : {0}.", ex.Message), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { if (file != null) { file.Close(); } } }; dlg.ShowDialog(); ScriptText.RefreshKeyColour(); }
/// <summary> /// On Click for turning key word colour on/off /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnClick_KeyWordColour(object sender, RoutedEventArgs e) { ScriptText.KeyColour = (bool)KeyWordColour.IsChecked; ScriptText.RefreshKeyColour(); }