BaseWorkerForm

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() {
            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

时间: 2024-10-16 04:04:38

BaseWorkerForm的相关文章

OperationSystemForm : BaseWorkerForm

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Windows.Forms; using WindowsFormsApplication3.Enums; usin

BaseWorkerForm : Form

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

ThreadPool

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Windows.Forms; using WindowsFormsApplication3.Enums; usin

FormHierachy

using System; using System.Collections.Generic; using System.Linq; using System.Text; using WindowsFormsApplication3.DataStorge; using WindowsFormsApplication3.FormPage; namespace WindowsFormsApplication3.Model { public class FormHierachy { public st

MainForm()

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using WindowsFormsApplication3.Model; using WindowsFormsApplicatio

OperationSystemForm

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Windows.Forms; using WindowsFormsApplication3.Enums; usin