-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainWindow.xaml
127 lines (115 loc) · 9.14 KB
/
MainWindow.xaml
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
<Window x:Class="Simvars.MainWindow"
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:Simvars"
xmlns:simco="clr-namespace:Microsoft.FlightSimulator.SimConnect;assembly=Microsoft.FlightSimulator.SimConnect"
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="MainWindow" Height="700" Width="800" MinWidth="800" MinHeight="700">
<Window.Resources>
<ObjectDataProvider x:Key="SimObjectTypeFromEnum" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="simco:SIMCONNECT_SIMOBJECT_TYPE"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<CollectionViewSource x:Key="AlphaSortedSimvarNames" Source="{Binding aSimvarNames}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
<CollectionViewSource x:Key="AlphaSortedUnitNames" Source="{Binding aUnitNames}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</Window.Resources>
<Grid>
<TextBlock Width="236" Margin="10,11,546,-11" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top">
<Hyperlink x:Name="hl_SimConnect" NavigateUri="https://msdn.microsoft.com/en-us/library/cc526983.aspx" RequestNavigate="LinkOnRequestNavigate">
SimConnect Reference
</Hyperlink>
</TextBlock>
<TextBlock Margin="10,33,546,613" Width="236" VerticalAlignment="Top" HorizontalAlignment="Left" Height="23">
<Hyperlink x:Name="hl_SimVariables" NavigateUri="https://msdn.microsoft.com/en-us/library/cc526981.aspx" RequestNavigate="LinkOnRequestNavigate" >
Simulation Variables Reference
</Hyperlink>
</TextBlock>
<Button x:Name="btn_Connection" Content="{Binding sConnectButtonLabel}" Command="{Binding cmdToggleConnect}" HorizontalAlignment="Left" Margin="29,68,0,0" VerticalAlignment="Top" Width="217" Height="48"/>
<Button x:Name="btn_LoadFile" Content="Load File" Command="{Binding cmdLoadFiles}" HorizontalAlignment="Left" Margin="29,156,0,0" VerticalAlignment="Top" Width="100" Height="23" RenderTransformOrigin="0.423,0.841"/>
<Button x:Name="btn_SaveFile" Content="Save File" Command="{Binding cmdSaveFile}" HorizontalAlignment="Left" Margin="148,156,0,0" VerticalAlignment="Top" Width="100" Height="23"/>
<CheckBox Content="Save values" IsChecked="{Binding bSaveValues, Mode=TwoWay}" HorizontalAlignment="Left" Margin="167,184,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.597,0.489"/>
<ListView x:Name="lv_Simvars" ItemsSource="{Binding lSimvarRequests}" SelectedItem="{Binding oSelectedSimvarRequest, Mode=OneWayToSource}" Margin="270,10,10,10">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Style.Triggers>
<DataTrigger Binding="{Binding bStillPending}" Value="True">
<Setter Property="Background" Value="#55D3D373" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Remove" Command="{Binding cmdRemoveSelectedRequest}" />
</ContextMenu>
</ListView.ContextMenu>
<ListView.View>
<GridView>
<GridViewColumn Header="Simvar" Width="200" DisplayMemberBinding="{Binding sName}"/>
<GridViewColumn Header="Value" Width="150" DisplayMemberBinding="{Binding dValue, StringFormat=\{0:F9\}}"/>
<GridViewColumn Header="Units" Width="150" DisplayMemberBinding="{Binding sUnits}"/>
</GridView>
</ListView.View>
</ListView>
<Label Content="SimObject" HorizontalAlignment="Left" Margin="10,208,0,0" VerticalAlignment="Top" Height="23" Width="83"/>
<ComboBox x:Name="cbb_SimObjectType" ItemsSource="{Binding Source={StaticResource SimObjectTypeFromEnum}}" SelectedValue="{Binding eSimObjectType, Mode=OneWayToSource}" SelectedIndex="0" HorizontalAlignment="Left" Margin="11,231,0,0" VerticalAlignment="Top" Width="119" Height="23"/>
<Label Content="ObjectID" HorizontalAlignment="Left" Margin="165,208,0,0" VerticalAlignment="Top" Height="23" Width="71"/>
<ComboBox x:Name="cbb_ObjectIds" ItemsSource="{Binding lObjectIDs}" SelectedValue="{Binding iObjectIdRequest, Mode=OneWayToSource}" IsEnabled="{Binding bObjectIDSelectionEnabled}" SelectedIndex="0" HorizontalAlignment="Left" Margin="165,231,0,0" VerticalAlignment="Top" Width="48" Height="23"/>
<Label Content="Simvar Name" HorizontalAlignment="Left" Margin="10,259,0,0" VerticalAlignment="Top" Height="23" Width="83"/>
<ComboBox x:Name="cbb_SimvarNames" ItemsSource="{Binding Source={StaticResource AlphaSortedSimvarNames}}" SelectedValue="{Binding sSimvarRequest, Mode=OneWayToSource}" SelectedIndex="0" HorizontalAlignment="Left" Margin="10,282,0,0" VerticalAlignment="Top" Width="238" Height="23"/>
<Label Content="Index" HorizontalAlignment="Left" Margin="10,310,0,0" VerticalAlignment="Top" Height="23" Width="71"/>
<ComboBox x:Name="cbb_Indices" ItemsSource="{Binding aIndices}" SelectedValue="{Binding iIndexRequest, Mode=OneWayToSource}" SelectedIndex="0" HorizontalAlignment="Left" Margin="10,333,0,0" VerticalAlignment="Top" Width="45" Height="23"/>
<Label Content="Units" HorizontalAlignment="Left" Margin="70,310,0,0" VerticalAlignment="Top" Height="23" Width="83"/>
<ComboBox x:Name="cbb_UnitNames" ItemsSource="{Binding Source={StaticResource AlphaSortedUnitNames}}" SelectedValue="{Binding sUnitRequest, Mode=OneWayToSource}" SelectedIndex="0" HorizontalAlignment="Left" Margin="70,333,0,0" VerticalAlignment="Top" Width="178" Height="23"/>
<Button x:Name="btn_Request" Content="Add request >" Command="{Binding cmdAddRequest}" HorizontalAlignment="Left" Margin="158,370,0,0" VerticalAlignment="Top" Width="90" Height="23
"/>
<Label Content="Value" HorizontalAlignment="Left" Margin="10,396,0,0" VerticalAlignment="Top" Height="23" Width="83"/>
<TextBox x:Name="tb_SetValue" PreviewTextInput="NumberValidationTextBox" Text="{Binding sSetValue, Mode=OneWayToSource}" HorizontalAlignment="Left" Height="23" Margin="10,419,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<Button x:Name="btn_TrySetValue" Content="Try set value >" Command="{Binding cmdTrySetValue}" IsEnabled="{Binding bConnected}" HorizontalAlignment="Left" Margin="158,419,0,0" VerticalAlignment="Top" Width="90" Height="23"/>
<Ellipse HorizontalAlignment="Left" Height="14" Margin="251,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="14">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Style.Triggers>
<DataTrigger Binding="{Binding bConnected}" Value="false">
<Setter Property="Fill" Value="#FFFF5030" />
</DataTrigger>
<DataTrigger Binding="{Binding bConnected}" Value="true">
<Setter Property="Fill" Value="#FF50FF30" />
</DataTrigger>
<DataTrigger Binding="{Binding bOddTick}" Value="true">
<!-- Assume bOddTick is true only when bConnected is true-->
<Setter Property="Fill" Value="#FF45E2F4" />
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
<Label Content="Errors" HorizontalAlignment="Left" Margin="10,454,0,0" VerticalAlignment="Top" Height="23" Width="83"/>
<ListBox ItemsSource="{Binding lErrorMessages}" RenderTransformOrigin="0.5,0.5" Width="236" HorizontalAlignment="Left" Margin="10,482,0,10">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Foreground" Value="Red"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel VerticalAlignment="Bottom"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
<CheckBox Content="Use FSX-compatible configuration" IsChecked="{Binding bFSXcompatible, Mode=TwoWay}" HorizontalAlignment="Left" Margin="29,121,0,0" VerticalAlignment="Top" Width="217"/>
</Grid>
</Window>