Source

TrafficLight / src / UI / SettingsView.cs

using System.Collections.Generic;
using RossCode.TrafficLight.Core.Domain;
using RossCode.TrafficLight.Core.Presenters.Views;
using System.Linq;
using RossCode.TrafficLight.Core.Utilities;

namespace RossCode.TrafficLight.UI
{
    public partial class SettingsView : BaseForm, ISettingsView
    {
        public SettingsView()
        {
            InitializeComponent();
            btnSave.Click += (sender, args) => SaveClicked();

        }

        public void SetSelectedProjectsTo(IEnumerable<IndicatorType> indicatorTypes)
        {
            var indicators = indicatorTypes as IList<IndicatorType> ?? indicatorTypes.ToList();
            chkBuildIndicatorDelcom.Checked = (indicators.Contains(IndicatorType.Delcom));
            chkBuildIndicatorBusyLight.Checked = (indicators.Contains(IndicatorType.BusyLight)); 
        }

        public IList<IndicatorType> GetIndicatoryTypes()
        {
            var indicators = new List<IndicatorType>();

            if (chkBuildIndicatorDelcom.Checked) indicators.Add(IndicatorType.Delcom);
            if (chkBuildIndicatorBusyLight.Checked) indicators.Add(IndicatorType.BusyLight);

            return indicators;
        } 

        public event VoidHandler SaveClicked = delegate { };
    }
}