Button position on map - Windows Phone 8 - windows-phone-8

I'm using Windows Phone 8 (Silverlight) and control Microsoft.Phone.Maps.Controls.Map. How can I position the button, to be on the bottom right corner of the map.
I have tried:
var grid = new Grid
{
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch
};
var button = new Button
{
Content = "button",
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Bottom,
};
grid.Children.Add(centerButton);
var mapOverlay = new MapOverlay
{
Content = grid
};
var mapLayer = new MapLayer {mapOverlay};
map.Layers.Add(mapLayer);
but it still stays on top left only.
Thanks

var grid = new Grid()
{
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Bottom,
};
var button = new Button
{
Content = "button",
};
grid.Children.Add(button);
var mapOverlay = new MapOverlay
{
Content = grid
};
var mapLayer = new MapLayer {mapOverlay};
map.Layers.Add(mapLayer);

Related

How to click through googlemap pins

I have a map using Xamarin.Forms.Googlemap in my xamarin forms app.
Is there a way to click on what is behind a pin?
I am creating polygons on the googlemap and then adding custom pins with orchard names on it.
Pin pin = new Pin()
{
Icon = CreateLabels(orchardname, 60),
Flat = true,
Address = string.Empty,
Label = string.Empty,
Position = Xamarin.Forms.GoogleMaps.Bounds.FromPositions(allpositions).Center,
Anchor = new Point(0.5, -1),
IsVisible = _showPropertyzoom
};
protected BitmapDescriptor CreateLabels(string Text, int size)
{
SKBitmap bitmap;
SKCanvas bitmapCanvas;
SKColor white = new SKColor(255,255,255);
SKColor blue = new SKColor(0,88,164);
SKPaint textPaintStroke = new SKPaint { TextSize = size, StrokeWidth=3, Color = white, FakeBoldText=true, Style = SKPaintStyle.Stroke};
SKPaint textPaint = new SKPaint { TextSize = size, Color = blue };
SKRect bounds = new SKRect();
textPaint.MeasureText(Text, ref bounds);
bitmap = new SKBitmap((int)(bounds.Right + 10), (int)(bounds.Height +5));
using (bitmapCanvas = new SKCanvas(bitmap))
{
bitmapCanvas.Clear();
bitmapCanvas.DrawText(Text, bounds.Left, -bounds.Top, textPaintStroke);
bitmapCanvas.DrawText(Text, bounds.Left, -bounds.Top, textPaint);
}
SKData data = SKImage.FromBitmap(bitmap).Encode(SKEncodedImageFormat.Png, 100);
var image = BitmapDescriptorFactory.FromStream(data.AsStream());
return image;
}
The problem i am having is when i click on a polygon to trigger the polygonclicked event i am clicking on the pin so nothing happens.
I can't just use the pinclicked event to trigger the polygonclicked event in this case, because the pin/label can span across multiple polygons.

Newbie trying to display two images side by side using Scala.Swing

I'm trying to make an application where you can flip through pages.
I was hoping this code would display two images (001.jpg, 002.jpg) side by side, but instead I don't get anything.
import java.awt.Dimension
import javax.swing.ImageIcon
import scala.swing.event.UIElementResized
import scala.swing.{BorderPanel, BoxPanel, Label, MainFrame, Orientation, SimpleSwingApplication}
object CViewerMainWindow extends SimpleSwingApplication {
var i = 0
def drawPages(left: Label, right: Label, size: Dimension): Unit = {
//resize to match window
}
def top = new MainFrame {
title = "Work in Progress"
preferredSize = new Dimension(320, 240)
var leftPage = new Label {new ImageIcon("/Users/Matt/learning-scala/learning-GUI/001.jpg")}
var rightPage = new Label {new ImageIcon("/Users/Matt/learning-scala/learning-GUI/002.jpg")}
// maximize
visible = true
// contents = new BorderPanel {
// layout(leftPage) = BorderPanel.Position.West
// layout(rightPage) = BorderPanel.Position.East
// }
contents = new BorderPanel {
layout(new BoxPanel(Orientation.Vertical) {
contents += leftPage
}) = BorderPanel.Position.West
layout(new BoxPanel(Orientation.Vertical) {
contents += rightPage
}) = BorderPanel.Position.East
}
// contents = new Label("Here is the contents!")
listenTo(this)
reactions += {
case UIElementResized(source) =>
println(source.size)
drawPages(leftPage, rightPage, size)
}
}
}
I fixed the issue by replacing
var leftPage = new Label {
new ImageIcon("/Users/Matt/learning-scala/learning-GUI/001.jpg")
}
var rightPage = new Label {
new ImageIcon("/Users/Matt/learning-scala/learning-GUI/002.jpg")
}
with this code
var leftPage = new Label {
icon = new ImageIcon("/Users/Matt/learning-scala/learning-GUI/001.jpg")
}
var rightPage = new Label {
icon = new ImageIcon("/Users/Matt/learning-scala/learning-GUI/002.jpg")
}
Instead of just giving the Label the ImageIcon, you apparently have to set its icon to the ImageIcon you want.

how to add image to the location over a map (windows phone 8)

i am following the example
Nokia blog but my problem is ,
1> i need to add image to the location point instead of color
2> i want to show detail information in the popup like Google map
May this help you.
Here i had use textblock to show custom data. Background image for a stack panel
Private void ShoeCustomPushPuin()
{
Pushpin pushPin = null;
StackPanel stackPanel = null;
TextBlock txtblkDownloadSpeed = null;
TextBlock txtblkUploadSpeed = null;
GeoCoordinate cordinates = null;
try
{
cordinates = new GeoCoordinate();
pushPin = new Pushpin();
stackPanel = new StackPanel();
txtblkDownloadSpeed = new TextBlock();
txtblkUploadSpeed = new TextBlock();
cordinates.Latitude = Your latitude value;
cordinates.Longitude = your longitude value;
txtblkUploadSpeed.Text = your data;
txtblkDownloadSpeed.Text =your data;
ImageBrush imgbrush= new ImageBrush
{
ImageSource = new BitmapImage(new Uri("your background image path", UriKind.Relative)),
};
stackPanel.Background = imgbrush;
stackPanel.Children.Add(txtblkDownloadSpeed);
stackPanel.Children.Add(txtblkUploadSpeed);
pushPin.Content = stackPanel;
pushPin.GeoCoordinate = cordinates;
MapOverlay overlay = new MapOverlay
{
GeoCoordinate = cordinates,
Content = pushPin
};
MapLayer layer = new MapLayer();
layer.Add(overlay);
mapHistory.Center = cordinates;
mapHistory.Layers.Add(layer);
}
catch (Exception ex)
{
}
}

Background Border of TextBlock

I want to add border around TextBlock programatically in Windows Store Application.
How can I do this?
Thanks.
Create new project and add this code in OnNavigatedTo event.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var tb = new TextBlock()
{
Text = "...TextBlock with border...",
FontSize = 20
};
//To get actual height and width of TextBlock
tb.Arrange(new Rect(0, 0, Window.Current.Bounds.Width, Window.Current.Bounds.Height));
tb.Measure(new Size(Window.Current.Bounds.Width, Window.Current.Bounds.Height));
var border = new Border()
{
BorderThickness = new Thickness(3),
BorderBrush = new SolidColorBrush(Windows.UI.Colors.Red),
Height = tb.ActualHeight + 10,
Width = tb.ActualWidth + 10
};
var rootGrid = (Grid)(((Page)this).Content);
rootGrid.Children.Add(border);
border.Child = tb;
}

Calling button in Action Script 3.0

I am trying to make button panel. each button have two type btn_home and btn_home_white I am trying to reach those buttons.It is work if I write for each button their own methods like
btn_home.addEventListener(MouseEvent.MOUSE_OVER,overEffect);
btn_home_white.addEventListener(MouseEvent.MOUSE_OUT,outEffect);
function overEffect(e:MouseEvent)
{
var myTweenHight:Tween = new Tween( btn_home,"height",Bounce.easeOut,25,0,3,true);
var myTweenHight2:Tween = new Tween(btn_home_white,"height",Bounce.easeOut,0,25,3,true);
var myTweenAlpha:Tween = new Tween(btn_home_white,"alpha",Strong.easeOut,0,1,2,true);
}
function outEffect(e:MouseEvent)
{
var myTweenHight:Tween = new Tween btn_home,"height",Bounce.easeOut,0,25,3,true);
var myTweenHight2:Tween = new Tween(btn_home_white,"height",Bounce.easeOut,25,0,3,true);
var myTweenAlpha:Tween = new Tween(btn_home_white,"alpha",Strong.easeOut,1,0,2,true);
}
But I have 10 buttons as btn_buttonname and btn_buttonname_white . I tryed to create Event listener on stage for all.It works for firts type buttons btn_buttonname but How can I get second type buttons? I tryed e.target["_white"] but it does not work .
stage.addEventListener(MouseEvent.MOUSE_OVER , overEffect);
stage.addEventListener(MouseEvent.MOUSE_OUT , outEffect);
function overEffect(e:MouseEvent)
{
var myTweenHight:Tween = new Tween(e.target,"height",Bounce.easeOut,25,0,3,true);
trace("height");
var myTweenHight2:Tween = new Tween(e.target["_white"],"height",Bounce.easeOut,0,25,3,true);
var myTweenAlpha:Tween = new Tween(e.target["_white"],"alpha",Strong.easeOut,0,1,2,true);
}
function outEffect(e:MouseEvent)
{
var myTweenHight:Tween = new Tween(e.target,"height",Bounce.easeOut,0,25,3,true);
var myTweenHight2:Tween = new Tween(e.target["_white"],"height",Bounce.easeOut,25,0,3,true);
var myTweenAlpha:Tween = new Tween(e.target["_white"],"alpha",Strong.easeOut,1,0,2,true);
}
EDIT:
I made it work as Daniel Carvalho sad adding for each buttons event listener.Now it works but if I move out mouse on button to other button previous button does not turn original form .
btn_home.addEventListener(MouseEvent.MOUSE_OVER,overEffect);
btn_home_white.addEventListener(MouseEvent.MOUSE_OUT,outEffect);
btn_contact.addEventListener(MouseEvent.MOUSE_OVER,overEffect);
btn_contact_white.addEventListener(MouseEvent.MOUSE_OUT,outEffect);
btn_menu.addEventListener(MouseEvent.MOUSE_OVER,overEffect);
btn_menu_white.addEventListener(MouseEvent.MOUSE_OUT,outEffect);
btn_restaurant.addEventListener(MouseEvent.MOUSE_OVER,overEffect);
btn_restaurant_white.addEventListener(MouseEvent.MOUSE_OUT,outEffect);
btn_rezervation.addEventListener(MouseEvent.MOUSE_OVER,overEffect);
btn_rezervation_white.addEventListener(MouseEvent.MOUSE_OUT,outEffect);
function overEffect(e:MouseEvent)
{
switch (e.target)
{
case ( btn_home) :
{
var HomeTweenHight:Tween = new Tween(btn_home,"height",Bounce.easeOut,25,0,0.5,true);
var HomeTweenHight2:Tween = new Tween(btn_home_white,"height",Bounce.easeOut,0,25,0.5,true);
var HomeTweenAlpha:Tween = new Tween(btn_home_white,"alpha",Strong.easeOut,0,1,2,true);
break;
};
case ( btn_contact) :
{
var ContactTweenHight:Tween = new Tween(btn_contact,"height",Bounce.easeOut,25,0,0.5,true);
var ContactTweenHight2:Tween = new Tween(btn_contact_white,"height",Bounce.easeOut,0,25,0.5,true);
var ContactTweenAlpha:Tween = new Tween(btn_contact_white,"alpha",Strong.easeOut,0,1,2,true);
break;
};
case ( btn_menu) :
{
var MenuTweenHight:Tween = new Tween(btn_menu,"height",Bounce.easeOut,25,0,0.5,true);
var MenuTweenHight2:Tween = new Tween(btn_menu_white,"height",Bounce.easeOut,0,25,0.5,true);
var MenuTweenAlpha:Tween = new Tween(btn_menu_white,"alpha",Strong.easeOut,0,1,2,true);
break;
};
case ( btn_restaurant) :
{
var RestourantTweenHight:Tween = new Tween(btn_restaurant,"height",Bounce.easeOut,25,0,0.5,true);
var RestourantTweenHight2:Tween = new Tween(btn_restaurant_white,"height",Bounce.easeOut,0,25,0.5,true);
var RestourantTweenAlpha:Tween = new Tween(btn_restaurant_white,"alpha",Strong.easeOut,0,1,2,true);
break;
};
case (btn_rezervation) :
{
var RezervationTweenHight:Tween = new Tween(btn_rezervation,"height",Bounce.easeOut,25,0,0.5,true);
var RezervationTweenHight2:Tween = new Tween(btn_rezervation_white,"height",Bounce.easeOut,0,25,0.5,true);
var RezervationTweenAlpha:Tween = new Tween(btn_rezervation_white,"alpha",Strong.easeOut,0,1,2,true);
break;
}
}
};
function outEffect(e:MouseEvent)
{
switch (e.target)
{
case (btn_home_white) :
{
var HomeTweenHight:Tween = new Tween(btn_home,"height",Bounce.easeOut,0,25,0.5,true);
var HomeTweenHight2:Tween = new Tween(btn_home_white,"height",Bounce.easeOut,25,0,0.5,true);
var HomeTweenAlpha:Tween = new Tween(btn_home_white,"alpha",Strong.easeOut,1,0,2,true);
break;
};
case (btn_contact_white) :
{
var ContactTweenHight:Tween = new Tween(btn_contact,"height",Bounce.easeOut,0,25,0.5,true);
var ContactTweenHight2:Tween = new Tween(btn_contact_white,"height",Bounce.easeOut,25,0,0.5,true);
var ContactTweenAlpha:Tween = new Tween(btn_contact_white,"alpha",Strong.easeOut,1,0,2,true);
break;
}
case (btn_menu_white) :
{
var MenuTweenHight:Tween = new Tween(btn_menu,"height",Bounce.easeOut,0,25,0.5,true);
var MenuTweenHight2:Tween = new Tween(btn_menu_white,"height",Bounce.easeOut,25,0,0.5,true);
var MenuTweenAlpha:Tween = new Tween(btn_menu_white,"alpha",Strong.easeOut,1,0,2,true);
break;
};
case (btn_restaurant_white) :
{
var RestourantTweenHight:Tween = new Tween(btn_restaurant,"height",Bounce.easeOut,0,25,0.5,true);
var RestourantTweenHight2:Tween = new Tween(btn_restaurant_white,"height",Bounce.easeOut,25,0,0.5,true);
var RestourantTweenAlpha:Tween = new Tween(btn_restaurant_white,"alpha",Strong.easeOut,1,0,2,true);
break;
};
case (btn_rezervation_white) :
{
var RezervationTweenHight:Tween = new Tween(btn_rezervation,"height",Bounce.easeOut,0,25,0.5,true);
var RezervationTweenHight2:Tween = new Tween(btn_rezervation_white,"height",Bounce.easeOut,25,0,0.5,true);
var RezervationTweenAlpha:Tween = new Tween(btn_rezervation_white,"alpha",Strong.easeOut,1,0,2,true);
break;
};
}
};
Your e.target should work, though you don't (as far as I can see) need the [_"white"] after e.target for your _white buttons. The reason the e.targets aren't working is because you're just adding event listeners to the stage, and not the individual buttons.
I see two choices (perhaps there are others): manually go through writing event listeners for each button, or put all the buttons that will use the overEffect function into one Array, and all the buttons using the outEffect function into another Array.
Then create two for loops, and go through those Arrays adding the event listeners to each child of the array. Your e.target code should work at that point.
Let me know if you have any trouble with that, hope it helps.
debu
Here is a quick example that may help you:
http://wonderfl.net/c/vhay
function createButton():MovieClip{
var button:MovieClip=new MovieClip();
var stateA:Shape=new Shape();
var g:Graphics = stateA.graphics;
g.beginFill(0xFF0000);
g.drawRect(0, 0, 10, 10);
g.endFill();
button["stateA"] = stateA;
button.addChild(stateA);
var stateB:Shape=new Shape();
g = stateB.graphics;
g.beginFill(0x00FF00);
g.drawRect(0, 0, 10, 10);
g.endFill();
button["stateB"] = stateB;
button.addChild(stateB);
stateB.visible=false;
return button;
}
var nbButtons:int=10;
var buttons:Array=[];
var selectButton:MovieClip;
for (var i : int = 0;i < nbButtons; i++) {
var button:MovieClip=createButton();
addChild(button);
button.y=10;
button.x=i*12+10;
addChild(button);
buttons.push(button);
setUpButton(button);
}
function setUpButton(button:MovieClip):void {
button.buttonMode=true;
button.addEventListener(MouseEvent.ROLL_OVER, buttonRollOver);
button.addEventListener(MouseEvent.ROLL_OUT, buttonRollOut);
button.addEventListener(MouseEvent.CLICK, buttonClick);
}
function buttonClick(e:Event):void{
switchButtonStateToNotSelected();
switchButtonStateToSelected(e.currentTarget as MovieClip);
}
function switchButtonStateToSelected(button:MovieClip):void{
button.buttonMode=true;
button.removeEventListener(MouseEvent.ROLL_OVER, buttonRollOver);
button.removeEventListener(MouseEvent.ROLL_OUT, buttonRollOut);
button.removeEventListener(MouseEvent.CLICK, buttonClick);
button["stateA"]["visible"]=false;
button["stateB"]["visible"]=true;
selectButton=button;
}
function switchButtonStateToNotSelected():void{
if(selectButton) {
setUpButton(selectButton);
selectButton["stateA"]["visible"]=true;
selectButton["stateB"]["visible"]=false;
selectButton=null;
}
}
function buttonRollOver(e:Event):void{
e.currentTarget["stateA"]["visible"]=false;
e.currentTarget["stateB"]["visible"]=true;
}
function buttonRollOut(e:Event):void{
e.currentTarget["stateA"]["visible"]=true;
e.currentTarget["stateB"]["visible"]=false;
}