internal SettingViewModel(PeerCastApplication peca_app)
{
this.pecaApp = peca_app;
this.peerCast = peca_app.PeerCast;
this.AddPortCommand = new Command(() => AddPort());
this.RemovePortCommand = new Command(() => RemovePort(), () => SelectedPort!=null);
this.AddYellowPageCommand = new Command(() => AddYellowPage());
this.RemoveYellowPageCommand = new Command(() => RemoveYellowPage(), () => SelectedYellowPage!=null);
this.CheckBandwidth = new CheckBandwidthCommand(this);
channelCleanupMode = ChannelCleaner.Mode;
channelCleanupInactiveLimit = ChannelCleaner.InactiveLimit/60000;
maxRelays = peerCast.AccessController.MaxRelays;
maxRelaysPerChannel = peerCast.AccessController.MaxRelaysPerChannel;
maxPlays = peerCast.AccessController.MaxPlays;
maxPlaysPerChannel = peerCast.AccessController.MaxPlaysPerChannel;
maxUpstreamRate = peerCast.AccessController.MaxUpstreamRate;
maxUpstreamRatePerChannel = peerCast.AccessController.MaxUpstreamRatePerChannel;
isShowWindowOnStartup = pecaApp.Settings.Get<WPFSettings>().ShowWindowOnStartup;
ports = new ObservableCollection<OutputListenerViewModel>(
peerCast.OutputListeners
.Select(listener => new OutputListenerViewModel(this, listener))
);
yellowPages = new ObservableCollection<YellowPageClientViewModel>(
peerCast.YellowPages
.Select(yp => new YellowPageClientViewModel(this, yp))
);
var port_mapper = pecaApp.Plugins.GetPlugin<PeerCastStation.UI.PortMapperPlugin>();
if (port_mapper!=null) {
portMapperEnabled = port_mapper.Enabled;
port_mapper.DiscoverAsync()
.ContinueWith(prev => OnPropertyChanged("PortMapperExternalAddresses"));
}
PortCheckStatus = PortCheckStatus.Checking;
CheckPortAsync().ContinueWith(prev => {
if (prev.IsCanceled || prev.IsFaulted) {
PortCheckStatus = PortCheckStatus.Failed;
}
else {
PortCheckStatus = prev.Result;
}
});
}