/// <summary> /// показать окошко быстрого перехода /// </summary> private void MenuitemGoToClick(object sender, EventArgs e) { var totalCount = chart.StockSeries.Data.Count; if (totalCount == 0) { return; } // получить границы графика var indexOpen = (int)chart.StockPane.WorldRect.Left + 1; var timeOpen = chart.StockSeries.GetCandleOpenTimeByIndex(indexOpen); var indexClose = (int)chart.StockPane.WorldRect.Right; if (indexClose > chart.StockSeries.DataCount) { indexClose = chart.StockSeries.DataCount - 1; } var timeClose = chart.StockSeries.GetCandleOpenTimeByIndex(indexClose); var minTime = chart.StockSeries.GetCandleOpenTimeByIndex(0); var maxTime = chart.StockSeries.GetCandleOpenTimeByIndex(totalCount - 1); // диалог var dlg = new GoToForm(indexOpen, indexClose, timeOpen, timeClose, totalCount, minTime, maxTime); if (dlg.ShowDialog() == DialogResult.Cancel) { return; } // установить границы в свечах? var candleBounds = dlg.CandleBounds; if (candleBounds.HasValue) { chart.SetScrollView(candleBounds.Value.X, candleBounds.Value.Y); return; } // установить границы по времени? var timeBounds = dlg.TimeBounds; if (!timeBounds.HasValue) { return; } var start = chart.StockSeries.GetIndexByCandleOpen(timeBounds.Value.a); var stop = chart.StockSeries.GetIndexByCandleOpen(timeBounds.Value.b); chart.SetScrollView(start, stop); }
public override void Execute(TextBoxControl editor) { GoToForm dlg = new GoToForm(); if (dlg.ShowDialog() == DialogResult.OK) { } //TextLocation homeLocation = editor.GetLineHomeInfo(editor.Caret.Line); //if (homeLocation != TextLocation.Empty) //{ // editor.Caret.Position = homeLocation; // editor.Caret.UpdateCaretPosition(); // if (editor.HorizontalScroll.Value != 0 && editor.HorizontalScroll.Visible) // { // editor.HorizontalScroll.Value = 0; // editor.PerformLayout(); // } //} }
/// <summary> /// Shows Goto dialog form /// </summary> public static void ShowGoToDialog(FastColoredTextBox textbox) { var form = new GoToForm(); form.TotalLineCount = textbox.LinesCount; form.SelectedLineNumber = textbox.Selection.Start.iLine + 1; if (form.ShowDialog() == DialogResult.OK) { int line = Math.Min(textbox.LinesCount - 1, Math.Max(0, form.SelectedLineNumber - 1)); textbox.Selection = new Range(textbox, 0, line, 0, line); textbox.DoSelectionVisible(); } }