Learn Silverlight and Blend
Nibbles offers some quick tutorials for Silverlight and Blend. Quite a nice reading.
ASP.net C# VB.net and other programming languages...new software and other tech-related articles...with the good and the bad...
Nibbles offers some quick tutorials for Silverlight and Blend. Quite a nice reading.
Posted by
Vlad
at
9:35 PM
0
comments
Tags: Programming, Silverlight, web
This game got famous today on digg.com. It`s a really nice flash game which requires logic. Loved the game but..when I read a MS blog I got to another Silverlight sample game. If you take a closer look at things you can see that the concept of the game is the same. I wonder how much time was needed to create the game in Flash and Silverlight. Until we find that out..enjoy the games.
Posted by
Vlad
at
12:56 PM
0
comments
Tags: Silverlight, Software, web
If you enjoyed Richard Zadorozny`s bar chart, pie char or the graph you can now download the source code. This is the best way you can learn Silverlight programming.
(source)
Posted by
Vlad
at
12:12 PM
0
comments
Tags: Programming, Silverlight
This is part of a series of articles that shows the creation of a Silverlight game. Please read part 1,part 2 or part 3 if you haven`t done so yet.
1: void Start(int size,double blockProbability,Point StartPosition,Point EndPosition)
2: {3: startPoint = new Point(StartPosition.X * multiplier, StartPosition.Y * multiplier);
4: endPoint = new Point(EndPosition.X * multiplier, EndPosition.Y * multiplier);
5: 6: NextLevel.Visibility = Visibility.Collapsed; 7: NextLevelText.Visibility = Visibility.Collapsed; 8: Congratulations.Visibility = Visibility.Collapsed; 9: steps = 0;10: isMoving = false;
11: map = new int[size, size];
12: int unpassable = 0;
13: for (int i = 0; i < size; i++)
14: {15: for (int j = 0; j < size; j++)
16: { 17: map[i, j] = (r.NextDouble() < blockProbability) ? 1 : 0;18: map[(int)StartPosition.X, (int)StartPosition.Y] = 0;
19: map[(int)EndPosition.X, (int)EndPosition.Y] = 0;
20: if (map[i, j] == 0)
21: {22: AddNewRectangle(new Point(i , j ), Colors.Green);
23: }24: if (map[i, j] == 1)
25: { 26: unpassable++;27: AddNewRectangle(new Point(i , j ), Colors.Black);
28: } 29: } 30: } 31: Unpassable.Text = unpassable.ToString(); 32: CurrentLevel.Text = level.ToString();33: //setup visibility and location of helper objects
34: 35: Congratulations.SetValue(Canvas.TopProperty, size * multiplier + 5); 36: NumberOfSteps.SetValue(Canvas.TopProperty, size * multiplier + 5); 37: NumberOfStepsText.SetValue(Canvas.TopProperty, size * multiplier + 5); 38: NextLevelText.SetValue(Canvas.LeftProperty, size * multiplier + 40); 39: NextLevel.SetValue(Canvas.LeftProperty, size * multiplier + 5); 40: Restart.SetValue(Canvas.LeftProperty, size * multiplier + 5); 41: RestartText.SetValue(Canvas.LeftProperty, size * multiplier + 30); 42: UnpassableText.SetValue(Canvas.LeftProperty, size * multiplier + 19); 43: Unpassable.SetValue(Canvas.LeftProperty, size * multiplier + 107); 44: CurrentLevelText.SetValue(Canvas.LeftProperty, size * multiplier + 5); 45: CurrentLevel.SetValue(Canvas.LeftProperty, size * multiplier + 107); 46: 47: 48: //setup the main objects:the start and the end(start is the moving object)
49: end = CreateSpecialRectangle(EndPosition, Colors.Yellow); 50: start = CreateSpecialRectangle(StartPosition, Colors.Red);51: //setup event handler for the end object
52: end.MouseLeftButtonDown += new MouseEventHandler(r_MouseLeftButtonDown);
53: }
Posted by
Vlad
at
6:58 PM
0
comments
Tags: Programming, Silverlight
So with the static part in place we need to get the game moving...But first we need some class variables that will help within the project:
1: //the level
2: static int level = 1;
3: //the number of times that the user moved the rectangle in this round
4: static int steps = 0;
5: //the probability that the block generated is a blocking block(cannot pass through it)
6: static double blockingProbability = 0.03;
7: //the current destination point of the moving rectangle
8: Point toMove;9: //the start point of the round
10: Point startPoint;11: //the end point of the round
12: Point endPoint;13: //true if the user rectangle is moving
14: bool isMoving;
15: //keeps the map
16: int[,] map;
17: Random r;18: //the height of the generated rectangles
19: const int height = 19;
20: //the width of the generated rectangles
21: const int width = 19;
22: //the multiplier by which the matrix location is multiplied (Ex if multiplier is
23: //20 than the location (1,2) on the map will actually be shown at
24: //(20,40)
25: const int multiplier = 20;
26: //the start rectangle
27: Rectangle start;28: //the end rectangle
29: Rectangle end;30: //the board size
31: static int boardSize = 10;
1: public void Page_Loaded(object o, EventArgs e)
2: {3: // Required to initialize variables
4: InitializeComponent();5: r = new Random();
6: timer.Completed += new EventHandler(timer_Completed);
7: Restart.MouseLeftButtonDown += new MouseEventHandler(Restart_MouseLeftButtonDown);
8: RestartText.MouseLeftButtonDown += new MouseEventHandler(Restart_MouseLeftButtonDown);
9: NextLevel.MouseLeftButtonDown += new MouseEventHandler(NextLevel_MouseLeftButtonDown);
10: NextLevelText.MouseLeftButtonDown += new MouseEventHandler(NextLevel_MouseLeftButtonDown);
11: 12: Start(boardSize, blockingProbability, new Point(r.Next() % boardSize, r.Next() % boardSize), new Point(r.Next() % boardSize, r.Next() % boardSize));
13: }
Posted by
Vlad
at
6:14 PM
0
comments
Tags: Programming, Silverlight
As I always like seeing the final product first...here is the whole XAML code needed for the game:
1: <Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="parentCanvas" Loaded="Page_Loaded" x:Class="PathFinder.Page;assembly=ClientBin/PathFinder.dll" Width="709" Height="558" Background="White">
2: <Canvas.Resources>
3: <Storyboard x:Name="timer">
4: <DoubleAnimation Duration="00:00:0.01" />
5: </Storyboard>
6: </Canvas.Resources>
7: <!--The restart rectangle with a gradient fill-->
8: <Rectangle Stroke="#FF000000" x:Name="Restart" Width="149" Height="40" Canvas.Left="550" Canvas.Top="13" RadiusX="15" RadiusY="15" Cursor="Hand">
9: <Rectangle.Fill>
10: <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
11: <GradientStop Color="#FF3E9E35" Offset="0"/>
12: <GradientStop Color="#FF51FF40" Offset="1"/>
13: </LinearGradientBrush>
14: </Rectangle.Fill>
15: </Rectangle>
16: <!--The restart text-->
17: <TextBlock Cursor="Hand" Width="97" Height="20" Canvas.Left="581" Canvas.Top="23" TextWrapping="Wrap" x:Name="RestartText" Text="Restart Level"/>
18: <!--The congratulations text - Collapsed at first as it should only be visible when the user completes a level-->
19: <TextBlock x:Name="Congratulations" Width="303" Visibility="Collapsed" Height="26" Canvas.Left="189" Canvas.Top="529" Foreground="#FFC43E3E" Text="Congratulations you reached your target!" TextWrapping="Wrap"/>
20: <!--Static text-->
21: <TextBlock x:Name="NumberOfStepsText" RenderTransformOrigin="0.492,-1.333" Width="124" Height="21" Canvas.Left="8" Canvas.Top="529" Text="Number of steps" TextWrapping="Wrap"/>
22: <!--The number of moves that the user made-->
23: <TextBlock x:Name="NumberOfSteps" Width="49" Height="21" Canvas.Left="136" Canvas.Top="529" Text="0" TextWrapping="Wrap"/>
24: <!--The next level rectangle with a gradient fill-->
25: <Rectangle x:Name="NextLevel" Visibility="Visible" Stroke="#FF000000" RadiusX="15" RadiusY="15" Width="149" Height="40" Canvas.Left="550" Canvas.Top="77" Cursor="Hand">
26: <Rectangle.Fill>
27: <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
28: <GradientStop Color="#FFF48F40" Offset="0"/>
29: <GradientStop Color="#FFDBF65C" Offset="1"/>
30: </LinearGradientBrush>
31: </Rectangle.Fill>
32: </Rectangle>
33: <!--The next level text-->
34: <TextBlock x:Name="NextLevelText" Visibility="Collapsed" Width="94" Height="21" Canvas.Left="584" Canvas.Top="87" Text="Next Level" TextWrapping="Wrap" Cursor="Hand"/>
35: <!--Static text-->
36: <TextBlock x:Name="UnpassableText" Width="89" Height="21" Canvas.Left="564" Canvas.Top="129" Text="Unpassable:" TextWrapping="Wrap"/>
37: <!--The number of unpaassable blocks-->
38: <TextBlock x:Name="Unpassable" Width="39" Height="21" Canvas.Left="650" Canvas.Top="130" Text="12" TextWrapping="Wrap"/>
39: <!--Static text-->
40: <TextBlock x:Name="CurrentLevelText" Width="103" Height="19" Canvas.Left="550" Canvas.Top="154" Text="Current Level:" TextWrapping="Wrap"/>
41: <!--The current level-->
42: <TextBlock x:Name="CurrentLevel" Width="28" Height="18" Canvas.Left="650" Canvas.Top="155" Text="12" TextWrapping="Wrap"/>
43: </Canvas>
Posted by
Vlad
at
6:07 PM
0
comments
Tags: Programming, Silverlight
Posted by
Vlad
at
5:28 PM
0
comments
Tags: Programming, Silverlight, XAML
...is cool...
If you want to learn a bit about it try this
Posted by
Vlad
at
9:52 AM
0
comments
Tags: Programming, Silverlight, Web