├── .gitignore
├── KeyPad
├── KeyPad.sln
├── KeyPad.sln.docstates.suo
├── KeyPad.suo
├── KeyPad
│ ├── Converter
│ │ └── BoolToVisibilityConverter.cs
│ ├── KeyPad.csproj
│ ├── Keypad.xaml
│ ├── Keypad.xaml.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── VirtualKeyboard.xaml
│ ├── VirtualKeyboard.xaml.cs
│ └── app.config
└── TestKeypad
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
│ └── TestKeypad.csproj
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | bin
3 | obj
4 |
5 | # mstest test results
6 | TestResults
--------------------------------------------------------------------------------
/KeyPad/KeyPad.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeyPad", "KeyPad\KeyPad.csproj", "{3ADBFF38-915C-4115-9CDD-81C0CAD9733A}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestKeypad", "TestKeypad\TestKeypad.csproj", "{2302659E-071F-4525-9D8F-C16AE000B201}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {3ADBFF38-915C-4115-9CDD-81C0CAD9733A}.Debug|x86.ActiveCfg = Debug|x86
15 | {3ADBFF38-915C-4115-9CDD-81C0CAD9733A}.Debug|x86.Build.0 = Debug|x86
16 | {3ADBFF38-915C-4115-9CDD-81C0CAD9733A}.Release|x86.ActiveCfg = Release|x86
17 | {3ADBFF38-915C-4115-9CDD-81C0CAD9733A}.Release|x86.Build.0 = Release|x86
18 | {2302659E-071F-4525-9D8F-C16AE000B201}.Debug|x86.ActiveCfg = Debug|x86
19 | {2302659E-071F-4525-9D8F-C16AE000B201}.Debug|x86.Build.0 = Debug|x86
20 | {2302659E-071F-4525-9D8F-C16AE000B201}.Release|x86.ActiveCfg = Release|x86
21 | {2302659E-071F-4525-9D8F-C16AE000B201}.Release|x86.Build.0 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad.sln.docstates.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mesta1/WPF-on-screen-keyboard-and-keypad/a70f5b02fc0818398e0ff05ee42af9efb910ba42/KeyPad/KeyPad.sln.docstates.suo
--------------------------------------------------------------------------------
/KeyPad/KeyPad.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mesta1/WPF-on-screen-keyboard-and-keypad/a70f5b02fc0818398e0ff05ee42af9efb910ba42/KeyPad/KeyPad.suo
--------------------------------------------------------------------------------
/KeyPad/KeyPad/Converter/BoolToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Data;
6 |
7 | namespace KeyPad.Converter
8 | {
9 | class BoolToVisibilityConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
12 | {
13 | if ((bool?)value == true)
14 | return System.Windows.Visibility.Visible;
15 | else
16 | return System.Windows.Visibility.Collapsed;
17 | }
18 |
19 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
20 | {
21 | throw new NotImplementedException();
22 | }
23 | }
24 |
25 | }
26 |
27 |
28 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/KeyPad.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {3ADBFF38-915C-4115-9CDD-81C0CAD9733A}
9 | Library
10 | Properties
11 | KeyPad
12 | KeyPad
13 | v4.0
14 | Client
15 | 512
16 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
17 | 4
18 |
19 |
20 | x86
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | x86
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 4.0
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | VirtualKeyboard.xaml
60 |
61 |
62 | MSBuild:Compile
63 | Designer
64 |
65 |
66 | Keypad.xaml
67 | Code
68 |
69 |
70 | Designer
71 | MSBuild:Compile
72 |
73 |
74 |
75 |
76 | Code
77 |
78 |
79 | True
80 | True
81 | Resources.resx
82 |
83 |
84 | True
85 | Settings.settings
86 | True
87 |
88 |
89 | ResXFileCodeGenerator
90 | Resources.Designer.cs
91 |
92 |
93 |
94 | SettingsSingleFileGenerator
95 | Settings.Designer.cs
96 |
97 |
98 |
99 |
100 |
107 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/Keypad.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/Keypad.xaml.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*
4 | * Copyright (c) 2008, Andrzej Rusztowicz (ekus.net)
5 | * All rights reserved.
6 |
7 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10 |
11 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
12 |
13 | * Neither the name of ekus.net nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
14 |
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 | */
17 | /*
18 | * Added by Michele Cattafesta (mesta-automation.com) 29/2/2011
19 | * The code has been totally rewritten to create a control that can be modified more easy even without knowing the MVVM pattern.
20 | * If you need to check the original source code you can download it here: http://wosk.codeplex.com/
21 | */
22 | using System;
23 | using System.Windows;
24 | using System.Windows.Controls;
25 | using System.ComponentModel;
26 |
27 | namespace KeyPad
28 | {
29 | ///
30 | /// Logica di interazione per MainWindow.xaml
31 | ///
32 | public partial class Keypad : Window,INotifyPropertyChanged
33 | {
34 | #region Public Properties
35 |
36 | private string _result;
37 | public string Result
38 | {
39 | get { return _result; }
40 | private set { _result = value; this.OnPropertyChanged("Result"); }
41 | }
42 |
43 | #endregion
44 |
45 | public Keypad(TextBox owner, Window wndOwner)
46 | {
47 | InitializeComponent();
48 | this.Owner = wndOwner;
49 | this.DataContext = this;
50 | Result = "";
51 | }
52 |
53 | private void button_Click(object sender, RoutedEventArgs e)
54 | {
55 | Button button = sender as Button;
56 | switch (button.CommandParameter.ToString())
57 | {
58 | case "ESC":
59 | this.DialogResult = false;
60 | break;
61 |
62 | case "RETURN":
63 | this.DialogResult = true;
64 | break;
65 |
66 | case "BACK":
67 | if (Result.Length > 0)
68 | Result = Result.Remove(Result.Length - 1);
69 | break;
70 |
71 | default:
72 | Result += button.Content.ToString();
73 | break;
74 | }
75 | }
76 |
77 | #region INotifyPropertyChanged members
78 |
79 | public event PropertyChangedEventHandler PropertyChanged;
80 | private void OnPropertyChanged(String info)
81 | {
82 | if (PropertyChanged != null)
83 | {
84 | PropertyChanged(this, new PropertyChangedEventArgs(info));
85 | }
86 | }
87 |
88 | #endregion
89 |
90 |
91 |
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // Le informazioni generali relative a un assembly sono controllate dal seguente
8 | // set di attributi. Per modificare le informazioni associate a un assembly
9 | // occorre quindi modificare i valori di questi attributi.
10 | [assembly: AssemblyTitle("KeyPad")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("KeyPad")]
15 | [assembly: AssemblyCopyright("Copyright © 2012")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
20 | // ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
21 | // COM, impostare su true l'attributo ComVisible per tale tipo.
22 | [assembly: ComVisible(false)]
23 |
24 | //Per iniziare la compilazione delle applicazioni localizzabili, impostare
25 | //CultureYouAreCodingWith nel file .csproj
26 | //all'interno di un . Ad esempio, se si utilizza l'inglese (Stati Uniti)
27 | //nei file di origine, impostare su en-US. Rimuovere quindi il commento dall'attributo
28 | //NeutralResourceLanguage riportato di seguito. Aggiornare "en-US" nella
29 | //riga sottostante in modo che corrisponda all'impostazione UICulture nel file di progetto.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //dove si trovano i dizionari delle risorse specifiche del tema
36 | //(in uso se non è possibile trovare una risorsa nella pagina
37 | // oppure nei dizionari delle risorse dell'applicazione)
38 | ResourceDictionaryLocation.SourceAssembly //dove si trova il dizionario delle risorse generiche
39 | //(in uso se non è possibile trovare una risorsa nella pagina,
40 | // nell'applicazione o nei dizionari delle risorse specifiche del tema)
41 | )]
42 |
43 |
44 | // Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
45 | //
46 | // Numero di versione principale
47 | // Numero di versione secondario
48 | // Numero build
49 | // Revisione
50 | //
51 | // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
52 | // utilizzando l'asterisco (*) come descritto di seguito:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Codice generato da uno strumento.
4 | // Versione runtime:4.0.30319.239
5 | //
6 | // Le modifiche a questo file possono causare un comportamento non corretto e verranno perse
7 | // se il codice viene rigenerato.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace KeyPad.Properties
12 | {
13 |
14 |
15 | ///
16 | /// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via.
17 | ///
18 | // Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder
19 | // tramite uno strumento quale ResGen o Visual Studio.
20 | // Per aggiungere o rimuovere un membro, modificare il file con estensione .ResX, quindi eseguire di nuovo ResGen
21 | // con l'opzione /str oppure ricompilare il progetto VS.
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 | /// Restituisce l'istanza di ResourceManager nella cache utilizzata da questa classe.
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("KeyPad.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte
56 | /// le ricerche di risorse che utilizzano questa classe di risorse fortemente tipizzata.
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 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/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 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.239
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 KeyPad.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.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 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/VirtualKeyboard.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
29 |
30 |
43 |
44 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
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 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
264 |
265 |
266 |
267 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/VirtualKeyboard.xaml.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2008, Andrzej Rusztowicz (ekus.net)
3 | * All rights reserved.
4 |
5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 |
9 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 |
11 | * Neither the name of ekus.net nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12 |
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 | */
15 | /*
16 | * Added by Michele Cattafesta (mesta-automation.com) 29/2/2011
17 | * The code has been totally rewritten to create a control that can be modified more easy even without knowing the MVVM pattern.
18 | * If you need to check the original source code you can download it here: http://wosk.codeplex.com/
19 | */
20 |
21 | using System;
22 | using System.Collections.Generic;
23 | using System.Linq;
24 | using System.Text;
25 | using System.Windows;
26 | using System.Windows.Controls;
27 | using System.Windows.Data;
28 | using System.Windows.Documents;
29 | using System.Windows.Input;
30 | using System.Windows.Media;
31 | using System.Windows.Media.Imaging;
32 | using System.Windows.Navigation;
33 | using System.Windows.Shapes;
34 | using System.ComponentModel;
35 | using System.Text.RegularExpressions;
36 |
37 | namespace KeyPad
38 | {
39 | ///
40 | /// Logica di interazione per VirtualKeyboard.xaml
41 | ///
42 | public partial class VirtualKeyboard : Window, INotifyPropertyChanged
43 | {
44 | #region Public Properties
45 |
46 | private bool _showNumericKeyboard;
47 | public bool ShowNumericKeyboard
48 | {
49 | get { return _showNumericKeyboard; }
50 | set { _showNumericKeyboard = value; this.OnPropertyChanged("ShowNumericKeyboard"); }
51 | }
52 |
53 | private string _result;
54 | public string Result
55 | {
56 | get { return _result; }
57 | private set { _result = value; this.OnPropertyChanged("Result"); }
58 | }
59 |
60 | #endregion
61 |
62 | #region Constructor
63 |
64 | public VirtualKeyboard(TextBox owner, Window wndOwner)
65 | {
66 | InitializeComponent();
67 | this.Owner = wndOwner;
68 | this.DataContext = this;
69 | Result = "";
70 | }
71 |
72 | #endregion
73 |
74 | #region Callbacks
75 |
76 | private void button_Click(object sender, RoutedEventArgs e)
77 | {
78 | Button button = sender as Button;
79 | if (button != null)
80 | {
81 | switch (button.CommandParameter.ToString())
82 | {
83 | case "LSHIFT":
84 | Regex upperCaseRegex = new Regex("[A-Z]");
85 | Regex lowerCaseRegex = new Regex("[a-z]");
86 | Button btn;
87 | foreach (UIElement elem in AlfaKeyboard.Children) //iterate the main grid
88 | {
89 | Grid grid = elem as Grid;
90 | if (grid != null)
91 | {
92 | foreach (UIElement uiElement in grid.Children) //iterate the single rows
93 | {
94 | btn = uiElement as Button;
95 | if (btn != null) // if button contains only 1 character
96 | {
97 | if (btn.Content.ToString().Length == 1)
98 | {
99 | if (upperCaseRegex.Match(btn.Content.ToString()).Success) // if the char is a letter and uppercase
100 | btn.Content = btn.Content.ToString().ToLower();
101 | else if (lowerCaseRegex.Match(button.Content.ToString()).Success) // if the char is a letter and lower case
102 | btn.Content = btn.Content.ToString().ToUpper();
103 | }
104 |
105 | }
106 | }
107 | }
108 | }
109 | break;
110 |
111 | case "ALT":
112 | case "CTRL":
113 | break;
114 |
115 | case "RETURN":
116 | this.DialogResult = true;
117 | break;
118 |
119 | case "BACK":
120 | if (Result.Length > 0)
121 | Result = Result.Remove(Result.Length - 1);
122 | break;
123 |
124 | default:
125 | Result += button.Content.ToString();
126 | break;
127 | }
128 | }
129 | }
130 |
131 | #endregion
132 |
133 | #region INotifyPropertyChanged members
134 |
135 | public event PropertyChangedEventHandler PropertyChanged;
136 | protected void OnPropertyChanged(string propertyName)
137 | {
138 | if (PropertyChanged != null)
139 | this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
140 | }
141 |
142 | #endregion
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/KeyPad/KeyPad/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Windows;
7 |
8 | namespace TestKeypad
9 | {
10 | ///
11 | /// Logica di interazione per App.xaml
12 | ///
13 | public partial class App : Application
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using System.Windows.Documents;
9 | using System.Windows.Input;
10 | using System.Windows.Media;
11 | using System.Windows.Media.Imaging;
12 | using System.Windows.Navigation;
13 | using System.Windows.Shapes;
14 | using KeyPad;
15 |
16 | namespace TestKeypad
17 | {
18 | ///
19 | /// Logica di interazione per MainWindow.xaml
20 | ///
21 | public partial class MainWindow : Window
22 | {
23 | public MainWindow()
24 | {
25 | InitializeComponent();
26 | }
27 |
28 | private void textBox1_PreviewMouseDown(object sender, MouseButtonEventArgs e)
29 | {
30 | TextBox textbox = sender as TextBox;
31 | Keypad keypadWindow = new Keypad(textbox, this);
32 | if (keypadWindow.ShowDialog() == true)
33 | textbox.Text = keypadWindow.Result;
34 | }
35 |
36 | private void textBox2_PreviewMouseDown(object sender, MouseButtonEventArgs e)
37 | {
38 | TextBox textbox = sender as TextBox;
39 | VirtualKeyboard keyboardWindow = new VirtualKeyboard(textbox, this);
40 | if (keyboardWindow.ShowDialog() == true)
41 | textbox.Text = keyboardWindow.Result;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // Le informazioni generali relative a un assembly sono controllate dal seguente
8 | // set di attributi. Per modificare le informazioni associate a un assembly
9 | // occorre quindi modificare i valori di questi attributi.
10 | [assembly: AssemblyTitle("TestKeypad")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("TestKeypad")]
15 | [assembly: AssemblyCopyright("Copyright © 2012")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
20 | // ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
21 | // COM, impostare su true l'attributo ComVisible per tale tipo.
22 | [assembly: ComVisible(false)]
23 |
24 | //Per iniziare la compilazione delle applicazioni localizzabili, impostare
25 | //CultureYouAreCodingWith nel file .csproj
26 | //all'interno di un . Ad esempio, se si utilizza l'inglese (Stati Uniti)
27 | //nei file di origine, impostare su en-US. Rimuovere quindi il commento dall'attributo
28 | //NeutralResourceLanguage riportato di seguito. Aggiornare "en-US" nella
29 | //riga sottostante in modo che corrisponda all'impostazione UICulture nel file di progetto.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //dove si trovano i dizionari delle risorse specifiche del tema
36 | //(in uso se non è possibile trovare una risorsa nella pagina
37 | // oppure nei dizionari delle risorse dell'applicazione)
38 | ResourceDictionaryLocation.SourceAssembly //dove si trova il dizionario delle risorse generiche
39 | //(in uso se non è possibile trovare una risorsa nella pagina,
40 | // nell'applicazione o nei dizionari delle risorse specifiche del tema)
41 | )]
42 |
43 |
44 | // Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
45 | //
46 | // Numero di versione principale
47 | // Numero di versione secondario
48 | // Numero build
49 | // Revisione
50 | //
51 | // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
52 | // utilizzando l'asterisco (*) come descritto di seguito:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Codice generato da uno strumento.
4 | // Versione runtime:4.0.30319.239
5 | //
6 | // Le modifiche a questo file possono causare un comportamento non corretto e verranno perse
7 | // se il codice viene rigenerato.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TestKeypad.Properties
12 | {
13 |
14 |
15 | ///
16 | /// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via.
17 | ///
18 | // Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder
19 | // tramite uno strumento quale ResGen o Visual Studio.
20 | // Per aggiungere o rimuovere un membro, modificare il file con estensione .ResX, quindi eseguire di nuovo ResGen
21 | // con l'opzione /str oppure ricompilare il progetto VS.
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 | /// Restituisce l'istanza di ResourceManager nella cache utilizzata da questa classe.
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("TestKeypad.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte
56 | /// le ricerche di risorse che utilizzano questa classe di risorse fortemente tipizzata.
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 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/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 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.239
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 TestKeypad.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.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 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/KeyPad/TestKeypad/TestKeypad.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {2302659E-071F-4525-9D8F-C16AE000B201}
9 | WinExe
10 | Properties
11 | TestKeypad
12 | TestKeypad
13 | v4.0
14 | Client
15 | 512
16 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
17 | 4
18 |
19 |
20 | x86
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | x86
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 4.0
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | MSBuild:Compile
56 | Designer
57 |
58 |
59 | MSBuild:Compile
60 | Designer
61 |
62 |
63 | App.xaml
64 | Code
65 |
66 |
67 | MainWindow.xaml
68 | Code
69 |
70 |
71 |
72 |
73 | Code
74 |
75 |
76 | True
77 | True
78 | Resources.resx
79 |
80 |
81 | True
82 | Settings.settings
83 | True
84 |
85 |
86 | ResXFileCodeGenerator
87 | Resources.Designer.cs
88 |
89 |
90 | SettingsSingleFileGenerator
91 | Settings.Designer.cs
92 |
93 |
94 |
95 |
96 |
97 | {3ADBFF38-915C-4115-9CDD-81C0CAD9733A}
98 | KeyPad
99 |
100 |
101 |
102 |
109 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | WPF-on-screen-keyboard-and-keypad
2 | =================================
3 |
4 | Contains a WPF keypad and keyboard that can be used with touch applications and that has a good graphic
5 | Read the full article at http://www.mesta-automation.com/wpf-touch-keyboard/
6 |
--------------------------------------------------------------------------------