/****************************************************************************** Function Name : OnDraw Input(s) : CDC* pomDC Output : - Functionality : Called by the frame work to update the view. This function gets source code from the document and displays on the view. If warning is specified, it highlight that line with different color. If single line of comment is found, it displays the line with differet color. Member of : CFileView Friend of : - Author(s) : Date Created : ******************************************************************************/ void CFileView::OnDraw(CDC* pDC) { // Get document CFunctionEditorDoc* pomDoc = omGetDocument(); ASSERT_VALID(pomDoc); // Initialise backend Buffer // Get Client rectangle // This will give the starting point and size CRect omRect; GetClientRect(&omRect); // Get current scroll position CPoint omPoint = GetScrollPosition(); // Add this walue with Client Rect // to get rect from the starting point to the end of scrolling point omRect.right += omPoint.x; omRect.bottom += omPoint.y; // Create Backend Buffer /*************************************************************/ // If backend buffer creation failed it will use Screen DC // Directly to avoid showing blank screen // The Flag m_bCreateSuccess gives an indication of which DC // it is using. If it is TRUE then that is Buffer. If it is // FALSE then it is directly drawing on the pDC (screen pr printer DC). // No extra check is required to handle create failure /************************************************************/ COffScreenDC omMemDC(pDC, &omRect); CDC* pomDC = nullptr; pomDC = &omMemDC; if(pomDoc != nullptr) { char acSourceLineNo[10] = ""; long lLineCount = LONG_INIT; long lCurrentWarnLineNum = LONG_INIT; int nTabStopPositions = INT_INIT; BOOL bWarningLine = FALSE; COLORREF CurrentTextColor = DWORD_INIT, CurrentBkColor = DWORD_INIT; // Change Font CFont omNewFont; CFont* pomOldFont=nullptr; BOOL bCommentFound = FALSE; BOOL bWithInComment = FALSE; // Create font BOOL bSuccess = omNewFont.CreateFont(m_nCharHeight, m_nCharWidth, DEFAULT_FONT_ESCAPEMENT, DEFAULT_FONT_ORIENTATION, FW_NORMAL, NOT_ITALIC, NO_UNDERLINE, NO_STRIKEOUT, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_MODERN, DEFAULT_FONT); if(bSuccess == TRUE) { // Select the new font object pomOldFont = pomDC -> SelectObject(&omNewFont); // Get line count lLineCount = pomDoc->dwGetLineCount (); // Get warning line number lCurrentWarnLineNum = pomDoc->m_lCurrentWarningLineNum; nTabStopPositions = defNO_OF_CHARS_IN_TAB * m_nCharWidth; if(lLineCount > defCOUNT_INIT) { POSITION Position = pomDoc -> SetPosToFirstLine(); if( Position!= nullptr) { for(long lInt = defCOUNT_INIT; lInt < lLineCount ; lInt++) { int nMargin = MARGIN_FOR_FILE_VIEW; bCommentFound = FALSE; // Set the background mix mode to // tranparent pomDC -> SetBkMode(TRANSPARENT); // Display line number wsprintf(acSourceLineNo,"%lu:",lInt+NEXT_POSITION); CString omStr = (CString) pomDoc -> pcGetLine(Position); int nIndex = omStr.Find( "/*" ); // Starting of comment or already in comment block if (nIndex != -1 || bWithInComment) { if( nIndex == -1 ) { nIndex = 0; } pomDC -> SetTextColor(DIALOG_COLOR); // if comment is in betn the line, // get uncommented chars CString omStrTemp = omStr.Left( nIndex ); // set uncommented char to blue pomDC -> SetTextColor(BLUE_COLOR); pomDC -> TextOut(DEFAULT_X_POS, (m_nCharHeight * (lInt+INCR_LEN)), acSourceLineNo); pomDC -> TabbedTextOut( ( nMargin) * m_nCharWidth, (m_nCharHeight * (lInt+INCR_LEN)), omStrTemp, TAB_POSITION, &nTabStopPositions, TAB_ORIGIN); nMargin += nIndex; // Get commented text and set different color pomDC -> SetTextColor(DIALOG_COLOR); omStrTemp = omStr.Right( omStr.GetLength() - (nIndex)); nIndex = omStrTemp.Find( "*/" ); omStr = ""; if ( nIndex != -1 ) { // Set the comment flag to true bWithInComment = FALSE; omStr = omStrTemp.Right( omStrTemp.GetLength() - (nIndex+2)); omStrTemp = omStrTemp.Left( nIndex+2 ); } else { // Reset the comment flag bWithInComment = TRUE; } pomDC -> TextOut(DEFAULT_X_POS, (m_nCharHeight * (lInt+INCR_LEN)), acSourceLineNo); pomDC -> TabbedTextOut( ( nMargin) * m_nCharWidth, (m_nCharHeight * (lInt+INCR_LEN)), omStrTemp, TAB_POSITION, &nTabStopPositions, TAB_ORIGIN); nMargin += nIndex+2; pomDC -> SetTextColor(BLUE_COLOR); } //else { nIndex = omStr.Find( "//" ); if (nIndex != -1 ) { pomDC -> SetTextColor(DIALOG_COLOR); // if comment is in betn the line, // get uncommented chars CString omStrTemp = omStr.Left( nIndex ); // set uncommented char to blue pomDC -> SetTextColor(BLUE_COLOR); pomDC -> TextOut(DEFAULT_X_POS, (m_nCharHeight * (lInt+INCR_LEN)), acSourceLineNo); pomDC -> TabbedTextOut( ( nMargin) * m_nCharWidth, (m_nCharHeight * (lInt+INCR_LEN)), omStrTemp, TAB_POSITION, &nTabStopPositions, TAB_ORIGIN); nMargin += nIndex; // Get commented text and set different color pomDC -> SetTextColor(DIALOG_COLOR); omStrTemp = omStr.Right( omStr.GetLength() - (nIndex)); omStr = ""; pomDC -> TextOut(DEFAULT_X_POS, (m_nCharHeight * (lInt+INCR_LEN)), acSourceLineNo); pomDC -> TabbedTextOut( ( nMargin) * m_nCharWidth, (m_nCharHeight * (lInt+INCR_LEN)), omStrTemp, TAB_POSITION, &nTabStopPositions, TAB_ORIGIN); nMargin += nIndex + 2; pomDC -> SetTextColor(BLUE_COLOR); } else { pomDC -> SetTextColor(BLUE_COLOR); } } if(lCurrentWarnLineNum == lInt+NEXT_POSITION) { bWarningLine = TRUE; // Get & save current color settings CurrentTextColor = pomDC -> GetTextColor(); CurrentBkColor = pomDC -> GetBkColor(); // Set the background mix mode to // opaque pomDC -> SetBkMode(OPAQUE); // Display the warning line in WHITE with RED // Background pomDC -> SetBkColor(RED_COLOR); pomDC -> SetTextColor(WHITE_COLOR); } pomDC -> TextOut(DEFAULT_X_POS, (m_nCharHeight * (lInt+INCR_LEN)), acSourceLineNo); pomDC -> TabbedTextOut( nMargin * m_nCharWidth, (m_nCharHeight * (lInt+INCR_LEN)), omStr, TAB_POSITION, &nTabStopPositions, TAB_ORIGIN); // Restore normal display colors and background // mix mode if(bWarningLine == TRUE) { pomDC -> SetTextColor(CurrentTextColor); pomDC -> SetBkColor(CurrentBkColor); pomDC -> SetBkMode(TRANSPARENT); bWarningLine = FALSE; } }// End of for(long lInt = defCOUNT_INIT; lInt < lLin.... }// End of if( Position!= nullptr) }// End of if(lLineCount > defCOUNT_INIT) pomDC -> SelectObject(pomOldFont); omNewFont.DeleteObject(); } } // end of if(pomDoc != nullptr) }
bool CWizard::make_project() { wizard.AddSymbol(info.ar_app[info.nAppType],true); wizard.AddSymbol("WINX_USE_CPP_FILES",info.bCppFiles); wizard.AddSymbol("WINX_USE_MENUBAR", info.bMenuBar); wizard.AddSymbol("WINX_USE_REBAR",info.bReBar); wizard.AddSymbol("WINX_USE_CMDBAR",info.bCmdBar); wizard.AddSymbol("WINX_USE_TOOLBAR",info.bToolBar); wizard.AddSymbol("WINX_USE_STATUSBAR",info.bStatusBar); wizard.AddSymbol("WINX_ENABLE_AX",info.bEnableActiveX); wizard.AddSymbol("WINX_USE_MANIFEST",info.bManifest); wizard.AddSymbol("WINX_HOST_AX",info.bHostActiveX); wizard.AddSymbol("WINX_USE_UNICODE",info.bUnicode); wizard.AddSymbol("WINX_USE_VIEW",info.bUseView); wizard.AddSymbol("PROJECT_LANG_"+info.ar_lang[info.nAppLang],true); wizard.AddSymbol("WINX_USE_GDIPLUS",info.bGdiPlus); wizard.AddSymbol("WINX_USE_ACCEL",info.bAccel); wizard.AddSymbol("WINX_USE_DDX",info.bDDX); wizard.AddSymbol("WINX_USE_DEFSDK",info.bDefSDK); if (info.bFrameDialog == false) { wizard.AddSymbol("WINX_USE_LOOKNFEEL",info.bLookNFeel); } wizard.AddSymbol("WINX_APPTYPE_DLG_FRAME",info.bFrameDialog); wizard.AddSymbol("WINX_USE_ADDVFCFILES",info.bAddVFCFiles); wizard.AddSymbol("PROJECT_NAME",info.strProjectName); wizard.AddSymbol("PROJECT_PATH",info.strProjectPath); wizard.AddSymbol("PROJECT_ENCODE","Windows-1252"); wizard.AddSymbol("PROJECT_GUID",wizard.make_guid()); wizard.AddSymbol("WINX_MAINDLG_CLASS","CMainDlg"); wizard.AddSymbol("WINX_MAINDLG_FILE","MainDlg"); if (info.nViewType == 6) { info.bEnableActiveX = true; } if (info.nAppType == 0) { if (info.bEnableActiveX) wizard.AddSymbol("WINX_MAINDLG_BASE_CLASS","winx::AxModelDialog"); else wizard.AddSymbol("WINX_MAINDLG_BASE_CLASS","winx::ModelDialog"); } else if (info.nAppType == 1) { if (info.bEnableActiveX) wizard.AddSymbol("WINX_MAINDLG_BASE_CLASS","winx::AxModelessDialog"); else wizard.AddSymbol("WINX_MAINDLG_BASE_CLASS","winx::ModelessDialog"); } if (info.bVS60) wizard.AddSymbol("PROJECT_VS60",true); if (info.bVS2002) wizard.AddSymbol("PROJECT_VS2002",true); if (info.bVS2003) wizard.AddSymbol("PROJECT_VS2003",true); if (info.bVS2005) wizard.AddSymbol("PROJECT_VS2005",true); if (info.bVS2008) wizard.AddSymbol("PROJECT_VS2008",true); if ( (info.bVS2005 || info.bVS2008) && info.bManifest) { wizard.AddSymbol("WINX_USE_EMBEDDED_MANIFEST", true); if (!info.bVS60 && !info.bVS2002 && !info.bVS2003) wizard.AddSymbol("WINX_USE_MANIFEST", false); } if (info.bVCExpress) { wizard.AddSymbol("WTL_USE_SDK_ATL3", true); } // Create symbols based on the project name CString strSafeProjectName = CreateSafeName(info.strProjectName); wizard.AddSymbol("SAFE_PROJECT_NAME", strSafeProjectName); CString tmp = strSafeProjectName.Left(1); tmp.MakeUpper(); tmp += strSafeProjectName.Right(strSafeProjectName.GetLength()-1); wizard.AddSymbol("NICE_SAFE_PROJECT_NAME", tmp); tmp.MakeUpper(); wizard.AddSymbol("UPPERCASE_SAFE_PROJECT_NAME", tmp); // Set current year symbol SYSTEMTIME st = {0}; ::GetLocalTime(&st); if(st.wYear >= 2003) { tmp.Format(_T("%d"),st.wYear); wizard.AddSymbol("WTL_CURRENT_YEAR", tmp); } // Set view symbols if(wizard.FindSymbol("WINX_USE_VIEW")) { CString strViewFile = info.strProjectName + "View"; wizard.AddSymbol("WINX_VIEW_FILE", strViewFile); CString strViewClass = "C" + wizard.FindSymbolVal("NICE_SAFE_PROJECT_NAME") + "View"; wizard.AddSymbol("WINX_VIEW_CLASS", strViewClass); wizard.AddSymbol("WINX_VIEW_CLASS_REG",wizard.FindSymbolVal("NICE_SAFE_PROJECT_NAME") + "View"); // wizard.AddSymbol("WTL_VIEWTYPE_GENERIC", false); // wizard.AddSymbol("WTL_VIEW_BASE_CLASS","CWindowImpl"); // wizard.AddSymbol("WTL_VIEW_STYLES","WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN"); // wizard.AddSymbol("WTL_VIEW_EX_STYLES","WS_EX_CLIENTEDGE"); switch(info.nViewType) { case 0: wizard.AddSymbol("WINX_VIEWTYPE_GENERIC",true); wizard.AddSymbol("WINX_VIEW_BASE_CLASS","winx::Window"); break; case 1: wizard.AddSymbol("WINX_VIEWTYPE_LISTBOX", true); wizard.AddSymbol("WINX_VIEW_BASE_CLASS", "winx::ListBox"); break; case 2: wizard.AddSymbol("WINX_VIEWTYPE_EDIT", true); wizard.AddSymbol("WINX_VIEW_BASE_CLASS", "winx::Edit"); break; case 3: wizard.AddSymbol("WINX_VIEWTYPE_LISTVIEW", true); wizard.AddSymbol("WINX_VIEW_BASE_CLASS", "winx::ListCtrl"); break; case 4: wizard.AddSymbol("WINX_VIEWTYPE_TREEVIEW", true); wizard.AddSymbol("WINX_VIEW_BASE_CLASS", "winx::TreeCtrl"); break; case 5: wizard.AddSymbol("WINX_VIEWTYPE_RICHEDIT", true); wizard.AddSymbol("WINX_VIEW_BASE_CLASS", "winx::RichEdit"); break; case 6: wizard.AddSymbol("WINX_VIEWTYPE_HTML", true); break; case 7: wizard.AddSymbol("WINX_VIEWTYPE_SCROLL", true); wizard.AddSymbol("WINX_VIEW_BASE_CLASS", "winx::ScrollWindow"); break; default: wizard.AddSymbol("WTL_VIEWTYPE_GENERIC", true); break; } if(wizard.FindSymbol("WINX_VIEWTYPE_HTML")) wizard.AddSymbol("WINX_USE_VIEW", false); } CString strInfFile = info.templatePath + "\\Templates.inf"; str_vector array; wizard.load_file_vector(strInfFile,array); CConfirmDlg dlg; dlg.m_projectPath = info.strProjectPath; CString t1,t2,t3; wizard.get_define_info(t1); wizard.get_output_info(t2); CString t4; for (str_vector::iterator it = array.begin(); it != array.end(); it++) { t4 = *it; t4.TrimLeft(); t4.TrimRight(); if (!t4.IsEmpty()) { t3 += _T(".\\")+GetTargetName(t4,info.strProjectName); t3 += _T("\r\n"); } } dlg.m_info = t1+_T("\r\n")+t2+_T("\r\n")+t3; if (dlg.DoModal() == IDOK) { return AddFilesToProject(info.strProjectName,info.strProjectPath,array); } else { wizard.clear(); return false; } return false; }
int _tmain() { BOOL videoFindFlag; CFileFind videoFileFind; const bool b_recordVide = false; //Record the color, depth, skeleton or not. CString label[18]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r'}; for (int l=0; l<18; l++) { CString folderName; folderName.Format("..\\output\\%02d", l); mkdir(folderName); CString fileFolderName; fileFolderName.Format("E:\\handShapeData\\%s\\*.oni", label[l]); videoFindFlag = TRUE; videoFindFlag = videoFileFind.FindFile(fileFolderName); int nSample = 0; while(videoFindFlag) { // Find the sign video videoFindFlag = videoFileFind.FindNextFile(); CString videoFileName = videoFileFind.GetFilePath(); Readvideo myReadVideo; CString personID = videoFileName.Right(24).Left(2); // Initial the video recording VideoWriter writer_depth; VideoWriter writer_skeleton; if (b_recordVide) { CString addName = videoFileName.Right(25).Left(10); string depthName = "..\\data\\" + addName + "_depth.avi"; string skeletonName = "..\\data\\" + addName + "_skeleton.avi"; CString colorName; colorName.Format("..\\data\\%s_color.avi", addName); writer_depth.open(depthName, CV_FOURCC('D', 'I', 'V', 'X'), 25.0, Size(r_width, r_heigth)); writer_skeleton.open(skeletonName, CV_FOURCC('D', 'I', 'V', 'X'), 25.0, Size(r_width, r_heigth)); CString colorOriName; colorOriName.Format("%s\\color.avi",videoFileName); CopyFile(colorOriName,colorName,TRUE); } // Read the sign video string s = (LPCTSTR)videoFileName; myReadVideo.readvideo(s); int frameSize = myReadVideo.vColorData.size(); cvNamedWindow("color_skeleton",1); cout<<"The total frame is: "<<frameSize<<endl; // Process each frame for (int i=0; i<frameSize; i++) { // File name of images to be saved. CString fileName; fileName.Format("..\\output\\%02d\\c%02d_p%s_%05d_color.jpg", l, l, personID, nSample); CString fileName_depth; fileName_depth.Format("..\\output\\%02d\\c%02d_p%s_%05d_depth.jpg", l, l, personID, nSample); nSample++; // color and depth images to be saved. IplImage* showImage; IplImage* showImage_depth; // Make color frame as the showImage showImage = myReadVideo.vColorData[i]; // Make depth frame as the showImage Mat depthMat = myReadVideo.retrieveGrayDepth(myReadVideo.vDepthData[i]); IplImage* depthImage = &(IplImage)depthMat; showImage_depth = cvCreateImage(cvGetSize(depthImage), 8, 1); for (int rows=0; rows<depthImage->height; rows++) { uchar* src_ptr = (uchar*)(depthImage->imageData + rows*depthImage->widthStep); uchar* des_ptr = (uchar*)(showImage_depth->imageData + rows*showImage_depth->widthStep); for (int cols=0; cols<depthImage->width; cols++) { if (src_ptr[3*cols] < 1) { des_ptr[cols] = 255; } else { des_ptr[cols] = src_ptr[3*cols]; } } } //---------------------------------------- //Record the sign postures CvRect hand_rect; int len_box = 64; hand_rect.x = myReadVideo.vSkeletonData[i]._2dPoint[11].x - len_box/2; hand_rect.y = myReadVideo.vSkeletonData[i]._2dPoint[11].y - len_box/2; hand_rect.height = len_box; hand_rect.width = len_box; cvSetImageROI(showImage, hand_rect); cvSaveImage(fileName, showImage); cvResetImageROI(showImage); cvSetImageROI(showImage_depth, hand_rect); cvSaveImage(fileName_depth, showImage_depth); cvResetImageROI(showImage_depth); //---------------------------------------- // Create black background // showImage = cvCreateImage(cvSize(width, height),8,3); // for (int rows=0; rows<height; rows++) // { // uchar* src_ptr = (uchar*)(showImage->imageData + rows*showImage->widthStep); // for (int cols=0; cols<width; cols++) // { // src_ptr[3*cols + 0] = 0; // src_ptr[3*cols + 1] = 0; // src_ptr[3*cols + 2] = 0; // } // } // for (int j=2; j<=11; j++) // { // CvPoint p1; // p1.x = myReadVideo.vSkeletonData[i]._2dPoint[j].x; // p1.y = myReadVideo.vSkeletonData[i]._2dPoint[j].y; // cvCircle(showImage,p1,2,cvScalar(225,0,0),3,8,0); // if (j!=7 && j!=3 && j!=11) // { // CvPoint p2; // p2.x = myReadVideo.vSkeletonData[i]._2dPoint[j+1].x; // p2.y = myReadVideo.vSkeletonData[i]._2dPoint[j+1].y; // cvLine(showImage,p1,p2,cvScalar(0,0,225),3,8,0); // } // if (j==2) // { // CvPoint p2; // p2.x = myReadVideo.vSkeletonData[i]._2dPoint[j+2].x; // p2.y = myReadVideo.vSkeletonData[i]._2dPoint[j+2].y; // CvPoint p3; // p3.x = myReadVideo.vSkeletonData[i]._2dPoint[j+6].x; // p3.y = myReadVideo.vSkeletonData[i]._2dPoint[j+6].y; // cvLine(showImage,p1,p2,cvScalar(0,0,225),3,8,0); // cvLine(showImage,p1,p3,cvScalar(0,0,225),3,8,0); // } // // } // // // // // // Segment right hand // _Vector4f left_elblow = myReadVideo.vSkeletonData[i]._3dPoint[9]; // _Vector4f left_hand = myReadVideo.vSkeletonData[i]._3dPoint[11]; // _Vector4f left_wrist = myReadVideo.vSkeletonData[i]._3dPoint[10]; // float len_arm = sqrt((float)((left_elblow.x - left_hand.x)*(left_elblow.x - left_hand.x) // + (left_elblow.y - left_hand.y)*(left_elblow.y - left_hand.y) // /*+ (left_elblow.z - left_hand.z)*(left_elblow.z - left_hand.z)*/)); // // // int len_bound_wid = 60; //len_arm*400; // int len_bound_hei = 80; //len_arm*500; // // _Vector2i left_elbow_2D = myReadVideo.vSkeletonData[i]._2dPoint[9]; // _Vector2i left_hand_2D = myReadVideo.vSkeletonData[i]._2dPoint[11]; // _Vector2i left_wrist_2D = myReadVideo.vSkeletonData[i]._2dPoint[10]; // // // int lt[2] = {-len_bound_wid/2, len_bound_hei/2}; // int rt[2] = {len_bound_wid/2, len_bound_hei/2}; // int lb[2] = {-len_bound_wid/2, -len_bound_hei/1.2}; // int rb[2] = {len_bound_wid/2, -len_bound_hei/1.2}; // // float co = (-left_elblow.y + left_wrist.y)/len_arm; // float si = (-left_elblow.x + left_wrist.x)/len_arm; // // //int lt_new[2]; // CvPoint lt_new; // lt_new.x = lt[0]*co + lt[1]*(-si) + left_hand_2D.x; // lt_new.y = lt[0]*(si) + lt[1]*co + left_hand_2D.y; // // //int rt_new[2]; // CvPoint rt_new; // rt_new.x = rt[0]*co + rt[1]*(-si) + left_hand_2D.x; // rt_new.y = rt[0]*(si) + rt[1]*co + left_hand_2D.y; // // //int lb_new[2]; // CvPoint lb_new; // lb_new.x = lb[0]*co + lb[1]*(-si) + left_hand_2D.x; // lb_new.y = lb[0]*(si) + lb[1]*co + left_hand_2D.y; // // //int rb_new[2]; // CvPoint rb_new; // rb_new.x = rb[0]*co + rb[1]*(-si) + left_hand_2D.x; // rb_new.y = rb[0]*(si) + rb[1]*co + left_hand_2D.y; // // // cvLine(showImage,lt_new, rt_new, cvScalar(0,255,0),3,8,0); // cvLine(showImage,rt_new, rb_new, cvScalar(0,255,0),3,8,0); // cvLine(showImage,rb_new, lb_new, cvScalar(0,255,0),3,8,0); // cvLine(showImage,lb_new, lt_new, cvScalar(0,255,0),3,8,0); cvShowImage("color_skeleton",showImage); if (b_recordVide) { writer_skeleton << showImage; //writer_depth << depthImage; } cvReleaseImage(&showImage_depth); cvWaitKey(10); } cvDestroyWindow("color_skeleton"); } } cout<<"Done!"<<endl; return 0; }
char CMagneticView::GetInput(bool& done, bool trans) { static const int MAX_HISTORY = 20; done = true; CMagneticApp* pApp = (CMagneticApp*)AfxGetApp(); CMagneticView* pView = CMagneticView::GetView(); if (pView == NULL) return 0; int cInput = 0; // Input character int iPosition = 0; // Current cursor position int iHistory = -1; // Current history position static CString strFullLine; // Input line already obtained? if (strFullLine.GetLength() > 0) { cInput = strFullLine[0]; strFullLine = strFullLine.Right(strFullLine.GetLength()-1); if (cInput == (signed char)(CMagneticView::SPECIAL_KEYS + VK_SPACE)) cInput = ' '; return (char)cInput; } if (pView->m_bMorePrompt) pView->m_PageTable.RemoveAt(pView->m_PageTable.GetSize()-1); else pView->m_PageTable.RemoveAll(); // Refresh the view pView->Invalidate(); pView->CaretOn(); pView->m_bInputActive = true; while (cInput != 10 && cInput != 1) { pView = CMagneticView::GetView(); if (pView == NULL) break; // Wait for a character CArray<int, int>& Input = pView->m_Input; if (Input.GetSize() == 0) { pApp->PumpMessage(); pApp->CWinApp::OnIdle(0); // Call base class OnIdle(); pView = CMagneticView::GetView(); if (pView) { CMagneticApp::Redraw Status = pApp->GetRedrawStatus(); switch (Status) { case CMagneticApp::Redraw::EndPlayback: done = false; // intentional fall-through case CMagneticApp::Redraw::EndLine: case CMagneticApp::Redraw::EndOpcode: Input.RemoveAll(); strFullLine.Empty(); if (Status == CMagneticApp::Redraw::EndOpcode) cInput = 1; else cInput = 10; // intentional fall-through case CMagneticApp::Redraw::ThisLine: pView->CaretOff(); pView->CaretOn(); pView->Invalidate(); break; } pView->SetCursorPos(pView->m_pTextDC,strFullLine.GetLength()-iPosition); } } else { cInput = (pView->m_bMorePrompt) ? 10 : Input[0]; Input.RemoveAt(0); int iInsertPos, iRemovePos; switch (cInput) { case 10: // Return strFullLine += (char)cInput; break; case CMagneticView::SPECIAL_KEYS + VK_LEFT: // Cursor left if (iPosition > 0) iPosition--; break; case CMagneticView::SPECIAL_KEYS + VK_RIGHT: // Cursor right if (iPosition < strFullLine.GetLength()) iPosition++; break; case CMagneticView::SPECIAL_KEYS + VK_HOME: // Home iPosition = 0; break; case CMagneticView::SPECIAL_KEYS + VK_END: // End iPosition = strFullLine.GetLength(); break; case CMagneticView::SPECIAL_KEYS + VK_DELETE: // Delete if (iPosition < strFullLine.GetLength()) { iRemovePos = strFullLine.GetLength() - iPosition; pView->RemoveChar(strFullLine,iRemovePos); pView->RemoveChar(pView->m_strOutput,iRemovePos,TRUE); } break; case 8: // Backspace if (iPosition > 0) { iRemovePos = strFullLine.GetLength() - iPosition + 1; pView->RemoveChar(strFullLine,iRemovePos); pView->RemoveChar(pView->m_strOutput,iRemovePos,TRUE); iPosition--; } break; case CMagneticView::SPECIAL_KEYS + VK_UP: // Cursor up if (iHistory < pView->m_History.GetSize()-1) iHistory++; if ((iHistory >= 0) && (pView->m_History.GetSize() > 0)) { int iOldLength = strFullLine.GetLength(); strFullLine = pView->m_History[iHistory]; pView->UseHistory(strFullLine,iOldLength); iPosition = strFullLine.GetLength(); } break; case CMagneticView::SPECIAL_KEYS + VK_DOWN: // Cursor down if (iHistory > 0) iHistory--; if ((iHistory >= 0) && (pView->m_History.GetSize() > 0)) { int iOldLength = strFullLine.GetLength(); strFullLine = pView->m_History[iHistory]; pView->UseHistory(strFullLine,iOldLength); iPosition = strFullLine.GetLength(); } break; case CMagneticView::SPECIAL_KEYS + VK_SPACE: // Space iInsertPos = strFullLine.GetLength() - iPosition; pView->InsertChar(pView->m_strOutput,(char)cInput,iInsertPos,TRUE); pView->InsertChar(strFullLine,(char)cInput,iInsertPos); iPosition++; break; default: if (isprint(cInput) && (cInput < CMagneticView::SPECIAL_KEYS)) { // Insert the character into the input string iInsertPos = strFullLine.GetLength() - iPosition; pView->InsertChar(pView->m_strOutput,(char)cInput,iInsertPos,TRUE); pView->InsertChar(strFullLine,(char)cInput,iInsertPos); iPosition++; } break; } // Update the input line pView->InvalidateRect(pView->m_LastLineRect,FALSE); } } if (pView && (strFullLine.GetLength() > 0)) { if (pView->m_bMorePrompt == false) { // Store in input history CString strHistory = strFullLine.Left(strFullLine.GetLength()-1); if (strHistory.GetLength() > 0) { pView->m_History.InsertAt(0,strHistory); if (pView->m_History.GetSize() > MAX_HISTORY) pView->m_History.RemoveAt(pView->m_History.GetSize()-1); } int i; while ((i = strHistory.Find((char)(CMagneticView::SPECIAL_KEYS + VK_SPACE))) >= 0) strHistory.SetAt(i,' '); // Input recording if ((pView->m_Recording == Recording::RecordingOn) && (pView->m_pFileRecord)) fprintf(pView->m_pFileRecord,"%s\n",strHistory); // Scrollback buffer pView->m_Scrollback.GetScrollback() += strHistory; // Scripting if (pView->m_Scripting == Scripting::ScriptingOn) pView->m_strScript += strHistory; } if (trans && (strFullLine.CompareNoCase("#undo\n") == 0)) { cInput = 0; strFullLine.Empty(); } else { cInput = strFullLine[0]; strFullLine = strFullLine.Right(strFullLine.GetLength()-1); } } if (pView) { pView->m_iLines = 0; pView->m_bInputActive = false; pView->CaretOff(); } if (cInput == (signed char)(CMagneticView::SPECIAL_KEYS + VK_SPACE)) cInput = ' '; return (char)cInput; }
//------------------------------------------------ // 파일의 리스트 및 각 파일에 대한 자세한 정보를 // 함께 저장하게 됨 // data.h파일에 해당 구조체를 선언한다. //-------------------------------------------------- void CMyExplorerDoc::SelectTreeViewFolder(CString strFullName) { LIST_VIEW* pListView; CFileFind ff; // 사용자가 폴더를 선택할 때마다 파일 리스트를 // 새로 업데이트 해야 함 // 따라서 기존 정보를 모두 삭제한다. if (m_pFileList != NULL) RemoveAllFileList(); m_pFileList = new CObList; SetCurrentPath(strFullName); strFullName += "*.*"; if (ff.FindFile(strFullName) == TRUE) { BOOL bFlag = TRUE; while(bFlag == TRUE) { bFlag = ff.FindNextFile(); // 디렉토리 , 도트파일이면 다시 찾음 if (ff.IsDirectory() || ff.IsDots()) continue; // 파일 정보를 알아내서LIST_VIEW 구조체에 // 저장한 후 // 그것을 모두 m_pFileList에 저장한다. pListView = new LIST_VIEW; InitListViewStruct(pListView); pListView->strName = ff.GetFileName(); pListView->strPath = ff.GetFilePath(); CString strName = pListView->strName; CString strExt = ff.GetFileTitle(); int nNum = strName.GetLength() - strExt.GetLength(); if (nNum == 0) strExt = ""; else strExt = strName.Right(nNum - 1); pListView->strKind = strExt + " 파일"; pListView->dwFileSize = ff.GetLength(); CTime time; if (ff.GetCreationTime(time) == TRUE) pListView->tCreateTime = time; if (ff.GetLastAccessTime(time) == TRUE) pListView->tLastAccessTime = time; if (ff.GetLastWriteTime(time) == TRUE) pListView->tLastWriteTime = time; if (ff.IsHidden() == TRUE) pListView->bIsHidden = TRUE; if (ff.IsReadOnly() == TRUE) pListView->bIsReadOnly = TRUE; if (ff.IsArchived() == TRUE) pListView->bIsArchived = TRUE; if (ff.IsSystem() == TRUE) pListView->bIsSystem = TRUE; m_pFileList->AddTail((CObject*)pListView); } } ff.Close(); //------------------------------ m_pExpListView->SetFileList(); //------------------------------------- }
void CTokenEx::SplitPath (BOOL UsingDirsOnly, CString Path, CString& Drive, CString& Dir, CString& FName, CString& Ext) { int nSecond; // Look for a UNC Name! if (Path.Left(2) == "\\\\") { // find the first '\' after the first two '\\' int nFirst = Path.Find("\\",3); // find the second '\' after the first one found nSecond = Path.Find("\\",nFirst + 1); // if the second does NOT exist if (nSecond == -1) { // add the 'Path' var to the 'Drive' var // because the passed var is just a UNC share // i.e.: '\\Server\Share' Drive = Path; // set ALL others to empty Dir = ""; FName = ""; Ext = ""; } else if (nSecond > nFirst) { // set the 'Drive' var with the correct info // i.e.: '\\Server\Share' Drive = Path.Left(nSecond); } } else { // Look for normal Drive Structure (C:\Dir\File.name) nSecond = 2; Drive = Path.Left(2); } // check if we are looking for directory or file if (UsingDirsOnly) { // load the correct information in the 'Dir' var Dir = Path.Right((Path.GetLength() - nSecond) - 1); // set ALL others to empty FName = ""; Ext = ""; } else { // this means we have a filename structure // first find the the '\' (in reverse) int nDirEnd = Path.ReverseFind('\\'); if (nDirEnd == Path.GetLength()) { // if we are here, this means that // 'C:\' was passed, so // set ALL to empty Dir = ""; FName = ""; Ext = ""; } else { // set the 'Dir' var with directory info Dir = Path.Mid(nSecond + 1, (nDirEnd - nSecond) - 1); // breakdown the filename // // look for a period '.' int nFileEnd = Path.ReverseFind('.'); // if it doesn't exist if (nFileEnd != -1) { if (nDirEnd > nFileEnd) { // this would also mean no file extension found FName = Path.Right(Path.GetLength() - nDirEnd); Ext = ""; } else { // fill vars with info FName = Path.Mid(nDirEnd + 1, (nFileEnd - nDirEnd) - 1); Ext = Path.Right((Path.GetLength() - nFileEnd) - 1); } } else { // this means filename w/o extention FName = Path.Right((Path.GetLength() - nDirEnd) - 1); Ext = ""; } } } }
//--------------------------------------------------------------------------- // ◎함수명 : CreateShortcut // ◎함수설명 : 바로가기를 만든다 // ◎인자 // strPathLink : 생성될 바로가기 파일의 경로와 이름 // strObjPath : 실행할 오브젝트 // strArgs : 실행시 인자 // strIcon : 사용될 아이콘 리소스 지정 (EXE, ICO 등) // strDesc : 마우스가 올라갈때 나타나는 툴팁 // ◎반환값 : 성공시 TRUE, 실패시 FALSE //--------------------------------------------------------------------------- BOOL COutputDialog::CreateShortcut(LPCTSTR strShortcutPath, LPCTSTR strObjPath, LPCTSTR strArgs, LPCTSTR strWorkingDir, LPCTSTR strIconPath, LPCTSTR strDesc) { BOOL bRetVal = FALSE; HRESULT hres = 0; IShellLink* psl = NULL; IPersistFile* ppf = NULL; //CString strMyPath = strPathLink; try { CString strTmpDir = _T(""); if(NULL == strShortcutPath || NULL == strObjPath || _T('\0') == strShortcutPath[0] || _T('\0') == strObjPath[0]) throw _T("파일 위치 지정이 잘못되었습니다."); if(NULL == strIconPath || _T('\0') == strIconPath) strIconPath = strObjPath; if(NULL == strWorkingDir || _T('\0') == strWorkingDir) { strTmpDir = strObjPath; int nIdx = strTmpDir.ReverseFind('\\'); if(nIdx > 0) strTmpDir = strTmpDir.Left(nIdx); else strTmpDir = _T(""); } else { strTmpDir = strWorkingDir; } ::CoInitialize(NULL); hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*) &psl); if (FAILED(hres)) throw _T("ShellLink 객체를 생성할 수 없습니다."); psl->SetPath(strObjPath); psl->SetIconLocation(strIconPath, 0); psl->SetWorkingDirectory(strTmpDir); if(strArgs && strArgs[0]) psl->SetArguments(strArgs); if(strDesc && strDesc[0]) psl->SetDescription(strDesc); hres = psl->QueryInterface( IID_IPersistFile, (LPVOID *) &ppf); if (FAILED(hres)) throw _T("IPersistFile 인터페이스를 얻어올 수 없습니다."); // 확장자를 검사하여 붙여줌 CString strMyPath = strShortcutPath; if(strMyPath.Right(4).CompareNoCase(_T(".lnk"))) strMyPath += _T(".lnk"); #ifdef UNICODE LPCWSTR wsz = (LPCWSTR)strMyPath; #else wchar_t wsz[MAX_PATH] = {0,}; MyMultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR)strMyPath, -1, wsz, MAX_PATH); #endif // 생성 DeleteFile(wsz); hres = ppf->Save(wsz, TRUE); if (hres != S_OK ) throw _T("IPersistFile->Save() 에러"); bRetVal = TRUE; } catch (LPCTSTR cszErr) { cszErr = cszErr; bRetVal = FALSE; } if(ppf) ppf->Release(); if(psl) psl->Release(); return bRetVal; }
void CLegendDisplay::AdjustLegend(LPCTSTR lpFilename) { CString strTmp; int index; char str2[255]; GetPrivateProfileString("ͼÀý","ÍÁ²ã±àºÅ","",str2,255,lpFilename); strTmp = str2; CString strLayerNo; CString strSubLayerNo; int j = strTmp.Find("^"); if (j>0) { strLayerNo = strTmp.Left(j); strSubLayerNo = strTmp.Right(strTmp.GetLength()-j-1); } else { strLayerNo = strTmp; strSubLayerNo = ""; } if (strLayerNo !="") { index = -1; for(int i=0;i<m_pGraphics->m_Blocks.GetSize();i++) { CADBlock* pBlock=(CADBlock*)m_pGraphics->m_Blocks.GetAt(i); if(_stricmp("ÍÁ²ã±àºÅ",pBlock->m_Name)==0) index = i; } if (index>-1) { int k = 1; CADBlock* pBlock=(CADBlock*)m_pGraphics->m_Blocks.GetAt(index); for(int j=0;j<pBlock->m_Entities.GetSize();j++) { CADEntity* pEntity=(CADEntity*)pBlock->m_Entities.GetAt(j); if (pEntity->GetType()==AD_ENT_MTEXT) { CADMText* pText = (CADMText*)pEntity; if (k==1) pText->m_Text = strLayerNo; else pText->m_Text = strSubLayerNo; k++; } } } } /////// GetPrivateProfileString("ͼÀý","±ê×¼¹áÈë","",str2,255,lpFilename); strTmp = str2; if (strTmp !="") { index = -1; for(int i=0;i<m_pGraphics->m_Blocks.GetSize();i++) { CADBlock* pBlock=(CADBlock*)m_pGraphics->m_Blocks.GetAt(i); if(_stricmp("±ê×¼¹áÈë",pBlock->m_Name)==0) index = i; } if (index>-1) { CADBlock* pBlock=(CADBlock*)m_pGraphics->m_Blocks.GetAt(index); for(int j=0;j<pBlock->m_Entities.GetSize();j++) { CADEntity* pEntity=(CADEntity*)pBlock->m_Entities.GetAt(j); if (pEntity->GetType()==AD_ENT_MTEXT) {//::AfxMessageBox(strTmp); CADMText* pText = (CADMText*)pEntity; //if (pText->m_Text=="8") pText->m_Text = strTmp; } } } } ///////// GetPrivateProfileString("ͼÀý","¿×ºÅ±ê¸ß","",str2,255,lpFilename); strTmp = str2; CString strUp; CString strDown; j = strTmp.Find("^"); if (j>0) { strUp = strTmp.Left(j); strDown = strTmp.Right(strTmp.GetLength()-j-1); } else { strUp = strTmp; strDown = ""; } if (strUp !="") { index = -1; for(int i=0;i<m_pGraphics->m_Blocks.GetSize();i++) { CADBlock* pBlock=(CADBlock*)m_pGraphics->m_Blocks.GetAt(i); if(_stricmp("¿×ºÅ±ê¸ß",pBlock->m_Name)==0) index = i; } if (index>-1) { int k = 1; CADBlock* pBlock=(CADBlock*)m_pGraphics->m_Blocks.GetAt(index); for(int j=0;j<pBlock->m_Entities.GetSize();j++) { CADEntity* pEntity=(CADEntity*)pBlock->m_Entities.GetAt(j); if (pEntity->GetType()==AD_ENT_MTEXT) { CADMText* pText = (CADMText*)pEntity; if (k==1) pText->m_Text = ""; else if (k==2) { pText->m_Text = strUp; pText->m_Location.x -= 1.5; } else if (k==3) pText->m_Text = strDown; k++; } } } } }
void COutWnd::OnDbClick() { INT nSelectIndex; CString omStrSelectedItem; nSelectIndex = m_omListBox.GetCurSel(); if(nSelectIndex!=LB_ERR ) { CString omStrLineNumber = ""; INT nIndex = 0; UINT unLineNumber = 0; char* pcStopStr = nullptr; m_omListBox.GetText(nSelectIndex,omStrSelectedItem); CString omStrFilePath; CString omStrFileName; omStrFilePath=omStrSelectedItem; while(!(nSelectIndex==0||omStrFilePath==defSTR_BUILD_TRACE_LINE_MARK)) { --nSelectIndex; m_omListBox.GetText(nSelectIndex,omStrFilePath); } if(omStrFilePath==defSTR_BUILD_TRACE_LINE_MARK) { ++nSelectIndex; m_omListBox.GetText(nSelectIndex,omStrFilePath); int nNameIndex = omStrFilePath.ReverseFind('\\'); if(nNameIndex != -1) { //pGetBusSpecificFunctionEditorDoc(omStrFilePath); CFunctionEditorDoc* pDoc = m_pGlobalObj->pGetDocPtrOfFile(omStrFilePath); if (pDoc != nullptr) { //If file is opened then get its frame and activate it { POSITION pos = pDoc->GetFirstViewPosition(); if (pos) { pDoc->GetNextView(pos)->GetParentFrame()->ActivateFrame(); } } } else { //If file is not opened then open it if ( !m_pGlobalObj->bOpenFunctioneditorfile(omStrFilePath) ) { AfxMessageBox("Specified filename not found!", MB_OK|MB_ICONINFORMATION); } } // Find the ':' to get the number after second ':' nIndex = omStrSelectedItem.Find(":"); if(nIndex!=-1) { omStrLineNumber = omStrSelectedItem.Right( omStrSelectedItem.GetLength()-nIndex-1); nIndex = omStrLineNumber.Find(":"); omStrLineNumber = omStrLineNumber.Right( omStrLineNumber.GetLength()-nIndex-1); omStrLineNumber.TrimLeft(); omStrLineNumber.TrimRight(); omStrLineNumber = omStrLineNumber.SpanExcluding(":"); unLineNumber = _tcstol((LPCTSTR)omStrLineNumber, &pcStopStr,10); // Call this function only if the line number is valid if(unLineNumber!=0) { CFileView* pFileView = m_pGlobalObj->podGetFileViewPtr(); if(pFileView != nullptr) { pFileView->vDisplayWarningLineNumber(OUTWND,unLineNumber); } } } else { nIndex = omStrSelectedItem.Find(":"); if(nIndex!=-1) { nIndex = omStrSelectedItem.Find(":"); omStrLineNumber = omStrSelectedItem.Right( omStrSelectedItem.GetLength()-nIndex-1); omStrLineNumber.TrimLeft(); omStrLineNumber.TrimRight(); omStrLineNumber = omStrLineNumber. SpanExcluding("\t "); unLineNumber = _tcstol((LPCTSTR)omStrLineNumber, &pcStopStr, 10); if(unLineNumber!=0) { CFileView* pFileView = m_pGlobalObj->podGetFileViewPtr(); if(nullptr != pFileView) { pFileView->vDisplayWarningLineNumber(OUTWND, unLineNumber); } } } } } } } }
void CCloneDlg::OnCbnEditchangeUrlcombo() { // do not update member variables from UI while saving if (m_bSaving || m_bExactPath) return; this->UpdateData(); CString url; m_URLCombo.GetWindowText(url); url.Trim(); if(m_OldURL == url ) return; m_OldURL=url; //if(url.IsEmpty()) // return; CString old; old=m_ModuleName; url.Replace(_T('\\'),_T('/')); // add compatibility for Google Code git urls url.TrimRight(L"/"); int start=url.ReverseFind(_T('/')); if(start<0) { start = url.ReverseFind(_T(':')); if(start <0) start = url.ReverseFind(_T('@')); if(start<0) start = 0; } CString temp; temp=url.Mid(start+1); temp=temp.MakeLower(); // we've to check whether the URL ends with .git (instead of using the first .git) int end = temp.Right(4) == _T(".git") ? (temp.GetLength() - 4) : temp.GetLength(); //CString modulename; m_ModuleName=url.Mid(start+1,end); start = m_Directory.ReverseFind(_T('\\')); if(start <0 ) start = m_Directory.ReverseFind(_T('/')); if(start <0 ) start =0; int dirstart=m_Directory.Find(old,start); if(dirstart>=0 && (dirstart+old.GetLength() == m_Directory.GetLength()) ) m_Directory=m_Directory.Left(dirstart); m_Directory.TrimRight(L"\\/"); m_Directory += _T('\\'); m_Directory += m_ModuleName; // check if URL starts with http://, https:// or git:// in those cases loading putty keys is only // asking for passwords for keys that are never used if (url.Find(L"http://", 0) >= 0 || url.Find(L"https://", 0) >= 0 || url.Find(L"git://", 0) >= 0) m_bAutoloadPuttyKeyFile = false; else m_bAutoloadPuttyKeyFile = m_regUseSSHKey && CAppUtils::IsSSHPutty(); this->UpdateData(FALSE); }
void CLegendDisplay::CreateLegend(const char* legendName,double legendLeft,double legendTop) { //check special legend--------------------- short curLayerIndex = m_pLayerGroup->indexOf("0"); CADPolyline* pPolyline; ADPOINT* pPoint; pPolyline=new CADPolyline(); m_pGraphics->m_Entities.Add((CObject*)pPolyline); pPolyline->m_nLayer = curLayerIndex; pPolyline->m_Closed=true; pPolyline->m_nLineWidth=1; pPoint=new ADPOINT(); pPoint->x = legendLeft; pPoint->y = legendTop; pPolyline->m_Point.Add((CObject*)pPoint); pPoint=new ADPOINT(); pPoint->x = legendLeft+m_LegendWidth; pPoint->y = legendTop; pPolyline->m_Point.Add((CObject*)pPoint); pPoint=new ADPOINT(); pPoint->x = legendLeft+m_LegendWidth; pPoint->y = legendTop-m_LegendHeight; pPolyline->m_Point.Add((CObject*)pPoint); pPoint=new ADPOINT(); pPoint->x = legendLeft; pPoint->y = legendTop-m_LegendHeight; pPolyline->m_Point.Add((CObject*)pPoint); CADHatch* pHatch=new CADHatch(); m_pGraphics->m_Entities.Add((CObject*)pHatch); pHatch->m_Scale = 10.0; pHatch->m_nLayer = curLayerIndex; pHatch->m_pPolyline=pPolyline; //update //strcpy(pHatch->m_Name,legendName); CString strTmp; CString strCN,strEN; strTmp = legendName; int j = strTmp.Find(m_SplitChar); if (j>0) { strCN = strTmp.Left(j); strEN = strTmp.Right(strTmp.GetLength()-j-1); } else { strCN = strTmp; } strcpy(pHatch->m_Name,strCN); //check special legend--------------------- short SpecialLegendCount = 5; char SpecialLegendChar[] = {'f','x','z','c','l'}; int legendCharIndex = -1; if (strcmp(strCN,"·Ûɰ")==0) { strcpy(pHatch->m_Name,"ɰ"); legendCharIndex = 0; } else if (strcmp(strCN,"·Ûϸɰ")==0) { strcpy(pHatch->m_Name,"ɰ"); legendCharIndex = 0; } else if (strcmp(strCN,"·Ûɰ¼Ðϸɰ")==0) { strcpy(pHatch->m_Name,"ɰ"); legendCharIndex = 0; } //updated on 20070207 else if (strcmp(strCN,"·Ûɰ¼Ð·ÛÍÁ")==0) { strcpy(pHatch->m_Name,"º¬Õ³ÐÔÍÁ·Ûɰ"); legendCharIndex = 0; } //added on 20070207 else if (strcmp(strCN,"·Ûɰ¼ÐÑÇɰÍÁ")==0) { strcpy(pHatch->m_Name,"º¬Õ³ÐÔÍÁ·Ûɰ"); legendCharIndex = 0; } else if (strcmp(strCN,"ϸɰ")==0) { strcpy(pHatch->m_Name,"ɰ"); legendCharIndex = 1; } else if (strcmp(strCN,"ÖÐɰ")==0) { strcpy(pHatch->m_Name,"ɰ"); legendCharIndex = 2; } else if (strcmp(strCN,"ÖÐϸɰ")==0) { strcpy(pHatch->m_Name,"ɰ"); legendCharIndex = 2; } else if (strcmp(strCN,"ÖдÖɰ")==0) { strcpy(pHatch->m_Name,"ɰ"); legendCharIndex = 2; } else if (strcmp(strCN,"´Öɰ")==0) { strcpy(pHatch->m_Name,"ɰ"); legendCharIndex = 3; } else if (strcmp(strCN,"Àùɰ")==0) { strcpy(pHatch->m_Name,"ɰ"); legendCharIndex = 4; } else if (strcmp(strCN,"·ÛɰÑÒ")==0) { strcpy(pHatch->m_Name,"ɰÑÒ"); legendCharIndex = 0; } else if (strcmp(strCN,"ϸɰÑÒ")==0) { strcpy(pHatch->m_Name,"ɰÑÒ"); legendCharIndex = 1; } else if (strcmp(strCN,"ÖÐɰÑÒ")==0) { strcpy(pHatch->m_Name,"ɰÑÒ"); legendCharIndex = 2; } else if (strcmp(strCN,"´ÖɰÑÒ")==0) { strcpy(pHatch->m_Name,"ɰÑÒ"); legendCharIndex = 3; } else if (strcmp(strCN,"º¬Àù·ÛɰÑÒ")==0) { legendCharIndex = 0; } /*else if (strcmp(legendName,"·Ûɰ¼Ð·ÛÍÁ")==0) { strcpy(pHatch->m_Name,"ɰÖÊ·ÛÍÁ"); legendCharIndex = 0; }*/ else if (strcmp(strCN,"º¬Àùɰ·ÛÖÊÕ³ÍÁ")==0) { legendCharIndex = 4; } else if (strcmp(strCN,"º¬ÀùɰճÍÁ")==0) { legendCharIndex = 4; } else if (strcmp(strCN,"º¬ÀùɰÓÙÄàÖÊ·ÛÖÊÕ³ÍÁ")==0) { legendCharIndex = 4; } else if (strcmp(strCN,"º¬Õ³ÐÔÍÁ·Ûɳ")==0) { legendCharIndex = 0; } else if (strcmp(strCN,"º¬Õ³ÐÔÍÁϸɳ")==0) { legendCharIndex = 1; } else if (strcmp(strCN,"º¬Õ³ÐÔÍÁÖÐɳ")==0) { legendCharIndex = 2; } else if (strcmp(strCN,"º¬Õ³ÐÔÍÁ´Öɳ")==0) { legendCharIndex = 3; } else if (strcmp(strCN,"º¬Õ³ÐÔÍÁÀùɳ")==0) { legendCharIndex = 4; } //----------------------------------------- //CreateHatch(legendName,pPolyline,curLayerIndex); //special legend-------------------------------- if(legendCharIndex>-1) { CADMText* pMText; pMText=new CADMText(); m_pGraphics->m_Entities.Add((CObject*)pMText); pMText->m_nLayer = curLayerIndex; pMText->m_Text=SpecialLegendChar[legendCharIndex]; pMText->m_Height=2.5; pMText->m_Align=AD_MTEXT_ATTACH_MIDDLECENTER; ADPOINT* pPoint = (ADPOINT*)pPolyline->m_Point.GetAt(0); pMText->m_Location.x = pPoint->x; pMText->m_Location.y = pPoint->y; pPoint = (ADPOINT*)pPolyline->m_Point.GetAt(1); pMText->m_Location.x += pPoint->x; pMText->m_Location.x /= 2; pPoint = (ADPOINT*)pPolyline->m_Point.GetAt(2); pMText->m_Location.y += pPoint->y; pMText->m_Location.y /= 2; } //------------------------------------------------------ CADMText* pMText; pMText=new CADMText(); m_pGraphics->m_Entities.Add((CObject*)pMText); pMText->m_nLayer = curLayerIndex; pMText->m_Align=AD_MTEXT_ATTACH_MIDDLELEFT; //pMText->m_Text=legendName; pMText->m_Text = strEN; strcpy(pMText->m_Font,ENFONTNAME); pMText->m_Height=3.5; pMText->m_Width=m_MTextWidth; pMText->m_Location.x=legendLeft+m_LegendWidth+6; pMText->m_Location.y=legendTop-m_LegendHeight/2; pMText->m_isWarp = true; }
bool CCommonAppUtils::FileOpenSave(CString& path, int * filterindex, UINT title, UINT filter, bool bOpen, HWND hwndOwner, LPCTSTR defaultExt) { OPENFILENAME ofn = {0}; // common dialog box structure TCHAR szFile[MAX_PATH] = {0}; // buffer for file name. Explorer can't handle paths longer than MAX_PATH. ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwndOwner; if (path.GetLength() >= MAX_PATH) { CString dir = path; while (true) { int index = dir.ReverseFind(_T('\\')); if (index < 0) break; dir = dir.Left(index); if (PathFileExists(dir)) break; } GetShortPathName(dir, szFile, MAX_PATH); CString remain = path.Right(path.GetLength() - dir.GetLength()); _tcscat_s(szFile, MAX_PATH, remain); } else _tcscpy_s(szFile, MAX_PATH, (LPCTSTR)path); ofn.lpstrFile = szFile; ofn.nMaxFile = _countof(szFile); CSelectFileFilter fileFilter; if (filter) { fileFilter.Load(filter); ofn.lpstrFilter = fileFilter; } ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.lpstrDefExt = defaultExt; CString temp; if (title) { temp.LoadString(title); CStringUtils::RemoveAccelerators(temp); } ofn.lpstrTitle = temp; if (bOpen) ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER; else ofn.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER; // Display the Open dialog box. bool bRet = false; if (bOpen) { bRet = !!GetOpenFileName(&ofn); } else { bRet = !!GetSaveFileName(&ofn); } SetCurrentDirectory(sOrigCWD.GetBuffer()); sOrigCWD.ReleaseBuffer(); if (bRet) { path = CString(ofn.lpstrFile); if (filterindex) *filterindex = ofn.nFilterIndex; return true; } return false; }
BOOL CSelectFunctions::bFormatFunctionPrototype(CString &omStrFunctionPrototype) { BOOL bReturn = TRUE; CStringArray omStrArrayParaType; CString omStrReturnType = ""; CString omStrFuncName = ""; if(m_omStrSelectedText.IsEmpty() == 0 ) { CString omStrTemp = m_omStrSelectedText; omStrTemp = omStrTemp.Right(omStrTemp.GetLength() - omStrTemp.Find(" ") - 1 ); omStrTemp.TrimLeft(); omStrTemp.TrimRight(); omStrReturnType = m_omStrSelectedText; omStrReturnType.Replace(omStrTemp, ""); INT nIndex = 0; nIndex = omStrTemp.Find("("); omStrFuncName = omStrTemp.Left(nIndex); omStrTemp = omStrTemp.Right(omStrTemp.GetLength() - nIndex - 1); omStrTemp = omStrTemp.Left( omStrTemp.Find(")")); while(omStrTemp.IsEmpty() == 0) { nIndex = omStrTemp.Find(","); if(nIndex != -1) { omStrArrayParaType.Add(omStrTemp.Left(nIndex)); } else { omStrArrayParaType.Add(omStrTemp); omStrTemp = ""; } omStrTemp = omStrTemp.Right(omStrTemp.GetLength() - nIndex - 1 ); } omStrReturnType.TrimLeft(); omStrReturnType.TrimRight(); omStrFuncName.TrimLeft(); omStrFuncName.TrimRight(); if(omStrReturnType.CompareNoCase(_T("void")) !=0) { omStrFunctionPrototype = defTODO_FUNCTION_INSERT; omStrFunctionPrototype += defNEW_LINE; omStrFunctionPrototype += _T("/* "); omStrFunctionPrototype += omStrReturnType; omStrFunctionPrototype += _T(" "); omStrFunctionPrototype += defRETURN_TYPE_NAME; omStrFunctionPrototype += _T(" ;*/"); } UINT unCount = (COMMANUINT)omStrArrayParaType.GetSize(); omStrFuncName += _T("("); for(UINT i = 0; i<unCount ;i++) { omStrTemp = omStrArrayParaType.GetAt(i); omStrTemp.TrimLeft(); omStrTemp.TrimRight(); omStrFunctionPrototype += defNEW_LINE; omStrFunctionPrototype += "/* "; omStrFunctionPrototype += omStrTemp; omStrTemp = ""; omStrTemp.Format(defPARAMETER_NAME,i+1); omStrFunctionPrototype += " "; omStrFunctionPrototype +=omStrTemp; omStrFunctionPrototype += " ;*/"; omStrFuncName +=omStrTemp; if(i != unCount - 1 ) { omStrFuncName += _T(","); } } omStrFuncName += _T(")"); if(omStrReturnType.CompareNoCase(_T("void")) !=0) { omStrFunctionPrototype += defNEW_LINE; omStrFunctionPrototype += defRETURN_TYPE_NAME; omStrFunctionPrototype += _T(" = "); } omStrFunctionPrototype += omStrFuncName; omStrFunctionPrototype += _T(";"); omStrFunctionPrototype += defNEW_LINE; } return bReturn; }
CString CPicapDoc::GetFileNameByPath(CString path) const { return path.Right(path.GetLength() - path.ReverseFind(_T('\\')) - 1); }
int CCachedDirectory::EnumFiles(const CTGitPath &path , bool IsFull) { CString sProjectRoot; path.HasAdminDir(&sProjectRoot); CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": EnumFiles %s\n"), path.GetWinPath()); ATLASSERT( !m_directoryPath.IsEmpty() ); CString sSubPath; CString s = path.GetWinPath(); if (s.GetLength() > sProjectRoot.GetLength()) { // skip initial slash if necessary if(s[sProjectRoot.GetLength()] == _T('\\')) sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() -1); else sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() ); } // strip "\" at the end, otherwise cache lookups for drives do not work correctly sProjectRoot.TrimRight(_T("\\")); GitStatus *pStatus = &CGitStatusCache::Instance().m_GitStatus; UNREFERENCED_PARAMETER(pStatus); git_wc_status_kind status = git_wc_status_none; if (!path.IsDirectory()) { bool assumeValid = false; bool skipWorktree = false; pStatus->GetFileStatus(sProjectRoot, sSubPath, &status, IsFull, false, true, GetStatusCallback, this, &assumeValid, &skipWorktree); if (status < m_mostImportantFileStatus) RefreshMostImportant(); } else { bool isSelf = path == m_directoryPath; if (isSelf) { AutoLocker lock(m_critSec); // clear subdirectory status cache m_childDirectories.clear(); // build new files status cache m_entryCache_tmp.clear(); } m_mostImportantFileStatus = git_wc_status_none; pStatus->EnumDirStatus(sProjectRoot, sSubPath, &status, IsFull, false, true, GetStatusCallback,this); m_mostImportantFileStatus = GitStatus::GetMoreImportant(m_mostImportantFileStatus, status); if (isSelf) { AutoLocker lock(m_critSec); // use a tmp files status cache so that we can still use the old cached values // for deciding whether we have to issue a shell notify m_entryCache = m_entryCache_tmp; m_entryCache_tmp.clear(); } // need to set/construct m_ownStatus (only unversioned and normal are valid values) m_ownStatus = git_wc_status_unversioned; m_ownStatus.SetKind(git_node_dir); if (m_mostImportantFileStatus > git_wc_status_unversioned) { git_wc_status2_t status2; status2.text_status = status2.prop_status = git_wc_status_normal; m_ownStatus.SetStatus(&status2); } else { if (::PathFileExists(m_directoryPath.GetWinPathString() + _T("\\.git"))) { git_wc_status2_t status2; status2.text_status = status2.prop_status = git_wc_status_normal; m_ownStatus.SetStatus(&status2); } else { git_wc_status2_t status2; status2.text_status = status2.prop_status = CalculateRecursiveStatus(); m_ownStatus.SetStatus(&status2); } } } return 0; }
void CScriptEdit::OnSaveasGeneral(int type) { char BASED_CODE *szFilter; CString tmpstr; CString newname; int fhandle; int res; if(readonly) { MessageBox("You opened it read only!","Warning",MB_ICONEXCLAMATION|MB_OK); return; } res=OFN_HIDEREADONLY|OFN_ENABLESIZING|OFN_EXPLORER; if(type!=-1) m_bcs=type; szFilter=szFilterb; if(m_bcs) { //szFilter=szFiltera; tmpstr=bgfolder+"override\\"+itemname; } else { //szFilter=szFilterb; tmpstr=makeitemname(".baf",1); } CMyFileDialog m_getfiledlg(FALSE, m_bcs?"bcs":"baf", tmpstr, res, szFilter); m_getfiledlg.m_ofn.nFilterIndex = m_bcs+1; restart: if( m_getfiledlg.DoModal() == IDOK ) { filepath=m_getfiledlg.GetPathName(); filepath.MakeLower(); if(filepath.Right(4)==".baf") m_bcs=0; else if(filepath.Right(4)==".bcs") m_bcs=1; //this is the default if(m_bcs) { if(filepath.Right(4)!=".bcs") filepath+=".bcs"; lastopenedoverride=filepath.Left(filepath.ReverseFind('\\')); } else { if(filepath.Right(4)!=".baf") filepath+=".baf"; lastopenedscript=filepath.Left(filepath.ReverseFind('\\')); } newname=m_getfiledlg.GetFileName(); newname.MakeUpper(); if(newname.Right(4)==".BCS") newname=newname.Left(newname.GetLength()-4); else if(newname.Right(4)==".BAF") newname=newname.Left(newname.GetLength()-4); if(newname.GetLength()>8 || newname.GetLength()<1 || newname.Find(" ",0)!=-1) { tmpstr.Format("The resource name '%s' is wrong, it should be 8 characters long and without spaces.",newname); MessageBox(tmpstr,"Warning",MB_ICONEXCLAMATION|MB_OK); goto restart; } if(newname!=itemname && file_exists(filepath) ) { res=MessageBox("Do you want to overwrite "+newname+"?","Warning",MB_ICONQUESTION|MB_YESNO); if(res==IDNO) goto restart; } itemname=newname; res=0; if(filepath.Right(4)==".bcs") { chdir(bgfolder); tmpstr=bgfolder+weidudecompiled; assure_dir_exists(tmpstr); if(!dir_exists(tmpstr) ) { res=-3; } else tmpstr+="\\"+newname+".baf"; } if(!res) { fhandle=creat(tmpstr,S_IWRITE); if(fhandle>0) { //this is the intended way of extracting info from a richedit control res=writestream(fhandle,m_text_control); close(fhandle); } else res=-2; if(m_bcs) { if(!res) res=compile(tmpstr); } } switch(res) { case -3: newname.Format("Cannot create output path:%s",tmpstr); MessageBox(tmpstr,"Script editor",MB_ICONSTOP|MB_OK); break; case -2: newname.Format("Cannot create file:%s",tmpstr); MessageBox(tmpstr,"Script editor",MB_ICONSTOP|MB_OK); break; case 0: if(m_bcs) MessageBox("Script saved and compiled...","Script editor",MB_ICONINFORMATION|MB_OK); else MessageBox("Script saved...","Script editor",MB_ICONINFORMATION|MB_OK); break; default: MessageBox("Error during save.","Script editor",MB_ICONSTOP|MB_OK); } } UpdateData(UD_DISPLAY); the_script.m_changed=false; CheckScript(0); RefreshDialog(); }
void CEditorAction::Render(CRect &Pos, CDC& dc,bool EventSelected, CChronoEventEditor& Ed, int renderType, bool bEnabled) { COLORREF ActionBG =m_select(&Ed)? ACTION_BG_SEL : (EventSelected? ACTION_BG_EVSEL : ACTION_BG); // Animating if(m_Anim.m_bDestroyed) { if(renderType == 3) { Pos.OffsetRect(0,m_Anim.Space); } if(renderType == 1) { Pos.OffsetRect(-30 + m_Anim.Space, 0); } //dc.FillSolidRect(Calc,BG); return; } switch(renderType) { /* case 0: { if(m_select(&Ed)) { dc.FillSolidRect(Pos,ActionBG); dc.Draw3dRect(Pos,ACTION_BG_SEL2,ACTION_BG_SEL2); } HBITMAP load = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_DOT)); HDC hdcScreenCompat = CreateCompatibleDC(dc.m_hDC); HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcScreenCompat, load); BitBlt(dc.m_hDC, Pos.left + 1, Pos.top + 1, 16, 16, hdcScreenCompat, 0, 0, SRCCOPY); SelectObject(hdcScreenCompat, hbmpOld); DeleteDC(hdcScreenCompat); DeleteObject(load); } break;*/ case 1: { if(m_select(&Ed)) { Pos.InflateRect(3,3); dc.FillSolidRect(Pos,ActionBG); dc.Draw3dRect(Pos,ACTION_BG_SEL2,ACTION_BG_SEL2); Pos.DeflateRect(3,3); } int icon = 0; if(m_Family) ((EventSheetEditor*)(&Ed))->m_familyhbitmaps.Lookup(oid, icon); else ((EventSheetEditor*)(&Ed))->m_objecthbitmaps.Lookup(oid, icon); static HDC dcMem = CreateCompatibleDC(dc.m_hDC); HBITMAP old = (HBITMAP)SelectObject(dcMem, Ed.GetIcon(icon)); BitBlt(dc.m_hDC,Pos.left, Pos.top ,16 ,16,dcMem,0,0,SRCCOPY); SelectObject(dcMem, old); //DeleteDC(dcMem); - its static so we cant delete it m_Anim.Space = 30; } break; case 2: { CHTMLFont f; f.SetBold(false); f.SetSize(8); f.SetName("Arial"); f.SetImage(false); if (!bEnabled) f.SetStrike(true); CRect Calc = Pos; Calc.bottom += m_rect(&Ed).Height(); // Draw the action CString Out = m_Text; g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,¶ms); m_Readable = Out; Pos.bottom = Pos.top + Calc.Height(); Calc = Pos; dc.FillSolidRect(Pos,ActionBG); // We may be hovering over something. CPoint mouse; GetCursorPos(&mouse); Ed.ScreenToClient(&mouse); if(Pos.PtInRect(mouse) && m_select(&Ed)) { for(int p = 0; p < params.size(); p++) for(int d = 0; d < params[p]->displayrects.size(); d++) if(params[p]->displayrects[d].PtInRect(mouse)) { for(int a = 0; a < params[p]->displayrects.size(); a++) dc.FillSolidRect(params[p]->displayrects[a], RGB(100,255,100)); continue; } } // End hover Out = m_Text; g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,¶ms); m_Readable = Out; if(m_select(&Ed)) dc.Draw3dRect(Calc,ACTION_BG_SEL2,ACTION_BG_SEL2); } break; case 3: { CHTMLFont f; f.SetBold(false); f.SetSize(8); f.SetName("Arial"); f.SetImage(false); if (!bEnabled) f.SetStrike(true); CRect Calc = Pos; Calc.bottom += m_rect(&Ed).Height(); CString newtext; CObjType* objectType = ((EventSheetEditor*)&Ed)->application->FindObjTypeFromNumber(oid); int icon = 0; if(m_Family) ((EventSheetEditor*)(&Ed))->m_familyhbitmaps.Lookup(oid, icon); else ((EventSheetEditor*)(&Ed))->m_objecthbitmaps.Lookup(oid, icon); bool show_name = true; bool show_icon = true; bool show_quotes = true; if (m_Text.Find("#noname") != -1) show_name = false; if (m_Text.Find("#noicon") != -1) show_icon = false; if (m_Text.Find("#noquotes") != -1) show_quotes = false; CString display_text = m_Text; display_text.Replace("#noname", ""); display_text.Replace("#noicon", ""); display_text.Replace("#noquotes", ""); if (!show_quotes) display_text.Replace("\"", ""); if (show_name && show_icon) newtext.Format("<img>%d</img> %s: %s", icon, objectType->GetName(), display_text); else if (show_name && !show_icon) newtext.Format("%s: %s", objectType->GetName(), display_text); else if (!show_name && show_icon) newtext.Format("<img>%d</img> %s", icon, display_text); else newtext.Format("%s", display_text); CString Out = newtext; g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,¶ms); dc.FillSolidRect(Calc,ActionBG); //We may be hovering over something. CPoint mouse; GetCursorPos(&mouse); Ed.ScreenToClient(&mouse); if(Calc.PtInRect(mouse) && m_select(&Ed)) { for(int p = 0; p < params.size(); p++) for(int d = 0; d < params[p]->displayrects.size(); d++) if(params[p]->displayrects[d].PtInRect(mouse)) { for(int a = 0; a < params[p]->displayrects.size(); a++) dc.FillSolidRect(params[p]->displayrects[a], RGB(100,255,100)); continue; } } // End hover Calc = Pos; Calc.bottom += m_rect(&Ed).Height(); // Get readable text g_HTMLDraw.DrawText(&dc, newtext, f, Calc, 0, &Ed, &m_imgs,¶ms); m_Readable = newtext.Right(newtext.GetLength() - newtext.ReverseFind(':')); Pos.bottom = Pos.top + Calc.Height(); if(m_select(&Ed)) dc.Draw3dRect(Calc,ACTION_BG_SEL2,ACTION_BG_SEL2); m_Anim.Space = Calc.Height(); } break; } m_visible = true; m_rect(&Ed) = Pos; if(renderType == 1) { Pos.InflateRect(3,3); m_rect(&Ed) = Pos; Pos.DeflateRect(3,3); } }
void CRegisterMonitorDlg::OnBnClickedBtnOpen() { // TODO: Add your control notification handler code here wchar_t PortNumber[100]; m_port.GetWindowTextW(PortNumber,100); CString tempcs = PortNumber; tempcs = tempcs.Right(tempcs.GetLength()-3); int comport = _wtoi(tempcs); CString reg_cs_temp; if(!m_port_open) { if(OnConnect(comport)) { m_port.EnableWindow(FALSE); m_reg_edit1.EnableWindow(FALSE); m_reg_edit2.EnableWindow(FALSE); m_reg_edit3.EnableWindow(FALSE); m_reg_edit4.EnableWindow(FALSE); m_reg_edit5.EnableWindow(FALSE); m_device_edit.EnableWindow(FALSE); m_combo_reg.EnableWindow(TRUE); ((CEdit *)GetDlgItem(IDC_EDIT_WRITE))->EnableWindow(TRUE); ((CButton *)GetDlgItem(IDC_BUTTON1))->EnableWindow(1); SetDlgItemTextW(IDC_BTN_OPEN,_T("Close")); m_port_open = true; UpdateData(FALSE); m_reg_edit1.GetWindowText(reg_cs_temp); m_reg_address1 = _wtoi(reg_cs_temp); reg_cs_temp.Empty(); m_reg_edit2.GetWindowText(reg_cs_temp); m_reg_address2 = _wtoi(reg_cs_temp); reg_cs_temp.Empty(); m_reg_edit3.GetWindowText(reg_cs_temp); m_reg_address3 = _wtoi(reg_cs_temp); reg_cs_temp.Empty(); m_reg_edit4.GetWindowText(reg_cs_temp); m_reg_address4 = _wtoi(reg_cs_temp); reg_cs_temp.Empty(); m_reg_edit5.GetWindowText(reg_cs_temp); m_reg_address5 = _wtoi(reg_cs_temp); reg_cs_temp.Empty(); m_device_edit.GetWindowText(reg_cs_temp); m_device_ID = _wtoi(reg_cs_temp); reg_cs_temp.Empty(); SetTimer(1,1000,NULL); suspend_thread =false; if(hFirstThread==NULL) hFirstThread = CreateThread(NULL,NULL,ReadRegAddress,this,NULL,0); if(hWriteThread==NULL) hWriteThread = CreateThread(NULL,NULL,WriteRegAddress,this,NULL,&nThreadID); } } else { OnDisconnect(); m_port.EnableWindow(1); m_reg_edit1.EnableWindow(1); m_reg_edit2.EnableWindow(1); m_reg_edit3.EnableWindow(1); m_reg_edit4.EnableWindow(1); m_reg_edit5.EnableWindow(1); m_device_edit.EnableWindow(1); m_combo_reg.EnableWindow(0); ((CEdit *)GetDlgItem(IDC_EDIT_WRITE))->EnableWindow(0); ((CButton *)GetDlgItem(IDC_BUTTON1))->EnableWindow(0); SetDlgItemTextW(IDC_BTN_OPEN,_T("Open")); m_port_open =false; UpdateData(FALSE); KillTimer(1); SetDlgItemTextW(IDC_STATIC_VALUE1,_T("")); SetDlgItemTextW(IDC_STATIC_VALUE2,_T("")); SetDlgItemTextW(IDC_STATIC_VALUE3,_T("")); SetDlgItemTextW(IDC_STATIC_VALUE4,_T("")); SetDlgItemTextW(IDC_STATIC_VALUE5,_T("")); suspend_thread =true; //if(hFirstThread!=NULL) // TerminateThread(hFirstThread, 0); //hFirstThread=NULL; } }
bool CCustom1Dlg::ComputeRelativePath( ) { if ( m_RootPath.GetAt(1) != ':' ) { MessageBox( "Error! The root path must specify a drive!", "Bogus Root Path!", MB_ICONERROR | MB_OK ); return false; } if ( m_TargetPath.GetAt(1) != ':' ) { MessageBox( "Error! The target path must specify a drive!", "Bogus Target Path!", MB_ICONERROR | MB_OK ); return false; } CString sourcePath; if (!Valvelibaw.m_Dictionary.Lookup("FULL_DIR_PATH", sourcePath )) { MessageBox( "I can't seem to find the source path!??!", "Umm... Get Brian", MB_ICONERROR | MB_OK ); return false; } FixupPath( m_RootPath ); FixupPath( m_TargetPath ); FixupPath( sourcePath ); CString srcRootPath = m_RootPath; srcRootPath += m_SrcPath; srcRootPath += "\\"; FixupPath( srcRootPath ); if (sourcePath.Find( srcRootPath ) != 0) { MessageBox( "Error! The source path must lie under the root source path!", "Bogus Root Path!", MB_ICONERROR | MB_OK ); return false; } if (m_TargetPath.Find( m_RootPath ) != 0) { MessageBox( "Error! The target path must lie under the root path!", "Bogus Target Path!", MB_ICONERROR | MB_OK ); return false; } int rootLen = m_RootPath.GetLength(); int rootSrcLen = srcRootPath.GetLength(); int sourceLen = sourcePath.GetLength(); int targetLen = m_TargetPath.GetLength(); CString relativePath = m_TargetPath.Right( targetLen - rootLen ); // Now that we've got the relative source path, // find out how many slashes are in it; // that'll tell us how many paths to back up.... int i; CString relativeSourcePath = sourcePath.Right( sourceLen - rootLen ); int numSlashes = CountSlashes(relativeSourcePath); CString targetRelativePath; for ( i = 0; i < numSlashes; ++i ) { targetRelativePath += "..\\"; } // Now that we've got the relative source path, // find out how many slashes are in it; // that'll tell us how many paths to back up.... CString rootSrcToProj = sourcePath.Right( sourceLen - rootSrcLen ); numSlashes = CountSlashes(rootSrcToProj); CString projToRootSrc; for ( i = 0; i < numSlashes; ++i ) { projToRootSrc += "..\\"; } Valvelibaw.m_Dictionary["VALVE_ROOT_RELATIVE_PATH"] = targetRelativePath; Valvelibaw.m_Dictionary["VALVE_SRC_RELATIVE_PATH"] = projToRootSrc; targetRelativePath += relativePath; Valvelibaw.m_Dictionary["VALVE_ROOT_PATH"] = m_RootPath; Valvelibaw.m_Dictionary["VALVE_ROOT_SRC_PATH"] = srcRootPath; Valvelibaw.m_Dictionary["VALVE_TARGET_PATH"] = m_TargetPath; Valvelibaw.m_Dictionary["VALVE_RELATIVE_PATH"] = targetRelativePath; if (m_ToolProject) Valvelibaw.m_Dictionary["VALVE_TOOL"] = "1"; if (m_PublicProject && (m_ProjectType != 2)) Valvelibaw.m_Dictionary["VALVE_PUBLIC_PROJECT"] = "1"; if (m_PublishImportLib && (m_ProjectType == 1)) Valvelibaw.m_Dictionary["VALVE_PUBLISH_IMPORT_LIB"] = "1"; // Import libraries if (m_ProjectType == 1) { if ( m_ImplibPath.GetAt(1) != ':' ) { MessageBox( "Error! The import library path must specify a drive!", "Bogus Import Library Path!", MB_ICONERROR | MB_OK ); return false; } if (m_ImplibPath.Find( srcRootPath ) != 0) { MessageBox( "Error! The import library path must lie under the root src path!", "Bogus Target Path!", MB_ICONERROR | MB_OK ); return false; } int implibLen = m_ImplibPath.GetLength(); relativePath = m_ImplibPath.Right( implibLen - rootSrcLen ); int numSlashes = CountSlashes(rootSrcToProj); CString implibRelativePath; for (int i = 0; i < numSlashes; ++i ) { implibRelativePath += "..\\"; } implibRelativePath += relativePath; Valvelibaw.m_Dictionary["VALVE_IMPLIB_PATH"] = m_ImplibPath; Valvelibaw.m_Dictionary["VALVE_IMPLIB_RELATIVE_PATH"] = implibRelativePath; } return true; }
CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CString& sPageRet) { // Check that their session really belongs to their IP address. IP-based // authentication is bad, but here it's just an extra layer that makes // stealing cookies harder to pull off. // // When their IP is wrong, we give them an invalid cookie. This makes // sure that they will get a new cookie on their next request. if (CZNC::Get().GetProtectWebSessions() && GetSession()->GetIP() != GetRemoteIP()) { DEBUG("Expected IP: " << GetSession()->GetIP()); DEBUG("Remote IP: " << GetRemoteIP()); SendCookie("SessionId", "WRONG_IP_FOR_SESSION"); PrintErrorPage(403, "Access denied", "This session does not belong to your IP."); return PAGE_DONE; } // Check that they really POSTed from one our forms by checking if they // know the "secret" CSRF check value. Don't do this for login since // CSRF against the login form makes no sense and the login form does a // cookies-enabled check which would break otherwise. if (IsPost() && GetParam("_CSRF_Check") != GetCSRFCheck() && sURI != "/login") { DEBUG("Expected _CSRF_Check: " << GetCSRFCheck()); DEBUG("Actual _CSRF_Check: " << GetParam("_CSRF_Check")); PrintErrorPage(403, "Access denied", "POST requests need to send " "a secret token to prevent cross-site request forgery attacks."); return PAGE_DONE; } SendCookie("SessionId", GetSession()->GetId()); if (GetSession()->IsLoggedIn()) { m_sUser = GetSession()->GetUser()->GetUserName(); m_bLoggedIn = true; } // Handle the static pages that don't require a login if (sURI == "/") { if(!m_bLoggedIn && GetParam("cookie_check", false).ToBool() && GetRequestCookie("SessionId").empty()) { GetSession()->AddError("Your browser does not have cookies enabled for this site!"); } return PrintTemplate("index", sPageRet); } else if (sURI == "/favicon.ico") { return PrintStaticFile("/pub/favicon.ico", sPageRet); } else if (sURI == "/robots.txt") { return PrintStaticFile("/pub/robots.txt", sPageRet); } else if (sURI == "/logout") { GetSession()->SetUser(NULL); SetLoggedIn(false); Redirect("/"); // We already sent a reply return PAGE_DONE; } else if (sURI == "/login") { if (GetParam("submitted").ToBool()) { m_sUser = GetParam("user"); m_sPass = GetParam("pass"); m_bLoggedIn = OnLogin(m_sUser, m_sPass); // AcceptedLogin()/RefusedLogin() will call Redirect() return PAGE_DEFERRED; } Redirect("/"); // the login form is here return PAGE_DONE; } else if (sURI.Left(5) == "/pub/") { return PrintStaticFile(sURI, sPageRet); } else if (sURI.Left(11) == "/skinfiles/") { CString sSkinName = sURI.substr(11); CString::size_type uPathStart = sSkinName.find("/"); if (uPathStart != CString::npos) { CString sFilePath = sSkinName.substr(uPathStart + 1); sSkinName.erase(uPathStart); m_Template.ClearPaths(); m_Template.AppendPath(GetSkinPath(sSkinName) + "pub"); if (PrintFile(m_Template.ExpandFile(sFilePath))) { return PAGE_DONE; } else { return PAGE_NOTFOUND; } } return PAGE_NOTFOUND; } else if (sURI.Left(6) == "/mods/" || sURI.Left(10) == "/modfiles/") { // Make sure modules are treated as directories if (sURI.Right(1) != "/" && sURI.find(".") == CString::npos && sURI.TrimLeft_n("/mods/").TrimLeft_n("/").find("/") == CString::npos) { Redirect(sURI + "/"); return PAGE_DONE; } // The URI looks like: // /mods/[type]/([network]/)?[module][/page][?arg1=val1&arg2=val2...] m_sPath = GetPath().TrimLeft_n("/"); m_sPath.TrimPrefix("mods/"); m_sPath.TrimPrefix("modfiles/"); CString sType = m_sPath.Token(0, false, "/"); m_sPath = m_sPath.Token(1, true, "/"); CModInfo::EModuleType eModType; if (sType.Equals("global")) { eModType = CModInfo::GlobalModule; } else if (sType.Equals("user")) { eModType = CModInfo::UserModule; } else if (sType.Equals("network")) { eModType = CModInfo::NetworkModule; } else { PrintErrorPage(403, "Forbidden", "Unknown module type [" + sType + "]"); return PAGE_DONE; } if ((eModType != CModInfo::GlobalModule) && !ForceLogin()) { // Make sure we have a valid user return PAGE_DONE; } CIRCNetwork *pNetwork = NULL; if (eModType == CModInfo::NetworkModule) { CString sNetwork = m_sPath.Token(0, false, "/"); m_sPath = m_sPath.Token(1, true, "/"); pNetwork = GetSession()->GetUser()->FindNetwork(sNetwork); if (!pNetwork) { PrintErrorPage(404, "Not Found", "Network [" + sNetwork + "] not found."); return PAGE_DONE; } } m_sModName = m_sPath.Token(0, false, "/"); m_sPage = m_sPath.Token(1, true, "/"); if (m_sPage.empty()) { m_sPage = "index"; } DEBUG("Path [" + m_sPath + "], Module [" + m_sModName + "], Page [" + m_sPage + "]"); CModule *pModule = NULL; switch (eModType) { case CModInfo::GlobalModule: pModule = CZNC::Get().GetModules().FindModule(m_sModName); break; case CModInfo::UserModule: pModule = GetSession()->GetUser()->GetModules().FindModule(m_sModName); break; case CModInfo::NetworkModule: pModule = pNetwork->GetModules().FindModule(m_sModName); break; } if (!pModule) return PAGE_NOTFOUND; m_Template["ModPath"] = pModule->GetWebPath(); m_Template["ModFilesPath"] = pModule->GetWebFilesPath(); if (pModule->WebRequiresLogin() && !ForceLogin()) { return PAGE_PRINT; } else if (pModule->WebRequiresAdmin() && !GetSession()->IsAdmin()) { PrintErrorPage(403, "Forbidden", "You need to be an admin to access this module"); return PAGE_DONE; } else if (pModule->GetType() != CModInfo::GlobalModule && pModule->GetUser() != GetSession()->GetUser()) { PrintErrorPage(403, "Forbidden", "You must login as " + pModule->GetUser()->GetUserName() + " in order to view this page"); return PAGE_DONE; } else if (pModule->OnWebPreRequest(*this, m_sPage)) { return PAGE_DEFERRED; } VWebSubPages& vSubPages = pModule->GetSubPages(); for (unsigned int a = 0; a < vSubPages.size(); a++) { TWebSubPage& SubPage = vSubPages[a]; bool bActive = (m_sModName == pModule->GetModName() && m_sPage == SubPage->GetName()); if (bActive && SubPage->RequiresAdmin() && !GetSession()->IsAdmin()) { PrintErrorPage(403, "Forbidden", "You need to be an admin to access this page"); return PAGE_DONE; } } if (pModule && pModule->GetType() != CModInfo::GlobalModule && (!IsLoggedIn() || pModule->GetUser() != GetSession()->GetUser())) { AddModLoop("UserModLoop", *pModule); } if (sURI.Left(10) == "/modfiles/") { m_Template.AppendPath(GetSkinPath(GetSkinName()) + "/mods/" + m_sModName + "/files/"); m_Template.AppendPath(pModule->GetModDataDir() + "/files/"); if (PrintFile(m_Template.ExpandFile(m_sPage.TrimLeft_n("/")))) { return PAGE_PRINT; } else { return PAGE_NOTFOUND; } } else { SetPaths(pModule, true); /* if a module returns false from OnWebRequest, it does not want the template to be printed, usually because it did a redirect. */ if (pModule->OnWebRequest(*this, m_sPage, m_Template)) { // If they already sent a reply, let's assume // they did what they wanted to do. if (SentHeader()) { return PAGE_DONE; } return PrintTemplate(m_sPage, sPageRet, pModule); } if (!SentHeader()) { PrintErrorPage(404, "Not Implemented", "The requested module does not acknowledge web requests"); } return PAGE_DONE; } } else { CString sPage(sURI.Trim_n("/")); if (sPage.length() < 32) { for (unsigned int a = 0; a < sPage.length(); a++) { unsigned char c = sPage[a]; if ((c < '0' || c > '9') && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '_') { return PAGE_NOTFOUND; } } return PrintTemplate(sPage, sPageRet); } } return PAGE_NOTFOUND; }
BOOL COutputDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here // CString strWndTitle; // m_pParentWnd->GetWindowText(strWndTitle); // strWndTitle += _T("의 출력창"); // m_editOutput.SetWindowText(strWndTitle); // 후킹 플러그인 폴더 검색 CString folderAlgorithm = (MAINAPP)->m_strAralTransDir + _T("\\Algorithm\\*.dll"); CFileFind findAlgorithm; BOOL bFindAlgorithm = findAlgorithm.FindFile(folderAlgorithm); if(bFindAlgorithm) { do { bFindAlgorithm = findAlgorithm.FindNextFile(); CString strPluginName = findAlgorithm.GetFileName(); if( strPluginName.Right(4).CompareNoCase(_T(".dll")) == 0 ) { strPluginName = strPluginName.Left( strPluginName.GetLength() - 4 ); } m_comboHookMode.AddString(strPluginName); } while( bFindAlgorithm ); } m_comboHookMode.SetCurSel(0); // 필터 플러그인 InitFilterGrid(); // 번역 플러그인 폴더 검색 CString folderTranslator = (MAINAPP)->m_strAralTransDir + _T("\\Translator\\*.dll"); CFileFind findTranslator; BOOL bFindTranslator = findTranslator.FindFile(folderTranslator); if(bFindTranslator) { do { bFindTranslator = findTranslator.FindNextFile(); CString strPluginName = findTranslator.GetFileName(); if( strPluginName.Right(4).CompareNoCase(_T(".dll")) == 0 ) { strPluginName = strPluginName.Left( strPluginName.GetLength() - 4 ); } m_comboTranslator.AddString(strPluginName); } while( bFindTranslator ); } m_comboTranslator.SetCurSel(0); // 트레이 설정 int nTrayMin = (int)CRegistryMgr::RegReadDWORD(_T("HKEY_CURRENT_USER\\Software\\AralGood"), _T("TrayMinimize")); m_chkTrayMin.SetCheck(nTrayMin); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CHtmlFilter::AddaLink(CString & strcontent) { TCHAR * urls[] = { L"http://", L"https://", L"ftp://", L"www."}; int indexBegin = 0; int count = sizeof(urls) / sizeof(TCHAR *); for( int i=0 ; i<count ; i++ ) { TCHAR * pCurrent = urls[i]; DWORD firstwhile =0,secondwhile =0; while( (indexBegin=strcontent.Find(pCurrent, indexBegin))!=-1 ) { #ifdef NO_RELEASE firstwhile++; if(firstwhile>100000) { /// Ìáʾ¹æ·¶»¯[12/24/2007 λÔÃô] /// ::MessageBox(NULL,_T("AddaLink firstwhile"),_T("51IM"),0); AfxMessageBox(_T("AddaLink firstwhile")); break; } #endif vector<pair <int ,int > > vecBE; vector<pair <int ,int > > vecBE2; FindAllLink(strcontent,vecBE); FindAllTag(strcontent,vecBE2); int index; int index2; bool re = BeInLink(indexBegin,vecBE,index); bool re2 = BeInTag(indexBegin,vecBE2,index2); if(re) { indexBegin=index+1; continue; } else if(re2) { indexBegin=index2+1; continue; } else { CString s; s = strcontent.Right(strcontent.GetLength()-indexBegin); int len=0; while( ( isdigit(s[len]) || isalpha(s[len]) || s[len]=='.' || s[len]==':' || s[len]=='/' || s[len]=='-'|| s[len]=='_' || s[len]=='?' || s[len]=='=' || s[len]=='&' || s[len]=='%' || s[len]=='~' || s[len]=='+' || s[len]==',') ) { #ifdef NO_RELEASE secondwhile++; if(secondwhile>100000) { /// Ìáʾ¹æ·¶»¯[12/24/2007 λÔÃô] /// ::MessageBox(NULL,_T("AddaLink secondwhile"),_T("51IM"),0); AfxMessageBox( _T("AddaLink secondwhile") ); //MessageBox(_T("AddaLink secondwhile")); break; } #endif if(len < s.GetLength()) { len++; } else { break; } } CString sLeft,sRight; sLeft = s.Left(len); sRight = s.Right(s.GetLength()- len); CString sHead; sHead = _T("<A href=\"http://") + sLeft + _T("\">") + sLeft + _T("</A>"); CString strContentLeft = strcontent.Left(indexBegin); strcontent = strContentLeft + sHead + sRight; indexBegin += sHead.GetLength();// + sRight.GetLength(); } } indexBegin = 0; } }
void Path::AddEndingBackslash(CString& cszPath) { if (cszPath.Right(1) != Path::Separator) cszPath += Path::Separator; }
//删除 void CTestScript::OnDelScript() { char strfile[128] = "TestCase\\TestCases.xml"; TiXmlDocument pDoc(strfile); ///载入配置文件 if(!pDoc.LoadFile()) { PutDebugString("装载配置文件<TestCases.xml>出错!"); return; } else { HTREEITEM mSelItem = m_treeTestCase.GetSelectedItem(); if( mSelItem == m_treeTestCase.GetRootItem()) { AfxMessageBox("设定为:不能删除根节点下的所有磁盘文件",MB_OK,NULL); return; } long lSelID = (long)m_treeTestCase.GetItemData(mSelItem); itTestCase pCase = m_TestCases.find(lSelID); CString strSelItemText = m_treeTestCase.GetItemText(mSelItem); //如果不是某个lua文件 if(strSelItemText.Right(4) != ".lua") { //分类节点 TiXmlElement* rootElem = pDoc.RootElement(); TiXmlNode * rootNode = pDoc.FirstChild(rootElem->Value()); TiXmlElement* caseElem = rootElem->FirstChildElement(); TiXmlNode * caseNode = rootElem->FirstChild(caseElem->Value()); for( ; caseElem != NULL; caseElem = caseElem->NextSiblingElement(), caseNode = caseNode->NextSibling() ) { if( caseElem->Attribute("name") == strSelItemText ) { rootNode->RemoveChild(caseElem); break; } } //删除磁盘文件 DeleteFile(strSelItemText); //删除控件 m_treeTestCase.DeleteItem(mSelItem); pDoc.SaveFile(strfile); // m_TestCases.erase(pCase); //显示 char strText[256]=""; sprintf(strText,"所有案例(%d)",m_TestCases.size()); m_treeTestCase.SetItemText(m_treeTestCase.GetRootItem(),strText); return; } //是lua文件 else { //删除xml配置文件 TiXmlElement* RootEle = pDoc.RootElement(); //根 TiXmlNode* pRootNode = pDoc.FirstChild(RootEle->Value()); TiXmlElement* caseElem = RootEle->FirstChildElement(); TiXmlNode* caseNode = RootEle->FirstChild(caseElem->Value()); bool bDel = false; for(; caseElem != NULL; caseElem = caseElem->NextSiblingElement()) { TiXmlElement* scriptElem = caseElem->FirstChildElement(); TiXmlNode* scriptNode = caseElem->FirstChild(scriptElem->Value()); for(; scriptElem!=NULL; scriptElem = scriptElem->NextSiblingElement(), scriptNode = scriptNode->NextSibling() ) { if(scriptElem->Attribute("scriptname") == strSelItemText) { caseElem->RemoveChild(scriptNode); bDel = true; break; } } if( bDel ) break; } //删除磁盘文件 DeleteFile(strSelItemText); //删除控件 m_treeTestCase.DeleteItem(mSelItem); //显示 char strText[256]=""; sprintf(strText,"所有案例(%d)",m_TestCases.size()); m_treeTestCase.SetItemText(m_treeTestCase.GetRootItem(),strText); } pDoc.SaveFile(strfile); return; } }
bool CWizard::AddFilesToProject(const CString & strProjectName, const CString &strProjectPath, str_vector & array) { wizard.AddSymbol("INSERT_LOCATION_COMMENT","VisualFC AppWizard will insert additional declarations immediately before the previous line."); CString strTemplatePath = info.templatePath; CString strTpl; CString strName; if (!::CreateDirectory(strProjectPath,0)) { MessageBox(NULL,"Unable Create Direct "+ strProjectPath,"WTLAppWizard",MB_OK | MB_ICONWARNING); return false; } ::CreateDirectory(strProjectPath+_T("\\res"),0); for (int i = 0; i < array.size(); i++) { strTpl = array[i]; strTpl.TrimLeft(); strTpl.TrimRight(); if (!strTpl.IsEmpty()) { strName = strTpl; CString strTarget = GetTargetName(strName, strProjectName); CString strTemplate = strTemplatePath + '\\' + strTpl; CString strFile = strProjectPath + '\\' + strTarget; bool bCopyOnly = false; //"true" will only copy the file from strTemplate to strTarget without rendering/adding to the project CString strExt = strName.Right(strName.GetLength()-strName.ReverseFind('.')); if(strExt==".bmp" || strExt==".ico" || strExt==".gif" || strExt==".rtf" || strExt==".css") bCopyOnly = true; if (strExt == _T(".h")) { CString strFileNS = strTarget; strFileNS.MakeUpper(); strFileNS = _T("VFC_")+strFileNS.Left(strFileNS.GetLength()-2)+_T("_H__"); wizard.AddSymbol(_T("FILE_NAME_SYMBOL"),strFileNS+wizard.make_include_guid()+_T("_")); } else { wizard.AddSymbol(_T("FILE_NAME_SYMBOL"),false); } if (bCopyOnly) ::CopyFile(strTemplate,strFile,FALSE); else wizard.make_file(strTemplate,strFile); // don't add these files to the project /* if(strTarget == strProjectName + ".h" || strTarget == strProjectName + "ps.mk" || strTarget == strProjectName + "ps.def") continue; */ } } return true; }
void CVideoPlayBack::AddToListEnglish() { int j = m_iBeginNode; for(int i = 0; i< (int)m_storeLog.node_count; i++) { CString strId(_T("")); strId.Format(_T("%d"),j+1); CString strType = _T(""); if(m_SerachRecodeByType == ALL_RECODE) { if(m_storeLog.store[i].rec_type & TIMER_RECODE) { strType += _T(",TIMER_RECODE"); } if(m_storeLog.store[i].rec_type & ALARM_RECODE) { strType += _T(",ALARM_RECODE"); } if(m_storeLog.store[i].rec_type & MOVE_RECODE) { strType += _T(",MOVE_RECODE"); } if(m_storeLog.store[i].rec_type & MANUAL_RECODE) { strType += _T(",MANUAL_RECODE"); } if(m_storeLog.store[i].rec_type & LOST_RECODE) { strType += _T(",LOST_RECODE"); } if(m_storeLog.store[i].rec_type & HIDE_RECODE) { strType += _T(",HIDE_RECODE"); } if(m_storeLog.store[i].rec_type & NET_FAULT_RECODE) { strType += _T(",NET_FAULT_RECODE"); } if(m_storeLog.store[i].rec_type & PIR_RECODE) { strType += _T(",PIR_RECODE"); } strType = strType.Right(strType.GetLength() - 1 ); } else { if(m_storeLog.store[i].rec_type & TIMER_RECODE) { strType = _T("TIMER_RECODE"); } if(m_storeLog.store[i].rec_type & ALARM_RECODE) { strType = _T("ALARM_RECODE"); } if(m_storeLog.store[i].rec_type & MOVE_RECODE) { strType = _T("MOVE_RECODE"); } if(m_storeLog.store[i].rec_type & MANUAL_RECODE) { strType = _T("MANUAL_RECODE"); } if(m_storeLog.store[i].rec_type & LOST_RECODE) { strType = _T("LOST_RECODE"); } if(m_storeLog.store[i].rec_type & HIDE_RECODE) { strType = _T("HIDE_RECODE"); } if(m_storeLog.store[i].rec_type & NET_FAULT_RECODE) { strType = _T("NET_FAULT_RECODE"); } if(m_storeLog.store[i].rec_type & PIR_RECODE) { strType += _T("PIR_RECODE"); } } CString strStartTime = _T(""); CString strEndTime =_T(""); CString StartTime = _T(""); CString EndTime = _T(""); strStartTime.Format(_T("%d-%02d-%02d-%02d:%02d:%02d"),m_storeLog.store[i].beg_time.year+1900,m_storeLog.store[i].beg_time.month, m_storeLog.store[i].beg_time.date, m_storeLog.store[i].beg_time.hour , m_storeLog.store[i].beg_time.minute, m_storeLog.store[i].beg_time.second); strEndTime.Format(_T("%d-%02d-%02d-%02d:%02d:%02d"),m_storeLog.store[i].end_time.year+1900,m_storeLog.store[i].end_time.month, m_storeLog.store[i].end_time.date, m_storeLog.store[i].end_time.hour , m_storeLog.store[i].end_time.minute, m_storeLog.store[i].end_time.second); //计算时间段的差 COleDateTime tStartDateTime; COleDateTime tEndDateTime; tStartDateTime.SetDateTime(m_storeLog.store[i].beg_time.year+1900,m_storeLog.store[i].beg_time.month, m_storeLog.store[i].beg_time.date, m_storeLog.store[i].beg_time.hour , m_storeLog.store[i].beg_time.minute, m_storeLog.store[i].beg_time.second); tEndDateTime.SetDateTime(m_storeLog.store[i].end_time.year+1900,m_storeLog.store[i].end_time.month, m_storeLog.store[i].end_time.date, m_storeLog.store[i].end_time.hour , m_storeLog.store[i].end_time.minute, m_storeLog.store[i].end_time.second); m_lRecFileSize[j] = m_storeLog.store[i].file_size; //保存录像文件的大小 下载时计算进度 COleDateTimeSpan tMinute = tEndDateTime - tStartDateTime; // 计算两个日期时间的差值 DOUBLE dMinute = tMinute.GetTotalSeconds(); CString strFileTimes = _T(""); strFileTimes.Format(_T("%ld"), (LONG)dMinute); CString strFileSize = _T("");//录像大小 strFileSize.Format(_T("%d"), m_storeLog.store[i].file_size/(1024*1024)); m_VideoPlayBack.InsertItem(j,strId ); m_VideoPlayBack.SetItemText(j, 1, strType); m_VideoPlayBack.SetItemText(j, 2, strStartTime); m_VideoPlayBack.SetItemText(j, 3, strEndTime); m_VideoPlayBack.SetItemText(j, 4, strFileTimes); m_VideoPlayBack.SetItemText(j, 5, strFileSize); j++; } }
void CWHTable::GetColumnStrings(CStringArray& csStrings, BOOL fKillUnsupportedTypes) { // Retrieve the strings in the current column. // Keep finding strings until an 'end choice' token is found. int nIndex = m_nIndex; int nTableItems = m_csaLine.GetUpperBound(); int nFound = 0; while (nIndex < nTableItems) { // Find the next non empty string in the column while (m_csaLine[nIndex].IsEmpty()) { IncrementRow(nIndex); if (nIndex > nTableItems) break; } // Add the non empty string to the array if (nIndex <= nTableItems) { // Add string BOOL f = AddFoundString(csStrings, nIndex); nFound++; // Check for an unsupported type if (fKillUnsupportedTypes && nFound > m_nTitleStrings) { int nLastIndex = csStrings.GetUpperBound(); CString cs = csStrings[nLastIndex]; // Search for a token int nBang = cs.Find(m_cListEnd); if (nBang != -1) { CString csProjType = cs.Right(cs.GetLength() - (nBang+1)); int nProjType = atoi((const char*)csProjType); // Take off the project type info cs = cs.Left(nBang); csStrings[nLastIndex] = cs; // See if the project type is supported CPmwApp* pApp = GET_PMWAPP(); CPmwDocTemplate* pTemplate = NULL; POSITION pos = pApp->GetFirstDocTemplatePosition(); while (pos != NULL) { CPmwDocTemplate* pThisTemplate = (CPmwDocTemplate*)pApp->GetNextDocTemplate(pos); if (pThisTemplate->ProjectType() == nProjType) { pTemplate = pThisTemplate; break; } } if (pTemplate == NULL) { // Take it off the list, and empty it csStrings.RemoveAt(nLastIndex); m_csaLine[nIndex].Empty(); // In theory, if this string was the last in the column, // we should put a m_cListEnd char in front of the next to // last string in the column because this one is now gone. // We don't really need to do this, however, because we're // tossing out project types which are in the first row. } } } IncrementRow(nIndex); if (f) break; } } }
CStatusCacheEntry CCachedDirectory::GetStatusFromGit(const CTGitPath &path, CString sProjectRoot) { CString subpaths = path.GetGitPathString(); if(subpaths.GetLength() >= sProjectRoot.GetLength()) { if(subpaths[sProjectRoot.GetLength()] == _T('/')) subpaths=subpaths.Right(subpaths.GetLength() - sProjectRoot.GetLength()-1); else subpaths=subpaths.Right(subpaths.GetLength() - sProjectRoot.GetLength()); } GitStatus *pGitStatus = &CGitStatusCache::Instance().m_GitStatus; UNREFERENCED_PARAMETER(pGitStatus); bool isVersion =true; pGitStatus->IsUnderVersionControl(sProjectRoot, subpaths, path.IsDirectory(), &isVersion); if(!isVersion) { //untracked file bool isDir = path.IsDirectory(); bool isIgnoreFileChanged = pGitStatus->HasIgnoreFilesChanged(sProjectRoot, subpaths, isDir); if( isIgnoreFileChanged) { pGitStatus->LoadIgnoreFile(sProjectRoot, subpaths, isDir); } if (isDir) { CCachedDirectory * dirEntry = CGitStatusCache::Instance().GetDirectoryCacheEntry(path, false); /* we needn't watch untracked directory*/ if(dirEntry) { AutoLocker lock(dirEntry->m_critSec); git_wc_status_kind dirstatus = dirEntry->GetCurrentFullStatus() ; if (CGitStatusCache::Instance().IsUnversionedAsModified() || dirstatus == git_wc_status_none || dirstatus >= git_wc_status_normal || isIgnoreFileChanged) {/* status have not initialized*/ bool isignore = false; pGitStatus->IsIgnore(sProjectRoot, subpaths, &isignore, isDir); if (!isignore && CGitStatusCache::Instance().IsUnversionedAsModified()) { dirEntry->EnumFiles(path, TRUE); dirEntry->UpdateCurrentStatus(); return CStatusCacheEntry(dirEntry->GetCurrentFullStatus()); } git_wc_status2_t status2; status2.text_status = status2.prop_status = (isignore? git_wc_status_ignored:git_wc_status_unversioned); // we do not know anything about files here, all we know is that there are not versioned files in this dir dirEntry->m_mostImportantFileStatus = git_wc_status_none; dirEntry->m_ownStatus.SetKind(git_node_dir); dirEntry->m_ownStatus.SetStatus(&status2); dirEntry->m_currentFullStatus = status2.text_status; } return dirEntry->m_ownStatus; } } else /* path is file */ { AutoLocker lock(m_critSec); CString strCacheKey = GetCacheKey(path); if (strCacheKey.IsEmpty()) return CStatusCacheEntry(); CacheEntryMap::iterator itMap = m_entryCache.find(strCacheKey); if(itMap == m_entryCache.end() || isIgnoreFileChanged) { git_wc_status2_t status2; bool isignore = false; pGitStatus->IsIgnore(sProjectRoot, subpaths, &isignore, isDir); status2.text_status = status2.prop_status = (isignore? git_wc_status_ignored:git_wc_status_unversioned); AddEntry(path, &status2); return m_entryCache[strCacheKey]; } else { return itMap->second; } } return CStatusCacheEntry(); } else { EnumFiles(path, TRUE); UpdateCurrentStatus(); if (!path.IsDirectory()) return GetCacheStatusForMember(path); return CStatusCacheEntry(m_ownStatus); } }
/* LoadList() */ int CWallBrowserFileView::LoadList(LPCSTR lpcszPathName) { CWaitCursor cursor; CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument(); if(!pDoc) return(0); CImage* pImage = pDoc->GetImage(); if(!pImage) return(0); CString strPath = lpcszPathName; if(strPath.Right(1)!="\\") strPath += "\\"; strPath += "*.*"; HANDLE hFind; WIN32_FIND_DATA fd; m_nFiles = m_nPictures = 0; SetRedraw(FALSE); if((hFind = ::FindFirstFile((LPCTSTR)strPath,&fd))!=INVALID_HANDLE_VALUE) { if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { m_nFiles++; if(pImage->IsImageFile(fd.cFileName)) { if(AddItem(m_nPictures,&fd)) m_nPictures++; } } while(::FindNextFile(hFind,&fd)) { if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { m_nFiles++; if(pImage->IsImageFile(fd.cFileName)) { if(AddItem(m_nPictures,&fd)) m_nPictures++; else break; } } } ::FindClose(hFind); } if(m_nPictures > 0) GetListCtrl().SortItems(CompareFunc,g_nSortOrder); BOOL bAutoSizeCols = TRUE; CWinAppEx* pWinAppEx = (CWinAppEx*)AfxGetApp(); if(pWinAppEx) bAutoSizeCols = pWinAppEx->m_Config.GetNumber(WALLBROWSER_OPTIONS_KEY,WALLBROWSER_AUTOSIZECOLUMNS_KEY); if(bAutoSizeCols) AutoSizeColumns(); SetRedraw(TRUE); pDoc->SetTitle(lpcszPathName); return(m_nPictures); }
void CMyCommView::DoRunScript(const CString str) { CString Commandstr; CString Paramsstr,SendStr; char data[512]; int myindex; int commandindex; if (str.GetLength()==0){return;} if (str[0]=='#'){return;} //注释行不处理。 myindex = str.Find('=',0); if (myindex == -1) { //有可能是无参数的命令 Commandstr = str; Commandstr.MakeUpper(); if ((Commandstr=="CLEAR") || (Commandstr=="DATE") || (Commandstr=="HELP")) { Paramsstr.Empty(); } else { CString ErrorStr; ErrorStr.Format("\n\r语法出错1 %s\n\r",str); m_EditLogger.AddText(_T(ErrorStr)); return; } } else{ Commandstr = str.Left(myindex); Paramsstr = str.Right(str.GetLength()-myindex-1); Commandstr.MakeUpper(); } if (Commandstr=="SEND") { //内容可能有#1的情况 if ((Paramsstr.GetLength()>0) && (Paramsstr[0]=='%')) { commandindex = atoi(Paramsstr.Right(Paramsstr.GetLength()-1))-1; if (GetDocument()->m_Command[commandindex].m_isScript) { CString ErrorStr; ErrorStr.Format("\n\r语法出错,脚本不能做SEND的参数。 %s\n\r",str); m_EditLogger.AddText(_T(ErrorStr)); return; } SendStr=GetDocument()->m_Command[commandindex].m_strCommand; } else{ SendStr = Paramsstr; } if(m_ctrlSendHex.GetCheck()) { int len=DoStr2Hex(SendStr,data); GetDocument()->m_Comm.WriteToPort(data,len); GetDocument()->m_RXCount+=(long)((SendStr.GetLength()+1)/3); CMyCommApp * myApp = (CMyCommApp *)AfxGetApp(); CString str; str.Format("TX:%d",GetDocument()->m_RXCount); myApp->DoSetStautsBarText(SBSTX,str); } else{ GetDocument()->m_Comm.WriteToPort((LPCTSTR)SendStr); //发送数据 GetDocument()->m_RXCount+=SendStr.GetLength(); CMyCommApp * myApp = (CMyCommApp *)AfxGetApp(); CString str; str.Format("TX:%d",GetDocument()->m_RXCount); myApp->DoSetStautsBarText(SBSTX,str); } CEdit *edit = (CEdit*)GetDlgItem(IDC_EDRECDATAVALUE); int nLength=edit->SendMessage(WM_GETTEXTLENGTH); edit->SetSel(nLength, nLength); edit->ReplaceSel(SendStr); } else if (Commandstr=="SLEEP") { Sleep(atoi(Paramsstr)); } else if (Commandstr=="OUT") { //char re[3] = {VK_RETURN, 0x0a}; SendStr = Paramsstr; //SendStr.Replace("\n\r","abc"); m_EditLogger.AddText(_T(SendStr)); } else if (Commandstr =="DATE") { CTime time=CTime::GetCurrentTime(); CString s; if (Paramsstr.IsEmpty()) s = time.Format("%Y-%m-%d %H:%M:%S"); else s = time.Format(Paramsstr); m_EditLogger.AddText(s); } else if (Commandstr == "CLEAR") { OnBtclearreceivedata(); } else if (Commandstr == "HELP") { CMyCommApp * myApp = (CMyCommApp *)AfxGetApp(); m_EditLogger.AddText(myApp->m_ScriptHelp); } else{ CString ErrorStr; ErrorStr.Format("\n\r语法出错2 %s\n\r",str); m_EditLogger.AddText(_T(ErrorStr)); } }