changeset 0:7c3921bf511e

Beta2
author pyon@macmini
date Sat, 20 Oct 2012 16:07:42 +0900
parents
children 20018a6f69a9
files .hgignore Changes Makefile include/about.h include/common.h include/main.h include/myframe.h src/about.cpp src/main.cpp src/myframe.cpp
diffstat 10 files changed, 639 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,11 @@
+syntax: glob
+obj/*.o
+img/*
+tmp/*
+trash/*
+*.app/*
+.DS_Store
+*.conf
+log
+*.bak
+*~
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Changes	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,9 @@
+version 0.2
+2012-06-22
+ Beta2 Release.
+
+----
+version 0.1
+2012-10-20
+ Beta Release.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,95 @@
+# Makefile for wxWidgets Application
+# Last Change: 20-Oct-2012.
+# by Takayuki Mutoh
+#
+
+PROGNAME = dw
+
+### Variables ###
+OBJDIR = ./obj
+CXX = g++
+vpath %.cpp ./src
+vpath %.h   ./include
+
+# For Microsoft Windows
+ifdef COMSPEC
+WXCXXFLAGS = -I/local/lib/wx/include/msw-unicode-static-2.9 -I/local/include/wx-2.9 -D_LARGEFILE_SOURCE=unknown -D__WXMSW__ -mthreads
+WXLIBS = -L/local/lib -Wl,--subsystem,windows -mwindows /local/lib/libwx_mswu_richtext-2.9.a /local/lib/libwx_mswu_xrc-2.9.a /local/lib/libwx_mswu_webview-2.9.a /local/lib/libwx_mswu_qa-2.9.a /local/lib/libwx_baseu_net-2.9.a /local/lib/libwx_mswu_html-2.9.a /local/lib/libwx_mswu_adv-2.9.a /local/lib/libwx_mswu_core-2.9.a /local/lib/libwx_baseu_xml-2.9.a /local/lib/libwx_baseu-2.9.a -lwxregexu-2.9 -lwxexpat-2.9 -lwxtiff-2.9 -lwxjpeg-2.9 -lwxpng-2.9 -lwxzlib-2.9 -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
+EXECUTABLE = $(PROGNAME).exe
+
+# For Apple OSX
+else 
+WXCXXFLAGS = -I/opt/local/lib/wx/include/osx_cocoa-unicode-2.9 -I/opt/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ 
+WXLIBS = -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -framework QuickTime -lwx_osx_cocoau_richtext-2.9 -lwx_osx_cocoau_xrc-2.9 -lwx_osx_cocoau_webview-2.9 -lwx_osx_cocoau_html-2.9 -lwx_osx_cocoau_qa-2.9 -lwx_osx_cocoau_adv-2.9 -lwx_osx_cocoau_core-2.9 -lwx_baseu_xml-2.9 -lwx_baseu_net-2.9 -lwx_baseu-2.9 
+
+EXECUTABLE = $(PROGNAME).app/Contents/Pkginfo
+
+endif
+
+CXXFLAGS = $(WXCXXFLAGS) -I./include -I./image
+LIBS = $(WXLIBS) -static-libgcc -static-libstdc++
+
+
+OBJ = $(OBJDIR)/main.o \
+	  $(OBJDIR)/about.o \
+	  $(OBJDIR)/myframe.o 
+
+ifdef COMSPEC
+OBJMSW = $(OBJ) $(OBJDIR)/sample_rc.o
+endif
+
+
+### Targets ###
+
+all: $(EXECUTABLE)
+
+
+$(PROGNAME): $(OBJ)
+	$(CXX) $^ -o $@ $(LIBS) 
+
+$(OBJDIR)/main.o: main.cpp main.h common.h myframe.h
+	-mkdir -p $(OBJDIR)
+	$(CXX) -c $< -o $@ $(CXXFLAGS)
+
+$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h
+	$(CXX) -c $< -o $@ $(CXXFLAGS)
+
+$(OBJDIR)/about.o: about.cpp about.h common.h
+	$(CXX) -c $< -o $@ $(CXXFLAGS)
+
+
+# for icon
+ifdef COMSPEC
+$(OBJDIR)/sample_rc.o: sample.rc
+	windres -i sample.rc -o $@ -I/local/include/wx-2.9
+endif
+
+$(EXECUTABLE): $(PROGNAME)
+ifdef COMSPEC
+	strip --strip-all $(EXECUTABLE)
+	./$(PROGNAME).exe
+else
+	-mkdir -p $(PROGNAME).app/Contents
+	-mkdir -p $(PROGNAME).app/Contents/MacOS
+	-mkdir -p $(PROGNAME).app/Contents/Resources
+	
+	sed -e "s/IDENTIFIER/$(PROGNAME)/" \
+	-e "s/EXECUTABLE/$(PROGNAME)/" \
+	-e "s/VERSION/0.0/" \
+	Info.plist.in > $(PROGNAME).app/Contents/Info.plist
+	
+	echo -n "APPL????" > $(EXECUTABLE)
+	
+	ln -f $(PROGNAME) $(PROGNAME).app/Contents/MacOS/$(PROGNAME)
+	cp -f wxmac.icns $(PROGNAME).app/Contents/Resources/wxmac.icns
+
+	open $(PROGNAME).app
+endif
+
+clean:
+	rm -f $(PROGNAME) $(PROGNAME).exe
+	rm -f $(OBJDIR)/*.o
+	rm -rf $(PROGNAME).app
+
+.PHONY:	all clean
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/about.h	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,26 @@
+// Filename   : about.h
+// Last Change: 23-Jun-2012.
+//
+#ifndef __ABOUT_H__
+#define __ABOUT_H__
+
+#include "common.h"
+
+class AboutDialog : public wxDialog 
+{
+	private:
+	
+	protected:
+		wxStaticBitmap* m_bitmap;
+		wxStaticText*   m_staticTextDesc;
+		wxButton*       m_buttonOK;
+		wxRichTextCtrl* m_richText;
+	
+	public:
+		AboutDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); 
+		~AboutDialog();
+        void LoadChangeLog( void );
+};
+
+#endif //__ABOUT_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/common.h	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,44 @@
+// Filename   : common.h
+// Last Change: 12-Oct-2012.
+//
+#ifndef __COMMON_H__
+#define __COMMON_H__
+
+#include "wx/wxprec.h"
+ 
+#ifndef WX_PRECOMP
+
+#include <wx/wx.h>
+#include <wx/string.h>
+#include <wx/bitmap.h>
+#include <wx/image.h>
+#include <wx/icon.h>
+#include <wx/menu.h>
+#include <wx/gdicmn.h>
+#include <wx/colour.h>
+#include <wx/settings.h>
+#include <wx/statbmp.h>
+#include <wx/textctrl.h>
+#include <wx/listctrl.h>
+#include <wx/button.h>
+#include <wx/sizer.h>
+#include <wx/panel.h>
+#include <wx/stattext.h>
+#include <wx/combobox.h>
+#include <wx/tglbtn.h>
+#include <wx/richtext/richtextctrl.h>
+#include "wx/fswatcher.h"
+#include <wx/frame.h>
+#include <wx/dialog.h>
+#include <wx/dir.h>
+#include <wx/regex.h>
+#include <wx/stdpaths.h>
+#include <wx/config.h>
+#include <wx/fileconf.h>
+#include <wx/filepicker.h>
+#include <wx/window.h>
+
+#endif
+
+#endif  // __COMMON_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/main.h	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,35 @@
+// Filename   : main.h
+// Last Change: 17-Jun-2012.
+//
+#include "wx/wx.h"
+#include "wx/config.h"
+#include "wx/fileconf.h"
+
+// private classes
+// Define a new application type, each program should derive a class from wxApp
+class MyApp : public wxApp
+{
+    DECLARE_CLASS( MyApp )
+public:
+    MyApp();
+    ~MyApp();
+
+    virtual bool OnInit();
+    virtual int  OnExit();
+    void InitSetting();
+    void SaveSetting();
+    void InitLog();
+    void WriteLog( wxString msg );
+
+    wxFileConfig *config;
+    wxString      conf_file;
+    wxString      log_file;
+    wxRect        rect;
+};
+
+enum {
+    ID_MAIN = wxID_HIGHEST + 1,
+};
+
+DECLARE_APP(MyApp)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/myframe.h	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,57 @@
+// Filename   : myframe.h
+// Last Change: 20-Oct-2012.
+//
+#ifndef __MYFRAME_H__
+#define __MYFRAME_H__
+
+#include "common.h"
+
+class MyFrame : public wxFrame 
+{
+    DECLARE_EVENT_TABLE()
+	private:
+	
+	protected:
+		wxMenuBar* m_menubar;
+		wxMenu*	   m_menuFile;
+
+		wxStaticText*    m_staticText1;
+		wxDirPickerCtrl* m_dirPickerWatch;
+		wxStaticText*    m_staticText2;
+		wxTextCtrl*      m_textCtrlFile;
+		wxStaticText*    m_staticText3;
+		wxTextCtrl*      m_textCtrlCommand;
+		wxStaticText*    m_staticText4;
+		wxDirPickerCtrl* m_dirPickerMove;
+		wxStaticText*    m_staticText5;
+		wxToggleButton*  m_toggleBtn;
+
+        wxFileSystemWatcher* m_watcher;
+
+	public:
+        MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style );
+		~MyFrame();
+
+        void OnFileSystemEvent( wxFileSystemWatcherEvent& event );
+        void OnWatch( wxCommandEvent& WXUNUSED(event) );
+
+        void OnWinSize( wxSizeEvent& event );
+        void OnWinMove( wxMoveEvent& WXUNUSED(event) );
+        void TellLocation( void );
+        void OnQuit( wxCommandEvent& WXUNUSED(event) );
+        void OnAbout( wxCommandEvent& WXUNUSED(event) );
+        void SaveConfig( wxCloseEvent& WXUNUSED(event) );
+};
+
+enum {
+    ID_MNAPPDIR = wxID_HIGHEST + 10,
+    ID_MNABOUT,
+    ID_WATCHDIR,
+    ID_FILENAME,
+    ID_COMMAND,
+    ID_MOVEDIR,
+    ID_TOGGLEWATCH,
+};
+
+#endif //__MYFRAME_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/about.cpp	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,82 @@
+// Filename   : about.cpp
+// Last Change: 18-Jun-2012.
+//
+
+#include "common.h"
+#include "about.h"
+
+AboutDialog::AboutDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
+    : wxDialog( parent, id, title, pos, size, style )
+{
+	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+	
+	wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
+	
+	wxBoxSizer* bSizerOK = new wxBoxSizer( wxHORIZONTAL );
+	
+    wxString iamge = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("takashi.png");
+    wxBitmap bmp = wxBitmap( iamge, wxBITMAP_TYPE_PNG );
+	m_bitmap = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerOK->Add( m_bitmap, 0, wxALL, 5 );
+	
+	m_staticTextDesc = new wxStaticText( this, wxID_ANY, wxT("我に自由を!\rLet me free !"), wxDefaultPosition, wxSize(-1,50), 0 );
+	bSizerOK->Add( m_staticTextDesc, 0, wxALL|wxALIGN_CENTRE, 5 );
+	
+	m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );
+	m_buttonOK->SetDefault(); 
+	bSizerOK->Add( m_buttonOK, 0, wxALL|wxALIGN_BOTTOM, 5 );
+	
+	bSizer->Add( bSizerOK, 0, wxEXPAND, 5 );
+	
+	m_richText = new wxRichTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxVSCROLL|wxBORDER_NONE|wxWANTS_CHARS );
+	bSizer->Add( m_richText, 1, wxEXPAND|wxALL, 5 );
+	
+	this->SetSizer( bSizer );
+	this->Layout();
+	
+	this->Centre( wxBOTH );
+
+    LoadChangeLog();
+}
+
+AboutDialog::~AboutDialog()
+{
+}
+
+void AboutDialog::LoadChangeLog( void )
+{
+    wxTextFile textfile;
+    textfile.Open( wxGetCwd() + wxFILE_SEP_PATH + wxT("Changes") );
+    for ( int i=0; i<textfile.GetLineCount(); i++ ) {
+        if ( textfile[i].StartsWith( wxT("version")) ) {
+            m_richText->BeginBold();
+            m_richText->BeginFontSize(16);
+            m_richText->BeginTextColour( wxColour( 0, 200, 0 ) );
+            m_richText->WriteText( textfile[i] );
+            m_richText->EndTextColour();
+            m_richText->EndFontSize();
+            m_richText->EndBold();
+            m_richText->Newline();
+        }
+        else if ( textfile[i].StartsWith( wxT("20")) ) {
+            m_richText->BeginAlignment( wxTEXT_ALIGNMENT_RIGHT );
+            m_richText->BeginItalic();
+            m_richText->WriteText( textfile[i] );
+            m_richText->EndItalic();
+            m_richText->EndAlignment();
+            m_richText->Newline();
+        }
+        else if ( textfile[i].StartsWith( wxT("----")) ) {
+            m_richText->WriteText( textfile[i] );
+            m_richText->Newline();
+        }
+        else {
+            m_richText->BeginSymbolBullet( wxT("* "), 60, 0, wxTEXT_ATTR_BULLET_STYLE_SYMBOL );
+            m_richText->WriteText( textfile[i] );
+            m_richText->EndSymbolBullet();
+        }
+    }
+    textfile.Close();
+    m_richText->SetEditable( false );
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main.cpp	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,90 @@
+// Filename   : main.cpp
+// Last Change: 20-Oct-2012.
+//
+#include "main.h"
+#include "myframe.h"
+
+IMPLEMENT_APP(MyApp)
+
+IMPLEMENT_CLASS( MyApp, wxApp )
+
+MyApp::MyApp()
+{
+}
+MyApp::~MyApp()
+{
+}
+
+bool MyApp::OnInit()
+{
+    if ( !wxApp::OnInit() ) return false;
+
+    wxImage::AddHandler( new wxPNGHandler );
+
+    InitLog();
+    InitSetting();
+
+    MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, wxT("Folder Watcher"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE );
+    mainframe->SetSize( rect );
+    mainframe->SetMinSize( wxSize( 350, 200 ) );
+    mainframe->Show(true);
+
+    return true;
+}
+
+int MyApp::OnExit()
+{
+    SaveSetting();
+    return 0;
+}
+
+void MyApp::InitSetting()
+{
+    conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf");
+    config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
+
+    config->SetPath( wxT("/Geometry") );
+    config->Read( wxT("x"), &rect.x );
+    config->Read( wxT("y"), &rect.y );
+    config->Read( wxT("w"), &rect.width );
+    config->Read( wxT("h"), &rect.height );
+
+    WriteLog( wxT("Setting Parameters read.") );
+}
+
+void MyApp::SaveSetting()
+{
+    config->SetPath( wxT("/Geometry") );
+    config->Write( wxT("x"), rect.x );
+    config->Write( wxT("y"), rect.y );
+    config->Write( wxT("w"), rect.width );
+    config->Write( wxT("h"), rect.height );
+    delete config;
+
+    WriteLog( wxT("Setting Parameters saved.") );
+}
+
+void MyApp::InitLog()
+{
+    log_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("log") + wxFILE_SEP_PATH + wxT("log");
+    wxTextFile file( log_file );
+
+    if ( file.Exists() ) {
+        wxString log_bak = log_file + wxT(".bak");
+        wxRenameFile( log_file, log_bak, true );
+    }
+
+    file.Create();
+    WriteLog( wxT("[Application start...]") );
+}
+
+void MyApp::WriteLog( wxString msg )
+{
+    wxDateTime now = wxDateTime::Now();
+    wxTextFile logfile;
+    logfile.Open( log_file );
+    logfile.AddLine( now.Format(wxT("%Y-%m-%d %H:%M:%S ")) + msg );
+    logfile.Write();
+    logfile.Close();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/myframe.cpp	Sat Oct 20 16:07:42 2012 +0900
@@ -0,0 +1,190 @@
+// Filename   : myframe.cpp
+// Last Change: 20-Oct-2012.
+//
+
+#include "main.h"
+#include "myframe.h"
+#include "about.h"
+
+// resources
+#if !defined(__WXMSW__) && !defined(__WXPM__)
+    #include "sample.xpm"
+#endif
+
+MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
+    : wxFrame( parent, id, title, pos, size, style )
+{
+	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+    this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
+    // set the frame icon
+    SetIcon(wxICON(sample));
+	
+    // メニューバー Menu
+	m_menubar = new wxMenuBar();
+	m_menuFile = new wxMenu();
+
+	wxMenuItem* m_menuItemAbout = new wxMenuItem( m_menuFile, ID_MNABOUT, wxString( wxT("&About...\tF1") ) , wxT("Show about dialog"), wxITEM_NORMAL );
+	m_menuFile->Append( m_menuItemAbout );
+	
+	m_menubar->Append( m_menuFile, wxT("ファイル(&F)") ); 
+	
+	this->SetMenuBar( m_menubar );
+	
+    // 
+	wxFlexGridSizer* fgSizer = new wxFlexGridSizer( 0, 2, 0, 0 );
+	fgSizer->SetFlexibleDirection( wxBOTH );
+	fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
+	
+	m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("Folder"), wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_staticText1, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
+	
+	m_dirPickerWatch = new wxDirPickerCtrl( this, ID_WATCHDIR, wxEmptyString, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE );
+	fgSizer->Add( m_dirPickerWatch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+	
+	m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("Filename"), wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_staticText2, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
+	
+	m_textCtrlFile = new wxTextCtrl( this, ID_FILENAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_textCtrlFile, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
+	
+	m_staticText3 = new wxStaticText( this, wxID_ANY, wxT("Command"), wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_staticText3, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
+	
+	m_textCtrlCommand = new wxTextCtrl( this, ID_COMMAND, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); 
+	fgSizer->Add( m_textCtrlCommand, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
+	
+	m_staticText4 = new wxStaticText( this, wxID_ANY, wxT("MoveTo"), wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_staticText4, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
+	
+	m_dirPickerMove = new wxDirPickerCtrl( this, ID_MOVEDIR, wxEmptyString, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE );
+	fgSizer->Add( m_dirPickerMove, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+	
+	m_staticText5 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_staticText5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+	
+	m_toggleBtn = new wxToggleButton( this, ID_TOGGLEWATCH, wxT("Start Watching"), wxDefaultPosition, wxDefaultSize, 0 );
+	fgSizer->Add( m_toggleBtn, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
+	
+	this->SetSizer( fgSizer );
+	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_textCtrlFile->SetValue( wxT("test.file") );
+}
+
+MyFrame::~MyFrame()
+{
+    delete m_watcher;
+}
+
+// Event Table
+BEGIN_EVENT_TABLE( MyFrame, wxFrame )
+    EVT_SIZE( MyFrame::OnWinSize )
+    EVT_MOVE( MyFrame::OnWinMove )
+    EVT_MENU( ID_MNABOUT, MyFrame::OnAbout )
+    //EVT_MENU( wxID_EXIT,          MyFrame::OnQuit )
+    EVT_TOGGLEBUTTON( ID_TOGGLEWATCH, MyFrame::OnWatch )
+    EVT_CLOSE( MyFrame::SaveConfig )
+END_EVENT_TABLE()
+
+// Event Handlers & Functions
+/* フォルダ監視開始/停止スイッチ */
+void MyFrame::OnWatch( wxCommandEvent& WXUNUSED(event) )
+{
+    Connect( wxEVT_FSWATCHER, wxFileSystemWatcherEventHandler( MyFrame::OnFileSystemEvent ) );
+
+    static bool enabled = false;
+    enabled = !enabled;
+
+    if ( enabled ) {
+        m_toggleBtn->SetLabelText( wxT("Stop Watching") );
+        m_watcher = new wxFileSystemWatcher();
+        m_watcher->SetOwner( this );
+
+        m_watcher->Add( m_dirPickerWatch->GetPath(), wxFSW_EVENT_CREATE );
+    }
+    else {
+        m_toggleBtn->SetLabelText( wxT("Start Watching") );
+        wxDELETE( m_watcher );
+    }
+}
+
+/* フォルダ監視 */
+void MyFrame::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
+{
+    //wxMessageBox(wxT(""));
+    wxString watchdir = m_dirPickerWatch->GetPath();
+    wxString filename = m_textCtrlFile->GetValue();
+    wxString command  = m_textCtrlCommand->GetValue();
+    wxString movedir  = m_dirPickerMove->GetPath();
+
+    wxString from;
+    wxString to;
+
+    wxString file;
+    wxDir dir( watchdir );
+    bool cont = dir.GetFirst( &file, filename, wxDIR_FILES );
+    while ( cont ) {
+
+        if ( !command.IsEmpty() ) {
+            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();
+            wxRenameFile( from, to, false );
+        }
+
+        cont = dir.GetNext( &file );
+    }
+}
+
+/* サイズ変更 */
+void MyFrame::OnWinSize( wxSizeEvent& event )
+{
+    this->Refresh( true, NULL );
+    TellLocation();
+    event.Skip();
+}
+/* ウィンドウ移動 */
+void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) )
+{
+    TellLocation();
+    return;
+}
+/* ウィンドウ位置とサイズを表示 */
+void MyFrame::TellLocation( void ) 
+{
+    wxRect r = this->GetRect();
+    int x = r.GetX();
+    int y = r.GetY();
+    int w = r.GetWidth();
+    int h = r.GetHeight();
+    //SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 3 );
+}
+/* 終了 */
+void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
+{
+    Close(true);
+}
+/* 設定を保存 */
+void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) )
+{
+    if ( !IsIconized() && !IsMaximized() ) {
+        wxGetApp().rect = this->GetRect();
+    }
+    Destroy();
+}
+/* アバウトダイアログ */
+void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
+{
+    AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); 
+    aboutDlg->ShowModal();
+}
+