Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 2424 → Rev 2425

/MKLiveView/v1.0/Source/MainWindow.xaml
594,7 → 594,7
</Label.Style>
</Label>
</Grid>
<Grid x:Name="GridData" Background="#7F000000" HorizontalAlignment="Left" Width="204" Margin="23,36,0,0" Visibility="Collapsed" >
<Grid x:Name="GridData" Background="#7F000000" HorizontalAlignment="Left" Width="204" Margin="23,36,0,0" >
<TabControl x:Name="tabControl" HorizontalAlignment="Left" Height="619" VerticalAlignment="Top" Width="200" Background="{x:Null}" Margin="2,0,0,0">
<TabItem Header="Analog">
<Grid>
679,7 → 679,7
 
</Grid>
</TabItem>
<TabItem Header="Serial" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top" Width="54" Margin="-1,0,0,0">
<TabItem Header="Serial">
<Grid>
<GroupBox x:Name="groupBox3" Header="Channel 1" HorizontalAlignment="Left" Height="188" VerticalAlignment="Top" Width="194" Foreground="White" BorderThickness="0.5">
<Grid Margin="0,0,-2,0.04">
838,6 → 838,21
 
</Grid>
</TabItem>
<TabItem Header="License">
<Grid>
<TextBlock x:Name="tbDataLicenseUser" HorizontalAlignment="Left" Height="44" Margin="10,60,0,0" TextWrapping="Wrap" Text="NA" VerticalAlignment="Top" Width="184" Foreground="White" FontSize="16"/>
<TextBlock x:Name="tbDataLicenseMail" HorizontalAlignment="Left" Height="23" Margin="10,128,0,0" TextWrapping="Wrap" Text="NA" VerticalAlignment="Top" Width="184" Foreground="White" FontSize="16"/>
<Label x:Name="label6_Copy25" Content="User:" HorizontalAlignment="Left" Margin="2,38,0,0" VerticalAlignment="Top" Background="{x:Null}" Foreground="White" FontSize="14"/>
<Label x:Name="label6_Copy26" Content="Mail:" HorizontalAlignment="Left" Margin="2,104,0,0" VerticalAlignment="Top" Background="{x:Null}" Foreground="White" FontSize="14"/>
<TextBlock x:Name="tbDataLicenseFeature" HorizontalAlignment="Left" Height="44" Margin="10,175,0,0" TextWrapping="Wrap" Text="NA" VerticalAlignment="Top" Width="184" Foreground="White" FontSize="16"/>
<Label x:Name="label6_Copy27" Content="Feature:" HorizontalAlignment="Left" Margin="2,151,0,0" VerticalAlignment="Top" Background="{x:Null}" Foreground="White" FontSize="14"/>
<TextBlock x:Name="tbDataLicenseExpire" HorizontalAlignment="Left" Height="23" Margin="10,253,0,0" TextWrapping="Wrap" Text="NA" VerticalAlignment="Top" Width="184" Foreground="White" FontSize="16"/>
<TextBlock x:Name="tbDataLicenseLicense" HorizontalAlignment="Left" Height="23" Margin="10,304,0,0" TextWrapping="Wrap" Text="NA" VerticalAlignment="Top" Width="174" Foreground="White" FontSize="16"/>
<Label x:Name="label6_Copy28" Content="Expire:" HorizontalAlignment="Left" Margin="2,224,0,0" VerticalAlignment="Top" Background="{x:Null}" Foreground="White" FontSize="14"/>
<Label x:Name="label6_Copy29" Content="License:" HorizontalAlignment="Left" Margin="2,281,0,0" VerticalAlignment="Top" Background="{x:Null}" Foreground="White" FontSize="14"/>
 
</Grid>
</TabItem>
</TabControl>
</Grid>
<Grid x:Name="GridSettings" Background="#7B000000" HorizontalAlignment="Left" Width="233" Margin="23,36,0,0" Visibility="Collapsed">
1228,7 → 1243,7
</LinearGradientBrush>
</Label.Background>
</Label>
<Grid x:Name="GridWP" Margin="23,36,25,0" Background="#7F000000" Height="526" VerticalAlignment="Top">
<Grid x:Name="GridWP" Margin="23,36,25,0" Background="#7F000000" Height="526" VerticalAlignment="Top" Visibility="Collapsed">
<Label x:Name="label4" Content="points" HorizontalAlignment="Right" Margin="0,480,51,0" VerticalAlignment="Top" Width="53" Foreground="White" Height="19" HorizontalContentAlignment="Right" Padding="0" VerticalContentAlignment="Center" FontSize="13" Visibility="Hidden"/>
<Label x:Name="lblWPCount" Content="##" HorizontalAlignment="Right" Margin="0,482,19,0" VerticalAlignment="Top" Width="26" Foreground="White" HorizontalContentAlignment="Right" Padding="0" Height="16" FontSize="13" Visibility="Hidden"/>
<Label x:Name="label4_Copy" Content="WP Index" HorizontalAlignment="Left" Margin="94,194,0,0" VerticalAlignment="Top" Width="80" Foreground="White" Visibility="Hidden"/>
1500,16 → 1515,16
</Style>
</Rectangle.Style>
</Rectangle>
<ed:LineArrow Fill="Black" Height="0" Stroke="White" StrokeThickness="4" Width="25" RenderTransformOrigin="0.5,0.5" Margin="748,93,67,17">
<ed:LineArrow.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</ed:LineArrow.RenderTransform>
</ed:LineArrow>
<ed:LineArrow Fill="Black" Height="0" Stroke="White" StrokeThickness="4" Width="25" RenderTransformOrigin="0.5,0.5" Margin="748,93,67,17">
<ed:LineArrow.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</ed:LineArrow.RenderTransform>
</ed:LineArrow>
<Button x:Name="btnWPEditmoveDown" HorizontalAlignment="Left" Height="34" Margin="737,0,0,-2" VerticalAlignment="Bottom" Width="44" ToolTip="move WP down in list (index +1)" BorderBrush="#FFBDBDBD" Style="{DynamicResource ButtonWithoutEffectStyle}" Click="btnWPEditmoveDown_Click" Padding="14,1" Background="#00000000">
</Button>
<Label x:Name="lblWPEditIndex" Content="##" HorizontalAlignment="Left" Height="23" Margin="-2,22,0,0" VerticalAlignment="Top" Width="29" Foreground="White" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>
/MKLiveView/v1.0/Source/MainWindow.xaml.cs
49,6 → 49,7
GMapRoute mRouteWP;
GMapMarker wpActiveMarker;
List<PointLatLng> wpList = new List<PointLatLng>();
List<int> wpOffset = new List<int>();
Circle cWPBound = new Circle();
double dWPMaxRange = 0;
 
1929,25 → 1930,26
Dispatcher.Invoke((Action)(() => lblWPStatusIndexNC.Content = data[48].ToString()));
if(data[48] > 0 && _wpIndex != data[48] -1 && wpList.Count >= data[48] -1)
{
_setActiveWP(data[48]-1);
_setActiveWP(data[48]- 1);
if((data[67] & 2) == 2)
Dispatcher.Invoke(() => {
DataGridRow row;
if (_wpIndex > -1)
{
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(wpOffset[_wpIndex]);
row.Background = new SolidColorBrush(Colors.Transparent);
row.BorderBrush = new SolidColorBrush(Colors.Transparent);
row.BorderThickness = new Thickness(0);
}
 
_wpIndex = data[48] - 1;
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(wpOffset[_wpIndex]);
row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 255, 100));
row.BorderBrush = new SolidColorBrush(Colors.SpringGreen);
row.BorderThickness = new Thickness(2);
dgvWP.UpdateLayout();
});
_wpIndex = data[48]-1;
_wpIndex = data[48]- 1;
}
else
{
1959,7 → 1961,7
DataGridRow row;
if (_wpIndex > -1 && data[48] == 0 && wpList.Count > _wpIndex)
{
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(wpOffset[_wpIndex]);
row.Background = new SolidColorBrush(Colors.Transparent);
row.BorderBrush = new SolidColorBrush(Colors.Transparent);
row.BorderThickness = new Thickness(0);
2161,12 → 2163,13
lblWPRouteDistance.Content = "0 m";
dtWaypoints.Rows.Clear();
_wpEdit = -1;_wpIndex = -1;
wpOffset.Clear();
});
}
DataRow dr = dtWaypoints.NewRow();
dr = Waypoints.toDataRow(data, dr);
dtWaypoints.Rows.Add(dr);
_createWP(new PointLatLng((double)dr[3], (double)dr[4]), (string)dr[2], (int)dr[1]);
_createWP(new PointLatLng((double)dr[3], (double)dr[4]), (string)dr[2], (int)dr[1],(int)data[1]-1);
Dispatcher.Invoke(() => dgvWP.Items.Refresh());
Dispatcher.Invoke(() => _iWPIndex = data[1]);
if (data[1] == data[0])
3487,6 → 3490,7
nfi.NumberDecimalSeparator = ".";
dtWaypoints.Rows.Clear();
_wpEdit = -1;_wpIndex = -1;
wpOffset.Clear();
_clearMapMarkers(typeof(CustomMarkerWP));
_clearMapMarkers(typeof(CustomMarkerWPActive));
wpList.Clear();
3564,7 → 3568,7
 
dr.ItemArray = o;
dtWaypoints.Rows.Add(dr);
_createWP(new PointLatLng((double)o[3], (double)o[4]), (string)dr[2], (int)o[1]);
_createWP(new PointLatLng((double)o[3], (double)o[4]), (string)dr[2], (int)o[1], (int)o[0]-1);
 
Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString());
Dispatcher.Invoke(() => lblWPCount.Content = k.ToString());
3678,7 → 3682,7
MapRoute mr = new MapRoute(wpList, "WPList");
Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m"));
}
GMapMarker _createWP(PointLatLng p, string name, int type)
GMapMarker _createWP(PointLatLng p, string name, int type, int index)
{
GMapMarker wpMarker = new GMapMarker(p);
Dispatcher.Invoke(()=>
3690,7 → 3694,10
_setMarkerColor(wpMarker, type);
MainMap.Markers.Add(wpMarker);
if (type == 0 || type == 3)
{
wpList.Add(p);
wpOffset.Add(index);
}
((CustomMarkerWP)wpMarker.Shape).positionChanged += _updateDTWPPos;
((CustomMarkerWP)wpMarker.Shape).newPosition += _updateDTWPPosFin;
((CustomMarkerWP)wpMarker.Shape).mouseCaptured += _WPMouseCaptured;
3745,7 → 3752,45
}
 
}
/// <summary>
/// find the index of of a wp from datatable in the waypointlist wpList
/// </summary>
/// <param name="dtIndex">the index of wp in datatable (0-based)</param>
/// <returns></returns>
int _getWPIndexfromList(int dtIndex)
{
if ((int)dtWaypoints.Rows[dtIndex][1] == 0 || (int)dtWaypoints.Rows[dtIndex][1] == 3)
{
GMapMarker wp = _findWPMarker((string)dtWaypoints.Rows[dtIndex][2]);
if (wp != null)
return wpList.IndexOf(wp.Position);
}
return -1;
}
/// <summary>
/// find the index of of a wp from datatable in the waypointlist wpList
/// </summary>
/// <param name="name">the name of the wp</param>
/// <returns></returns>
int _getWPIndexfromList(string name)
{
GMapMarker wp = _findWPMarker(name);
if ((wp != null && wp.Shape != null) && ((CustomMarkerWP)wp.Shape).WPType == 0 | ((CustomMarkerWP)wp.Shape).WPType == 3)
return wpList.IndexOf(wp.Position);
else
return -1;
}
int _getWPListOffset(int index)
{
int k = 0;
for(int i = 0; i < wpOffset.Count;i++)
{
if (wpOffset[i] <= index)
k++;
}
 
return k;
}
void _setMarkerColor(GMapMarker wpMarker,int iType)
{
if(wpMarker != null)
3921,6 → 3966,7
dtWaypoints.Rows.Clear();
_wpEdit = -1;
_wpIndex = -1;
wpOffset.Clear();
Dispatcher.Invoke(() => dgvWP.Items.Refresh());
Dispatcher.Invoke(() => lblWPIndex.Content = 0);
Dispatcher.Invoke(() => lblWPCount.Content = 0);
4173,6 → 4219,18
if (dgvWP.SelectedIndex > 0 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
{
int index = dgvWP.SelectedIndex;
if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index - 1][1] == 0 | (int)dtWaypoints.Rows[index - 1][1] == 3))// && wpList.Count > index)
{
PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]);
int wpListIndex = wpList.IndexOf(x);
if (wpListIndex > 0)
{
wpList.RemoveAt(wpListIndex);
wpList.Insert(wpListIndex - 1, x);
MainMap.Markers.Remove(mRouteWP);
_routeUpdate();
}
}
DataRow dr = dtWaypoints.Rows[index];
DataRow newRow = dtWaypoints.NewRow();
newRow.ItemArray = dr.ItemArray;
4190,18 → 4248,26
dgvWP.Items.Refresh();
dgvWP.SelectedIndex = index - 1;
_dgvWPselectEditRow();
if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index - 1][1] == 0 | (int)dtWaypoints.Rows[index - 1][1] == 3))// && wpList.Count > index)
if (wpOffset.Contains(index)) // calculating offset for wpList (index is 0-based - offset starts with index 1)
{
PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]);
int wpListIndex = wpList.IndexOf(x);
if (wpListIndex > 0)
int iOffset = wpOffset.IndexOf(index);
if (iOffset > 0) // if not first element
{
wpList.RemoveAt(wpListIndex);
wpList.Insert(wpListIndex - 1, x);
MainMap.Markers.Remove(mRouteWP);
_routeUpdate();
if (wpOffset[iOffset - 1] < index-1) //if previous element is not immediately before actual offset
wpOffset[iOffset] = index-1; //then decrease offset value by one
}
else
wpOffset[iOffset] = index-1; //if first element, decrease offset by one
}
else //selected line is POI
{
if (wpOffset.Contains(index - 1)) // if next point is WP
{
int iOffset = wpOffset.IndexOf(index - 1);
wpOffset[iOffset] = index; //decrease linenumber of following WP
}
}
 
}
}
 
4210,6 → 4276,21
if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count - 1)
{
int index = dgvWP.SelectedIndex;
if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index+1][1] == 0 | (int)dtWaypoints.Rows[index+1][1] == 3))// && wpList.Count > index)
{
PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]);
int wpListIndex = wpList.IndexOf(x);
if (wpListIndex > -1)
{
wpList.RemoveAt(wpListIndex);
if (wpList.Count > wpListIndex)
wpList.Insert(wpListIndex + 1, x);
else
wpList.Add(x);
MainMap.Markers.Remove(mRouteWP);
_routeUpdate();
}
}
DataRow dr = dtWaypoints.Rows[index];
DataRow newRow = dtWaypoints.NewRow();
newRow.ItemArray = dr.ItemArray;
4227,21 → 4308,25
dgvWP.Items.Refresh();
dgvWP.SelectedIndex = index + 1;
_dgvWPselectEditRow();
if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index+1][1] == 0 | (int)dtWaypoints.Rows[index+1][1] == 3))// && wpList.Count > index)
if(wpOffset.Contains(index)) // If selected line is WP
{
PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]);
int wpListIndex = wpList.IndexOf(x);
if (wpListIndex > -1)
int iOffset = wpOffset.IndexOf(index);
if(iOffset < wpOffset.Count -1) // if not last element
{
wpList.RemoveAt(wpListIndex);
if (wpList.Count > wpListIndex)
wpList.Insert(wpListIndex + 1, x);
else
wpList.Add(x);
MainMap.Markers.Remove(mRouteWP);
_routeUpdate();
if (wpOffset[iOffset + 1] > index + 1) //if next element is not immediately after actual offset
wpOffset[iOffset] = index + 1; //then increase offset value by one
}
else
wpOffset[iOffset] = index + 1; //if last element increase offset by one
}
else //selected line is POI
{
if (wpOffset.Contains(index + 1)) // if next point is WP
{
int iOffset = wpOffset.IndexOf(index + 1);
wpOffset[iOffset] = index; //decrease linenumber of following WP
}
}
}
 
}
4260,10 → 4345,13
dtWaypoints.Rows[dgvWP.SelectedIndex][4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ','));
if (i > -1)
{
if((int)dtWaypoints.Rows[dgvWP.SelectedIndex][1] == 0 || (int)dtWaypoints.Rows[dgvWP.SelectedIndex][1] == 3)
if ((int)dtWaypoints.Rows[dgvWP.SelectedIndex][1] == 0 || (int)dtWaypoints.Rows[dgvWP.SelectedIndex][1] == 3)
wpList[i] = (new PointLatLng((double)dtWaypoints.Rows[dgvWP.SelectedIndex][3], (double)dtWaypoints.Rows[dgvWP.SelectedIndex][4]));
else
{
wpList.Remove(pOld);
wpOffset.Remove(wpOffset[i]);
}
}
else
{
4271,9 → 4359,14
{
int found = 0;
for (int k = 0; k < dgvWP.SelectedIndex; k++)
if ((int)dtWaypoints.Rows[k][1] == 0)
{
if ((int)dtWaypoints.Rows[k][1] == 0 || (int)dtWaypoints.Rows[k][1] == 3)
{
found++;
}
}
wpList.Insert(found, new PointLatLng((double)dtWaypoints.Rows[dgvWP.SelectedIndex][3], (double)dtWaypoints.Rows[dgvWP.SelectedIndex][4]));
wpOffset.Insert(found, dgvWP.SelectedIndex);
}
}
dtWaypoints.Rows[dgvWP.SelectedIndex][5] = tbWPEditAlt.Text;
4363,6 → 4456,8
}
if ((int)dtWaypoints.Rows[index][1] == 0 || (int)dtWaypoints.Rows[index][1] == 3)
wpList.Remove(new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]));
else
wpOffset.Remove((int)dtWaypoints.Rows[index][0] + 1);
_clearWPMarker((string)dtWaypoints.Rows[index][2]);
if (wpActiveMarker != null)
MainMap.Markers.Remove(wpActiveMarker);
4525,7 → 4620,7
o[15] = "0";
 
dtWaypoints.Rows.Add(o);
_createWP(new PointLatLng((double)o[3], (double)o[4]), (string)o[2], (int)o[1]);
_createWP(new PointLatLng((double)o[3], (double)o[4]), (string)o[2], (int)o[1],(int)o[0]-1);
Dispatcher.Invoke(() => lblWPCount.Content = o[0].ToString());
if (mRouteWP != null)
MainMap.Markers.Remove(mRouteWP);
4631,6 → 4726,12
}
}
}
 
private void Grid_TouchDown(object sender, TouchEventArgs e)
{
 
}
 
private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e)
{
_loadGPXLog();
4713,7 → 4814,8
#endregion GPX
#endregion functions
}
/// <summary>
 
/// <summary>
/// formats the wp datatable values for display in datagrid - this is bound in the datagrid as a converter
/// </summary>
public class waypointsConverter : IValueConverter
4760,7 → 4862,6
throw new NotImplementedException();
}
}
 
public class IniFile
{
public string path;
4815,7 → 4916,6
 
}
}
 
/// <summary>
/// Selected Win AI Function Calls
/// </summary>