Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 2294 → Rev 2295

/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();