public static frmTextEditor OpenSharedSnippet(SharedSnippetItemData itemData) { string caption = String.Empty; string script = String.Empty; if (itemData == null) { throw new NullParameterException("ItemData is null!"); } caption = itemData.Name + "{Shared snippet}"; script = itemData.Snippet; frmTextEditor frm = new frmTextEditor(); frm.Icon = PragmaSQL.Properties.Resources.sharedSnippet; frm.ContentPersister = new SharedSnippetContentPersister(); frm.ContentPersister.Data = itemData; frm.ContentPersister.Hint = "This is a shared snippet: " + itemData.Name; frm.ContentInfo = frm.ContentPersister.Hint; frm.ContentPersister.ContentName = itemData.Name; frm.InitializeScriptEditor(caption, script, DBObjectType.None); return(frm); }
internal static frmTextEditor Create(string caption, string script, string syntaxMode, string filePath) { int?windowNo = Numerator.NextNumber; if (!windowNo.HasValue) { _instanceCnt++; windowNo = _instanceCnt; } string c = String.IsNullOrEmpty(caption) ? String.Format("Text {0}", windowNo) : caption; frmTextEditor frm = new frmTextEditor(); frm.WindowNo = windowNo; frm.InitializeTextEditor(c, script); if (!String.IsNullOrEmpty(syntaxMode)) { frm.SetSyntaxMode(syntaxMode); } if (!String.IsNullOrEmpty(filePath)) { frm.SetFilePath(filePath); } return(frm); }
internal static frmTextEditor OpenSharedScript(SharedScriptsItemData itemData) { string caption = String.Empty; string script = String.Empty; if (itemData == null) { throw new NullParameterException("ItemData is null!"); } caption = itemData.Name; script = itemData.Script; frmTextEditor frm = new frmTextEditor(); frm.Icon = PragmaSQL.Properties.Resources.sharedScript; frm.ContentPersister = new SharedScriptContentPersister(); frm.ContentPersister.Data = itemData; frm.ContentPersister.Hint = "This is a shared script: " + itemData.Name; frm.ContentInfo = frm.ContentPersister.Hint; frm.ContentPersister.FilePath = itemData.Name; frm.InitializeTextEditor(caption, script); return(frm); }
public static frmTextEditor Create(string caption, string script, int objType) { frmTextEditor frm = new frmTextEditor(); frm.InitializeScriptEditor(caption, script, objType); return(frm); }
internal static frmTextEditor CreateSharedSnippet(string caption, string snippet) { frmTextEditor frm = new frmTextEditor(); frm.Icon = PragmaSQL.Properties.Resources.sharedSnippet; frm.ContentPersister = new SharedSnippetContentPersister(); frm.InitializeTextEditor(caption, snippet); return(frm); }
internal static frmTextEditor OpenFile(string fileName) { frmTextEditor frm = Create(); if (!frm.OpenFile(fileName)) { frm.Close(); frm.Dispose(); return(null); } frm.ContentPersister.ContentType = EditorContentType.File; return(frm); }
public static frmTextEditor OpenFile(string fileName) { frmTextEditor frm = Create(); if (!frm.OpenFile(fileName)) { _instanceCnt--; frm.Close(); frm.Dispose(); return(null); } return(frm); }
public void LoadTextFile(string fileName) { frmTextEditor frm = null; try { frm = TextEditorFactory.OpenFile(fileName); TextEditorFactory.ShowTextEditor(frm); } catch (Exception ex) { frm.Dispose(); frm = null; throw ex; } }
public void CreateTextEditor(string caption, string script) { frmTextEditor frm = null; try { frm = TextEditorFactory.Create(caption, script); TextEditorFactory.ShowTextEditor(frm); } catch (Exception ex) { frm.Dispose(); frm = null; throw ex; } }
public static void ShowTextEditor(frmTextEditor frm) { if (frm == null) { return; } if (Program.MainForm.DockPanel.DocumentStyle == DocumentStyles.SystemMdi) { frm.MdiParent = Program.MainForm; frm.Show(); } else if (Program.MainForm.DockPanel.DocumentStyle == DocumentStyles.DockingWindow) { frm.Show(); } else { frm.Show(Program.MainForm.DockPanel); } }
internal static void ShowTextEditor(frmTextEditor frm) { if (frm == null) { return; } if (Program.MainForm.DockPanel.DocumentStyle == DocumentStyle.SystemMdi) { frm.MdiParent = Program.MainForm; frm.Show(); frm.WindowState = System.Windows.Forms.FormWindowState.Maximized; } else if (Program.MainForm.DockPanel.DocumentStyle == DocumentStyle.DockingWindow) { frm.Show(); } else { frm.Show(Program.MainForm.DockPanel); } }
private void btnNewScript_Click(object sender, EventArgs e) { frmTextEditor editor = TextEditorFactory.Create(); TextEditorFactory.ShowTextEditor(editor); }
private void PerformRestore() { ConnectionParams cp = null; IList <frmTextEditor> textEditors = new List <frmTextEditor>(); IList <frmScriptEditor> scriptEditors = new List <frmScriptEditor>(); StringBuilder sbErrors = new StringBuilder(); bool showTextEditorInfoHeader = false; bool failedConnections = false; string scriptWarningText = String.Empty; InitializeProgress(lv.CheckedItems.Count); try { foreach (ListViewItem lvItem in lv.Items) { cp = null; scriptWarningText = String.Empty; RecoverContent item = lvItem.Tag as RecoverContent; if (!lvItem.Checked || item == null) { continue; } string itemCaption = item.Title; failedConnections = false; showTextEditorInfoHeader = false; frmTextEditor txtEditor = null; frmScriptEditor scriptEditor = null; try { if (item.ItemType == RecoverContentType.Script || item.ItemType == RecoverContentType.ScriptFile) { if (item.HasConnectionInfo) { cp = PrepareWorkspaceItemConnection(item, out failedConnections); if (cp == null && !failedConnections) { Utils.ShowWarning(String.Format(Properties.Resources.RecoverScriptWarning, item.Database, item.Server), MessageBoxButtons.OK); } } if (cp == null) { item.SyntaxMode = "SQL"; if (item.ItemType == RecoverContentType.Script) { item.ItemType = RecoverContentType.Text; } else if (item.ItemType == RecoverContentType.ScriptFile) { item.ItemType = RecoverContentType.TextFile; } showTextEditorInfoHeader = true; scriptWarningText = !item.HasConnectionInfo ? Properties.Resources.RecoverScript_NoConnWarningInfoHeader : String.Format(Properties.Resources.RecoverScriptWarningInfoHeader, item.Database, item.Server); } else { if (item.ItemType == RecoverContentType.Script) { scriptEditor = ScriptEditorFactory.CreateWithAsyncConnection(itemCaption, item.Content, cp, cp.Database, String.Empty); } else if (item.ItemType == RecoverContentType.ScriptFile) { scriptEditor = ScriptEditorFactory.CreateWithAsyncConnection(itemCaption, item.Content, cp, cp.Database, item.FileName); } scriptEditor.Uid = item.Uid; scriptEditor.IsRecoveredContent = true; scriptEditor.ObjectType = item.ObjectType; if (OpMode == OperationMode.Recover) { scriptEditor.ShowInfo(String.Format("Recovered content. Content automatically saved on {0}", DateTime.FromFileTime(item.Time))); } scriptEditors.Add(scriptEditor); } } txtEditor = null; switch (item.ItemType) { case RecoverContentType.Script: case RecoverContentType.ScriptFile: break; case RecoverContentType.SharedScript: txtEditor = TextEditorFactory.CreateSharedScript(itemCaption, item.Content); txtEditor.SetSyntaxMode("SQL"); txtEditor.Uid = item.Uid; txtEditor.IsRecoveredContent = true; break; case RecoverContentType.SharedSnippet: txtEditor = TextEditorFactory.CreateSharedSnippet(itemCaption, item.Content); txtEditor.SetSyntaxMode("SQL"); txtEditor.Uid = item.Uid; txtEditor.IsRecoveredContent = true; break; case RecoverContentType.Text: txtEditor = TextEditorFactory.Create(itemCaption, item.Content, item.SyntaxMode); txtEditor.Uid = item.Uid; txtEditor.IsRecoveredContent = true; break; case RecoverContentType.TextFile: txtEditor = TextEditorFactory.Create(itemCaption, item.Content, item.SyntaxMode, item.FileName); txtEditor.Uid = item.Uid; txtEditor.IsRecoveredContent = true; break; default: throw new Exception(String.Format("Unknowm item type: {0}", item.ItemType)); } if (txtEditor != null) { if (showTextEditorInfoHeader) { txtEditor.ShowInfo(scriptWarningText); } else if (OpMode == OperationMode.Recover) { txtEditor.ShowInfo(String.Format("Recovered content. Automatically saved on: {0}", DateTime.FromFileTime(item.Time))); } textEditors.Add(txtEditor); } ChangeProgress(String.Format("Restoring {0}", item.Title)); } catch (Exception ex) { sbErrors.AppendLine(String.Format("- Can not restore '{0} ({1})'. Error: {2}", item.Title, item.ItemType, ex.Message)); } Application.DoEvents(); } } finally { ResetProgress(); } try { this.Visible = false; foreach (frmTextEditor editor in textEditors) { TextEditorFactory.ShowTextEditor(editor); } foreach (frmScriptEditor editor in scriptEditors) { ScriptEditorFactory.ShowScriptEditor(editor); } } catch (Exception ex) { this.Visible = true; throw ex; } if (sbErrors.Length > 0) { GenericErrorDialog.ShowError("Content Restore Error", "Some content items can not be restored.", sbErrors.ToString()); } }
private void OnAction_OpenFromFile_Execute(object sender, EventArgs e) { frmTextEditor editor = TextEditorFactory.OpenFile(String.Empty); TextEditorFactory.ShowTextEditor(editor); }
private void OnAction_NewScript_Execute(object sender, EventArgs e) { frmTextEditor editor = TextEditorFactory.Create(); TextEditorFactory.ShowTextEditor(editor); }