Setting colour of application bar in C# - windows-phone-7

I define my ApplicationBar in code like that:
private void BuildApplicationBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
ApplicationBar = new ApplicationBar();
ApplicationBar.Opacity = 0.8;
ApplicationBar.ForegroundColor = Color.FromArgb(0, 138, 204, 34);
// Create a new button and set the text value to the localized string from AppResources.
ApplicationBarIconButton CheckInExitAppBarButton = new ApplicationBarIconButton(new Uri("icons/check_in.png", UriKind.Relative));
CheckInExitAppBarButton.Text = AppResource.CheckInExit;
ApplicationBar.Buttons.Add(CheckInExitAppBarButton);
CheckInExitAppBarButton.Click += new EventHandler(CheckInExitAppBarButton_Click);
}
Atfer that I can see that color of icons changed, but I can't see text under them. When I do this without ApplicationBar.Color I can see both icon + text but in white which doesn't interest me

The text uses the alpha value of the foreground color, and you're setting it to 0 (transparent). Set it to 255 instead and it'll work:
private void BuildApplicationBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
ApplicationBar = new ApplicationBar();
ApplicationBar.Opacity = 0.8;
ApplicationBar.ForegroundColor = Color.FromArgb(255, 138, 204, 34);
// Create a new button and set the text value to the localized string from AppResources.
ApplicationBarIconButton CheckInExitAppBarButton = new ApplicationBarIconButton(new Uri("icons/check_in.png", UriKind.Relative));
CheckInExitAppBarButton.Text = AppResource.CheckInExit;
ApplicationBar.Buttons.Add(CheckInExitAppBarButton);
CheckInExitAppBarButton.Click += new EventHandler(CheckInExitAppBarButton_Click);
}

Related

How to use TextButtonStyle.overFont?

I'm trying to use overFont and overColor on TextButton so the button appearance can changes when the mouse move over.
Here's the style I defined.
var buttonStyle = new TextButtonStyle();
buttonStyle.fontColor = new Color(1f, 1f, 1f, 1f);
buttonStyle.disabledFontColor = new Color(0, 0, 0, 0.4f);
buttonStyle.down = skin.getDrawable( "button_down");
buttonStyle.up= skin.getDrawable( "button_up");
buttonStyle.over= skin.getDrawable( "button_over");
buttonStyle.overFontColor = new Color(0, 0.3f, 0.3f, 1f);
buttonStyle.font = font
skin.add("default", buttonStyle);
The button is created as follows:
var startGameButton = new TextButton("Start game", skin);
startGameButton.x = buttonX;
startGameButton.y = currentY;
startGameButton.width = BUTTON_WIDTH;
startGameButton.height = BUTTON_HEIGHT;
stage.addActor(startGameButton);
/*startGameButton.addListener ([ Event e |
Gdx.app.log ("App", "Start game") ;
return true ;
])*/
startGameButton.addListener (new ChangeListener () {
override changed(ChangeEvent event, Actor actor) {
Gdx.app.log ("App", "Start game") ;
}
})
While the down and up state are properly taken into account, the over properties are not used: the button doesn't change when the mouse enters the button area.
buttonStyle.fontOverColor = Color.BLUE; works fine for me,
try to pass to your TextButton constructor not skin, but buttonStyle,
in TextButton there is such constructor
public TextButton (String text, TextButtonStyle style)
It's difficult to say something else, because code not looks like real working code, I mean var keyword or this code is not correct (there is no public variables x, y, width, height):
startGameButton.x = buttonX;
startGameButton.y = currentY;
startGameButton.width = BUTTON_WIDTH;
startGameButton.height = BUTTON_HEIGHT;
If changing constructor will not help you, please post your real code.

how to add tooltip to pushpin on windowsphone

I've been doing a essay about map on windows phone. I added pushpins default into map and its content is a image. I want to show information when I tap or click on pushpin, but I don't know what to do. I've just thought about use tooltip to show info, but I can't do it.
here is my createpushpin function.
can you help me? thank you for all kind of you!
private void CreateNewPushpin(object selectedItem)
{
var pushpinPrototype = selectedItem as Pushpinsmodel;
var pushpinicon = pushpinPrototype.Icon;
Pushpin pushpins = new Pushpin() { Tag = adress.Name };
pushpins.Background = new SolidColorBrush(Colors.Green);
pushpins.Location = new GeoCoordinate(lad, long);
ImageBrush image = new ImageBrush() {
ImageSource = new System.Windows.Media.Imaging.BitmapImage
(pushpinicon)};
Ellipse elip = new Ellipse()
{
Fill = image,
Name = adress.Name,
StrokeThickness = 10,
Height = 30,
Width = 30
};
pushpins.Content = elip;
var tooltipText = new ToolTip { Content = adress.Name};
ToolTipService.SetToolTip(pushpins, tooltipText);
map1.Children.Add(pushpins);
listpushpin.Add(pushpins);
this.map1.SetView(pushpins.Location, 18.0);
}

WP7 Button content is not being displayed

I am creating a hyperlink button like this:
HyperlinkButton hlbMail = new HyperlinkButton();
hlbMail.Height = 89;
hlbMail.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
hlbMail.VerticalAlignment = System.Windows.VerticalAlignment.Top;
hlbMail.Margin = new Thickness(60, -70, 0, 0);
hlbMail.Width = 290;
hlbMail.FontSize = 22;
TextBlock btnContent = new TextBlock();
btnContent.TextWrapping = TextWrapping.Wrap;
btnContent.Text = message;
btnContent.Visibility = System.Windows.Visibility.Visible;
hlbMail.Content = btnContent;
hlbMail.Visibility = System.Windows.Visibility.Visible;
mailStackPanel.Children.Add(hlbMail);
mailscrollViewer.Content = mailStackPanel;
PIMail.Content = mailscrollViewer;
But i have a problem in which the content of the button is not being displayed. As can be seen, the content is supposed to be the text of the TextBlock (the message var is a string which is not empty). What can be the reason that the content is not being shown?
You need to use this:
hlbMail.Content= btnContent.Text;
I think you forgot to add the .Text.
You cannot have a hyperlinkbutton having textblock as its content. But you can have the text of a textblock as the content of the hyperlink
As you also mentioned you need the text of textblock than you need to specify that you need the text by adding the btnContent.Text;

gtk sharp multiple styles for one widget

I was trying to create two different kinds of buttons: buttons with background and buttons without background.
And unfortunately I can't figure out how I can set some buttons to use the first style and some buttons to use the second.
Here's a code sample (although i doubt it'll help)
Is there some way to change the Style of the button in the .cs file, or any workaround?
//init hyperlink
Button hyperlink = new Button();
Label hyperlink_label = new Label();
hyperlink_label.Text = hyperlink_text;
hyperlink_label.ModifyFg(StateType.Normal, new Gdk.Color(0,0,0));
hyperlink_label.ModifyFg(StateType.Prelight, new Gdk.Color(255,255,255));
hyperlink_label.ModifyFg(StateType.Selected, new Gdk.Color(255,255,255));
Pango.FontDescription hyperlinkFontDesc = new Pango.FontDescription();
hyperlinkFontDesc.Family = "Adobe Garamond Pro";
hyperlinkFontDesc.AbsoluteSize = hyperlink_fontSize * Pango.Scale.PangoScale;
hyperlink_label.ModifyFont(hyperlinkFontDesc);
hyperlink.Add(hyperlink_label);
mainWindowFixed.Put(hyperlink, hyperlink_pos[0], hyperlink_pos[1]);
//init startbutton
Button startButton = new Button();
Label startLabel = new Label();
startLabel.Text = startButton_text;
startButton.Settings.ThemeName = "Ludwig_AutoUpdater";
startLabel.ModifyFg(StateType.Normal, new Gdk.Color(255,255,255));
startLabel.ModifyFg(StateType.Prelight, new Gdk.Color(255,255,255));
startLabel.ModifyFg(StateType.Selected, new Gdk.Color(255,255,255));
Pango.FontDescription startLabelFontDesc = new Pango.FontDescription();
startLabelFontDesc.Family = "Klavika bd";
startLabelFontDesc.AbsoluteSize = startButton_fontSize * Pango.Scale.PangoScale;
startButton.Add(startLabel);
startButton.Child.ModifyFont(startLabelFontDesc);
startButton.SetSizeRequest(startButton_size[0], startButton_size[1]);
mainWindowFixed.Put(startButton, startButton_pos[0],startButton_pos[1]);
Don't change the style of Gtk.Button. Create a custom widget derived from Gtk.Button and change that widget's style. For example:
public class BGButton : Gtk.Button {}
and
public class NoBGButton : Gtk.Button {}
and now change the style of BGButton and NoBGButton.
Then if you want a Button with a Background use BGButton , else use NoBGButton.

Text on image not appearing, in preview handler vs2005 .net2

hi i am trying to show image of my file in previwew pane i am able to display the image of my file but i am stuck in the part where i need write some text on the image before adding it to preview pane.
// create an image object, using the filename we just retrieved
String strImageFile = file.FullName.Substring(0, file.FullName.Length - 3) + "jpg";
//file.CreationTime.ToString();
//------------------------------------
//Load the Image to be written on.
Bitmap bitMapImage = new System.Drawing.Bitmap(strImageFile);
Graphics graphicImage = Graphics.FromImage(bitMapImage);
graphicImage.SmoothingMode = SmoothingMode.AntiAlias;
graphicImage.DrawString("AWESOME!", new Font("Arial", 20, FontStyle.Bold), Brushes.Black, new Point(100, 250));
//Save the new image to the response output stream.
bitMapImage.Save(strImageFile, ImageFormat.Png);
//------------------------------------
// Create a picture box control
PictureBox p = new PictureBox();
p.Dock = DockStyle.Fill;
p.Image = bitMapImage;
//p.Image = System.Drawing.Image.FromFile(strImageFile);
p.SizeMode = PictureBoxSizeMode.Zoom;
Controls.Add(p);
//graphicImage.Dispose();
//bitMapImage.Dispose();
Only the image appease and not the text, any idea what i might be missing.
thanks
Narrow it down too:
PictureBox p = new PictureBox();
// create an image object, using the filename we just retrieved
String strImageFile = file.FullName.Substring(0, file.FullName.Length - 3) + "jpg";
Bitmap bitMapImage = new System.Drawing.Bitmap(strImageFile);
Graphics graphicImage = Graphics.FromImage(bitMapImage);
graphicImage.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
graphicImage.DrawString("AWESOME!", new Font("Arial", 20, FontStyle.Bold), Brushes.Black, new Point(100, 250));
graphicImage.DrawImage(bitMapImage, new Rectangle(205, 0, 200, 200), 0, 0, bitMapImage.Width, bitMapImage.Height, GraphicsUnit.Pixel);
p.Image = bitMapImage;
p.Dock = DockStyle.Fill;
Controls.Add(p);
But i am getting an exception on

Resources