├── .gitignore
├── LICENSE
├── Out
└── Windows.Forms.HintTextBox.dll
├── README.md
├── img
├── icon.png
└── screenshut.png
└── src
├── .nuget
├── CreateNugetPackAfterCompile.bat
├── HintTextBox.nuspec
├── NuGet.Config
├── NuGet.exe
├── NuGet.targets
├── nupack.bat
└── readme.txt
├── Demo
├── Demo.csproj
├── DemoForm.Designer.cs
├── DemoForm.cs
├── DemoForm.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── bin
│ └── Debug
│ │ ├── Demo.exe
│ │ ├── Demo.pdb
│ │ ├── Demo.vshost.exe
│ │ ├── Demo.vshost.exe.manifest
│ │ ├── Windows.Forms.HintTextBox.dll
│ │ └── Windows.Forms.HintTextBox.pdb
└── obj
│ └── Debug
│ ├── Demo.Properties.Resources.resources
│ ├── Demo.csproj.FileListAbsolute.txt
│ ├── Demo.csproj.GenerateResource.Cache
│ ├── Demo.csprojResolveAssemblyReference.cache
│ ├── Demo.exe
│ ├── Demo.pdb
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── Windows.Forms.HintTextBox.sln
└── Windows.Forms.HintTextBox
├── HintTextBox.cs
├── MathParser.cs
├── Properties
└── AssemblyInfo.cs
├── VersionUpdater.tt
├── VersionUpdater.txt
├── Windows.Forms.HintTextBox.csproj
└── obj
└── Debug
├── DesignTimeResolveAssemblyReferences.cache
├── DesignTimeResolveAssemblyReferencesInput.cache
├── Windows.Forms.HintTextBox.csproj.FileListAbsolute.txt
├── Windows.Forms.HintTextBox.dll
└── Windows.Forms.HintTextBox.pdb
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # .NET Core
46 | project.lock.json
47 | project.fragment.lock.json
48 | artifacts/
49 | **/Properties/launchSettings.json
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # Visual Studio code coverage results
117 | *.coverage
118 | *.coveragexml
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 |
125 | # MightyMoose
126 | *.mm.*
127 | AutoTest.Net/
128 |
129 | # Web workbench (sass)
130 | .sass-cache/
131 |
132 | # Installshield output folder
133 | [Ee]xpress/
134 |
135 | # DocProject is a documentation generator add-in
136 | DocProject/buildhelp/
137 | DocProject/Help/*.HxT
138 | DocProject/Help/*.HxC
139 | DocProject/Help/*.hhc
140 | DocProject/Help/*.hhk
141 | DocProject/Help/*.hhp
142 | DocProject/Help/Html2
143 | DocProject/Help/html
144 |
145 | # Click-Once directory
146 | publish/
147 |
148 | # Publish Web Output
149 | *.[Pp]ublish.xml
150 | *.azurePubxml
151 | # TODO: Comment the next line if you want to checkin your web deploy settings
152 | # but database connection strings (with potential passwords) will be unencrypted
153 | *.pubxml
154 | *.publishproj
155 |
156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
157 | # checkin your Azure Web App publish settings, but sensitive information contained
158 | # in these scripts will be unencrypted
159 | PublishScripts/
160 |
161 | # NuGet Packages
162 | *.nupkg
163 | # The packages folder can be ignored because of Package Restore
164 | **/packages/*
165 | # except build/, which is used as an MSBuild target.
166 | !**/packages/build/
167 | # Uncomment if necessary however generally it will be regenerated when needed
168 | #!**/packages/repositories.config
169 | # NuGet v3's project.json files produces more ignorable files
170 | *.nuget.props
171 | *.nuget.targets
172 |
173 | # Microsoft Azure Build Output
174 | csx/
175 | *.build.csdef
176 |
177 | # Microsoft Azure Emulator
178 | ecf/
179 | rcf/
180 |
181 | # Windows Store app package directories and files
182 | AppPackages/
183 | BundleArtifacts/
184 | Package.StoreAssociation.xml
185 | _pkginfo.txt
186 |
187 | # Visual Studio cache files
188 | # files ending in .cache can be ignored
189 | *.[Cc]ache
190 | # but keep track of directories ending in .cache
191 | !*.[Cc]ache/
192 |
193 | # Others
194 | ClientBin/
195 | ~$*
196 | *~
197 | *.dbmdl
198 | *.dbproj.schemaview
199 | *.jfm
200 | *.pfx
201 | *.publishsettings
202 | orleans.codegen.cs
203 |
204 | # Since there are multiple workflows, uncomment next line to ignore bower_components
205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
206 | #bower_components/
207 |
208 | # RIA/Silverlight projects
209 | Generated_Code/
210 |
211 | # Backup & report files from converting an old project file
212 | # to a newer Visual Studio version. Backup files are not needed,
213 | # because we have git ;-)
214 | _UpgradeReport_Files/
215 | Backup*/
216 | UpgradeLog*.XML
217 | UpgradeLog*.htm
218 |
219 | # SQL Server files
220 | #*.mdf
221 | #*.ldf
222 | #*.ndf
223 |
224 | # Business Intelligence projects
225 | *.rdl.data
226 | *.bim.layout
227 | *.bim_*.settings
228 |
229 | # Microsoft Fakes
230 | FakesAssemblies/
231 |
232 | # GhostDoc plugin setting file
233 | *.GhostDoc.xml
234 |
235 | # Node.js Tools for Visual Studio
236 | .ntvs_analysis.dat
237 | node_modules/
238 |
239 | # Typescript v1 declaration files
240 | typings/
241 |
242 | # Visual Studio 6 build log
243 | *.plg
244 |
245 | # Visual Studio 6 workspace options file
246 | *.opt
247 |
248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
249 | *.vbw
250 |
251 | # Visual Studio LightSwitch build output
252 | **/*.HTMLClient/GeneratedArtifacts
253 | **/*.DesktopClient/GeneratedArtifacts
254 | **/*.DesktopClient/ModelManifest.xml
255 | **/*.Server/GeneratedArtifacts
256 | **/*.Server/ModelManifest.xml
257 | _Pvt_Extensions
258 |
259 | # Paket dependency manager
260 | .paket/paket.exe
261 | paket-files/
262 |
263 | # FAKE - F# Make
264 | .fake/
265 |
266 | # JetBrains Rider
267 | .idea/
268 | *.sln.iml
269 |
270 | # CodeRush
271 | .cr/
272 |
273 | # Python Tools for Visual Studio (PTVS)
274 | __pycache__/
275 | *.pyc
276 |
277 | # Cake - Uncomment if you are using it
278 | # tools/**
279 | # !tools/packages.config
280 |
281 | # Telerik's JustMock configuration file
282 | *.jmconfig
283 |
284 | # BizTalk build output
285 | *.btp.cs
286 | *.btm.cs
287 | *.odx.cs
288 | *.xsd.cs
289 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Behzad Khosravifar
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Out/Windows.Forms.HintTextBox.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/Out/Windows.Forms.HintTextBox.dll
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [Hint TextBox](https://github.com/Behzadkhosravifar/HintTextBox)
2 | --------------------
3 | [](https://ci.appveyor.com/project/Behzadkhosravifar/hinttextbox)
4 | [](https://www.nuget.org/packages/TextBox)
5 |
6 | A TextBox by default value to hint that and have some features such as Math Parser, Numeric Mode, Thousands Separator and etc.
7 |
8 | --------------------------------
9 | ### How To Use The Examples
10 |
11 | Hint TextBox in Demo app:
12 |
13 | 
14 |
15 |
16 | --------------------------
17 | ### LICENSE INFORMATION [](http://opensource.org/licenses/GPL-3.0.html)
18 |
19 | This software is open source, licensed under the GNU General Public License, Version 3.0.
20 | See [GPL-3.0](http://opensource.org/licenses/GPL-3.0.html) for details.
21 | This Class Library creates a way of handling structured exception handling,
22 | inheriting from the Exception class gives us access to many method
23 | we wouldn't otherwise have access to
24 |
25 | Copyright (C) 2015-2016 [Behzad Khosravifar](mailto:Behzad.Khosravifar@Gmail.com)
26 |
27 | This program published by the Free Software Foundation,
28 | either version 1.0.1 of the License, or (at your option) any later version.
29 |
30 | This program is distributed in the hope that it will be useful,
31 | but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
33 |
--------------------------------------------------------------------------------
/img/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/img/icon.png
--------------------------------------------------------------------------------
/img/screenshut.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/img/screenshut.png
--------------------------------------------------------------------------------
/src/.nuget/CreateNugetPackAfterCompile.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | Echo ---------------------- Nuget Packaging ---------------------------------
3 |
4 | mkdir ..\..\NuGetPackages 2> NUL
5 | nuget pack -OutputDirectory ..\..\NuGetPackages HintTextBox.nuspec
6 |
7 | Echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 |
9 | pause
--------------------------------------------------------------------------------
/src/.nuget/HintTextBox.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | TextBox
5 | Hint and Numericable TextBox
6 |
7 | https://github.com/Behzadkhosravifar/HintTextBox/blob/master/img/icon.png?raw=true
8 |
9 | 1.3.13
10 |
11 | A TextBox by default value to hint that and have some features such as Math Parser, Numeric Mode, Thousands Separator and etc.
12 | for more informations: https://github.com/Behzadkhosravifar/HintTextBox
13 |
14 |
15 | This is a C#.Net project's for placeholder text box by Numeric Mode, Thousands Separator and etc of your .Net applications.
16 |
17 | Behzad Khosravifar
18 | Behzad Khosravifar
19 | http://www.gnu.org/licenses/gpl.txt
20 | https://github.com/Behzadkhosravifar/HintTextBox
21 | false
22 |
23 | * Some Bug fixes.
24 | * First Nuget Version
25 |
26 | Copyright (C) 2015-2018 Behzad Khosravifar
27 |
28 | Hint TextBox Placeholder Numerical Math Parser
29 |
30 | false
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/src/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config
41 |
42 |
43 |
44 | $(MSBuildProjectDirectory)\packages.config
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | $(NuGetToolsPath)\NuGet.exe
51 | @(PackageSource)
52 |
53 | "$(NuGetExePath)"
54 | mono --runtime=v4.0.30319 "$(NuGetExePath)"
55 |
56 | $(TargetDir.Trim('\\'))
57 |
58 | -RequireConsent
59 | -NonInteractive
60 |
61 | "$(SolutionDir) "
62 | "$(SolutionDir)"
63 |
64 |
65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
67 |
68 |
69 |
70 | RestorePackages;
71 | $(BuildDependsOn);
72 |
73 |
74 |
75 |
76 | $(BuildDependsOn);
77 | BuildPackage;
78 |
79 |
80 |
81 |
82 |
83 |
84 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
99 |
100 |
103 |
104 |
105 |
106 |
108 |
109 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
141 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/src/.nuget/nupack.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | Echo ---------------------- Build Start -------------------------------------
3 |
4 | IF NOT "%VS140COMNTOOLS%" == "" (call "%VS140COMNTOOLS%vsvars32.bat")
5 | IF NOT "%VS130COMNTOOLS%" == "" (call "%VS130COMNTOOLS%vsvars32.bat")
6 | IF NOT "%VS120COMNTOOLS%" == "" (call "%VS120COMNTOOLS%vsvars32.bat")
7 | IF NOT "%VS110COMNTOOLS%" == "" (call "%VS110COMNTOOLS%vsvars32.bat")
8 |
9 | for /F %%A in ('dir /b ..\*.sln') do call devenv ..\%%A /Rebuild "Release"
10 |
11 | Echo ------------------------------------------------------------------------
12 |
13 | Echo ---------------------- Nuget Packaging ---------------------------------
14 |
15 | mkdir ..\..\NuGetPackages 2> NUL
16 | nuget pack -OutputDirectory ..\..\NuGetPackages HintTextBox.nuspec
17 |
18 | pause
--------------------------------------------------------------------------------
/src/.nuget/readme.txt:
--------------------------------------------------------------------------------
1 | Usage:
2 |
3 | A TextBox by default value to hint that and have some features such as Math Parser, Numeric Mode, Thousands Separator and etc.
--------------------------------------------------------------------------------
/src/Demo/Demo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {66B27364-0590-412D-BA11-07B6F31B1292}
8 | WinExe
9 | Properties
10 | Demo
11 | Demo
12 | v4.0
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | Form
49 |
50 |
51 | DemoForm.cs
52 |
53 |
54 |
55 |
56 | DemoForm.cs
57 |
58 |
59 | ResXFileCodeGenerator
60 | Resources.Designer.cs
61 | Designer
62 |
63 |
64 | True
65 | Resources.resx
66 |
67 |
68 | SettingsSingleFileGenerator
69 | Settings.Designer.cs
70 |
71 |
72 | True
73 | Settings.settings
74 | True
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | {05faaa9a-132b-4057-a171-c0e184d399a6}
83 | Windows.Forms.HintTextBox
84 |
85 |
86 |
87 |
94 |
--------------------------------------------------------------------------------
/src/Demo/DemoForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Demo
2 | {
3 | partial class DemoForm
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 | this.btnShow = new System.Windows.Forms.Button();
33 | this.txtNum = new Windows.Forms.HintTextBox(this.components);
34 | this.txtText = new Windows.Forms.HintTextBox(this.components);
35 | this.lblResult = new System.Windows.Forms.Label();
36 | this.SuspendLayout();
37 | //
38 | // btnShow
39 | //
40 | this.btnShow.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
41 | this.btnShow.Location = new System.Drawing.Point(67, 171);
42 | this.btnShow.Name = "btnShow";
43 | this.btnShow.Size = new System.Drawing.Size(75, 23);
44 | this.btnShow.TabIndex = 2;
45 | this.btnShow.Text = "&Show";
46 | this.btnShow.UseVisualStyleBackColor = true;
47 | this.btnShow.Click += new System.EventHandler(this.btnShow_Click);
48 | //
49 | // txtNum
50 | //
51 | this.txtNum.AcceptMathChars = true;
52 | this.txtNum.AcceptsReturn = true;
53 | this.txtNum.EnterToTab = false;
54 | this.txtNum.ForeColor = System.Drawing.Color.DarkKhaki;
55 | this.txtNum.HintColor = System.Drawing.Color.DarkKhaki;
56 | this.txtNum.HintValue = "Math & Numerical + - / * ( )";
57 | this.txtNum.IsNumerical = true;
58 | this.txtNum.Location = new System.Drawing.Point(18, 73);
59 | this.txtNum.Name = "txtNum";
60 | this.txtNum.Size = new System.Drawing.Size(174, 20);
61 | this.txtNum.TabIndex = 1;
62 | this.txtNum.Text = "Math & Numerical + - / * ( )";
63 | this.txtNum.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
64 | this.txtNum.TextForeColor = System.Drawing.Color.Black;
65 | this.txtNum.Value = "";
66 | //
67 | // txtText
68 | //
69 | this.txtText.EnterToTab = false;
70 | this.txtText.ForeColor = System.Drawing.Color.Gray;
71 | this.txtText.HintColor = System.Drawing.Color.Gray;
72 | this.txtText.HintValue = "Hint Text";
73 | this.txtText.Location = new System.Drawing.Point(18, 24);
74 | this.txtText.Margin = new System.Windows.Forms.Padding(2);
75 | this.txtText.Name = "txtText";
76 | this.txtText.Size = new System.Drawing.Size(174, 20);
77 | this.txtText.TabIndex = 0;
78 | this.txtText.Text = "Hint Text";
79 | this.txtText.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
80 | this.txtText.TextForeColor = System.Drawing.Color.Black;
81 | this.txtText.Value = "";
82 | //
83 | // lblResult
84 | //
85 | this.lblResult.AutoSize = true;
86 | this.lblResult.Location = new System.Drawing.Point(15, 96);
87 | this.lblResult.Name = "lblResult";
88 | this.lblResult.Size = new System.Drawing.Size(44, 13);
89 | this.lblResult.TabIndex = 3;
90 | this.lblResult.Text = "result: ";
91 | //
92 | // DemoForm
93 | //
94 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
95 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
96 | this.ClientSize = new System.Drawing.Size(212, 206);
97 | this.Controls.Add(this.lblResult);
98 | this.Controls.Add(this.btnShow);
99 | this.Controls.Add(this.txtNum);
100 | this.Controls.Add(this.txtText);
101 | this.Margin = new System.Windows.Forms.Padding(2);
102 | this.Name = "DemoForm";
103 | this.Text = "Demo";
104 | this.ResumeLayout(false);
105 | this.PerformLayout();
106 |
107 | }
108 |
109 | #endregion
110 |
111 | private Windows.Forms.HintTextBox txtText;
112 | private Windows.Forms.HintTextBox txtNum;
113 | private System.Windows.Forms.Button btnShow;
114 | private System.Windows.Forms.Label lblResult;
115 | }
116 | }
117 |
118 |
--------------------------------------------------------------------------------
/src/Demo/DemoForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace Demo
5 | {
6 | public partial class DemoForm : Form
7 | {
8 | public DemoForm()
9 | {
10 | InitializeComponent();
11 |
12 | txtNum.KeyUp += TxtNum_KeyUp;
13 | }
14 |
15 | private void TxtNum_KeyUp(object sender, EventArgs e)
16 | {
17 | lblResult.Text = $"Result: {txtNum.MathParserResult}";
18 | }
19 |
20 | private void btnShow_Click(object sender, EventArgs e)
21 | {
22 | MessageBox.Show(txtText.Value);
23 | MessageBox.Show(txtNum.Value);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Demo/DemoForm.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 | True
122 |
123 |
124 | True
125 |
126 |
127 | True
128 |
129 |
130 | True
131 |
132 |
--------------------------------------------------------------------------------
/src/Demo/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace Demo
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// The main entry point for the application.
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new DemoForm());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Demo/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("Demo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Demo")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
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("66b27364-0590-412d-ba11-07b6f31b1292")]
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 |
--------------------------------------------------------------------------------
/src/Demo/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 Demo.Properties
12 | {
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", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Demo.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/Demo/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 |
--------------------------------------------------------------------------------
/src/Demo/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 Demo.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Demo/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/Demo/bin/Debug/Demo.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/bin/Debug/Demo.exe
--------------------------------------------------------------------------------
/src/Demo/bin/Debug/Demo.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/bin/Debug/Demo.pdb
--------------------------------------------------------------------------------
/src/Demo/bin/Debug/Demo.vshost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/bin/Debug/Demo.vshost.exe
--------------------------------------------------------------------------------
/src/Demo/bin/Debug/Demo.vshost.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Demo/bin/Debug/Windows.Forms.HintTextBox.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/bin/Debug/Windows.Forms.HintTextBox.dll
--------------------------------------------------------------------------------
/src/Demo/bin/Debug/Windows.Forms.HintTextBox.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/bin/Debug/Windows.Forms.HintTextBox.pdb
--------------------------------------------------------------------------------
/src/Demo/obj/Debug/Demo.Properties.Resources.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/obj/Debug/Demo.Properties.Resources.resources
--------------------------------------------------------------------------------
/src/Demo/obj/Debug/Demo.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\bin\Debug\Demo.exe
2 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\bin\Debug\Demo.pdb
3 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\bin\Debug\Windows.Forms.HintTextBox.dll
4 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\bin\Debug\Windows.Forms.HintTextBox.pdb
5 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\obj\Debug\Demo.csprojResolveAssemblyReference.cache
6 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\obj\Debug\Demo.Properties.Resources.resources
7 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\obj\Debug\Demo.csproj.GenerateResource.Cache
8 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\obj\Debug\Demo.exe
9 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\obj\Debug\Demo.pdb
10 | D:\Send Projects\Windows.Forms.HintTextBox\Demo\obj\Debug\Demo.Form1.resources
11 | D:\Projects\HintTextBox\src\Demo\bin\Debug\Demo.exe
12 | D:\Projects\HintTextBox\src\Demo\bin\Debug\Demo.pdb
13 | D:\Projects\HintTextBox\src\Demo\bin\Debug\Windows.Forms.HintTextBox.dll
14 | D:\Projects\HintTextBox\src\Demo\bin\Debug\Windows.Forms.HintTextBox.pdb
15 | D:\Projects\HintTextBox\src\Demo\obj\Debug\Demo.csprojResolveAssemblyReference.cache
16 | D:\Projects\HintTextBox\src\Demo\obj\Debug\Demo.Properties.Resources.resources
17 | D:\Projects\HintTextBox\src\Demo\obj\Debug\Demo.csproj.GenerateResource.Cache
18 | D:\Projects\HintTextBox\src\Demo\obj\Debug\Demo.csproj.CoreCompileInputs.cache
19 | D:\Projects\HintTextBox\src\Demo\obj\Debug\Demo.exe
20 | D:\Projects\HintTextBox\src\Demo\obj\Debug\Demo.pdb
21 | D:\Projects\HintTextBox\src\Demo\obj\Debug\Demo.DemoForm.resources
22 |
--------------------------------------------------------------------------------
/src/Demo/obj/Debug/Demo.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/obj/Debug/Demo.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/src/Demo/obj/Debug/Demo.csprojResolveAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/obj/Debug/Demo.csprojResolveAssemblyReference.cache
--------------------------------------------------------------------------------
/src/Demo/obj/Debug/Demo.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/obj/Debug/Demo.exe
--------------------------------------------------------------------------------
/src/Demo/obj/Debug/Demo.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/obj/Debug/Demo.pdb
--------------------------------------------------------------------------------
/src/Demo/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Demo/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27130.2024
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Windows.Forms.HintTextBox", "Windows.Forms.HintTextBox\Windows.Forms.HintTextBox.csproj", "{05FAAA9A-132B-4057-A171-C0E184D399A6}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{66B27364-0590-412D-BA11-07B6F31B1292}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9823C184-CB53-4622-BDFF-73BBCF2BB42D}"
11 | ProjectSection(SolutionItems) = preProject
12 | ..\LICENSE = ..\LICENSE
13 | ..\README.md = ..\README.md
14 | EndProjectSection
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{DFF332A4-A5E0-44B8-9D3B-FB223ADFF174}"
17 | ProjectSection(SolutionItems) = preProject
18 | .nuget\CreateNugetPackAfterCompile.bat = .nuget\CreateNugetPackAfterCompile.bat
19 | .nuget\HintTextBox.nuspec = .nuget\HintTextBox.nuspec
20 | .nuget\NuGet.Config = .nuget\NuGet.Config
21 | .nuget\NuGet.exe = .nuget\NuGet.exe
22 | .nuget\NuGet.targets = .nuget\NuGet.targets
23 | .nuget\nupack.bat = .nuget\nupack.bat
24 | .nuget\readme.txt = .nuget\readme.txt
25 | EndProjectSection
26 | EndProject
27 | Global
28 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
29 | Debug|Any CPU = Debug|Any CPU
30 | Release|Any CPU = Release|Any CPU
31 | EndGlobalSection
32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
33 | {05FAAA9A-132B-4057-A171-C0E184D399A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {05FAAA9A-132B-4057-A171-C0E184D399A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {05FAAA9A-132B-4057-A171-C0E184D399A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {05FAAA9A-132B-4057-A171-C0E184D399A6}.Release|Any CPU.Build.0 = Release|Any CPU
37 | {66B27364-0590-412D-BA11-07B6F31B1292}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38 | {66B27364-0590-412D-BA11-07B6F31B1292}.Debug|Any CPU.Build.0 = Debug|Any CPU
39 | {66B27364-0590-412D-BA11-07B6F31B1292}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {66B27364-0590-412D-BA11-07B6F31B1292}.Release|Any CPU.Build.0 = Release|Any CPU
41 | EndGlobalSection
42 | GlobalSection(SolutionProperties) = preSolution
43 | HideSolutionNode = FALSE
44 | EndGlobalSection
45 | GlobalSection(ExtensibilityGlobals) = postSolution
46 | SolutionGuid = {4C01E75F-3341-4BAB-9D6A-540A9677D332}
47 | EndGlobalSection
48 | EndGlobal
49 |
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/HintTextBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.ComponentModel.Design;
4 | using System.Drawing;
5 | using System.Globalization;
6 | using System.Numerics;
7 | using System.Windows.Forms;
8 |
9 | namespace Windows.Forms
10 | {
11 | [ProvideProperty("HintTextBox", typeof(Control))]
12 | public sealed class HintTextBox : TextBox
13 | {
14 | #region Members
15 |
16 | private readonly MathParser _mathParser = new MathParser();
17 |
18 | [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
19 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
20 | [Description("Hint text, when text box is empty this value be superseded."), Category("Appearance")]
21 | [Localizable(true)]
22 | [Editor(typeof(MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
23 | public string HintValue
24 | {
25 | set
26 | {
27 | _hintValue = value;
28 | Text = value;
29 | ForeColor = HintColor;
30 | }
31 | get { return _hintValue; }
32 | }
33 |
34 | private string _hintValue;
35 |
36 |
37 | [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
38 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
39 | [Description("Hint value text's fore color."), Category("Appearance")]
40 | public Color HintColor
41 | {
42 | set
43 | {
44 | if (ForeColor == _hintColor || Text == string.Empty || Text == HintValue)
45 | {
46 | ForeColor = value;
47 | }
48 | _hintColor = value;
49 | }
50 | get { return _hintColor; }
51 | }
52 |
53 | private Color _hintColor;
54 |
55 |
56 | [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
57 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
58 | [Description("Main text's fore color."), Category("Appearance")]
59 | public Color TextForeColor { get; set; }
60 |
61 | [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
62 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
63 | [Description("Is Numerical TextBox? if value is true then just typed numbers, and if false then typed any chars."), Category("Behavior")]
64 | [DefaultValue(false)]
65 | public bool IsNumerical
66 | {
67 | get { return _isNumerical; }
68 | set
69 | {
70 | _isNumerical = value;
71 |
72 | if (!value)
73 | {
74 | ThousandsSeparator = false;
75 | AcceptMathChars = false;
76 | }
77 | }
78 | }
79 |
80 | private bool _isNumerical;
81 |
82 | [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
83 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
84 | [Description("Show Thousands Separator in TextBox? if value is true then split any 3 numerical digits by char ',' .\n\rNote: IsNumerical must be 'true' for runes this behavior."), Category("Behavior")]
85 | [DisplayName("Thousands Separator"), DefaultValue(false)]
86 | public bool ThousandsSeparator
87 | {
88 | get { return _thousandsSeparator; }
89 | set
90 | {
91 | _thousandsSeparator = value;
92 | if (value)
93 | {
94 | IsNumerical = true;
95 | AcceptMathChars = false;
96 | }
97 | }
98 | }
99 |
100 | private bool _thousandsSeparator;
101 |
102 | [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
103 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
104 | [Description("Convert Enter key press to TAB and focus next controls."), Category("Behavior")]
105 | [DisplayName("Enter key To Tab")]
106 | public bool EnterToTab { get; set; }
107 |
108 |
109 |
110 | [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
111 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
112 | [Description("Accepting mathematical operators such as + , - , * and /"), Category("Behavior")]
113 | [DefaultValue(false)]
114 | public bool AcceptMathChars
115 | {
116 | get { return _acceptMathChars; }
117 | set
118 | {
119 | _acceptMathChars = value;
120 | if (value)
121 | {
122 | IsNumerical = true;
123 | ThousandsSeparator = false;
124 | }
125 | }
126 | }
127 |
128 | private bool _acceptMathChars;
129 |
130 | public string MathParserResult { get; private set; }
131 |
132 | [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
133 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
134 | [Description("The real text of text box"), Category("Appearance")]
135 | [Localizable(true)]
136 | [Editor(typeof(MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
137 | public string Value
138 | {
139 | get { return (_hintValue != null && Text == HintValue) ? string.Empty : Text; }
140 | set
141 | {
142 | if (value != string.Empty && value != HintValue)
143 | ForeColor = TextForeColor;
144 |
145 | Text = value;
146 | }
147 | }
148 |
149 | #endregion
150 |
151 | #region Constructors
152 | public HintTextBox()
153 | {
154 | TextForeColor = Color.Black;
155 | HintColor = Color.Gray;
156 | HintValue = "Hint Value";
157 |
158 | HandleCreated += (s, e) => { if (string.IsNullOrEmpty(Value)) Text = HintValue; };
159 | }
160 |
161 | public HintTextBox(IContainer container)
162 | : this() { container.Add(this); }
163 |
164 | #endregion
165 |
166 | #region PreInitialized Events
167 |
168 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
169 | protected override void OnMouseDown(MouseEventArgs e)
170 | {
171 | base.OnMouseDown(e);
172 | //
173 | if (Text == HintValue)
174 | {
175 | // Clean hint text
176 | Text = string.Empty;
177 | ForeColor = TextForeColor;
178 | }
179 | }
180 |
181 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
182 | protected override void OnMouseLeave(EventArgs e)
183 | {
184 | base.OnMouseLeave(e);
185 | //
186 | if (Text == string.Empty)
187 | {
188 | // Set to hint text
189 | ForeColor = HintColor;
190 | Text = HintValue;
191 | }
192 | }
193 |
194 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
195 | protected override void OnKeyUp(KeyEventArgs e)
196 | {
197 | base.OnKeyUp(e);
198 | //
199 | if (Text == string.Empty)
200 | {
201 | // Set to hint text
202 | ForeColor = HintColor;
203 | Text = HintValue;
204 | }
205 |
206 | if (ThousandsSeparator && !AcceptMathChars)
207 | {
208 | var indexSelectionBuffer = SelectionStart;
209 | if (!string.IsNullOrEmpty(Text) && e.KeyData != Keys.Left && e.KeyData != Keys.Right)
210 | {
211 | BigInteger valueBefore;
212 | // Parse currency value using en-GB culture.
213 | // value = "�1,097.63";
214 | // Displays:
215 | // Converted '�1,097.63' to 1097.63
216 | var style = NumberStyles.Number | NumberStyles.AllowCurrencySymbol;
217 | var culture = CultureInfo.CreateSpecificCulture("en-US");
218 | if (BigInteger.TryParse(Text, style, culture, out valueBefore))
219 | {
220 | Text = String.Format(culture, "{0:N0}", valueBefore);
221 | if (e.KeyData != Keys.Delete && e.KeyData != Keys.Back) Select(Text.Length, 0);
222 | else Select(indexSelectionBuffer, 0);
223 | }
224 | }
225 | }
226 | }
227 |
228 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
229 | protected override void OnKeyDown(KeyEventArgs e)
230 | {
231 | base.OnKeyDown(e);
232 | //
233 | if (e.KeyCode == Keys.Enter && EnterToTab) SendKeys.Send("{TAB}");
234 | else if (Text == HintValue)
235 | {
236 | // Clean hint text
237 | Text = string.Empty;
238 | ForeColor = TextForeColor;
239 | }
240 | }
241 |
242 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
243 | protected override void OnKeyPress(KeyPressEventArgs e)
244 | {
245 | base.OnKeyPress(e);
246 | //
247 | if (!char.IsDigit(e.KeyChar) && IsNumerical)
248 | {
249 | int charValue = e.KeyChar;
250 | const int backKeyCharValue = 8; // 8 or '\b'
251 | const int deleteKeyCharValue = 13; // 13 or '\d'
252 |
253 | if (charValue == backKeyCharValue || charValue == deleteKeyCharValue)
254 | {
255 | e.Handled = false;
256 | return;
257 | }
258 |
259 | if (AcceptMathChars && !ThousandsSeparator)
260 | {
261 | if (e.KeyChar == '+' || e.KeyChar == '-' ||
262 | e.KeyChar == '*' || e.KeyChar == '/' ||
263 | e.KeyChar == '(' || e.KeyChar == ')')
264 | {
265 | e.Handled = false;
266 | return;
267 | }
268 | }
269 |
270 | e.Handled = true;
271 | }
272 | else
273 | {
274 | e.Handled = false;
275 | }
276 | }
277 |
278 | [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
279 | protected override void OnTextChanged(EventArgs e)
280 | {
281 | base.OnTextChanged(e);
282 | //
283 | if (IsNumerical && AcceptMathChars && !string.IsNullOrEmpty(Text))
284 | {
285 | try
286 | {
287 | MathParserResult = _mathParser.Calculate(Text).ToString(CultureInfo.InvariantCulture);
288 | }
289 | catch { MathParserResult = ""; }
290 | }
291 | else MathParserResult = "";
292 | }
293 |
294 |
295 | #endregion
296 |
297 | }
298 | }
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/MathParser.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | namespace Windows.Forms
6 | {
7 | public class MathParser
8 | {
9 | private readonly List _operationOrder = new List();
10 |
11 |
12 | public MathParser()
13 | {
14 | _operationOrder.Add("/");
15 | _operationOrder.Add("*");
16 | _operationOrder.Add("-");
17 | _operationOrder.Add("+");
18 | }
19 |
20 | public decimal Calculate(string formula)
21 | {
22 | try
23 | {
24 | while (formula.LastIndexOf("(", StringComparison.Ordinal) > -1)
25 | {
26 | var lastOpenPhrantesisIndex = formula.LastIndexOf("(", StringComparison.Ordinal);
27 | var firstClosePhrantesisIndexAfterLastOpened = formula.IndexOf(")", lastOpenPhrantesisIndex, StringComparison.Ordinal);
28 | var result = ProcessOperation(formula.Substring(lastOpenPhrantesisIndex + 1, firstClosePhrantesisIndexAfterLastOpened - lastOpenPhrantesisIndex - 1));
29 | var appendAsterix = false;
30 | if (lastOpenPhrantesisIndex > 0)
31 | {
32 | if (formula.Substring(lastOpenPhrantesisIndex - 1, 1) != "(" && !_operationOrder.Contains(formula.Substring(lastOpenPhrantesisIndex - 1, 1)))
33 | {
34 | appendAsterix = true;
35 | }
36 | }
37 |
38 | formula = formula.Substring(0, lastOpenPhrantesisIndex) + (appendAsterix ? "*" : "") + result + formula.Substring(firstClosePhrantesisIndexAfterLastOpened + 1);
39 |
40 | }
41 | return ProcessOperation(formula);
42 | }
43 | catch (Exception ex)
44 | {
45 | throw new Exception("Error Occurred While Calculating. Check Syntax", ex);
46 | }
47 | }
48 |
49 | private decimal ProcessOperation(string operation)
50 | {
51 | var arr = new ArrayList();
52 | var s = "";
53 | for (var i = 0; i < operation.Length; i++)
54 | {
55 | var currentCharacter = operation.Substring(i, 1);
56 | if (_operationOrder.IndexOf(currentCharacter) > -1)
57 | {
58 | if (s != "")
59 | {
60 | arr.Add(s);
61 | }
62 | arr.Add(currentCharacter);
63 | s = "";
64 | }
65 | else
66 | {
67 | s += currentCharacter;
68 | }
69 | }
70 | arr.Add(s);
71 | foreach (var op in _operationOrder)
72 | {
73 | while (arr.IndexOf(op) > -1)
74 | {
75 | var operatorIndex = arr.IndexOf(op);
76 | var digitBeforeOperator = Convert.ToDecimal(arr[operatorIndex - 1]);
77 | decimal digitAfterOperator;
78 | if (arr[operatorIndex + 1].ToString() == "-")
79 | {
80 | arr.RemoveAt(operatorIndex + 1);
81 | digitAfterOperator = Convert.ToDecimal(arr[operatorIndex + 1]) * -1;
82 | }
83 | else
84 | {
85 | digitAfterOperator = Convert.ToDecimal(arr[operatorIndex + 1]);
86 | }
87 | arr[operatorIndex] = CalculateByOperator(digitBeforeOperator, digitAfterOperator, op);
88 | arr.RemoveAt(operatorIndex - 1);
89 | arr.RemoveAt(operatorIndex);
90 | }
91 | }
92 | return Convert.ToDecimal(arr[0]);
93 | }
94 |
95 | private decimal CalculateByOperator(decimal number1, decimal number2, string op)
96 | {
97 | switch (op)
98 | {
99 | case "/":
100 | return number1 / number2;
101 | case "*":
102 | return number1 * number2;
103 | case "-":
104 | return number1 - number2;
105 | case "+":
106 | return number1 + number2;
107 | default:
108 | return 0;
109 | }
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/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("Windows.Forms.HintTextBox")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Windows.Forms.HintTextBox")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
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("05faaa9a-132b-4057-a171-c0e184d399a6")]
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.3.13")]
36 | [assembly: AssemblyFileVersion("1.3.13")]
37 |
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/VersionUpdater.tt:
--------------------------------------------------------------------------------
1 | <#@ template language="C#" hostspecific="true" #>
2 | <#@ output extension=".txt" #>
3 | <#@ import namespace="System.IO" #>
4 | <#@ import namespace="System.Text.RegularExpressions" #>
5 |
6 | //------------------------------------------------------------------------------
7 | //
8 | // This code was generated by a tool.
9 | // Runtime Version: 4.0.30319.42000
10 | // Generated at <#=DateTime.Now#>
11 | //
12 | // Changes to this file may cause incorrect behavior and will be lost if
13 | // the code is regenerated.
14 | //
15 | // This file is a T4 Text Template for change automatically this
16 | // project files version.
17 | //
18 | // Affected files:
19 | //
20 | // 1. Assembly Version
21 | // 3. .nuget\HintTextBox.nuspec
22 | //
23 | //------------------------------------------------------------------------------
24 |
25 | <#
26 | string path = Host.ResolvePath(".."); // path is: HintTextBox\src\
27 |
28 | var AssemblyFilePath = Path.Combine(path, "Windows.Forms.HintTextBox\\Properties\\AssemblyInfo.cs");
29 | var NuspecPath = Path.Combine(path, ".nuget\\HintTextBox.nuspec");
30 |
31 | //========================================== Assembly File ==================================================
32 | string newVersion = null;
33 | if(File.Exists(AssemblyFilePath))
34 | {
35 | var AssemblyFileData = File.ReadAllText(AssemblyFilePath);
36 | var asmVerPattern = @"(\[assembly: [\w\.]*Version\("")(?[\d+\.\d+]*)(""\)\])";
37 | var match = Regex.Match(AssemblyFileData, asmVerPattern);
38 | var gAsmVer = match.Groups["asmVer"].Value;
39 | var oldVersion = new Version(gAsmVer);
40 |
41 | // Compile new version [major.minor.build] = 2.4.99
42 | if (oldVersion.Build >= 99)
43 | {
44 | newVersion = oldVersion.Minor >= 99
45 | ? new Version(oldVersion.Major + 1, 0, 0).ToString()
46 | : new Version(oldVersion.Major, oldVersion.Minor + 1, 0).ToString();
47 | }
48 | else
49 | {
50 | newVersion = new Version(oldVersion.Major, oldVersion.Minor, oldVersion.Build + 1).ToString();
51 | }
52 | //
53 | // Set new version in target files
54 | AssemblyFileData = Regex.Replace(AssemblyFileData, asmVerPattern, m => m.Groups[1].Value + newVersion + m.Groups[2].Value);
55 | File.WriteAllText(AssemblyFilePath, AssemblyFileData);
56 | }
57 | //========================================== Assembly File ==================================================
58 | //===========================================================================================================
59 |
60 | //================================================ Nuspec ===================================================
61 | if(newVersion != null && File.Exists(NuspecPath))
62 | {
63 | var nuspecData = File.ReadAllText(NuspecPath);
64 | var asmVerPattern = @"\d+\.\d+\.\d+<\/version>";
65 | //
66 | // Set new version in target files
67 | nuspecData = Regex.Replace(nuspecData, asmVerPattern, string.Format("{0}", newVersion));
68 | File.WriteAllText(NuspecPath, nuspecData);
69 | }
70 | //================================================ Nuspec ===================================================
71 | //===========================================================================================================
72 | #>
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/VersionUpdater.txt:
--------------------------------------------------------------------------------
1 |
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version: 4.0.30319.42000
6 | // Generated at 03/05/2018 11:47:39
7 | //
8 | // Changes to this file may cause incorrect behavior and will be lost if
9 | // the code is regenerated.
10 | //
11 | // This file is a T4 Text Template for change automatically this
12 | // project files version.
13 | //
14 | // Affected files:
15 | //
16 | // 1. Assembly Version
17 | // 3. .nuget\HintTextBox.nuspec
18 | //
19 | //------------------------------------------------------------------------------
20 |
21 |
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/Windows.Forms.HintTextBox.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {05FAAA9A-132B-4057-A171-C0E184D399A6}
8 | Library
9 | Properties
10 | Windows.Forms
11 | Windows.Forms.HintTextBox
12 | v4.0
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | ..\..\Out\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | ..\..\Out\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | Component
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | TextTemplatingFileGenerator
54 | VersionUpdater.txt
55 |
56 |
57 | True
58 | True
59 | VersionUpdater.tt
60 |
61 |
62 |
63 |
64 | 1.20.0
65 |
66 |
67 |
68 |
69 | CD "$(SolutionDir).nuget\"
70 | call "$(SolutionDir).nuget\CreateNugetPackAfterCompile.bat"
71 |
72 |
79 |
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/obj/Debug/DesignTimeResolveAssemblyReferences.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Windows.Forms.HintTextBox/obj/Debug/DesignTimeResolveAssemblyReferences.cache
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Windows.Forms.HintTextBox/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/obj/Debug/Windows.Forms.HintTextBox.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | D:\Send Projects\Windows.Forms.HintTextBox\Windows.Forms.HintTextBox\bin\Debug\Windows.Forms.HintTextBox.dll
2 | D:\Send Projects\Windows.Forms.HintTextBox\Windows.Forms.HintTextBox\bin\Debug\Windows.Forms.HintTextBox.pdb
3 | D:\Send Projects\Windows.Forms.HintTextBox\Windows.Forms.HintTextBox\obj\Debug\Windows.Forms.HintTextBox.dll
4 | D:\Send Projects\Windows.Forms.HintTextBox\Windows.Forms.HintTextBox\obj\Debug\Windows.Forms.HintTextBox.pdb
5 | D:\Send Projects\Windows.Forms.HintTextBox\Windows.Forms.HintTextBox\obj\Debug\Windows.Forms.HintTextBox.csprojResolveAssemblyReference.cache
6 | D:\Projects\HintTextBox\src\Windows.Forms.HintTextBox\bin\Debug\Windows.Forms.HintTextBox.dll
7 | D:\Projects\HintTextBox\src\Windows.Forms.HintTextBox\bin\Debug\Windows.Forms.HintTextBox.pdb
8 | D:\Projects\HintTextBox\src\Windows.Forms.HintTextBox\obj\Debug\Windows.Forms.HintTextBox.csproj.CoreCompileInputs.cache
9 | D:\Projects\HintTextBox\src\Windows.Forms.HintTextBox\obj\Debug\Windows.Forms.HintTextBox.dll
10 | D:\Projects\HintTextBox\src\Windows.Forms.HintTextBox\obj\Debug\Windows.Forms.HintTextBox.pdb
11 | D:\Projects\HintTextBox\Out\Windows.Forms.HintTextBox.dll
12 | D:\Projects\HintTextBox\Out\Windows.Forms.HintTextBox.pdb
13 |
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/obj/Debug/Windows.Forms.HintTextBox.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Windows.Forms.HintTextBox/obj/Debug/Windows.Forms.HintTextBox.dll
--------------------------------------------------------------------------------
/src/Windows.Forms.HintTextBox/obj/Debug/Windows.Forms.HintTextBox.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bezzad/HintTextBox/4d7afbd16b803a67c41576a1fae2b2ffea4b06d4/src/Windows.Forms.HintTextBox/obj/Debug/Windows.Forms.HintTextBox.pdb
--------------------------------------------------------------------------------