private static void ShowToast(福利 fuli) { var xml = getToastXML(fuli); var doc = loadXml(xml); ToastNotificationManager.CreateToastNotifier() .Show(new ToastNotification(doc)); }
private static string getToastXML(福利 fuli) { var xml = $@" <toast launch='0'> <visual> <binding template='ToastGeneric'> <text>{fuli?.publishedAt:yyyy-MM-dd} 干货</text> <text>点击查看今日更新...</text> <image src='{fuli?.url}'/> </binding> </visual> </toast>"; return(xml); }
private static string getFuliTileXML(福利 f) { return($@"<tile> <visual branding='nameAndLogo' displayName='福利'> <binding template='TileSmall'> <image placement='background' src='{f.url}' /> </binding> <binding template='TileMedium' > <image placement='background' src='{f.url}' /> </binding> <binding template='TileWide'> <image placement='background' src='{f.url}' /> </binding> <binding template='TileLarge'> <image placement='background' src='{f.url}'/> </binding> </visual> </tile>"); // return $@"<tile> // <visual branding='none'> // <binding template='TileSmall'> // <image placement='peek' src='{f.url}' /> // <text hint-style='captionSubtle' ></text> // <text hint-style='caption' >{f.publishedAt:MM-dd}</text> // </binding> // <binding template='TileMedium'> // <image placement = 'peek' src='{f.url}' /> // <text hint-style='captionSubtle' >福利</text> // <text hint-style='caption' hint-wrap='true'>{f.desc}</text> // <text hint-style='captionSubtle' hint-align='right'>{f.who}</text> // <text hint-style='captionSubtle' hint-align='right'>{f.publishedAt:yyyy-MM-dd}</text> // </binding> // <binding template='TileWide'> // <image placement = 'background' src='{f.url}' /> // </binding> // <binding template='TileLarge'> // <image alt ='{f.desc}' placement ='background' src='{f.url}'/> // </binding> // </visual> //</tile>"; }
private static string getItemXML(all item, all item2, 福利 f) { return($@"<tile> <visual branding='name' displayName='干货'> <binding template='TileSmall' hint-textStacking='center'> <text hint-style='body' hint-align='center'>{item.publishedAt:MMdd}</text> </binding> <binding template='TileMedium'> <image placement='background' src='{f.url}' /> <text hint-style='captionSubtle'>{item.type}</text> <text hint-style='caption' hint-wrap='true' hint-maxLines='2'>{item.desc}</text> <text hint-style='captionSubtle' hint-align='right' hint-maxLines='1'>{item.publishedAt:yyyy-MM-dd}</text> </binding> <binding template='TileWide'> <image placement='background' src='{f.url}' /> <text hint-style='captionSubtle'>{item.type}</text> <text hint-style='caption' hint-wrap='true' hint-maxLines='2'>{item.desc}</text> <text hint-style='captionSubtle' hint-align='right' hint-maxLines='1'>{item.who}{(item.who==null?"":"@")}{item.publishedAt:yyyy-MM-dd}</text> </binding> <binding template='TileLarge'> <image placement='background' src='{f.url}' /> <group> <subgroup> <text hint-style='subtitleSubtle'>{item.type}</text> <text hint-style='caption' hint-wrap='true' hint-maxLines='3'>{item.desc}</text> {(item.desc.Length<30? "<text hint-style='caption'></text>" : "")} </subgroup> </group> <group> <subgroup> <text hint-style='subtitleSubtle'>{item2?.type}</text> <text hint-style='caption' hint-wrap='true' hint-maxLines='3'>{item2?.desc}</text> <text hint-style='captionSubtle' hint-align='right' hint-maxLines='1'>{item.publishedAt:yyyy-MM-dd}</text> </subgroup> </group> </binding> </visual> </tile>"); #region old //if (item.images == null || item.images.Length == 0) //{ // return $@"<tile> // <visual branding='name'> // <binding template='TileSmall' branding='none'> // <text hint-style='caption' ></text> // <text hint-style='caption' >{item.publishedAt:MMdd}</text> // </binding> // <binding template='TileMedium'> // <text hint-style='captionSubtle'>{item.type}</text> // <text hint-style='caption' hint-wrap='true' hint-maxLines='2'>{item.desc}</text> // <text hint-style='captionSubtle' hint-align='right' hint-maxLines='1'>{item.publishedAt:yyyy-MM-dd}</text> // </binding> // <binding template='TileWide'> // <text hint-style='captionSubtle'>{item.type}</text> // <text hint-style='caption' hint-wrap='true' hint-maxLines='2'>{item.desc}</text> // <text hint-style='captionSubtle' hint-align='right' hint-maxLines='1'>{item.who} @ {item.publishedAt:yyyy-MM-dd}</text> // </binding> // <binding template='TileLarge'> // <group> // <subgroup> // <text hint-style='titleSubtle'>{item.type}</text> // <text hint-style='caption' hint-wrap='true' hint-maxLines='3'>{item.desc}</text> // </subgroup> // </group> // <group> // <subgroup> // <text hint-style='captionSubtle'>{item2?.type}</text> // <text hint-style='caption' hint-wrap='true' hint-maxLines='3'>{item2?.desc}</text> // <text hint-style='captionSubtle' hint-align='right' hint-maxLines='1'>{item.publishedAt:yyyy-MM-dd}</text> // </subgroup> // </group> // </binding> // </visual> //</tile> //"; //} //else //有网络图片经常会显示异常。 // { // var bakImg = item.images.Length > 1 ? item.images[1] : item.images[0]; // return $@" //<tile> // <visual branding='nameAndLogo'> // <binding template='TileSmall'> // <text hint-style='caption' >{item.publishedAt:MMdd}</text> // </binding> // <binding template='TileMedium'> // <image src='{item.images[0]}' placement='peek'/> // <text hint-style='captionSubtle'>{item.type}</text> // <text hint-style='caption' hint-wrap='true' hint-maxLines='2'>{item.desc}</text> // <text hint-style='captionSubtle' hint-align='right' hint-maxLines='1'>{item.publishedAt:yyyy-MM-dd}</text> // </binding> // <binding template='TileWide'> // <group> // <subgroup hint-weight='33' hint-textStacking='center'> // <image src='{item.images[0]}' hint-align='center' /> // </subgroup> // <subgroup> // <text hint-style='captionSubtle'>{item.type}</text> // <text hint-style='caption' hint-wrap='true' hint-maxLines='2'>{item.desc}</text> // <text hint-style='captionSubtle' hint-align='right' hint-maxLines='1'>{item.who} @ {item.publishedAt:yyyy-MM-dd}</text> // </subgroup> // </group> // </binding> // <binding template='TileLarge'> // <group> // <subgroup hint-weight='33' hint-textStacking='center'> // <image src='{item.images[0]}' hint-align='center' /> // </subgroup> // <subgroup> // <text hint-style='titleSubtle'>{item.type}</text> // <text hint-style='caption' hint-wrap='true' hint-maxLines='3'>{item.desc}</text> // </subgroup> // </group> // <group> // <subgroup hint-weight='33' hint-textStacking='center'> // <image src='{item2?.images?[0]}' hint-align='center'/> // </subgroup> // <subgroup> // <text hint-style='captionSubtle'>Android</text> // <text hint-style='caption' hint-wrap='true' hint-maxLines='3'>{item2?.desc}</text> // </subgroup> // </group> // <group> // <subgroup> // <text hint-style='captionSubtle' hint-maxLines='1' hint-align='right'>{item.publishedAt:yyyy-MM-dd}</text> // </subgroup> // </group> // <image src='{bakImg}' placement='peek' /> // </binding> // </visual> //</tile>"; // }; #endregion }