public ConnectionSettingsViewModel() { _pageService = new PageService(); asyncSocketListener = AsyncSocketListener.Instance; asyncClient = AsyncClient.Instance; if (asyncClient.IsConnected() == true) { Settings.ClientIsConnected = true; } else { Settings.ClientIsConnected = false; } ServerIsRunning = Settings.ServerIsRunning; IsConnectToServer = Settings.ClientIsConnected; ServerPort = Settings.ServerPort; ClientConnectedCount = Settings.ServerClientConnectedQty; StartServerCommand = new Command(() => StartServer()); StopServerCommand = new Command(() => StopServer()); ConnectToServerCommand = new Command(() => ConnectToServer()); StartPresentationForCLientCommand = new Command(async() => await StartPresentationForCLient()); DisconnectWithServerCommand = new Command(() => DisconnectWithServer()); IPServerAdress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString(); MessagingCenter.Subscribe <AsyncSocketListener, Boolean> (this, Events.SendPlaylist, OnServerIsRunning); MessagingCenter.Subscribe <AsyncSocketListener, int> (this, Events.ClientConnected, OnClientConnected); MessagingCenter.Subscribe <AsyncSocketListener, int> (this, Events.ClientDisconnected, OnClientDisconnected); MessagingCenter.Subscribe <AsyncClient, Boolean> (this, Events.ConnectToServer, OnConnectToServer); }
public SongTextPresentationViewModel() { songRepository = new SongRepository(DependencyService.Get <ISQLiteDb>()); MessagingCenter.Subscribe <PlaylistDetailViewModel, PlaylistViewModel> (this, Events.SendPlaylistToPresentation, OnPlaylistSended); MessagingCenter.Subscribe <ConnectionSettingsViewModel, Boolean> (this, Events.ConnectToServer, OnConnectToServer); MessagingCenter.Subscribe <AsyncClient, string> (this, Events.SendedText, OnTextRecive); MessagingCenter.Subscribe <SongListViewModel, SongViewModel> (this, Events.SendSongToPresentation, OnSongSended); asyncSocketListener = AsyncSocketListener.Instance; asyncClient = AsyncClient.Instance; FontSize = Double.Parse(Settings.FontSize); ShowChords = Settings.ShowChords; }