Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 2294 → Rev 2295

/MKLiveView/v1.0/Source/MainWindow.xaml
628,8 → 628,8
</Style>
</Label.Style>
</Label>
<Slider x:Name="UIScaleSlider" HorizontalAlignment="Left" Height="29" Margin="4,28,0,0" VerticalAlignment="Top" Width="206" Maximum="2" Minimum="0.7" Value="1" FontSize="20" Style="{DynamicResource TouchSliderStyle}" />
<Slider x:Name="UIScaleTopSlider" HorizontalAlignment="Left" Height="16" Margin="9,74,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5" ValueChanged="UIScaleTopSlider_ValueChanged"/>
<Slider x:Name="UIScaleSlider" HorizontalAlignment="Left" Height="29" Margin="4,28,0,0" VerticalAlignment="Top" Width="206" Maximum="2" Minimum="0.7" Value="1" FontSize="20" Style="{DynamicResource TouchSliderStyle}" LargeChange="0.01" SmallChange="0.001"/>
<Slider x:Name="UIScaleTopSlider" HorizontalAlignment="Left" Height="16" Margin="9,74,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5" ValueChanged="UIScaleTopSlider_ValueChanged" LargeChange="0.01" SmallChange="0.001"/>
<Label x:Name="label_Copy8" Content="Top bar scale" HorizontalAlignment="Left" Margin="14,57,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="95"/>
<Label x:Name="labelTopBarScale" HorizontalAlignment="Left" Margin="95,57,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="42" Content="{Binding Value, ElementName=UIScaleTopSlider}">
<Label.Style>
642,7 → 642,7
</Style>
</Label.Style>
</Label>
<Slider x:Name="UIScaleMotorsSlider" HorizontalAlignment="Left" Height="16" Margin="9,112,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5"/>
<Slider x:Name="UIScaleMotorsSlider" HorizontalAlignment="Left" Height="16" Margin="9,112,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5" LargeChange="0.01" SmallChange="0.001"/>
<Label x:Name="label_Copy9" Content="Motors scale" HorizontalAlignment="Left" Margin="14,95,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="95"/>
<Label x:Name="labelMotorsScale" HorizontalAlignment="Left" Margin="95,95,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="42" Content="{Binding Value, ElementName=UIScaleMotorsSlider}">
<Label.Style>
655,7 → 655,7
</Style>
</Label.Style>
</Label>
<Slider x:Name="UIScaleOSDSlider" HorizontalAlignment="Left" Height="16" Margin="9,148,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5"/>
<Slider x:Name="UIScaleOSDSlider" HorizontalAlignment="Left" Height="16" Margin="9,148,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5" LargeChange="0.01" SmallChange="0.001"/>
<Label x:Name="label_Copy10" Content="OSD scale" HorizontalAlignment="Left" Margin="14,131,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="95"/>
<Label x:Name="labelOSDScale" HorizontalAlignment="Left" Margin="95,131,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="42" Content="{Binding Value, ElementName=UIScaleOSDSlider}">
<Label.Style>
668,7 → 668,7
</Style>
</Label.Style>
</Label>
<Slider x:Name="UIScaleLOGSlider" HorizontalAlignment="Left" Height="16" Margin="9,184,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5"/>
<Slider x:Name="UIScaleLOGSlider" HorizontalAlignment="Left" Height="16" Margin="9,184,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5" LargeChange="0.01" SmallChange="0.001"/>
<Label x:Name="label_Copy11" Content="LOG scale" HorizontalAlignment="Left" Margin="14,167,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="95"/>
<Label x:Name="labelLOGScale" HorizontalAlignment="Left" Margin="95,167,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="42" Content="{Binding Value, ElementName=UIScaleLOGSlider}">
<Label.Style>
681,7 → 681,7
</Style>
</Label.Style>
</Label>
<Slider x:Name="UIScaleHorizonSlider" HorizontalAlignment="Left" Height="16" Margin="9,220,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5"/>
<Slider x:Name="UIScaleHorizonSlider" HorizontalAlignment="Left" Height="16" Margin="9,220,0,0" VerticalAlignment="Top" Width="207" Value="1" Maximum="2" Minimum="0.5" LargeChange="0.01" SmallChange="0.001"/>
<Label x:Name="label_Copy12" Content="Horizon scale" HorizontalAlignment="Left" Margin="14,203,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="95"/>
<Label x:Name="labelHorizonScale" HorizontalAlignment="Left" Margin="95,203,0,0" VerticalAlignment="Top" Foreground="White" Padding="0" Width="42" Content="{Binding Value, ElementName=UIScaleHorizonSlider}">
<Label.Style>
716,7 → 716,8
</TabItem>
<TabItem Header="Map" Height="20" VerticalAlignment="Top" Margin="7.193,0,-17.257,0">
<Grid x:Name="GridMapData" Margin="0,0,-3,-1" HorizontalAlignment="Left" Width="226">
<CheckBox x:Name="checkBoxFollowCopter" Content="follow copter" HorizontalAlignment="Left" Margin="109,430,0,0" Width="107" RenderTransformOrigin="0.783,27.263" Foreground="White" Click="checkBoxFollowCopter_Click" FontSize="14" VerticalContentAlignment="Center" Height="20" VerticalAlignment="Top"/>
<CheckBox x:Name="checkBoxFollowCopter" Content="follow copter" HorizontalAlignment="Left" Margin="8,516,0,0" Width="107" RenderTransformOrigin="0.783,27.263" Foreground="White" Click="checkBoxFollowCopter_Click" FontSize="14" VerticalContentAlignment="Center" Height="20" VerticalAlignment="Top" ToolTip="the map follows the copter - the copter is always centered"/>
<CheckBox x:Name="checkBoxAutoSetHP" Content="auto set HP" HorizontalAlignment="Left" Margin="92,432,0,0" Width="107" RenderTransformOrigin="0.783,27.263" Foreground="White" FontSize="14" VerticalContentAlignment="Center" Height="20" VerticalAlignment="Top" ToolTip="set HP automatically with first satfix" Click="checkBoxAutoSetHP_Click"/>
<TextBox Margin="6,24,10,0" x:Name="textBoxGeo" KeyUp="textBoxGeo_KeyUp" Foreground="Black" Height="22" VerticalAlignment="Top" VerticalContentAlignment="Center" Text="Landshut"/>
<Button x:Name="buttonGeoCoding" Content="Go To!" HorizontalAlignment="Left" Margin="6,47,0,0" VerticalAlignment="Top" Width="144" Height="26" Click="buttonGeoCoding_Click"/>
<Button Height="27" Margin="0,136,10,0" x:Name="buttonReloadMap" VerticalAlignment="Top" Click="ReloadMap_Click" HorizontalAlignment="Right" Width="71" Content="Reload"/>
/MKLiveView/v1.0/Source/MainWindow.xaml.cs
218,6 → 218,9
int _iThresholdRC = 160;
int _iThresholdMagField = 15;
 
bool _bAutoHome = false;
bool _bFirstSatFix = false;
int _iFirstSatFix = 0;
 
double _dTopHeight = 36;
 
255,7 → 258,6
/// datatable for motordata (current,temp)
/// </summary>
DataTable dtMotors1 = new DataTable();
// DataTable dtMotors2 = new DataTable();
 
DataTable dtWaypoints = new DataTable();
static volatile int _iWP = -1;
332,7 → 334,7
cBoxTimingsNav.SelectedItem = navctrlInterval * 10;
cBoxTimingsBl.SelectedItem = blctrlInterval * 10;
cBoxTimingsOSD.SelectedItem = OSDInterval * 10;
 
checkBoxAutoSetHP.IsChecked = _bAutoHome;
checkBoxFollowCopter.IsChecked = _bFollowCopter;
 
 
542,6 → 544,10
if (home != null && MainMap.Markers.Contains(home))
MainMap.Position = home.Position;
}
private void checkBoxAutoSetHP_Click(object sender, RoutedEventArgs e)
{
_bAutoHome = (bool)checkBoxAutoSetHP.IsChecked;
}
private void chkBoxSaveNormalState_Click(object sender, RoutedEventArgs e)
{
_bSaveWinStateNormal = (bool)chkBoxSaveNormalState.IsChecked;
804,16 → 810,6
}
else
{
//if (d * 1000 == _dDistanceLast)
//{
// if (_iDistanceJitter < 20)
// { _iDistanceJitter++; }
//}
//else
//{
// _iDistanceJitter = 0;
// _dDistanceLast = d * 1000;
//}
if (_iDistanceJitter < 20)
{ _iDistanceJitter++; }
if (_iDistanceJitter == 20)
825,19 → 821,13
}
if (_bVoiceDistancePlay && !_bVoiceDistanceActive)
{
if (File.Exists("Voice\\Distance.mp3"))
{
 
MediaPlayer.MediaPlayer mp = new MediaPlayer.MediaPlayer();
mp.Open("Voice\\Distance.mp3");
mp.Play();
}
Thread t = new Thread(()=>_mediaPlayer("Voice\\Distance.mp3"));
t.Start();
_bVoiceDistanceActive = true;
}
_iDistanceJitter++;
}
}
 
}
}
 
1346,13 → 1336,8
}
if (_bVoiceVoltPlay && !_bCritVoiceVoltActive)
{
if (File.Exists("Voice\\CriticalBattery.mp3"))
{
 
MediaPlayer.MediaPlayer mp = new MediaPlayer.MediaPlayer();
mp.Open("Voice\\CriticalBattery.mp3");
mp.Play();
}
Thread t = new Thread(() => _mediaPlayer("Voice\\CriticalBattery.mp3"));
t.Start();
_bCritVoiceVoltActive = true;
}
}
1367,13 → 1352,8
 
if (_bVoiceVoltPlay && !_bWarnVoiceVoltActive)
{
if (File.Exists("Voice\\LowBattery.mp3"))
{
 
MediaPlayer.MediaPlayer mp = new MediaPlayer.MediaPlayer();
mp.Open("Voice\\LowBattery.mp3");
mp.Play();
}
Thread t = new Thread(() => _mediaPlayer("Voice\\LowBattery.mp3"));
t.Start();
_bWarnVoiceVoltActive = true;
}
}
1442,13 → 1422,8
}
if (_bVoiceMagneticFieldPlay && !_bVoiceMagneticFieldActive)
{
if (File.Exists("Voice\\MagneticField.mp3"))
{
 
MediaPlayer.MediaPlayer mp = new MediaPlayer.MediaPlayer();
mp.Open("Voice\\MagneticField.mp3");
mp.Play();
}
Thread t = new Thread(() => _mediaPlayer("Voice\\MagneticField.mp3"));
t.Start();
_bVoiceMagneticFieldActive = true;
}
}
1606,6 → 1581,16
if (data[50] > 4)//if more than 4 sats in use . otherwise the map would jump and scroll insane at beginning
{
_bSatFix = true; _iSatsJitter = 0; _bVoiceSatFixActive = false;
if(_bAutoHome && !_bFirstSatFix)
{
if (_iFirstSatFix < 3)
_iFirstSatFix++;
else
{
_bFirstSatFix = true;
Dispatcher.Invoke(() => setHomePos());
}
}
if (stbSatFixLostAnim != null && _bAnimSatFixActive)
{
Dispatcher.Invoke(() => stbSatFixLostAnim.Stop());
1644,13 → 1629,8
}
if (_bVoiceSatFixPlay && !_bVoiceSatFixActive)
{
if (File.Exists("Voice\\CriticalBattery.mp3"))
{
 
MediaPlayer.MediaPlayer mp = new MediaPlayer.MediaPlayer();
mp.Open("Voice\\CriticalBattery.mp3");
mp.Play();
}
Thread th = new Thread(() => _mediaPlayer("Voice\\CriticalBattery.mp3"));
th.Start();
_bVoiceSatFixActive = true;
}
 
1720,13 → 1700,8
}
if (_bVoiceRCLevelPlay && !_bVoiceRCLevelActive)
{
if (File.Exists("Voice\\RCLevel.mp3"))
{
 
MediaPlayer.MediaPlayer mp = new MediaPlayer.MediaPlayer();
mp.Open("Voice\\RCLevel.mp3");
mp.Play();
}
Thread th = new Thread(() => _mediaPlayer("Voice\\RCLevel.mp3"));
th.Start();
_bVoiceRCLevelActive = true;
}
_iRCLevelJitter++;
2142,6 → 2117,15
 
#endregion controller messages
 
void _mediaPlayer(string file)
{
if (File.Exists(file))
{
MediaPlayer.MediaPlayer mp = new MediaPlayer.MediaPlayer();
mp.Open(file);
mp.Play();
}
}
private void imageFullscreen_MouseDown(object sender, MouseButtonEventArgs e)
{
if (winState.isMaximized)
2254,82 → 2238,84
ini.path = filePath + "\\MKLiveViewSettings.ini";
 
string sVal = ini.IniReadValue("timings", "AutorefreshDebugData");
_debugDataAutorefresh = Convert.ToBoolean(sVal);
if (sVal != "") _debugDataAutorefresh = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("timings", "AutorefreshNavCtrlData");
_navCtrlDataAutorefresh = Convert.ToBoolean(sVal);
if (sVal != "") _navCtrlDataAutorefresh = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("timings", "AutorefreshBLCtrlData");
_blctrlDataAutorefresh = Convert.ToBoolean(sVal);
if (sVal != "") _blctrlDataAutorefresh = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("timings", "AutorefreshOSDData");
_OSDAutorefresh = Convert.ToBoolean(sVal);
if (sVal != "") _OSDAutorefresh = Convert.ToBoolean(sVal);
 
sVal = ini.IniReadValue("timings", "IntervalDebugData");
debugInterval = (byte)Convert.ToInt16(sVal);
if (sVal != "") debugInterval = (byte)Convert.ToInt16(sVal);
sVal = ini.IniReadValue("timings", "IntervalNavCtrlData");
navctrlInterval = (byte)Convert.ToInt16(sVal);
if (sVal != "") navctrlInterval = (byte)Convert.ToInt16(sVal);
sVal = ini.IniReadValue("timings", "IntervalBLCtrlData");
blctrlInterval = (byte)Convert.ToInt16(sVal);
if (sVal != "") blctrlInterval = (byte)Convert.ToInt16(sVal);
sVal = ini.IniReadValue("timings", "IntervalOSDData");
OSDInterval = (byte)Convert.ToInt16(sVal);
if (sVal != "") OSDInterval = (byte)Convert.ToInt16(sVal);
 
sVal = ini.IniReadValue("topBar", "voltage");
chkBoxTopBarShowVoltage.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowVoltage.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("topBar", "capacity");
chkBoxTopBarShowCapacity.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowCapacity.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("topBar", "current");
chkBoxTopBarShowCurrent.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowCurrent.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("topBar", "flightTime");
chkBoxTopBarShowFlightTime.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowFlightTime.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("topBar", "distanceHP");
chkBoxTopBarShowDistanceHP.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowDistanceHP.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("topBar", "height");
chkBoxTopBarShowHeight.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowHeight.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("topBar", "speed");
chkBoxTopBarShowSpeed.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowSpeed.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("topBar", "magneticField");
chkBoxTopBarShowMF.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowMF.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("topBar", "satellites");
chkBoxTopBarShowSatellites.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowSatellites.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("topBar", "rc");
chkBoxTopBarShowRC.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxTopBarShowRC.IsChecked = Convert.ToBoolean(sVal);
 
sVal = ini.IniReadValue("style", "saveFullScreen");
chkBoxSaveFullScreenState.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxSaveFullScreenState.IsChecked = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("style", "saveNormalState");
chkBoxSaveNormalState.IsChecked = Convert.ToBoolean(sVal);
if (sVal != "") chkBoxSaveNormalState.IsChecked = Convert.ToBoolean(sVal);
 
sVal = ini.IniReadValue("style", "scaleNormalAll");
scaleNormalAll = Convert.ToDouble(sVal);
if (sVal != "") scaleNormalAll = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleNormalTopBar");
scaleNormalTopBar = Convert.ToDouble(sVal);
if (sVal != "") scaleNormalTopBar = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleNormalMotors");
scaleNormalMotors = Convert.ToDouble(sVal);
if (sVal != "") scaleNormalMotors = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleNormalOSD");
scaleNormalOSD = Convert.ToDouble(sVal);
if (sVal != "") scaleNormalOSD = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleNormalLOG");
scaleNormalLOG = Convert.ToDouble(sVal);
if (sVal != "") scaleNormalLOG = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleNormalHorizon");
scaleNormalHorizon = Convert.ToDouble(sVal);
if (sVal != "") scaleNormalHorizon = Convert.ToDouble(sVal);
 
sVal = ini.IniReadValue("style", "scaleFullAll");
scaleFullAll = Convert.ToDouble(sVal);
if (sVal != "") scaleFullAll = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleFullTopBar");
scaleFullTopBar = Convert.ToDouble(sVal);
if (sVal != "") scaleFullTopBar = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleFullMotors");
scaleFullMotors = Convert.ToDouble(sVal);
if (sVal != "") scaleFullMotors = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleFullOSD");
scaleFullOSD = Convert.ToDouble(sVal);
if (sVal != "") scaleFullOSD = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleFullLOG");
scaleFullLOG = Convert.ToDouble(sVal);
if (sVal != "") scaleFullLOG = Convert.ToDouble(sVal);
sVal = ini.IniReadValue("style", "scaleFullHorizon");
scaleFullHorizon = Convert.ToDouble(sVal);
if (sVal != "") scaleFullHorizon = Convert.ToDouble(sVal);
 
sVal = ini.IniReadValue("general", "LiPoCells");
_LipoCells = Convert.ToInt16(sVal);
sVal = ini.IniReadValue("general", "Motors");
_iMotors = Convert.ToInt16(sVal);
if (sVal != "") _iMotors = Convert.ToInt16(sVal);
 
sVal = ini.IniReadValue("map", "followMe");
_bFollowCopter = Convert.ToBoolean(sVal);
if (sVal != "") _bFollowCopter = Convert.ToBoolean(sVal);
sVal = ini.IniReadValue("map", "AutoSetHome");
if (sVal != "") _bAutoHome = Convert.ToBoolean(sVal);
 
sVal = ini.IniReadValue("threshold", "VoltageWarning");
if(sVal != "") _dThresholdVoltageWarn = Convert.ToDouble(sVal);
2380,6 → 2366,7
ini.IniWriteValue("general", "Motors", _iMotors.ToString());
 
ini.IniWriteValue("map", "followMe", _bFollowCopter.ToString());
ini.IniWriteValue("map", "AutoSetHome", _bAutoHome.ToString());
 
ini.IniWriteValue("topBar", "voltage", chkBoxTopBarShowVoltage.IsChecked.ToString());
ini.IniWriteValue("topBar", "capacity", chkBoxTopBarShowCapacity.IsChecked.ToString());
2425,6 → 2412,7
}
#endregion functions
 
 
private void Window_Closing(object sender, CancelEventArgs e)
{
_writeIni();