-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti.cs
More file actions
69 lines (53 loc) · 1.67 KB
/
multi.cs
File metadata and controls
69 lines (53 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using AutoCorrectLibrary;
namespace AutoCorrectApp
{
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
}
private void AutoCorrectTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
var textBox = sender as TextBox;
var cursorPosition = textBox.SelectionStart;
textBox.TextChanged -= AutoCorrectTextBox_TextChanged; // Unsubscribe to avoid recursive call
textBox.Text = TextHelper.ContextualAutoCorrect(textBox.Text);
textBox.SelectionStart = cursorPosition; // Restore cursor position
textBox.TextChanged += AutoCorrectTextBox_TextChanged; // Subscribe again
}
}
}
<Application
x:Class="AutoCorrectApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<!-- Application resource dictionary -->
</Application.Resources>
</Application>
using Microsoft.UI.Xaml;
namespace AutoCorrectApp
{
public partial class App : Application
{
public App()
{
this.InitializeComponent();
}
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
m_window.Activate();
}
private Window m_window;
}
}
private static Dictionary<string, string> _corrections = new Dictionary<string, string>
{
{ "teh", "the" },
{ "recieve", "receive" },
// Add more pairs here
};