Add project files.

This commit is contained in:
Admin
2024-09-02 10:03:23 +07:00
parent 42def0d4aa
commit 6219298497
361 changed files with 58423 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
+42
View File
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace VirtualKeyboard.Wpf
{
class Command : ICommand
{
public event EventHandler CanExecuteChanged;
private bool _canExecuteCommand = true;
public bool CanExecuteCommand
{
get => _canExecuteCommand;
set
{
_canExecuteCommand = value;
CanExecuteChanged?.Invoke(this, new EventArgs());
}
}
private readonly Action<object> _execute;
public Command(Action<object> execute)
{
_execute = execute;
}
public bool CanExecute(object parameter)
{
return CanExecuteCommand;
}
public void Execute(object parameter)
{
_execute?.Invoke(parameter);
}
}
}
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VirtualKeyboard.Wpf.Controls
{
class AdvancedTextBox : TextBox
{
public int CaretPosition
{
get { return (int)GetValue(CaretPositionProperty); }
set { SetValue(CaretPositionProperty, value); }
}
// Using a DependencyProperty as the backing store for CaretPosition. This enables animation, styling, binding, etc...
public static readonly DependencyProperty CaretPositionProperty =
DependencyProperty.Register("CaretPosition", typeof(int), typeof(AdvancedTextBox),
new PropertyMetadata(0, OnCaretPositionChange));
public string SelectedValue
{
get { return (string)GetValue(SelectedValueProperty); }
set { SetValue(SelectedValueProperty, value); }
}
// Using a DependencyProperty as the backing store for SelectedValue. This enables animation, styling, binding, etc...
public static readonly DependencyProperty SelectedValueProperty =
DependencyProperty.Register("SelectedValue", typeof(string), typeof(AdvancedTextBox),
new PropertyMetadata("", OnSelectedTextChange));
public string TextValue
{
get { return (string)GetValue(TextValueProperty); }
set { SetValue(TextValueProperty, value); }
}
// Using a DependencyProperty as the backing store for TextValue. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextValueProperty =
DependencyProperty.Register("TextValue", typeof(string), typeof(AdvancedTextBox),
new PropertyMetadata("", OnTextValueChange));
public AdvancedTextBox()
{
SelectionChanged += AdvancedTextBox_SelectionChanged;
TextChanged += (s, e) => SetValue(TextValueProperty, Text);
}
private void AdvancedTextBox_SelectionChanged(object sender, RoutedEventArgs e)
{
SetValue(CaretPositionProperty, CaretIndex);
SetValue(SelectedValueProperty, SelectedText);
}
private static void OnCaretPositionChange(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
int? value = e.NewValue as int?;
((TextBox)sender).CaretIndex = value ?? 0;
}
private static void OnSelectedTextChange(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
string value = e.NewValue as string;
((TextBox)sender).SelectedText = value ?? "";
}
private static void OnTextValueChange(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
var s = (AdvancedTextBox)sender;
int caretPosition = s.CaretPosition;
string value = e.NewValue as string;
s.Text = value;
s.CaretIndex = caretPosition <= value.Length ? caretPosition : value.Length;
}
}
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using VirtualKeyboard.Wpf.Types;
using VirtualKeyboard.Wpf.Views;
namespace VirtualKeyboard.Wpf.Converters
{
class KeyboardTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var type = (KeyboardType)value;
switch (type)
{
case KeyboardType.Alphabet: return new AlphabetView();
case KeyboardType.Special: return new SpecialCharactersView();
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Documents;
namespace VirtualKeyboard.Wpf.Converters
{
class UppercaseTypographyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool uppercase = (bool)value;
if (uppercase) return FontCapitals.AllSmallCaps;
else return FontCapitals.Normal;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
+25
View File
@@ -0,0 +1,25 @@
<Window x:ClassModifier="internal"
x:Class="VirtualKeyboard.Wpf.DefaultKeyboardHost"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VirtualKeyboard.Wpf"
mc:Ignorable="d"
WindowState="Maximized" ShowInTaskbar="False" ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True">
<Window.Background>
<SolidColorBrush Opacity="0.5" Color="Black"/>
</Window.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<ContentControl MaxWidth="700" MaxHeight="150" x:Name="KeyboardValueContent"/>
</Grid>
<Grid Grid.Row="1">
<ContentControl MaxWidth="900" MaxHeight="360" x:Name="KeyboardContent"/>
</Grid>
</Grid>
</Window>
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace VirtualKeyboard.Wpf
{
/// <summary>
/// Logika interakcji dla klasy DefaultKeyboardHost.xaml
/// </summary>
partial class DefaultKeyboardHost : Window
{
public DefaultKeyboardHost()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,39 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="KeyboardBackgroundBrush" Color="#2f2f2f"/>
<SolidColorBrush x:Key="KeyboardBackgroundAccentBrush" Color="#FFA0A0A0"/>
<SolidColorBrush x:Key="KeyboardForegroundBrush" Color="White"/>
<sys:Double x:Key="KeyboardIconSize">50</sys:Double>
<!--<SolidColorBrush x:Key="UppercaseBrush" Color="#FF006DA0"/>-->
<Style x:Key="KeyboardButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="FontSize" Value="30"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="{StaticResource KeyboardBackgroundBrush}"/>
<Setter Property="Foreground" Value="{StaticResource KeyboardForegroundBrush}"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Margin" Value="5" />
<Setter Property="Height" Value="Auto"/>
<Setter Property="Width" Value="Auto" />
</Style>
<Style x:Key="KeyboardRepeatButtonStyle" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource {x:Type RepeatButton}}">
<Setter Property="FontSize" Value="30"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="{StaticResource KeyboardBackgroundBrush}"/>
<Setter Property="Foreground" Value="{StaticResource KeyboardForegroundBrush}"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Margin" Value="5" />
<Setter Property="Height" Value="Auto"/>
<Setter Property="Width" Value="Auto" />
</Style>
<Style x:Key="KeyboardValueBoxStyle" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="FontSize" Value="40" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Foreground" Value="{StaticResource KeyboardForegroundBrush}"/>
<Setter Property="Background" Value="{StaticResource KeyboardBackgroundBrush}"/>
<Setter Property="Margin" Value="25" />
</Style>
</ResourceDictionary>
@@ -0,0 +1,38 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:VirtualKeyboard.Wpf.Converters">
<converters:UppercaseTypographyConverter x:Key="UppercaseConverter"/>
<converters:KeyboardTypeConverter x:Key="KeyboardTypeConverter"/>
<Style TargetType="Viewbox">
<Setter Property="Width" Value="{DynamicResource KeyboardIconSize}"/>
<Setter Property="Height" Value="{DynamicResource KeyboardIconSize}"/>
</Style>
<Style TargetType="Path">
<Setter Property="Fill" Value="{DynamicResource KeyboardForegroundBrush}"/>
</Style>
<RepeatButton Style="{DynamicResource KeyboardRepeatButtonStyle}" Delay="500" Interval="50" x:Key="BackspaceButton" Command="{Binding RemoveCharacter}">
<Viewbox>
<Canvas Width="24" Height="24">
<Path Data="M19,15.59L17.59,17L14,13.41L10.41,17L9,15.59L12.59,12L9,8.41L10.41,7L14,10.59L17.59,7L19,8.41L15.41,12L19,15.59M22,3A2,2 0 0,1 24,5V19A2,2 0 0,1 22,21H7C6.31,21 5.77,20.64 5.41,20.11L0,12L5.41,3.88C5.77,3.35 6.31,3 7,3H22M22,5H7L2.28,12L7,19H22V5Z" />
</Canvas>
</Viewbox>
</RepeatButton>
<Button Style="{DynamicResource KeyboardButtonStyle}" x:Key="AcceptButton" Command="{Binding Accept}">
<Viewbox>
<Canvas Width="24" Height="24">
<Path Data="M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z" />
</Canvas>
</Viewbox>
</Button>
<Button Style="{DynamicResource KeyboardButtonStyle}" x:Key="CasingButton" Command="{Binding ChangeCasing}">
<Viewbox>
<Canvas Width="24" Height="24">
<Path Data="M15,18V12H17.17L12,6.83L6.83,12H9V18H15M12,4L22,14H17V20H7V14H2L12,4Z">
</Path>
</Canvas>
</Viewbox>
</Button>
</ResourceDictionary>
+14
View File
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VirtualKeyboard.Wpf.Types
{
public enum KeyboardType
{
Alphabet,
Special
}
}
+15
View File
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VirtualKeyboard.Wpf.Types
{
enum UppercaseMode
{
None,
FirstUpper,
AlwaysUpper
}
}
+86
View File
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using VirtualKeyboard.Wpf.Controls;
using VirtualKeyboard.Wpf.ViewModels;
using VirtualKeyboard.Wpf.Views;
namespace VirtualKeyboard.Wpf
{
public static class VKeyboard
{
private const string _keyboardValueName = "KeyboardValueContent";
private const string _keyboardName = "KeyboardContent";
private static Type _hostType = typeof(DefaultKeyboardHost);
private static TaskCompletionSource<string> _tcs;
private static Window _windowHost;
public static void Config(Type hostType)
{
if (hostType.IsSubclassOf(typeof(Window))) _hostType = hostType;
else throw new ArgumentException();
}
public static void Listen<T>(Expression<Func<T, string>> property) where T: UIElement
{
EventManager.RegisterClassHandler(typeof(T), UIElement.PreviewMouseLeftButtonDownEvent, (RoutedEventHandler)(async (s, e) =>
{
if (s is AdvancedTextBox) return;
var memberSelectorExpression = property.Body as MemberExpression;
if (memberSelectorExpression == null) return;
var prop = memberSelectorExpression.Member as PropertyInfo;
if (prop == null) return;
var initValue = (string)prop.GetValue(s);
var value = await OpenAsync(initValue);
prop.SetValue(s, value, null);
}));
}
public static Task<string> OpenAsync(string initialValue = "")
{
if (_windowHost != null) throw new InvalidOperationException();
_tcs = new TaskCompletionSource<string>();
_windowHost = (Window)Activator.CreateInstance(_hostType);
_windowHost.DataContext = new VirtualKeyboardViewModel(initialValue);
((ContentControl)_windowHost.FindName(_keyboardValueName)).Content = new KeyboardValueView();
((ContentControl)_windowHost.FindName(_keyboardName)).Content = new VirtualKeyboardView();
void handler(object s, CancelEventArgs a)
{
var result = GetResult();
((Window)s).Closing -= handler;
_windowHost = null;
_tcs?.SetResult(result);
_tcs = null;
}
_windowHost.Closing += handler;
_windowHost.Owner = Application.Current.MainWindow;
_windowHost.Show();
return _tcs.Task;
}
public static void Close()
{
if (_windowHost == null) throw new InvalidOperationException();
_windowHost.Close();
}
private static string GetResult()
{
var viewModel = (VirtualKeyboardViewModel)_windowHost.DataContext;
return viewModel.KeyboardText;
}
}
}
@@ -0,0 +1,135 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VirtualKeyboard.Wpf.Types;
namespace VirtualKeyboard.Wpf.ViewModels
{
class VirtualKeyboardViewModel : INotifyPropertyChanged
{
private string _keyboardText;
public string KeyboardText {
get => _keyboardText;
set
{
_keyboardText = value;
NotifyPropertyChanged(nameof(KeyboardText));
}
}
private KeyboardType _keyboardType;
public KeyboardType KeyboardType {
get => _keyboardType;
private set
{
_keyboardType = value;
NotifyPropertyChanged(nameof(KeyboardType));
}
}
private bool _uppercase;
public bool Uppercase
{
get => _uppercase;
private set
{
_uppercase = value;
NotifyPropertyChanged(nameof(Uppercase));
}
}
private int _caretPosition;
public int CaretPosition
{
get => _caretPosition;
set
{
if (value < 0) _caretPosition = 0;
else if (value > KeyboardText.Length) _caretPosition = KeyboardText.Length;
else _caretPosition = value;
NotifyPropertyChanged(nameof(CaretPosition));
}
}
private string _selectedValue;
public string SelectedValue
{
get => _selectedValue;
set
{
_selectedValue = value;
NotifyPropertyChanged(nameof(SelectedValue));
}
}
public Command AddCharacter { get; }
public Command ChangeCasing { get; }
public Command RemoveCharacter { get; }
public Command ChangeKeyboardType { get; }
public Command Accept { get; }
public VirtualKeyboardViewModel(string initialValue)
{
_keyboardText = initialValue;
_keyboardType = KeyboardType.Alphabet;
_uppercase = false;
CaretPosition = _keyboardText.Length;
AddCharacter = new Command(a =>
{
if (a is string character)
if (character.Length == 1)
{
if (Uppercase) character = character.ToUpper();
if (!string.IsNullOrEmpty(SelectedValue))
{
RemoveSubstring(SelectedValue);
KeyboardText = KeyboardText.Insert(CaretPosition, character);
CaretPosition++;
SelectedValue = "";
}
else
{
KeyboardText = KeyboardText.Insert(CaretPosition, character);
CaretPosition++;
}
}
});
ChangeCasing = new Command(a => Uppercase = !Uppercase);
RemoveCharacter = new Command(a =>
{
if(!string.IsNullOrEmpty(SelectedValue))
{
RemoveSubstring(SelectedValue);
}
else
{
var position = CaretPosition - 1;
if (position >= 0)
{
KeyboardText = KeyboardText.Remove(position, 1);
if (position < KeyboardText.Length) CaretPosition--;
else CaretPosition = KeyboardText.Length;
}
}
});
ChangeKeyboardType = new Command(a =>
{
if (KeyboardType == KeyboardType.Alphabet) KeyboardType = KeyboardType.Special;
else KeyboardType = KeyboardType.Alphabet;
});
Accept = new Command(a => VKeyboard.Close());
}
private void RemoveSubstring(string substring)
{
var position = KeyboardText.IndexOf(substring);
KeyboardText = KeyboardText.Remove(position, substring.Length);
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string prop)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
}
}
}
+116
View File
@@ -0,0 +1,116 @@
<UserControl x:ClassModifier="public"
x:Class="VirtualKeyboard.Wpf.Views.AlphabetView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VirtualKeyboard.Wpf.Views"
xmlns:converters="clr-namespace:VirtualKeyboard.Wpf.Converters"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../ResourceDictionaries/KeyboardCore.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="q" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="1" Content="w" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="2" Content="e" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="3" Content="r" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="4" Content="t" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="5" Content="y" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="6" Content="u" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="7" Content="i" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="8" Content="o" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="9" Content="p" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" Content="a" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="2" Content="s" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="3" Content="d" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="4" Content="f" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="5" Content="g" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="6" Content="h" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="7" Content="j" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="8" Content="k" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="9" Content="l" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.1*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1.9*"/>
</Grid.ColumnDefinitions>
<ContentControl Grid.Column="0" Content="{StaticResource CasingButton}"/>
<Button Grid.Column="1" Content="z" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="2" Content="x" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="3" Content="c" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="4" Content="v" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="5" Content="b" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="6" Content="n" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="7" Content="m" Typography.Capitals="{Binding Uppercase, Converter={StaticResource UppercaseConverter}}" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<ContentControl Grid.Column="8" Content="{StaticResource BackspaceButton}" />
</Grid>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="?123" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding ChangeKeyboardType}"/>
<Button Grid.Column="1" Content=" " Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="2" Content="." Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="3" Content="@" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<ContentControl Grid.Column="4" Content="{StaticResource AcceptButton}"/>
</Grid>
</Grid>
</Grid>
</UserControl>
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VirtualKeyboard.Wpf.Views
{
/// <summary>
/// Logika interakcji dla klasy AlphabetView.xaml
/// </summary>
partial class AlphabetView : UserControl
{
public AlphabetView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,21 @@
<UserControl x:ClassModifier="public"
x:Class="VirtualKeyboard.Wpf.Views.KeyboardValueView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VirtualKeyboard.Wpf.Views"
xmlns:controls="clr-namespace:VirtualKeyboard.Wpf.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../ResourceDictionaries/DefaultStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Background="{DynamicResource KeyboardBackgroundAccentBrush}">
<controls:AdvancedTextBox TextValue="{Binding KeyboardText, Mode=TwoWay}" CaretPosition="{Binding CaretPosition, Mode=TwoWay}" SelectedValue="{Binding SelectedValue, Mode=TwoWay}" Style="{DynamicResource KeyboardValueBoxStyle}"/>
</Grid>
</UserControl>
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VirtualKeyboard.Wpf.Views
{
/// <summary>
/// Logika interakcji dla klasy KeyboardValueView.xaml
/// </summary>
partial class KeyboardValueView : UserControl
{
public KeyboardValueView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,115 @@
<UserControl x:ClassModifier="public"
x:Class="VirtualKeyboard.Wpf.Views.SpecialCharactersView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VirtualKeyboard.Wpf.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../ResourceDictionaries/KeyboardCore.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="1" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="1" Content="2" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="2" Content="3" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="3" Content="4" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="4" Content="5" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="5" Content="6" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="6" Content="7" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="7" Content="8" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="8" Content="9" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="9" Content="0" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="&quot;" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="1" Content="!" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="2" Content="#" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="3" Content="$" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="4" Content="%" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="5" Content="/" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="6" Content="&amp;" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="7" Content="*" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="8" Content="(" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="9" Content=")" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="'" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="1" Content="-" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="2" Content="+" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="3" Content=";" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="4" Content=":" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="5" Content="," Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="6" Content="_" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="7" Content="?" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<ContentControl Grid.Column="8" Content="{StaticResource BackspaceButton}"/>
</Grid>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="abc" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding ChangeKeyboardType}"/>
<Button Grid.Column="1" Content=" " Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="2" Content="." Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<Button Grid.Column="3" Content="@" Style="{DynamicResource KeyboardButtonStyle}" Command="{Binding AddCharacter}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content}"/>
<ContentControl Grid.Column="9" Content="{StaticResource AcceptButton}"/>
</Grid>
</Grid>
</Grid>
</UserControl>
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VirtualKeyboard.Wpf.Views
{
/// <summary>
/// Logika interakcji dla klasy SpecialCharactersView.xaml
/// </summary>
partial class SpecialCharactersView : UserControl
{
public SpecialCharactersView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,20 @@
<UserControl x:ClassModifier="public"
x:Class="VirtualKeyboard.Wpf.Views.VirtualKeyboardView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VirtualKeyboard.Wpf"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../ResourceDictionaries/KeyboardCore.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Background="{DynamicResource KeyboardBackgroundAccentBrush}">
<ContentControl Content="{Binding KeyboardType, Converter={StaticResource KeyboardTypeConverter}}"/>
</Grid>
</UserControl>
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VirtualKeyboard.Wpf.ViewModels;
namespace VirtualKeyboard.Wpf.Views
{
/// <summary>
/// Logika interakcji dla klasy VirtualKeyboard.xaml
/// </summary>
partial class VirtualKeyboardView : UserControl
{
public VirtualKeyboardView()
{
InitializeComponent();
}
}
}
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>