コード例 #1
0
ファイル: dlgAirspaceDetails.cpp プロジェクト: LK8000/LK8000
static void OnSetFrequency(WndButton* pWnd){
(void)pWnd;
#ifdef RADIO_ACTIVE
TCHAR Tmp[255];
 if(RadioPara.Enabled)
 {
   double ASFrequency = ExtractFrequency((TCHAR*)airspace_copy.Name());
   if(!ValidFrequency(ASFrequency))
   {
	 ASFrequency = ExtractFrequency((TCHAR*)airspace_copy.Comment());
   }
   if(ValidFrequency(ASFrequency))
   {
     _stprintf(Tmp,_T("%7.3fMHz"),ASFrequency);
     devPutFreqActive(ASFrequency, (TCHAR*)airspace_copy.Name());
     DoStatusMessage(_T(""), Tmp );
   }
 }
#endif  // RADIO_ACTIVE        
  if(pWnd) {
    WndForm * pForm = pWnd->GetParentWndForm();
    if(pForm) {
      pForm->SetModalResult(mrOK);
    }
  }
} 
コード例 #2
0
static void OnPassiveFreq(WndButton* pWnd){
TCHAR	szFreq[8] ;
_stprintf(szFreq,  _T("%7.3f"),RadioPara.PassiveFrequency);
TCHAR	Name[20] = _T("  ???   ");
   dlgNumEntryShowModal(szFreq,8,false);

   double Frequency = StrToDouble(szFreq,NULL);
   while(Frequency > 1000)
	   Frequency /=10;

   if(ValidFrequency(Frequency))
   {
     _stprintf( RadioPara.PassiveName,_T(" "));
      int iIdx = SearchStation(Frequency);
      if(iIdx != 0)
      {
    	_stprintf(Name,_T("%s"),WayPointList[iIdx].Name);
    	_stprintf( RadioPara.PassiveName,_T("%s"),WayPointList[iIdx].Name);
	PassiveRadioIndex = iIdx;
      }
     devPutFreqStandby(devA(), Frequency,Name);
     devPutFreqStandby(devB(), Frequency,Name);
    RadioPara.PassiveFrequency = Frequency;
  //  _stprintf( RadioPara.PassiveName,_T(""));
    RadioPara.Changed =TRUE;
  // OnRemoteUpdate();

   }
   OnUpdate();
}
コード例 #3
0
static void OnActiveButton(WndButton* pWnd){

  if (HoldOff ==0)
  {
    int res = dlgWayPointSelect(0, 90.0, 1, 3);
    if(res > RESWP_END )
    if(ValidWayPoint(res))
    {
      double  Frequency = StrToDouble(WayPointList[res].Freq,NULL);
      if(!ValidFrequency(Frequency))
      {
   // 	DoStatusMessage(_T("No valid Frequency!") );
    	return;
      }
      devPutFreqActive(devA(), Frequency, WayPointList[res].Name);
      devPutFreqActive(devB(), Frequency, WayPointList[res].Name);
      _stprintf(RadioPara.ActiveName,_T("%s"), WayPointList[res].Name);
      RadioPara.ActiveFrequency = Frequency;

      ActiveRadioIndex = res;
    }
    OnUpdate();
    HoldOff = HOLDOFF_TIME;
  }
}
コード例 #4
0
ファイル: dlgAirspaceDetails.cpp プロジェクト: LK8000/LK8000
static void SetValues(WndForm* wf) {

  
  WndProperty* wp;
  WndButton *wb;
  TCHAR buffer[80];
  TCHAR buffer2[160]; // must contain buffer

  int bearing;
  int hdist;
  int vdist;

  
  bool inside = false;
  {
    ScopeLock guard(CAirspaceManager::Instance().MutexRef());
    CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails();
    if(airspace) {
        // Get an object instance copy with actual values
        airspace_copy = CAirspaceManager::Instance().GetAirspaceCopy(airspace);
        inside = CAirspaceManager::Instance().AirspaceCalculateDistance( airspace, &hdist, &bearing, &vdist);
    } else {
        // error : CAirspaceManager are closed ?
        return;
    }
  }
  
  if (wf!=NULL) {
	TCHAR capbuffer[250];
	_stprintf(capbuffer,_T("%s ("),airspace_copy.Name());
        if (airspace_copy.Enabled()) {
        	_tcscat(capbuffer,MsgToken(1643)); // ENABLED
        } else {
        	_tcscat(capbuffer,MsgToken(1600)); // DISABLED
        }
        _tcscat(capbuffer,_T(")")); // DISABLED
	wf->SetCaption(capbuffer);
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpType"));
  if (wp) {
	if (airspace_copy.Flyzone()) {
	  _stprintf(buffer,TEXT("%s %s"), CAirspaceManager::GetAirspaceTypeText(airspace_copy.Type()), TEXT("FLY"));
/*
	  if( _tcsnicmp(  airspace_copy.Name(),   airspace_copy.TypeName() ,_tcslen(airspace_copy.TypeName())) == 0)
		_stprintf(buffer,TEXT("%s"),airspace_copy.Name());
	  else
	    _stprintf(buffer,TEXT("%s %s"),airspace_copy.TypeName()   // fixed strings max. 20
			                          ,airspace_copy.Name());     // NAME_SIZE          30   => max. 30 char
*/
	} else {
	  _stprintf(buffer,TEXT("%s %s"), TEXT("NOFLY"), CAirspaceManager::GetAirspaceTypeText(airspace_copy.Type()));
	}

	wp->SetText( buffer );
//    wp->SetBackColor( airspace_copy.TypeColor());
//	wp->SetForeColor( ContrastTextColor(airspace_copy.TypeColor()));
    wp->RefreshDisplay();
  }
  
  wp = (WndProperty*)wf->FindByName(TEXT("prpTop"));
  if (wp) {
	CAirspaceManager::Instance().GetAirspaceAltText(buffer, sizeof(buffer)/sizeof(buffer[0]), airspace_copy.Top());
    wp->SetText(buffer);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpBase"));
  if (wp) {
	CAirspaceManager::Instance().GetAirspaceAltText(buffer, sizeof(buffer)/sizeof(buffer[0]), airspace_copy.Base());
    wp->SetText(buffer);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpRange"));
  if (wp) {
    Units::FormatUserDistance(abs(hdist), buffer, 20);
    if (inside) {
	  // LKTOKEN  _@M359_ = "Inside" 
      wp->SetCaption(MsgToken(359));
    }
    if (hdist < 0) {
	  // LKTOKEN _@M1257_ "to leave"
	  _stprintf(buffer2, TEXT("%s %d%s %s"), buffer, iround(bearing), MsgToken(2179), MsgToken(1257));
    } else {
	  // LKTOKEN _@M1258_ "to enter"
	  _stprintf(buffer2, TEXT("%s %d%s %s"), buffer, iround(bearing), MsgToken(2179), MsgToken(1258));
	}
    wp->SetText(buffer2);
    wp->RefreshDisplay();
  }


  WindowControl* wDetails = wf->FindByName(TEXT("cmdDetails"));
  {
    ScopeLock guard(CAirspaceManager::Instance().MutexRef());
    CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails();
  	if(airspace->Comment() != NULL)
  	{
      if(_tcslen(airspace->Comment()) > 10 )    
      {
        WindowControl* wSelect = wf->FindByName(TEXT("cmdSelect"));
        if(wSelect) {
          wSelect->SetLeft(IBLSCALE(155));
          wSelect->SetWidth(IBLSCALE(80));
        }

        wDetails->SetLeft(IBLSCALE(80));
        wDetails->SetWidth(IBLSCALE(75));
        wDetails->Enable(true);
      }
      else wDetails->Enable(false);
    }
  }

#ifdef  RADIO_ACTIVE

  WindowControl* wFreq = wf->FindByName(TEXT("cmdSFrequency"));
  if (wFreq) {
    bool bRadio = false;

    if(RadioPara.Enabled) {

	  double fASFrequency = ExtractFrequency((TCHAR*)airspace_copy.Name());
	  if(!ValidFrequency(fASFrequency))
	  {
		fASFrequency = ExtractFrequency((TCHAR*)airspace_copy.Comment());
	  }
	  
      if(ValidFrequency(fASFrequency)) {

        WindowControl* wClose = wf->FindByName(TEXT("cmdClose"));
        if(wClose) {
          wClose->SetLeft(IBLSCALE(115));
          wClose->SetWidth(IBLSCALE(120));
        }

        wFreq->SetLeft(IBLSCALE(3));
        wFreq->SetWidth(IBLSCALE(110));

        _stprintf(buffer2,_T("%7.3fMHz"),fASFrequency);
        wFreq->SetCaption(buffer2);
        wFreq->Redraw();
        bRadio = true;
      }
    }
    wFreq->SetVisible(bRadio);
  }

#else
  WndProperty* wFreq = wf->FindByName(TEXT("cmdSFrequency"));
  if (wFreq) {
    wFreq->Hide();
  }
#endif  // RADIO_ACTIVE        
  // ONLY for DIAGNOSTICS- ENABLE ALSO XML
  #if 0
  wp = (WndProperty*)wf->FindByName(TEXT("prpWarnLevel"));
  if (wp) {
	  switch (airspace_copy.WarningLevel()) {
		default:
		  // LKTOKEN _@M765_ "Unknown"
		  wp->SetText(MsgToken(765));
		  break;
		  
		case awNone:
		  // LKTOKEN _@M479_ "None"
  		  wp->SetText(MsgToken(479));
		  break;

		case awYellow:
			// LKTOKEN _@M1255_ "YELLOW WARNING"
			wp->SetText(MsgToken(1255));
		  break;
		
		case awRed:
			// LKTOKEN _@M1256_ "RED WARNING"
			wp->SetText(MsgToken(1256));
		  break;
	  }//sw
	  wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAckLevel"));
  if (wp) {
      if (airspace_copy.Enabled()) {
        switch (airspace_copy.WarningAckLevel()) {
          default:
            // LKTOKEN _@M765_ "Unknown"
            wp->SetText(MsgToken(765));
            break;
            
          case awNone:
            // LKTOKEN _@M479_ "None"
            wp->SetText(MsgToken(479));
            break;

          case awYellow:
              // LKTOKEN _@M1267_ "Yellow acknowledged"
              wp->SetText(MsgToken(1267));
            break;
          
          case awRed:
              // LKTOKEN _@M1268_ "Red acknowledged"
              wp->SetText(MsgToken(1268));
            break;

        }//sw
      } else {
          // LKTOKEN _@M1269_ "Disabled"
          wp->SetText(MsgToken(1269));
      }
	  wp->RefreshDisplay();
  }
  #endif

  wb = (WndButton*)wf->FindByName(TEXT("cmdFly"));
  if (wb) {
	if (airspace_copy.Flyzone()) {
	  // LKTOKEN _@M1271_ "NOFLY"
	  wb->SetCaption(MsgToken(1271));
	} else {
	  // LKTOKEN _@M1270_ "FLY"
	  wb->SetCaption(MsgToken(1270));
	}
	wb->Redraw();
  }

  wb = (WndButton*)wf->FindByName(TEXT("cmdSelect"));
  if (wb) {
	if (airspace_copy.Selected()) {
	  wb->SetCaption(MsgToken(1656)); // SELECTED!
	} else {
	  wb->SetCaption(MsgToken(1654)); // SELECT
	}
	wb->Redraw();
  }

  wb = (WndButton*)wf->FindByName(TEXT("cmdAcknowledge"));
  if (wb) {
    if (airspace_copy.Enabled()) {
      // LKTOKEN _@M1283_ "Disable"
      wb->SetCaption(MsgToken(1283));
    } else {
      // LKTOKEN _@M1282_ "Enable"
      wb->SetCaption(MsgToken(1282));
    }
    wb->Redraw();
  }

}