////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>	Attaches the ui to the given controller. </summary>
        ///
        /// <param name="controller">	The controller. </param>
        public void Attach(IModelExtractorController controller)
        {
            mController = controller;

            // Attach to controller state changes
            mController.StateChanged += ControllerStateChanged;
            SetState(ModelExtractorStateEnum.ExtractorClosed);

            // Attach to extraction manager events
            var extractionManager = mController.GetExtractionManager();

            extractionManager.JobAdded +=
                (sender, args) =>
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new Action(
                                    () =>
                    {
                        AddJob(args.JobID, args.JobName);
                        SetJobState(args.JobID, args.JobState, "");
                    })
                                );
                }
                else
                {
                    AddJob(args.JobID, args.JobName);
                    SetJobState(args.JobID, args.JobState, "");
                }
            };

            extractionManager.JobRemoved +=
                (sender, args) =>
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new Action(
                                    () =>
                    {
                        RemoveJob(args.JobID);
                    })
                                );
                }
                else
                {
                    RemoveJob(args.JobID);
                }
            };

            extractionManager.JobStateChanged +=
                (sender, args) =>
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new Action(
                                    () =>
                    {
                        SetJobState(args.JobID, args.JobState, args.ResultString);
                    })
                                );
                }
                else
                {
                    SetJobState(args.JobID, args.JobState, args.ResultString);
                }
            };
        }
Exemplo n.º 2
0
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Attaches the ui to the given controller. </summary>
		///
		/// <param name="controller">	The controller. </param>
		public void Attach(IModelExtractorController controller)
		{
			mController = controller;

			// Attach to controller state changes
			mController.StateChanged += ControllerStateChanged;
			SetState(ModelExtractorStateEnum.ExtractorClosed);

			// Attach to extraction manager events
			var extractionManager = mController.GetExtractionManager();

			extractionManager.JobAdded +=
				(sender, args) =>
				{
					if (InvokeRequired)
					{
						BeginInvoke(new Action(
							() => 
							{
								AddJob(args.JobID, args.JobName);
								SetJobState(args.JobID, args.JobState, "");
							})
						);
					}
					else
					{
						AddJob(args.JobID, args.JobName);
						SetJobState(args.JobID, args.JobState, "");
					}
				};

			extractionManager.JobRemoved +=
				(sender, args) =>
				{
					if (InvokeRequired)
					{
						BeginInvoke(new Action(
							() =>
							{
								RemoveJob(args.JobID);
							})
						);
					}
					else
					{
						RemoveJob(args.JobID);
					}
				};

			extractionManager.JobStateChanged +=
				(sender, args) =>
				{
					if (InvokeRequired)
					{
						BeginInvoke(new Action(
							() =>
							{
								SetJobState(args.JobID, args.JobState, args.ResultString);
							})
						);
					}
					else
					{
						SetJobState(args.JobID, args.JobState, args.ResultString);
					}
				};
		}
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>	Clears the completed jobs in the extraction manager. </summary>
 ///
 /// <param name="sender">	Source of the event. </param>
 /// <param name="e">	    Event information. </param>
 private void ClearCompletedJobs(object sender, EventArgs e)
 {
     mController.GetExtractionManager().ClearCompletedJobs();
 }