Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 2362 → Rev 2363

/MKLiveView/v1.0/Source/MainWindow.xaml
1301,15 → 1301,15
<Label x:Name="label4b" Content="Prefix" HorizontalAlignment="Left" Margin="81,6,0,0" Width="35" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditPrefix" HorizontalAlignment="Left" Height="22" Margin="81,24,0,0" VerticalAlignment="Top" Width="29" IsUndoEnabled="False" MaxLines="1" MaxLength="1" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<Label x:Name="label4_Copy16" Content="Latitude" HorizontalAlignment="Left" Margin="115,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditLat" HorizontalAlignment="Left" Height="22" Margin="115,24,0,0" VerticalAlignment="Top" Width="76" IsUndoEnabled="False" MaxLines="1" MaxLength="10" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditLat" HorizontalAlignment="Left" Height="22" Margin="115,24,0,0" VerticalAlignment="Top" Width="76" IsUndoEnabled="False" MaxLines="1" MaxLength="10" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<Label x:Name="label4_Copy17" Content="Longitude" HorizontalAlignment="Left" Margin="196,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditLon" HorizontalAlignment="Left" Height="22" Margin="196,24,0,0" VerticalAlignment="Top" Width="76" IsUndoEnabled="False" MaxLines="1" MaxLength="10" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditLon" HorizontalAlignment="Left" Height="22" Margin="196,24,0,0" VerticalAlignment="Top" Width="76" IsUndoEnabled="False" MaxLines="1" MaxLength="10" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<Label x:Name="label4_Copy18" Content="Altitude" HorizontalAlignment="Left" Margin="277,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditAlt" HorizontalAlignment="Left" Height="22" Margin="277,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="7" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditAlt" HorizontalAlignment="Left" Height="22" Margin="277,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="7" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<Label x:Name="label4_Copy19" Content="Heading" HorizontalAlignment="Left" Margin="324,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditHeading" HorizontalAlignment="Left" Height="22" Margin="324,24,0,0" VerticalAlignment="Top" Width="69" IsUndoEnabled="False" MaxLines="1" MaxLength="7" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEditHeading_KeyDown"/>
<TextBox x:Name="tbWPEditHeading" HorizontalAlignment="Left" Height="22" Margin="324,24,0,0" VerticalAlignment="Top" Width="69" IsUndoEnabled="False" MaxLines="1" MaxLength="7" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<Label x:Name="label4_Copy20" Content="Speed" HorizontalAlignment="Left" Margin="398,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditSpeed" HorizontalAlignment="Left" Height="22" Margin="398,24,0,0" VerticalAlignment="Top" Width="65" IsUndoEnabled="False" MaxLines="1" MaxLength="6" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditSpeed" HorizontalAlignment="Left" Height="22" Margin="398,24,0,0" VerticalAlignment="Top" Width="65" IsUndoEnabled="False" MaxLines="1" MaxLength="6" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<ComboBox x:Name="cbWPEditSpeed" HorizontalAlignment="Left" Height="22" Margin="398,51,0,0" VerticalAlignment="Top" Width="65">
<ComboBoxItem Content="MAX"/>
<ComboBoxItem Content="m/s"/>
1328,19 → 1328,19
<ComboBoxItem Content="degree"/>
</ComboBox>
<Label x:Name="label4_Copy21" Content="Climbrate" HorizontalAlignment="Left" Margin="468,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditClimbrate" HorizontalAlignment="Left" Height="22" Margin="468,24,0,0" VerticalAlignment="Top" Width="61" IsUndoEnabled="False" MaxLines="1" MaxLength="4" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditClimbrate" HorizontalAlignment="Left" Height="22" Margin="468,24,0,0" VerticalAlignment="Top" Width="61" IsUndoEnabled="False" MaxLines="1" MaxLength="4" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<ComboBox x:Name="cbWPEditClimbrate" HorizontalAlignment="Left" Height="22" Margin="468,51,0,0" VerticalAlignment="Top" Width="61">
<ComboBoxItem Content="AUTO"/>
<ComboBoxItem Content="m/s"/>
</ComboBox>
<Label x:Name="label4_Copy22" Content="Radius" HorizontalAlignment="Left" Margin="534,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditRadius" HorizontalAlignment="Left" Height="22" Margin="534,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="3" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditRadius" HorizontalAlignment="Left" Height="22" Margin="534,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="3" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<Label x:Name="label4_Copy23" Content="Holdtime" HorizontalAlignment="Left" Margin="581,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditHoldtime" HorizontalAlignment="Left" Height="22" Margin="581,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="2" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditHoldtime" HorizontalAlignment="Left" Height="22" Margin="581,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="2" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<Label x:Name="label4_Copy24" Content="AutoTrig" HorizontalAlignment="Left" Margin="635,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditAutoTrigger" HorizontalAlignment="Left" Height="22" Margin="635,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="2" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditAutoTrigger" HorizontalAlignment="Left" Height="22" Margin="635,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="2" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<Label x:Name="label4_Copy25" Content="CamAngle" HorizontalAlignment="Left" Margin="688,6,0,0" Width="54" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditCamAngle" HorizontalAlignment="Left" Height="22" Margin="688,24,0,0" VerticalAlignment="Top" Width="69" IsUndoEnabled="False" MaxLines="1" MaxLength="2" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditCamAngle" HorizontalAlignment="Left" Height="22" Margin="688,24,0,0" VerticalAlignment="Top" Width="69" IsUndoEnabled="False" MaxLines="1" MaxLength="2" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<ComboBox x:Name="cbWPEditCamAngle" HorizontalAlignment="Left" Height="22" Margin="688,51,0,0" VerticalAlignment="Top" Width="69">
<ComboBoxItem Content=" - - - " HorizontalContentAlignment="Center"/>
<ComboBoxItem Content="AUTO"/>
1347,7 → 1347,7
<ComboBoxItem Content="degree"/>
</ComboBox>
<Label x:Name="label4_Copy26" Content="Out1Timer" HorizontalAlignment="Left" Margin="762,6,0,0" Width="63" Foreground="White" Padding="0" Height="18" VerticalAlignment="Top"/>
<TextBox x:Name="tbWPEditOut1" HorizontalAlignment="Left" Height="22" Margin="762,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="2" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center"/>
<TextBox x:Name="tbWPEditOut1" HorizontalAlignment="Left" Height="22" Margin="762,24,0,0" VerticalAlignment="Top" Width="42" IsUndoEnabled="False" MaxLines="1" MaxLength="2" Foreground="White" Background="{x:Null}" VerticalContentAlignment="Center" KeyDown="tbWPEdit_KeyDown"/>
<Rectangle HorizontalAlignment="Left" Width="94" Stroke="#FFE4E4E4" StrokeThickness="0.5" Margin="12,0,0,-2" Height="40" VerticalAlignment="Bottom">
<Rectangle.Style>
<Style TargetType="{x:Type Rectangle}">
1369,7 → 1369,7
<Rectangle.Style>
<Style TargetType="{x:Type Rectangle}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=btnEditWPSave}" Value="True">
<DataTrigger Binding="{Binding IsMouseOver, ElementName=btnEditWPDel}" Value="True">
<Setter Property="Fill" Value="{DynamicResource PressedItemBrush}"/>
</DataTrigger>
</Style.Triggers>
/MKLiveView/v1.0/Source/MainWindow.xaml.cs
1898,17 → 1898,9
DataRow dr = dtWaypoints.NewRow();
dr = Waypoints.toDataRow(data, dr);
dtWaypoints.Rows.Add(dr);
Dispatcher.Invoke(() => {
GMapMarker wp = new GMapMarker(new PointLatLng((double)dr[3], (double)dr[4]));
wp.Shape = new CustomMarkerWP(this, wp, (string)dr[2],(int)dr[1]);
wp.Offset = new System.Windows.Point(-11.5, -11.5);
_setMarkerColor(wp, (int)dr[1]);
MainMap.Markers.Add(wp);
});
_createWP(new PointLatLng((double)dr[3], (double)dr[4]), (string)dr[2], (int)dr[1]);
Dispatcher.Invoke(() => dgvWP.Items.Refresh());
Dispatcher.Invoke(() => _iWPIndex = data[1]);
if ((int)dr[1] == 0)
wpList.Add(new PointLatLng((double)dr[3], (double)dr[4]));
if (data[1] == data[0])
{
_bGetWP = false;
2181,11 → 2173,19
}
}
}
 
/// <summary>
/// Wrapper for _clearCopterWPList()
/// necessary, cause it is called by threadnew which does not like return values...
/// </summary>
void clearCopterWPList()
{
_clearCopterWPList();
}
/// <summary>
/// clear the WP list of the copter
/// by sending 'invalid' and index '0'
/// </summary>
/// <returns></returns>
bool _clearCopterWPList()
{
int iTimeout = 0;
2253,7 → 2253,6
Log(LogMsgType.Error, "NOT CONNECTED!");
 
}
 
bool _sendWayPoint(DataRow dr, int index, char command)
{
 
3173,11 → 3172,12
dtWaypoints.Rows.Clear();
_wpEdit = -1;
_clearMapMarkers(typeof(CustomMarkerWP));
_clearMapMarkers(typeof(CustomMarkerWPActive));
wpList.Clear();
if (mRouteWP != null)
MainMap.Markers.Remove(mRouteWP);
if (wpActiveMarker != null)
MainMap.Markers.Remove(wpActiveMarker);
//if (wpActiveMarker != null)
// MainMap.Markers.Remove(wpActiveMarker);
Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m");
 
for (int k = 1; k <= wpnum; k++)
3248,14 → 3248,7
 
dr.ItemArray = o;
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]);
wpMarker.Offset = new System.Windows.Point(-11.5, -11.5);
wpMarker.ZIndex = 100;
_setMarkerColor(wpMarker, (int)o[1]);
MainMap.Markers.Add(wpMarker);
if((int)o[1] == 0)
wpList.Add(new PointLatLng((double)o[3], (double)o[4]));
_createWP(new PointLatLng((double)o[3], (double)o[4]), (string)dr[2], (int)o[1]);
 
Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString());
Dispatcher.Invoke(() => lblWPCount.Content = k.ToString());
3360,7 → 3353,7
mRouteWP = new GMapRoute(wpList, null);
 
if (_bShowWPRoute)
MainMap.Markers.Add(mRouteWP);
Dispatcher.Invoke(() => MainMap.Markers.Add(mRouteWP));
});
 
MapRoute mr = new MapRoute(wpList, "WPList");
3367,6 → 3360,19
Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m"));
 
}
 
GMapMarker _createWP(PointLatLng p, string name, int type)
{
GMapMarker wpMarker = new GMapMarker(p);
wpMarker.Shape = new CustomMarkerWP(this, wpMarker, name, type);
wpMarker.Offset = new System.Windows.Point(-11.5, -11.5);
wpMarker.ZIndex = 100;
_setMarkerColor(wpMarker, type);
Dispatcher.Invoke(() => MainMap.Markers.Add(wpMarker));
if (type == 0)
wpList.Add(p);
return wpMarker;
}
void _setMarkerColor(GMapMarker wpMarker,int iType)
{
Dispatcher.Invoke(() =>
3544,6 → 3550,7
// _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], -1,'s');
//else
// _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], 1,'s');
 
int index = dgvWP.SelectedIndex;
Thread t = new Thread(() => _sendWPList(index));
t.Start();
3688,7 → 3695,78
 
private void btnEditWPSave_Click(object sender, RoutedEventArgs e)
{
if(dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
{
dtWaypoints.Rows[dgvWP.SelectedIndex][1] = cbWPEditType.SelectedIndex;
dtWaypoints.Rows[dgvWP.SelectedIndex][2] = tbWPEditPrefix.Text + (dgvWP.SelectedIndex + 1).ToString();
dtWaypoints.Rows[dgvWP.SelectedIndex][3] = Convert.ToDouble(tbWPEditLat.Text.Replace('.', ','));
dtWaypoints.Rows[dgvWP.SelectedIndex][4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ','));
dtWaypoints.Rows[dgvWP.SelectedIndex][5] = tbWPEditAlt.Text;
switch (cbWPEditHeading.SelectedIndex)
{
case 0:
dtWaypoints.Rows[dgvWP.SelectedIndex][6] = "0";
break;
case 1:
dtWaypoints.Rows[dgvWP.SelectedIndex][6] = "-" + tbWPEditHeading.Text;
break;
case 2:
dtWaypoints.Rows[dgvWP.SelectedIndex][6] = tbWPEditHeading.Text;
break;
}
switch (cbWPEditSpeed.SelectedIndex)
{
case 0:
dtWaypoints.Rows[dgvWP.SelectedIndex][7] = "0";
break;
case 1:
dtWaypoints.Rows[dgvWP.SelectedIndex][7] = (System.Convert.ToDouble(tbWPEditSpeed.Text.Replace('.', ',')) * 10).ToString("0");
break;
case 2:
dtWaypoints.Rows[dgvWP.SelectedIndex][7] = (256 - Convert.ToInt16(tbWPEditSpeed.Text)).ToString();
break;
}
switch (cbWPEditClimbrate.SelectedIndex)
{
case 0:
dtWaypoints.Rows[dgvWP.SelectedIndex][8] = "255";
break;
case 1:
dtWaypoints.Rows[dgvWP.SelectedIndex][8] = (System.Convert.ToDouble(tbWPEditClimbrate.Text.Replace('.',',')) * 10).ToString("0");
break;
}
dtWaypoints.Rows[dgvWP.SelectedIndex][9] = tbWPEditRadius.Text;
dtWaypoints.Rows[dgvWP.SelectedIndex][10] = tbWPEditHoldtime.Text;
dtWaypoints.Rows[dgvWP.SelectedIndex][11] = tbWPEditAutoTrigger.Text;
switch (cbWPEditCamAngle.SelectedIndex)
{
case 0:
dtWaypoints.Rows[dgvWP.SelectedIndex][12] = "0";
break;
case 1:
dtWaypoints.Rows[dgvWP.SelectedIndex][12] = "255";
break;
case 2:
dtWaypoints.Rows[dgvWP.SelectedIndex][12] = tbWPEditCamAngle.Text;
break;
}
dtWaypoints.Rows[dgvWP.SelectedIndex][14] = tbWPEditOut1.Text;
 
_clearMapMarkers(typeof(CustomMarkerWP));
_clearMapMarkers(typeof(CustomMarkerWPActive));
wpList.Clear();
if (mRouteWP != null)
MainMap.Markers.Remove(mRouteWP);
 
for (int k = 0; k < dtWaypoints.Rows.Count; k++)
{
_createWP(new PointLatLng((double)dtWaypoints.Rows[k][3], (double)dtWaypoints.Rows[k][4]), (string)dtWaypoints.Rows[k][2], (int)dtWaypoints.Rows[k][1]);
}
_routeUpdate();
dgvWP.Items.Refresh();
 
}
 
}
private void btnEditWPDel_Click(object sender, RoutedEventArgs e)
{
3700,17 → 3778,77
{
KeyPad.Keypad k = new KeyPad.Keypad(this);
 
//var x = KeyInterop.VirtualKeyFromKey(e.Key);
KeyConverter x = new KeyConverter();
string s = x.ConvertToString(e.Key);
 
if ("1234567890,\b".IndexOf(s) < 0) //general check for valid chars(0-9) and backspace (\b)
e.Handled = true;
else
if ("\b".IndexOf(s) < 0)
if (Convert.ToInt16(((TextBox)sender).Text + s) > 360) //if valid and not backspace, check for upper limit of the resulting number
e.Handled = true;
 
switch (((TextBox)sender).Name)
{
case "tbWPEditLat":
k.Title = "Latitude";
k.LENGTH = 17;
k.MAX = 359.9;
break;
case "tbWPEditLon":
k.Title = "Longitude";
k.LENGTH = 17;
k.MAX = 359.9;
break;
case "tbWPEditAlt":
k.Title = "Altitude";
k.LENGTH = 3;
k.MAX = 254;
k.disableDecimal();
break;
case "tbWPEditHeading":
k.Title = "Heading";
k.LENGTH = 3;
k.MAX = 359;
k.MIN = 1;
k.disableDecimal();
break;
case "tbWPEditSpeed":
k.Title = "Speed";
k.LENGTH = 4;
k.MAX = 24.7;
k.MIN = 0.1;
break;
case "tbWPEditClimbrate":
k.Title = "Climbrate";
k.LENGTH = 4;
k.MAX = 25.4;
k.MIN = 0.1;
break;
case "tbWPEditRadius":
k.Title = "Radius";
k.LENGTH = 3;
k.MAX = 254;
k.disableDecimal();
break;
case "tbWPEditHoldtime":
k.Title = "Holdtime";
k.LENGTH = 3;
k.MAX = 254;
break;
case "tbWPEditAutoTrigger":
k.Title = "Autotrigger";
k.LENGTH = 3;
k.MAX = 254;
k.disableDecimal();
break;
case "tbWPEditCamAngle":
k.Title = "Camera angle";
k.LENGTH = 3;
k.MAX = 254;
k.MIN = 1;
k.disableDecimal();
break;
case "tbWPEditOut1":
k.Title = "OUT1 timer interval";
k.LENGTH = 3;
k.MAX = 254;
k.disableDecimal();
break;
}
k.Result = ((TextBox)sender).Text;
if(k.ShowDialog() == true && k.Result.Length > 0)
((TextBox)sender).Text = k.Result;
}
}