public void MyDrawNode(object sender, DrawTreeNodeEventArgs e) { e.DrawDefault = true; if (e.Bounds.Width >= 300) { ObjectsTreeNode objectNode = e.Node as ObjectsTreeNode; string txt = objectNode.rightStuff; if (txt != null && txt != "") { using (StringFormat sf = new StringFormat()) { int left = e.Bounds.Left + FormsToolbox.GetTextWidth(e.Node.Text + "00", Font); sf.Trimming = StringTrimming.EllipsisCharacter; sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Far; using (Brush gray = new SolidBrush(UI.passiveForecolor1)) { e.Graphics.DrawString(txt, SystemFonts.MessageBoxFont, gray, new Rectangle(left, e.Bounds.Top, e.Bounds.Width - left, e.Bounds.Height), sf); } } } } }
public bool ColumnDataTruncated(int col) { if (query == null) { return(false); } int dataWidth = FormsToolbox.GetTextWidth(Math.Min(100, query.columns[col].maxLength), Font); return(dataWidth > Columns[col].Width); }
public EditorHeaderDropdown(string nam) { Text = nam; dropDownimageIndex = 4; nam = nam.ToLower(); Name = nam.ToLower() + "Combo"; // combo.FormattingEnabled = true; Location = new System.Drawing.Point(0, 0); TabIndex = 0; Font = SystemFonts.MessageBoxFont; Width = FormsToolbox.GetTextWidth(Text + "0000", Font); Height = Math.Max(20, FormsToolbox.GetTextHeight(Text + "0000", Font)); // SetStyle(ControlStyles.UserPaint, true); }
public static string FitText(this string txt, int width, Font font) { if (FormsToolbox.GetTextWidth(txt, font) > width) { for (int i = (txt.Length - 3) / 2; i > 5; i -= 1) { string test = txt.Left(i) + "..." + txt.Right(i); if (FormsToolbox.GetTextWidth(test, font) < width) { return(test); } } } return(txt); }
private void UpdateLeftPanelLayout(bool onlyButtons = false) { if (leftTabs == null) { return; } int buttonSize = 32; int offset = 0; leftTabs.UpdateTabs(); leftTabs.Top = 0; // menu.Bottom + 10; leftTabs.Left = offset; leftTabs.Width = horzSplitter.Panel1.ClientRectangle.Width - offset; leftTabs.BlankSpaceToRightOfTabs = buttonSize * 5; leftTabs.SendToBack(); leftTabs.UpdateTabs(); Rectangle rc = new Rectangle(leftTabs.MoreButtonLeft, leftTabs.Bottom - (buttonSize + leftTabs.BottomLineWidth), buttonSize, buttonSize); rc.Offset(-buttonSize, 0); int width = buttonSize + FormsToolbox.GetTextWidth("STOP", goButton.Font); goButton.Bounds = new Rectangle(rc.Right - width, rc.Top, width, rc.Height); rc.Offset(-buttonSize, 0); addButton.Bounds = new Rectangle(leftTabs.RightExtent, rc.Top, rc.Width, rc.Height); if (onlyButtons) { return; } int top = leftTabs.Bottom; editorHeader.Width = horzSplitter.Panel1.ClientRectangle.Width - offset; editorHeader.Top = top; top = editorHeader.Bottom; vertSplitter.Bounds = new Rectangle(offset, top, horzSplitter.Panel1.ClientRectangle.Width - offset, horzSplitter.Panel1.ClientRectangle.Height - (top)); /* * rc = vertSplitter.Panel2.ClientRectangle; * top = 200; * editorDropdown.Bounds = new Rectangle(rc.Left, rc.Top, rc.Width, top); * resultsList.Bounds = new Rectangle(rc.Left, top, rc.Width, rc.Height - top); */ }
public void FitDataInColumn(int col, bool toggle = false) { if (query != null && col > 0 && col < query.columns.Count) { QueryColumnInfo columnInfo = query.columns[col]; columnInfo.fitData = (toggle && columnInfo.fitData) ? false : true; Columns[col].Width = columnInfo.fitData ? Math.Max(columnInfo.defaultWidth, FormsToolbox.GetTextWidth(Math.Min(100, columnInfo.maxLength), Font)) : columnInfo.width; Invalidate(true); } }
public main() { Font = SystemFonts.MessageBoxFont; InitializeComponent(); A.Initialize(this); ToolButton.toolTip = ToolCheckBox.toolTip = toolTip; Wait.form = this; UI.LoadPreferences(); focusTextbox.BackColor = horzSplitter.Panel1.BackColor = horzSplitter.Panel2.BackColor = vertSplitter.Panel1.BackColor = vertSplitter.Panel2.BackColor = UI.passiveBackColor; SuspendLayout(); goButton = new ToolButton(bigButtonImages, 0, new EventHandler(OnRunClicked), null); goButton.SetText("Go"); horzSplitter.Panel1.Controls.Add(goButton); addButton = new ToolButton(bigButtonImages, 7, new EventHandler(OnNewClicked), "New Query"); horzSplitter.Panel1.Controls.Add(addButton); leftTabs = new NiceTabControl(); leftTabs.MinHeight = 32; leftTabs.ContextMenuStrip = this.tabContextMenu; leftTabs.ImageList = bigButtonImages; leftTabs.DropdownImageIndex = 6; leftTabs.OnSelectedTabChanged += new EventHandler(OnLeftTabChanged); horzSplitter.Panel1.Controls.Add(leftTabs); rightTabs = new NiceTabControl(); rightTabs.ImageList = bigButtonImages; rightTabs.MinHeight = 32; rightTabs.DropdownImageIndex = 6; rightTabs.OnSelectedTabChanged += new EventHandler(OnRightTabChanged); rightTabs.AddTab("Structure", objectSplitter); // , S.Get("showDatabaseObjects", true)); rightTabs.AddTab("Query History", queryHistory); // , Settings.Get("showQueryHistory", false)); rightTabs.AddTab("Log", logTextBox); // , Settings.Get("showLog", false)); horzSplitter.Panel2.Controls.Add(rightTabs); allObjectsTree = CreateObjectTree(objectSplitter.Panel2, "allObjectsTree", "All Objects"); objectSplitter.Panel2.Controls.Add(allObjectsTree); activeObjectsTree = CreateObjectTree(objectSplitter.Panel1, "activeObjectsTree", "Active Objects"); objectSplitter.Panel1.Controls.Add(activeObjectsTree); rowCount.Width = FormsToolbox.GetTextWidth("00000000000000", Font); queryTime.Width = FormsToolbox.GetTextWidth(" 00:00 ", Font); rowCount.Text = queryTime.Text = ""; autoComplete = new AutoSuggest(this, editor); Controls.Add(autoComplete); editorHeader = new EditorHeader(this, autoComplete); horzSplitter.Panel1.Controls.Add(editorHeader); resultsList = new ResultsListView(this); resultsList.ContextMenuStrip = resultsMenu; vertSplitter.Panel2.Controls.Add(resultsList); Query.resultsList = resultsList; clipboardHelper = new ClipboardHelper(editor, logTextBox, resultsList); queryHistory = new QueryListView(); queryHistory.ContextMenuStrip = queryHistoryMenuStrip; horzSplitter.Panel2.Controls.Add(queryHistory); UpdateUIPreferences(false); Parser.onParsed = OnParsed; objectSplitter.SplitterWidth = vertSplitter.SplitterWidth = horzSplitter.SplitterWidth = 10; ResumeLayout(); background.DoWork += new System.ComponentModel.DoWorkEventHandler(BackgroundInitialize); Background.status = BackgroundStatus.Loading; background.RunWorkerAsync(); Width = Math.Max(600, T.Coalesce(S.initSettings.width, 900)); Height = Math.Max(400, T.Coalesce(S.initSettings.height, 600)); editor.MouseDown += new MouseEventHandler(OnEditorMouseDown); editor.KeyDown += new KeyEventHandler(OnEditorKeyDown); editor.Leave += new EventHandler(OnEditorLostFocus); timer.Tick += OnIdle; loading = new Loading(this); StartBackgroundLoading(); Application.Idle += OnIdle; queryHistory.dirty = true; }
public bool UpdateSuggestions(SuggestionList suggestions, Point p) { suggestionList = suggestions; theList.Sorted = false; // !suggestionList.queryMode; Point pOrig = p; p = parent.PointToClient(p); leftWidth = 0; rightWidth = 0; middleWidth = 0; int lineHeight = theList.ItemHeight = FormsToolbox.GetTextHeight("0", this.Font) + 4; // suggestions.Clear(); if (suggestions != null && suggestions.Count > 0) { int maxWidth = 0; theList.BeginUpdate(); theList.Items.Clear(); theList.SelectedIndex = -1; Suggestion selectedItem = null; string match = suggestions.textEntered.ToLower().Trim(); foreach (Suggestion s in suggestions.GetSuggestions(!suggestionList.queryMode, match)) { if (s.expr.Trim().Length > 0) { if (s.expr.ToLower().Contains(match)) { leftWidth = Math.Max(leftWidth, 20 + FormsToolbox.GetTextWidth(s.expr + "00", Font)); if (s.middleStuff != null) { middleWidth = Math.Max(middleWidth, FormsToolbox.GetTextWidth(s.middleStuff + "00", SystemFonts.MessageBoxFont)); } if (s.rightStuff != null) { rightWidth = Math.Max(rightWidth, FormsToolbox.GetTextWidth(s.rightStuff + "00", SystemFonts.MessageBoxFont)); } theList.Items.Add(s); if (s.expr.ToLower().StartsWith(match) && (selectedItem == null || s.position < selectedItem.position)) { selectedItem = s; } } } } theList.EndUpdate(); if (selectedItem != null) { theList.SelectedItem = selectedItem; int topItem = Math.Max(0, theList.SelectedIndex - (maxVisibleItems / 2)); theList.TopIndex = topItem; } maxWidth = leftWidth + middleWidth + rightWidth; if (theList.Items.Count > 0) { if (!Visible) { Show(); BringToFront(); } T.Debug(p.Y.ToString() + " " + pOrig.Y.ToString()); int maxHeight = maxVisibleItems * lineHeight; theList.Size = new Size(T.MinMax(20, 600, maxWidth), T.MinMax(lineHeight, maxHeight, lineHeight * theList.Items.Count)); int y = p.Y; if (!suggestionList.queryMode) { y += lineHeight; } Bounds = new Rectangle(p.X, y, theList.Width, theList.Height); editor.Focus(); return(theList.Items.Count > 0); } } Hide(); editor.Focus(); return(false); }