Ejemplo n.º 1
0
        /// <summary>
        /// See base docs.
        /// </summary>
        protected override void CreateBindings()
        {
            base.CreateBindings();

            var rebroadcastFormatManager = Factory.ResolveSingleton<IRebroadcastFormatManager>();

            AddControlBinder(new MasterListToListBinder<Configuration, RebroadcastSettings>(SettingsView.Configuration, listRebroadcastServers, r => r.RebroadcastSettings) {
                FetchColumns = (rebroadcastServer, e) => {
                    var receiver = SettingsView.CombinedFeed.FirstOrDefault(r => r.UniqueId == rebroadcastServer.ReceiverId);
                    var portDescription = !rebroadcastServer.IsTransmitter ? String.Format("::{0}", rebroadcastServer.Port) : String.Format("{0}:{1}", rebroadcastServer.TransmitAddress, rebroadcastServer.Port);

                    e.Checked = rebroadcastServer.Enabled;
                    e.ColumnTexts.Add(rebroadcastServer.Name);
                    e.ColumnTexts.Add(receiver == null ? "" : receiver.Name ?? "");
                    e.ColumnTexts.Add(rebroadcastFormatManager.ShortName(rebroadcastServer.Format));
                    e.ColumnTexts.Add(portDescription);
                    e.ColumnTexts.Add(Describe.DefaultAccess(rebroadcastServer.Access.DefaultAccess));
                },
                GetSortValue = (rebroadcastServer, header, defaultValue) => {
                    IComparable result = defaultValue;
                    if(header == columnHeaderUNC) {
                        if(!rebroadcastServer.IsTransmitter) result = String.Format("_{0:00000}", rebroadcastServer.Port);
                        else                                 result = String.Format("{0}:{1:00000}", rebroadcastServer.TransmitAddress, rebroadcastServer.Port);
                    }

                    return result;
                },
                AddHandler = () => SettingsView.CreateRebroadcastServer(),
                AutoDeleteEnabled = true,
                EditHandler = (rebroadcastServer) => SettingsView.DisplayPageForPageObject(rebroadcastServer),
                CheckedChangedHandler = (rebroadcastServer, isChecked) => rebroadcastServer.Enabled = isChecked,
            });
        }