//======================================================================================== // DoImport() // The open/save dialog boxes reset the current working directory. We need // to preserve the working directory prior to invoking these dialogs and // restore it afterwards to ensure that System.Activator keeps working. //======================================================================================== private void DoImport(object sender, EventArgs e) { string curdir = Directory.GetCurrentDirectory(); DialogResult result = openDialog.ShowDialog(this); if (result == DialogResult.OK) { try { UserOptions.Load(openDialog.FileName); InternalReset(); } catch (Exception exc) { Logger.WriteLine("ERROR [" + exc.Message + "]", Color.Red); MessageBox.Show( translator.GetString("ImportError"), translator.GetString("ImportErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error ); } } Directory.SetCurrentDirectory(curdir); }
//======================================================================================== // DoExport() // The open/save dialog boxes reset the current working directory. We need // to preserve the working directory prior to invoking these dialogs and // restore it afterwards to ensure that System.Activator keeps working. //======================================================================================== private void DoExport(object sender, EventArgs e) { string curdir = Directory.GetCurrentDirectory(); DialogResult result = saveDialog.ShowDialog(this); if (result == DialogResult.OK) { XDocument doc = UserOptions.OptionsDoc; InternalSave(); try { UserOptions.Save(saveDialog.FileName); } catch (Exception) { MessageBox.Show( translator.GetString("ExportError"), translator.GetString("ExportErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error ); } finally { UserOptions.OptionsDoc = doc; } } Directory.SetCurrentDirectory(curdir); }
//======================================================================================== // SaveOptions() //======================================================================================== public override void SaveOptions() { UserOptions.SetValue("connections/loginTimeout", (int)loginTimeoutBox.Value); UserOptions.SetValue("connections/queryTimeout", (int)queryTimeoutBox.Value); UserOptions.SetValue( "connections/parseMode", ((ParseMode)parseModeBox.SelectedIndex).ToString()); UserOptions.SetValue("connections/planTable", planTableBox.Text); UserOptions.SetValue("connections/utilProcedure", utilProcedureBox.Text); }
//======================================================================================== // SaveOptions() //======================================================================================== public override void SaveOptions() { UserOptions.SetValue("results/general/target", (int)targetBox.SelectedIndex); UserOptions.SetValue("results/general/format", (int)formatBox.SelectedIndex); UserOptions.SetValue("results/general/delimeter", delimeterBox.Text); UserOptions.SetValue("results/general/maxChar", maxCharBox.Value.ToString()); UserOptions.SetValue("results/general/printHeader", printHeadersCheck.Checked); UserOptions.SetValue("results/general/scrollResults", scrollResultsCheck.Checked); UserOptions.SetValue("results/general/rightAlign", rightAlignCheck.Checked); UserOptions.SetValue("results/general/outputQuery", outputQueryCheck.Checked); UserOptions.SetValue("results/general/dbmsOutput", dbmsOutputCheck.Checked); UserOptions.SetValue("results/general/cleanNewlines", cleanNewlinesCheck.Checked); }
//======================================================================================== // Reset() //======================================================================================== public override void Reset() { sizeBox.Value = UserOptions.GetInt("editor/editorTabs/size"); if (UserOptions.GetBoolean("editor/editorTabs/keepTabs")) { keepTabsRadio.Checked = true; } else { insertSpacesRadio.Checked = true; } }
private void InternalSave() { IDictionaryEnumerator en = sheets.GetEnumerator(); SheetBase sheet; while (en.MoveNext()) { sheet = (SheetBase)en.Value; sheet.SaveOptions(); } UserOptions.Save(); }
private void InternalReset() { UserOptions.Reset(); IDictionaryEnumerator en = sheets.GetEnumerator(); SheetBase sheet; while (en.MoveNext()) { sheet = (SheetBase)en.Value; sheet.Reset(); } }
//======================================================================================== // Reset() //======================================================================================== public override void Reset() { loginTimeoutBox.Value = UserOptions.GetInt("connections/loginTimeout"); queryTimeoutBox.Value = UserOptions.GetInt("connections/queryTimeout"); parseModeBox.SelectedIndex = (int)Enum.Parse( typeof(Database.ParseMode), UserOptions.GetString("connections/parseMode"), false); planTableBox.Text = UserOptions.GetString("connections/planTable"); utilProcedureBox.Text = UserOptions.GetString("connections/utilProcedure"); }
//======================================================================================== // Reset() //======================================================================================== public override void Reset() { StatisticClass classes = (StatisticClass)UserOptions.GetInt("statistics/classifications"); userCheck.Checked = ((classes & StatisticClass.User) > 0); redoCheck.Checked = ((classes & StatisticClass.Redo) > 0); enqueueCheck.Checked = ((classes & StatisticClass.Enqueue) > 0); cacheCheck.Checked = ((classes & StatisticClass.Cache) > 0); osCheck.Checked = ((classes & StatisticClass.OS) > 0); parallelCheck.Checked = ((classes & StatisticClass.Parallel) > 0); sqlCheck.Checked = ((classes & StatisticClass.SQL) > 0); debugCheck.Checked = ((classes & StatisticClass.Debug) > 0); }
//======================================================================================== // SaveOptions() //======================================================================================== public override void SaveOptions() { UserOptions.SetValue("editor/general/showGutter", showGutterCheck.Checked); UserOptions.SetValue("editor/general/lineNumbers", lineNumbersCheck.Checked); UserOptions.SetValue("editor/general/gutterWidth", (int)gutterWidthBox.Value); UserOptions.SetValue("editor/general/showMargin", showMarginCheck.Checked); UserOptions.SetValue("editor/general/marginPosition", (int)marginPositionBox.Value); UserOptions.SetValue("editor/general/wordWrap", wordWrapCheck.Checked); UserOptions.SetValue("editor/general/wrapAtMargin", wrapAtMarginCheck.Checked); UserOptions.SetValue("editor/general/beyondEoln", beolnCheck.Checked); UserOptions.SetValue("editor/general/beyondEof", beofCheck.Checked); UserOptions.SetValue("editor/general/verticalScroll", vscrollCheck.Checked); UserOptions.SetValue("editor/general/horizontalScroll", hscrollCheck.Checked); }
//======================================================================================== // SaveOptions() //======================================================================================== public override void SaveOptions () { UserOptions.SetValue("editor/editorFonts/font/family", ((DisplayFont)familyBox.SelectedItem).Family.Name); UserOptions.SetValue("editor/editorFonts/font/size", (int)sizeBox.Value); var ns = UserOptions.OptionsDoc.Elements().First().GetDefaultNamespace(); var styles = UserOptions.OptionsDoc .Element(ns + "OrqaOptions") .Element(ns + "editor") .Element(ns + "editorFonts") .Element(ns + "lexStyles"); DisplayItem item; for (int i = 0; i < itemsBox.Items.Count; i++) { item = itemsBox.Items[i] as DisplayItem; if (item != null) { var node = styles.Element(item.InternalName); if (node != null) { var attribute = node.Attribute("foreColor"); if (attribute != null) { attribute.SetValue(item.ForeColor.IsKnownColor ? item.ForeColor.Name : item.ForeColor.ToArgb().ToString("x8")); } attribute = node.Attribute("backColor"); if (attribute != null) { attribute.SetValue(item.BackColor.IsKnownColor ? item.BackColor.Name : item.BackColor.ToArgb().ToString("x8")); } attribute = node.Attribute("style"); if (attribute != null) { attribute.SetValue(((int)item.FontStyle).ToString()); } } } } }
//======================================================================================== // SaveOptions() //======================================================================================== public override void SaveOptions() { UserOptions.SetValue("results/resultsFonts/font/family", ((DisplayFont)familyBox.SelectedItem).Family.Name); UserOptions.SetValue("results/resultsFonts/font/size", (int)sizeBox.Value); XPathNavigator nav = UserOptions.OptionsDoc.CreateNavigator(); nav.MoveToFirstChild(); nav = nav.SelectSingleNode("results/resultsFonts/lexStyles"); DisplayItem item; for (int i = 0; i < itemsBox.Items.Count; i++) { item = (DisplayItem)itemsBox.Items[i]; if (nav.MoveToChild(item.InternalName, nav.NamespaceURI)) { if (nav.MoveToAttribute("foreColor", nav.NamespaceURI)) { nav.SetValue(item.ForeColor.IsKnownColor ? item.ForeColor.Name : item.ForeColor.ToArgb().ToString("x8")); nav.MoveToParent(); } if (nav.MoveToAttribute("backColor", nav.NamespaceURI)) { nav.SetValue(item.BackColor.IsKnownColor ? item.BackColor.Name : item.BackColor.ToArgb().ToString("x8")); nav.MoveToParent(); } if (nav.MoveToAttribute("style", nav.NamespaceURI)) { nav.SetValue(((int)item.FontStyle).ToString()); nav.MoveToParent(); } nav.MoveToParent(); } } }
//======================================================================================== // Reset() //======================================================================================== public override void Reset() { queryDirBox.Text = UserOptions.GetString("general/queryPath"); resultsDirBox.Text = UserOptions.GetString("general/resultPath"); templateDirBox.Text = UserOptions.GetString("general/templatePath"); queryExtBox.Text = UserOptions.GetString("general/queryExtension"); reportExtBox.Text = UserOptions.GetString("general/reportExtension"); resultsExtBox.Text = UserOptions.GetString("general/resultExtension"); templateExtBox.Text = UserOptions.GetString("general/templateExtension"); maxMruBox.Value = UserOptions.GetInt("general/maxMru"); saveModifiedCheck.Checked = UserOptions.GetBoolean("general/saveModified"); savePositionCheck.Checked = UserOptions.GetBoolean("general/savePosition"); defaultAppCheck.Checked = UserOptions.GetBoolean("general/defaultApp"); }
//======================================================================================== // SaveOptions() //======================================================================================== public override void SaveOptions() { UserOptions.SetValue("general/queryPath", queryDirBox.Text); UserOptions.SetValue("general/resultPath", resultsDirBox.Text); UserOptions.SetValue("general/templatePath", templateDirBox.Text); UserOptions.SetValue("general/queryExtension", queryExtBox.Text); UserOptions.SetValue("general/reportExtension", reportExtBox.Text); UserOptions.SetValue("general/resultExtension", resultsExtBox.Text); UserOptions.SetValue("general/templateExtension", templateExtBox.Text); UserOptions.SetValue("general/maxMru", (int)maxMruBox.Value); UserOptions.SetValue("general/saveModified", saveModifiedCheck.Checked); UserOptions.SetValue("general/savePosition", savePositionCheck.Checked); UserOptions.SetValue("general/defaultApp", defaultAppCheck.Checked); }
//======================================================================================== // Reset() //======================================================================================== public override void Reset() { showGutterCheck.Checked = UserOptions.GetBoolean("editor/general/showGutter"); lineNumbersCheck.Checked = UserOptions.GetBoolean("editor/general/lineNumbers"); gutterWidthBox.Value = UserOptions.GetInt("editor/general/gutterWidth"); showMarginCheck.Checked = UserOptions.GetBoolean("editor/general/showMargin"); marginPositionBox.Value = UserOptions.GetInt("editor/general/marginPosition"); wordWrapCheck.Checked = UserOptions.GetBoolean("editor/general/wordWrap"); wrapAtMarginCheck.Checked = UserOptions.GetBoolean("editor/general/wrapAtMargin"); beolnCheck.Checked = UserOptions.GetBoolean("editor/general/beyondEoln"); beofCheck.Checked = UserOptions.GetBoolean("editor/general/beyondEof"); vscrollCheck.Checked = UserOptions.GetBoolean("editor/general/verticalScroll"); hscrollCheck.Checked = UserOptions.GetBoolean("editor/general/horizontalScroll"); DoToggleGutter(null, null); DoToggleWordWrap(null, null); }
//======================================================================================== // Reset() //======================================================================================== public override void Reset() { targetBox.SelectedIndex = (int)Enum.Parse( typeof(Database.ResultTarget), UserOptions.GetString("results/general/target"), false); formatBox.SelectedIndex = (int)Enum.Parse( typeof(Database.ResultFormat), UserOptions.GetString("results/general/format"), false); delimeterBox.Text = UserOptions.GetString("results/general/delimeter"); maxCharBox.Value = UserOptions.GetInt("results/general/maxChar"); printHeadersCheck.Checked = UserOptions.GetBoolean("results/general/printHeader"); scrollResultsCheck.Checked = UserOptions.GetBoolean("results/general/scrollResults"); rightAlignCheck.Checked = UserOptions.GetBoolean("results/general/rightAlign"); outputQueryCheck.Checked = UserOptions.GetBoolean("results/general/outputQuery"); dbmsOutputCheck.Checked = UserOptions.GetBoolean("results/general/dbmsOutput"); cleanNewlinesCheck.Checked = UserOptions.GetBoolean("results/general/cleanNewlines"); }
//======================================================================================== // SaveOptions() //======================================================================================== public override void SaveOptions() { StatisticClass classes = 0; if (userCheck.Checked) { classes |= StatisticClass.User; } if (redoCheck.Checked) { classes |= StatisticClass.Redo; } if (enqueueCheck.Checked) { classes |= StatisticClass.Enqueue; } if (cacheCheck.Checked) { classes |= StatisticClass.Cache; } if (osCheck.Checked) { classes |= StatisticClass.OS; } if (parallelCheck.Checked) { classes |= StatisticClass.Parallel; } if (sqlCheck.Checked) { classes |= StatisticClass.SQL; } if (debugCheck.Checked) { classes |= StatisticClass.Debug; } UserOptions.SetValue("statistics/classifications", (int)classes); }
//======================================================================================== // SaveOptions() //======================================================================================== public override void SaveOptions() { UserOptions.SetValue("editor/editorTabs/size", (int)sizeBox.Value); UserOptions.SetValue("editor/editorTabs/keepTabs", keepTabsRadio.Checked); }