Microsoft Band Development - microsoft-band

I want to add the Background color to the page in tile in the Microsoft Band. I am following the below code to create the tile in the band and to display the white color in background, but I didn't get the white color in page, Please help me to solve this problem.
Guid tileguid = new Guid("C781F673-6D05-4D69-BCFF-EA7E706C3418");
Guid pageguid = Guid.NewGuid();
var panel = new FilledPanel
{
Rect = new PageRect(0, 0, 220, 128),
BackgroundColor = Colors.White.ToBandColor(),
};
var layout = new PageLayout(panel);
BandTile tile = new BandTile(tileguid)
{
Name = "Torch Tile",
TileIcon = await LoadIcon("ms-appx:///Assets/ElectricBulb.png"),
SmallIcon = await LoadIcon("ms-appx:///Assets/Torchsmaltile.png")};
tile.PageLayouts.Add(layout);
await bandclient.TileManager.AddTileAsync(tile);
Thanks & Regards,
Sai Priya. C

In your sample code you're creating the Tile with a page layout (a.k.a. template), but not actually creating an instance of a page with that layout. You need to use the IBandTileManager.SetPagesAsync() API to add a page with that layout to the Tile. See section 8.8.3 of the Microsoft Band SDK Documentation.

Related

Xamarin Forms add new controls dinamically in the content via code

I have a form in my Xamarin project that its result is something like that:
Basically there is a header (1) and a body of this form (2). The header is quite simple build with AbsoluteLayout.
For creating the body (2) I've created my component to show a tab control and then for each tab a specific grid with images and text. For each section, I'm checking in the database how many records there are for it and change the text. This activity is very long and I'm trying to understand why and how I can improve speed.
Then I should cut the corner to add later in my page the tab control so the user can see immediately the header and after few second all page. The code is like the following:
public class MyPage : WaitingPage
{
public MyPage(Card card)
{
LoadingMessage = "Loading...";
ShowLoadingFrame = true;
ShowLoadingMessage = true;
ShadeBackground = true;
WaitingOrientation = StackOrientation.Vertical;
IsWaiting = true;
StackLayout stackPage = new StackLayout() {
BackgroundColor = Color.FromHex("#fff"),
Children = {
ShowHeader(card),
}
};
Content = stackPage;
Task.Yield();
Task.Run(async () => {
Content = await ShowDetails(card);
});
IsWaiting = false;
}
}
I tried different ways to add the content from await ShowDetails(card); but nothing happens. Basically the content doesn't change unless await ShowDetails(card); is executed. I discovered Task.Yield(); (you can wait the page is rendered and showed and then continue) but in this case doesn't work. And also WaitingPage doesn't show the message.
Any suggestions or help? Thank you in advance

Xamarin Forms Labs GridView not showing up

I'm trying to use GridView from Forms Lab. Problem is that I'm not getting anything shown on screen. One thing to note - when i set Content = gridView or Content = mainLayout I'm getting null pointer reference exception, but i cannot find out which element is null. Here's code in view :
var itemTemplate = new DataTemplate(typeof (MedicineBoxItemCell));
var gridView = new GridView();
gridView.ItemsSource = medicineBoxViewModel.MedicineBoxViewModelItems;
gridView.ItemTemplate = itemTemplate;
StackLayout mainLayout = new StackLayout();
mainLayout.Children.Add(gridView);
var scrollView = new ScrollView()
{
Content = mainLayout,
BackgroundColor = Color.Yellow
};
Content = scrollView;
}
public class MedicineBoxItemCell : ViewCell
{
public MedicineBoxItemCell()
{
var name = new Entry()
{
HorizontalOptions = LayoutOptions.FillAndExpand
};
name.SetBinding(Entry.TextProperty, "MedicineBoxItem.Medicine.Name");
View = name;
}
}`
What platform are you testing? This a very alpha version that has some problems, specially with ItemTemplate.
Try one of the demo ViewCells and see if it works for you.. and go from there.
One thing that will not work is having a layout inside a layout on the template. For example, if you are using a Grid, and inside the grid u have a stackpanel that stackpanel and it's contents will not appear , it s somethign we don't know how to fix yet.

Tooltip in Paper.js

I am a beginner in Paper.js . Please could someone tell me how to display tool tip on a paper.js object ? The tool tip should be visible when the mouse moves over the object and should disappear when the mouse moves away from the object .
Thank you.
When drawing your object you want to create a popup for, first add it to a group, then use the onMouseEnter and onMouseLeave handlers on that object:
// Create a group
var group = new Group();
// Create a dot (circle the mouse will hover)
var point = new Point(50, 50);
var dot = new Path.Circle(point, 5);
dot.fillColor = 'blue';
// Add dot to group
group.addChild(dot);
// Create onMouseEnter event for dot
dot.onMouseEnter = function(event) {
// Layout the tooltip above the dot
var tooltipRect = new Rectangle(this.position + new Point(-20, -40), new Size(40, 28));
// Create tooltip from rectangle
var tooltip = new Path.Rectangle(tooltipRect);
tooltip.fillColor = 'white';
tooltip.strokeColor = 'black';
// Name the tooltip so we can retrieve it later
tooltip.name = 'tooltip';
// Add the tooltip to the parent (group)
this.parent.addChild(tooltip);
}
// Create onMouseLeave event for dot
dot.onMouseLeave = function(event) {
// We retrieve the tooltip from its name in the parent node (group) then remove it
this.parent.children['tooltip'].remove();
}

Leaflet.js: Open all popup bubbles on page load

I'm trying to work out from the Leaflet.js docs how it would be possible to open more than one popup upon showing the page. For instance, if one had three markers (each representing a building), each one would have their popup opened immediately.
http://leaflet.cloudmade.com/reference.html#popup
cryptically says:
"Use Map#openPopup to open popups while making sure that only one popup is open at one time (recommended for usability), or use Map#addLayer to open as many as you want."
but
http://leaflet.cloudmade.com/reference.html#map-addlayer
gives no hints about how this might be achievable.
Can anyone clarify if this is possible, and give any hints on how to do it?
You must add the popups as Layer.
Try with this example code:
var popupLocation1 = new L.LatLng(51.5, -0.09);
var popupLocation2 = new L.LatLng(51.51, -0.08);
var popupContent1 = '<p>Hello world!<br />This is a nice popup.</p>',
popup1 = new L.Popup();
popup1.setLatLng(popupLocation1);
popup1.setContent(popupContent1);
var popupContent2 = '<p>Hello world!<br />This is a nice popup.</p>',
popup2 = new L.Popup();
popup2.setLatLng(popupLocation2);
popup2.setContent(popupContent2);
map.addLayer(popup1).addLayer(popup2);
L.Map = L.Map.extend({
openPopup: function(popup) {
// this.closePopup();
this._popup = popup;
return this.addLayer(popup).fire('popupopen', {
popup: this._popup
});
}
});
example: http://jsfiddle.net/paulovieira/yVLJf/
found it here: https://groups.google.com/forum/#!msg/leaflet-js/qXVBcD3juL4/4pZXHTv1baIJ
marker.addTo(myMap).bindPopup('Hello popup', {autoClose:false}).openPopup();
use autoClose option
In the latest version, there is an autoClose option.
To have both marker and popup open at same time, without adding layers explicitly :
var popup1 = new L.Popup({'autoClose':false});
popup1.setLatLng([53.55375, 9.96871]);
popup1.setContent('First popup');
var popup2 = new L.Popup({'autoClose':false});
popup2.setLatLng([53.552046, 9.9132]);
popup2.setContent('Second popup');
L.marker([53.55375, 9.96871]).addTo(myMap)
.bindPopup(popup1).openPopup();
L.marker([53.552046, 9.9132]).addTo(myMap)
.bindPopup(popup2).openPopup();
This solution work for me:
L.marker([30.4160534, -87.2226216], {icon: icon_url}).bindPopup('Hello World',{autoClose:false}).addTo(map).openPopup();
here is the preview image: https://prnt.sc/NuX9Qs291IQq
triky solution is remove popup link from map object on open:
map.on('popupopen', function (e) {
delete map._popup;
});

Flex 4 Drag-n-Drop with custom DragProxy

I'm doing the drag an drop of an ItemRenderer manually (DataGrid) and want to know how to generate a custom DragProxy of a component that hasn't been added to the display list.
I tried something like this but didn't work:
private function doDrag(event:MouseEvent):void
{
var dragSource:DragSource = new DragSource();
dragSource.addData(data, 'dnd_format');
//var bm:Bitmap = new Bitmap(ImageSnapshot.captureBitmapData(this));
var btn:Button = new Button();
btn.label = 'New Button';
var bm:Bitmap = new Bitmap(ImageSnapshot.captureBitmapData(btn));
var dragProxy:Image = new Image();
dragProxy.source = bm;
DragManager.doDrag(this, dragSource, event, dragProxy,0,0, 0.6);
}
So, I want to be able to create the DragProxy using a component, the button is just an example.
Any ideas?
My guess is that this is not working because you are trying to get a bitmap from a component that was just created and has not been added to the stage. I would try testing this code with using an embedded image as the drag proxy first. If that works, then try getting a bitmap from a component that exists on the stage. My guess is that both cases will work.

Resources