本文整理匯總了C#中Windows.UI.StartScreen.SecondaryTile.RequestDeleteForSelectionAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# SecondaryTile.RequestDeleteForSelectionAsync方法的具體用法?C# SecondaryTile.RequestDeleteForSelectionAsync怎麽用?C# SecondaryTile.RequestDeleteForSelectionAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.UI.StartScreen.SecondaryTile
的用法示例。
在下文中一共展示了SecondaryTile.RequestDeleteForSelectionAsync方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PinUnPinCommandButton_Click
/*string displayName = "Secondary tile pinned through app bar";
string tileActivationArguments = MainPage.appbarTileId + " was pinned at=" + DateTime.Now.ToLocalTime().ToString();
Uri square150x150Logo = new Windows.Foundation.Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
TileSize newTileDesiredSize = TileSize.Square150x150;
*/
private async void PinUnPinCommandButton_Click(object sender, RoutedEventArgs e)
{
this.SecondaryTileCommandBar.IsSticky = true;
if (SecondaryTile.Exists("Amr"))
{
//UnPin
SecondaryTile secTile = new SecondaryTile("Amr");
Windows.Foundation.Rect rect = new Rect(20, 20, 2000, 2000);
var placment = Windows.UI.Popups.Placement.Above;
bool IsUnPinned = await secTile.RequestDeleteForSelectionAsync(rect, placment);
ToggleAppBarButton(IsUnPinned);
}
else
{
//Pin
SecondaryTile secTile = new SecondaryTile("Amr", "Amr Alaa", "AAA", new Uri("ms-appx:///Assets/Wide310x150Logo.scale-100.png"), TileSize.Square150x150);
secTile.VisualElements.Square30x30Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-100.png");
secTile.VisualElements.ShowNameOnSquare150x150Logo = true;
secTile.VisualElements.ShowNameOnSquare310x310Logo = true;
secTile.VisualElements.ForegroundText = ForegroundText.Dark;
Windows.Foundation.Rect rect = new Rect(20, 20, 2000, 2000);
var placment = Windows.UI.Popups.Placement.Above;
bool isPinned = await secTile.RequestCreateForSelectionAsync(rect,placment);
ToggleAppBarButton(isPinned);
}
this.BottomAppBar.IsSticky = false;
}
示例2: UnpinSecondaryTile_Click
/// <summary>
/// This is the click handler for the 'Unpin' button.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void UnpinSecondaryTile_Click(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
if (button != null)
{
if (Windows.UI.StartScreen.SecondaryTile.Exists(MainPage.logoSecondaryTileId))
{
// First prepare the tile to be unpinned
SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId);
// Now make the delete request.
bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
if (isUnpinned)
{
rootPage.NotifyUser("Secondary tile successfully unpinned.", NotifyType.StatusMessage);
}
else
{
rootPage.NotifyUser("Secondary tile not unpinned.", NotifyType.ErrorMessage);
}
}
else
{
rootPage.NotifyUser(MainPage.logoSecondaryTileId + " is not currently pinned.", NotifyType.ErrorMessage);
}
}
}
示例3: Unpin
public async Task<bool> Unpin(TileInfo info)
{
System.Diagnostics.Contracts.Contract.Requires(info != null, "TileInfo");
if (!SecondaryTile.Exists(info.TileId))
return true;
var tile = new SecondaryTile(info.TileId);
var result = await tile.RequestDeleteForSelectionAsync(info.Rect(), info.RequestPlacement);
return result;
}
示例4: UnpinAsync
public async Task<bool> UnpinAsync(string tileId, Rect selection, Windows.UI.Popups.Placement placement = Windows.UI.Popups.Placement.Above)
{
System.Diagnostics.Contracts.Contract.Requires(tileId != null, "TileId");
if (!SecondaryTile.Exists(tileId))
return true;
var tile = new SecondaryTile(tileId);
var result = await tile.RequestDeleteForSelectionAsync(selection, placement);
return result;
}
示例5: Unpin
public async Task<bool> Unpin(TileInfo tileInfo)
{
var wasUnpinned = false;
if (SecondaryTile.Exists(tileInfo.TileId))
{
var secondaryTile = new SecondaryTile(tileInfo.TileId);
wasUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(
GetElementRect(tileInfo.AnchorElement), tileInfo.RequestPlacement);
}
return wasUnpinned;
}
示例6: UnpinPoll
public async Task<bool> UnpinPoll(FrameworkElement anchorElement, int pollId)
{
var wasUnpinned = false;
var tileId = string.Format(SecondaryPinner.TileIdFormat, pollId);
if (SecondaryTile.Exists(tileId))
{
var secondaryTile = new SecondaryTile(tileId);
wasUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(
GetElementRect(anchorElement), Placement.Above);
}
return wasUnpinned;
}
示例7: btnSecTile_Click
private async void btnSecTile_Click(object sender, RoutedEventArgs e)
{
Windows.Foundation.Rect rect = GetElementRect((FrameworkElement)sender);
if (SecondaryTile.Exists("MyUnicTileID"))
{
SecondaryTile secondaryTile = new SecondaryTile("MyUnicTileID");
bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
ToggleAppBarButton(isUnpinned);
}
else
{
// Pin
Uri square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.png");
string tileActivationArguments = "Secondary tile was pinned at = " + DateTime.Now.ToLocalTime().ToString();
string displayName = "App Template";
TileSize newTileDesiredSize = TileSize.Square150x150;
SecondaryTile secondaryTile = new SecondaryTile("MyUnicTileID",
displayName,
tileActivationArguments,
square150x150Logo,
newTileDesiredSize);
secondaryTile.VisualElements.Square44x44Logo = new Uri("ms-appx:///Assets/Square44x44Logo.png");
secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
secondaryTile.VisualElements.ForegroundText = ForegroundText.Light;
bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
ToggleAppBarButton(!isPinned);
}
}
示例8: pinToAppBar_Click
async void pinToAppBar_Click(object sender, RoutedEventArgs e)
{
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
this.SecondaryTileCommandBar.IsSticky = true;
// Let us first verify if we need to pin or unpin
if (SecondaryTile.Exists(MainPage.appbarTileId))
{
// First prepare the tile to be unpinned
SecondaryTile secondaryTile = new SecondaryTile(MainPage.appbarTileId);
// Now make the delete request.
bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);
if (isUnpinned)
{
rootPage.NotifyUser(MainPage.appbarTileId + " unpinned.", NotifyType.StatusMessage);
}
else
{
rootPage.NotifyUser(MainPage.appbarTileId + " not unpinned.", NotifyType.ErrorMessage);
}
ToggleAppBarButton(isUnpinned);
}
else
{
// Prepare package images for the medium tile size in our tile to be pinned
Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
// During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
// These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
string tileActivationArguments = MainPage.appbarTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();
// Create a Secondary tile with all the required arguments.
// Note the last argument specifies what size the Secondary tile should show up as by default in the Pin to start fly out.
// It can be set to TileSize.Square150x150, TileSize.Wide310x150, or TileSize.Default.
// If set to TileSize.Wide310x150, then the asset for the wide size must be supplied as well.
// TileSize.Default will default to the wide size if a wide size is provided, and to the medium size otherwise.
SecondaryTile secondaryTile = new SecondaryTile(MainPage.appbarTileId,
"Secondary tile pinned via AppBar",
tileActivationArguments,
square150x150Logo,
TileSize.Square150x150);
// Whether or not the app name should be displayed on the tile can be controlled for each tile size. The default is false.
secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
// Specify a foreground text value.
// The tile background color is inherited from the parent unless a separate value is specified.
secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;
// OK, the tile is created and we can now attempt to pin the tile.
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
{
// Note that the status message is updated when the async operation to pin the tile completes.
bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);
if (isPinned)
{
rootPage.NotifyUser(MainPage.appbarTileId + " successfully pinned.", NotifyType.StatusMessage);
}
else
{
rootPage.NotifyUser(MainPage.appbarTileId + " not pinned.", NotifyType.ErrorMessage);
}
ToggleAppBarButton(!isPinned);
}
if ((Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
{
// Since pinning a secondary tile on Windows Phone will exit the app and take you to the start screen, any code after
// RequestCreateForSelectionAsync or RequestCreateAsync is not guaranteed to run. For an example of how to use the OnSuspending event to do
// work after RequestCreateForSelectionAsync or RequestCreateAsync returns, see Scenario9_PinTileAndUpdateOnSuspend in the SecondaryTiles.WindowsPhone project.
await secondaryTile.RequestCreateAsync();
}
}
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
this.BottomAppBar.IsSticky = false;
}
示例9: Unpin
private async void Unpin(object sender)
{
// Unpin
SecondaryTile secondaryTile = new SecondaryTile(SecondaryTileId);
Windows.Foundation.Rect rect = MainPage.GetElementRect((FrameworkElement)sender);
Windows.UI.Popups.Placement placement = Windows.UI.Popups.Placement.Above;
bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, placement);
ToggleAppBarButton(isUnpinned);
}
示例10: RemoveSecondaryTile
public async Task<bool> RemoveSecondaryTile(Category category, Rect rect)
{
SecondaryTile secondaryTile = new SecondaryTile(category.TileId);
return await secondaryTile.RequestDeleteForSelectionAsync(rect, Placement.Above);
}
示例11: PinUnpinNoteFlyoutItem_Click
private async void PinUnpinNoteFlyoutItem_Click(object sender, RoutedEventArgs e)
{
var pinFlyout = (MenuFlyoutItem)sender;
var note = (Note)(e.OriginalSource as FrameworkElement).DataContext;
string SecondaryTileId = note.Id + "NoteTile";
var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
if (SecondaryTile.Exists(SecondaryTileId))
{
// Unpin
SecondaryTile secondaryTile = new SecondaryTile(SecondaryTileId);
Windows.Foundation.Rect rect = MainPage.GetElementRect((FrameworkElement)sender);
Windows.UI.Popups.Placement placement = Windows.UI.Popups.Placement.Above;
bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, placement);
pinFlyout.Text = loader.GetString("pin_text");
note.PinText = loader.GetString("pin_text");
}
else
{
//Pin
Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
Uri wide310x150Logo = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");
Uri square310x310Logo = new Uri("ms-appx:///Assets/square310x310Tile-sdk.png");
Uri square30x30Logo = new Uri("ms-appx:///Assets/square30x30Tile-sdk.png");
string tileActivationArguments = note.Id.ToString();
SecondaryTile secondaryTile = new SecondaryTile(SecondaryTileId,
note.Title,
tileActivationArguments,
square150x150Logo,
TileSize.Square150x150);
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
{
secondaryTile.VisualElements.Square310x310Logo = square310x310Logo;
}
secondaryTile.VisualElements.Wide310x150Logo = wide310x150Logo;
secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
{
secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;
secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;
}
secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;
secondaryTile.VisualElements.BackgroundColor = note.Color;
secondaryTile.RoamingEnabled = false;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
{
bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
SecondaryTiles.UpdateTile(SecondaryTileId, note);
if (isPinned)
{
pinFlyout.Text = loader.GetString("unpin_text"); ;
note.PinText = loader.GetString("unpin_text"); ;
}
else
{
var dialog = new MessageDialog(loader.GetString("pin_error_text"), loader.GetString("pin_error_title"));
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
}
else
{
await secondaryTile.RequestCreateAsync();
SecondaryTiles.UpdateTile(SecondaryTileId, note);
note.PinText = loader.GetString("unpin_text");
pinFlyout.Text = loader.GetString("unpin_text");
}
}
}
示例12: PintoStart_Click
async void PintoStart_Click(object sender, RoutedEventArgs e)
{
this.BottomAppBar.IsSticky = true;
// Let us first verify if we need to pin or unpin
if (SecondaryTile.Exists(TileID))
{
// First prepare the tile to be unpinned
SecondaryTile secondaryTile = new SecondaryTile(TileID);
// Now make the delete request.
bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(Tasks.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);
if (isUnpinned)
{
// rootPage.NotifyUser(MainPage.appbarTileId + " unpinned.", NotifyType.StatusMessage);
}
else
{
// rootPage.NotifyUser(MainPage.appbarTileId + " not unpinned.", NotifyType.ErrorMessage);
}
ToggleAppBarButton(isUnpinned);
}
else
{
// Prepare package images for use as the Tile Logo in our tile to be pinned
Uri logo = new Uri("ms-appx:///Assets/logo.png");
// During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
// These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
string tileActivationArguments = TileID + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();
// Create a 1x1 Secondary tile
SecondaryTile secondaryTile = new SecondaryTile(TileID,
"WandTask",
"Wand Appbar Task",
tileActivationArguments,
TileOptions.ShowNameOnLogo,
logo);
// Specify a foreground text value.
// The tile background color is inherited from the parent unless a separate value is specified.
secondaryTile.ForegroundText = ForegroundText.Dark;
// OK, the tile is created and we can now attempt to pin the tile.
// Note that the status message is updated when the async operation to pin the tile completes.
bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);
if (isPinned)
{
// rootPage.NotifyUser(MainPage.appbarTileId + " successfully pinned.", NotifyType.StatusMessage);
}
else
{
// rootPage.NotifyUser(MainPage.appbarTileId + " not pinned.", NotifyType.ErrorMessage);
}
ToggleAppBarButton(!isPinned);
}
BottomAppBar.IsSticky = false;
}
示例13: pinButton_Click_1
private async void pinButton_Click_1(object sender, RoutedEventArgs e)
{
pageRoot.BottomAppBar.IsSticky = true;
string shortName = appName;
string displayName = appName;
string tileActivationArguments = appName + "|" + appPlatform + "|" + apiKey + "|" + appApiKey;
Uri logo = new Uri("ms-appx:///Assets/Logo.png");
SecondaryTile secondaryTile = new SecondaryTile(appApiKey,
shortName,
displayName,
tileActivationArguments,
TileOptions.ShowNameOnLogo,
logo);
secondaryTile.ForegroundText = ForegroundText.Dark;
secondaryTile.SmallLogo = new Uri("ms-appx:///Assets/SmallLogo.png");
Windows.UI.Xaml.Media.GeneralTransform buttonTransform = ((FrameworkElement)sender).TransformToVisual(null);
Windows.Foundation.Point point = buttonTransform.TransformPoint(new Point());
Windows.Foundation.Rect rect = new Rect(point, new Size(((FrameworkElement)sender).ActualWidth, ((FrameworkElement)sender).ActualHeight));
if (!SecondaryTile.Exists(appApiKey))
{ // add
//FrameworkElement sender2 = (FrameworkElement)pinToAppBar;
bool x = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
Debug.WriteLine("secondaryTile creation: " + x);
}
else
{ // remove
bool x = await secondaryTile.RequestDeleteForSelectionAsync(rect);
Debug.WriteLine("secondaryTile removal: " + x);
}
pageRoot.BottomAppBar.IsSticky = false;
pageRoot.BottomAppBar.IsOpen = false;
ToggleAppBarButton(!SecondaryTile.Exists(appApiKey));
/*
XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText02);
XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
tileTextAttributes[0].InnerText = appName;
tileTextAttributes[1].InnerText = appPlatform;
// create a tile notification
TileNotification tile = new TileNotification(tileXml);
TileUpdateManager.CreateTileUpdaterForSecondaryTile("1").Update(tile);
*/
}
示例14: CreateOrReplaceSecondaryTile
public static async void CreateOrReplaceSecondaryTile(VLCItemType type, int id, string title)
{
string tileId = "SecondaryTile-" + type.ToString() + "-" + id;
if (!SecondaryTile.Exists(tileId))
{
var tileData = new SecondaryTile()
{
TileId = tileId,
DisplayName = title,
Arguments = tileId
};
string subfolder = null;
switch (type)
{
case VLCItemType.Album:
subfolder = "albumPic";
break;
case VLCItemType.Artist:
subfolder = "artistPic";
break;
}
tileData.VisualElements.ShowNameOnSquare150x150Logo = true;
tileData.DisplayName = title;
tileData.VisualElements.Square150x150Logo =
new Uri("ms-appdata:///local/" + subfolder + "/" + id + ".jpg");
await tileData.RequestCreateAsync();
}
else
{
SecondaryTile secondaryTile = new SecondaryTile(tileId);
await secondaryTile.RequestDeleteForSelectionAsync(Window.Current.Bounds, Placement.Default);
ToastHelper.Basic("Tile removed !");
}
}
示例15: AppBarPin_Click
private async void AppBarPin_Click(object sender, RoutedEventArgs e)
{
FrameworkElement pinElement = (FrameworkElement)sender;
Windows.UI.Xaml.Media.GeneralTransform buttonTransform = pinElement.TransformToVisual(null);
Windows.Foundation.Point point = buttonTransform.TransformPoint(new Point());
Windows.Foundation.Rect rect = new Rect(point, new Size(pinElement.ActualWidth, pinElement.ActualHeight));
if (SecondaryTile.Exists(appbarTileId))
{
SecondaryTile secondaryTile = new SecondaryTile(appbarTileId);
bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
ToggleAppBarButton((Button) sender, isUnpinned);
}
else
{
Uri logo = new Uri("ms-appx:///Assets/badge_01.png");
string tileActivationArguments = appbarTileId + " was pinned at " + DateTime.Now.ToLocalTime().ToString();
SecondaryTile secondaryTile = new SecondaryTile(appbarTileId,
"Secondary tile pinned via AppBar",
tileActivationArguments,
logo,
TileSize.Square150x150);
secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;
secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/badge_01.png");
secondaryTile.VisualElements.Square70x70Logo = new Uri("ms-appx:///Assets/badge_02.png");
secondaryTile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/badge_03.png");
bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
ToggleAppBarButton((Button)sender, !isPinned);
}
}