Ejemplo n.º 1
0
        /// <summary>
        /// Set the active watch face
        /// </summary>
        /// <param name="_item"></param>
        public async Task SetActiveWatchApp(vmWatchApp _item)
        {
            try
            {
                Connector.PebbleConnector _pc = Connector.PebbleConnector.GetInstance();

                await _pc.Launch(_item.Model);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
        public async void LoadImage(vmWatchApp item)
        {
            try
            {
                Windows.Storage.StorageFolder LocalFolder = Windows.Storage.ApplicationData.Current.LocalFolder;

                item.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage();

                if (item.ImageFile.Contains("ms-app"))
                {
                    item.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(item.ImageFile));
                }
                else
                {
                    Windows.Storage.StorageFile file = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(item.ImageFile);

                    await item.Image.SetSourceAsync(await file.OpenAsync(Windows.Storage.FileAccessMode.Read));
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("vmWatchApps:LoadImage: " + e.Message);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Event handler for watch items
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void WatchItemListChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            //Clear all watchfaces
            case NotifyCollectionChangedAction.Reset:

                WatchApps.Clear();
                AddSportApp();

                break;


            //Add viewmodel WatchFace
            case NotifyCollectionChangedAction.Add:

                foreach (IWatchItem item in e.NewItems)
                {
                    if (item.Type == WatchItemType.WatchApp)
                    {
                        if (item.ID == Guid.Parse(Constants.TennisAppGuid))
                        {
                            return;
                        }

                        try
                        {
                            var vmExistingWatchFace = WatchApps.Single(x => x.Model == item.ID);
                            WatchApps.Remove(vmExistingWatchFace);
                        }
                        catch (Exception) { };

                        vmWatchApp _newWatchApp = new vmWatchApp();
                        _newWatchApp.Name         = item.Name;
                        _newWatchApp.Model        = item.ID;
                        _newWatchApp.Developer    = item.Developer;
                        _newWatchApp.ImageFile    = item.File.Replace(".zip", ".gif");
                        _newWatchApp.Configurable = item.Configurable;
                        _newWatchApp.Item         = item;

                        WatchApps.Add(_newWatchApp);
                        LoadImage(_newWatchApp);

                        System.Diagnostics.Debug.WriteLine("vmWatchApps add item: " + item.Name);
                    }
                }

                //Sort
                var SortedApps = WatchApps.OrderBy(x => x.Name).ToList();
                WatchApps.Clear();

                foreach (var App in SortedApps)
                {
                    WatchApps.Add(App);
                }

                break;

            //Remove viewmodel WatchFace
            case NotifyCollectionChangedAction.Remove:

                foreach (IWatchItem item in e.OldItems)
                {
                    if (item.Type == WatchItemType.WatchApp)
                    {
                        vmWatchApp element = null;

                        foreach (var WatchApp in WatchApps)
                        {
                            if (WatchApp.Model == item.ID)
                            {
                                element = WatchApp;
                                break;
                            }
                        }

                        try
                        {
                            if (element != null)
                            {
                                WatchApps.Remove(element);
                            }
                        }
                        catch (Exception) { }

                        System.Diagnostics.Debug.WriteLine("vmWatchApps remove item: " + item.Name);
                    }
                }

                break;
            }
        }