public static bool OpenSharedScript(IPragmaEditor currentEditor, ConnectionParams cp) { if (currentEditor != null && currentEditor.ContentModified) { DialogResult dlgRes = MessageBox.Show("Save changes to \"" + currentEditor.Caption + "\" before opening another script in current script editor", "Save Script", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dlgRes == DialogResult.Cancel) { return(false); } else if (dlgRes == DialogResult.Yes) { currentEditor.SaveContent(); } } SharedScriptsItemData data = frmSharedScriptSelectDialog.ShowOpenSharedScriptDialog_SingleSelect(); if (data != null && currentEditor != null) { currentEditor.Caption = data.Name; currentEditor.Icon = PragmaSQL.Properties.Resources.sharedScript; currentEditor.ContentPersister = new SharedScriptContentPersister(); currentEditor.ContentPersister.Data = data; currentEditor.ContentPersister.Hint = "This is a shared script: " + data.Name; currentEditor.ContentInfo = currentEditor.ContentPersister.Hint; currentEditor.ContentPersister.FilePath = data.Name; currentEditor.ActiveDocument.TextContent = data.Script; currentEditor.ContentModified = false; return(true); } else { return(false); } }
private void btnSaveChecked_Click(object sender, EventArgs e) { foreach (ListViewItem item in lv.Items) { IPragmaEditor editor = item.Tag as IPragmaEditor; if (item.Checked) { editor.SaveContent(); } editor.CheckSave = false; } DialogResult = DialogResult.OK; }
public static bool OpenSharedScripts(IPragmaEditor currentEditor, ConnectionParams cp) { bool result = false; if (currentEditor != null && currentEditor.ContentModified) { DialogResult dlgRes = MessageBox.Show("Save changes to \"" + currentEditor.Caption + "\" before opening another script in current script editor", "Save Script", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dlgRes == DialogResult.Cancel) { return(false); } else if (dlgRes == DialogResult.Yes) { currentEditor.SaveContent(); } } IList <IPragmaEditor> editors = new List <IPragmaEditor>(); IList <SharedScriptsItemData> scripts = frmSharedScriptSelectDialog.ShowOpenSharedScriptDialog_MultiSelect(); int i = 0; IPragmaEditor frm = null; foreach (SharedScriptsItemData data in scripts) { if (data.Type != GenericItemType.Item) { continue; } i++; if (i == 1 && currentEditor != null) { currentEditor.Caption = data.Name; currentEditor.Icon = PragmaSQL.Properties.Resources.sharedScript; currentEditor.ContentPersister = new SharedScriptContentPersister(); currentEditor.ContentPersister.Data = data; currentEditor.ContentPersister.Hint = "This is a shared script: " + data.Name; currentEditor.ContentInfo = currentEditor.ContentPersister.Hint; currentEditor.ContentPersister.FilePath = data.Name; currentEditor.ActiveDocument.TextContent = data.Script; currentEditor.ContentModified = false; result = true; continue; } if (cp != null) { frm = ScriptEditorFactory.OpenSharedScript(data, cp); editors.Add(frm); } else { frm = TextEditorFactory.OpenSharedScript(data); editors.Add(frm); } } foreach (IPragmaEditor editor in editors) { if (editor is frmScriptEditor) { ScriptEditorFactory.ShowScriptEditor(editor as frmScriptEditor); } else if (editor is frmTextEditor) { TextEditorFactory.ShowTextEditor(editor as frmTextEditor); } } return(result); }