Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 2314 → Rev 2315

/MKLiveView/v1.0/Source/MainWindow.xaml
951,14 → 951,14
<Button x:Name="btnOSDEnter" Content="" HorizontalAlignment="Left" Height="34" Margin="87,90,0,0" VerticalAlignment="Top" Width="52" Click="btnOSDEnter_Click"/>
<Button x:Name="btnOSDLeave" Content="" HorizontalAlignment="Left" Height="34" Margin="144,90,0,0" VerticalAlignment="Top" Width="52" Click="btnOSDLeave_Click"/>
</Grid>
<Grid x:Name="GridWP" Margin="23,36,25,0" Background="#7F000000" Height="456" VerticalAlignment="Top">
<Grid x:Name="GridWP" Margin="23,36,25,0" Background="#7F000000" Height="472" VerticalAlignment="Top">
<Button x:Name="btnGetWPList" Content="" HorizontalAlignment="Left" Height="39" Margin="10,362,0,0" VerticalAlignment="Top" Width="78" Click="btnGetWP_Click" ToolTip="Download WP-list from copter" BorderBrush="#FFBDBDBD">
<Button.Background>
<ImageBrush ImageSource="Images/FromCopterToPc.png" Stretch="Uniform"/>
</Button.Background>
</Button>
<Label x:Name="label4" Content="Items" HorizontalAlignment="Right" Margin="0,361,5,0" VerticalAlignment="Top" Width="80" Foreground="White"/>
<Label x:Name="lblWPCount" Content="##" HorizontalAlignment="Right" Margin="0,362,23,0" VerticalAlignment="Top" Width="28" Foreground="White"/>
<Label x:Name="label4" Content="Items" HorizontalAlignment="Right" Margin="0,356,5,0" VerticalAlignment="Top" Width="62" Foreground="White"/>
<Label x:Name="lblWPCount" Content="##" HorizontalAlignment="Right" Margin="0,357,5,0" VerticalAlignment="Top" Width="28" Foreground="White"/>
<Label x:Name="label4_Copy" Content="WP Index" HorizontalAlignment="Left" Margin="94,194,0,0" VerticalAlignment="Top" Width="80" Foreground="White" Visibility="Hidden"/>
<Label x:Name="lblWPIndex" Content="##" HorizontalAlignment="Left" Margin="170,194,0,0" VerticalAlignment="Top" Width="28" Foreground="White" Visibility="Hidden"/>
<Button x:Name="btnSendWPList" Content="" HorizontalAlignment="Left" Height="39" Margin="96,362,0,0" VerticalAlignment="Top" Width="78" ToolTip="Upload WP-list to copter" BorderBrush="#FFBDBDBD" Click="btnSendWPList_Click">
966,7 → 966,7
<ImageBrush ImageSource="Images/FromPcToCopter.png" Stretch="Uniform"/>
</Button.Background>
</Button>
<Button x:Name="btnLoadWPLFile" Content="" HorizontalAlignment="Left" Height="43" Margin="10,406,0,0" VerticalAlignment="Top" Width="42" ToolTip="load wp-list from file" BorderBrush="#FFBDBDBD" HorizontalContentAlignment="Center" Click="btnLoadWPLFile_Click">
<Button x:Name="btnLoadWPLFile" Content="" HorizontalAlignment="Left" Height="43" Margin="10,419,0,0" VerticalAlignment="Top" Width="42" ToolTip="load wp-list from file" BorderBrush="#FFBDBDBD" HorizontalContentAlignment="Center" Click="btnLoadWPLFile_Click">
<Button.Background>
<ImageBrush ImageSource="Images/LoadFile.png" Stretch="Uniform"/>
</Button.Background>
989,6 → 989,30
<DataGridTextColumn Header="Out1Timer" Binding="{Binding Path=Out1Timer}"/>
</DataGrid.Columns>
</DataGrid>
<ComboBox x:Name="comboBoxWPColor" HorizontalAlignment="Left" Height="40" Margin="656,426,0,0" VerticalAlignment="Top" Width="95" SelectedIndex="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="16" DropDownClosed="comboBoxWPColor_DropDownClosed">
<ComboBoxItem Content="red"/>
<ComboBoxItem Content="green"/>
<ComboBoxItem Content="blue"/>
<ComboBoxItem Content="yellow"/>
<ComboBoxItem Content="pink"/>
</ComboBox>
<Label x:Name="label4_Copy1" Content="WP color" HorizontalAlignment="Right" Margin="0,400,223,0" VerticalAlignment="Top" Width="80" Foreground="White"/>
<ComboBox x:Name="comboBoxPOIColor" HorizontalAlignment="Left" Height="40" Margin="756,426,0,0" VerticalAlignment="Top" Width="95" SelectedIndex="4" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="16" DropDownClosed="comboBoxPOIColor_DropDownClosed">
<ComboBoxItem Content="red"/>
<ComboBoxItem Content="green"/>
<ComboBoxItem Content="blue"/>
<ComboBoxItem Content="yellow"/>
<ComboBoxItem Content="pink"/>
</ComboBox>
<Label x:Name="label4_Copy2" Content="POI color" HorizontalAlignment="Right" Margin="0,400,123,0" VerticalAlignment="Top" Width="80" Foreground="White"/>
<ComboBox x:Name="comboBoxFSColor" HorizontalAlignment="Left" Height="40" Margin="856,426,0,0" VerticalAlignment="Top" Width="95" SelectedIndex="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="16" DropDownClosed="comboBoxFSColor_DropDownClosed">
<ComboBoxItem Content="red"/>
<ComboBoxItem Content="green"/>
<ComboBoxItem Content="blue"/>
<ComboBoxItem Content="yellow"/>
<ComboBoxItem Content="pink"/>
</ComboBox>
<Label x:Name="label4_Copy3" Content="failsave color" HorizontalAlignment="Right" Margin="0,400,23,0" VerticalAlignment="Top" Width="80" Foreground="White"/>
</Grid>
<Grid x:Name="GridSideBarR" Background="#66000000" Margin="0,36,0,0" HorizontalAlignment="Right" Width="23">
<Label x:Name="labelMotordata" Content="Motors" Padding="0" RenderTransformOrigin="0.5,0.5" Margin="-25,233,-26,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Stretch" MouseDown="labelMotorData_MouseDown" FontSize="14" HorizontalAlignment="Left" Width="74" Height="22" VerticalAlignment="Top">
/MKLiveView/v1.0/Source/MainWindow.xaml.cs
260,7 → 260,7
/// <summary>
/// datatable for motordata (current,temp)
/// </summary>
DataTable dtMotors1 = new DataTable();
DataTable dtMotors = new DataTable();
 
DataTable dtWaypoints = new DataTable();
static volatile int _iWPCount = -1;
350,13 → 350,13
/// </summary>
void _dataTablesInit()
{
dtMotors1.Columns.Add("#");
dtMotors.Columns.Add("#");
if (Thread.CurrentThread.CurrentUICulture.Name == "de-DE")
dtMotors1.Columns.Add("Strom");
dtMotors.Columns.Add("Strom");
else
dtMotors1.Columns.Add("Current");
dtMotors1.Columns.Add("Temp");
dgvMotors1.DataContext = dtMotors1.DefaultView;
dtMotors.Columns.Add("Current");
dtMotors.Columns.Add("Temp");
dgvMotors1.DataContext = dtMotors.DefaultView;
_initDTMotors();
 
Setter setter = new Setter(ContentControl.PaddingProperty, new Thickness(5,0,5,0));
368,10 → 368,10
style.Setters.Add(setter);
 
dtWaypoints.Columns.Add("Index",typeof(int));
dtWaypoints.Columns.Add("Type",typeof(string));
dtWaypoints.Columns.Add("Type", typeof(int));
dtWaypoints.Columns.Add("Name",typeof(string));
dtWaypoints.Columns.Add("Latitude",typeof(string));
dtWaypoints.Columns.Add("Longitude",typeof(string));
dtWaypoints.Columns.Add("Latitude",typeof(double));
dtWaypoints.Columns.Add("Longitude",typeof(double));
dtWaypoints.Columns.Add("Altitude",typeof(string));
dtWaypoints.Columns.Add("Heading",typeof(string));
dtWaypoints.Columns.Add("Speed",typeof(string));
391,7 → 391,7
 
}
/// <summary>
/// initialize the datatable dtMotors1 for motor values
/// initialize the datatable dtMotors for motor values
/// DataGridView dgvMotors1 is bound to dtMotors1
/// </summary>
void _initDTMotors()
398,12 → 398,12
{
for (int i = 0; i < 12; i++)
{
if (dtMotors1.Rows.Count < 12)
dtMotors1.Rows.Add((i + 1).ToString(), "NA", "NA");
if (dtMotors.Rows.Count < 12)
dtMotors.Rows.Add((i + 1).ToString(), "NA", "NA");
else
{
dtMotors1.Rows[i].SetField(1, "NA");
dtMotors1.Rows[i].SetField(2, "NA");
dtMotors.Rows[i].SetField(1, "NA");
dtMotors.Rows[i].SetField(2, "NA");
}
}
}
1508,13 → 1508,13
{
if (bAvailable)
{
dtMotors1.Rows[data[i]].SetField(1, ((double)data[i + 1] / (double)10).ToString("0.0 A"));
dtMotors1.Rows[data[i]].SetField(2, data[i + 2].ToString("0 °C"));
dtMotors.Rows[data[i]].SetField(1, ((double)data[i + 1] / (double)10).ToString("0.0 A"));
dtMotors.Rows[data[i]].SetField(2, data[i + 2].ToString("0 °C"));
}
else
{
dtMotors1.Rows[data[i]].SetField(1, "NA");
dtMotors1.Rows[data[i]].SetField(2, "NA");
dtMotors.Rows[data[i]].SetField(1, "NA");
dtMotors.Rows[data[i]].SetField(2, "NA");
}
}
//if (data[i] > 3 && data[i] < 8)
1769,10 → 1769,21
if (_bGetWP)
{
if (data[1] == 1)
{
dtWaypoints.Rows.Clear();
foreach (GMapMarker p in MainMap.Markers)
{
if (p.Shape.GetType() == typeof(CustomMarkerWP))
MainMap.Markers.Remove(p);
}
}
DataRow dr = dtWaypoints.NewRow();
dr = Waypoints.toDataRow(data, dr);
dtWaypoints.Rows.Add(dr);
GMapMarker wp = new GMapMarker(new PointLatLng((double)dr[3], (double)dr[4]));
wp.Shape = new CustomMarkerWP(this, wp, (string)dr[2],(int)dr[1]);
_setMarkerColor(wp, (int)dr[1]);
MainMap.Markers.Add(wp);
Dispatcher.Invoke(() => dgvWP.Items.Refresh());
Dispatcher.Invoke(() => _iWPIndex = data[1]);
if (data[1] == data[0])
2005,22 → 2016,12
}
void _getWP()
{
//if (_iWP > 0)
//{
// _getWPList();
//}
//else
//{
// if (_iWP == -1)
// {
_bGetWPCount = true;
_getpWP(1);
_getpWP(1); //get the itemscount of wp
while (_bGetWPCount)
Thread.Sleep(100);
if (_iWPCount > 0)
_getWPList();
// }
//}
}
void _getWPList()
{
2558,6 → 2559,7
}
}
 
#region WP
void _readWPLFile()
{
Microsoft.Win32.OpenFileDialog fd = new Microsoft.Win32.OpenFileDialog();
2591,6 → 2593,14
NumberFormatInfo nfi = new NumberFormatInfo();
nfi.NumberDecimalSeparator = ".";
dtWaypoints.Rows.Clear();
for(int k = 0; k < MainMap.Markers.Count;)
{
GMapMarker p = MainMap.Markers[k];
if (p.Shape.GetType() == typeof(CustomMarkerWP))
MainMap.Markers.Remove(p);
else
k++;
}
for (int k = 1; k <= wpnum; k++)
{
DataRow dr = dtWaypoints.NewRow();
2602,7 → 2612,7
i++;
sVal = ini.IniReadValue(wp, "Type");
if (sVal != "")
o[i] = Convert.ToInt16(sVal) -1;
o[i] = Convert.ToInt16(sVal) - 1;
i++;
sVal = ini.IniReadValue(wp, "Prefix");
if (sVal != "")
2626,7 → 2636,7
i++;
sVal = ini.IniReadValue(wp, "Speed");
if (sVal != "")
o[i] =Convert.ToInt16(sVal);
o[i] = Convert.ToInt16(sVal);
i++;
sVal = ini.IniReadValue(wp, "ClimbRate");
if (sVal != "")
2657,8 → 2667,12
o[i] = "New";
 
dr.ItemArray = o;
// dtWaypoints.Rows.Add(dr);
dtWaypoints.Rows.Add(dr);
GMapMarker wpMarker = new GMapMarker(new PointLatLng((double)o[3], (double)o[4]));
wpMarker.Shape = new CustomMarkerWP(this, wpMarker, (string)dr[2], (int)o[1]);
_setMarkerColor(wpMarker, (int)o[1]);
MainMap.Markers.Add(wpMarker);
 
Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString());
Dispatcher.Invoke(() => lblWPCount.Content = k.ToString());
Dispatcher.Invoke(() => dgvWP.Items.Refresh());
2677,27 → 2691,121
 
}
}
void _setMarkerColor(GMapMarker wpMarker,int iType)
{
Dispatcher.Invoke(() =>
{
switch (iType)
{
case 0:
if (comboBoxWPColor.SelectionBoxItem != null)
{
string s = comboBoxWPColor.SelectionBoxItem.ToString();
((CustomMarkerWP)(wpMarker.Shape)).setColor(s);
}
else
((CustomMarkerWP)(wpMarker.Shape)).setColor("red");
break;
case 1:
if (comboBoxPOIColor.SelectionBoxItem != null)
{
string s = comboBoxPOIColor.SelectionBoxItem.ToString();
((CustomMarkerWP)(wpMarker.Shape)).setColor(s);
}
else
((CustomMarkerWP)(wpMarker.Shape)).setColor("red");
break;
case 2:
if (comboBoxFSColor.SelectionBoxItem != null)
{
string s = comboBoxFSColor.SelectionBoxItem.ToString();
((CustomMarkerWP)(wpMarker.Shape)).setColor(s);
}
else
((CustomMarkerWP)(wpMarker.Shape)).setColor("red");
break;
default:
((CustomMarkerWP)(wpMarker.Shape)).setColor("red");
break;
}
});
 
private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e)
}
private void comboBoxWPColor_DropDownClosed(object sender, EventArgs e)
{
_readWPLFile();
Dispatcher.Invoke(() =>
{
if (comboBoxWPColor.SelectionBoxItem != null)
{
for (int k = 0; k < MainMap.Markers.Count;k++)
{
GMapMarker p = MainMap.Markers[k];
if (p.Shape.GetType() == typeof(CustomMarkerWP))
{
if (((CustomMarkerWP)p.Shape).WPType == 0)
{
string s = comboBoxWPColor.SelectionBoxItem.ToString();
((CustomMarkerWP)(p.Shape)).setColor(s);
}
}
}
}
});
}
#endregion functions
}
public class BooleanToVisibilityConverter : IValueConverter
{
private void comboBoxPOIColor_DropDownClosed(object sender, EventArgs e)
{
Dispatcher.Invoke(() =>
{
if (comboBoxPOIColor.SelectionBoxItem != null)
{
for (int k = 0; k < MainMap.Markers.Count; k++)
{
GMapMarker p = MainMap.Markers[k];
if (p.Shape.GetType() == typeof(CustomMarkerWP))
{
if (((CustomMarkerWP)p.Shape).WPType == 1)
{
string s = comboBoxPOIColor.SelectionBoxItem.ToString();
((CustomMarkerWP)(p.Shape)).setColor(s);
}
}
}
}
});
 
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
}
private void comboBoxFSColor_DropDownClosed(object sender, EventArgs e)
{
return (bool)value ? Visibility.Visible : Visibility.Collapsed;
Dispatcher.Invoke(() =>
{
if (comboBoxFSColor.SelectionBoxItem != null)
{
for (int k = 0; k < MainMap.Markers.Count; k++)
{
GMapMarker p = MainMap.Markers[k];
if (p.Shape.GetType() == typeof(CustomMarkerWP))
{
if (((CustomMarkerWP)p.Shape).WPType == 2)
{
string s = comboBoxFSColor.SelectionBoxItem.ToString();
((CustomMarkerWP)(p.Shape)).setColor(s);
}
}
}
}
});
}
 
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e)
{
throw new NotImplementedException();
_readWPLFile();
}
#endregion WP
 
#endregion functions
}
 
/// <summary>
/// formats the wp datatable values for display in datagrid - this is bound in the datagrid as a converter
/// </summary>
public class waypointsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)