changeset 2:deaf3f2d54b2

more parameters.
author pyon@macmini
date Thu, 08 Nov 2012 20:17:12 +0900
parents 20018a6f69a9
children eea479fc2a28
files dws/KYFH13.dws dws/docuworks.dws include/myframe.h src/myframe.cpp
diffstat 4 files changed, 120 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dws/KYFH13.dws	Thu Nov 08 20:17:12 2012 +0900
@@ -0,0 +1,9 @@
+[Parameter]
+Folder=\\\\Kai-sv51\\lifep\\DATA\\KY
+Filename=KYFH13
+Command=eject-nt
+Wait=
+MoveTo=C:\\Users\\KAIGO\\Desktop\\dww
+Copy=true
+Suffix=
+Exit=true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dws/docuworks.dws	Thu Nov 08 20:17:12 2012 +0900
@@ -0,0 +1,9 @@
+[Parameter]
+Folder=\\\\Kai-sv51\\Users\\Administrator\\Documents\\Fuji Xerox\\DocuWorks\\DWFolders\\$B%f!<%6!<%U%)%k%@(B
+Filename=
+Command=
+Wait=
+MoveTo=C:\\Users\\KAIGO\\Desktop\\dww
+Copy=false
+Suffix=0
+Exit=false
--- a/include/myframe.h	Wed Oct 31 18:08:52 2012 +0900
+++ b/include/myframe.h	Thu Nov 08 20:17:12 2012 +0900
@@ -27,9 +27,13 @@
 		wxDirPickerCtrl* m_dirPickerMove;
 		wxStaticText*    m_staticText6;
         wxCheckBox*      m_checkBoxCopy;
+		wxStaticText*    m_staticText7;
+        wxComboBox*      m_comboSuffix;
 		wxStaticText*    m_staticTextDummy1;
 		wxStaticText*    m_staticTextDummy2;
 		wxStaticText*    m_staticTextDummy3;
+		wxStaticText*    m_staticText8;
+        wxCheckBox*      m_checkBoxExit;
 		wxToggleButton*  m_toggleBtn;
 
         wxFileSystemWatcher* m_watcher;
@@ -46,11 +50,15 @@
         void TellLocation( void );
         void OnQuit( wxCommandEvent& WXUNUSED(event) );
         void OnAbout( wxCommandEvent& WXUNUSED(event) );
+        void OnSetup( wxCommandEvent& WXUNUSED(event) );
+        void OnSaveParams( wxCommandEvent& WXUNUSED(event) );
         void SaveConfig( wxCloseEvent& WXUNUSED(event) );
 };
 
 enum {
     ID_MNAPPDIR = wxID_HIGHEST + 10,
+    ID_MNSETUP,
+    ID_MNSAVE,
     ID_MNABOUT,
     ID_WATCHDIR,
     ID_FILENAME,
@@ -58,6 +66,8 @@
     ID_WAIT,
     ID_MOVEDIR,
     ID_COPY,
+    ID_SUFFIX,
+    ID_EXIT,
     ID_TOGGLEWATCH,
 };
 
--- a/src/myframe.cpp	Wed Oct 31 18:08:52 2012 +0900
+++ b/src/myframe.cpp	Thu Nov 08 20:17:12 2012 +0900
@@ -23,6 +23,12 @@
 	m_menubar = new wxMenuBar();
 	m_menuFile = new wxMenu();
 
+	wxMenuItem* m_menuItemSetup = new wxMenuItem( m_menuFile, ID_MNSETUP, wxString( wxT("&Setup...") ) , wxT("Setup parameters"), wxITEM_NORMAL );
+	m_menuFile->Append( m_menuItemSetup );
+
+	wxMenuItem* m_menuItemSave = new wxMenuItem( m_menuFile, ID_MNSAVE, wxString( wxT("Save setting...") ) , wxT("Save parameters"), wxITEM_NORMAL );
+	m_menuFile->Append( m_menuItemSave );
+
 	wxMenuItem* m_menuItemAbout = new wxMenuItem( m_menuFile, ID_MNABOUT, wxString( wxT("&About...\tF1") ) , wxT("Show about dialog"), wxITEM_NORMAL );
 	m_menuFile->Append( m_menuItemAbout );
 	
@@ -71,12 +77,26 @@
     m_checkBoxCopy = new wxCheckBox( this, ID_COPY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 	fgSizer->Add( m_checkBoxCopy, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
 
+	m_staticText7 = new wxStaticText( this, wxID_ANY, wxT("suffix"), wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_staticText7, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
+
+    wxArrayString suffix;
+    suffix.Add( wxT("Date & Time") );
+    m_comboSuffix = new wxComboBox( this, ID_SUFFIX, wxEmptyString, wxDefaultPosition, wxDefaultSize, suffix, 0 );
+	fgSizer->Add( m_comboSuffix, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+
 	m_staticTextDummy1 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 	fgSizer->Add( m_staticTextDummy1, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
 
 	m_staticTextDummy2 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 	fgSizer->Add( m_staticTextDummy2, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
 
+	m_staticText8 = new wxStaticText( this, wxID_ANY, wxT("Exit"), wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_staticText8, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
+
+    m_checkBoxExit = new wxCheckBox( this, ID_EXIT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_checkBoxExit, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+
 	m_staticTextDummy3 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 	fgSizer->Add( m_staticTextDummy3, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
 	
@@ -87,12 +107,6 @@
 	this->Layout();
 	
 	this->Centre( wxBOTH );
-
-    //m_dirPickerWatch->SetPath( wxT("/Users/takayuki/wx/dw_test" ) );
-    //m_dirPickerMove->SetPath( wxT("/Users/takayuki/wx/dw_test/log" ) );
-    m_dirPickerWatch->SetPath( wxT("\\\\Kai-sv51\\Users\\Administrator\\Documents\\Fuji Xerox\\DocuWorks\\DWFolders\\ユーザーフォルダ" ) );
-    m_dirPickerMove->SetPath( wxT("C:\\Users\\KAIGO\\Desktop\\dww\\" ) );
-    m_textCtrlFile->SetValue( wxT("test.file") );
 }
 
 MyFrame::~MyFrame()
@@ -104,6 +118,8 @@
 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
     EVT_SIZE( MyFrame::OnWinSize )
     EVT_MOVE( MyFrame::OnWinMove )
+    EVT_MENU( ID_MNSETUP, MyFrame::OnSetup )
+    EVT_MENU( ID_MNSAVE, MyFrame::OnSaveParams )
     EVT_MENU( ID_MNABOUT, MyFrame::OnAbout )
     //EVT_MENU( wxID_EXIT,          MyFrame::OnQuit )
     EVT_TOGGLEBUTTON( ID_TOGGLEWATCH, MyFrame::OnWatch )
@@ -151,25 +167,88 @@
     while ( cont ) {
 
         if ( !command.IsEmpty() ) {
+            wxExecute( command );
             wxSleep( 2 );
-            wxExecute( command );
         }
 
         if ( !movedir.IsEmpty() ) {
             from = watchdir + wxFILE_SEP_PATH + filename;
             wxFileName f( from );
-            wxDateTime now = wxDateTime::Now();
-            to = movedir + wxFILE_SEP_PATH + f.GetName() + wxT("_") + now.Format(wxT("%Y%m%d%H%M%S")) + wxT(".") + f.GetExt();
-            if ( m_checkBoxCopy->IsChecked() ) {
-                wxCopyFile( from, to, false );
+
+            // ファイル名をどうするか
+            if ( m_comboSuffix->GetCurrentSelection() == 0 ) { 
+                wxDateTime now = wxDateTime::Now();
+                to = movedir + wxFILE_SEP_PATH + f.GetName() + wxT("_") + now.Format(wxT("%Y%m%d%H%M%S")) + wxT(".") + f.GetExt();
             }
             else {
+                to = movedir + wxFILE_SEP_PATH + filename;
+            }
+
+            // オリジナルを残すか
+            if ( m_checkBoxCopy->IsChecked() )
+                wxCopyFile( from, to, false );
+            else
                 wxRenameFile( from, to, false );
-            }
         }
 
         cont = dir.GetNext( &file );
     }
+    if ( m_checkBoxExit->IsChecked() ) Close( true );
+}
+
+/* セットアップ */
+void MyFrame::OnSetup( wxCommandEvent& WXUNUSED(event) )
+{
+    wxString dws_dir = wxGetCwd() + wxFILE_SEP_PATH + wxT("dws");
+    wxFileDialog fd( this, wxT("Open Setup file"), dws_dir , wxEmptyString, wxT("Setup files (*.dws)|*.dws"), wxFD_OPEN|wxFD_FILE_MUST_EXIST );
+    if ( fd.ShowModal() == wxID_CANCEL ) return;     // the user changed idea...     
+
+    wxFileConfig* config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), fd.GetPath(), wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
+
+    wxString p_folder, p_filename, p_command, p_wait, p_moveto;
+    bool p_copy, p_exit;
+    long p_suffix;
+    config->SetPath( wxT("/Parameter") );
+    config->Read( wxT("Folder"),   &p_folder   );
+    config->Read( wxT("Filename"), &p_filename );
+    config->Read( wxT("Command"),  &p_command  );
+    config->Read( wxT("Wait"),     &p_wait     );
+    config->Read( wxT("MoveTo"),   &p_moveto   );
+    config->Read( wxT("Copy"),     p_copy      );
+    config->Read( wxT("Suffix"),   &p_suffix   );
+    config->Read( wxT("Exit"),     p_exit      );
+
+    m_dirPickerWatch->SetPath( p_folder );
+    m_textCtrlFile->SetValue( p_filename );
+    m_textCtrlCommand->SetValue( p_command );
+    m_textCtrlWait->SetValue( p_wait );
+    m_dirPickerMove->SetPath( p_moveto );
+    m_checkBoxCopy->SetValue( p_copy );
+    m_comboSuffix->SetSelection( (int)p_suffix );
+    m_checkBoxExit->SetValue( p_exit );
+
+    delete config;
+}
+/* パラーメータを保存 */
+void MyFrame::OnSaveParams(  wxCommandEvent& WXUNUSED(event) )
+{
+    wxString dws_dir = wxGetCwd() + wxFILE_SEP_PATH + wxT("dws");
+    wxFileDialog fd( this, wxT("Save Setup file"), dws_dir , wxEmptyString, wxT("Setup files (*.dws)|*.dws"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT );
+    if ( fd.ShowModal() == wxID_CANCEL ) return;     // the user changed idea...     
+
+    wxFileConfig* config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), fd.GetPath(), wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
+
+    config->SetPath( wxT("/Parameter") );
+    config->Write( wxT("Folder"),   m_dirPickerWatch->GetPath()   );
+    config->Write( wxT("Filename"), m_textCtrlFile->GetValue()    );
+    config->Write( wxT("Command"),  m_textCtrlCommand->GetValue() );
+    config->Write( wxT("Wait"),     m_textCtrlWait->GetValue()    );
+    config->Write( wxT("MoveTo"),   m_dirPickerMove->GetPath()    );
+    config->Write( wxT("Copy"),     m_checkBoxCopy->GetValue()    );
+    config->Write( wxT("Suffix"),   m_comboSuffix->GetSelection() );
+    config->Write( wxT("Exit"),     m_checkBoxExit->GetValue()    );
+
+    delete config;
 }
 
 /* サイズ変更 */
@@ -198,7 +277,7 @@
 /* 終了 */
 void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
 {
-    Close(true);
+    Close( true );
 }
 /* 設定を保存 */
 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) )