DCSIMG
Fun,C# - Pavel's Blog
Sign in | Join | Help

Pavel's Blog

Pavel is a software guy that is interested in almost everything
software related... way too much for too little time

Browse by Tags

C# Extension Methods and Fluent Interfaces
07 February 13 03:42 AM | pavely | 1 comment(s)
The idea of fluent interfaces is not new, and has many forms. The basic idea is to use a single statement to encompass a series of operations that are natural, or at least simple, to use. There are very few fluent interfaces in .NET – the most well known, which has some fluent interface semantics, is the System.Text.StringBuilder class. Here’s a simple example: public static string BuildInfo(Process process) { return new StringBuilder( "Process " ) .AppendLine(process.ProcessName) .Append...
תגים:, , , , , ,
Windows Phone: Playing Sound Effects
03 September 12 01:25 PM | pavely | with no comments
I wanted to create a simple timer application for Windows Phone . The timer would count backwards from a user configured value and when it reached zero, it would play some sound effect to indicate expiration. Sounds simple enough… This is how the application looks like: The problem turned out to be playing that sound effect. I had a WAV file I wanted to play. Silverlight has a MediaElement object that is capable of playing video and/or audio, so it seemed to be a good candidate for the job. MediaElement...
Console Calculator with Roslyn (Part 2)
08 August 12 02:39 PM | pavely | with no comments
In the first part we created a simple enough calculator, but it lacked two features I wanted to have: 1. work with degrees or radians in trigonometric functions. 2. allow simple variables to be used without first declaring them. Let’s see how we can implement these features, starting with the first. Trigonometric functions work in radians, which is sometimes inconvenient.What we need is a way to change the parameter to the trigonometric functions by multiplying it by PI/180 if degrees was requested...
Towers of Hanoi–WPF Style (Part 2)
13 February 12 10:45 PM | pavely | with no comments
In the first part , we saw how to recursively solve the Towers of Hanoi problem in C#. In this post I want to show a graphic view of the solution. This is a starting position with 7 discs: This is how it looks when the problem is solved: In between, the discs move with animation from pole to pole, as the solution dictates. Options include speeding up the process (with the slider, very useful), pausing the animation and resetting to the initial state. Here’s something in the middle: The Poles The...
Towers of Hanoi–WPF Style (part 1)
11 February 12 10:43 PM | pavely | 3 comment(s)
I remember many years ago (at least 15), I was learning Prolog . I used the “Turbo Prolog” package from (what was once) Borland. One of the nice examples there was a solution of the Towers of Hanoi , with a simple animation that showed the steps graphically. This was all textual graphics (today’s Console windows), but it was impressive (at least it impressed me). Prolog was used to show off its AI capabilities, which are, in fact, a recursive, backtracking engine. No matter; we can do it in C#. Towers...
Calculating PI in .NET
30 December 11 10:31 PM | pavely | 2 comment(s)
I always loved mathematics. Although I’m certainly not a mathematician by profession, I’m always intrigued and inspired by math’s pureness and cleverness. One of the simplest and fascinating aspects of math is the number PI . Described simply as the ratio of a circle’s circumference to its diameter, it’s a constant with infinite digits after the decimal point and most importantly, non repeating (at least as far as I know). There are many ways to calculate PI, as evident within the PI Wikipedia link...
Windows Phone: Combining Silverlight & XNA in a Single Page
26 October 11 09:30 PM | pavely | 2 comment(s)
There are two very distinct ways to program on Windows Phone 7.x: Silverlight & XNA. Silverlight is about UI, retained graphics and is event driven. XNA is about immediate mode graphics, based on a timer and polling; Very different models indeed. Each has its strengths and weaknesses. One of the new features in WP7.1 (“mango”) is the ability to combine the two to get the best of both worlds. Here’s a typical scenario where this need may come up: suppose you’re developing an XNA game (2D or 3D...
Porting an XNA game from Windows to Windows Phone (Part 2)
14 August 11 03:40 PM | pavely | 2 comment(s)
In the first part we got our introduction screen up and running, with the starfield scrolling by. However, we couldn’t actually start playing because the game was waiting for a key press… which is nowhere to be found on a Windows Phone device. We simply need a little touch. Adding Touch Support Touch is something the XNA version of Windows and XBOX 360 have no notion of. This is specific for Windows Phone. Touch input information is available as “raw” data (touch points, with positions, etc.) and...
Technology Radio Show, Part 2
21 March 11 10:03 AM | pavely | 3 comment(s)
The second part of the technology radio show on 106.4 FM aired on last Thursday. As with the first part , I was the “Microsoft guy”. This time we were missing the iPhone and Ruby guys, but the show was more to the point (somewhat). You can listen to the recording (if you’re kinda really really bored) here (look for the March 17 show).
תגים:, , , , , , ,
Technology Radio show that I participated in
02 March 11 08:40 PM | pavely | 2 comment(s)
Last week I was invited to a radio show called “Technofobia” (origin in Hebrew) in the Interdisciplinary Center (IDC) in Hertzliya (Israel) (106.4 FM). This was a “special” talk about development technologies. There was a Ruby guy, a Python guy, a C++ guy (actually a girl), an iPhone guy (the famous Yossi Taguri ) and myself, as the “Microsoft guy”. I had to repeatedly (and during the music breaks) tell the hosts that I don’t work at Microsoft, I just use, teach, mostly like and develop with those...
תגים:, , , , , ,
COM Fun with Microsoft Agent
25 February 11 03:44 PM | pavely | 1 comment(s)
Whenever I teach COM interoperability in .NET, I try to show some nice demo for this. The classic is to use one of the Office applications (such as Word) to do some automation by creating a document, adding some text, etc. This is effective enough but not really fun. A much more fun way is to use the Microsoft Agent technology. MS Agent is discontinued as far as further development is concerned, but it’s still fun and great for (at least) learning purposes. What is MS Agent? Its most well known appearance...
XNA 2D Game Tutorial (Part 12)
05 December 10 03:55 PM | pavely | 3 comment(s)
Previous posts in this series: Part 1 : Getting started Part 2 : Drawing something Part 3 : Input handling Part 4 : Game Components Part 5 : Animation and Sprites Part 6 : Handling Projectiles Part 7 : Sound Effects Part 8 : Setting Up Data Part 9 : Creating Aliens Part 10 : Collision Detection Part 11 : More Collisions Teched is over. Time to get back to XNA… In our current project, we have a simple game in which the player can shoot aliens. They keep coming, and once the player is killed – the...
תגים:, , , ,
XNA 2D Game Tutorial (Part 11)
17 November 10 07:25 PM | pavely | 6 comment(s)
Previous posts in this series: Part 1 : Getting started Part 2 : Drawing something Part 3 : Input handling Part 4 : Game Components Part 5 : Animation and Sprites Part 6 : Handling Projectiles Part 7 : Sound Effects Part 8 : Setting Up Data Part 9 : Creating Aliens Part 10 : Collision Detection In the previous part we did some collision detection between the player’s missiles and the aliens. If hit, the alien disappeared gradually (as opposed to a big explosion). Let’s add some more collision detection...
תגים:, , , , , ,
XNA 2D Game Tutorial (Part 10)
16 November 10 10:45 AM | pavely | 2 comment(s)
Previous posts in this series: Part 1 : Getting started Part 2 : Drawing something Part 3 : Input handling Part 4 : Game Components Part 5 : Animation and Sprites Part 6 : Handling Projectiles Part 7 : Sound Effects Part 8 : Setting Up Data Part 9 : Creating Aliens In the previous part we created a bunch of alien enemies that are moving down the screen. Currently, if they hit the player’s ship – nothing happens. If the player’s missiles hit an alien – nothing happens. We need some collision detection...
תגים:, , , ,
XNA 2D Game Tutorial (Part 9)
14 November 10 10:20 PM | pavely | 3 comment(s)
Previous posts in this series: Part 1 : Getting started Part 2 : Drawing something Part 3 : Input handling Part 4 : Game Components Part 5 : Animation and Sprites Part 6 : Handling Projectiles Part 7 : Sound Effects Part 8 : Setting Up Data In the previous post we prepared the data for the aliens and for the game levels. In this post, we’ll put that data to action. The first thing we’ll do is create a custom Alien class, that extends the Sprite class and adds some specific alien attributes. This...
תגים:, , , , ,
More Posts Next page »