码迷,mamicode.com
首页 > 其他好文 > 详细

BaseWorkerForm : Form

时间:2014-07-23 11:36:46      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   for   re   

using System.Collections.Generic;
using System.Windows.Forms;
using WindowsFormsApplication3.Enums;
using WindowsFormsApplication3.Jobs;
using WindowsFormsApplication3.Model;
using WindowsFormsApplication3.DataStorge;


namespace WindowsFormsApplication3.FormPage
{
    public class BaseWorkerForm : Form
    {
        public delegate void FormStatusChangedHandler();
        public event FormStatusChangedHandler FormStatusChanged;
        protected int childFormNO;
        public int ChildFormNO{ 
            get{return childFormNO;}}


        protected CheckoutContext checkoutContext;
        protected List<BaseJob> jobs;
        protected FormStatus status;
        public virtual FormStatus Status {
            get { return status; }
        }

        public BaseWorkerForm():this(new CheckoutContext(),CheckoutStep.Introduction){}
        public BaseWorkerForm(CheckoutContext checkoutContext,CheckoutStep checkoutStep):base()
        {
            this.checkoutContext= checkoutContext;
            jobs=new List<BaseJob>();

        }

        public virtual void Execute(object obj)
        {
            status = FormStatus.Processing;
            ReportChildFormNO();
            ReportFormStatusChanged();
        }

        public void ReportFormStatusChanged(){
        if(FormStatusChanged!=null)
            FormStatusChanged();
        }

        public virtual void RefreshForm() { 
        }

        public virtual void ResetForm() {
            jobs.Clear();
            status = FormStatus.Waiting;
            ReportFormStatusChanged();
        }

        public void ReportChildFormNO() {
            childFormNO = 0;
            foreach (var childf in checkoutContext.formHierachy) {
                if (childf.fatherForm == base.Text)
                    childFormNO++;
            }
        }

        public int FinishedChildFormNO(string formname) {
            int finishedFormNO = 0;
            foreach (var childf in checkoutContext.formHierachy)
            {
                if (childf.fatherForm == formname&&childf.childForm.status==FormStatus.OK)
                    finishedFormNO++;
            }
            return finishedFormNO;
        }
    }
}

BaseWorkerForm : Form,布布扣,bubuko.com

BaseWorkerForm : Form

标签:style   blog   color   io   for   re   

原文地址:http://www.cnblogs.com/rosizel/p/3861616.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!