public static void CreateBatteryLivetile() { //Uri tileUri = new Uri("/View/MainPage.xaml?pi=PILivetile&tile=battery", UriKind.Relative); Uri tileUri = new Uri("/View/FlashlightPage.xaml?pi=PILivetile&tile=battery", UriKind.Relative); ShellTile.Create(tileUri, LivetileHelper.GetBatteryLivetileData(), false); }
private void CreateBatteryLivetileImage() { LivetileTemplateItem batteryItem = LivetileSelector.ItemsSource[2] as LivetileTemplateItem; batteryItem.Background = new SolidColorBrush((SettingHelper.Get(Constants.LIVETILE_BATTERY_BACKGROUND_COLOR) as ColorItem).Color); batteryItem.BackTitle = AppResources.ApplicationTitle; LivetileData data = new LivetileData(); //배터리 이미지 로드 LivetileHelper.CreateLivetileImage(data, LiveItems.Battery); LoadLivetileImage(batteryItem); //배터리 백타일 내용 batteryItem.LiveBackTileContent = LivetileHelper.GetBatteryBackTextContent(); batteryItem.Visibility = System.Windows.Visibility.Visible; if (ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("battery")) != null) { batteryItem.PinIconOpacity = 1; GetAppBarButton(AppResources.PinBatteryLivetile).IsEnabled = false; UpdateLiveTile(batteryItem, 0); } else { batteryItem.PinIconOpacity = 0.3; GetAppBarButton(AppResources.PinBatteryLivetile).IsEnabled = true; } }
private void CreateWeatherLivetileImage() { LivetileTemplateItem weatherItem = LivetileSelector.ItemsSource[0] as LivetileTemplateItem; //날씨 데이타 LivetileData data = new LivetileData() { LiveWeather = SettingHelper.Get(Constants.WEATHER_LIVE_RESULT) as LiveWeather, Forecasts = SettingHelper.Get(Constants.WEATHER_FORECAST_RESULT) as Forecasts }; //날씨 이미지 로드 LivetileHelper.CreateLivetileImage(data, LiveItems.Weather); LoadLivetileImage(weatherItem); weatherItem.Visibility = System.Windows.Visibility.Visible; if (ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("weather")) != null) { weatherItem.PinIconOpacity = 1; GetAppBarButton(AppResources.PinWeatherLivetile).IsEnabled = false; UpdateLiveTile(weatherItem, 0); } else { weatherItem.PinIconOpacity = 0.3; GetAppBarButton(AppResources.PinWeatherLivetile).IsEnabled = true; } }
private void SetLivetileImage(ScheduledTask task, LivetileData data) { try { System.Diagnostics.Debug.WriteLine("타일 전 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage); for (int i = 0; i < ShellTile.ActiveTiles.Count(); i++) { ShellTile tile = ShellTile.ActiveTiles.ElementAt(i); if (tile.NavigationUri.ToString().Contains("calendar")) { List <Appointment> appList = data.DayList.Find(x => x.DateTime.ToLongDateString() == DateTime.Today.ToLongDateString()).AppointmentList; int count = appList == null ? 0 : appList.Count; LivetileHelper.CreateLivetileImage(data, LiveItems.Calendar); tile.Update(LivetileHelper.GetCalendarLivetileData(count)); } else if (tile.NavigationUri.ToString().Contains("weather")) { LivetileHelper.CreateLivetileImage(data, LiveItems.Weather); tile.Update(LivetileHelper.GetWeatherLivetileData()); } else if (tile.NavigationUri.ToString().Contains("battery")) { LivetileHelper.CreateLivetileImage(data, LiveItems.Battery); tile.Update(LivetileHelper.GetBatteryLivetileData()); } } System.Diagnostics.Debug.WriteLine("타일 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage); //배터리 잠금화면 업데이트 UpdateBatteryStatus(); System.Diagnostics.Debug.WriteLine("배터리 후 =>" + Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } #if DEBUG_AGENT ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(30)); System.Diagnostics.Debug.WriteLine(Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage); #else IsolatedStorageSettings.ApplicationSettings[Constants.LAST_RUN_LIVETILE] = DateTime.Now; IsolatedStorageSettings.ApplicationSettings.Save(); #endif }
/* * 타일을 업데이트 한다. */ private void UpdateLiveTile(LivetileTemplateItem item, int appCount) { ShellTile oTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(item.LiveItem.ToString().ToLower().ToString())); if (oTile != null) { if (item.LiveItem == LiveItems.Weather) { oTile.Update(LivetileHelper.GetWeatherLivetileData()); } else if (item.LiveItem == LiveItems.Battery) { oTile.Update(LivetileHelper.GetBatteryLivetileData()); } else { oTile.Update(LivetileHelper.GetCalendarLivetileData(appCount)); } } }
public static void CreateWeatherLivetile() { Uri tileUri = new Uri("/View/MainPage.xaml?pi=PIWeather&tile=weather", UriKind.Relative); ShellTile.Create(tileUri, LivetileHelper.GetWeatherLivetileData(), false); }
public void CreateCalendarLivetile(int appointCount) { Uri tileUri = new Uri("/View/MainPage.xaml?pi=PICalendar&tile=calendar", UriKind.Relative); ShellTile.Create(tileUri, LivetileHelper.GetCalendarLivetileData(appointCount), false); }
private void CreateCalendarLivetileImage() { LivetileTemplateItem calendarItem = LivetileSelector.ItemsSource[1] as LivetileTemplateItem; calendarItem.Background = new SolidColorBrush((SettingHelper.Get(Constants.LIVETILE_CALENDAR_BACKGROUND_COLOR) as ColorItem).Color); calendarItem.BackTitle = AppResources.ApplicationTitle; //달력이미지를 무조건 새로 생성해서 화면 업데이트 LivetileData data = new LivetileData() { DayList = VsCalendar.GetCalendarOfMonth(DateTime.Now, DateTime.Now, true, true) }; if ((bool)SettingHelper.Get(Constants.CALENDAR_SHOW_APPOINTMENT)) { Appointments appointments = new Appointments(); appointments.SearchCompleted += (s, se) => { //달력 데이타 VsCalendar.MergeCalendar(data.DayList, se.Results); LivetileHelper.CreateLivetileImage(data, LiveItems.Calendar); LoadLivetileImage(calendarItem); //일정이 몇개 있는지를 백타일에 표시 List <Appointment> appList = data.DayList.Find(x => x.DateTime.ToLongDateString() == DateTime.Today.ToLongDateString()).AppointmentList; int count = appList == null ? 0 : appList.Count; calendarItem.LiveBackTileContent = LivetileHelper.GetCalendarBackTextContent(count); calendarItem.Visibility = System.Windows.Visibility.Visible; if (ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("calendar")) != null) { calendarItem.PinIconOpacity = 1; GetAppBarButton(AppResources.PinCalendarLivetile).IsEnabled = false; UpdateLiveTile(calendarItem, count); } else { calendarItem.PinIconOpacity = 0.3; GetAppBarButton(AppResources.PinCalendarLivetile).IsEnabled = true; } }; appointments.SearchAsync(data.DayList[7].DateTime, data.DayList[data.DayList.Count - 1].DateTime.AddDays(1), null); } else { //전체 타일 이미지 생성 LivetileHelper.CreateLivetileImage(data, LiveItems.Calendar); //달력 이미지 로드 LoadLivetileImage(calendarItem); //백타일에 일정 표시하지 않음 calendarItem.LiveBackTileContent = LivetileHelper.GetCalendarBackTextContent(-1); calendarItem.Visibility = System.Windows.Visibility.Visible; if (ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("calendar")) != null) { calendarItem.PinIconOpacity = 1; GetAppBarButton(AppResources.PinCalendarLivetile).IsEnabled = false; UpdateLiveTile(calendarItem, -1); } else { calendarItem.PinIconOpacity = 0.3; GetAppBarButton(AppResources.PinCalendarLivetile).IsEnabled = true; } } }