3
|
1 // Filename : dndfile.h
|
22
|
2 // Last Change: 2015-04-04 11:10:10.
|
3
|
3 //
|
5
|
4 #ifndef __DNDFILE_H__
|
|
5 #define __DNDFILE_H__
|
3
|
6
|
|
7 #include "db.h"
|
22
|
8 #include "wx/config.h"
|
|
9 #include "wx/fileconf.h"
|
|
10 #include "myframe.h"
|
3
|
11
|
|
12 class DnDFile : public wxFileDropTarget
|
|
13 {
|
|
14 public:
|
|
15 DnDFile( wxGrid *grid )
|
|
16 {
|
|
17 m_grid = grid;
|
|
18 }
|
|
19 virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames )
|
|
20 {
|
|
21 size_t nFiles = filenames.GetCount();
|
|
22 if ( nFiles != 1 ) return false;
|
|
23
|
|
24 m_grid->ClearGrid();
|
4
|
25
|
|
26 // ファイルから被保番リストを生成
|
|
27 wxTextFile csv;
|
|
28 csv.Open( filenames[0] );
|
|
29
|
|
30 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") );
|
|
31 wxArrayString hhs;
|
|
32 for ( int n = 0; n < csv.GetLineCount(); n++ ) {
|
|
33 wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL );
|
|
34 if ( ! reHhs.Matches( hhsno ) )
|
|
35 continue;
|
|
36 hhs.Add( hhsno );
|
|
37 }
|
|
38 csv.Close();
|
|
39
|
|
40 //
|
|
41 int d = hhs.GetCount() - m_grid->GetNumberRows();
|
|
42 if ( d > 0 )
|
|
43 m_grid->AppendRows( d, true );
|
|
44
|
|
45 // グリッドに情報を読込み
|
|
46 wxArrayString res = GetHhsInfoAndPathByHhsNoList( hhs );
|
|
47 for ( int r = 0; r < res.GetCount(); r++ ) {
|
|
48 wxArrayString data = wxSplit( res[r], '_', '\\' );
|
|
49 m_grid->SetCellValue( r, 0, data[0] );
|
|
50 m_grid->SetCellValue( r, 1, data[1] );
|
|
51 m_grid->SetCellValue( r, 2, data[2] );
|
|
52 }
|
|
53
|
|
54 return true;
|
|
55 }
|
|
56
|
|
57 private:
|
|
58 wxGrid* m_grid;
|
|
59 };
|
22
|
60
|
|
61 class DnDFile2 : public wxFileDropTarget
|
|
62 {
|
|
63 public:
|
|
64 DnDFile2( MyFrame *frame )
|
|
65 {
|
|
66 m_frame = frame;
|
|
67 }
|
|
68 virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames )
|
|
69 {
|
|
70 size_t nFiles = filenames.GetCount();
|
|
71 if ( nFiles != 1 ) return false;
|
|
72
|
|
73 m_frame->ShowBPrintFrame( filenames[0] );
|
|
74
|
|
75 return true;
|
|
76 }
|
|
77
|
|
78 private:
|
|
79 MyFrame* m_frame;
|
|
80 };
|
|
81
|
5
|
82 #endif //__DNDFILE_H__
|
22
|
83
|