-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathMainWindow.xaml
More file actions
146 lines (133 loc) · 5.79 KB
/
MainWindow.xaml
File metadata and controls
146 lines (133 loc) · 5.79 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
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
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
136
137
138
139
140
141
142
143
144
145
146
<Window x:Class="WpfMath.Example.MainWindow"
x:Name="Window"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WpfMath.Controls;assembly=WpfMath"
xmlns:example="clr-namespace:WpfMath.Example"
Title="WPF-Math Example" Width="1200" Height="600"
WindowStartupLocation="CenterScreen">
<Window.DataContext>
<example:MainViewModel />
</Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<GroupBox Grid.Column="0"
Grid.Row="0"
Header="Presets">
<ListView ItemsSource="{Binding Presets}"
SelectedItem="{Binding SelectedPreset}">
<ListView.ItemTemplate>
<DataTemplate DataType="{x:Type example:Preset}">
<TextBlock Text="{Binding Name}">
<TextBlock.ToolTip>
<controls:FormulaControl Formula="{Binding Formula}" />
</TextBlock.ToolTip>
</TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</GroupBox>
<GroupBox Grid.Column="1"
Grid.Row="0"
Header="Formula">
<TextBox Name="InputTextBox"
AcceptsReturn="True"
BorderThickness="0"
FontFamily="Consolas"
HorizontalScrollBarVisibility="Auto"
Margin="3"
SelectionChanged="OnSelectionChanged"
Text="{Binding Formula, UpdateSourceTrigger=PropertyChanged}"
VerticalScrollBarVisibility="Auto" />
</GroupBox>
<Label Grid.Column="1"
Grid.Row="1"
Margin="3"
HorizontalAlignment="Right">
<Label.Style>
<Style TargetType="Label">
<Setter Property="Content" Value="Formula is valid" />
<Setter Property="Foreground" Value="Green" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=FormulaControl, Path=HasError}" Value="True">
<Setter Property="Content" Value="{Binding ElementName=FormulaControl, Path=Errors[0].Message}" />
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<GridSplitter Grid.Column="2"
Grid.Row="0"
Grid.RowSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
ShowsPreview="True"
Width="5" />
<Label Grid.Column="2"
Grid.Row="0"
Grid.RowSpan="2"
Content="⁞"
FontSize="18"
IsHitTestVisible="False"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<GroupBox Grid.Column="3"
Grid.Row="0"
Header="Rendering">
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Disabled"
Margin="3">
<controls:FormulaControl Name="FormulaControl"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
SnapsToDevicePixels="True"
Formula="{Binding Formula, NotifyOnValidationError=True}"
Padding="5"
Scale="{Binding Scale}"
SelectionBrush="LightBlue"
SystemTextFontName="Arial" />
</ScrollViewer>
</GroupBox>
<DockPanel Grid.Column="3"
Grid.Row="1"
DockPanel.Dock="Bottom">
<Label DockPanel.Dock="Left"
Content="{Binding Scale}"
ContentStringFormat="Scale: {0}"
Margin="3"
Width="58" />
<Button DockPanel.Dock="Right"
Command="{Binding ExportCommand}"
Content="Export..."
Margin="3"
Padding="5 0">
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=FormulaControl, Path=HasError}" Value="True">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Slider AutoToolTipPlacement="BottomRight"
AutoToolTipPrecision="2"
IsSnapToTickEnabled="True"
Margin="3"
Minimum="7" Maximum="42"
TickPlacement="BottomRight"
Value="{Binding Scale}" />
</DockPanel>
</Grid>
</Window>