Mercurial > mercurial > hgweb_mover.cgi
diff src/myframe.cpp @ 4:a505f7417742
v0.1 release
author | pyon@macmini |
---|---|
date | Thu, 06 Oct 2011 07:56:12 +0900 |
parents | a5bddd859104 |
children | 3b734fd6ee2b |
line wrap: on
line diff
--- a/src/myframe.cpp Tue Oct 04 07:43:08 2011 +0900 +++ b/src/myframe.cpp Thu Oct 06 07:56:12 2011 +0900 @@ -1,10 +1,11 @@ // Filename : mainframe.cpp -// Last Change: 03-Oct-2011. +// Last Change: 05-Oct-2011. // #include "symbol.h" #include "common.h" #include "myframe.h" #include "delwhite.h" +#include "marksheet.h" #include "main.h" // resources @@ -47,8 +48,10 @@ m_menubar = new wxMenuBar(); m_menuFile = new wxMenu(); + m_menuFile->Append( ID_OPWORK, wxT("作業フォルダを開く"), wxT("Open work folder") ); + m_menuFile->AppendSeparator(); //---- m_menuFile->Append( wxID_ABOUT, wxT("&About...\tF1"), wxT("Show about dialog") ); - //m_menuFile->AppendSeparator(); //---- + m_menuFile->AppendSeparator(); //---- m_menuFile->Append( wxID_EXIT, wxT("終了(&X)\tAlt-X"), wxT("Quit this program") ); m_menubar->Append( m_menuFile, wxT("ファイル(&F)") ); @@ -126,20 +129,28 @@ bSizerDoMove->Add( m_textCtrlMoveDir, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_buttonDoMove = new wxButton( this, ID_DOMOVE, wxT("画像移動"), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonDoMove->Enable( false ); bSizerDoMove->Add( m_buttonDoMove, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 ); bSizerTop->Add( bSizerDoMove, 0, wxEXPAND, 5 ); m_listCtrl = new wxListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); + wxListItem itemCol; + itemCol.SetText( wxT("通番") ); + m_listCtrl->InsertColumn( 0, itemCol ); + m_listCtrl->SetColumnWidth( 0, 100 ); + itemCol.SetText( wxT("被保険者番号") ); + m_listCtrl->InsertColumn( 1, itemCol ); + m_listCtrl->SetColumnWidth( 1, 180 ); + itemCol.SetText( wxT("ファイル数") ); + m_listCtrl->InsertColumn( 2, itemCol ); + m_listCtrl->SetColumnWidth( 1, 100 ); bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); this->SetSizer( bSizerTop ); this->Layout(); this->Centre( wxBOTH ); - //this->SetDefaultItem(m_buttonDetWhite); m_buttonDetWhite->SetFocus(); } @@ -154,9 +165,11 @@ EVT_MOVE( MyFrame::OnMove ) EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) EVT_MENU( wxID_ABOUT, MyFrame::OnAbout ) + EVT_MENU( ID_OPWORK, MyFrame::OnOpenWorkDir ) EVT_BUTTON( ID_DTWHITE, MyFrame::OnDetectWhite ) - EVT_BUTTON( ID_STDIR, MyFrame::SetDir ) - EVT_BUTTON( ID_MKDIR, MyFrame::MakeDir ) + EVT_BUTTON( ID_STDIR, MyFrame::SetDir ) + EVT_BUTTON( ID_MKDIR, MyFrame::MakeDir ) + EVT_BUTTON( ID_DOMOVE, MyFrame::MoveImages ) EVT_CLOSE( MyFrame::SaveConfig ) END_EVENT_TABLE() @@ -229,20 +242,89 @@ m_textCtrlMoveDir->SetValue( dir ); } +/* 移動先フォルダ作成 */ void MyFrame::MakeDir(wxCommandEvent& WXUNUSED(event)) { + wxString dirname = m_textCtrlMoveDir->GetValue(); + wxString ccn = m_comboBoxCcn->GetValue(); + if ( dirname.Len() < 15 || ccn.IsEmpty() ) { + wxMessageBox(wxT("フォルダを指定してください.")); + return; + } + + wxStringTokenizer tkz( dirname, wxFILE_SEP_PATH ); + wxString d; + while ( tkz.HasMoreTokens() ) { + d.Append( tkz.GetNextToken() ); + d.Append( wxFILE_SEP_PATH ); + if ( !wxDirExists( d ) ) wxMkdir( d ); + } } -/* アプリケーションフォルダを開く */ -/* -void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event)) +/* 画像移動 */ +void MyFrame::MoveImages(wxCommandEvent& WXUNUSED(event)) { - wxStandardPaths appdir; - wxString execmd = wxT("explorer ") + appdir.GetDataDir(); + wxString dirname = m_textCtrlMoveDir->GetValue(); + wxString ccn = m_comboBoxCcn->GetValue(); + if ( dirname.IsEmpty() || ccn.IsEmpty() ) { + wxMessageBox(wxT("フォルダを指定してください.")); + return; + } + + dirname.Append( wxFILE_SEP_PATH ); + if ( !wxDirExists( dirname ) ) { + wxMessageBox(wxT("フォルダが存在しません.")); + return; + } + + wxString workdir = m_dirPickerWork->GetPath(); + wxDir dir( workdir ); + if ( !dir.IsOpened() ) return; + + wxString filename; + bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES ); + + int cnt=0, r=0; + wxString hhs; + m_listCtrl->DeleteAllItems(); + while ( cout ) { + wxString from = workdir + wxFILE_SEP_PATH + filename; + if ( IsMarksheet( from ) ) { + hhs = GuessHhs( from ); + wxString d = dirname + hhs; + wxMkdir( d ); + m_listCtrl->InsertItem( r, wxString::Format(wxT("%d"),r+1) ); + m_listCtrl->SetItem( r, 1, hhs, -1 ); // 被保険者番号 + m_listCtrl->SetItem( r-1, 2, wxString::Format(wxT("%d"),cnt), -1 ); // ファイル数 + if ( r % 2 ) m_listCtrl->SetItemBackgroundColour( r, wxColour(wxT("WHEAT")) ); + r++; + cnt=0; + } + if ( hhs.IsEmpty() ) { + wxMessageBox(wxT("マークシートの画像ファイルを確認してください.")); + return; + } + wxString to = dirname + wxFILE_SEP_PATH + hhs + wxFILE_SEP_PATH + filename; + wxRenameFile( from, to, false ); + // write log + cout = dir.GetNext( &filename ); + cnt++; + } + m_listCtrl->SetItem( r-1, 2, wxString::Format(wxT("%d"),cnt), -1 ); // ファイル数 + if ( cnt < 5 ) m_listCtrl->SetItemTextColour( r, *wxRED ); + + wxString cmd = wxT("explorer ") + dirname; + wxExecute( cmd ); +} + +/* 作業フォルダを開く */ +void MyFrame::OnOpenWorkDir(wxCommandEvent& WXUNUSED(event)) +{ + wxString workdir = m_dirPickerWork->GetPath(); + wxString execmd = wxT("explorer ") + workdir; wxExecute( execmd ); return; } -*/ /* 設定を保存 */