Commits

Joel Ross committed 7db49d1

Updated form activation to pass in the current build status

  • Participants
  • Parent commits 6bd6685

Comments (0)

Files changed (2)

src/Core/Presenters/PresenterBase.cs

+using RossCode.TrafficLight.Core.Domain;
 using RossCode.TrafficLight.Core.Eventing;
 using RossCode.TrafficLight.Core.Eventing.Events;
 using RossCode.TrafficLight.Core.Presenters.Views;
         protected PresenterBase(T view)
         {
             View = view;
-            DomainEvents.Register<BuildStatusChanged>(UpdateBuildStatus);
-            View.Closed += (sender, e) => DomainEvents.Unregister<BuildStatusChanged>(UpdateBuildStatus);
+            DomainEvents.Register<BuildStatusChanged>(BuildStatusChangedHandler);
+            View.Closed += (sender, e) => DomainEvents.Unregister<BuildStatusChanged>(BuildStatusChangedHandler);
         }
 
-        private void UpdateBuildStatus(BuildStatusChanged args)
+        private void BuildStatusChangedHandler(BuildStatusChanged args)
         {
-            View.SetBuildStatusTo(args.Status);        
+            UpdateBuildStatus(args.Status);
+        }
+
+        public void UpdateBuildStatus(BuildStatus status)
+        {
+            View.SetBuildStatusTo(status);        
         }
     }
 }

src/UI/TrafficLightApplicationContext.cs

 		private MenuItem showBuildStatusMenuItem;
 
         private readonly IDictionary<BuildStatus, Action> setBuildIcon;
+        private BuildStatus currentBuildStatus;
 
-		public TrafficLightApplicationContext(IApplicationService applicationService) 
+        public TrafficLightApplicationContext(IApplicationService applicationService) 
 		{
 			InitializeContext();
             this.applicationService = applicationService;
             var view = presenter.View;
             if (setDataOn != null) setDataOn(presenter);
             view.Show();
+            presenter.UpdateBuildStatus(currentBuildStatus);
             view.Closed += (sender, e) =>
                 {
                     DisposeView(view);
 
         private void ChangeBuildStatus(BuildStatusChanged arg)
         {
+            currentBuildStatus = arg.Status;
             setBuildIcon[arg.Status]();
         }
     }