本文整理匯總了C#中Windows.UI.Notifications.TileNotification類的典型用法代碼示例。如果您正苦於以下問題:C# TileNotification類的具體用法?C# TileNotification怎麽用?C# TileNotification使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TileNotification類屬於Windows.UI.Notifications命名空間,在下文中一共展示了TileNotification類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Send_Notif
private void Send_Notif(object sender, RoutedEventArgs e)
{
//Updates Live Tile and Lock Screen if pinned
XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText01);
TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText01);
XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
tileTextAttributes[0].InnerText = input.Text;
XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");
((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///Assets/wideLogo_up.png");
/*
XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);
XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode(input.Text));
IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);
* */
TileNotification tileNotification = new TileNotification(tileXml);
//Sets when the notification should expire
//tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(10);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
//Update feedback
feedback.Text = "Lock Screen and Tile updated";
}
示例2: tileUpdateButton_Click
private void tileUpdateButton_Click(object sender, RoutedEventArgs e)
{
// タイルのテンプレート選択
// http://msdn.microsoft.com/ja-jp/library/windows/apps/hh761491.aspx#TileSquareText03
XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText01);
// キューに複數のタイル通知を設定可能にする
//TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
tileTextAttributes[0].InnerText = this.tileText.Text;
XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");
((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///Assets/wideTile.png");
((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "wideTile.png");
XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);
XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode(this.tileText.Text));
IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);
TileNotification tileNotification = new TileNotification(tileXml);
tileNotification.Tag = this.tileText.Text;
//tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(10);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
}
示例3: PinAndUpdate_Click
private async void PinAndUpdate_Click(object sender, RoutedEventArgs e)
{
// Create the original Square150x150 tile
var tile = new SecondaryTile(SCENARIO1_TILEID, "Scenario 1", "/MainPage.xaml?scenario=Scenario1", new Uri("ms-appx:///Assets/originalTileImage.png"), TileSize.Default);
tile.VisualElements.ShowNameOnSquare150x150Logo = true;
await tile.RequestCreateAsync();
// When a new tile is created, the app will be deactivated and the new tile will be displayed to the user on the start screen.
// Any code after the call to RequestCreateAsync is not guaranteed to run.
// For example, a common scenario is to associate a push channel with the newly created tile,
// which involves a call to WNS to get a channel using the CreatePushNotificationChannelForSecondaryTileAsync() asynchronous operation.
// Another example is updating the secondary tile with data from a web service. Both of these are examples of actions that may not
// complete before the app is deactivated. To illustrate this, we'll create a delay and then attempt to update our secondary tile.
// If the app is deactivated before reaching this point, the following code will never run.
// Update the tile we created using a notification.
var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Image);
// The TileSquare150x150Image template only contains one image entry, so retrieve it.
var imageElement = tileXml.GetElementsByTagName("image").Single();
// Set the src propertry on the image entry.
imageElement.Attributes.GetNamedItem("src").NodeValue = "ms-appx:///Assets/updatedTileImage.png";
// Create a new tile notification.
var notification = new Windows.UI.Notifications.TileNotification(tileXml);
// Create a tile updater.
var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(SCENARIO1_TILEID);
// Send the update notification for the tile.
updater.Update(notification);
}
示例4: registerBackgroundTask
public async void registerBackgroundTask()
{
try
{
var result = await BackgroundExecutionManager.RequestAccessAsync();
if (result == BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity ||
result == BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity)
{
foreach (var task in BackgroundTaskRegistration.AllTasks)
{
if (task.Value.Name == TASK_NAME)
task.Value.Unregister(true);
}
BackgroundTaskBuilder builder = new BackgroundTaskBuilder();
builder.Name = TASK_NAME;
builder.TaskEntryPoint = TASK_ENTRY;
builder.SetTrigger(new TimeTrigger(15, false));
var registration = builder.Register();
}
for (int i = 0; i < 5; i++)
{
Uri u = new Uri("ms-appx:///tile/TileTemplate" + new Random().Next(1, 3).ToString() + ".xml");
StorageFile xmlFile = await StorageFile.GetFileFromApplicationUriAsync(u);
XmlDocument doc = await XmlDocument.LoadFromFileAsync(xmlFile);
TileNotification notifi = new TileNotification(doc);
TileUpdater udt = TileUpdateManager.CreateTileUpdaterForApplication();
udt.Update(notifi);
}
}
catch(Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
}
}
示例5: UpdateTile
private void UpdateTile()
{
var now = DateTime.Now.ToString("HH:mm:ss");
var xml =
"<tile>" +
" <visual>" +
" <binding template='TileSmall'>" +
" <text>" + now + "</text>" +
" </binding>" +
" <binding template='TileMedium'>" +
" <text>" + now + "</text>" +
" </binding>" +
" <binding template='TileWide'>" +
" <text>" + now + "</text>" +
" </binding>" +
" <binding template='TileLarge'>" +
" <text>" + now + "</text>" +
" </binding>" +
" </visual>" +
"</tile>";
var tileDom = new XmlDocument();
tileDom.LoadXml(xml);
var tile = new TileNotification(tileDom);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
}
示例6: Run
public void Run(IBackgroundTaskInstance taskInstance)
{
// Checking for the last time access when the network was available and displaying it on the live tile.
var tileContent = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);
var tileLines = tileContent.SelectNodes("tile/visual/binding/text");
var networkStatus = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
tileLines[0].InnerText = (networkStatus == null) ?
"No network" :
networkStatus.GetNetworkConnectivityLevel().ToString();
tileLines[1].InnerText = DateTime.Now.ToString("MM/dd/yyyy");
tileLines[2].InnerText = DateTime.Now.ToString("HH:mm:ss");
tileLines[3].InnerText = "Update from my App";
var notification = new TileNotification(tileContent);
var updater = TileUpdateManager.CreateTileUpdaterForApplication();
updater.Update(notification);
}
示例7: SetLiveTileToSingleImage
static async void SetLiveTileToSingleImage(string wideImageFileName, string mediumImageFileName)
{
// Construct the tile content as a string
string content = [email protected]"
<tile>
<visual>
<binding template='TileSquareImage'>
<image id='1' src='ms-appdata:///local/{mediumImageFileName}' />
</binding>
<binding template='TileWideImage' branding='none'>
<image id='1' src='ms-appdata:///local/{wideImageFileName}' />
</binding>
</visual>
</tile>";
SecondaryTile sec = new SecondaryTile("tile", "","prof2", new Uri("ms-appdata:///local/{mediumImageFileName}"), TileSize.Square150x150);
await sec.RequestCreateAsync();
// Load the string into an XmlDocument
XmlDocument doc = new XmlDocument();
doc.LoadXml(content);
// Then create the tile notification
var notification = new TileNotification(doc);
TileUpdateManager.CreateTileUpdaterForSecondaryTile(sec.TileId).Update(notification);
}
示例8: UpdateTilesAsync
private async void UpdateTilesAsync()
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(tileUpdateURL);
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
StreamReader reader = new StreamReader(response.GetResponseStream());
string tileXml = reader.ReadToEnd();
Debug.WriteLine(tileXml);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(tileXml);
TileNotification tileNotification = new TileNotification(xmlDoc);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
finally
{
UpdateTaskCompleted();
}
}
示例9: CreateDataTilesAsync
private async Task<List<TileNotification>> CreateDataTilesAsync()
{
var result = new List<TileNotification>();
var randomEntries = await backendServiceClient.GetRandomEntries(5);
foreach (var randomEntry in randomEntries)
{
var tileHeading = randomEntry.Text;
var tileText = randomEntry.Definition;
var wideTile = TileContentFactory.CreateTileWide310x150Text01();
wideTile.TextHeading.Text = tileHeading;
wideTile.TextBody1.Text = tileText;
var squareTile = TileContentFactory.CreateTileSquare150x150Text01();
squareTile.TextHeading.Text = tileHeading;
squareTile.TextBody1.Text = tileText;
wideTile.Square150x150Content = squareTile;
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(wideTile.ToString());
var notification = new TileNotification(xmlDocument);
result.Add(notification);
}
return result;
}
示例10: Tile
public static bool Tile(string line1, string line2, string line3)
{
try
{
Toast.TileClear();
TileContent content = GetTileContent(line1, line2, line3);
// Create the tile notification
var notification = new TileNotification(content.GetXml());
notification.ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10);
// And send the notification
TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
return true;
}
catch (Exception ex)
{
return false;
}
}
示例11: OnUpdateTileClicked
public void OnUpdateTileClicked(object sender, RoutedEventArgs e)
{
string xml = @"<tile>
<visual>
<binding template=""TileMedium"">
<group>
<subgroup>
<text hint-style=""subtitle"">John Doe</text>
<text hint-style=""subtle"">Photos from our trip</text>
<text hint-style=""subtle"">Thought you might like to see all of</text>
</subgroup>
</group>
<group>
<subgroup>
<text hint-style=""subtitle"">Jane Doe</text>
<text hint-style=""subtle"">Questions about your blog</text>
<text hint-style=""subtle\"">Have you ever considered writing a</text>
</subgroup>
</group>
</binding>
</visual>
</tile>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
TileNotification notification = new TileNotification(doc);
TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();
updater.Update(notification);
}
示例12: UpdateBigTileWithMusicInfo
public static void UpdateBigTileWithMusicInfo()
{
const TileTemplateType template = TileTemplateType.TileWide310x150PeekImage05;
var tileXml = TileUpdateManager.GetTemplateContent(template);
var tileTextAttributes = tileXml.GetElementsByTagName("text");
#if WINDOWS_APP
tileTextAttributes[0].InnerText = "Now playing";
#endif
if (Locator.MusicPlayerVM.CurrentTrack != null)
{
#if WINDOWS_APP
tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.Name + " - " + Locator.MusicPlayerVM.CurrentTrack.ArtistName;
#else
tileTextAttributes[0].InnerText = Locator.MusicPlayerVM.CurrentTrack.Name ?? "";
tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.AlbumName;
tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.ArtistName;
#endif
var tileImgAttribues = tileXml.GetElementsByTagName("image");
#if WINDOWS_APP
if (Locator.MusicPlayerVM.CurrentArtist != null)
tileImgAttribues[0].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentArtist.Picture;
if (Locator.MusicPlayerVM.CurrentAlbum != null)
tileImgAttribues[1].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentAlbum.AlbumCoverFullUri;
#else
if (Locator.MusicPlayerVM.CurrentAlbum != null)
tileImgAttribues[0].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentAlbum.AlbumCoverFullUri;
#endif
}
var tileNotification = new TileNotification(tileXml);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
}
示例13: UpdatePrimaryTile
private void UpdatePrimaryTile(object sender, RoutedEventArgs e)
{
var xmlDoc = TileService.CreateTiles(new Models.PrimaryTile());
var updater = TileUpdateManager.CreateTileUpdaterForApplication();
TileNotification notification = new TileNotification(xmlDoc);
updater.Update(notification);
}
示例14: CreateTileUpdate
// For more about tile templates:
// http://msdn.microsoft.com/en-us/library/windows/apps/Hh761491.aspx
public static void CreateTileUpdate(string text)
{
try
{
string tileXmlString = "<tile>"
+ "<visual>"
+ "<binding template='TileWideText04'>"
+ "<text id='1'>" + text + "</text>"
+ "</binding>"
+ "</visual>"
+ "</tile>";
XmlDocument tileDOM = new XmlDocument();
tileDOM.LoadXml(tileXmlString);
TileNotification tile = new TileNotification(tileDOM);
// Enable notification cycling.
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
示例15: Pin
public async void Pin()
{
var tileId = Artist.Id.ToString();
var tile = new SecondaryTile(tileId)
{
DisplayName = Artist.Name,
VisualElements =
{
BackgroundColor = Color.FromArgb(255, 7, 96, 110),
Square150x150Logo = new Uri("ms-appx:///Assets/Logo.png"),
ShowNameOnSquare150x150Logo = true,
Wide310x150Logo = new Uri("ms-appx:///Assets/WideLogo.png"),
ShowNameOnWide310x150Logo = true,
ForegroundText = ForegroundText.Light
},
Arguments = Artist.Id.ToString()
};
await tile.RequestCreateAsync();
var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId);
var template = await GetTemplateDocumentAsync();
var notification = new TileNotification(template);
updater.Update(notification);
}