Example #1
0
void
dlgWeatherShowModal()
{

  wf = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(),
                  _T("IDR_XML_WEATHER"));
  if (wf == NULL)
    return;

  WndProperty* wp;

  wp = (WndProperty*)wf->FindByName(_T("prpTime"));
  if (wp) {
    DataFieldEnum* dfe;
    dfe = (DataFieldEnum*)wp->GetDataField();
    dfe->addEnumText(_T("Now"));
    for (unsigned i = 1; i < RasterWeather::MAX_WEATHER_TIMES; i++) {
      if (RASP.isWeatherAvailable(i)) {
        TCHAR timetext[10];
        _stprintf(timetext, _T("%04d"), RASP.IndexToTime(i));
        dfe->addEnumText(timetext, i);
      }
    }

    dfe->Set(RASP.GetTime());

    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpDisplayItem"));
  DataFieldEnum* dfe;
  if (wp) {
    dfe = (DataFieldEnum*)wp->GetDataField();
    dfe->addEnumText(_("Terrain"));

    for (int i = 1; i <= 15; i++) {
      const TCHAR *label = RASP.ItemLabel(i);
      if (label != NULL)
        dfe->addEnumText(label, i);
    }
    dfe->Set(RASP.GetParameter());
    wp->RefreshDisplay();
  }

  wf->ShowModal();

  wp = (WndProperty*)wf->FindByName(_T("prpTime"));
  if (wp) {
    DataFieldEnum* dfe;
    dfe = (DataFieldEnum*)wp->GetDataField();
    RASP.SetTime(dfe->GetAsInteger());
  }

  wp = (WndProperty*)wf->FindByName(_T("prpDisplayItem"));
  if (wp)
    RASP.SetParameter(wp->GetDataField()->GetAsInteger());

  delete wf;
}
Example #2
0
/**
 * @return true if the value has changed
 */
static bool
FinishPortField(DeviceConfig &config, const DataFieldEnum &df)
{
  unsigned value = df.GetAsInteger();

  /* decode the port type from the upper 16 bits of the id; we don't
     need the rest, because that's just some serial we don't care
     about */
  const DeviceConfig::PortType new_type =
    (DeviceConfig::PortType)(value >> 16);
  switch (new_type) {
  case DeviceConfig::PortType::DISABLED:
  case DeviceConfig::PortType::AUTO:
  case DeviceConfig::PortType::INTERNAL:
  case DeviceConfig::PortType::TCP_LISTENER:
    if (new_type == config.port_type)
      return false;

    config.port_type = new_type;
    return true;

  case DeviceConfig::PortType::SERIAL:
    /* Serial Port */
    if (new_type == config.port_type &&
        _tcscmp(config.path, df.GetAsString()) == 0)
      return false;

    config.port_type = new_type;
    config.path = df.GetAsString();
    return true;

  case DeviceConfig::PortType::RFCOMM:
    /* Bluetooth */
    if (new_type == config.port_type &&
        _tcscmp(config.bluetooth_mac, df.GetAsString()) == 0)
      return false;

    config.port_type = new_type;
    config.bluetooth_mac = df.GetAsString();
    return true;

  case DeviceConfig::PortType::IOIOUART:
    /* IOIO UART */
    if (new_type == config.port_type &&
        config.ioio_uart_id == (unsigned)_ttoi(df.GetAsString()))
      return false;

    config.port_type = new_type;
    config.ioio_uart_id = (unsigned)_ttoi(df.GetAsString());
    return true;
  }

  /* unreachable */
  assert(false);
  return false;
}
Example #3
0
void
TaskPropertiesPanel::OnTaskTypeChange(DataFieldEnum &df)
{
  const TaskFactoryType newtype =
    (TaskFactoryType)df.GetAsInteger();
  if (newtype != ordered_task->GetFactoryType()) {
    ReadValues();
    ordered_task->SetFactory(newtype);
    *task_changed =true;
    RefreshView();
  }
}
Example #4
0
static void GetValues(void) {
  WndProperty* wp;
  double num=0, mm = 0, ss = 0; // mm,ss are numerators (division) so don't want to lose decimals

  if(Units::CoordinateFormat==4) {
	  int utmXZone=0;
	  char utmYZone='\0';;
	  double easting=0, northing=0;

      wp = (WndProperty*)wf->FindByName(TEXT("prpUTMzoneX"));
      if (wp) {
    	utmXZone = wp->GetDataField()->GetAsInteger();
      }
      wp = (WndProperty*)wf->FindByName(TEXT("prpUTMzoneY"));
      if (wp) {
    	  DataFieldEnum* dfe = (DataFieldEnum*)wp->GetDataField();
    	  if(dfe){
    		  utmYZone = enumToYZone(dfe->GetAsInteger());
    	  }
      }
      wp = (WndProperty*)wf->FindByName(TEXT("prpUTMeast"));
      if (wp) {
    	  easting = wp->GetDataField()->GetAsFloat();
      }
      wp = (WndProperty*)wf->FindByName(TEXT("prpUTMnorth"));
      if (wp) {
    	  northing = wp->GetDataField()->GetAsFloat();
      }
      UtmToLatLonWGS84(utmXZone, utmYZone, easting, northing, global_wpt->Latitude, global_wpt->Longitude );

  } else {
	  bool sign = false;
	  int dd = 0;

	  wp = (WndProperty*)wf->FindByName(TEXT("prpLongitudeSign"));
	  if (wp) {
		sign = (wp->GetDataField()->GetAsInteger()==1);
	  }
	  wp = (WndProperty*)wf->FindByName(TEXT("prpLongitudeD"));
	  if (wp) {
		dd = wp->GetDataField()->GetAsInteger();
	  }

	  switch (Units::CoordinateFormat) {
	  case 0: // ("DDMMSS");
	  case 1: // ("DDMMSS.ss");
		wp = (WndProperty*)wf->FindByName(TEXT("prpLongitudeM"));
		if (wp) {
		  mm = wp->GetDataField()->GetAsInteger();
		}
		wp = (WndProperty*)wf->FindByName(TEXT("prpLongitudeS"));
		if (wp) {
		  ss = wp->GetDataField()->GetAsInteger();
		}
		num = dd+mm/60.0+ss/3600.0;
		break;
	  case 2: // ("DDMM.mmm");
		wp = (WndProperty*)wf->FindByName(TEXT("prpLongitudeM"));
		if (wp) {
		  mm = wp->GetDataField()->GetAsInteger();
		}
		wp = (WndProperty*)wf->FindByName(TEXT("prpLongitudemmm"));
		if (wp) {
		  ss = wp->GetDataField()->GetAsInteger();
		}
		num = dd+(mm+ss/1000.0)/60.0;
		break;
	  case 3: // ("DD.dddd");
		wp = (WndProperty*)wf->FindByName(TEXT("prpLongitudeDDDD"));
		if (wp) {
		  mm = wp->GetDataField()->GetAsInteger();
		}
		num = dd+mm/10000;
		break;
	  case 4:
		break;
	  }
	  if (!sign) {
		num = -num;
	  }

	  global_wpt->Longitude = num;

	  wp = (WndProperty*)wf->FindByName(TEXT("prpLatitudeSign"));
	  if (wp) {
		sign = (wp->GetDataField()->GetAsInteger()==1);
	  }
	  wp = (WndProperty*)wf->FindByName(TEXT("prpLatitudeD"));
	  if (wp) {
		dd = wp->GetDataField()->GetAsInteger();
	  }

	  switch (Units::CoordinateFormat) {
	  case 0: // ("DDMMSS");
	  case 1: // ("DDMMSS.ss");
		wp = (WndProperty*)wf->FindByName(TEXT("prpLatitudeM"));
		if (wp) {
		  mm = wp->GetDataField()->GetAsInteger();
		}
		wp = (WndProperty*)wf->FindByName(TEXT("prpLatitudeS"));
		if (wp) {
		  ss = wp->GetDataField()->GetAsInteger();
		}
		num = dd+mm/60.0+ss/3600.0;
		break;
	  case 2: // ("DDMM.mmm");
		wp = (WndProperty*)wf->FindByName(TEXT("prpLatitudeM"));
		if (wp) {
		  mm = wp->GetDataField()->GetAsInteger();
		}
		wp = (WndProperty*)wf->FindByName(TEXT("prpLatitudemmm"));
		if (wp) {
		  ss = wp->GetDataField()->GetAsInteger();
		}
		num = dd+(mm+ss/1000.0)/60.0;
		break;
	  case 3: // ("DD.dddd");
		wp = (WndProperty*)wf->FindByName(TEXT("prpLatitudeDDDD"));
		if (wp) {
		  mm = wp->GetDataField()->GetAsInteger();
		}
		num = dd+mm/10000;
		break;
	  case 4:
		break;
	  }
	  if (!sign) {
		num = -num;
	  }

	  global_wpt->Latitude = num;
  }
  
  wp = (WndProperty*)wf->FindByName(TEXT("prpAltitude"));
  if (wp) {
    ss = wp->GetDataField()->GetAsFloat();
    if (ss==0) {
      WaypointAltitudeFromTerrain(global_wpt);
    } else {
      global_wpt->Altitude = ss/ALTITUDEMODIFY;
    }
  }
  
  wp = (WndProperty*)wf->FindByName(TEXT("prpFlags"));
  if (wp) {
    int myflag = wp->GetDataField()->GetAsInteger();
    switch(myflag) {
    case 0:
      global_wpt->Flags = TURNPOINT;
	#if 100825
	if ( global_wpt->Format == LKW_CUP) {
		// set normal turnpoint style
		global_wpt->Style = 1;
	}
	#endif
      break;
    case 1:
      global_wpt->Flags = AIRPORT | TURNPOINT;
	#if 100825
	if ( global_wpt->Format == LKW_CUP) {
		// set airfield style
		global_wpt->Style = 5;
	}
	#endif
      break;
    case 2:
      global_wpt->Flags = LANDPOINT;
	#if 100825
	if ( global_wpt->Format == LKW_CUP) {
		// set outlanding style
		global_wpt->Style = 3;
	}
	#endif
      break;
    default:
      global_wpt->Flags = 0;
      break;
    };
  }
}
Example #5
0
    void OnSend(WndButton* pWnd) {
        if(ItemIndex < FileList.size()) {
            StartHourglassCursor();
            
            //Start Bluetooth if needed...
#ifdef UNDER_CE    
            CObexPush Obex;
            if(Obex.Startup()) {
                StartupStore(_T("Startup OK \n"));
                size_t nDevice = Obex.LookupDevice();
                StartupStore(_T("LookupDevice OK \n"));
                if(nDevice == 0) {
                    StopHourglassCursor();
                    MessageBoxX(_T("No Device"), _T("Error"), mbOk);
                    StartHourglassCursor();
                } else {
                    WndProperty* wp = (WndProperty*)wfDlg->FindByName(TEXT("prpDeviceList"));
                    DataFieldEnum* dfe = NULL;
                    if (wp) {
                        dfe = (DataFieldEnum*)wp->GetDataField();
                    }
                    if(dfe) {
                        dfe->Clear();
                        dfe->addEnumText(_T("none"));
                    }
                    for(size_t i = 0; i < nDevice; ++i) {
                        TCHAR szDeviceName[100] = {0};
                        if(!Obex.GetDeviceName(i, szDeviceName, array_size(szDeviceName))) {
                            _stprintf(szDeviceName, _T("Unknown device <%d>"), i);
                        }
                        StartupStore(_T("GetDeviceName <%d><%s> \n"), i, szDeviceName);
                        if(dfe) {
                            dfe->addEnumText(szDeviceName);
                        }
                    }
                    if(wp) {
                        if(dfe) {
                            dfe->SetAsInteger(0);
                        }
                        wp->SetReadOnly(false);
                        wp->RefreshDisplay();
                    }
                    StopHourglassCursor();
                    size_t DeviceIndex = 0;
                    if(dfe && wp) {
                        dlgComboPicker(wp);
                        DeviceIndex = dfe->GetAsInteger();
                    }
                    StartHourglassCursor();
                    if(DeviceIndex != 0) {
                        DeviceIndex--;

                        TCHAR szFileFullPath[MAX_PATH] = _T("\0");
                        LocalPath(szFileFullPath, _T(LKD_LOGS));
                        size_t nLen = _tcslen(szFileFullPath);
                        if (szFileFullPath[nLen - 1] != _T('\\')) {
                            _tcscat(szFileFullPath, _T("\\"));
                        }
                        FileList_t::const_iterator ItFileName = FileList.begin();
                        std::advance(ItFileName, ItemIndex);
                        _tcscat(szFileFullPath, ItFileName->c_str());

                        if(!Obex.SendFile(DeviceIndex, szFileFullPath)) {
                            StopHourglassCursor();
                            MessageBoxX(_T("Send Failed"), _T("Error"), mbOk);
                            StartHourglassCursor();
                        } else {
                            StopHourglassCursor();
                            MessageBoxX(_T("File sent!"), _T("Success"), mbOk);
                            StartHourglassCursor();
                        }
                    }
                }
                Obex.Shutdown();
            } else {
                MessageBoxX(_T("Unsupported on this device"), _T("Error"), mbOk);
            }
#else
            MessageBoxX(_T("Unsupported on this device"), _T("Error"), mbOk);
#endif
            StopHourglassCursor();
        }
    }