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 frmMain_Load(object sender, System.EventArgs e)
        {
            ccMsg = new cc.Msg(txtMsg);

            // add ver to title
            System.Reflection.Assembly ass = System.Reflection.Assembly.GetExecutingAssembly();
            string sver = System.Diagnostics.FileVersionInfo.GetVersionInfo(ass.Location).FileVersion;

            this.Text = this.Text + " (Version:" + sver + ") - uuware.com";

            //all tabpages, for set Init,and load it
            lstPage.Items.Clear();
            //add first page
            //tabData[0].page = tabControl1.TabPages[0];
            //tabControl1.TabPages[0].Name = "0";
            //lstPage.Items.Add("About - something about this project");
            //lstPageHide has this pages for load

            TabPage      page1  = new TabPage("Diff");
            TabPage      page2  = new TabPage("Clear");
            TabPage      page3  = new TabPage("About");
            PageDirDiff  pDiff  = new PageDirDiff();
            PageDirClear pClear = new PageDirClear();
            PageAbout2   pAbout = new PageAbout2();

            tabControl1.TabPages.Clear();
            page1.Controls.Add(pDiff);
            page2.Controls.Add(pClear);
            page3.Controls.Add(pAbout);
            pDiff.Dock     = DockStyle.Fill;
            pClear.Dock    = DockStyle.Fill;
            pAbout.Dock    = DockStyle.Fill;
            pDiff.frmMain  = this;
            pClear.frmMain = this;
            pAbout.frmMain = this;
            tabControl1.TabPages.Add(page1);
            tabControl1.TabPages.Add(page2);
            tabControl1.TabPages.Add(page3);

            if (false)
            {
                for (int i = 0; i < lstPageHide.Items.Count; i++)
                {
                    string sItem = lstPageHide.Items[i].ToString();
                    if (!sItem.Equals("") && !sItem.StartsWith("#"))
                    {
                        if (sItem.IndexOf(".") < 0)
                        {
                            sItem = this.CompanyName + "." + sItem;
                        }
                        Type ctlType = Type.GetType(sItem);
                        if (ctlType != null && ctlType.BaseType.Name.Equals("UserControl"))
                        {
                            object  obj     = System.Reflection.Assembly.GetAssembly(ctlType).CreateInstance(sItem);
                            Control userCtl = (Control)obj;
                            System.Reflection.MethodInfo method = ctlType.GetMethod("Init");
                            if (method != null && method.GetParameters().Length == 1)
                            {
                                method.Invoke(userCtl, new object[] { this });
                            }
                            else
                            {
                                msg.println("Error when load page:" + sItem, Color.Red);
                            }
                            string sTitle;
                            System.Reflection.PropertyInfo property = ctlType.GetProperty("Title");
                            if (property != null)
                            {
                                sTitle = (string)property.GetValue(userCtl, null);
                            }
                            else
                            {
                                sTitle = "NewPage";
                            }
                            string sComment;
                            System.Reflection.PropertyInfo property2 = ctlType.GetProperty("Comment");
                            if (property2 != null)
                            {
                                sComment = (string)property2.GetValue(userCtl, null);
                            }
                            else
                            {
                                sComment = "Comment for this page";
                            }

                            //add comment to list,for show/hide them
                            lstPage.Items.Add(sTitle + " - " + sComment);
                            //index for page.Name and tabData's index
                            int     nIndex = lstPage.Items.Count - 1;
                            TabPage page   = new TabPage(sTitle);
                            page.Name        = "" + nIndex;
                            page.ToolTipText = sComment;
                            page.Controls.Add(userCtl);
                            userCtl.Dock = DockStyle.Fill;
                            //page is add at Config_Load
                            //tabControl1.TabPages.Add(page);
                            tabData[nIndex].page = page;
                        }
                    }
                }
            }

            Config_Load(Application.ExecutablePath + ".ini");
        }