Esempio n. 1
0
        public static async Task Initialize()
        {
            DeviceInformationCollection devices;

            CallManager = await CallManager.GetSystemPhoneCallManagerAsync();

            CallStore = await PhoneCallManager.RequestStoreAsync();

            CallHistoryStore = await PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesReadWrite);

            devices = await DeviceInformation.FindAllAsync(ProximitySensor.GetDeviceSelector());

            ProximitySensor = devices.Count > 0 ? ProximitySensor.FromId(devices.First().Id) : null;
            VibrationAccessStatus accessStatus = await VibrationDevice.RequestAccessAsync();

            if (accessStatus == VibrationAccessStatus.Allowed)
            {
                VibrationDevice = await VibrationDevice.GetDefaultAsync();
            }
            try
            {
                DefaultLine = await PhoneLine.FromIdAsync(await CallStore.GetDefaultLineAsync());
            }
            catch
            {
            }
            Initialized = true;
        }
        public Scenario1_DataEvents()
        {
            this.InitializeComponent();

            watcher        = DeviceInformation.CreateWatcher(ProximitySensor.GetDeviceSelector());
            watcher.Added += OnProximitySensorAdded;
            watcher.Start();
        }
Esempio n. 3
0
        public ProximityStateTrigger()
        {
            var watcher = DeviceInformation.CreateWatcher(ProximitySensor.GetDeviceSelector());

            watcher.Added   += OnProximitySensorAddedAsync;
            watcher.Removed += OnProximitySensorRemoved;
            watcher.Start();
        }
Esempio n. 4
0
        public List <DeviceInfo> CreateList()
        {
            List <DeviceInfo> selectors = new List <DeviceInfo>();

            // Pre-canned device class selectors
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "All Device Interfaces (default)", DeviceClassSelector = DeviceClass.All, Selection = null
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Audio Capture", DeviceClassSelector = DeviceClass.AudioCapture, Selection = null
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Audio Render", DeviceClassSelector = DeviceClass.AudioRender, Selection = null
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Image Scanner", DeviceClassSelector = DeviceClass.ImageScanner, Selection = null
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Location", DeviceClassSelector = DeviceClass.Location, Selection = null
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Portable Storage", DeviceClassSelector = DeviceClass.PortableStorageDevice, Selection = null
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Video Capture", DeviceClassSelector = DeviceClass.VideoCapture, Selection = null
            });

            // A few examples of selectors built dynamically by windows runtime apis.
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Human Interface (HID)", Selection = HidDevice.GetDeviceSelector(0, 0)
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Activity Sensor", Selection = ActivitySensor.GetDeviceSelector()
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Pedometer", Selection = Pedometer.GetDeviceSelector()
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Proximity", Selection = ProximityDevice.GetDeviceSelector()
            });
            selectors.Add(new DeviceInfo()
            {
                DisplayName = "Proximity Sensor", Selection = ProximitySensor.GetDeviceSelector()
            });

            return(selectors);
        }
Esempio n. 5
0
        private async Task AttachAsync()
        {
            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
            {
                var devices = await DeviceInformation.FindAllAsync(ProximitySensor.GetDeviceSelector());

                if (devices.Count > 0)
                {
                    _sensor = ProximitySensor.FromId(devices[0].Id);
                    //_sensor.ReadingChanged += OnReadingChanged;

                    _controller = _sensor.CreateDisplayOnOffController();
                }
            }
        }
Esempio n. 6
0
        async Task GetOrRegisterProximityTaskAsync()
        {
            // This technique also valid for the Pedometer where you can specify
            // a particular step count.
            var deviceInfoList = await DeviceInformation.FindAllAsync(
                ProximitySensor.GetDeviceSelector());

            var deviceInfo = deviceInfoList.FirstOrDefault();

            if (deviceInfo != null)
            {
                var proximtySensor = ProximitySensor.FromId(deviceInfo.Id);
                var threshold      = new ProximitySensorDataThreshold(proximtySensor);
                var trigger        = new SensorDataThresholdTrigger(threshold);

                this.proximityTaskRegistration = FindOrRegisterBackgroundTaskFromLibrary(
                    "Proximity Trigger",
                    trigger);
            }
        }
Esempio n. 7
0
 public ProximityHelper()
 {
     _watcher        = DeviceInformation.CreateWatcher(ProximitySensor.GetDeviceSelector());
     _watcher.Added += OnProximitySensorAdded;
     _watcher.Start();
 }
Esempio n. 8
0
        public PlaybackService(IProtoService protoService, ICacheService cacheService, ISettingsService settingsService, IEventAggregator aggregator)
        {
            if (!ApiInfo.IsMediaSupported)
            {
                return;
            }

            _protoService    = protoService;
            _cacheService    = cacheService;
            _settingsService = settingsService;
            _aggregator      = aggregator;

            _mediaPlayer = new MediaPlayer();
            _mediaPlayer.PlaybackSession.PlaybackStateChanged += OnPlaybackStateChanged;
            _mediaPlayer.PlaybackSession.PositionChanged      += OnPositionChanged;
            _mediaPlayer.MediaFailed             += OnMediaFailed;
            _mediaPlayer.MediaEnded              += OnMediaEnded;
            _mediaPlayer.SourceChanged           += OnSourceChanged;
            _mediaPlayer.CommandManager.IsEnabled = false;
            _mediaPlayer.Volume = _settingsService.VolumeLevel;

            _transport = _mediaPlayer.SystemMediaTransportControls;
            _transport.ButtonPressed += Transport_ButtonPressed;

            _transport.AutoRepeatMode = _settingsService.Playback.RepeatMode;
            _isRepeatEnabled          = _settingsService.Playback.RepeatMode == MediaPlaybackAutoRepeatMode.Track
                ? null
                : _settingsService.Playback.RepeatMode == MediaPlaybackAutoRepeatMode.List
                ? true
                : (bool?)false;

            _mapping = new Dictionary <string, PlaybackItem>();

            aggregator.Subscribe(this);

            _watcher        = Windows.Devices.Enumeration.DeviceInformation.CreateWatcher(ProximitySensor.GetDeviceSelector());
            _watcher.Added += OnProximitySensorAdded;
            _watcher.Start();
        }