Added plain TextBox to test the databinding on CodeTextBox.

This commit is contained in:
David
2016-10-13 21:15:10 -04:00
parent 1c44e00a1d
commit 3e96ed3484
6 changed files with 1081 additions and 4 deletions

View File

@@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=Befunge_002EEditor_002EAnnotations/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=Befunge_002EInterpreter_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -66,6 +66,7 @@
<Compile Include="CharStyles\BefungeStyler.cs" />
<Compile Include="CharStyles\ITextStyler.cs" />
<Compile Include="Controls\CodeTextBox.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Utils\Extensions.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>

View File

@@ -1,12 +1,22 @@
<Window x:Class="Befunge.Editor.MainWindow"
<Window
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:loc="clr-namespace:Befunge.Editor.Controls"
xmlns:local="clr-namespace:Befunge.Editor" x:Class="Befunge.Editor.MainWindow"
mc:Ignorable="d"
Title="Befunge Editor" Height="350" Width="525">
<Window.DataContext>
<local:TextContext/>
</Window.DataContext>
<Grid>
<loc:CodeTextBox x:Name="EditRegion" Margin="10,10,10,10.5" Text="Hello, world!"/>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<loc:CodeTextBox x:Name="EditRegion" Margin="10" Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0"/>
<TextBox x:Name="PlainTextBox" Margin="10" Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1"/>
</Grid>
</Window>

View File

@@ -1,8 +1,34 @@
using System.Windows;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using Befunge.Editor.Annotations;
using Befunge.Editor.CharStyles;
namespace Befunge.Editor
{
public class TextContext : INotifyPropertyChanged
{
private string _text;
public string Text
{
get { return _text; }
set
{
_text = value;
OnPropertyChanged(nameof(Text));
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public partial class MainWindow
{
public MainWindow()

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@ using System.Threading.Tasks;
namespace Befunge.Interpreter
{
public interface StepInterpreter : INotifyPropertyChanged
public interface IStepInterpreter : INotifyPropertyChanged
{
IVec2 InstructionPointerPosition { get; }
string Output { get; }