public FullPreviewForm() { InitializeComponent(); scintilla = SciUtil.CreateScintilla(); Controls.Add(scintilla); scintilla.Dock = DockStyle.Fill; FormClosing += (o, e) => { if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; Hide(); } }; }
public MainFormBehind(MainFormUi ui) { void SetupScintilla() { var scintilla = SciUtil.CreateScintilla(); scintilla.UpdateUI += (o, e) => { if (e.Change == UpdateChange.Selection) { UpdateStatusBar(); } }; //sci.ReadOnly = true; ui.resultBox = scintilla; ui.form.Controls.Add(ui.resultBox); ui.resultBox.Dock = DockStyle.Fill; ui.searchTextBox.Select(); ui.tableLayout.Controls.Add(ui.resultBox, 0, 1); } this.Ui = ui; SetupScintilla(); ui.searchTextBox.KeyDown += (o, e) => { if (e.KeyCode == Keys.Enter) { SearchStartEvent(ui, e); } }; ui.dirSelector.KeyDown += (o, e) => { if (e.KeyCode == Keys.Enter) { SearchStartEvent(ui, e); } }; ui.resultBox.KeyDown += (o, e) => { HandleKeyDownOnResults(e, ui.resultBox.CurrentLine); }; ui.resultBox.KeyPress += (o, e) => { // prevent PLING sound e.Handled = true; }; SciUtil.SetAllText(ui.resultBox, Logic.Tutorial); ui.dirSelector.DataSource = Logic.DirHistory; ui.searchTextBox.DataSource = Logic.SearchHistory; ui.rgArgsComboBox.Items.AddRange(new[] { Logic.RgExtraArgs, "--files", "-m 5 --smart-case", "-M 1000", "-g *.cs -g *.csproj", "--no-ignore", "--context 2" }); ui.rgArgsComboBox.TextChanged += (o, e) => { Logic.RgExtraArgs = ui.rgArgsComboBox.Text; UpdateStatusBar(); }; ui.dirSelector.Text = Logic.WorkDir; ui.btnAbort.Click += (o, e) => { ui.btnAbort.Visible = false; Logic.KillSearch(); }; LiveSearchEvents(ui); if (Logic.InitialSearchString != null) { ui.searchTextBox.Text = Logic.InitialSearchString; Logic.InitialSearchString = null; Logic.StartSearch(ui); } UpdateStatusBar(); }