protected override async void OnNavigatedTo(NavigationEventArgs e) { loader.IsActive = true; Application.Current.Resuming += (s, ar) => { try { if (Memory.Live_Tile) { LiveTile.Update(); /* Update / reset live tile */ } else { LiveTile.Reset(); } Header_Set(); Body_Set(); } catch { } }; var cmp = Windows.Devices.Sensors.Compass.GetDefault(); if (cmp == null) { Compass_Btn.Visibility = Visibility.Collapsed; } else { Compass_Btn.Visibility = Visibility.Visible; } if (Memory.Live_Tile) { LiveTile.Update(); /* Update / reset live tile */ } else { LiveTile.Reset(); } DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += new TypedEventHandler <DataTransferManager, DataRequestedEventArgs>(this.ShareTextHandler); HardwareButtons.BackPressed += HardwareButtons_BackPressed; Header_Set(); Body_Set(); if (MainPage.firstUpad) //ako ulazi u app postavi grupne notifijacije { await Task.Delay(1600); MainPage.firstUpad = false; Set.Group_Notifications(2, 0, false); } }
public async void Run(IBackgroundTaskInstance taskInstance) { System.Diagnostics.Debug.WriteLine("WE are @ Background"); _deferral = taskInstance.GetDeferral(); _taskInstance = taskInstance; _taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(OnCanceled); GattCharacteristicNotificationTriggerDetails details = (GattCharacteristicNotificationTriggerDetails)taskInstance.TriggerDetails; //get the characteristics data and get heartbeat value out from it byte[] ReceivedData = new byte[details.Value.Length]; DataReader.FromBuffer(details.Value).ReadBytes(ReceivedData); HeartbeatMeasurement tmpMeasurement = HeartbeatMeasurement.GetHeartbeatMeasurementFromData(ReceivedData); System.Diagnostics.Debug.WriteLine("Background heartbeast values: " + tmpMeasurement.HeartbeatValue); // send heartbeat values via progress callback _taskInstance.Progress = tmpMeasurement.HeartbeatValue; //update the value to the Tile LiveTile.UpdateSecondaryTile("" + tmpMeasurement.HeartbeatValue); //Check if we are within the limits, and alert by starting the app if we are not alertType alert = await checkHeartbeatLevels(tmpMeasurement.HeartbeatValue); _deferral.Complete(); }
public async void Run(IBackgroundTaskInstance taskInstance) { var def = taskInstance.GetDeferral(); try { Data.data = Set.JsonToArray <Data>(await Get.Read_Data_To_String())[0]; Year.Set(); if (Memory.Live_Tile) { LiveTile.Update(); } else { LiveTile.Reset(); } Set.Group_Notifications(2, 0, false); } finally { def.Complete(); } }
public void Delete(TaskModel task) { Tasks.Remove(task); task.RemoveSystemReminder(); LiveTile.Unpin(task); }
private void InitialTileSetup() { if (App.ViewModel != null && App.ViewModel.Item != null) { LiveTile.UpdateLiveTile("Trivia Buff", App.ViewModel.Item.Title); } }
/// <summary> /// 用户设置个人信息 /// 个人信息页面的"应用"按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void SetInformation(object sender, RoutedEventArgs e) { ContentDialog dialog; dialog = new ContentDialog() { Title = "提示", PrimaryButtonText = "确认", Content = "确定要修改信息?", FullSizeDesired = false }; if (Info.Email != "" && CheckEmail(Info.Email) == false) { /// 判断答案是否不为空格式且格式错误 dialog.Content = "邮箱格式错误"; dialog.PrimaryButtonClick += (_s, _e) => { }; } else { /// 确认个人信息无不合法填写时 /// 提示用户是否保存修改信息 /// 点击"确认"保存,点击"取消"不保存 dialog.Content = "确定修改信息?"; dialog.SecondaryButtonText = "取消"; dialog.PrimaryButtonClick += (_s, _e) => { UserInfo.SetInfo("UserName", Info.Name); UserInfo.SetInfo("Birth", Info.Birth); UserInfo.SetInfo("Email", Info.Email); UserInfo.SaveImage(Info.Avator, "Avator.jpg"); LiveTile.LoadTile(); }; dialog.SecondaryButtonClick += (_s, _e) => { }; } await dialog.ShowAsync(); }
/// <summary> /// 初始化单一实例应用程序对象。这是执行的创作代码的第一行, /// 已执行,逻辑上等同于 main() 或 WinMain()。 /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; loginFlag = false; // 加载动态磁贴 LiveTile.LoadTile(); }
protected override void OnInvoke(ScheduledTask scheduledTask) { Debug.WriteLine(">>> BACKGROUND AGENT <<<"); #if DEBUG if (Debugger.IsAttached) { ScheduledActionService.LaunchForTest(scheduledTask.Name, TimeSpan.FromSeconds(65)); Debug.WriteLine("> LAUNCH FOR TEST"); } #endif // Aktualizace každý den 1x if (scheduledTask.LastScheduledTime.Date != DateTime.Today) { Debug.WriteLine(">>> BACKGROUND AGENT: UPDATE <<<"); Settings.Current = Settings.LoadFromFile(AppInfo.SettingsFileName); if (Settings.Current.EnableTile) { TaskCollection tasks = TaskCollection.LoadFromFile(AppInfo.TasksFileName); if (tasks != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { LiveTile.Update(tasks); foreach (TaskModel task in tasks) { if (task.HasDueDate) { DateTime date = task.ActualDueDate.Value.Date; if (date == DateTimeExtensions.Today) //if (date >= DateTimeExtensions.Yesterday && date <= DateTimeExtensions.Tomorrow) { LiveTile.Update(task); } } } Debug.WriteLine(">>> BACKGROUND AGENT: DONE <<<"); ShowMemoryUsage(); NotifyComplete(); }); } else { Debug.WriteLine(">>> BACKGROUND AGENT: no tasks <<<"); ShowMemoryUsage(); NotifyComplete(); } } } else { Debug.WriteLine(">>> BACKGROUND AGENT: PASS <<<"); ShowMemoryUsage(); NotifyComplete(); } }
private void Odaberi_Btn_Click(object sender, RoutedEventArgs e) { Memory.location = locationsListBox.SelectedIndex; LiveTile.Update(); Notification.Set(Data.Obavijest.All); Frame.Navigate(typeof(Home)); }
private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason) { LiveTile.UpdateSecondaryTile("--"); System.Diagnostics.Debug.WriteLine("Background " + sender.Task.Name + " Cancel Requested because " + reason); if (!reason.Equals(BackgroundTaskCancellationReason.Abort)) { ToastHelper.PopToast("Background Cancelled", "Background Task Cancelled, reason: " + reason + ", please re-start the applications."); } }
/// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); try { LiveTile.Update(); } finally { deferral.Complete(); } }
/// <summary> /// Agent that runs a scheduled task /// </summary> /// <param name="task"> /// The invoked task /// </param> /// <remarks> /// This method is called when a periodic or resource intensive task is invoked /// </remarks> protected override void OnInvoke(ScheduledTask task) { try { var model = new MainViewModel(); model.OnLoaded += () => { if (model.Item == null) { return; } if (model.Items == null || model.Items.Count < 3) { return; } int randomIndex = new Random().Next(3); var item = model.Items[randomIndex]; string title = "Trivia Buff"; string description = item.Title; Deployment.Current.Dispatcher.BeginInvoke(() => { try { LiveTile.UpdateLiveTile(title, description); Debug.WriteLine("Current memory - updated: {0}", DeviceStatus.ApplicationCurrentMemoryUsage); } catch { // TODO: log error } NotifyComplete(); }); }; model.OnError += exception => { // TODO: log error NotifyComplete(); }; model.LoadData(); } catch (Exception e) { NotifyComplete(); } }
private void livetile_TS_Toggled(object sender, RoutedEventArgs e) { if (ucitavam) { return; } Memory.Live_Tile = livetile_TS.IsOn; if (Memory.Live_Tile) { LiveTile.Update(); } else { LiveTile.Reset(); } Postavi_Stranicu(); }
public async void Run(IBackgroundTaskInstance taskInstance) { var def = taskInstance.GetDeferral(); try { Data.data = Data.JsonToArray <Data>(await Data.Read_Data_To_String(Fixed.App_Data_File))[0]; LiveTile.Update(); Notification.Set(Data.Obavijest.All); } finally { def.Complete(); } }
protected override void OnNavigatedFrom(NavigationEventArgs e) { Debug.WriteLine("NAV FROM: {0} ({1})", this, e.NavigationMode); base.OnNavigatedFrom(e); if (!e.IsNavigationInitiator) { LiveTile.UpdateOrReset(Settings.Current.EnableTile, App.Tasks.Tasks); foreach (TaskModel task in App.Tasks.Tasks) { if (task.ModifiedSinceStart) { task.ModifiedSinceStart = false; LiveTile.Update(task); } } } }
/// <summary> /// Agent that runs a scheduled task /// </summary> /// <param name="task"> /// The invoked task /// </param> /// <remarks> /// This method is called when a periodic or resource intensive task is invoked /// </remarks> protected override void OnInvoke(ScheduledTask task) { Debug.WriteLine("Memory limit: {0}", DeviceStatus.ApplicationMemoryUsageLimit); Debug.WriteLine("Current memory - initial: {0}", DeviceStatus.ApplicationCurrentMemoryUsage); DataManager.Current.Load <DayViewModel>( CurrentDateForWiki, vm => { Debug.WriteLine("Current memory - loaded: {0}", DeviceStatus.ApplicationCurrentMemoryUsage); try { if (vm.Highlights.Count == 0) { return; } int index = new Random().Next(vm.Highlights.Count); Entry entry = vm.Highlights[index]; string title = entry.Year; string content = entry.Description; GC.Collect(); GC.WaitForPendingFinalizers(); LiveTile.UpdateLiveTile(title, content); Debug.WriteLine("Current memory - updated: {0}", DeviceStatus.ApplicationCurrentMemoryUsage); } finally { NotifyComplete(); } }, ex => { // TODO: report error using bugsense NotifyComplete(); }); }
/// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); try { if (Memory.Live_Tile) /// Update / reset live tile { LiveTile.Update(); } else { LiveTile.Reset(); } Set.Group_Notifications(2, 0, false); } finally { deferral.Complete(); } }
protected void AppointmentsSearchCompleted(object sender, AppointmentsSearchEventArgs e) { var licenseInfo = new LicenseInformation(); if (!licenseInfo.IsTrial()) { var appointment = Calendar.GetAppointment(e); if (appointment == null) { return; } LiveTile.Update(appointment.Subject, appointment.Location, appointment.DateAndTime, Battery, AppSettings); } else { LiveTile.Update("Sample Calendar Item", "Get full version", "to display calendar items", Battery, AppSettings); } // Call NotifyComplete to let the system know the agent is done working. NotifyComplete(); }
public void Complete(TaskModel task) { if (task == null) { return; } task.Completed = DateTime.Now; task.ModifiedSinceStart = true; if (Settings.Current.CompleteSubtasks && task.HasSubtasks) { foreach (Subtask subtask in task.Subtasks) { subtask.IsCompleted = true; } } if (Settings.Current.UnpinCompleted && !task.HasRepeats) { LiveTile.Unpin(task); } App.Tasks.Update(task); }
private void RebuildTable() { Children.Clear(); if (ItemsSource == null || !(ItemsSource is IEnumerable)) return; var list = (ItemsSource as IEnumerable).OfType<object>().ToList(); int count = list.Count; int rows = currentRowCount; int cols = currentColumnCount; int itemSpace = rows * cols; bool hasLiveTile = false; if (count > itemSpace) { LiveTile tile = new LiveTile() { ItemsSource = ItemsSource, ItemTemplate = LiveTileItemTemplate, Margin = new Thickness(0, 0, 20, 20) }; tile.SetValue(Callisto.Effects.Tilt.IsTiltEnabledProperty, true); Children.Add(tile); hasLiveTile = true; tile.Tapped += livetile_Tapped; } int i = 0; for (int c = 0; c < cols; c++) { for (int r = 0; r < rows; r++) { if (i >= list.Count) break; if (hasLiveTile && c < 2 && r < 2) continue; ContentControl ctrl = new ContentControl() { Content = list[i++], ContentTemplate = ItemTemplate, Margin = new Thickness(0, 0, 20, 20), HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch, VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch, HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch, VerticalContentAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch }; //ctrl.Transitions = new Windows.UI.Xaml.Media.Animation.TransitionCollection(); //ctrl.Transitions.Add(new Windows.UI.Xaml.Media.Animation.AddDeleteThemeTransition()); //ctrl.Transitions.Add(new Windows.UI.Xaml.Media.Animation.EntranceThemeTransition()); ctrl.SetValue(Callisto.Effects.Tilt.IsTiltEnabledProperty, true); if (r == rows - 1 && c == Math.Min(cols, MaxColumnCount) - 1 && count > rows * cols) // last item { ctrl.ContentTemplate = MoreTemplate; ctrl.Tapped += moreTile_Tapped; } else { ctrl.Tapped += ctrl_Tapped; } Children.Add(ctrl); } } }
private void setTile_Click(object sender, RoutedEventArgs e) { LiveTile.CreateSecoondaryTile(); }
private void livetile_TS_Toggled(object sender, RoutedEventArgs e) { Memory.Live_Tile = livetile_TS.IsOn; LiveTile.Update(); }
public void Unpin() { LiveTile.Unpin(Task); }
//private string image_pathStr; public HomePage() { this.InitializeComponent(); live_tile = new LiveTile(); }
public bool IsPinned() { return(LiveTile.IsPinned(Task)); }
private void UpdateTileAction() { LiveTile tile = new LiveTile(); tile.CreateTileAsync(); }
public static void Pin(TaskModel task) { Pin(task, LiveTile.CreateTile(task)); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); _CityData = e.Parameter as CityData; /*set country flag*/ /*string _CountryCode = _CityData.PlaceInfo.DisplayName; * _CountryCode = _CountryCode.Substring(_CountryCode.LastIndexOf(",") + 2); * StorageFolder _assets = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets"); * StorageFolder _flags = await _assets.GetFolderAsync("CountriesFlag"); * * if (_flags.TryGetItemAsync(_CountryCode + ".png") != null) * { * CurrentPlaceName.Text = _CityData.PlaceInfo.DisplayName.Substring(0, _CityData.PlaceInfo.DisplayName.LastIndexOf(",")); * BitmapImage image = new BitmapImage(new Uri("ms-appx:///Assets/CountriesFlag/" + _CountryCode + ".png")); * CountryFlag.Source = image; * } * else { * CurrentPlaceName.Text = _CityData.PlaceInfo.DisplayName; * }*/ /*set country flag*/ CurrentPlaceName.Text = _CityData.PlaceInfo.DisplayName; this.DataContext = _CityData; DailyForecastResult = _CityData.DailyForecast; CurrentWeatherResult = _CityData.Current; PlaceInfo = _CityData.PlaceInfo; CoverLink = _CityData.CoverImage; /*set back navigation arguments*/ if (_LocationHistory == null) { _LocationHistory = new List <PlaceInfo>(); _LocationHistory.Add(_CityData.PlaceInfo); } if (_LocationHistory[_LocationHistory.Count - 1].PlaceId != _CityData.PlaceInfo.PlaceId) { _LocationHistory.Add(_CityData.PlaceInfo); } if (_LocationHistory.Count > 1) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; AppNameGrid.Margin = new Thickness(55, 10, 0, 10); } else { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; AppNameGrid.Margin = new Thickness(20, 10, 0, 10); } /*set back navigation arguments*/ _Settings = await UserDataHelper.GetSettings("Settings.json"); if (_Settings.SaveData == "1" || _CityData.IsLocalData == true) { BottomItemsPivot.Items.Remove(BottomItemsPivot.Items.Single(p => ((PivotItem)p).Name == "NewsPivot")); BottomItemsPivot.Items.Remove(BottomItemsPivot.Items.Single(p => ((PivotItem)p).Name == "GalleryPivot")); _CityData.CoverImage = "ms-appx:///Assets/Weather/11.jpg"; if (_CityData.CoverImage != null) { BitmapImage image = new BitmapImage(new Uri(_CityData.CoverImage)); Cover.Source = image; } } else { int _CheckFileAge = await ApplicationData.Current.LocalFolder.TryGetItemAsync("News.json") != null ? await UserDataHelper.CheckFileAge("News.json", "local") : 1441; string Language = _Settings.Language ?? "en"; if (_CheckFileAge >= 1440) { _NewsResults = await News.GetNewsData(Language); bool _SaveNews = await UserDataHelper.SaveNewsData(_NewsResults); } else { _NewsResults = await UserDataHelper.GetSavedNews(); if (_NewsResults.Language != _Settings.Language) { _NewsResults = await News.GetNewsData(Language); bool _SaveNews = await UserDataHelper.SaveNewsData(_NewsResults); } } NewsData.ItemsSource = _NewsResults.articles; await GetCover(_CityData.PlaceInfo.DisplayName); } CoverLink = _CityData.CoverImage; var favorites = (await UserDataHelper.GetFavorites("Favorites.json")); var _CurrentPlace = favorites.Where(x => x.PlaceId == _CityData.PlaceInfo.PlaceId).ToList(); if (_CurrentPlace.Count > 0) { SaveToFavorites.Visibility = Visibility.Collapsed; RemoveFromFavorites.Visibility = Visibility.Visible; } SetAsHome.IsEnabled = _CityData.PlaceInfo.PlaceId == _Settings.DefaultLocation.PlaceId ? false : true; if (SecondaryTile.Exists(_CityData.PlaceInfo.PlaceId)) { PinToStart.Visibility = Visibility.Collapsed; UnPinFromStart.Visibility = Visibility.Visible; await LiveTile.UpdateCustomTile(PlaceInfo, CurrentWeatherResult, DailyForecastResult, CoverLink); } if (_CityData.PlaceInfo.PlaceId == _Settings.DefaultLocation.PlaceId) { LiveTile.UpdateTile(PlaceInfo, CurrentWeatherResult, DailyForecastResult, CoverLink); } if (favorites.ToList().Where(x => x.PlaceId == _CityData.PlaceInfo.PlaceId).FirstOrDefault() != null) { await UserDataHelper.SaveFavoriteWeather(_CityData); } }
private async void AvailableActions_ItemClick(object sender, ItemClickEventArgs e) { switch ((e.ClickedItem as StackPanel).Tag.ToString()) { case "SetHome": var settings = await UserDataHelper.GetSettings("Settings.json"); settings.DefaultLocation = _CityData.PlaceInfo; await UserDataHelper.WriteFile("Settings.json", settings); SetAsHome.IsEnabled = false; ShowToolTip("SavedAsHome", 2000); break; case "Favorite": var IsFavorited = (await UserDataHelper.SaveToFavorites("Favorites.json", _CityData.PlaceInfo)); if (IsFavorited == true) { await UserDataHelper.SaveFavoriteWeather(_CityData); SaveToFavorites.Visibility = Visibility.Collapsed; RemoveFromFavorites.Visibility = Visibility.Visible; ShowToolTip("Favorited", 2000); } break; case "UnFavorite": var IsUnfavorited = (await UserDataHelper.RemoveFromFavorites("Favorites.json", _CityData.PlaceInfo)); if (IsUnfavorited == true) { await UserDataHelper.RemoveFavoriteWeather(_CityData.PlaceInfo.PlaceId); SaveToFavorites.Visibility = Visibility.Visible; RemoveFromFavorites.Visibility = Visibility.Collapsed; ShowToolTip("Unfavorited", 2000); } break; case "Pin": ShowToolTip("Pinning", 2000); var IsPined = await LiveTile.UpdateCustomTile(PlaceInfo, CurrentWeatherResult, DailyForecastResult, CoverLink); if (IsPined == true) { PinToStart.Visibility = Visibility.Collapsed; UnPinFromStart.Visibility = Visibility.Visible; ShowToolTip("Pined", 2000); } break; case "UnPin": ShowToolTip("Unpinning", 2000); var IsUnPined = await LiveTile.UnpinCustomTile(_CityData.PlaceInfo.PlaceId); if (IsUnPined == true) { PinToStart.Visibility = Visibility.Visible; UnPinFromStart.Visibility = Visibility.Collapsed; ShowToolTip("Unpined", 2000); } break; case "Download": ShowToolTip("DownloadingImage", 2000); BitmapImage bitMap = Cover.Source as BitmapImage; string uri = bitMap?.UriSource.ToString(); await UserDataHelper.DownloadAsset(uri); ShowToolTip("Downloaded", 2000); break; case "Rate": await Launcher.LaunchUriAsync(new Uri(string.Format("ms-windows-store:REVIEW?PFN={0}", Windows.ApplicationModel.Package.Current.Id.FamilyName))); break; case "Feedback": await Microsoft.Services.Store.Engagement.StoreServicesFeedbackLauncher.GetDefault().LaunchAsync(); break; default: break; } }