summaryrefslogtreecommitdiff
path: root/Bus/IvyFileMon/IvyFileMonDlg.cpp
diff options
context:
space:
mode:
authorfcolin2007-02-01 13:29:31 +0000
committerfcolin2007-02-01 13:29:31 +0000
commitafe2e7dfc1388cad991e8d38dda7d648c137aa52 (patch)
tree92bf63d2b2b34a805927aa294c7c51912638f66a /Bus/IvyFileMon/IvyFileMonDlg.cpp
parent0be65f8a110ee9bf5da9c93e0bd5b5b62b3bad0c (diff)
parent04c263c314499e38d64af9d4a1aa5e2b8d9d5ead (diff)
downloadivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.zip
ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.tar.gz
ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.tar.bz2
ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.tar.xz
modif struct svnwindows@3001
Diffstat (limited to 'Bus/IvyFileMon/IvyFileMonDlg.cpp')
-rw-r--r--Bus/IvyFileMon/IvyFileMonDlg.cpp281
1 files changed, 0 insertions, 281 deletions
diff --git a/Bus/IvyFileMon/IvyFileMonDlg.cpp b/Bus/IvyFileMon/IvyFileMonDlg.cpp
deleted file mode 100644
index 719ea66..0000000
--- a/Bus/IvyFileMon/IvyFileMonDlg.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-// IvyFileMonDlg.cpp : fichier d'implémentation
-//
-
-#include "stdafx.h"
-#include "IvyFileMon.h"
-#include "IvyFileMonDlg.h"
-#include "ParseCmdLine.h"
-#include "IvyApplication.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-const char * CONVSTR( const CString& str )
-{
-#ifdef UNDER_CE
-
- static char buffer[4096];
- int len = str.GetLength();
- buffer[len] = '\0';
- if ( len )
- {
- int err = WideCharToMultiByte( CP_ACP, 0, str, len, buffer, 4096, NULL, NULL );
- if ( err == 0 )
- TRACE(TEXT("Error converting chars %d\n"),GetLastError());
- }
- return buffer;
-#else
- return (LPCSTR) str;
-#endif
-
-}
-
-
-
-// boîte de dialogue CAboutDlg utilisée pour la boîte de dialogue 'À propos de' pour votre application
-
-class CAboutDlg : public CDialog
-{
-public:
- CAboutDlg();
-
-// Données de la boîte de dialogue
- enum { IDD = IDD_ABOUTBOX };
-
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // prise en charge de DDX/DDV
-
-// Implémentation
-protected:
- DECLARE_MESSAGE_MAP()
-};
-
-CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
-{
-}
-
-void CAboutDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
-}
-
-BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
-END_MESSAGE_MAP()
-
-
-// boîte de dialogue CIvyFileMonDlg
-
-
-
-CIvyFileMonDlg::CIvyFileMonDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CIvyFileMonDlg::IDD, pParent)
- , m_busnumber(_T(""))
- , m_directory(_T(""))
- , m_prefix(_T(""))
- , m_extent(_T(""))
-{
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-}
-
-void CIvyFileMonDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_BUS, m_busnumber);
- DDX_Text(pDX, IDC_DIRECTORY, m_directory);
- DDX_Text(pDX, IDC_PREFIX, m_prefix);
- DDX_Control(pDX, IDC_TEXT, m_text);
- DDX_Text(pDX, IDC_EXTENT, m_extent);
-}
-
-BEGIN_MESSAGE_MAP(CIvyFileMonDlg, CDialog)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(IDC_START, OnBnClickedStart)
-END_MESSAGE_MAP()
-
-
-// gestionnaires de messages pour CIvyFileMonDlg
-
-void CIvyFileMonDlg::WriteMessage(const char *format, ...)
-{
- char str[4096];
- // format and write the data we were given
- va_list args;
- va_start(args, format);
- vsprintf(str, format, args);
-
- m_text.AppendString( str );
-}
-
-void CIvyFileMonDlg::OnDirectMessage(IvyApplication *app, int id, const char *arg)
-{
-TRACE(TEXT("Direct Msg Receive %d, %s\n"),id,arg );
-}
-
-void CIvyFileMonDlg::OnApplicationConnected(IvyApplication *app)
-{
- WriteMessage( "Application: %s ready",(LPCSTR)(app->GetName()) );
-}
-void CIvyFileMonDlg::OnApplicationDisconnected(IvyApplication *app)
-{
- WriteMessage( "Application: %s bye",(LPCSTR)(app->GetName()) );
-}
-
-
-BOOL CIvyFileMonDlg::OnInitDialog()
-{
- CDialog::OnInitDialog();
-
- // Ajouter l'élément de menu "À propos de..." au menu Système.
-
- // IDM_ABOUTBOX doit se trouver dans la plage des commandes système.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
-
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
-
- // Définir l'icône de cette boîte de dialogue. L'infrastructure effectue cela automatiquement
- // lorsque la fenêtre principale de l'application n'est pas une boîte de dialogue
- SetIcon(m_hIcon, TRUE); // Définir une grande icône
- SetIcon(m_hIcon, FALSE); // Définir une petite icône
-
- // parse command Line Info
- ParseCmdLine cmd;
- AfxGetApp()->ParseCommandLine( cmd );
-
- // Set Argument from Command Line
- m_busnumber = cmd.m_busNumber;
- m_directory = cmd.m_directory;
- m_extent = cmd.m_extent;
- m_prefix = cmd.m_prefix;
-
- bus = new Ivy( "IvyFileMon","IvyFileMon Ready",this,FALSE);
-
-// bus->BindMsg("(.*)", BUS_CALLBACK_OF(CTestDlg, IvyCallback ));
-
- //bus->BindMsg("^S( A=([0-9]+))?( B=([0-9]+))?",cb);
- m_busnumber = bus->GetDomain( CONVSTR(m_busnumber) );
- UpdateData(FALSE);
-
- // force bus start in case of start
- if ( cmd.m_start )
- OnBnClickedStart();
- return TRUE; // retourner TRUE, sauf si vous avez défini le focus sur un contrôle
-}
-void CIvyFileMonDlg::OnCancel()
-{
- // TODO: Add extra cleanup here
-
- if ( bus )
- {
- bus->stop();
- delete bus;
- }
-
- CDialog::OnCancel();
-}
-void CIvyFileMonDlg::OnSysCommand(UINT nID, LPARAM lParam)
-{
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
-}
-
-// Si vous ajoutez un bouton Réduire à votre boîte de dialogue, vous devez utiliser le code ci-dessous
-// pour dessiner l'icône. Pour les applications MFC utilisant le modèle Document/Vue,
-// cela est fait automatiquement par l'infrastructure.
-
-void CIvyFileMonDlg::OnPaint()
-{
- if (IsIconic())
- {
- CPaintDC dc(this); // contexte de périphérique pour la peinture
-
- SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
-
- // Centrer l'icône dans le rectangle client
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Dessiner l'icône
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
-}
-
-// Le système appelle cette fonction pour obtenir le curseur à afficher lorsque l'utilisateur fait glisser
-// la fenêtre réduite.
-HCURSOR CIvyFileMonDlg::OnQueryDragIcon()
-{
- return static_cast<HCURSOR>(m_hIcon);
-}
-
-void CIvyFileMonDlg::OnBnClickedStart()
-{
- UpdateData(TRUE);
- bus->stop();
- m_busnumber = bus->GetDomain( CONVSTR(m_busnumber) );
- bus->start(CONVSTR(m_busnumber));
- watcher.WatchDirectory(m_directory,
- FILE_NOTIFY_CHANGE_FILE_NAME |FILE_NOTIFY_CHANGE_LAST_WRITE,
- this,
- FALSE, //<-- watch sub directories?
- m_extent, //<-- Include Filter
- NULL);//<-- Exclude Filter
- UpdateData(FALSE);
-}
-
-void CIvyFileMonDlg::SendIvyFile(const CString & strFileName)
-{
- CStdioFile file;
- CString line;
-
- TRACE("File Change %s\n", (LPCSTR)strFileName );
- if ( file.Open( strFileName, CFile::modeRead ) )
- {
- WriteMessage( "File %s Change sending file...",(LPCSTR)strFileName );
- bus->SendMsg("%s FileBegin %s",(LPCSTR)m_prefix, (LPCSTR)strFileName);
- while( file.ReadString(line) )
- {
- bus->SendMsg("%s FileLine %s",(LPCSTR) m_prefix, (LPCSTR)line);
- }
- file.Close();
- bus->SendMsg("%s FileEnd",(LPCSTR) m_prefix);
- WriteMessage( "File %s Change done",(LPCSTR)strFileName );
- }
-
-}
-void CIvyFileMonDlg::On_FileAdded(const CString & strFileName)
-{
- SendIvyFile( strFileName );
-}
-void CIvyFileMonDlg::On_FileModified(const CString & strFileName)
-{
- SendIvyFile( strFileName );
-} \ No newline at end of file