本文整理汇总了C#中Windows.UI.Xaml.Media.Imaging.WriteableBitmap.ToBandIcon方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.ToBandIcon方法的具体用法?C# WriteableBitmap.ToBandIcon怎么用?C# WriteableBitmap.ToBandIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.ToBandIcon方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterTile
public async Task<bool> RegisterTile() {
var pairedBands = await BandClientManager.Instance.GetBandsAsync();
using (var bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0])) {
var tiles = await bandClient.TileManager.GetTilesAsync();
var tileCapacity = await bandClient.TileManager.GetRemainingTileCapacityAsync();
var tileIconBitmap = new WriteableBitmap(46, 46);
var tileIcon = tileIconBitmap.ToBandIcon();
var tileGuid = Guid.NewGuid();
var tile = new BandTile(tileGuid) {
IsBadgingEnabled = true,
Name = "jcMSBWN",
TileIcon = tileIcon
};
await bandClient.TileManager.AddTileAsync(tile);
_setting.WriteSetting(SETTINGS.TILE_ID, tile.TileId);
}
return true;
}
示例2: LoadIcon
private static async Task<BandIcon> LoadIcon(string uri)
{
var imageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(uri));
using (var fileStream = await imageFile.OpenAsync(FileAccessMode.Read))
{
var bitmap = new WriteableBitmap(1, 1);
bitmap.SetSource(fileStream);
return bitmap.ToBandIcon();
}
}
示例3: TileManager_SetNewTile
public async void TileManager_SetNewTile()
{
var bandClient = await TestUtils.GetBandClientAsync();
// create a new Guid for the tile
Guid tileGuid = Guid.NewGuid();
// Create the small and tile icons from writable bitmaps.
// Small icons are 24x24 pixels.
WriteableBitmap smallIconBitmap = new WriteableBitmap(24, 24);
BandIcon smallIcon = smallIconBitmap.ToBandIcon();
// Tile icons are 46x46 pixels for Microsoft Band 1, and 48x48 pixels
// for Microsoft Band 2.
WriteableBitmap tileIconBitmap = new WriteableBitmap(46, 46);
BandIcon tileIcon = tileIconBitmap.ToBandIcon();
// create a new tile
BandTile tile = new BandTile(tileGuid)
{
// set the name
Name = "MyTile",
// set the icons
SmallIcon = smallIcon,
TileIcon = tileIcon
};
// get the current set of tiles
try
{
// add the tile to the Band
if (await bandClient.TileManager.AddTileAsync(tile))
{
// tile was successfully added
// can proceed to set tile content with SetPagesAsync
}
else
{
// tile failed to be added, handle error
}
}
catch (BandException ex)
{
// handle a Band connection exception }
}
}
示例4: GetBandIcon
private async Task<BandIcon> GetBandIcon(string icon)
{
using (var imageFile = this.GetType().GetTypeInfo().Assembly.GetManifestResourceStream("CTime2.Core.Services.Band.Icons." + icon))
{
WriteableBitmap bitmap = new WriteableBitmap(1, 1);
await bitmap.SetSourceAsync(imageFile.AsRandomAccessStream());
return bitmap.ToBandIcon();
}
}
示例5: Click_AddTile
async private void Click_AddTile(object sender, RoutedEventArgs e)
{
AppBarButton_Pin.IsEnabled = false;
try
{
// determine the number of available tile slots on the Band
int tileCapacity = await bandClient.TileManager.GetRemainingTileCapacityAsync();
if (tileCapacity < 1)
{
return;
}
}
catch (BandException ex)
{
// handle a Band connection exception }
}
// Create the small and tile icons from writable bitmaps.
// Small icons are 24x24 pixels.
BandIcon smallIcon;
StorageFile imageFile_small = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Band_SmallIcon.png"));
using (IRandomAccessStream fileStream = await imageFile_small.OpenAsync(FileAccessMode.Read))
{
WriteableBitmap bitmap = new WriteableBitmap(24, 24);
await bitmap.SetSourceAsync(fileStream);
smallIcon = bitmap.ToBandIcon();
}
// Tile icons are 46x46 pixels for Microsoft Band 1, and 48x48 pixels
// for Microsoft Band 2.
BandIcon tileIcon;
StorageFile imageFile_large = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Band_LargeIcon.png"));
using (IRandomAccessStream fileStream = await imageFile_large.OpenAsync(FileAccessMode.Read))
{
WriteableBitmap bitmap = new WriteableBitmap(48, 48);
await bitmap.SetSourceAsync(fileStream);
tileIcon = bitmap.ToBandIcon();
}
// create a new Guid for the tile
Guid newGuid = Guid.NewGuid();
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
localSettings.Values["BOLGuid"] = tileGuid = newGuid;
// create a new tile with a new Guid
tile = new BandTile(tileGuid)
{
// enable badging (the count of unread messages)
IsBadgingEnabled = true,
// set the name
Name = "Band of Love",
// set the icons
SmallIcon = smallIcon,
TileIcon = tileIcon
};
// Create a scrollable vertical panel that will hold 2 text messages.
ScrollFlowPanel panel = new ScrollFlowPanel
{
Rect = new PageRect(0, 0, 245, 102),
Orientation = FlowPanelOrientation.Vertical,
ScrollBarColorSource = ElementColorSource.BandBase
};
// add the text block to contain the first message
panel.Elements.Add(
new WrappedTextBlock
{
ElementId = (short)TileMessagesLayoutElementId.Message1,
Rect = new PageRect(0, 0, 245, 102),
// left, top, right, bottom margins
Margins = new Margins(15, 0, 15, 0),
Color = new BandColor(0xFF, 0xFF, 0xFF),
Font = WrappedTextBlockFont.Small
}
);
// add the text block to contain the second message
panel.Elements.Add(
new WrappedTextBlock
{
ElementId = (short)TileMessagesLayoutElementId.Message2,
Rect = new PageRect(0, 0, 245, 102),
// left, top, right, bottom margins
Margins = new Margins(15, 0, 15, 0),
Color = new BandColor(0xFF, 0xFF, 0xFF),
Font = WrappedTextBlockFont.Small
}
);
// create the page layout
PageLayout layout = new PageLayout(panel);
try
{ // add the layout to the tile
tile.PageLayouts.Add(layout);
}
catch (BandException ex)
{
// handle an error adding the layout
}
//.........这里部分代码省略.........
示例6: SetBandTile
private async void SetBandTile()
{
var bandManager = BandClientManager.Instance;
// query the service for paired devices
var pairedBands = await bandManager.GetBandsAsync();
// connect to the first device
var bandInfo = pairedBands.FirstOrDefault();
var bandClient = await bandManager.ConnectAsync(bandInfo);
//RETRIEVING THE BAND VERSION INFORMATION
string fwVersion;//"2.0.3923.0"
string hwVersion;//"26"
try
{
fwVersion = await bandClient.GetFirmwareVersionAsync();
hwVersion = await bandClient.GetHardwareVersionAsync();
// do work with firmware & hardware versions
}
catch (BandException ex)
{
// handle any BandExceptions
}
///////////////////////////////////////
//just vibration because of reasons - no message
//await bandClient.NotificationManager.VibrateAsync(Microsoft.Band.Notifications.VibrationType.NotificationAlarm);
// bandClient.TileManager.TileButtonPressed += TileManager_TileButtonPressed;
//await bandClient.TileManager.StartReadingsAsync();
var smallIconFile = await StorageFile.GetFileFromApplicationUriAsync(
new Uri("ms-appx:///Assets/logo_small.png"));
using (var smallStream = await smallIconFile.OpenReadAsync())
{
var largeBitmap = new WriteableBitmap(48, 48);
largeBitmap.SetSource(smallStream);
var largeIcon = largeBitmap.ToBandIcon();
var guid = Guid.NewGuid();//{be8a038f-2532-4be7-ac5e-aacf1771c788}
var added = await bandClient.TileManager.AddTileAsync(
new BandTile(guid)
{
Name = "MarvelCrimeCenterUnit",
TileIcon = largeIcon,
SmallIcon = largeIcon
}
);
if (added)
{
// NB: This call will return back to us *before* t
// user has acknowledged the dialog on their device -
// we don't get to know their answer here.
//await bandClient.NotificationManager.ShowDialogAsync(guid, "Test", "Hello Mario");
//PageData pageContent = new PageData(guid,
// 0, // index of our (only) layout
// new TextButtonData((short)1, "CALL SUPERHEROES!"));
//await bandClient.TileManager.SetPagesAsync(guid, pageContent);
}
}
bandClient.TileManager.TileOpened += TileManager_TileOpened;
await bandClient.TileManager.StartReadingsAsync();
}