string path; // path to the User Options folder //======================================================================================== // Constructor //======================================================================================== public MruManager(ToolStripMenuItem fileMenu, MruCallback callback) { this.fileMenu = fileMenu; this.maxItems = UserOptions.GetInt("general/maxMru"); this.path = Environment.GetFolderPath( Environment.SpecialFolder.LocalApplicationData) + '\\' + System.Windows.Forms.Application.CompanyName + "\\" + System.Windows.Forms.Application.ProductName; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path += "\\Mru.orq"; this.callback = callback; }
//======================================================================================== // Initialize() //======================================================================================== public void Initialize() { // allow classes to be changed dynamically in run-time this.classes = UserOptions.GetInt("statistics/classifications"); // clear out the stats collection this.Clear(); // get an initial snapshot so we can calculate a delta with Summarize DataRowCollection rows = GetSnapshot(); Statistic stat; int classID; // build the statistics collection from the current snapshot foreach (DataRow row in rows) { classID = (int)(decimal)row["classID"]; if ((classes & classID) == classID) { stat = new Statistic(); stat.ClassID = classID; if (row["className"] == System.DBNull.Value) { stat.ClassName = String.Empty; } else { stat.ClassName = (string)row["className"]; } stat.StatID = (int)(decimal)row["statID"]; stat.Name = (string)row["name"]; stat.Initial = (int)(decimal)row["value"]; stat.Value = stat.Initial; stat.Total = stat.Initial; this.Add(stat.Name, stat); } } }
/// <summary> /// Initializes a new QueryWindow for design-time; this default constructor is /// required by the VS Forms designer. /// </summary> public QueryWindow() { InitializeComponent(); if (this.DesignMode) { return; } activePane = editorView; windowIsValid = true; this.HandleDestroyed += new EventHandler(DoHandleDestroyed); splitContainer.SplitterDistance = (int)(splitContainer.ClientSize.Height * 0.6); // initially hide the results pane splitContainer.Panel2Collapsed = true; var updateCommanderHandler = new EventHandler(UpdateCommander); var resultTargetChangedHandler = new ResultTargetChangedEventHandler(DoResultTargetChanged); editorView.Enter += updateCommanderHandler; editorView.ResultTargetChanged += resultTargetChangedHandler; resultsView.Enter += updateCommanderHandler; resultsView.TextChanged += updateCommanderHandler; //resultsView.ResultTargetChanged += resultTargetChangedHandler; queryID = ++count; queries = new QueryCollection(); this.ResultTarget = (ResultTarget)UserOptions.GetInt("results/general/target"); this.basePath = UserOptions.GetString("general/queryPath"); this.filename = null; }
//======================================================================================== // Execute() //======================================================================================== /// <summary> /// Executes the specified query. Results and error messages are stored in /// the query itself. /// </summary> /// <param name="query">The Query describing the SQL statement.</param> public void Execute(QueryCollection queries, string basePath, int repeat) { Logger.WriteLine("QueryDriver.Execute count=[" + queries.Count + "]"); // fetch this each time incase the user changes it. this.timeout = UserOptions.GetInt("connections/queryTimeout") * 1000; this.isExecuting = true; this.basePath = basePath; try { Logger.WriteLine("QueryDriver.Execute Starting driver..."); worker = new Thread(new ParameterizedThreadStart(Execute)); worker.Name = String.Format("QueryDriver{0}", driverID); worker.IsBackground = true; timer = new System.Threading.Timer( new TimerCallback(Cancel), worker, timeout, Timeout.Infinite ); var chassis = new Chassis(); chassis.queries = queries; chassis.repeat = repeat; worker.Start(chassis); } catch (Exception exc) { Dialogs.ExceptionDialog.ShowException(exc); } }
private int[] MeasureColumns(OraTable table) { int MAX = UserOptions.GetInt("results/general/maxChar"); int[] widths = new int[table.Schema.FieldCount]; int width; string text; int rowcount = table.Count; foreach (OraRow row in table) { for (int i = 0; i < table.Schema.FieldCount; i++) { width = table.Schema.GetName(i).Length; if (width > MAX) { width = MAX; } else { if (row[i] == null) { //width = 0; } else if (table.Schema.GetType(i) == typeof(Byte[])) { try { if (row[i].GetType() == typeof(DBNull)) { width = 0; } else { // x2 so we provide room to convert bytes to Hex width = ((Byte[])row[i]).Length * 2; } } catch (Exception exc) { //select name, typeicon from con_itemtype; string m = exc.Message; } } else { text = row[i].ToString(); if (text.Length > width) { width = (text.Length < MAX ? text.Length : MAX); } } } if (widths[i] < width) { widths[i] = width; } } } return(widths); }
//======================================================================================== // SetOptions() //======================================================================================== public void SetOptions() { string fontName = UserOptions.GetString("editor/editorFonts/font/family"); int fontSize = UserOptions.GetInt("editor/editorFonts/font/size"); editor.Font = new Font(fontName, fontSize); bool beyondEof = UserOptions.GetBoolean("editor/general/beyondEof"); bool beyondEoln = UserOptions.GetBoolean("editor/general/beyondEoln"); NavigateOptions navigateOptions = NavigateOptions.DownAtLineEnd | NavigateOptions.UpAtLineBegin; if (beyondEof) { navigateOptions |= NavigateOptions.BeyondEof; } if (beyondEoln) { navigateOptions |= NavigateOptions.BeyondEol; } editor.NavigateOptions = navigateOptions; editor.IndentOptions = IndentOptions.AutoIndent; bool verticalScroll = UserOptions.GetBoolean("editor/general/verticalScroll"); bool horizontalScroll = UserOptions.GetBoolean("editor/general/horizontalScroll"); if (verticalScroll && horizontalScroll) { editor.Scrolling.ScrollBars = RichTextBoxScrollBars.ForcedBoth; } else if (verticalScroll) { editor.Scrolling.ScrollBars = RichTextBoxScrollBars.ForcedVertical; } else if (horizontalScroll) { editor.Scrolling.ScrollBars = RichTextBoxScrollBars.ForcedHorizontal; } else { editor.Scrolling.ScrollBars = RichTextBoxScrollBars.None; } bool showGutter = UserOptions.GetBoolean("editor/general/showGutter"); int gutterWidth = UserOptions.GetInt("editor/general/gutterWidth"); bool lineNumbers = UserOptions.GetBoolean("editor/general/lineNumbers"); editor.Gutter.Visible = showGutter; editor.Gutter.Width = gutterWidth; editor.Gutter.Options = (lineNumbers ? GutterOptions.PaintLineNumbers | GutterOptions.PaintLinesOnGutter : GutterOptions.None); bool showMargin = UserOptions.GetBoolean("editor/general/showMargin"); int marginPosition = UserOptions.GetInt("editor/general/marginPosition"); bool wordWrap = UserOptions.GetBoolean("editor/general/wordWrap"); bool wrapAtMargin = UserOptions.GetBoolean("editor/general/wrapAtMargin"); editor.Margin.Visible = showMargin; editor.Margin.Position = marginPosition; editor.WordWrap = wordWrap; editor.WrapAtMargin = wrapAtMargin; SyntaxSettings settings = new SyntaxSettings(); bool keepTabs = UserOptions.GetBoolean("editor/editorTabs/keepTabs"); int tabSize = UserOptions.GetInt("editor/editorTabs/size"); editor.Source.Lines.TabStops = new int[1] { tabSize }; editor.Source.Lines.UseSpaces = !keepTabs; // set lex styles XPathNavigator nav = UserOptions.OptionsDoc.CreateNavigator(); nav.MoveToFirstChild(); nav = nav.SelectSingleNode("editor/editorFonts/lexStyles"); nav.MoveToFirstChild(); LexStyleItem item; string colorName; var foreground = FontsAndColors.PlainTextForeground; var background = FontsAndColors.PlainTextBackground; do { if (nav.NodeType == XPathNodeType.Element) { item = new LexStyleItem(); item.Name = nav.LocalName; item.InternalName = nav.LocalName; colorName = nav.GetAttribute("foreColor", nav.NamespaceURI); item.ForeColor = Color.FromName(colorName); if (!item.ForeColor.IsKnownColor) { item.ForeColor = Color.FromArgb(unchecked ((int)uint.Parse( colorName, System.Globalization.NumberStyles.HexNumber))); } if (item.Name.Equals("whitespace")) { foreground = item.ForeColor; } colorName = nav.GetAttribute("backColor", nav.NamespaceURI); item.BackColor = Color.FromName(colorName); if (!item.BackColor.IsKnownColor) { item.BackColor = Color.FromArgb(unchecked ((int)uint.Parse( colorName, System.Globalization.NumberStyles.HexNumber))); } if (item.Name.Equals("whitespace")) { background = item.BackColor; } item.FontStyle = (FontStyle)Enum.Parse( typeof(FontStyle), nav.GetAttribute("style", nav.NamespaceURI)); ApplyLeXStyle(item); } }while (nav.MoveToNext(XPathNodeType.Element)); editor.ForeColor = foreground; editor.BackColor = background; editor.Refresh(); }