Esempio n. 1
0
        void FolderMonitor_Created(object sender, FileSystemEventArgs e)
        {
            FSW             fsw = (FSW)sender;
            int             idx = int.Parse(fsw.Tag.ToString());
            FlowLayoutPanel fl  = (FlowLayoutPanel)flowPanel.Controls[idx];

            this.Invoke((MethodInvoker) delegate
            {
                ListBox lb = ((ListBox)fl.Controls[ilb]);
                addToLB(lb, e.FullPath + ":" + e.ChangeType);
            });
        }
Esempio n. 2
0
        void FolderMonitor_Changed(object sender, FileSystemEventArgs e)
        {
            FSW             fsw = (FSW)sender;
            int             idx = int.Parse(fsw.Tag.ToString());
            FlowLayoutPanel fl  = (FlowLayoutPanel)flowPanel.Controls[idx];

            this.Invoke((MethodInvoker) delegate
            {
                ListBox lb = ((ListBox)fl.Controls[ilb]);
                addToLB(lb, e.FullPath + ":" + e.ChangeType);
                string strPath = ((TextBox)fl.Controls[itxt2]).Text;
                if (strPath != "" && ((CheckBox)fl.Controls[icb2]).CheckState == CheckState.Checked)
                {
                    if (strPath.ToLower().EndsWith(".vbs"))
                    {
                        ProcessStartInfo psi = new ProcessStartInfo(@"C:\WINDOWS\system32\wscript.exe");
                        psi.Arguments        = strPath + " " + e.FullPath;
                        FileInfo fi          = new FileInfo(e.FullPath);
                        psi.WorkingDirectory = fi.Directory.FullName;
                        Process.Start(psi);
                    }
                    else
                    {
                        if (strLastRun.Equals(e.FullPath))
                        {
                            DateTime dtNow = DateTime.Now;
                            TimeSpan ts    = new TimeSpan(dtNow.Ticks - dtLastRun.Ticks);
                            if (ts.TotalSeconds < 5)
                            {
                                return;
                            }
                            dtLastRun = dtNow;
                        }
                        else
                        {
                            strLastRun = e.FullPath;
                        }
                        Process.Start(strPath, e.FullPath);
                    }
                    addToLB(lb, strPath + ":Run");
                }
            });
        }
Esempio n. 3
0
        private void FolderMonitor_Load(object sender, EventArgs e)
        {
            timer1.Tick    += new EventHandler(timer1_Tick);
            timer1.Interval = 100;
            int idriv = 0;

            for (int idx = 0; idx < fsws.Length; idx++)
            {
                fsws[idx]                       = new FSW();
                fsws[idx].Changed              += new FileSystemEventHandler(FolderMonitor_Changed);
                fsws[idx].Created              += new FileSystemEventHandler(FolderMonitor_Created);
                fsws[idx].Deleted              += new FileSystemEventHandler(FolderMonitor_Deleted);
                fsws[idx].Renamed              += new RenamedEventHandler(FolderMonitor_Renamed);
                fsws[idx].EnableRaisingEvents   = false;
                fsws[idx].IncludeSubdirectories = true;
                fsws[idx].Filter                = "*.*";
                fsws[idx].Tag                   = idx;

                TextBox tb = new TextBox();
                tb.Width = 200;
                tb.Tag   = idx;
                if ((idx + idriv) < DriveInfo.GetDrives().Length)
                {
                    DriveInfo di = DriveInfo.GetDrives()[idx + idriv];
                    while (!di.IsReady)
                    {
                        idriv++;
                        if ((idx + idriv) >= DriveInfo.GetDrives().Length)
                        {
                            break;
                        }

                        di = DriveInfo.GetDrives()[idx + idriv];
                    }
                    tb.Text = di.Name;
                }
                CheckBox cb = new CheckBox();
                cb.Text = "Monitor";
                cb.Tag  = idx;
                cb.CheckStateChanged += new EventHandler(cb_CheckStateChanged);
                cb.Width              = 70;
                cb.Enabled            = false;

                Button btn = new Button();
                btn.Width  = 25;
                btn.Tag    = idx;
                btn.Text   = "...";
                btn.Click += new EventHandler(btn_Click);

                TextBox tb3 = new TextBox();
                tb3.Width = 30;
                tb3.Tag   = idx;
                tb3.Text  = "*.*";

                TextBox tb2 = new TextBox();
                tb2.Width = tb.Width - (tb3.Width + 6);
                tb2.Tag   = idx;

                CheckBox cb2 = new CheckBox();
                cb2.Text = "Run";
                cb2.Tag  = idx;
                cb2.CheckStateChanged += new EventHandler(cb2_CheckStateChanged);
                cb2.Width              = cb.Width;
                cb2.Enabled            = false;

                Button btn2 = new Button();
                btn2.Width  = btn.Width;
                btn2.Tag    = idx;
                btn2.Text   = "...";
                btn2.Click += new EventHandler(btn2_Click);

                ListBox lb = new ListBox();
                lb.BorderStyle         = BorderStyle.FixedSingle;
                lb.BackColor           = Color.White;
                lb.HorizontalScrollbar = true;
                lb.Height = 100;


                FlowLayoutPanel flp = new FlowLayoutPanel();
                flp.Padding = new Padding(0);
                flp.Width   = tb.Width + cb.Width + btn.Width + 20;
                flp.Height  = (Math.Max(Math.Max(tb.Height, cb.Height), Math.Max(btn.Height, 0)) * 2) + lb.Height + 15;
                lb.Width    = flp.Width - 10;
                //lb.Height += 10;
                dblWidthRatio     = ((double)tb.Width / (double)flp.Width);
                flp.FlowDirection = FlowDirection.LeftToRight;
                flp.Controls.Add(tb);
                flp.Controls.Add(cb);
                flp.Controls.Add(btn);
                flp.Controls.Add(tb2);
                flp.Controls.Add(tb3);
                flp.Controls.Add(cb2);
                flp.Controls.Add(btn2);
                flp.Controls.Add(lb);
                flp.Tag = idx;

                flp.BorderStyle = BorderStyle.FixedSingle;
                flp.Resize     += new EventHandler(flp_Resize);

                flowPanel.Controls.Add(flp);
            }
            timer1.Enabled = true;
        }
Esempio n. 4
0
        private void FolderMonitor_Load(object sender, EventArgs e)
        {
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Interval = 100;
            int idriv = 0;
            for (int idx = 0; idx < fsws.Length; idx++)
            {
                fsws[idx] = new FSW();
                fsws[idx].Changed += new FileSystemEventHandler(FolderMonitor_Changed);
                fsws[idx].Created += new FileSystemEventHandler(FolderMonitor_Created);
                fsws[idx].Deleted += new FileSystemEventHandler(FolderMonitor_Deleted);
                fsws[idx].Renamed += new RenamedEventHandler(FolderMonitor_Renamed);
                fsws[idx].EnableRaisingEvents = false;
                fsws[idx].IncludeSubdirectories = true;
                fsws[idx].Filter = "*.*";
                fsws[idx].Tag = idx;

                TextBox tb = new TextBox();
                tb.Width = 200;
                tb.Tag = idx;
                if ((idx + idriv) < DriveInfo.GetDrives().Length)
                {
                    DriveInfo di = DriveInfo.GetDrives()[idx + idriv];
                    while (!di.IsReady)
                    {
                        idriv++;
                        if ((idx + idriv) >= DriveInfo.GetDrives().Length)
                            break;

                        di = DriveInfo.GetDrives()[idx + idriv];
                        
                    }
                    tb.Text = di.Name;
                }
                CheckBox cb = new CheckBox();
                cb.Text = "Monitor";
                cb.Tag = idx;
                cb.CheckStateChanged += new EventHandler(cb_CheckStateChanged);
                cb.Width = 70;
                cb.Enabled = false;

                Button btn = new Button();
                btn.Width = 25;
                btn.Tag = idx;
                btn.Text = "...";
                btn.Click += new EventHandler(btn_Click);

                TextBox tb3 = new TextBox();
                tb3.Width = 30;
                tb3.Tag = idx;
                tb3.Text = "*.*";

                TextBox tb2 = new TextBox();
                tb2.Width = tb.Width - (tb3.Width + 6);
                tb2.Tag = idx;

                CheckBox cb2 = new CheckBox();
                cb2.Text = "Run";
                cb2.Tag = idx;
                cb2.CheckStateChanged += new EventHandler(cb2_CheckStateChanged);
                cb2.Width = cb.Width;
                cb2.Enabled = false;

                Button btn2 = new Button();
                btn2.Width = btn.Width;
                btn2.Tag = idx;
                btn2.Text = "...";
                btn2.Click += new EventHandler(btn2_Click);

                ListBox lb = new ListBox();
                lb.BorderStyle = BorderStyle.FixedSingle;
                lb.BackColor = Color.White;
                lb.HorizontalScrollbar = true;
                lb.Height = 100;


                FlowLayoutPanel flp = new FlowLayoutPanel();
                flp.Padding = new Padding(0);
                flp.Width = tb.Width + cb.Width + btn.Width + 20;
                flp.Height = (Math.Max(Math.Max(tb.Height, cb.Height), Math.Max(btn.Height, 0)) * 2) + lb.Height + 15;
                lb.Width = flp.Width - 10;
                //lb.Height += 10;
                dblWidthRatio = ((double)tb.Width / (double)flp.Width);
                flp.FlowDirection = FlowDirection.LeftToRight;
                flp.Controls.Add(tb);
                flp.Controls.Add(cb);
                flp.Controls.Add(btn);
                flp.Controls.Add(tb2);
                flp.Controls.Add(tb3);
                flp.Controls.Add(cb2);
                flp.Controls.Add(btn2);
                flp.Controls.Add(lb);
                flp.Tag = idx;

                flp.BorderStyle = BorderStyle.FixedSingle;
                flp.Resize += new EventHandler(flp_Resize);

                flowPanel.Controls.Add(flp);
            }
            timer1.Enabled = true;
        }