顯示具有 C# 標籤的文章。 顯示所有文章
顯示具有 C# 標籤的文章。 顯示所有文章

2011年9月7日 星期三

Windows Phone 7 Live Tile

原來WP7可以用戶API去Create, Update, Delete App Icon,
而且可以用一個人App有2個Icon係數Start Page,
真係幾得意見.......XD

Using dll
//Import the ShellTile namespace
using Microsoft.Phone.Shell;

create second icon
// Look to see whether the Tile already exists and if so, don't try to create it
again.
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x =>
x.NavigationUri.ToString().Contains("DefaultTitle=FromTile"));
// Create the Tile if we didn't find that it already exists.
if (TileToFind == null)
{
    // Create the Tile object and set some initial properties for the Tile.
    // The Count value of 12 shows the number 12 on the front of the Tile. Valid values are 1-99.
    // A Count value of 0 indicates that the Count should not be displayed.
    StandardTileData NewTileData = new StandardTileData
    {
        BackgroundImage = new Uri("Red.jpg", UriKind.Relative),
        Title = "Secondary Tile",
        Count = 12,
        BackTitle = "Back of Tile",
        BackContent = "Welcome to the back of the Tile",
        BackBackgroundImage = new Uri("Blue.jpg", UriKind.Relative)
    };
    // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
    ShellTile.Create(new Uri("/SecondaryTile.xaml?DefaultTitle=FromTile", UriKind.Relative), NewTileData);
}

2011年9月6日 星期二

C# Lambda Expression () =>

今天上了一個Windows Phone 7 course,
入面見到一個我沒見過的話syntax:

void accelerometer_ReadingChanged(object sender, AccelerometerReadingEventArgs e)
{
      Deployment.Current.Dispatcher.BeginInvoke(() => MyReadingChanged(e));
}

點來上網一看,它叫作Lambda Expression(Lambda 表達式),
"=>" 可以解作為 "goes to"


PS. 參考http://msdn.microsoft.com/en-us/library/bb397687.aspx

2010年1月14日 星期四

Dynamic Sprite Font - XNA 顯示及動態生成多國文字

下載點:http://sites.google.com/a/goldmoz.co.cc/icecatsfiles/dang-an-file/TestDynamicSpriteFont.rar?attredirects=0&d=1

Dynamic Sprite Font是一個XNA的Plug-in,
它應該是目前為止用法最方便的XNA多國文字顯示方法,
基本上用法跟SpriteFont相同,
只是Processor使用Dynamic Sprite Font Description,
之後如常使用Content.Load("Font Name");,
哪麼設定就會完成.

以下是例子:

spriteBatch.Begin();
spriteBatch.DrawString(font, "我是中國人", Vector2.Zero, Color.Red);
spriteBatch.DrawString(font, "I am a Chinese", new Vector2(0, 100), Color.White);
spriteBatch.DrawString(font, "我是中国人", new Vector2(0, 200), Color.Yellow);
spriteBatch.DrawString(font, "私は中国人です", new Vector2(0, 300), Color.Black);
spriteBatch.DrawString(font, "저는 중국인이에요", new Vector2(0, 400), Color.Purple);
spriteBatch.DrawString(font, "मैं एक चीनी रहा हूँ", new Vector2(0, 500), Color.LimeGreen);
spriteBatch.End();


2010年1月4日 星期一

XNA 無限制的 FPS

this.IsFixedTimeStep = false;

// intialize the graphics
graphics.SynchronizeWithVerticalRetrace = false;
graphics.ApplyChanges();

加上以上Code在Game.cs的Initialize()中,
就可以由60fps升到4000fps以上 (我使用NVIDIA® GeForce® 9800 GT和4GB Ram)