Beispiel #1
0
        private void btnRun_Click(object sender, System.EventArgs e)
        {
            msg = frmMain.msg;
            if (frmMain.isCanceling || frmMain.isRunning)
            {
                frmMain.status.Text = "can not run this time";
                return;
            }

            frmMain.isRunning = true;
            btnRun.Enabled    = false;
            btnExit.Text      = "Cancel";
            msg.clear();

            try
            {
                run_main();
            }
            catch (cc.AppException exp)
            {
                if (!exp.isIgnore)
                {
                    msg.println("have error:" + exp.MessageAll);
                }
            }
            catch (Exception exp)
            {
                msg.println("not expected error::" + exp.Message);
            }

            if (isMainStart)
            {
                //if output Start,then out "end time"
                msg.println("End:" + System.DateTime.Now + "(elapsed:" + (int)((System.DateTime.Now - MainTime).TotalMilliseconds / 1000) + " Seconds)");
                isMainStart = false;
            }

            btnExit.Text        = "Exit";
            frmMain.isRunning   = false;
            frmMain.isCanceling = false;
            btnRun.Enabled      = true;

            if (frmMain.isClosing)
            {
                frmMain.Close();
            }
        }
Beispiel #2
0
        private void run_main()
        {
            string sFrom = txtFrom.Text.Trim();

            if (sFrom.Equals(""))
            {
                msg.println("what dir to del?", Color.Red);
                return;
            }
            if (!sFrom.EndsWith("\\"))
            {
                sFrom += "\\";
            }
            if (!Directory.Exists(sFrom))
            {
                msg.println("not exist this dir", Color.Red);
                return;
            }
            if (clstClr.CheckedItems.Count < 1)
            {
                msg.println("Please define or select file&directory to delete.");
                return;
            }

            //Start do samething
            if (MessageBox.Show("Start delete files defined in list?", "Msg...", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            msg.clear();
            msg.Focus();
            frmMain.status.Text = "delete files.";
            isMainStart         = true;
            MainTime            = System.DateTime.Now;
            msg.println("Start:" + MainTime);

            run_main_sub(sFrom);
        }