object _items; //List<string> or Func<List<string>> /// public KCheckTextBox(KCheckBox c, KTextBox t, Button button = null) { this.c = c; this.t = t; c.Tag = this; t.Tag = this; t.Small = true; _button = button; if (_button != null) { //_button.ClickMode = ClickMode.Press; //open on button down. But then Popup.StaysOpen=false does not work. Tried async, but same. //SHOULDDO: replace Popup in KPopupListBox with KPopup. _button.Click += (_, _) => { if (_popup?.IsOpen ?? false) { _popup.IsOpen = false; return; } List <string> a = null; switch (_items) { case List <string> u: a = u; break; case Func <List <string> > u: a = u(); break; } if (a.NE_()) { return; } if (_popup == null) { _popup = new KPopupListBox { PlacementTarget = t }; _popup.OK += o => { c.IsChecked = true; var s = o as string; t.Text = s; t.Focus(); }; } _popup.Control.ItemsSource = null; _popup.Control.ItemsSource = a; _popup.Control.MinWidth = t.ActualWidth + _button.ActualWidth - 1; _popup.IsOpen = true; }; } }
public Dwnd(wnd w = default, DwndFlags flags = 0, string title = "Find window") { _dontInsert = flags.Has(DwndFlags.DontInsert); _noControl = flags.Has(DwndFlags.NoControl); _checkControl = flags.Has(DwndFlags.CheckControl); _forTrigger = flags.Has(DwndFlags.ForTrigger); Title = title; var b = new wpfBuilder(this).WinSize((500, 450..), (600, 430..)).Columns(-1); b.R.Add(out _info).Height(60); b.R.StartGrid().Columns(0, 76, 76, 0, 0, -1); _cCapture = b.xAddCheckIcon("*Unicons.Capture #FF4040", $"Enable capturing ({App.Settings.delm.hk_capture}) and show window/control rectangles"); b.AddButton(out _bTest, "Test", _bTest_Click).Disabled().Tooltip("Executes the 'find' part of the code now and shows the rectangle"); b.AddButton(out _bInsert, _dontInsert ? "OK" : "Insert", _Insert).Disabled(); if (!_dontInsert) { b.Tooltip("Insert code in editor"); } b.Add(out _cbFunc).Items("find|findOrRun|runAndFind").Tooltip("Function").Width(90); //rejected: |wndFinder. Rare, etc. _cbFunc.SelectionChanged += _cbFunc_SelectionChanged; b.Add(out _cActivate, "Activate").Tooltip("Activate the found window"); b.Add(out _cException, "Fail if not found").Checked(!_forTrigger).Tooltip("Throw exception if not found"); //cActivate.CheckChanged += (_, _) => { cException.Visibility = cActivate.IsChecked ? Visibility.Hidden : Visibility.Visible; }; //no, need for control too b.End(); //window and control properties and search settings b.R.AddSeparator(false).Margin("B"); b.Row(0); //auto height, else adds v scrollbar when textbox height changes when a textbox text is multiline or too long (with h scrollbar) _scroller = b.xStartPropertyGrid("L2 T3 R2 B1"); //actually never shows scrollbar because of row auto height, but sets some options etc _scroller.Visibility = Visibility.Hidden; b.Columns(-3, 0, -1.2); //window b.R.Add <TextBlock>("Window").Margin("T1 B3").xSetHeaderProp(); //rejected: vertical headers. Tested, looks not good, too small for vertical Control checkbox. b.Row(0).StartGrid().Columns(70, -1); nameW = b.xAddCheckText("name"); classW = b.xAddCheckText("class"); programW = b.xAddCheckTextDropdown("program"); containsW = b.xAddCheckTextDropdown("contains"); b.End(); b.xAddSplitterV(span: 4, thickness: 12); b.StartGrid().Columns(44, -1); b.xAddCheck(out cHiddenTooW, "Find hidden too"); b.xAddCheck(out cCloakedTooW, "Find cloaked too"); alsoW = b.xAddCheckText("also", "o=>true"); waitW = b.xAddCheckText("wait", "1", check: !_forTrigger); b.End(); //control b.R.AddSeparator(false).Margin("T4 B0"); _sepControl = b.Last as Separator; b.R.Add(out _cControl, "Control").Margin("T5 B3").xSetHeaderProp(); b.Row(0).StartGrid().Columns(70, -1); _gCon1 = b.Panel as Grid; nameC = b.xAddCheckTextDropdown("name"); classC = b.xAddCheckText("class"); idC = b.xAddCheckText("id"); b.End().Skip(); b.StartGrid().Columns(44, -1); _gCon2 = b.Panel as Grid; b.xAddCheck(out cHiddenTooC, "Find hidden too"); alsoC = b.xAddCheckText("also", "o=>true"); skipC = b.xAddCheckText("skip"); b.End(); b.xEndPropertyGrid(); b.R.AddSeparator(false); if (_forTrigger) { _cActivate.Visibility = Visibility.Hidden; _cException.Visibility = Visibility.Hidden; _cbFunc.Visibility = Visibility.Hidden; waitW.Visible = false; } //code b.Row(64).xAddInBorder(out _code, "B"); //tree and window info b.xAddSplitterH(span: -1); b.Row(-1).StartGrid().Columns(-1, 0, -1); b.Row(-1).xAddInBorder(out _tree, "TR"); b.xAddSplitterV(); b.xAddInBorder(out _winInfo, "TL"); _winInfo.ZWrapLines = false; _winInfo.Name = "window_info"; b.End(); b.End(); _InitTree(); _con = w; b.WinProperties( topmost: true, showActivated: _dontInsert || w.Is0 ? null : false //eg if captured a popup menu, activating this window closes the menu and we cannot get properties ); WndSavedRect.Restore(this, App.Settings.wndpos.wnd, o => App.Settings.wndpos.wnd = o); }
/// public void Deconstruct(out KCheckBox c, out TextBox t) { c = this.c; t = this.t; }
public PanelFind() { this.UiaSetName("Find panel"); var b = new wpfBuilder(this).Columns(-1).Brush(SystemColors.ControlBrush); b.Options(modifyPadding: false, margin: new Thickness(2)); b.AlsoAll((b, _) => { if (b.Last is Button k) { k.Padding = new(1, 0, 1, 1); } }); b.Row((-1, 22..)).Add(out _tFind).Margin(-1, 0, -1, 2).Multiline(wrap: TextWrapping.Wrap).Tooltip("Text to find"); b.Row((-1, 22..)).Add(out _tReplace).Margin(-1, 0, -1, 2).Multiline(wrap: TextWrapping.Wrap).Tooltip("Replacement text"); b.R.StartGrid().Columns((-1, ..80), (-1, ..80), (-1, ..80), 0); b.R.AddButton("Find", _bFind_Click).Tooltip("Find next in editor"); b.AddButton(out var bReplace, "Replace", _bReplace_Click).Tooltip("Replace current found text in editor and find next.\nRight click - find next."); bReplace.MouseRightButtonUp += (_, _) => _bFind_Click(null); b.AddButton("Repl. all", _bReplaceAll_Click).Tooltip("Replace all in editor"); b.R.AddButton("In files", _bFindIF_Click).Tooltip("Find text in files"); b.StartStack(); _cFolder = b.xAddCheckIcon("*Material.FolderSearchOutline #99BF00", "Let 'In files' search only in current project or root folder"); b.Padding(1, 0, 1, 1); b.xAddButtonIcon("*EvaIcons.Options2 #99BF00", _bOptions_Click, "More options"); var cmd1 = App.Commands[nameof(Menus.File.OpenCloseGo.Go_back)]; var bBack = b.xAddButtonIcon("*EvaIcons.ArrowBack #585858", _ => Menus.File.OpenCloseGo.Go_back(), "Go back"); b.Disabled(!cmd1.Enabled); cmd1.CanExecuteChanged += (o, e) => bBack.IsEnabled = cmd1.Enabled; b.End(); b.Add(out _cName, "Name").Tooltip("Search in filenames, not in text"); b.R.Add(out _cCase, "Case").Tooltip("Match case") .And(0).Add(out _cWildex, "Wildex").Hidden().Tooltip("Wildcard expression.\nExamples: start*.cs, *end.cs, *middle*.cs, **m green.cs||blue.cs.\nF1 - Wildex help."); b.Add(out _cWord, "Word").Tooltip("Whole word"); b.Add(out _cRegex, "Regex").Tooltip("Regular expression.\nF1 - Regex tool and help."); b.End().End(); //this.AccessibleName = this.Name = "Find"; this.IsVisibleChanged += (_, _) => { if (!_cName.IsChecked) { Panels.Editor.ZActiveDoc?.InicatorsFind_(IsVisible ? _aEditor : null); } }; _tFind.TextChanged += (_, _) => ZUpdateQuickResults(false); //prevent tooltip on set focus. // Broken in .NET 6: AppContext.SetSwitch("Switch.UseLegacyToolTipDisplay", true); //must be before creating Application object _tFind.ToolTipOpening += (o, e) => { if (o is UIElement k && !k.IsMouseOver) { e.Handled = true; } }; foreach (var v in new TextBox[] { _tFind, _tReplace }) { v.AcceptsTab = true; v.IsInactiveSelectionHighlightEnabled = true; v.GotKeyboardFocus += _tFindReplace_KeyboardFocus; v.LostKeyboardFocus += _tFindReplace_KeyboardFocus; v.ContextMenu = new KWpfMenu(); v.ContextMenuOpening += _tFindReplace_ContextMenuOpening; v.PreviewMouseUp += (o, e) => { //use up, else up will close popup. Somehow on up ClickCount always 1. if (e.ChangedButton == MouseButton.Middle) { var tb = o as TextBox; if (tb.Text.NE()) { _RecentPopupList(tb); } else { tb.Clear(); } } }; } foreach (var v in new KCheckBox[] { _cCase, _cWildex, _cWord, _cRegex, _cName }) { v.CheckChanged += _CheckedChanged; } }