예제 #1
0
        public override async Task OnNavigateToAsync()
        {
            HwndSource hwndSource = (HwndSource)PresentationSource.FromVisual(Application.Current.MainWindow);
            IPlayerNotificationProvider playerNotificationProvider = new PlayerNotificationProvider(hwndSource);
            IDeviceListener             uPnPDeviceListener         = new UPnPDeviceListener(new NetworkInfoProvider(), this.transportFactory);
            IDeviceDiscovery            uPnPDeviceDiscovery        = new UPnPDeviceDiscovery(this.transportFactory, uPnPDeviceListener);
            IDeviceDiscovery            tvDiscovery = new TvDiscovery(uPnPDeviceDiscovery, new TcpWebTransport(TimeSpan.FromSeconds(5)));

            this.deviceController = new DeviceController(tvDiscovery, this.devicePairing, playerNotificationProvider, new DeviceSettingProvider(), base.Controller);
            this.deviceController.StartDiscovery();
            base.IsDataLoaded = false;
            await this.CheckForUpdates();

            bool previousDeviceAsync = await this.deviceController.ConnectToPreviousDeviceAsync();

            base.IsDataLoaded = true;
            if (!previousDeviceAsync)
            {
                base.Controller.Navigate(new WelcomeViewModel(this.deviceController), true);
            }
            else
            {
                base.Controller.Push(new WelcomeViewModel(this.deviceController));
                base.Controller.Navigate(new MainViewModel(this.deviceController), true);
            }
        }
예제 #2
0
        static async void loadController()
        {
            Guid deviceId = Settings.Default.DeviceId;

            if (deviceId == Guid.Empty)
            {
                Console.WriteLine("No saved device ID found");
                Settings @default = Settings.Default;
                Guid     guid     = Guid.NewGuid();
                deviceId          = guid;
                @default.DeviceId = guid;
                Settings.Default.Save();
            }
            else
            {
                //Console.WriteLine("Previously saved device ID found");
            }

            transportFactory = new TransportFactory();
            devicePairing    = new DevicePairing(deviceId, transportFactory, new SpcApiWrapper());
            IPlayerNotificationProvider playerNotificationProvider = new PlayerNotificationProvider();
            IDeviceListener             uPnPDeviceListener         = new UPnPDeviceListener(new NetworkInfoProvider(), transportFactory);
            IDeviceDiscovery            uPnPDeviceDiscovery        = new UPnPDeviceDiscovery(transportFactory, uPnPDeviceListener);
            IDeviceDiscovery            tvDiscovery = new TvDiscovery(uPnPDeviceDiscovery, new TcpWebTransport(TimeSpan.FromSeconds(5)));

            deviceController = new DeviceController(tvDiscovery, devicePairing, playerNotificationProvider, new DeviceSettingProvider());
            //Console.WriteLine("Device discovery starting");
            deviceController.StartDiscovery();

            bool previousDeviceAsync = await deviceController.ConnectToPreviousDeviceAsync();

            if (!previousDeviceAsync)
            {
                Console.WriteLine("No previously paired TV found.");
                loadDevice(deviceController);
                checkNetwork(deviceController);
            }
            else
            {
                Console.WriteLine("Previously paired TV found.");
                verifyNetwork();
            }
        }