├── .github └── dependabot.yml ├── .gitignore ├── AutocompleteMenu.sln ├── AutocompleteMenu ├── AutocompleteItem.cs ├── AutocompleteItems.cs ├── AutocompleteListView.cs ├── AutocompleteMenu-ScintillaNET.csproj ├── AutocompleteMenu.cs ├── AutocompleteMenu.resx ├── AutocompleteMenuHost.cs ├── Colors.cs ├── EventArgs.cs ├── IAutocompleteListView.cs ├── ITextBoxWrapper.cs ├── Properties │ └── AssemblyInfo.cs ├── README.md ├── Range.cs ├── ScintillaWrapper.cs └── TextBoxWrapper.cs ├── LICENSE ├── README.md └── Tester ├── AdvancedSample.Designer.cs ├── AdvancedSample.cs ├── AdvancedSample.resx ├── ComboboxSample.Designer.cs ├── ComboboxSample.cs ├── ComboboxSample.resx ├── CustomItemSample.Designer.cs ├── CustomItemSample.cs ├── CustomItemSample.resx ├── CustomListViewSample.Designer.cs ├── CustomListViewSample.cs ├── CustomListViewSample.resx ├── DataGridViewSample.Designer.cs ├── DataGridViewSample.cs ├── DataGridViewSample.resx ├── DynamicMenuSample.Designer.cs ├── DynamicMenuSample.cs ├── DynamicMenuSample.resx ├── DynamicTooltipSample.Designer.cs ├── DynamicTooltipSample.cs ├── DynamicTooltipSample.resx ├── ExtraLargeSample.Designer.cs ├── ExtraLargeSample.cs ├── ExtraLargeSample.resx ├── MainForm.Designer.cs ├── MainForm.cs ├── MainForm.resx ├── MultiColumnSample.Designer.cs ├── MultiColumnSample.cs ├── MultiColumnSample.resx ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── Sandbox.Designer.cs ├── Sandbox.cs ├── Sandbox.resx ├── ScintillaSample.Designer.cs ├── ScintillaSample.cs ├── ScintillaSample.resx ├── SimplestSample.Designer.cs ├── SimplestSample.cs ├── SimplestSample.resx ├── Tester.NET.csproj ├── Tester.csproj └── app.config /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: nuget 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "03:00" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | -------------------------------------------------------------------------------- /AutocompleteMenu.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33205.214 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutocompleteMenu-ScintillaNET", "AutocompleteMenu\AutocompleteMenu-ScintillaNET.csproj", "{43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tester", "Tester\Tester.csproj", "{43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|Mixed Platforms = Debug|Mixed Platforms 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|Mixed Platforms = Release|Mixed Platforms 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 23 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 24 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 28 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Release|Mixed Platforms.Build.0 = Release|Any CPU 29 | {43CBC9AA-6A8E-463F-83A9-AFF3124AFDB6}.Release|x86.ActiveCfg = Release|Any CPU 30 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 33 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 34 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Debug|x86.ActiveCfg = Debug|x86 35 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Debug|x86.Build.0 = Debug|x86 36 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Release|Any CPU.ActiveCfg = Release|x86 37 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Release|Mixed Platforms.ActiveCfg = Release|x86 38 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Release|Mixed Platforms.Build.0 = Release|x86 39 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Release|x86.ActiveCfg = Release|x86 40 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35}.Release|x86.Build.0 = Release|x86 41 | EndGlobalSection 42 | GlobalSection(SolutionProperties) = preSolution 43 | HideSolutionNode = FALSE 44 | EndGlobalSection 45 | GlobalSection(ExtensibilityGlobals) = postSolution 46 | SolutionGuid = {276FB46B-6501-46EC-95F3-694CA2334FB2} 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /AutocompleteMenu/AutocompleteItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Text; 5 | 6 | namespace AutocompleteMenuNS 7 | { 8 | /// 9 | /// Item of autocomplete menu 10 | /// 11 | public class AutocompleteItem 12 | { 13 | public object Tag; 14 | string toolTipTitle; 15 | string toolTipText; 16 | Color? toolTipBackColor = null; 17 | Color? toolTipForeColor = null; 18 | string menuText; 19 | 20 | /// 21 | /// Parent AutocompleteMenu 22 | /// 23 | public AutocompleteMenu Parent { get; internal set; } 24 | 25 | /// 26 | /// Text for inserting into textbox 27 | /// 28 | public string Text { get; set; } 29 | 30 | /// 31 | /// Image index for this item 32 | /// 33 | public int ImageIndex{get; set; } 34 | 35 | /// 36 | /// Alignment. The direction the text shows. 37 | /// 38 | public StringAlignment Alignment { get; set; } 39 | 40 | /// 41 | /// Title for tooltip. 42 | /// 43 | /// Return null for disable tooltip for this item 44 | public virtual string ToolTipTitle 45 | { 46 | get { return toolTipTitle; } 47 | set { toolTipTitle = value; } 48 | } 49 | 50 | /// 51 | /// Tooltip text. 52 | /// 53 | /// For display tooltip text, ToolTipTitle must be not null 54 | public virtual string ToolTipText 55 | { 56 | get { return toolTipText; } 57 | set { toolTipText = value; } 58 | } 59 | 60 | /// 61 | /// Tooltip Backcolor. 62 | /// 63 | /// For display tooltip backcolor, ToolTipTitle must be not null 64 | public virtual Color? ToolTipBackColor 65 | { 66 | get { return toolTipBackColor; } 67 | set { toolTipBackColor = value; } 68 | } 69 | 70 | /// 71 | /// Tooltip ForeColor. 72 | /// 73 | /// For display tooltip forecolor, ToolTipTitle must be not null 74 | public virtual Color? ToolTipForeColor 75 | { 76 | get { return toolTipForeColor; } 77 | set { toolTipForeColor = value; } 78 | } 79 | 80 | /// 81 | /// Menu text. This text is displayed in the drop-down menu. 82 | /// 83 | public virtual string MenuText 84 | { 85 | get { return menuText; } 86 | set { menuText = value; } 87 | } 88 | 89 | public AutocompleteItem() 90 | { 91 | ImageIndex = -1; 92 | } 93 | 94 | public AutocompleteItem(string text):this() 95 | { 96 | Text = text; 97 | Alignment = StringAlignment.Near; 98 | } 99 | 100 | public AutocompleteItem(string text, int imageIndex) 101 | : this(text) 102 | { 103 | this.ImageIndex = imageIndex; 104 | } 105 | 106 | public AutocompleteItem(string text, int imageIndex, string menuText) 107 | : this(text, imageIndex) 108 | { 109 | this.menuText = menuText; 110 | } 111 | 112 | public AutocompleteItem(string text, int imageIndex, string menuText, string toolTipTitle, string toolTipText) 113 | : this(text, imageIndex, menuText) 114 | { 115 | this.toolTipTitle = toolTipTitle; 116 | this.toolTipText = toolTipText; 117 | } 118 | 119 | /// 120 | /// Returns text for inserting into Textbox 121 | /// 122 | public virtual string GetTextForReplace() 123 | { 124 | return Text; 125 | } 126 | 127 | /// 128 | /// Compares fragment text with this item 129 | /// 130 | public virtual CompareResult Compare(string fragmentText) 131 | { 132 | if (Text.StartsWith(fragmentText, StringComparison.InvariantCultureIgnoreCase) && 133 | Text != fragmentText) 134 | return CompareResult.VisibleAndSelected; 135 | 136 | return CompareResult.Hidden; 137 | } 138 | 139 | /// 140 | /// Returns text for display into popup menu 141 | /// 142 | public override string ToString() 143 | { 144 | return menuText ?? Text; 145 | } 146 | 147 | /// 148 | /// This method is called after item was inserted into text 149 | /// 150 | public virtual void OnSelected(SelectedEventArgs e) 151 | { 152 | } 153 | 154 | public virtual void OnPaint(PaintItemEventArgs e) 155 | { 156 | using(var brush = new SolidBrush(e.IsSelected ? e.Colors.SelectedForeColor : e.Colors.ForeColor)) 157 | e.Graphics.DrawString(ToString(), e.Font, brush, e.TextRect, new StringFormat() { Alignment = Alignment }); 158 | } 159 | } 160 | 161 | public enum CompareResult 162 | { 163 | /// 164 | /// Item do not appears 165 | /// 166 | Hidden, 167 | /// 168 | /// Item appears 169 | /// 170 | Visible, 171 | /// 172 | /// Item appears and will selected 173 | /// 174 | VisibleAndSelected 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /AutocompleteMenu/AutocompleteItems.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace AutocompleteMenuNS 8 | { 9 | /// 10 | /// This autocomplete item appears after dot 11 | /// 12 | public class MethodAutocompleteItem : AutocompleteItem 13 | { 14 | string firstPart; 15 | string lowercaseText; 16 | 17 | public MethodAutocompleteItem(string text) 18 | : base(text) 19 | { 20 | lowercaseText = Text.ToLower(); 21 | } 22 | 23 | public override CompareResult Compare(string fragmentText) 24 | { 25 | int i = fragmentText.LastIndexOf('.'); 26 | if (i < 0) 27 | return CompareResult.Hidden; 28 | string lastPart = fragmentText.Substring(i + 1); 29 | firstPart = fragmentText.Substring(0, i); 30 | 31 | if (lastPart == "") return CompareResult.Visible; 32 | if (Text.StartsWith(lastPart, StringComparison.InvariantCultureIgnoreCase)) 33 | return CompareResult.VisibleAndSelected; 34 | if (lowercaseText.Contains(lastPart.ToLower())) 35 | return CompareResult.Visible; 36 | 37 | return CompareResult.Hidden; 38 | } 39 | 40 | public override string GetTextForReplace() 41 | { 42 | return firstPart + "." + Text; 43 | } 44 | } 45 | 46 | /// 47 | /// Autocomplete item for code snippets 48 | /// 49 | /// Snippet can contain special char ^ for caret position. 50 | public class SnippetAutocompleteItem : AutocompleteItem 51 | { 52 | public SnippetAutocompleteItem(string snippet) 53 | { 54 | Text = snippet.Replace("\r", ""); 55 | ToolTipTitle = "Code snippet:"; 56 | ToolTipText = Text; 57 | } 58 | 59 | public override string ToString() 60 | { 61 | return MenuText ?? Text.Replace("\n", " ").Replace("^", ""); 62 | } 63 | 64 | public override string GetTextForReplace() 65 | { 66 | return Text; 67 | } 68 | 69 | public override void OnSelected(SelectedEventArgs e) 70 | { 71 | var tb = Parent.TargetControlWrapper; 72 | // 73 | if (!Text.Contains("^")) 74 | return; 75 | var text = tb.Text; 76 | for (int i = Parent.Fragment.Start; i < text.Length; i++) 77 | if (text[i] == '^') 78 | { 79 | tb.SelectionStart = i; 80 | tb.SelectionLength = 1; 81 | tb.SelectedText = ""; 82 | return; 83 | } 84 | } 85 | 86 | /// 87 | /// Compares fragment text with this item 88 | /// 89 | public override CompareResult Compare(string fragmentText) 90 | { 91 | if (Text.StartsWith(fragmentText, StringComparison.InvariantCultureIgnoreCase) && 92 | Text != fragmentText) 93 | return CompareResult.Visible; 94 | 95 | return CompareResult.Hidden; 96 | } 97 | } 98 | 99 | /// 100 | /// This class finds items by substring 101 | /// 102 | public class SubstringAutocompleteItem : AutocompleteItem 103 | { 104 | protected readonly string lowercaseText; 105 | protected readonly bool ignoreCase; 106 | 107 | public SubstringAutocompleteItem(string text, bool ignoreCase = true) 108 | : base(text) 109 | { 110 | this.ignoreCase = ignoreCase; 111 | if(ignoreCase) 112 | lowercaseText = text.ToLower(); 113 | } 114 | 115 | public override CompareResult Compare(string fragmentText) 116 | { 117 | if(ignoreCase) 118 | { 119 | if (lowercaseText.Contains(fragmentText.ToLower())) 120 | return CompareResult.Visible; 121 | } 122 | else 123 | { 124 | if (Text.Contains(fragmentText)) 125 | return CompareResult.Visible; 126 | } 127 | 128 | return CompareResult.Hidden; 129 | } 130 | } 131 | 132 | /// 133 | /// This item draws multicolumn menu 134 | /// 135 | public class MulticolumnAutocompleteItem : SubstringAutocompleteItem 136 | { 137 | public bool CompareBySubstring { get; set; } 138 | public string[] MenuTextByColumns { get; set; } 139 | public int[] ColumnWidth { get; set; } 140 | public StringAlignment[] Alignments { get; set; } 141 | 142 | public MulticolumnAutocompleteItem(string[] menuTextByColumns, string insertingText, bool compareBySubstring = true, bool ignoreCase = true) 143 | : base(insertingText, ignoreCase) 144 | { 145 | this.CompareBySubstring = compareBySubstring; 146 | this.MenuTextByColumns = menuTextByColumns; 147 | var tmp = new List(); 148 | for(int i = 0; i < menuTextByColumns.Length; i++) 149 | tmp.Add(StringAlignment.Near); 150 | this.Alignments = tmp.ToArray(); 151 | } 152 | 153 | public override CompareResult Compare(string fragmentText) 154 | { 155 | if (CompareBySubstring) 156 | return base.Compare(fragmentText); 157 | 158 | if(ignoreCase) 159 | { 160 | if (Text.StartsWith(fragmentText, StringComparison.InvariantCultureIgnoreCase)) 161 | return CompareResult.VisibleAndSelected; 162 | } else 163 | if (Text.StartsWith(fragmentText)) 164 | return CompareResult.VisibleAndSelected; 165 | 166 | return CompareResult.Hidden; 167 | } 168 | 169 | public override void OnPaint(PaintItemEventArgs e) 170 | { 171 | if (ColumnWidth != null && ColumnWidth.Length != MenuTextByColumns.Length) 172 | throw new Exception("ColumnWidth.Length != MenuTextByColumns.Length"); 173 | 174 | int[] columnWidth = ColumnWidth; 175 | if(columnWidth == null) 176 | { 177 | columnWidth = new int[MenuTextByColumns.Length]; 178 | float step = e.TextRect.Width/MenuTextByColumns.Length; 179 | for (int i = 0; i < MenuTextByColumns.Length; i++) 180 | columnWidth[i] = (int)step; 181 | } 182 | 183 | //draw columns 184 | Pen pen = Pens.Silver; 185 | float x = e.TextRect.X; 186 | e.StringFormat.FormatFlags = e.StringFormat.FormatFlags | StringFormatFlags.NoWrap; 187 | 188 | using (var brush = new SolidBrush(e.IsSelected ? e.Colors.SelectedForeColor : e.Colors.ForeColor)) 189 | for (int i=0;i 2 | 3 | net5.0-windows;net45;net6-windows;net7-windows;net4 4 | Library 5 | AutocompleteMenuNS 6 | false 7 | true 8 | true 9 | AutoCompleteMenu-ScintillaNET 10 | AutoCompleteMenu-ScintillaNET 11 | Ahmed Elwasefi 12 | autocomplete, scintilla, scintillanet, autocompletmenu, complete 13 | MIT 14 | README.md 15 | 16 | This is an AutoCompleteMenu based on this: 17 | http://www.codeproject.com/Articles/365974/Autocomplete-Menu - ByPavel Torgashov 18 | 19 | The main added feature is SctintillaNET wrapper and also fixed several bugs that can be seen in GitHub. 20 | 21 | ========================== 22 | Changes v2.1: 23 | * ToolTips now support changing of their BackColor and ForeColor. 24 | * Fixed ToolTip showing in wrong location in first time. 25 | * Added an AutoWidth feature. 26 | 27 | http://www.opensource.org/licenses/lgpl-3.0.html 28 | https://github.com/Ahmad45123/AutoCompleteMenu-ScintillaNET 29 | https://github.com/Ahmad45123/AutoCompleteMenu-ScintillaNET 30 | git 31 | 32 | * ToolTips now support changing of their BackColor and ForeColor. 33 | * Fixed ToolTip showing in wrong location in first time. 34 | * Added an AutoWidth feature. 35 | 36 | NEW: 37 | - Added support for various other old frameworks! 38 | 39 | 2.1.1 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | all 49 | runtime; build; native; contentfiles; analyzers; buildtransitive 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /AutocompleteMenu/AutocompleteMenu.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /AutocompleteMenu/AutocompleteMenuHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Drawing; 4 | using System.Windows.Forms; 5 | 6 | namespace AutocompleteMenuNS 7 | { 8 | [System.ComponentModel.ToolboxItem(false)] 9 | internal class AutocompleteMenuHost : ToolStripDropDown 10 | { 11 | private IAutocompleteListView listView; 12 | public ToolStripControlHost Host { get; set; } 13 | public readonly AutocompleteMenu Menu; 14 | 15 | public IAutocompleteListView ListView 16 | { 17 | get { return listView; } 18 | set { 19 | 20 | if(listView != null) 21 | (listView as Control).LostFocus -= new EventHandler(ListView_LostFocus); 22 | 23 | if (value == null) 24 | listView = new AutocompleteListView(); 25 | else 26 | { 27 | if (!(value is Control)) 28 | throw new Exception("ListView must be derived from Control class"); 29 | 30 | listView = value; 31 | } 32 | 33 | Host = new ToolStripControlHost(ListView as Control); 34 | Host.Margin = new Padding(2, 2, 2, 2); 35 | Host.Padding = Padding.Empty; 36 | Host.AutoSize = false; 37 | Host.AutoToolTip = false; 38 | 39 | (ListView as Control).MaximumSize = Menu.MaximumSize; 40 | (ListView as Control).Size = Menu.MaximumSize; 41 | (ListView as Control).LostFocus += new EventHandler(ListView_LostFocus); 42 | 43 | CalcSize(); 44 | base.Items.Clear(); 45 | base.Items.Add(Host); 46 | (ListView as Control).Parent = this; 47 | } 48 | } 49 | 50 | public AutocompleteMenuHost(AutocompleteMenu menu) 51 | { 52 | AutoClose = false; 53 | AutoSize = false; 54 | Margin = Padding.Empty; 55 | Padding = Padding.Empty; 56 | 57 | Menu = menu; 58 | ListView = new AutocompleteListView(); 59 | } 60 | 61 | protected override void OnPaintBackground(PaintEventArgs e) 62 | { 63 | using (var brush = new SolidBrush(listView.Colors.BackColor)) 64 | e.Graphics.FillRectangle(brush, e.ClipRectangle); 65 | } 66 | 67 | internal void CalcSize(int? customWidth = null) 68 | { 69 | if (customWidth == null) 70 | { 71 | Host.Size = (ListView as Control).Size; 72 | Size = new Size((ListView as Control).Size.Width + 4, (ListView as Control).Size.Height + 4); 73 | } 74 | else 75 | { 76 | Host.Size = new Size((int)customWidth, (ListView as Control).Size.Height); 77 | Size = new Size((int)customWidth + 4, (ListView as Control).Size.Height + 4); 78 | Debug.WriteLine("Setting width to " + customWidth); 79 | } 80 | } 81 | 82 | public override RightToLeft RightToLeft 83 | { 84 | get 85 | { 86 | return base.RightToLeft; 87 | } 88 | set 89 | { 90 | base.RightToLeft = value; 91 | (ListView as Control).RightToLeft = value; 92 | } 93 | } 94 | 95 | protected override void OnLostFocus(EventArgs e) 96 | { 97 | base.OnLostFocus(e); 98 | if(!(ListView as Control).Focused) 99 | Close(); 100 | } 101 | 102 | void ListView_LostFocus(object sender, EventArgs e) 103 | { 104 | if (!Focused) 105 | Close(); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /AutocompleteMenu/Colors.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Text; 5 | 6 | namespace AutocompleteMenuNS 7 | { 8 | [Serializable] 9 | public class Colors 10 | { 11 | public Color ForeColor { get; set; } 12 | public Color BackColor { get; set; } 13 | public Color SelectedForeColor { get; set; } 14 | public Color SelectedBackColor { get; set; } 15 | public Color SelectedBackColor2 { get; set; } 16 | public Color HighlightingColor { get; set; } 17 | 18 | public Colors() 19 | { 20 | ForeColor = Color.Black; 21 | BackColor = Color.White; 22 | SelectedForeColor = Color.Black; 23 | SelectedBackColor = Color.Orange; 24 | SelectedBackColor2 = Color.White; 25 | HighlightingColor = Color.Orange; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /AutocompleteMenu/EventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace AutocompleteMenuNS 8 | { 9 | public class SelectingEventArgs : EventArgs 10 | { 11 | public AutocompleteItem Item { get; internal set; } 12 | public bool Cancel { get; set; } 13 | public int SelectedIndex { get; set; } 14 | public bool Handled { get; set; } 15 | } 16 | 17 | public class SelectedEventArgs : EventArgs 18 | { 19 | public AutocompleteItem Item { get; internal set; } 20 | public Control Control { get; set; } 21 | } 22 | 23 | public class HoveredEventArgs : EventArgs 24 | { 25 | public AutocompleteItem Item { get; internal set; } 26 | } 27 | 28 | 29 | public class PaintItemEventArgs : PaintEventArgs 30 | { 31 | public RectangleF TextRect { get; internal set; } 32 | public StringFormat StringFormat { get; internal set; } 33 | public Font Font { get; internal set; } 34 | public bool IsSelected { get; internal set; } 35 | public bool IsHovered { get; internal set; } 36 | public Colors Colors { get; internal set; } 37 | 38 | public PaintItemEventArgs(Graphics graphics, Rectangle clipRect):base(graphics, clipRect) 39 | { 40 | } 41 | } 42 | 43 | public class WrapperNeededEventArgs : EventArgs 44 | { 45 | public Control TargetControl { get; private set; } 46 | public ITextBoxWrapper Wrapper { get; set; } 47 | 48 | public WrapperNeededEventArgs(Control targetControl) 49 | { 50 | this.TargetControl = targetControl; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /AutocompleteMenu/IAutocompleteListView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Windows.Forms; 5 | 6 | namespace AutocompleteMenuNS 7 | { 8 | /// 9 | /// Control for displaying menu items, hosted in AutocompleteMenu. 10 | /// 11 | public interface IAutocompleteListView 12 | { 13 | /// 14 | /// Image list 15 | /// 16 | ImageList ImageList { get; set; } 17 | 18 | string[] ColumnsTitle { get; set; } 19 | int[] ColumnsWidth { get; set; } 20 | 21 | /// 22 | /// Index of current selected item 23 | /// 24 | int SelectedItemIndex { get; set; } 25 | 26 | /// 27 | /// Index of current selected item 28 | /// 29 | int HighlightedItemIndex { get; set; } 30 | 31 | /// 32 | /// List of visible elements 33 | /// 34 | IList VisibleItems { get;set;} 35 | 36 | /// 37 | /// Duration (ms) of tooltip showing 38 | /// 39 | int ToolTipDuration { get; set; } 40 | 41 | /// 42 | /// Occurs when user selected item for inserting into text 43 | /// 44 | event EventHandler ItemSelected; 45 | 46 | /// 47 | /// Occurs when current hovered item is changing 48 | /// 49 | event EventHandler ItemHovered; 50 | 51 | /// 52 | /// Shows tooltip 53 | /// 54 | /// 55 | /// 56 | void ShowToolTip(AutocompleteItem autocompleteItem, Control control = null); 57 | 58 | /// 59 | /// Hides tooltip 60 | /// 61 | /// 62 | void HideToolTip(Control control); 63 | 64 | /// 65 | /// Returns rectangle of item 66 | /// 67 | Rectangle GetItemRectangle(int itemIndex); 68 | 69 | /// 70 | /// Colors 71 | /// 72 | Colors Colors { get; set; } 73 | 74 | 75 | Control GetParentControl(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /AutocompleteMenu/ITextBoxWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace AutocompleteMenuNS 8 | { 9 | /// 10 | /// Wrapper over the control like TextBox. 11 | /// 12 | public interface ITextBoxWrapper 13 | { 14 | Control TargetControl { get; } 15 | string Text { get; } 16 | string SelectedText { get; set; } 17 | int SelectionLength { get; set; } 18 | int SelectionStart { get; set; } 19 | Point GetPositionFromCharIndex(int pos); 20 | bool Readonly { get; } 21 | event EventHandler LostFocus; 22 | event ScrollEventHandler Scroll; 23 | event KeyEventHandler KeyDown; 24 | event MouseEventHandler MouseDown; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AutocompleteMenu/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ahmad45123/AutoCompleteMenu-ScintillaNET/547b03abec900cea6eb2924cac71dc59429af29e/AutocompleteMenu/Properties/AssemblyInfo.cs -------------------------------------------------------------------------------- /AutocompleteMenu/README.md: -------------------------------------------------------------------------------- 1 | # AutoCompleteMenu 2 | This library is a general auto complete menu library based on the [library originally created by Pavel Torgashov](http://www.codeproject.com/Articles/365974/Autocomplete-Menu). 3 | 4 | ## Features 5 | - The main feature is adding support for ScintillaNET via a new ScintillaWrapper. The wrapper can be enabled as simple as doing `AutoComplete.TargetControlWrapper = new ScintillaWrapper(scintilla1);`. 6 | - Fixed many bugs in the original library. 7 | - Added support for multiple columns. 8 | - Added AutoWidth feature. 9 | - Added ability to colorize backcolor and forecolor of tooltips. 10 | 11 | And many more.. The library is not documented well so feel free to open issues [in the repository](https://github.com/Ahmad45123/AutoCompleteMenu-ScintillaNET/issues) for any questions or feature requests. -------------------------------------------------------------------------------- /AutocompleteMenu/Range.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Windows.Forms; 5 | 6 | namespace AutocompleteMenuNS 7 | { 8 | public class Range 9 | { 10 | public ITextBoxWrapper TargetWrapper { get; private set; } 11 | public int Start { get; set; } 12 | public int End { get; set; } 13 | 14 | public Range(ITextBoxWrapper targetWrapper) 15 | { 16 | this.TargetWrapper = targetWrapper; 17 | } 18 | 19 | public string Text 20 | { 21 | get 22 | { 23 | var text = TargetWrapper.Text; 24 | 25 | if (string.IsNullOrEmpty(text)) 26 | return ""; 27 | if (Start >= text.Length) 28 | return ""; 29 | if (End > text.Length) 30 | return ""; 31 | 32 | return TargetWrapper.Text.Substring(Start, End - Start); 33 | } 34 | 35 | set 36 | { 37 | TargetWrapper.SelectionStart = Start; 38 | TargetWrapper.SelectionLength = End - Start; 39 | TargetWrapper.SelectedText = value; 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AutocompleteMenu/ScintillaWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Windows.Forms; 4 | using ScintillaNET; 5 | 6 | namespace AutocompleteMenuNS 7 | { 8 | public class ScintillaWrapper : ITextBoxWrapper 9 | { 10 | public Scintilla target; 11 | 12 | public ScintillaWrapper(Scintilla trgt) 13 | { 14 | target = trgt; 15 | 16 | //Now add handler for the UpdateUI event. 17 | target.UpdateUI += (sender, args) => 18 | { 19 | if (args?.Change == UpdateChange.HScroll || args?.Change == UpdateChange.VScroll) 20 | { 21 | Scroll?.Invoke(sender, new ScrollEventArgs(ScrollEventType.LargeIncrement, 0)); 22 | } 23 | }; 24 | } 25 | 26 | 27 | public bool Readonly 28 | { 29 | get { return target.ReadOnly; } 30 | } 31 | 32 | public string SelectedText 33 | { 34 | get { return target.SelectedText; } 35 | set 36 | { 37 | //Store the start of the selection. 38 | int start = target.SelectionStart; 39 | 40 | //Delete the current text between selections. 41 | target.DeleteRange(target.SelectionStart, (target.SelectionEnd - target.SelectionStart)); 42 | 43 | //Add the text in the same postion. 44 | target.InsertText(start, value); 45 | 46 | //Clear selection and make sure the caret is at the end. 47 | target.SelectionStart = (start + value.Length); 48 | target.SelectionEnd = (start + value.Length); 49 | } 50 | } 51 | 52 | public int SelectionLength 53 | { 54 | get { return (target.SelectionEnd - target.SelectionStart); } 55 | set { target.SelectionEnd = (target.SelectionStart + value); } 56 | } 57 | 58 | public int SelectionStart 59 | { 60 | get { return target.SelectionStart; } 61 | set { target.SelectionStart = value; } 62 | } 63 | 64 | public Control TargetControl 65 | { 66 | get { return target; } 67 | } 68 | 69 | public string Text 70 | { 71 | get { return target.Text; } 72 | } 73 | 74 | public Point GetPositionFromCharIndex(int pos) 75 | { 76 | return new Point(target.PointXFromPosition(pos), target.PointYFromPosition(pos)); 77 | } 78 | 79 | //Events 80 | public virtual event KeyEventHandler KeyDown 81 | { 82 | add { target.KeyDown += value; } 83 | remove { target.KeyDown -= value; } 84 | } 85 | public virtual event EventHandler LostFocus 86 | { 87 | add { target.LostFocus += value; } 88 | remove { target.LostFocus -= value; } 89 | } 90 | public virtual event MouseEventHandler MouseDown 91 | { 92 | add { target.MouseDown += value; } 93 | remove { target.MouseDown -= value; } 94 | } 95 | 96 | public event ScrollEventHandler Scroll; 97 | } 98 | } -------------------------------------------------------------------------------- /AutocompleteMenu/TextBoxWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Reflection; 4 | using System.Windows.Forms; 5 | 6 | namespace AutocompleteMenuNS 7 | { 8 | /// 9 | /// Wrapper over the control like TextBox. 10 | /// 11 | public class TextBoxWrapper : ITextBoxWrapper 12 | { 13 | private Control target; 14 | private PropertyInfo selectionStart; 15 | private PropertyInfo selectionLength; 16 | private PropertyInfo selectedText; 17 | private PropertyInfo readonlyProperty; 18 | private MethodInfo getPositionFromCharIndex; 19 | private event ScrollEventHandler RTBScroll; 20 | 21 | private TextBoxWrapper(Control targetControl) 22 | { 23 | this.target = targetControl; 24 | Init(); 25 | } 26 | 27 | protected virtual void Init() 28 | { 29 | var t = target.GetType(); 30 | selectedText = t.GetProperty("SelectedText"); 31 | selectionLength = t.GetProperty("SelectionLength"); 32 | selectionStart = t.GetProperty("SelectionStart"); 33 | readonlyProperty = t.GetProperty("ReadOnly"); 34 | getPositionFromCharIndex = t.GetMethod("GetPositionFromCharIndex") ?? t.GetMethod("PositionToPoint"); 35 | 36 | if (target is RichTextBox) 37 | (target as RichTextBox).VScroll += new EventHandler(TextBoxWrapper_VScroll); 38 | } 39 | 40 | void TextBoxWrapper_VScroll(object sender, EventArgs e) 41 | { 42 | if (RTBScroll != null) 43 | RTBScroll(sender, new ScrollEventArgs(ScrollEventType.EndScroll, 0, 1)); 44 | } 45 | 46 | public static TextBoxWrapper Create(Control targetControl) 47 | { 48 | var result = new TextBoxWrapper(targetControl); 49 | 50 | if (result.selectedText == null || result.selectionLength == null || result.selectionStart == null || 51 | result.getPositionFromCharIndex == null) 52 | return null; 53 | 54 | return result; 55 | } 56 | 57 | public virtual string Text 58 | { 59 | get { return target.Text; } 60 | set { target.Text = value; } 61 | } 62 | 63 | public virtual string SelectedText 64 | { 65 | get { return (string) selectedText.GetValue(target, null); } 66 | set { selectedText.SetValue(target, value, null); } 67 | } 68 | 69 | public virtual int SelectionLength 70 | { 71 | get { return (int) selectionLength.GetValue(target, null); } 72 | set { selectionLength.SetValue(target, value, null); } 73 | } 74 | 75 | public virtual int SelectionStart 76 | { 77 | get { return (int) selectionStart.GetValue(target, null); } 78 | set { selectionStart.SetValue(target, value, null); } 79 | } 80 | 81 | public virtual Point GetPositionFromCharIndex(int pos) 82 | { 83 | return (Point) getPositionFromCharIndex.Invoke(target, new object[] {pos}); 84 | } 85 | 86 | 87 | public virtual Form FindForm() 88 | { 89 | return target.FindForm(); 90 | } 91 | 92 | public virtual event EventHandler LostFocus 93 | { 94 | add { target.LostFocus += value; } 95 | remove { target.LostFocus -= value; } 96 | } 97 | 98 | public virtual event ScrollEventHandler Scroll 99 | { 100 | add { 101 | if(target is RichTextBox) 102 | RTBScroll += value; 103 | else 104 | if(target is ScrollableControl)(target as ScrollableControl).Scroll += value; 105 | 106 | } 107 | remove { 108 | if (target is RichTextBox) 109 | RTBScroll -= value; 110 | else 111 | if(target is ScrollableControl)(target as ScrollableControl).Scroll -= value; 112 | } 113 | } 114 | 115 | public virtual event KeyEventHandler KeyDown 116 | { 117 | add { target.KeyDown += value; } 118 | remove { target.KeyDown -= value; } 119 | } 120 | 121 | public virtual event MouseEventHandler MouseDown 122 | { 123 | add { target.MouseDown += value; } 124 | remove { target.MouseDown -= value; } 125 | } 126 | 127 | public virtual Control TargetControl 128 | { 129 | get { return target; } 130 | } 131 | 132 | 133 | public bool Readonly 134 | { 135 | get { return (bool) readonlyProperty.GetValue(target, null); } 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AutoCompleteMenu for ScintillaNET 2 | This is an edit of the .NET library called [AutoCompleteMenu](http://www.codeproject.com/Articles/365974/Autocomplete-Menu). 3 | 4 | ## Changes: 5 | ###### New Features: 6 | * Added support for the editor [ScintillaNET](https://github.com/jacobslusser/ScintillaNET). 7 | 8 | ###### Fixed bugs: 9 | Review commits. 10 | 11 | ## Download: 12 | You can install this from NuGet, package name: `AutoCompleteMenu-ScintillaNET` 13 | or through commandline: `PM> Install-Package AutoCompleteMenu-ScintillaNET` 14 | 15 | https://www.nuget.org/packages/AutoCompleteMenu-ScintillaNET 16 | 17 | ## License: 18 | This library is licensed under [The GNU Lesser General Public License (LGPLv3)](http://www.opensource.org/licenses/lgpl-3.0.html) 19 | -------------------------------------------------------------------------------- /Tester/AdvancedSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class AdvancedSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AdvancedSample)); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.label2 = new System.Windows.Forms.Label(); 35 | this.label3 = new System.Windows.Forms.Label(); 36 | this.imageList1 = new System.Windows.Forms.ImageList(this.components); 37 | this.richTextBox1 = new System.Windows.Forms.RichTextBox(); 38 | this.textBox1 = new System.Windows.Forms.TextBox(); 39 | this.autocompleteMenu1 = new AutocompleteMenuNS.AutocompleteMenu(); 40 | this.SuspendLayout(); 41 | // 42 | // label1 43 | // 44 | this.label1.AutoSize = true; 45 | this.label1.Location = new System.Drawing.Point(13, 56); 46 | this.label1.Name = "label1"; 47 | this.label1.Size = new System.Drawing.Size(46, 13); 48 | this.label1.TabIndex = 3; 49 | this.label1.Text = "TextBox"; 50 | // 51 | // label2 52 | // 53 | this.label2.AutoSize = true; 54 | this.label2.Location = new System.Drawing.Point(13, 105); 55 | this.label2.Name = "label2"; 56 | this.label2.Size = new System.Drawing.Size(68, 13); 57 | this.label2.TabIndex = 4; 58 | this.label2.Text = "RichTextBox"; 59 | // 60 | // label3 61 | // 62 | this.label3.Dock = System.Windows.Forms.DockStyle.Top; 63 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 64 | this.label3.Location = new System.Drawing.Point(0, 0); 65 | this.label3.Name = "label3"; 66 | this.label3.Size = new System.Drawing.Size(390, 45); 67 | this.label3.TabIndex = 5; 68 | this.label3.Text = "This example shows how to create custom autocomplete menu with keywords, snippets" + 69 | ", method suggestions, text correctors etc."; 70 | // 71 | // imageList1 72 | // 73 | this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); 74 | this.imageList1.TransparentColor = System.Drawing.Color.Transparent; 75 | this.imageList1.Images.SetKeyName(0, "script_16x16.png"); 76 | this.imageList1.Images.SetKeyName(1, "app_16x16.png"); 77 | this.imageList1.Images.SetKeyName(2, "1302166543_virtualbox.png"); 78 | // 79 | // richTextBox1 80 | // 81 | this.richTextBox1.AcceptsTab = true; 82 | this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 83 | | System.Windows.Forms.AnchorStyles.Left) 84 | | System.Windows.Forms.AnchorStyles.Right))); 85 | this.autocompleteMenu1.SetAutocompleteMenu(this.richTextBox1, this.autocompleteMenu1); 86 | this.richTextBox1.Location = new System.Drawing.Point(12, 121); 87 | this.richTextBox1.Name = "richTextBox1"; 88 | this.richTextBox1.Size = new System.Drawing.Size(366, 149); 89 | this.richTextBox1.TabIndex = 0; 90 | this.richTextBox1.Text = "Try to type \"in\"\nTry to type \"class\"\nTry to type \"obj.\"\nTry to type \"set{}abc\"\nTr" + 91 | "y to type \"123and567\""; 92 | // 93 | // textBox1 94 | // 95 | this.textBox1.AcceptsTab = true; 96 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 97 | | System.Windows.Forms.AnchorStyles.Right))); 98 | this.autocompleteMenu1.SetAutocompleteMenu(this.textBox1, this.autocompleteMenu1); 99 | this.textBox1.Location = new System.Drawing.Point(12, 72); 100 | this.textBox1.Name = "textBox1"; 101 | this.textBox1.Size = new System.Drawing.Size(366, 20); 102 | this.textBox1.TabIndex = 0; 103 | // 104 | // autocompleteMenu1 105 | // 106 | this.autocompleteMenu1.AllowsTabKey = true; 107 | this.autocompleteMenu1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); 108 | this.autocompleteMenu1.ImageList = this.imageList1; 109 | this.autocompleteMenu1.Items = new string[0]; 110 | this.autocompleteMenu1.SearchPattern = "[\\w\\.:=!<>]"; 111 | this.autocompleteMenu1.TargetControlWrapper = null; 112 | // 113 | // AdvancedSample 114 | // 115 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 116 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 117 | this.ClientSize = new System.Drawing.Size(390, 282); 118 | this.Controls.Add(this.label3); 119 | this.Controls.Add(this.label2); 120 | this.Controls.Add(this.label1); 121 | this.Controls.Add(this.richTextBox1); 122 | this.Controls.Add(this.textBox1); 123 | this.Name = "AdvancedSample"; 124 | this.Text = "AdvancedSample"; 125 | this.ResumeLayout(false); 126 | this.PerformLayout(); 127 | 128 | } 129 | 130 | #endregion 131 | 132 | private System.Windows.Forms.TextBox textBox1; 133 | private System.Windows.Forms.RichTextBox richTextBox1; 134 | private AutocompleteMenuNS.AutocompleteMenu autocompleteMenu1; 135 | private System.Windows.Forms.Label label1; 136 | private System.Windows.Forms.Label label2; 137 | private System.Windows.Forms.Label label3; 138 | private System.Windows.Forms.ImageList imageList1; 139 | } 140 | } -------------------------------------------------------------------------------- /Tester/AdvancedSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Text.RegularExpressions; 8 | using System.Windows.Forms; 9 | using AutocompleteMenuNS; 10 | 11 | namespace Tester 12 | { 13 | public partial class AdvancedSample : Form 14 | { 15 | string[] keywords = { "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while", "add", "alias", "ascending", "descending", "dynamic", "from", "get", "global", "group", "into", "join", "let", "orderby", "partial", "remove", "select", "set", "value", "var", "where", "yield" }; 16 | string[] methods = { "Equals()", "GetHashCode()", "GetType()", "ToString()" }; 17 | string[] snippets = { "if(^)\n{\n}", "if(^)\n{\n}\nelse\n{\n}", "for(^;;)\n{\n}", "while(^)\n{\n}", "do${\n^}while();", "switch(^)\n{\n\tcase : break;\n}" }; 18 | string[] declarationSnippets = { 19 | "public class ^\n{\n}", "private class ^\n{\n}", "internal class ^\n{\n}", 20 | "public struct ^\n{\n}", "private struct ^\n{\n}", "internal struct ^\n{\n}", 21 | "public void ^()\n{\n}", "private void ^()\n{\n}", "internal void ^()\n{\n}", "protected void ^()\n{\n}", 22 | "public ^{ get; set; }", "private ^{ get; set; }", "internal ^{ get; set; }", "protected ^{ get; set; }" 23 | }; 24 | 25 | public AdvancedSample() 26 | { 27 | InitializeComponent(); 28 | BuildAutocompleteMenu(); 29 | } 30 | 31 | private void BuildAutocompleteMenu() 32 | { 33 | var items = new List(); 34 | 35 | foreach (var item in snippets) 36 | items.Add(new SnippetAutocompleteItem(item) { ImageIndex = 1 }); 37 | foreach (var item in declarationSnippets) 38 | items.Add(new DeclarationSnippet(item) { ImageIndex = 0 }); 39 | foreach (var item in methods) 40 | items.Add(new MethodAutocompleteItem(item) { ImageIndex = 2 }); 41 | foreach (var item in keywords) 42 | items.Add(new AutocompleteItem(item)); 43 | 44 | items.Add(new InsertSpaceSnippet()); 45 | items.Add(new InsertSpaceSnippet(@"^(\w+)([=<>!:]+)(\w+)$")); 46 | items.Add(new InsertEnterSnippet()); 47 | 48 | //set as autocomplete source 49 | autocompleteMenu1.SetAutocompleteItems(items); 50 | } 51 | } 52 | 53 | 54 | 55 | /// 56 | /// This item appears when any part of snippet text is typed 57 | /// 58 | class DeclarationSnippet : SnippetAutocompleteItem 59 | { 60 | public static string RegexSpecSymbolsPattern = @"[\^\$\[\]\(\)\.\\\*\+\|\?\{\}]"; 61 | 62 | public DeclarationSnippet(string snippet) 63 | : base(snippet) 64 | { 65 | } 66 | 67 | public override CompareResult Compare(string fragmentText) 68 | { 69 | var pattern = Regex.Replace(fragmentText, RegexSpecSymbolsPattern, "\\$0"); 70 | if (Regex.IsMatch(Text, "\\b" + pattern, RegexOptions.IgnoreCase)) 71 | return CompareResult.Visible; 72 | return CompareResult.Hidden; 73 | } 74 | } 75 | 76 | /// 77 | /// Divides numbers and words: "123AND456" -> "123 AND 456" 78 | /// Or "i=2" -> "i = 2" 79 | /// 80 | class InsertSpaceSnippet : AutocompleteItem 81 | { 82 | string pattern; 83 | 84 | public InsertSpaceSnippet(string pattern) 85 | : base("") 86 | { 87 | this.pattern = pattern; 88 | } 89 | 90 | public InsertSpaceSnippet() 91 | : this(@"^(\d+)([a-zA-Z_]+)(\d*)$") 92 | { 93 | } 94 | 95 | public override CompareResult Compare(string fragmentText) 96 | { 97 | if (Regex.IsMatch(fragmentText, pattern)) 98 | { 99 | Text = InsertSpaces(fragmentText); 100 | if (Text != fragmentText) 101 | return CompareResult.Visible; 102 | } 103 | return CompareResult.Hidden; 104 | } 105 | 106 | public string InsertSpaces(string fragment) 107 | { 108 | var m = Regex.Match(fragment, pattern); 109 | if (m.Groups[1].Value == "" && m.Groups[3].Value == "") 110 | return fragment; 111 | return (m.Groups[1].Value + " " + m.Groups[2].Value + " " + m.Groups[3].Value).Trim(); 112 | } 113 | 114 | public override string ToolTipTitle 115 | { 116 | get 117 | { 118 | return Text; 119 | } 120 | } 121 | } 122 | 123 | /// 124 | /// Inerts line break after '}' 125 | /// 126 | class InsertEnterSnippet : AutocompleteItem 127 | { 128 | int enterPlace = 0; 129 | 130 | public InsertEnterSnippet() 131 | : base("[Line break]") 132 | { 133 | } 134 | 135 | public override CompareResult Compare(string fragmentText) 136 | { 137 | var tb = Parent.TargetControlWrapper; 138 | 139 | var text = tb.Text; 140 | for (int i = Parent.Fragment.Start - 1; i >= 0; i--) 141 | { 142 | if (text[i] == '\n') 143 | break; 144 | if (text[i] == '}') 145 | { 146 | enterPlace = i; 147 | return CompareResult.Visible; 148 | } 149 | } 150 | 151 | return CompareResult.Hidden; 152 | } 153 | 154 | public override string GetTextForReplace() 155 | { 156 | var tb = Parent.TargetControlWrapper; 157 | 158 | //insert line break 159 | tb.SelectionStart = enterPlace + 1; 160 | tb.SelectedText = "\n"; 161 | Parent.Fragment.Start += 1; 162 | Parent.Fragment.End += 1; 163 | return Parent.Fragment.Text; 164 | } 165 | 166 | public override string ToolTipTitle 167 | { 168 | get 169 | { 170 | return "Insert line break after '}'"; 171 | } 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /Tester/ComboboxSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class ComboboxSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ComboboxSample)); 33 | this.label3 = new System.Windows.Forms.Label(); 34 | this.imageList1 = new System.Windows.Forms.ImageList(this.components); 35 | this.textBox1 = new System.Windows.Forms.TextBox(); 36 | this.autocompleteMenu1 = new AutocompleteMenuNS.AutocompleteMenu(); 37 | this.SuspendLayout(); 38 | // 39 | // label3 40 | // 41 | this.label3.Dock = System.Windows.Forms.DockStyle.Top; 42 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 43 | this.label3.Location = new System.Drawing.Point(0, 0); 44 | this.label3.Name = "label3"; 45 | this.label3.Size = new System.Drawing.Size(390, 55); 46 | this.label3.TabIndex = 5; 47 | this.label3.Text = "This example shows how to create analog of Combobox, but with very large dropdown" + 48 | " list and with searching by substring.\r\nTry to type something, for example \"get\"" + 49 | " or \"Form\""; 50 | // 51 | // imageList1 52 | // 53 | this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); 54 | this.imageList1.TransparentColor = System.Drawing.Color.Transparent; 55 | this.imageList1.Images.SetKeyName(0, "script_16x16.png"); 56 | this.imageList1.Images.SetKeyName(1, "app_16x16.png"); 57 | this.imageList1.Images.SetKeyName(2, "1302166543_virtualbox.png"); 58 | // 59 | // textBox1 60 | // 61 | this.textBox1.AcceptsTab = true; 62 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 63 | | System.Windows.Forms.AnchorStyles.Right))); 64 | this.autocompleteMenu1.SetAutocompleteMenu(this.textBox1, this.autocompleteMenu1); 65 | this.textBox1.Location = new System.Drawing.Point(12, 71); 66 | this.textBox1.Name = "textBox1"; 67 | this.textBox1.Size = new System.Drawing.Size(366, 20); 68 | this.textBox1.TabIndex = 0; 69 | // 70 | // autocompleteMenu1 71 | // 72 | this.autocompleteMenu1.AllowsTabKey = true; 73 | this.autocompleteMenu1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); 74 | this.autocompleteMenu1.ImageList = this.imageList1; 75 | this.autocompleteMenu1.Items = new string[0]; 76 | this.autocompleteMenu1.MaximumSize = new System.Drawing.Size(366, 200); 77 | this.autocompleteMenu1.MinFragmentLength = 0; 78 | this.autocompleteMenu1.SearchPattern = "."; 79 | // 80 | // ComboboxSample 81 | // 82 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 83 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 84 | this.ClientSize = new System.Drawing.Size(390, 189); 85 | this.Controls.Add(this.label3); 86 | this.Controls.Add(this.textBox1); 87 | this.Name = "ComboboxSample"; 88 | this.Text = "ComboboxSample"; 89 | this.ResumeLayout(false); 90 | this.PerformLayout(); 91 | 92 | } 93 | 94 | #endregion 95 | 96 | private System.Windows.Forms.TextBox textBox1; 97 | private AutocompleteMenuNS.AutocompleteMenu autocompleteMenu1; 98 | private System.Windows.Forms.Label label3; 99 | private System.Windows.Forms.ImageList imageList1; 100 | } 101 | } -------------------------------------------------------------------------------- /Tester/ComboboxSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Text.RegularExpressions; 9 | using System.Windows.Forms; 10 | using AutocompleteMenuNS; 11 | 12 | namespace Tester 13 | { 14 | public partial class ComboboxSample : Form 15 | { 16 | public ComboboxSample() 17 | { 18 | InitializeComponent(); 19 | BuildAutocompleteMenu(); 20 | } 21 | 22 | private void BuildAutocompleteMenu() 23 | { 24 | var items = new List(); 25 | 26 | //get all classes and methods of Form's assembly 27 | foreach (var cl in Assembly.GetAssembly(typeof(Form)).GetTypes()) 28 | { 29 | items.Add(new SubstringAutocompleteItem(cl.Name, false) {ImageIndex = 0}); 30 | foreach(var method in cl.GetMethods()) 31 | items.Add(new SubstringAutocompleteItem(method.Name, false) { ImageIndex = 2, MenuText = cl.Name + "." + method.Name + "()" }); 32 | } 33 | 34 | //set as autocomplete source 35 | autocompleteMenu1.SetAutocompleteItems(items); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tester/CustomItemSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class CustomItemSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomItemSample)); 33 | this.richTextBox1 = new System.Windows.Forms.RichTextBox(); 34 | this.textBox1 = new System.Windows.Forms.TextBox(); 35 | this.autocompleteMenu1 = new AutocompleteMenuNS.AutocompleteMenu(); 36 | this.imageList1 = new System.Windows.Forms.ImageList(this.components); 37 | this.label1 = new System.Windows.Forms.Label(); 38 | this.label2 = new System.Windows.Forms.Label(); 39 | this.label3 = new System.Windows.Forms.Label(); 40 | this.SuspendLayout(); 41 | // 42 | // richTextBox1 43 | // 44 | this.richTextBox1.AcceptsTab = true; 45 | this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 46 | | System.Windows.Forms.AnchorStyles.Left) 47 | | System.Windows.Forms.AnchorStyles.Right))); 48 | this.autocompleteMenu1.SetAutocompleteMenu(this.richTextBox1, this.autocompleteMenu1); 49 | this.richTextBox1.Location = new System.Drawing.Point(12, 126); 50 | this.richTextBox1.Name = "richTextBox1"; 51 | this.richTextBox1.Size = new System.Drawing.Size(356, 114); 52 | this.richTextBox1.TabIndex = 0; 53 | this.richTextBox1.Text = ""; 54 | // 55 | // textBox1 56 | // 57 | this.textBox1.AcceptsTab = true; 58 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 59 | | System.Windows.Forms.AnchorStyles.Right))); 60 | this.autocompleteMenu1.SetAutocompleteMenu(this.textBox1, this.autocompleteMenu1); 61 | this.textBox1.Location = new System.Drawing.Point(12, 78); 62 | this.textBox1.Name = "textBox1"; 63 | this.textBox1.Size = new System.Drawing.Size(356, 20); 64 | this.textBox1.TabIndex = 0; 65 | // 66 | // autocompleteMenu1 67 | // 68 | this.autocompleteMenu1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); 69 | this.autocompleteMenu1.ImageList = this.imageList1; 70 | this.autocompleteMenu1.Items = new string[0]; 71 | this.autocompleteMenu1.MinFragmentLength = 1; 72 | this.autocompleteMenu1.SearchPattern = "[\\w\\.@]"; 73 | this.autocompleteMenu1.TargetControlWrapper = null; 74 | // 75 | // imageList1 76 | // 77 | this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); 78 | this.imageList1.TransparentColor = System.Drawing.Color.Transparent; 79 | this.imageList1.Images.SetKeyName(0, "at.png"); 80 | // 81 | // label1 82 | // 83 | this.label1.AutoSize = true; 84 | this.label1.Location = new System.Drawing.Point(13, 57); 85 | this.label1.Name = "label1"; 86 | this.label1.Size = new System.Drawing.Size(46, 13); 87 | this.label1.TabIndex = 3; 88 | this.label1.Text = "TextBox"; 89 | // 90 | // label2 91 | // 92 | this.label2.AutoSize = true; 93 | this.label2.Location = new System.Drawing.Point(13, 110); 94 | this.label2.Name = "label2"; 95 | this.label2.Size = new System.Drawing.Size(68, 13); 96 | this.label2.TabIndex = 4; 97 | this.label2.Text = "RichTextBox"; 98 | // 99 | // label3 100 | // 101 | this.label3.Dock = System.Windows.Forms.DockStyle.Top; 102 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 103 | this.label3.Location = new System.Drawing.Point(0, 0); 104 | this.label3.Name = "label3"; 105 | this.label3.Size = new System.Drawing.Size(380, 49); 106 | this.label3.TabIndex = 5; 107 | this.label3.Text = "This example shows how to create custom autocomplete menu item.\r\nTry to type \"@\" " + 108 | "anywhere in the text."; 109 | // 110 | // CustomItemSample 111 | // 112 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 113 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 114 | this.ClientSize = new System.Drawing.Size(380, 256); 115 | this.Controls.Add(this.label3); 116 | this.Controls.Add(this.label2); 117 | this.Controls.Add(this.label1); 118 | this.Controls.Add(this.richTextBox1); 119 | this.Controls.Add(this.textBox1); 120 | this.Name = "CustomItemSample"; 121 | this.Text = "CustomItemSample"; 122 | this.ResumeLayout(false); 123 | this.PerformLayout(); 124 | 125 | } 126 | 127 | #endregion 128 | 129 | private System.Windows.Forms.TextBox textBox1; 130 | private System.Windows.Forms.RichTextBox richTextBox1; 131 | private AutocompleteMenuNS.AutocompleteMenu autocompleteMenu1; 132 | private System.Windows.Forms.Label label1; 133 | private System.Windows.Forms.Label label2; 134 | private System.Windows.Forms.Label label3; 135 | private System.Windows.Forms.ImageList imageList1; 136 | } 137 | } -------------------------------------------------------------------------------- /Tester/CustomItemSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using AutocompleteMenuNS; 9 | 10 | namespace Tester 11 | { 12 | public partial class CustomItemSample : Form 13 | { 14 | public CustomItemSample() 15 | { 16 | InitializeComponent(); 17 | 18 | autocompleteMenu1.AddItem(new EmailSnippet("007@sis.gov.uk")); 19 | autocompleteMenu1.AddItem(new EmailSnippet("adam@god.gov")); 20 | autocompleteMenu1.AddItem(new EmailSnippet("eva@god.gov")); 21 | autocompleteMenu1.AddItem(new EmailSnippet("sheldon.cooper@moon.pie.com")); 22 | autocompleteMenu1.AddItem(new EmailSnippet("smith@yahoo.com")); 23 | } 24 | } 25 | 26 | internal class EmailSnippet : AutocompleteItem 27 | { 28 | public EmailSnippet(string email): base(email) 29 | { 30 | ImageIndex = 0; 31 | ToolTipTitle = "Insert email:"; 32 | ToolTipText = email; 33 | 34 | // Test change colors 35 | ToolTipForeColor = Color.Red; 36 | ToolTipBackColor = Color.Aqua; 37 | } 38 | 39 | public override CompareResult Compare(string fragmentText) 40 | { 41 | if (fragmentText == Text) 42 | return CompareResult.VisibleAndSelected; 43 | if (fragmentText.Contains("@")) 44 | return CompareResult.Visible; 45 | return CompareResult.Hidden; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Tester/CustomListViewSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Windows.Forms; 5 | using AutocompleteMenuNS; 6 | 7 | namespace Tester 8 | { 9 | public partial class CustomListViewSample : Form 10 | { 11 | public CustomListViewSample() 12 | { 13 | InitializeComponent(); 14 | 15 | //attach custom listview 16 | autocompleteMenu1.ListView = myListView1; 17 | 18 | //build menu 19 | for (int i = 0; i < 1000; i++) 20 | autocompleteMenu1.AddItem(new AutocompleteItem(string.Format("{0:000}", i), i % 4)); 21 | } 22 | } 23 | 24 | /// 25 | /// Custom control, derived from ListView. 26 | /// It is implements IAutocompleteListView interface. 27 | /// 28 | public class MyListView : ListView, IAutocompleteListView 29 | { 30 | #region IAutocompleteListView 31 | 32 | public string[] ColumnsTitle { get; set; } 33 | public int[] ColumnsWidth { get; set; } 34 | 35 | public int SelectedItemIndex 36 | { 37 | get { 38 | var ind = this.SelectedIndices; 39 | if (ind.Count > 0) 40 | return ind[0]; 41 | else 42 | return -1; 43 | } 44 | set 45 | { 46 | if (value >= 0 && value < Items.Count) 47 | { 48 | Items[value].Selected = true; 49 | EnsureVisible(value); 50 | Invalidate(); 51 | } 52 | } 53 | } 54 | 55 | private IList visibleItems; 56 | 57 | public IList VisibleItems 58 | { 59 | get { return visibleItems; } 60 | set 61 | { 62 | visibleItems = value; 63 | BeginUpdate(); 64 | Items.Clear(); 65 | if (visibleItems != null) 66 | foreach(var item in visibleItems) 67 | { 68 | var listViewItem = new ListViewItem(item.ToString(), item.ImageIndex); 69 | Items.Add(listViewItem); 70 | } 71 | EndUpdate(); 72 | } 73 | } 74 | 75 | public event EventHandler ItemSelected; 76 | 77 | public event EventHandler ItemHovered; 78 | 79 | public ImageList ImageList 80 | { 81 | get { return this.LargeImageList; } 82 | set { this.LargeImageList = value; } 83 | } 84 | 85 | public Rectangle GetItemRectangle(int itemIndex) 86 | { 87 | return GetItemRect(itemIndex); 88 | } 89 | 90 | public Colors Colors { get; set; } 91 | 92 | #endregion 93 | 94 | public MyListView() 95 | { 96 | Colors = new Colors(); 97 | } 98 | 99 | protected override void OnDoubleClick(EventArgs e) 100 | { 101 | OnItemSelected(); 102 | } 103 | 104 | protected override void OnKeyPress(KeyPressEventArgs e) 105 | { 106 | if (e.KeyChar == '\r') 107 | OnItemSelected(); 108 | base.OnKeyPress(e); 109 | } 110 | 111 | private void OnItemSelected() 112 | { 113 | if (ItemSelected != null) 114 | ItemSelected(this, EventArgs.Empty); 115 | } 116 | 117 | 118 | public int ToolTipDuration 119 | { 120 | get 121 | { 122 | return 3000; 123 | } 124 | set 125 | { 126 | ; 127 | } 128 | } 129 | 130 | public void ShowToolTip(AutocompleteItem autocompleteItem, Control control = null) 131 | { 132 | } 133 | 134 | public void HideToolTip(Control control) 135 | { } 136 | 137 | public Control GetParentControl() 138 | { 139 | return this.Parent; 140 | } 141 | 142 | public int HighlightedItemIndex 143 | { 144 | get { return -1; } 145 | set { } 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /Tester/DataGridViewSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class DataGridViewSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.label3 = new System.Windows.Forms.Label(); 33 | this.dgv = new System.Windows.Forms.DataGridView(); 34 | //this.dgv = new NoArrowNavigateDataGridView(); 35 | this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 36 | this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 37 | this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 38 | this.autocompleteMenu1 = new AutocompleteMenuNS.AutocompleteMenu(); 39 | ((System.ComponentModel.ISupportInitialize)(this.dgv)).BeginInit(); 40 | this.SuspendLayout(); 41 | // 42 | // label1 43 | // 44 | this.label1.AutoSize = true; 45 | this.label1.Location = new System.Drawing.Point(9, 49); 46 | this.label1.Name = "label1"; 47 | this.label1.Size = new System.Drawing.Size(72, 13); 48 | this.label1.TabIndex = 3; 49 | this.label1.Text = "DataGridView"; 50 | // 51 | // label3 52 | // 53 | this.label3.Dock = System.Windows.Forms.DockStyle.Top; 54 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 55 | this.label3.Location = new System.Drawing.Point(0, 0); 56 | this.label3.Name = "label3"; 57 | this.label3.Size = new System.Drawing.Size(411, 39); 58 | this.label3.TabIndex = 5; 59 | this.label3.Text = "This example shows how to attach AutocompeteMenu to DataGridView. Start to type \"" + 60 | "abc\" in any cell."; 61 | // 62 | // dgv 63 | // 64 | this.dgv.AllowUserToDeleteRows = false; 65 | this.dgv.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 66 | | System.Windows.Forms.AnchorStyles.Left) 67 | | System.Windows.Forms.AnchorStyles.Right))); 68 | this.dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 69 | this.dgv.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 70 | this.Column1, 71 | this.Column2, 72 | this.Column3}); 73 | this.dgv.Location = new System.Drawing.Point(12, 65); 74 | this.dgv.Name = "dgv"; 75 | this.dgv.Size = new System.Drawing.Size(383, 179); 76 | this.dgv.TabIndex = 6; 77 | this.dgv.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_CellEndEdit); 78 | this.dgv.EditingControlShowing += new System.Windows.Forms.DataGridViewEditingControlShowingEventHandler(this.dgv_EditingControlShowing); 79 | // 80 | // Column1 81 | // 82 | this.Column1.HeaderText = "Column1"; 83 | this.Column1.Name = "Column1"; 84 | // 85 | // Column2 86 | // 87 | this.Column2.HeaderText = "Column2"; 88 | this.Column2.Name = "Column2"; 89 | // 90 | // Column3 91 | // 92 | this.Column3.HeaderText = "Column3"; 93 | this.Column3.Name = "Column3"; 94 | // 95 | // autocompleteMenu1 96 | // 97 | this.autocompleteMenu1.AppearInterval = 700; 98 | this.autocompleteMenu1.CaptureFocus = true; 99 | this.autocompleteMenu1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); 100 | this.autocompleteMenu1.ImageList = null; 101 | this.autocompleteMenu1.Items = new string[] { 102 | "abc", 103 | "abcd", 104 | "abcde", 105 | "abcdef"}; 106 | this.autocompleteMenu1.MinFragmentLength = 1; 107 | this.autocompleteMenu1.TargetControlWrapper = null; 108 | // 109 | // DataGridViewSample 110 | // 111 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 112 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 113 | this.ClientSize = new System.Drawing.Size(411, 256); 114 | this.Controls.Add(this.dgv); 115 | this.Controls.Add(this.label3); 116 | this.Controls.Add(this.label1); 117 | this.Name = "DataGridViewSample"; 118 | this.Text = "DataGridViewSample"; 119 | ((System.ComponentModel.ISupportInitialize)(this.dgv)).EndInit(); 120 | this.ResumeLayout(false); 121 | this.PerformLayout(); 122 | 123 | } 124 | 125 | #endregion 126 | 127 | private AutocompleteMenuNS.AutocompleteMenu autocompleteMenu1; 128 | private System.Windows.Forms.Label label1; 129 | private System.Windows.Forms.Label label3; 130 | private System.Windows.Forms.DataGridView dgv; 131 | private System.Windows.Forms.DataGridViewTextBoxColumn Column1; 132 | private System.Windows.Forms.DataGridViewTextBoxColumn Column2; 133 | private System.Windows.Forms.DataGridViewTextBoxColumn Column3; 134 | } 135 | } -------------------------------------------------------------------------------- /Tester/DataGridViewSample.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | using AutocompleteMenuNS; 3 | 4 | namespace Tester 5 | { 6 | public partial class DataGridViewSample : Form 7 | { 8 | public DataGridViewSample() 9 | { 10 | InitializeComponent(); 11 | 12 | for (int i = 0; i < 100; i++) 13 | dgv.Rows.Add(); 14 | } 15 | 16 | private Control editControl; 17 | 18 | private void dgv_CellEndEdit(object sender, DataGridViewCellEventArgs e) 19 | { 20 | autocompleteMenu1.TargetControlWrapper = null; 21 | autocompleteMenu1.SetAutocompleteMenu(editControl, null); 22 | } 23 | 24 | private void dgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) 25 | { 26 | editControl = e.Control; 27 | autocompleteMenu1.SetAutocompleteMenu(e.Control, autocompleteMenu1); 28 | } 29 | } 30 | 31 | /* 32 | internal class NoArrowNavigateDataGridView : DataGridView 33 | { 34 | public bool DisableArrowNavigationMode { get; set; } 35 | 36 | public NoArrowNavigateDataGridView() 37 | { 38 | DisableArrowNavigationMode = true; 39 | } 40 | 41 | protected override bool ProcessDialogKey(Keys keyData) 42 | { 43 | if (DisableArrowNavigationMode) 44 | if (EditingControl != null) 45 | if (keyData == Keys.Enter) 46 | return false; 47 | return base.ProcessDialogKey(keyData); 48 | } 49 | 50 | protected override bool ProcessDataGridViewKey(KeyEventArgs e) 51 | { 52 | if (DisableArrowNavigationMode) 53 | if (EditingControl != null) 54 | if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up || e.KeyCode == Keys.Enter) 55 | return false; 56 | return base.ProcessDataGridViewKey(e); 57 | } 58 | }*/ 59 | } 60 | -------------------------------------------------------------------------------- /Tester/DataGridViewSample.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | True 122 | 123 | 124 | True 125 | 126 | 127 | True 128 | 129 | 130 | 17, 17 131 | 132 | 133 | 72 134 | 135 | -------------------------------------------------------------------------------- /Tester/DynamicMenuSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class DynamicMenuSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DynamicMenuSample)); 32 | this.label3 = new System.Windows.Forms.Label(); 33 | this.label2 = new System.Windows.Forms.Label(); 34 | this.tb = new System.Windows.Forms.RichTextBox(); 35 | this.autocompleteMenu1 = new AutocompleteMenuNS.AutocompleteMenu(); 36 | this.SuspendLayout(); 37 | // 38 | // label3 39 | // 40 | this.label3.Dock = System.Windows.Forms.DockStyle.Top; 41 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 42 | this.label3.Location = new System.Drawing.Point(0, 0); 43 | this.label3.Name = "label3"; 44 | this.label3.Size = new System.Drawing.Size(393, 49); 45 | this.label3.TabIndex = 10; 46 | this.label3.Text = "This example shows how to create dynamic context-sensitive autocomplete menu."; 47 | // 48 | // label2 49 | // 50 | this.label2.AutoSize = true; 51 | this.label2.Location = new System.Drawing.Point(12, 60); 52 | this.label2.Name = "label2"; 53 | this.label2.Size = new System.Drawing.Size(68, 13); 54 | this.label2.TabIndex = 9; 55 | this.label2.Text = "RichTextBox"; 56 | // 57 | // tb 58 | // 59 | this.tb.AcceptsTab = true; 60 | this.tb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 61 | | System.Windows.Forms.AnchorStyles.Left) 62 | | System.Windows.Forms.AnchorStyles.Right))); 63 | this.autocompleteMenu1.SetAutocompleteMenu(this.tb, this.autocompleteMenu1); 64 | this.tb.Location = new System.Drawing.Point(12, 76); 65 | this.tb.Name = "tb"; 66 | this.tb.Size = new System.Drawing.Size(369, 167); 67 | this.tb.TabIndex = 6; 68 | this.tb.Text = resources.GetString("tb.Text"); 69 | this.tb.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tb_KeyDown); 70 | // 71 | // autocompleteMenu1 72 | // 73 | this.autocompleteMenu1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); 74 | this.autocompleteMenu1.ImageList = null; 75 | this.autocompleteMenu1.Items = new string[0]; 76 | this.autocompleteMenu1.MinFragmentLength = 1; 77 | this.autocompleteMenu1.SearchPattern = "[\\w]"; 78 | // 79 | // DynamicMenuSample 80 | // 81 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 82 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 83 | this.ClientSize = new System.Drawing.Size(393, 255); 84 | this.Controls.Add(this.label3); 85 | this.Controls.Add(this.label2); 86 | this.Controls.Add(this.tb); 87 | this.Name = "DynamicMenuSample"; 88 | this.Text = "DynamicMenu"; 89 | this.ResumeLayout(false); 90 | this.PerformLayout(); 91 | 92 | } 93 | 94 | #endregion 95 | 96 | private System.Windows.Forms.Label label3; 97 | private System.Windows.Forms.Label label2; 98 | private System.Windows.Forms.RichTextBox tb; 99 | private AutocompleteMenuNS.AutocompleteMenu autocompleteMenu1; 100 | } 101 | } -------------------------------------------------------------------------------- /Tester/DynamicMenuSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Text.RegularExpressions; 8 | using System.Windows.Forms; 9 | using AutocompleteMenuNS; 10 | 11 | namespace Tester 12 | { 13 | public partial class DynamicMenuSample : Form 14 | { 15 | public DynamicMenuSample() 16 | { 17 | InitializeComponent(); 18 | 19 | autocompleteMenu1.SetAutocompleteItems(new DynamicCollection(tb)); 20 | } 21 | 22 | private void tb_KeyDown(object sender, KeyEventArgs e) 23 | { 24 | //forcibly shows menu 25 | if (e.Control && e.KeyCode == Keys.Space) 26 | autocompleteMenu1.Show(tb, true); 27 | } 28 | } 29 | 30 | internal class DynamicCollection : IEnumerable 31 | { 32 | private TextBoxBase tb; 33 | 34 | public DynamicCollection(TextBoxBase tb) 35 | { 36 | this.tb = tb; 37 | } 38 | 39 | public IEnumerator GetEnumerator() 40 | { 41 | return BuildList().GetEnumerator(); 42 | } 43 | 44 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 45 | { 46 | return GetEnumerator(); 47 | } 48 | 49 | private IEnumerable BuildList() 50 | { 51 | //find all words of the text 52 | var words = new Dictionary(); 53 | foreach (Match m in Regex.Matches(tb.Text, @"\b\w+\b")) 54 | words[m.Value] = m.Value; 55 | 56 | //return autocomplete items 57 | foreach(var word in words.Keys) 58 | yield return new AutocompleteItem(word); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Tester/DynamicMenuSample.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | Autocomplete Menu dynamically parses this text, and suggests words from it. 125 | Start to type "words" or "and" or any word from this text. 126 | Also, you can press Ctrl-Space for showing of all words of the text. 127 | 128 | -------------------------------------------------------------------------------- /Tester/DynamicTooltipSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class DynamicTooltipSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DynamicTooltipSample)); 32 | this.label2 = new System.Windows.Forms.Label(); 33 | this.label3 = new System.Windows.Forms.Label(); 34 | this.richTextBox1 = new System.Windows.Forms.RichTextBox(); 35 | this.autocompleteMenu1 = new AutocompleteMenuNS.AutocompleteMenu(); 36 | this.SuspendLayout(); 37 | // 38 | // label2 39 | // 40 | this.label2.AutoSize = true; 41 | this.label2.Location = new System.Drawing.Point(12, 44); 42 | this.label2.Name = "label2"; 43 | this.label2.Size = new System.Drawing.Size(68, 13); 44 | this.label2.TabIndex = 4; 45 | this.label2.Text = "RichTextBox"; 46 | // 47 | // label3 48 | // 49 | this.label3.Dock = System.Windows.Forms.DockStyle.Top; 50 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 51 | this.label3.Location = new System.Drawing.Point(0, 0); 52 | this.label3.Name = "label3"; 53 | this.label3.Size = new System.Drawing.Size(445, 44); 54 | this.label3.TabIndex = 5; 55 | this.label3.Text = "This example shows how to dynamically create tooltip for items.\r\nStart to type \"a" + 56 | "bc\" into textbox. Click on the item of AutocompleteMenu."; 57 | // 58 | // richTextBox1 59 | // 60 | this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 61 | | System.Windows.Forms.AnchorStyles.Left) 62 | | System.Windows.Forms.AnchorStyles.Right))); 63 | this.autocompleteMenu1.SetAutocompleteMenu(this.richTextBox1, this.autocompleteMenu1); 64 | this.richTextBox1.Location = new System.Drawing.Point(12, 60); 65 | this.richTextBox1.Name = "richTextBox1"; 66 | this.richTextBox1.Size = new System.Drawing.Size(421, 180); 67 | this.richTextBox1.TabIndex = 0; 68 | this.richTextBox1.Text = ""; 69 | // 70 | // autocompleteMenu1 71 | // 72 | this.autocompleteMenu1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 73 | this.autocompleteMenu1.ImageList = null; 74 | this.autocompleteMenu1.Items = new string[] { 75 | "abc", 76 | "abcd", 77 | "abcde", 78 | "abcdef"}; 79 | this.autocompleteMenu1.LeftPadding = 0; 80 | this.autocompleteMenu1.TargetControlWrapper = null; 81 | this.autocompleteMenu1.ToolTipDuration = 1000000; 82 | this.autocompleteMenu1.Hovered += new System.EventHandler(this.autocompleteMenu1_Hovered); 83 | // 84 | // DynamicTooltipSample 85 | // 86 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 87 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 88 | this.ClientSize = new System.Drawing.Size(445, 256); 89 | this.Controls.Add(this.label3); 90 | this.Controls.Add(this.label2); 91 | this.Controls.Add(this.richTextBox1); 92 | this.Name = "DynamicTooltipSample"; 93 | this.Text = "Dynamic tooltip sample"; 94 | this.ResumeLayout(false); 95 | this.PerformLayout(); 96 | 97 | } 98 | 99 | #endregion 100 | 101 | private System.Windows.Forms.RichTextBox richTextBox1; 102 | private AutocompleteMenuNS.AutocompleteMenu autocompleteMenu1; 103 | private System.Windows.Forms.Label label2; 104 | private System.Windows.Forms.Label label3; 105 | } 106 | } -------------------------------------------------------------------------------- /Tester/DynamicTooltipSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using System.IO; 9 | using AutocompleteMenuNS; 10 | 11 | namespace Tester 12 | { 13 | public partial class DynamicTooltipSample : Form 14 | { 15 | public DynamicTooltipSample() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void autocompleteMenu1_Hovered(object sender, HoveredEventArgs e) 21 | { 22 | if (e.Item != null) 23 | { 24 | e.Item.ToolTipTitle = "Dynamic tooltip"; 25 | e.Item.ToolTipText = "This tooltip was dynamically generated for item " + e.Item.ToString(); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Tester/DynamicTooltipSample.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 125 | AAEAAAD/////AQAAAAAAAAAMAgAAAEdBdXRvY29tcGxldGVNZW51LCBWZXJzaW9uPTEuMy40LjAsIEN1 126 | bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAwDAAAAUVN5c3RlbS5EcmF3aW5nLCBWZXJz 127 | aW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49YjAzZjVmN2YxMWQ1MGEz 128 | YQUBAAAAGUF1dG9jb21wbGV0ZU1lbnVOUy5Db2xvcnMGAAAAGjxGb3JlQ29sb3I+a19fQmFja2luZ0Zp 129 | ZWxkGjxCYWNrQ29sb3I+a19fQmFja2luZ0ZpZWxkIjxTZWxlY3RlZEZvcmVDb2xvcj5rX19CYWNraW5n 130 | RmllbGQiPFNlbGVjdGVkQmFja0NvbG9yPmtfX0JhY2tpbmdGaWVsZCM8U2VsZWN0ZWRCYWNrQ29sb3Iy 131 | PmtfX0JhY2tpbmdGaWVsZCI8SGlnaGxpZ2h0aW5nQ29sb3I+a19fQmFja2luZ0ZpZWxkBAQEBAQEFFN5 132 | c3RlbS5EcmF3aW5nLkNvbG9yAwAAABRTeXN0ZW0uRHJhd2luZy5Db2xvcgMAAAAUU3lzdGVtLkRyYXdp 133 | bmcuQ29sb3IDAAAAFFN5c3RlbS5EcmF3aW5nLkNvbG9yAwAAABRTeXN0ZW0uRHJhd2luZy5Db2xvcgMA 134 | AAAUU3lzdGVtLkRyYXdpbmcuQ29sb3IDAAAAAgAAAAX8////FFN5c3RlbS5EcmF3aW5nLkNvbG9yBAAA 135 | AARuYW1lBXZhbHVlCmtub3duQ29sb3IFc3RhdGUBAAAACQcHAwAAAAoAAAAAAAAAACMAAQAB+/////z/ 136 | //8KAAAAAAAAAACkAAEAAfr////8////CgAAAAAAAAAAIwABAAH5/////P///woAAAAAAAAAAH8AAQAB 137 | +P////z///8KAAAAAAAAAACkAAEAAff////8////CgAAAAAAAAAAfwABAAs= 138 | 139 | 140 | -------------------------------------------------------------------------------- /Tester/ExtraLargeSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class ExtraLargeSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.label2 = new System.Windows.Forms.Label(); 33 | this.label3 = new System.Windows.Forms.Label(); 34 | this.richTextBox1 = new System.Windows.Forms.RichTextBox(); 35 | this.textBox1 = new System.Windows.Forms.TextBox(); 36 | this.autocompleteMenu1 = new AutocompleteMenuNS.AutocompleteMenu(); 37 | this.SuspendLayout(); 38 | // 39 | // label1 40 | // 41 | this.label1.AutoSize = true; 42 | this.label1.Location = new System.Drawing.Point(13, 57); 43 | this.label1.Name = "label1"; 44 | this.label1.Size = new System.Drawing.Size(46, 13); 45 | this.label1.TabIndex = 3; 46 | this.label1.Text = "TextBox"; 47 | // 48 | // label2 49 | // 50 | this.label2.AutoSize = true; 51 | this.label2.Location = new System.Drawing.Point(13, 110); 52 | this.label2.Name = "label2"; 53 | this.label2.Size = new System.Drawing.Size(68, 13); 54 | this.label2.TabIndex = 4; 55 | this.label2.Text = "RichTextBox"; 56 | // 57 | // label3 58 | // 59 | this.label3.Dock = System.Windows.Forms.DockStyle.Top; 60 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 61 | this.label3.Location = new System.Drawing.Point(0, 0); 62 | this.label3.Name = "label3"; 63 | this.label3.Size = new System.Drawing.Size(380, 49); 64 | this.label3.TabIndex = 5; 65 | this.label3.Text = "This example shows performance of extra large autocomplete menu. Autocomplete men" + 66 | "u contains 1 000 000 items.\r\nStart to type \"123\" into any textbox."; 67 | // 68 | // richTextBox1 69 | // 70 | this.richTextBox1.AcceptsTab = true; 71 | this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 72 | | System.Windows.Forms.AnchorStyles.Left) 73 | | System.Windows.Forms.AnchorStyles.Right))); 74 | this.autocompleteMenu1.SetAutocompleteMenu(this.richTextBox1, this.autocompleteMenu1); 75 | this.richTextBox1.Location = new System.Drawing.Point(12, 126); 76 | this.richTextBox1.Name = "richTextBox1"; 77 | this.richTextBox1.Size = new System.Drawing.Size(356, 114); 78 | this.richTextBox1.TabIndex = 0; 79 | this.richTextBox1.Text = ""; 80 | // 81 | // textBox1 82 | // 83 | this.textBox1.AcceptsTab = true; 84 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 85 | | System.Windows.Forms.AnchorStyles.Right))); 86 | this.autocompleteMenu1.SetAutocompleteMenu(this.textBox1, this.autocompleteMenu1); 87 | this.textBox1.Location = new System.Drawing.Point(12, 78); 88 | this.textBox1.Name = "textBox1"; 89 | this.textBox1.Size = new System.Drawing.Size(356, 20); 90 | this.textBox1.TabIndex = 0; 91 | // 92 | // autocompleteMenu1 93 | // 94 | this.autocompleteMenu1.AppearInterval = 10; 95 | this.autocompleteMenu1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 96 | this.autocompleteMenu1.ImageList = null; 97 | this.autocompleteMenu1.Items = new string[0]; 98 | this.autocompleteMenu1.TargetControlWrapper = null; 99 | // 100 | // ExtraLargeSample 101 | // 102 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 103 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 104 | this.ClientSize = new System.Drawing.Size(380, 256); 105 | this.Controls.Add(this.label3); 106 | this.Controls.Add(this.label2); 107 | this.Controls.Add(this.label1); 108 | this.Controls.Add(this.richTextBox1); 109 | this.Controls.Add(this.textBox1); 110 | this.Name = "ExtraLargeSample"; 111 | this.Text = "ExtraLargeSample"; 112 | this.ResumeLayout(false); 113 | this.PerformLayout(); 114 | 115 | } 116 | 117 | #endregion 118 | 119 | private System.Windows.Forms.TextBox textBox1; 120 | private System.Windows.Forms.RichTextBox richTextBox1; 121 | private System.Windows.Forms.Label label1; 122 | private System.Windows.Forms.Label label2; 123 | private System.Windows.Forms.Label label3; 124 | private AutocompleteMenuNS.AutocompleteMenu autocompleteMenu1; 125 | } 126 | } -------------------------------------------------------------------------------- /Tester/ExtraLargeSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using AutocompleteMenuNS; 9 | 10 | namespace Tester 11 | { 12 | public partial class ExtraLargeSample : Form 13 | { 14 | public ExtraLargeSample() 15 | { 16 | InitializeComponent(); 17 | 18 | //build autocomplete menu 19 | List list = new List(); 20 | for (int i = 1; i <= 1000000; i++) 21 | list.Add(i.ToString()); 22 | 23 | autocompleteMenu1.SetAutocompleteItems(list); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Tester/ExtraLargeSample.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /Tester/MainForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using AutocompleteMenuNS; 4 | 5 | namespace Tester 6 | { 7 | public partial class MainForm : Form 8 | { 9 | public MainForm() 10 | { 11 | InitializeComponent(); 12 | } 13 | 14 | private void button1_Click(object sender, EventArgs e) 15 | { 16 | new SimplestSample().Show(); 17 | } 18 | 19 | private void button3_Click(object sender, EventArgs e) 20 | { 21 | new ExtraLargeSample().Show(); 22 | } 23 | 24 | private void button2_Click(object sender, EventArgs e) 25 | { 26 | new AdvancedSample().Show(); 27 | } 28 | 29 | private void button4_Click(object sender, EventArgs e) 30 | { 31 | new CustomItemSample().Show(); 32 | } 33 | 34 | private void button5_Click(object sender, EventArgs e) 35 | { 36 | new ComboboxSample().Show(); 37 | } 38 | 39 | private void button6_Click(object sender, EventArgs e) 40 | { 41 | new MultiColumnSample().Show(); 42 | } 43 | 44 | private void button7_Click(object sender, EventArgs e) 45 | { 46 | new CustomListViewSample().Show(); 47 | } 48 | 49 | private void button8_Click(object sender, EventArgs e) 50 | { 51 | new DynamicMenuSample().Show(); 52 | } 53 | 54 | private void button9_Click(object sender, EventArgs e) 55 | { 56 | new DataGridViewSample().Show(); 57 | } 58 | 59 | private void button10_Click(object sender, EventArgs e) 60 | { 61 | new DynamicTooltipSample().Show(); 62 | } 63 | 64 | private void MainForm_DoubleClick(object sender, EventArgs e) 65 | { 66 | new Sandbox().Show(); 67 | } 68 | 69 | private void button11_Click(object sender, EventArgs e) 70 | { 71 | new ScintillaSample().Show(); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Tester/MainForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /Tester/MultiColumnSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class MultiColumnSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MultiColumnSample)); 33 | this.richTextBox1 = new System.Windows.Forms.RichTextBox(); 34 | this.textBox1 = new System.Windows.Forms.TextBox(); 35 | this.autocompleteMenu1 = new AutocompleteMenuNS.AutocompleteMenu(); 36 | this.imageList1 = new System.Windows.Forms.ImageList(this.components); 37 | this.label1 = new System.Windows.Forms.Label(); 38 | this.label2 = new System.Windows.Forms.Label(); 39 | this.label3 = new System.Windows.Forms.Label(); 40 | this.checkBox1 = new System.Windows.Forms.CheckBox(); 41 | this.SuspendLayout(); 42 | // 43 | // richTextBox1 44 | // 45 | this.richTextBox1.AcceptsTab = true; 46 | this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 47 | | System.Windows.Forms.AnchorStyles.Left) 48 | | System.Windows.Forms.AnchorStyles.Right))); 49 | this.autocompleteMenu1.SetAutocompleteMenu(this.richTextBox1, this.autocompleteMenu1); 50 | this.richTextBox1.Location = new System.Drawing.Point(12, 126); 51 | this.richTextBox1.Name = "richTextBox1"; 52 | this.richTextBox1.Size = new System.Drawing.Size(356, 114); 53 | this.richTextBox1.TabIndex = 0; 54 | this.richTextBox1.Text = ""; 55 | // 56 | // textBox1 57 | // 58 | this.textBox1.AcceptsTab = true; 59 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 60 | | System.Windows.Forms.AnchorStyles.Right))); 61 | this.autocompleteMenu1.SetAutocompleteMenu(this.textBox1, this.autocompleteMenu1); 62 | this.textBox1.Location = new System.Drawing.Point(12, 78); 63 | this.textBox1.Name = "textBox1"; 64 | this.textBox1.Size = new System.Drawing.Size(356, 20); 65 | this.textBox1.TabIndex = 0; 66 | // 67 | // autocompleteMenu1 68 | // 69 | this.autocompleteMenu1.Colors = ((AutocompleteMenuNS.Colors)(resources.GetObject("autocompleteMenu1.Colors"))); 70 | this.autocompleteMenu1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); 71 | this.autocompleteMenu1.ImageList = this.imageList1; 72 | this.autocompleteMenu1.Items = new string[0]; 73 | this.autocompleteMenu1.MinFragmentLength = 1; 74 | this.autocompleteMenu1.TargetControlWrapper = null; 75 | // 76 | // imageList1 77 | // 78 | this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); 79 | this.imageList1.TransparentColor = System.Drawing.Color.Transparent; 80 | this.imageList1.Images.SetKeyName(0, "user_man.png"); 81 | this.imageList1.Images.SetKeyName(1, "user_woman.png"); 82 | // 83 | // label1 84 | // 85 | this.label1.AutoSize = true; 86 | this.label1.Location = new System.Drawing.Point(13, 57); 87 | this.label1.Name = "label1"; 88 | this.label1.Size = new System.Drawing.Size(46, 13); 89 | this.label1.TabIndex = 3; 90 | this.label1.Text = "TextBox"; 91 | // 92 | // label2 93 | // 94 | this.label2.AutoSize = true; 95 | this.label2.Location = new System.Drawing.Point(13, 110); 96 | this.label2.Name = "label2"; 97 | this.label2.Size = new System.Drawing.Size(68, 13); 98 | this.label2.TabIndex = 4; 99 | this.label2.Text = "RichTextBox"; 100 | // 101 | // label3 102 | // 103 | this.label3.Dock = System.Windows.Forms.DockStyle.Top; 104 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 105 | this.label3.Location = new System.Drawing.Point(0, 0); 106 | this.label3.Name = "label3"; 107 | this.label3.Size = new System.Drawing.Size(380, 49); 108 | this.label3.TabIndex = 5; 109 | this.label3.Text = "This example shows multicolumn autocomplete menu.\r\nStart to type \"smith\" or \"sam\"" + 110 | "."; 111 | // 112 | // checkBox1 113 | // 114 | this.checkBox1.AutoSize = true; 115 | this.checkBox1.Location = new System.Drawing.Point(12, 38); 116 | this.checkBox1.Name = "checkBox1"; 117 | this.checkBox1.Size = new System.Drawing.Size(102, 17); 118 | this.checkBox1.TabIndex = 6; 119 | this.checkBox1.Text = "Enable Headers"; 120 | this.checkBox1.UseVisualStyleBackColor = true; 121 | this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); 122 | // 123 | // MultiColumnSample 124 | // 125 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 126 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 127 | this.ClientSize = new System.Drawing.Size(380, 256); 128 | this.Controls.Add(this.checkBox1); 129 | this.Controls.Add(this.label3); 130 | this.Controls.Add(this.label2); 131 | this.Controls.Add(this.label1); 132 | this.Controls.Add(this.richTextBox1); 133 | this.Controls.Add(this.textBox1); 134 | this.Name = "MultiColumnSample"; 135 | this.Text = "MulticolumnSample"; 136 | this.Load += new System.EventHandler(this.MultiColumnSample_Load); 137 | this.ResumeLayout(false); 138 | this.PerformLayout(); 139 | 140 | } 141 | 142 | #endregion 143 | 144 | private System.Windows.Forms.TextBox textBox1; 145 | private System.Windows.Forms.RichTextBox richTextBox1; 146 | private AutocompleteMenuNS.AutocompleteMenu autocompleteMenu1; 147 | private System.Windows.Forms.Label label1; 148 | private System.Windows.Forms.Label label2; 149 | private System.Windows.Forms.Label label3; 150 | private System.Windows.Forms.ImageList imageList1; 151 | private System.Windows.Forms.CheckBox checkBox1; 152 | } 153 | } -------------------------------------------------------------------------------- /Tester/MultiColumnSample.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Windows.Forms; 3 | using AutocompleteMenuNS; 4 | 5 | namespace Tester 6 | { 7 | public partial class MultiColumnSample : Form 8 | { 9 | public MultiColumnSample() 10 | { 11 | InitializeComponent(); 12 | 13 | autocompleteMenu1.MaximumSize = new System.Drawing.Size(250, 200); 14 | var columnWidth = new int[] { 50, 200 }; 15 | var alig = new[] { StringAlignment.Near, StringAlignment.Far }; 16 | 17 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "001", "Mr. Adam Smith" }, "Adam Smith") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 18 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "002", "Ms. Eva Smith" }, "Eva Smith") { Alignments = alig,ColumnWidth = columnWidth, ImageIndex = 1 }); 19 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "003", "Mr. Ollie Craig" }, "Ollie Craig") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 20 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "004", "Mr. Tim Beauvais" }, "Tim Beauvais") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 21 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "005", "Ms. Caitlin Zambrano" }, "Caitlin Zambrano") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 22 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "006", "Ms. Mao Brune" }, "Mao Brune") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 23 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "007", "Ms. Tianna Nemitz" }, "Tianna Nemitz") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 24 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "008", "Ms. Kaylene Wang" }, "Kaylene Wang") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 25 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "009", "Ms. Estell Cavazos" }, "Estell Cavazos") { Alignments = alig,ColumnWidth = columnWidth, ImageIndex = 0 }); 26 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "010", "Ms. Denna Villalta" }, "Denna Villalta") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 27 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "011", "Ms. Fernanda Rosso" }, "Fernanda Rosso") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 28 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "012", "Ms. Zina Shealy" }, "Zina Shealy") { Alignments = alig,ColumnWidth = columnWidth, ImageIndex = 0 }); 29 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "013", "Ms. Shavon Ocampo" }, "Shavon Ocampo") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 30 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "014", "Mr. Forest Giguere" }, "Forest Giguere") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 31 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "015", "Mr. Eusebio Bealer" }, "Eusebio Bealer") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 32 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "016", "Mr. Erin Winkel" }, "Erin Winkel") { Alignments = alig,ColumnWidth = columnWidth, ImageIndex = 0 }); 33 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "017", "Mr. Clinton Duclos" }, "Clinton Duclos") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 34 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "018", "Mr. Gavin Ricotta" }, "Gavin Ricotta") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 35 | autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "019", "Mr. Jackie Julien" }, "Jackie Julien") {Alignments = alig, ColumnWidth = columnWidth, ImageIndex = 0 }); 36 | } 37 | 38 | private void MultiColumnSample_Load(object sender, System.EventArgs e) 39 | { 40 | 41 | } 42 | 43 | private void checkBox1_CheckedChanged(object sender, System.EventArgs e) 44 | { 45 | if (checkBox1.Checked) 46 | autocompleteMenu1.SetColumns(new[] { "ID", "Name" }, new[] { 50, 200 }); 47 | else 48 | autocompleteMenu1.SetColumns(null); 49 | 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Tester/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | 5 | namespace Tester 6 | { 7 | static class Program 8 | { 9 | /// 10 | /// The main entry point for the application. 11 | /// 12 | [STAThread] 13 | static void Main() 14 | { 15 | Application.EnableVisualStyles(); 16 | Application.SetHighDpiMode(HighDpiMode.SystemAware); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new MainForm()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Tester/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Tester")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Tester")] 13 | [assembly: AssemblyCopyright("Copyright © 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c0ed3287-a801-4fa2-8b0f-19456cb7d34a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Tester/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Tester.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tester.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Tester/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Tester/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Tester.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Tester/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Tester/Sandbox.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class Sandbox 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // Sandbox 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.ClientSize = new System.Drawing.Size(380, 256); 38 | this.Name = "Sandbox"; 39 | this.Text = "Sandbox"; 40 | this.ResumeLayout(false); 41 | 42 | } 43 | 44 | #endregion 45 | 46 | } 47 | } -------------------------------------------------------------------------------- /Tester/Sandbox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text.RegularExpressions; 4 | using System.Windows.Forms; 5 | using AutocompleteMenuNS; 6 | 7 | namespace Tester 8 | { 9 | public partial class Sandbox : Form 10 | { 11 | AutocompleteMenu menu; 12 | List items; 13 | 14 | public Sandbox() 15 | { 16 | InitializeComponent(); 17 | 18 | menu = new AutocompleteMenu(); 19 | //triggers 20 | MyMethodItem.Triggers = new char[] {'.', ':'}; 21 | menu.SearchPattern = @"[\w" + Regex.Escape(new string(MyMethodItem.Triggers)) + "]"; 22 | 23 | //create items 24 | items = new List(); 25 | items.Add(new MyMethodItem("ToString")); 26 | 27 | //assign items to the menu 28 | menu.SetAutocompleteItems(items); 29 | 30 | // 31 | var tb = new RichTextBox() { Parent = this, Dock = DockStyle.Fill }; 32 | menu.SetAutocompleteMenu(tb, menu); 33 | 34 | var f = new Form(); 35 | f.Show(); 36 | (menu.ListView as Control).Parent.VisibleChanged += (o, e) => 37 | { 38 | (menu.ListView as Control).Parent.Top = 100; 39 | }; 40 | } 41 | 42 | void Parent_VisibleChanged(object sender, EventArgs e) 43 | { 44 | (menu.ListView as Control).Parent.Top = 100; 45 | } 46 | } 47 | 48 | class MyMethodItem : AutocompleteItem 49 | { 50 | public static char[] Triggers = new char[]{'.'}; 51 | string firstPart; 52 | string methodNameLowercase; 53 | private char trigger; 54 | 55 | public MyMethodItem(string methodName) : base(methodName) 56 | { 57 | this.methodNameLowercase = methodName.ToLower(); 58 | } 59 | 60 | public override CompareResult Compare(string fragmentText) 61 | { 62 | int i = fragmentText.LastIndexOfAny(Triggers); 63 | 64 | if (i < 0) 65 | return CompareResult.Hidden; 66 | 67 | trigger = fragmentText[i]; 68 | string lastPart = fragmentText.Substring(i + 1); 69 | firstPart = fragmentText.Substring(0, i); 70 | 71 | if (lastPart == "") return CompareResult.Visible; 72 | if (Text.StartsWith(lastPart, StringComparison.InvariantCultureIgnoreCase)) 73 | return CompareResult.VisibleAndSelected; 74 | if (methodNameLowercase.Contains(lastPart.ToLower())) 75 | return CompareResult.Visible; 76 | 77 | return CompareResult.Hidden; 78 | } 79 | 80 | public override string GetTextForReplace() 81 | { 82 | return firstPart + trigger + Text; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Tester/Sandbox.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Tester/ScintillaSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class ScintillaSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ScintillaSample)); 32 | this.AutoComplete = new AutocompleteMenuNS.AutocompleteMenu(); 33 | this.scintilla1 = new ScintillaNET.Scintilla(); 34 | this.SuspendLayout(); 35 | // 36 | // AutoComplete 37 | // 38 | this.AutoComplete.AutoWidth = true; 39 | this.AutoComplete.Colors = ((AutocompleteMenuNS.Colors)(resources.GetObject("AutoComplete.Colors"))); 40 | this.AutoComplete.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); 41 | this.AutoComplete.ImageList = null; 42 | this.AutoComplete.Items = new string[] { 43 | "Ahmed", 44 | "Gasser", 45 | "Anas", 46 | "Yolo", 47 | "Hey", 48 | "Mamdouh", 49 | "Mohammed", 50 | "COLOR_RED", 51 | "SendClientMessage", 52 | "COLOR_RED_GREY_BLUE_TEST_123_AHA"}; 53 | this.AutoComplete.MaximumSize = new System.Drawing.Size(500, 200); 54 | this.AutoComplete.TargetControlWrapper = null; 55 | // 56 | // scintilla1 57 | // 58 | this.scintilla1.AutoCMaxHeight = 9; 59 | this.scintilla1.BiDirectionality = ScintillaNET.BiDirectionalDisplayType.Disabled; 60 | this.scintilla1.CaretLineBackColor = System.Drawing.Color.White; 61 | this.scintilla1.CaretLineVisible = true; 62 | this.scintilla1.Dock = System.Windows.Forms.DockStyle.Fill; 63 | this.scintilla1.LexerName = null; 64 | this.scintilla1.Location = new System.Drawing.Point(0, 0); 65 | this.scintilla1.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7); 66 | this.scintilla1.Name = "scintilla1"; 67 | this.scintilla1.ScrollWidth = 93; 68 | this.scintilla1.Size = new System.Drawing.Size(904, 847); 69 | this.scintilla1.TabIndents = true; 70 | this.scintilla1.TabIndex = 0; 71 | this.scintilla1.Text = "scintilla1"; 72 | this.scintilla1.UseRightToLeftReadingLayout = false; 73 | this.scintilla1.WrapMode = ScintillaNET.WrapMode.None; 74 | // 75 | // ScintillaSample 76 | // 77 | this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); 78 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 79 | this.ClientSize = new System.Drawing.Size(904, 847); 80 | this.Controls.Add(this.scintilla1); 81 | this.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7); 82 | this.Name = "ScintillaSample"; 83 | this.Text = "ScintillaSample"; 84 | this.Load += new System.EventHandler(this.ScintillaSample_Load); 85 | this.ResumeLayout(false); 86 | 87 | } 88 | 89 | #endregion 90 | private AutocompleteMenuNS.AutocompleteMenu AutoComplete; 91 | private ScintillaNET.Scintilla scintilla1; 92 | } 93 | } -------------------------------------------------------------------------------- /Tester/ScintillaSample.cs: -------------------------------------------------------------------------------- 1 | using AutocompleteMenuNS; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace Tester 11 | { 12 | public partial class ScintillaSample : Form 13 | { 14 | public ScintillaSample() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | private void ScintillaSample_Load(object sender, EventArgs e) 20 | { 21 | AutoComplete.TargetControlWrapper = new ScintillaWrapper(scintilla1); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Tester/ScintillaSample.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | text/microsoft-resx 50 | 51 | 52 | 2.0 53 | 54 | 55 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 56 | 57 | 58 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 59 | 60 | 61 | 17, 17 62 | 63 | 64 | 65 | AAEAAAD/////AQAAAAAAAAAMAgAAAENBdXRvY29tcGxldGVNZW51LVNjaW50aWxsYU5FVCwgQ3VsdHVy 66 | ZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsDAMAAABRU3lzdGVtLkRyYXdpbmcsIFZlcnNpb249 67 | NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iMDNmNWY3ZjExZDUwYTNhBQEA 68 | AAAZQXV0b2NvbXBsZXRlTWVudU5TLkNvbG9ycwYAAAAaPEZvcmVDb2xvcj5rX19CYWNraW5nRmllbGQa 69 | PEJhY2tDb2xvcj5rX19CYWNraW5nRmllbGQiPFNlbGVjdGVkRm9yZUNvbG9yPmtfX0JhY2tpbmdGaWVs 70 | ZCI8U2VsZWN0ZWRCYWNrQ29sb3I+a19fQmFja2luZ0ZpZWxkIzxTZWxlY3RlZEJhY2tDb2xvcjI+a19f 71 | QmFja2luZ0ZpZWxkIjxIaWdobGlnaHRpbmdDb2xvcj5rX19CYWNraW5nRmllbGQEBAQEBAQUU3lzdGVt 72 | LkRyYXdpbmcuQ29sb3IDAAAAFFN5c3RlbS5EcmF3aW5nLkNvbG9yAwAAABRTeXN0ZW0uRHJhd2luZy5D 73 | b2xvcgMAAAAUU3lzdGVtLkRyYXdpbmcuQ29sb3IDAAAAFFN5c3RlbS5EcmF3aW5nLkNvbG9yAwAAABRT 74 | eXN0ZW0uRHJhd2luZy5Db2xvcgMAAAACAAAABfz///8UU3lzdGVtLkRyYXdpbmcuQ29sb3IEAAAABG5h 75 | bWUFdmFsdWUKa25vd25Db2xvcgVzdGF0ZQEAAAAJBwcDAAAACgAAAAAAAAAAIwABAAH7/////P///woA 76 | AAAAAAAAAKQAAQAB+v////z///8KAAAAAAAAAAAjAAEAAfn////8////CgAAAAAAAAAAfwABAAH4//// 77 | /P///woAAAAAAAAAAKQAAQAB9/////z///8KAAAAAAAAAAB/AAEACw== 78 | 79 | 80 | -------------------------------------------------------------------------------- /Tester/SimplestSample.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Tester 2 | { 3 | partial class SimplestSample 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.label2 = new System.Windows.Forms.Label(); 33 | this.label3 = new System.Windows.Forms.Label(); 34 | this.richTextBox1 = new System.Windows.Forms.RichTextBox(); 35 | this.textBox1 = new System.Windows.Forms.TextBox(); 36 | this.autocompleteMenu1 = new AutocompleteMenuNS.AutocompleteMenu(); 37 | this.SuspendLayout(); 38 | // 39 | // label1 40 | // 41 | this.label1.AutoSize = true; 42 | this.label1.Location = new System.Drawing.Point(13, 57); 43 | this.label1.Name = "label1"; 44 | this.label1.Size = new System.Drawing.Size(46, 13); 45 | this.label1.TabIndex = 3; 46 | this.label1.Text = "TextBox"; 47 | // 48 | // label2 49 | // 50 | this.label2.AutoSize = true; 51 | this.label2.Location = new System.Drawing.Point(13, 110); 52 | this.label2.Name = "label2"; 53 | this.label2.Size = new System.Drawing.Size(68, 13); 54 | this.label2.TabIndex = 4; 55 | this.label2.Text = "RichTextBox"; 56 | // 57 | // label3 58 | // 59 | this.label3.Dock = System.Windows.Forms.DockStyle.Top; 60 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 61 | this.label3.Location = new System.Drawing.Point(0, 0); 62 | this.label3.Name = "label3"; 63 | this.label3.Size = new System.Drawing.Size(380, 49); 64 | this.label3.TabIndex = 5; 65 | this.label3.Text = "This example shows how to create simplest autocomplete menu and link it to textbo" + 66 | "x.\r\nStart to type \"abc\" into any textbox."; 67 | // 68 | // richTextBox1 69 | // 70 | this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 71 | | System.Windows.Forms.AnchorStyles.Left) 72 | | System.Windows.Forms.AnchorStyles.Right))); 73 | this.autocompleteMenu1.SetAutocompleteMenu(this.richTextBox1, this.autocompleteMenu1); 74 | this.richTextBox1.Location = new System.Drawing.Point(12, 126); 75 | this.richTextBox1.Name = "richTextBox1"; 76 | this.richTextBox1.Size = new System.Drawing.Size(356, 114); 77 | this.richTextBox1.TabIndex = 0; 78 | this.richTextBox1.Text = ""; 79 | // 80 | // textBox1 81 | // 82 | this.textBox1.AcceptsTab = true; 83 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 84 | | System.Windows.Forms.AnchorStyles.Right))); 85 | this.autocompleteMenu1.SetAutocompleteMenu(this.textBox1, this.autocompleteMenu1); 86 | this.textBox1.Location = new System.Drawing.Point(12, 78); 87 | this.textBox1.Name = "textBox1"; 88 | this.textBox1.Size = new System.Drawing.Size(356, 20); 89 | this.textBox1.TabIndex = 0; 90 | // 91 | // autocompleteMenu1 92 | // 93 | this.autocompleteMenu1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 94 | this.autocompleteMenu1.ImageList = null; 95 | this.autocompleteMenu1.Items = new string[] { 96 | "abc", 97 | "abcd", 98 | "abcde", 99 | "abcdef"}; 100 | this.autocompleteMenu1.LeftPadding = 0; 101 | this.autocompleteMenu1.TargetControlWrapper = null; 102 | // 103 | // SimplestSample 104 | // 105 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 106 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 107 | this.ClientSize = new System.Drawing.Size(380, 256); 108 | this.Controls.Add(this.label3); 109 | this.Controls.Add(this.label2); 110 | this.Controls.Add(this.label1); 111 | this.Controls.Add(this.richTextBox1); 112 | this.Controls.Add(this.textBox1); 113 | this.Name = "SimplestSample"; 114 | this.Text = "SimplestSample"; 115 | this.ResumeLayout(false); 116 | this.PerformLayout(); 117 | 118 | } 119 | 120 | #endregion 121 | 122 | private System.Windows.Forms.TextBox textBox1; 123 | private System.Windows.Forms.RichTextBox richTextBox1; 124 | private AutocompleteMenuNS.AutocompleteMenu autocompleteMenu1; 125 | private System.Windows.Forms.Label label1; 126 | private System.Windows.Forms.Label label2; 127 | private System.Windows.Forms.Label label3; 128 | } 129 | } -------------------------------------------------------------------------------- /Tester/SimplestSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using System.IO; 9 | 10 | namespace Tester 11 | { 12 | public partial class SimplestSample : Form 13 | { 14 | public SimplestSample() 15 | { 16 | InitializeComponent(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tester/SimplestSample.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /Tester/Tester.NET.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 8.0.30703 4 | {43D51B6D-CBE3-442C-A5EF-5E7D4626BB35} 5 | WinExe 6 | net461 7 | Tester 8 | Tester 9 | Copyright © 2012 10 | bin\$(Configuration)\ 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Form 19 | 20 | 21 | AdvancedSample.cs 22 | 23 | 24 | Form 25 | 26 | 27 | ComboboxSample.cs 28 | 29 | 30 | Form 31 | 32 | 33 | Sandbox.cs 34 | 35 | 36 | Form 37 | 38 | 39 | DynamicTooltipSample.cs 40 | 41 | 42 | Form 43 | 44 | 45 | DataGridViewSample.cs 46 | 47 | 48 | Form 49 | 50 | 51 | CustomListViewSample.cs 52 | 53 | 54 | Form 55 | 56 | 57 | DynamicMenuSample.cs 58 | 59 | 60 | Form 61 | 62 | 63 | MultiColumnSample.cs 64 | 65 | 66 | Form 67 | 68 | 69 | CustomItemSample.cs 70 | 71 | 72 | Form 73 | 74 | 75 | ExtraLargeSample.cs 76 | 77 | 78 | Form 79 | 80 | 81 | MainForm.cs 82 | 83 | 84 | Form 85 | 86 | 87 | ScintillaSample.cs 88 | 89 | 90 | Form 91 | 92 | 93 | SimplestSample.cs 94 | 95 | 96 | AdvancedSample.cs 97 | 98 | 99 | ComboboxSample.cs 100 | 101 | 102 | Sandbox.cs 103 | 104 | 105 | DynamicTooltipSample.cs 106 | 107 | 108 | DataGridViewSample.cs 109 | 110 | 111 | CustomListViewSample.cs 112 | 113 | 114 | DynamicMenuSample.cs 115 | 116 | 117 | MultiColumnSample.cs 118 | 119 | 120 | CustomItemSample.cs 121 | 122 | 123 | ExtraLargeSample.cs 124 | 125 | 126 | MainForm.cs 127 | 128 | 129 | ResXFileCodeGenerator 130 | Resources.Designer.cs 131 | Designer 132 | 133 | 134 | True 135 | Resources.resx 136 | True 137 | 138 | 139 | ScintillaSample.cs 140 | 141 | 142 | SimplestSample.cs 143 | 144 | 145 | 146 | SettingsSingleFileGenerator 147 | Settings.Designer.cs 148 | 149 | 150 | True 151 | Settings.settings 152 | True 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /Tester/Tester.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net7.0-windows 4 | x86 5 | WinExe 6 | false 7 | true 8 | true 9 | Tester.Program 10 | 11 | 12 | 13 | 14 | 15 | 16 | all 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tester/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | --------------------------------------------------------------------------------