private void Refresh() { switch (_currentSize) { case 2: WideTile.Refresh(); break; case 1: MediumTile.Refresh(); break; case 0: default: SmallTile.Refresh(); break; } }
private void SaveImageForeground(bool failed, string backcontent) { if (IsolatedStorageSettings.ApplicationSettings.Contains("oldtilestyle") && (bool)IsolatedStorageSettings.ApplicationSettings["oldtilestyle"]) { OldSmallTile.SaveTile(failed, _balance); } else { SmallTile.SaveTile(failed, _balance); } #if (DEBUG) Debug.WriteLine("Live tile: Small image created"); #endif FrontTile.SaveTile(failed, _balance); #if (DEBUG) Debug.WriteLine("Live tile: Front image created"); #endif BackTile.SaveTile(failed, _balance, backcontent); #if (DEBUG) Debug.WriteLine("Live tile: Back image created"); #endif }
public async Task <int> genTileImages(string siteName) { // Get colors by AQI. var aqName = aqHistNames[(int)localSettings.Values["TileBackColorAqId"]]; var aqLevel = getAqLevel(siteName, aqName); // Remove '#'. var rectColorStr = StaticTaqModel.aqColors[aqName][aqLevel].Substring(1); var r = (byte)Convert.ToUInt32(rectColorStr.Substring(0, 2), 16); var g = (byte)Convert.ToUInt32(rectColorStr.Substring(2, 2), 16); var b = (byte)Convert.ToUInt32(rectColorStr.Substring(4, 2), 16); var bgColor = new SolidColorBrush(Color.FromArgb(0xFF, r, g, b)); var textColor = StaticTaqModelView.getTextColor(aqLevel); // Extract time. var dateStr = sitesStrDict[siteName]["PublishTime"].Substring(5, 5).Replace("-", "/"); var timeStr = sitesStrDict[siteName]["PublishTime"].Substring(11, 5); var aqiStr = sitesStrDict[siteName]["AQI"]; var pm2_5_Str = sitesStrDict[siteName]["PM2.5"]; var pm10_Str = sitesStrDict[siteName]["PM10"]; // Small tile var smallTile = new SmallTile(textColor); smallTile.topTxt.Text = siteName; smallTile.downTxt.Text = timeStr; smallTile.border.Background = bgColor; // Med tile var medTile = new MedTile(textColor); medTile.topTxt.Text = siteName; medTile.topVal.Text = timeStr; medTile.medVal.Text = aqiStr; medTile.downVal.Text = pm2_5_Str; medTile.border.Background = bgColor; // Wide tile var wideTile = new WideTile(textColor); wideTile.topTxt.Text = siteName + "-" + dateStr + "-" + timeStr; wideTile.medVal1.Text = aqiStr; wideTile.medVal2.Text = pm2_5_Str; wideTile.medVal3.Text = pm10_Str; wideTile.border.Background = bgColor; // Large tile var largeTile = new LargeTile(textColor); largeTile.val1.Text = siteName; largeTile.val2.Text = sitesStrDict[siteName]["ShortStatus"]; largeTile.val3_1.Text = dateStr; largeTile.val3_2.Text = timeStr; largeTile.val4.Text = aqiStr; largeTile.val5.Text = pm2_5_Str; largeTile.val6.Text = pm10_Str; largeTile.val7.Text = sitesStrDict[siteName]["O3"]; largeTile.val8.Text = sitesStrDict[siteName]["CO"]; largeTile.val9.Text = sitesStrDict[siteName]["SO2"]; largeTile.border.Background = bgColor; await StaticTaqModelView.saveUi2Png(siteName + "SmallTile.png", smallTile); await StaticTaqModelView.saveUi2Png(siteName + "MedTile.png", medTile); await StaticTaqModelView.saveUi2Png(siteName + "WideTile.png", wideTile); await StaticTaqModelView.saveUi2Png(siteName + "LargeTile.png", largeTile); return(0); }