private bool DoSave(QueryTab editor) { if (string.IsNullOrEmpty(editor.FileName)) { return(DoSaveAs(editor)); } return(SaveEditor(editor, editor.FileName)); }
private bool DoSaveAs(QueryTab editor) { saveFileDialog.FileName = editor.FileName; if (saveFileDialog.ShowDialog() != DialogResult.OK) { return(false); } return(SaveEditor(editor, saveFileDialog.FileName)); }
private QueryTab CreateQueryTab(string title, ConnectionInfo info) { var queryTab = new QueryTab(applicationService, serverList, info, applicationService.SubscriptionManager) { Dock = DockStyle.Fill }; AddNewTab(queryTab, title); return(queryTab); }
private QueryTab CreateQueryTab(string title, ConnectionInfo info) { var tab = new TabPage(title) { BorderStyle = BorderStyle.None, Padding = new Padding(0) }; var queryTab = new QueryTab { ConnectionInfo = info, Dock = DockStyle.Fill, ApplicationService = this }; tab.Controls.Add(queryTab); fileTabs.Controls.Add(tab); fileTabs.SelectedTab = tab; return(queryTab); }
private void OpenFiles(string[] fns) { var originalConnection = ActiveConnectionInfo; // Close default untitled document if it is still empty if (fileTabs.TabPages.Count == 1 && ActiveQueryTab.QueryText.Trim() == String.Empty) { RemoveQueryTab(ActiveQueryTab); } // Open file(s) foreach (string fn in fns) { QueryTab queryTab = null; try { var connectionInfo = originalConnection.Copy(); connectionInfo.Connect(); IMetadataProvider metadataProvider; _metadataProviders.TryGetValue(connectionInfo, out metadataProvider); queryTab = CreateQueryTab(Path.GetFileName(fn), connectionInfo, metadataProvider); queryTab.QueryText = File.ReadAllText(fn); // Modified flag is set during loading because the document // "changes" (from nothing to something). So, clear it again. queryTab.IsDirty = false; } catch (Exception ex) { MessageBox.Show(this, ex.Message, ex.GetType().Name); if (queryTab != null) { RemoveQueryTab(queryTab); } return; } // ICSharpCode.TextEditor doesn't have any built-in code folding // strategies, so I've included a simple one. Apparently, the // foldings are not updated automatically, so in this demo the user // cannot add or remove folding regions after loading the file. //-- editor.Document.FoldingManager.FoldingStrategy = new RegionFoldingStrategy(); //-- editor.Document.FoldingManager.UpdateFoldings(null, null); } }
private QueryTab CreateQueryTab(string title, ConnectionInfo info) { var queryTab = new QueryTab { ConnectionInfo = info, Dock = DockStyle.Fill, ApplicationService = this.applicationService, SubscriptionManager = this.applicationService.SubscriptionManager }; IMetadataProvider provider; this.serverList.TryGetProvider(info, out provider); queryTab.SetMetadataProvider(provider); AddNewTab(queryTab, title); return(queryTab); }
public void OpenFiles(string[] files) { var connectionInfo = this.connectionsManager.ResolveConnection(); if (connectionInfo == null) { return; } this.dockPanel.ColoseInitialDocument(); connectionInfo.Connect(); // Open file(s) foreach (string fn in files) { QueryTab queryTab = null; try { queryTab = this.CreateQueryTab(string.Empty, connectionInfo); queryTab.QueryText = File.ReadAllText(fn); queryTab.FileName = fn; // Modified flag is set during loading because the document // "changes" (from nothing to something). So, clear it again. queryTab.MarkSaved(); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().Name); if (queryTab != null) { this.dockPanel.RemoveTab(queryTab.Parent as DockContent); } return; } // ICSharpCode.TextEditor doesn't have any built-in code folding // strategies, so I've included a simple one. Apparently, the // foldings are not updated automatically, so in this demo the user // cannot add or remove folding regions after loading the file. //-- editor.Document.FoldingManager.FoldingStrategy = new RegionFoldingStrategy(); //-- editor.Document.FoldingManager.UpdateFoldings(null, null); } }
private bool SaveEditor(QueryTab editor, string fileName) { try { File.WriteAllText(fileName, editor.QueryText); editor.FileName = fileName; editor.MarkSaved(); // The syntax highlighting strategy doesn't change // automatically, so do it manually. //editor.Document.HighlightingStrategy = // HighlightingStrategyFactory.CreateHighlightingStrategyForFile(editor.FileName); return(true); } catch (Exception ex) { MessageBox.Show(this, ex.Message, ex.GetType().Name); return(false); } }
private void FilesDock_ActiveContentChanged(object sender, EventArgs e) { this.RefreshSelectedConnections(); IConnectionTab activeConnectionTab = this.filesDock.ActiveConnectionTab; if (activeConnectionTab != null) { this.SelectedConnection = activeConnectionTab.ConnectionInfo; } var activeTab = filesDock.ActiveQueryTab; if (lastActiveTab != null && activeTab != lastActiveTab) { lastActiveTab.HideFindReplaceDialog(); } lastActiveTab = activeTab; }
private QueryTab CreateQueryTab(string title, ConnectionInfo info) { var tab = new TabPage(title) { BorderStyle = BorderStyle.None, Padding = new Padding(0) }; var queryTab = new QueryTab { ConnectionInfo = info, Dock = DockStyle.Fill, ApplicationService = this }; tab.Controls.Add(queryTab); fileTabs.Controls.Add(tab); fileTabs.SelectedTab = tab; info.ConnectionClosed += (sender, args) => { RemoveQueryTab(queryTab); Application.DoEvents(); }; return(queryTab); }
private void CloneActiveTabWithNewQuery(string query) { QueryTab tab = CreateQueryTab(ActiveConnectionTab.ConnectionInfo.Title, ActiveConnectionTab.ConnectionInfo); tab.QueryText = query; }
private QueryTab CreateQueryTab(string title, ConnectionInfo info) { var tab = new TabPage(title) { BorderStyle = BorderStyle.None, Padding = new Padding(0) }; var queryTab = new QueryTab { ConnectionInfo = info, Dock = DockStyle.Fill, ApplicationService = this }; tab.Controls.Add(queryTab); fileTabs.Controls.Add(tab); fileTabs.SelectedTab = tab; info.ConnectionClosed += (sender, args) => { RemoveQueryTab(queryTab); Application.DoEvents(); }; return queryTab; }