Exemple #1
0
        /// <summary>
        /// See base docs.
        /// </summary>
        protected override void CreateBindings()
        {
            base.CreateBindings();

            var combinedFeeds         = SettingsView.CombinedFeed;
            var receiverFormatManager = Factory.Singleton.Resolve <IReceiverFormatManager>().Singleton;
            var settings = SettingsView.Configuration.GoogleMapSettings;

            AddControlBinder(new ComboBoxBinder <GoogleMapSettings, CombinedFeed, int>(settings, comboBoxWebSiteReceiverId, combinedFeeds, r => r.WebSiteReceiverId, (r, v) => r.WebSiteReceiverId = v)
            {
                GetListItemDescription = r => r.Name, GetListItemValue = r => r.UniqueId, SortList = true,
            });
            AddControlBinder(new ComboBoxBinder <GoogleMapSettings, CombinedFeed, int>(settings, comboBoxClosestAircraftReceiverId, combinedFeeds, r => r.ClosestAircraftReceiverId, (r, v) => r.ClosestAircraftReceiverId = v)
            {
                GetListItemDescription = r => r.Name, GetListItemValue = r => r.UniqueId, SortList = true,
            });
            AddControlBinder(new ComboBoxBinder <GoogleMapSettings, CombinedFeed, int>(settings, comboBoxFsxReceiverId, combinedFeeds, r => r.FlightSimulatorXReceiverId, (r, v) => r.FlightSimulatorXReceiverId = v)
            {
                GetListItemDescription = r => r.Name, GetListItemValue = r => r.UniqueId, SortList = true,
            });

            AddControlBinder(new MasterListToListBinder <Configuration, Receiver>(SettingsView.Configuration, listReceivers, r => r.Receivers)
            {
                FetchColumns = (receiver, e) => {
                    var location = SettingsView == null ? null : SettingsView.Configuration.ReceiverLocations.FirstOrDefault(r => r.UniqueId == receiver.ReceiverLocationId);

                    e.Checked = receiver.Enabled;
                    e.ColumnTexts.Add(receiver.Name);
                    e.ColumnTexts.Add(receiverFormatManager.ShortName(receiver.DataSource));
                    e.ColumnTexts.Add(Describe.ReceiverUsage(receiver.ReceiverUsage));
                    e.ColumnTexts.Add(location == null ? "" : location.Name);
                    e.ColumnTexts.Add(Describe.ConnectionType(receiver.ConnectionType));
                    e.ColumnTexts.Add(DescribeConnectionParameters(receiver));
                },
                AddHandler            = () => SettingsView.CreateReceiver(),
                DeleteHandler         = (r) => SettingsView.RemoveReceivers(r),
                EditHandler           = (receiver) => SettingsView.DisplayPageForPageObject(receiver),
                CheckedChangedHandler = (receiver, isChecked) => receiver.Enabled = isChecked,
            });
        }