WORD MTime::DateFormatAlt(LPTSTR ptszTimeFormat, WORD cchTimeFormat) { if (!ptszTimeFormat || !cchTimeFormat) return 0; WORD wRes = DateFormat(ptszTimeFormat, cchTimeFormat); if (wRes != 0) return wRes; SYSTEMTIME AltSysTime = _SysTime; MTime mtNow; mtNow.GetLocalTime(); AltSysTime.wYear=mtNow.Year(); if ((cchTimeFormat = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &AltSysTime, NULL, ptszTimeFormat, cchTimeFormat)) == 0) { *ptszTimeFormat = 0; return 0; } TCHAR tszText[10]; _itot(mtNow.Year(), tszText, 10); TCHAR * tszYear = _tcsstr(ptszTimeFormat, tszText); if (tszYear && mir_tstrlen(tszYear) == 4) mir_tstrcpy(tszYear, _T("????")); else { *ptszTimeFormat = 0; return 0; } return cchTimeFormat; }
BOOL CallContextDayNote(SYSTEMTIME Time, HWND hCalendar) { CStringArray arr; arr.Add(_l("New reminder")); arr.Add(_l("Add date to clipboard")); int iSelection=SelectFromMenu(arr,0); if(iSelection<0){ return 0; } if(iSelection==0){ return -1; } CString s=""; COleDateTime tm;//=COleDateTime(Time); tm.SetDate(Time.wYear,Time.wMonth,Time.wDay); if(strlen(szDateFormat)==0){ s=DateFormat(tm,FALSE); }else{ SYSTEMTIME EventTime; tm.GetAsSystemTime(EventTime); char szTmp[1020]={0}; GetDateFormat(LOCALE_USER_DEFAULT,0,&EventTime,szDateFormat,szTmp,sizeof(szTmp)); s=szTmp; } BOOL bThroughGlobal=0; USES_CONVERSION; SetClipboardText(A2W(s),bThroughGlobal,0); return 0; };
/// <summary> /// Calculates the Julian date from the epoch parameter. The format of /// the epoch can be JulianDate, Date or Packed date format. /// </summary> /// <param name="epoch">The time instance in JulianDate, Date or Packed date format</param> /// <returns>The time instance in double</returns> int Ephemeris::GetJulianDate(std::string epoch, double &julianDate) { DateTime dateTime; std::string data = epoch.substr(2, epoch.length() - 2); EpochFormat epochFormat = GetFormat(epoch); switch (epochFormat) { case JulianDate: julianDate = atof(data.c_str()); break; case Date: DateFormat(epoch, dateTime); ToJulianDate(dateTime, julianDate); break; case PackedDate: PackedDateFormat(epoch, dateTime); ToJulianDate(dateTime, julianDate); break; case UndefinedFormat: Error::_errMsg = "Undefined format for epoch!"; Error::PushLocation(__FILE__, __FUNCTION__, __LINE__); return 1; default: Error::_errMsg = "Invalid value for epoch!"; Error::PushLocation(__FILE__, __FUNCTION__, __LINE__); return 1; } return 0; }
CString GetRemDsc(CWPReminder& rem,BOOL bAddDate=FALSE) { CString sDsc=TrimMessage(rem.szText,30,1); if(sDsc==""){ sDsc=_l2("No description"); } COleDateTime tm(rem.EventTime); COleDateTime dtNow=COleDateTime::GetCurrentTime(); if(bAddDate && (tm.GetDay()!=dtNow.GetDay() || tm.GetMonth()!=dtNow.GetMonth() || tm.GetYear()!=dtNow.GetYear())){ return Format("%s %s %s",DateFormat(tm,TRUE),TimeFormat(tm),sDsc); }else{ return Format("%s %s",TimeFormat(tm),sDsc); } }
void Window::SetupAnnotation() { int slice = m_ImageHandler.GetImageObj()->GetActiveSlice(); DICOMIOType::Pointer io = *m_ImageHandler.GetImageObj()->GetIOObject(slice); std::string temp; std::shared_ptr<ImageContainer> imageObj = m_ImageHandler.GetImageObj(); io->GetValueFromTag("0010|0010", temp); //Patient name std::string UpperLeftText = temp + "\n"; temp = ""; io->GetValueFromTag("0010|0030", temp); // Birthday UpperLeftText += DateFormat(temp) + ", "; temp = ""; io->GetValueFromTag("0010|0040", temp); // Sex UpperLeftText += temp + ", "; temp = ""; io->GetValueFromTag("0010|1010", temp); // Age UpperLeftText += temp + "\n"; temp = ""; io->GetValueFromTag("0008|103e", temp); // Series Description UpperLeftText += temp +"\n"; temp = ""; io->GetValueFromTag("0008|0012", temp); // Instance Creation Day UpperLeftText += DateFormat(temp) + "\n"; temp = ""; io->GetValueFromTag("0008|0013", temp); // Instance Creation Time UpperLeftText += TimeFormat(temp) + "\n"; temp = ""; temp = std::to_string(imageObj->GetActiveSlice()+1); UpperLeftText += temp + "/"; temp = ""; temp = std::to_string(imageObj->GetMaxSliceNum()+1); // Number of Slices UpperLeftText += temp + "\n"; temp = ""; io->GetValueFromTag("0008|0080", temp); // Institution Name std::string UpperRightText = temp + "\n"; temp = ""; io->GetValueFromTag("0008|1090", temp); // Manufacturer Model Name UpperRightText += temp + "\n"; temp = ""; io->GetValueFromTag("0018|1020", temp); // Software Versions UpperRightText += temp + "\n"; temp = ""; io->GetValueFromTag("0018|5100", temp); // Patient Position UpperRightText += temp + "\n"; temp = ""; io->GetValueFromTag("0051|1013", temp); // UpperRightText += temp + "\n"; temp = ""; io->GetValueFromTag("0018|0080", temp); // TR std::string LowerLeftText = "TR " + temp + "\n"; temp = ""; io->GetValueFromTag("0018|0081", temp); // TE LowerLeftText += "TE " + temp + "\n"; temp = ""; io->GetValueFromTag("0051|100a", temp); // TA LowerLeftText += temp + "\n"; temp = ""; io->GetValueFromTag("0018|0095", temp); // BW LowerLeftText += "BW " + temp + "\n"; temp = ""; io->GetValueFromTag("0051|1016", temp); // LowerLeftText += temp + "\n\n"; temp = ""; io->GetValueFromTag("0051|1019", temp); // LowerLeftText += temp + "\n"; temp = ""; io->GetValueFromTag("0051|100f", temp); // LowerLeftText += temp + "\n"; temp = ""; io->GetValueFromTag("0018|0024", temp); // Sequence Name LowerLeftText += temp + "\n"; temp = ""; io->GetValueFromTag("0051|1012", temp); // std::string LowerRightText = temp + "\n"; temp = ""; io->GetValueFromTag("0051|100d", temp); // LowerRightText += temp + "\n"; temp = ""; io->GetValueFromTag("0051|1017", temp); // LowerRightText += temp + "\n"; temp = ""; io->GetValueFromTag("0051|100c", temp); // FOV LowerRightText += temp + "\n"; temp = ""; io->GetValueFromTag("0051|100b", temp); // Matrix Size LowerRightText += temp + "\n"; temp = ""; io->GetValueFromTag("0051|100e", temp); // LowerRightText += temp + "\n"; temp = ""; temp = std::to_string(imageObj->GetCurrentWW()); // WW LowerRightText += "W " + temp + "\n"; temp = ""; temp = std::to_string(imageObj->GetCurrentWC()); // WC LowerRightText += "C " + temp + "\n"; temp = ""; m_pDisplay->SetUpperLeftAnnotation(UpperLeftText); m_pDisplay->SetUpperRightAnnotation(UpperRightText); m_pDisplay->SetLowerLeftAnnotation(LowerLeftText); m_pDisplay->SetLowerRightAnnotation(LowerRightText); }
BOOL COCalendar::PreTranslateMessage(MSG* pMsg) { // CG: The following block was added by the ToolTips component. { // Let the ToolTip process this message. m_tooltip.RelayEvent(pMsg); } if(pMsg->message==WM_MOUSEWHEEL){ if((pMsg->wParam)&0x80000000){ OnBnClickedButtonNext(); }else{ OnBnClickedButtonPrev(); } return 0; } if(pMsg->message==WM_MOUSEMOVE){ CPoint pt; GetCursorPos(&pt); GetDlgItem(IDC_CALCTRL)->ScreenToClient(&pt); CWVCellData* pCell=m_WMCtrl.HitTest(pt); if(pCell){ CString sText=DateFormat(pCell->GetCellDate(),0); sText+="\n"; sText+=m_WMCtrl.GetCellDsk(pCell); sText.Replace("\n","\r\n"); sText.TrimRight(); sText.TrimLeft(); m_tooltip.UpdateTipText(sText,GetDlgItem(IDC_CALCTRL)); } } if(pMsg->message==WM_KEYDOWN){ if(pMsg->wParam==33){//p up OnBnClickedButtonPrev(); return TRUE; } if(pMsg->wParam==34){//p down OnBnClickedButtonNext(); return TRUE; } if(pMsg->wParam==VK_UP){ if(bMonView){ WalkDays(-7); }else{ WalkDays(-1); } return TRUE; } if(pMsg->wParam==VK_DOWN){ if(bMonView){ WalkDays(7); }else{ WalkDays(1); } return TRUE; } if(pMsg->wParam==VK_RIGHT){ WalkDays(1); return TRUE; } if(pMsg->wParam==VK_LEFT){ WalkDays(-1); return TRUE; } if(pMsg->wParam==VK_SPACE){ OnBnClickedButtonView(); return TRUE; } if(pMsg->wParam==VK_RETURN){ CallDialogOnDate(m_WMCtrl.GetLastClicked()); RefreshCalendar(); return TRUE; } } return CResizeableDialog::PreTranslateMessage(pMsg); }