Interns Rise2Power

Installing Umbraco from Web Platform Installer (WPI) or Microsoft WebMatrix

 

Hello Everyone,

Yesterday, Microsoft launched the new Microsoft WebMatrix an easy-to-learn Web Development Environment.

Some of you probably have followed the event and tried to install the latest version of Umbraco  CMS (released yesterday for Web Application Gallery (WAG)) from WebMatrix or WPI…

Some of you, maybe got this error, when trying to configure SQL Express Database on WebMatrix or WPI:

“Cannot Connect to the database “. Loging Failed for user <admin>

erro1

erro2

 

This happen, because when SQL Express is installed, it assumes that the authentication method to use is “Windows Authentication Mode” so it is using your Windows Credentials, and Umbraco installation apparently is not prepared for that.

To solve this problem you should change the authentication method used by SQL Express and create a password for “sa” user (system account) following this steps:

1. Search this Registry Key (regedit.exe):

“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQLServer”

2. Change the “LoginModeproperty to 2

3. Go to a Command Line (cmd.exe) and follow this commands:

   1:  sqlcmd -E -S .\SQLEXPRESS (will login with windows authentication mode)
   2:  1) ALTER LOGIN sa WITH PASSWORD = '<new_password>'
   3:  2) GO
   4:  1) ALTER LOGIN sa ENABLE
   5:  2) GO

4. Go to SQL Server Configuration Manager (Just type “SQL Configuration Manager” on Windows Vista/7 search program box.

5. On “SQL Server Services” select SQL Server(SQLEXPRESS) and Restart it.

image

 

 

After that just type ‘sa’ on Admin Database User and the password that you have typed on Admin Database Password, and everything should work!

If you have any questions/problems, please leave a comment or mail us at:

t-vapere [ at] microsoft.com

t-edserr[ at ] microsoft.com

Windows Phone 7 XNA Pong Game – Demo

Just like Eduardo, in the last weeks I’ve been on road, making a lot of demos and presenting Imagine Cup to Portuguese students.

Some days ago I had my first live demo of XNA for Windows Phone 7 and today I’m bringing the full source demoed on the floor, to make everyone able to try and start in XNA world in a easy way.

This little demo, is a simple pong game, with two Phone Specific features:

1. Accelerometer capability (loot at Paddle.cs)

2. CameraTask usage (Showing how can you take a picture and use it on your own gameSmile)

If you need any support, please send an email to: t-vapere[ at ]microsoft.com

Download it right here:

http://cid-eb144c315c7d31f8.office.live.com/self.aspx/Public/MyPong.rar

 

 

image

Windows Phone 7 Recorder

This week we went to Leiria and Braga to talk about the Imagine Cup 2011 at IPLeiria and UMinho and try to get students to participate in this year competition. Besides Imagine Cup, we also talked about XNA, Azure and Windows Phone 7. It was up to me to do a quick live demo to show people how easy it is to build an application for Windows phone 7.

I didn’t know what I should do, I only knew that it shouldn’t take me more than one hour to write the application live from scratch. I started thinking and finally got an idea: let’s create a recorder application! I didn’t have any previous experience with using the WP7 microphone nor creating sounds in run-time for playback but after some time alone with bing I found what I needed.

For the sake of simplicity I decided to build this quick demo using a Windows Phone Application Project, however I did show them that they could use Pivot and Panorama to create more visually appealing applications Winking smile . The problems I encountered while coding this demo were how to use the Microphone, because WP7 uses Silverlight 3 and this version doesn’t have support for Microphone, and then I had some trouble finding out how to create the sound for playback in runtime. To address the first problem I found out that you can use the XNA framework to access the WP7 microphone, however you have to trick the XNA framework reference into thinking that your application is a game instead of a Silverlight application or else it’ll crash. How do we do this? We create a fake game-loop by calling a method every X milliseconds. The solution I used is well described here http://cisforcoder.wordpress.com/2010/08/21/recording-audio-in-silverlight-on-windows-phone-7/ . To solve the second problem I used a class introduced in XNA Game Studio 4.0, the DynamicSoundEffectInstance class.

I’m pleased to say that I was able to live code this solution in a bit more than an hour while explaining what I was doing. Also I received some positive feedback from my demo so I was quite happy Smile .

Here are some screenshots of the application recording, playing and in iddle state (click on the images to see in full size):

 

DemoIddleDemoIddleMenuDemoPlayingDemoRec

 

In iddle state you can either record or play a previous recording, while recording the phone uses it’s mic to capture sound and the timer counts the time you’ve been recording, and while playing the recording is played back and the timer starts at the recording’s duration and counts back to zero. Instead of using buttons I also thought it would be nice to show them how to use the ApplicationBar.  The Application Bar is what you see in the bottom of the application holding the record and play buttons. It will show a description of the buttons and even a menu, if you choose to, that will offer more options to the user. In this case I didn’t use the menu option but added some description to the buttons. To see the description all the user needs to do is click on the 3 white spots at the top right corner of the application bar.

I’ve attached the code used in the live demo to this post. You can download it using the link at the end of the post! (If you’re not seeing any attached file it’s because you’re reading from the blog view and not the post, click on the post title to enter the post view and you’ll find the attached file at the bottom of the post)

See you!

Windows Phone 7 Accelerometer Kit

Hi fellow readers! These past few weeks have been busy. Between the traveling around the country to promote the Imagine Cup 2011 competition at the Universities (are you registered at Imagine Cup 2011? Help us realize the millennium goals at http://www.imaginecup.com/ ), the Sapo Codebits event at Pavilhão Atlântico, my thesis and some experiences with Windows Phone 7, the time has passed by rather quickly!

In the last post I mentioned some work I was doing for Windows Phone 7 (WP7) and finally, in the beginning of this month, I was able to release a working version of my accelerometer kit. Please feel free to go to http://wp7accelerometerkit.codeplex.com/ , download it and try it out yourselves. At codeplex’s documentation tab (http://wp7accelerometerkit.codeplex.com/documentation) or in the READ ME ALL.docx included in the project download, you can find all the necessary information you need to use this kit.

So how does it work? The kit is made of 3 major components:

1) A Console application (AccelerometerServer) : This console application hosts a WCF Service that will bridge all the projects on this solution. It provides a service that lets you retrieve and store information about the acceleration and rotation values for the Windows Phone.
2) A, Silverlight OOB (out of browser) application (ControlPanelOOB) : This application is not required for the toolkit to work properly. It's meant to be more of a debugging assist tool. It will easily let you read the acceleration and rotation values that the accelerometer is sending at all time. In future versions i hope to expand this so that it will have other helpful functionalities
3) A XNA Windows Game application (WP7XNAAccelerometerSimulator) : This has a model of a Windows Phone 7 and lets you rotate it as you wish. According to the position of the Windows Phone in this simulator, it will calculate the appropriate accelerometer values and send them to the server.

Besides these components there’s a a Windows Phone Class Library (AccelerometerWP7ClassLibrary) which is what you insert in the application you want to test the accelerometer behaviour.  This DLL provides a similar interface as the Accelerometer class in the Windows Phone 7 tools.

To use the Kit I’ve included a compiled version of the 3 components that you can easily run by executing a batch file in Administrator mode. It’s important that you run the batch file in Administrator mode (right click "Run as administrator”) or else the Console application won’t have the necessary priviliges to host a WCF Service and the kit will fail to start. I’ve also made it so that when you close the XNA app, it will close the other 2 components.

To use the DLL just add a reference to your project, browse to the DLL directory (I’ve included a compiled DLL in the download version at “Accelerometer Kit Application\AccelerometerSimulatorDLL”) and then you can use the simulator’s code as you would use the Accelerometer class from the Windows Phone 7 tools. You can even have code for both accelerometers so that you don’t have to change your code when running your application on the simulator or on the Phone itself by using #if statements as explained in the documentation.

To control Windows Phone orientation in the XNA simulator you can use the mouse or the arrow keys plus A and D Keys. To use the mouse you can drag horizontally or vertically over the orange sphere to pitch or roll the phone. Drag over the green torus, located above the orange sphere, to yaw the phone. These mouse controls aren't very good, they need to be improved so i advise you to use the keys to control the phone's orientation. The Left and Right arrow keys control the phone's pitch, the Up and Down arrow keys control the phone's roll, the A and D keys control the phone's yaw.

Here’s an image of the Control Panel and the XNA simulator (click on it to see full size):

AccelerometerKit

The Phone starts with the same orientation as the one in emulator which is standing on an horizontal surface with the screen facing up.

That’s it, I hope you find this Kit useful. Download it at http://wp7accelerometerkit.codeplex.com/ and leave any comments here or at Codeplex.

Super Mario game for Windows Phone 7

Hello everyone! Me and Vando have been really busy here at Microsoft lately and I’ve only managed to blog now. With Kinect and Windows Phone 7 coming out we’ve had lots of stuff to do. As you might have read in the previous post, we had to thoroughly test Kinect and prepare a presentation to be performed in several universities around the country during technological events. As of today we’ve showed Kinect at Instituto Superior Técnico (Tagus) and at Escola Superior de Gestão e Tecnologia de Leiria.

Besides Kinect we decided to create a XNA Workshop for Windows Phone 7 which was already given at the two universities previously mentioned and we hope to repeat it at more universities in order to share how amazing XNA and Windows Phone 7 are. For those you don’t know, XNA is a really easy to learn  and yet powerful technology for game developing. Just so you can get an idea, I had no game developing bases whatsoever and in about 5 days (6h-7h a day) I developed the game used at the workshops. It’s not a super looking cool story addictive gameplay style game, but I’m quite proud of my first game Smile.

I don’t know if you heard but  Super Mario Bros. was released on September 13, 1985 and so I decided to make a game based on Super Mario to honor its 25th anniversarySmile with tongue out. Since Vando has been working with XNA for about 2 years now, he was the speaker at both workshops and I helped him here and there to explain some bits and bytes of code as well as assisted the audience when needed. You can find the workshop’s contents here and check out the game yourself. The zip file contains the final Solution and a pdf file which is the guide for doing the game from scratch. I have to apologize here because the guide is in Portuguese and I didn’t have time to translate it to English, however the code of the final solution is completely documented in English and that should help you understand how the game works.

The game consists of a tap and score game in which you loose points for taping friendly Super Mario Characters, such as Luigi, Super Mario, Yoshi, and win points for taping enemy Super Mario Characters such as Bowser, Bullet, Lakitu. In addiction you win extra points for tapping Helper Characters such as Star and Mushroom. There are three ground levels, each with two warp pipes from which the characters warp in and out. At first a character is inside the warp pipe, the it peeks out a bit and then it decides whether to come out or go back in. You can only tap a character when it has decided to come out of the pipe and before it goes back in again, taping while peeking will count as a miss tap and you will loose points for it. You start the game with a double tap at the start menu, while playing you can do a pan down to pause the game and you can resume it with a pan up. While these might not be the best way to start/pause/resume a game, I decided to use this form of interaction so that at the workshops we could show the Gestures functionality that Windows Phone SDK provides us. Gestures are really easy to use and help create uniform interaction across games and applications.

Here are some screenshots Hot smile:

image

So this month we will still be very busy with lots of technological events in which we will attend and/or help organize. However my next post will probably be to show you an emulator toolkit I’m developing for the Windows Phone 7 which will aid Windows Phone 7 developers test their games and applications which use the accelerometer without having to deploy their game/application to a Windows Phone. I’ve seen one or two nice ways to help developers test the windows phone accelerometer but I believe I have a cool different approach. I’m struggling with some math but as soon as possible I’ll post a beta version here.Winking smile

Hope you enjoy the game!

P.S.- The zip file is a bit large because of the game sounds and images.

Experiencing Microsoft Kinect !!

Although this post is only being posted now, here DPE Interns are playing with Kinect since last monthSmile And yes, we’re loving it!

Lets start by showing you our Kinect place here at Microsoft Portugal:

 

kinect_ms_place

Oh Yes, I know what you are thinking : “Uuuh, what a lovely TV!!” Yap, that’s true, a Full HD 3D Samsung LED TV the best in the market and thinnest too, only 0.8cmSmile

But that’s OK, the king here is the Kinect and we are here to talk about it!

Let’s see, Kinect is a really valuable piece of Hardware and Software. We have a Beta version of some games showed at E3 and Gamescon and we are loving them!

One of the most interesting aspects of having Kinect before most of the  people in the world, is that it needs to have games installed as Demo Kits and people from E&D are mainly Marketers, so they asked me to help them mounting and installing Kinect on Xbox 360 Demo KitSmile with tongue out So kind of them, I loved it!

In the last month we’ve showed this system to a lot of Media and the attendees of a Video Game Conference, named Videojogos2010 (Portuguese name). At this conference we called some people to experience Kinect themselves and as we thought they got really amazed with it. I believe that only by experiencing Kinect in first hand can you realize the power and simplicity of this technology.

Let’s talk a little bit about the play experience of Kinect.

Well, the first thing that you realize, is that it really maps all your body to the game. Yeah, its not fake, every frame you’ve got a Skeleton updated to your body position. In this Beta version you can see some minimum lag but when you’re playing you won’t actually notice it. Besides i was told by some Kinect people that this lag will disappear on the final version Smile with tongue out

About seating, I’ve tried Kinect while seating and it continued to map your hands correctly. Obviously you can not be seated while playing games that need leg movement and i suspect that some games will pause when you try to do thatSmile with tongue out

The games we’ve tried were:

KinectAnimals, Kinect Joy Ride, Kinect Sports, Kinect Adventures and Dance Central.

The game i was most impressed by was Kinect Adventures, maybe because it’s the most polished one and it really handles the constant player switching very well. You literally have the opportunity to swap players as many times as you want without worrying about anything,  just appear in front of Kinect and within 3 seconds the new player will be recognized and integrated in the game…WOW!!!

Another thing that impressed me was seeing Childs playing Kinect, what an amazing experience. A little girl at the age of six was interacting with the baby tiger as normal as you could imagine. She was enjoying the game so much that she even cried when it was time to stop playing… amazing how we didn’t need to teach her how to play. I know that some games need more skill but KinectAnimals is really simple to understand, even for childrenSmile

Well, I think that’s all for today. Below i leave you the schedule for Kinect Events at Portugal for the next Month:

- 6/10 – ESTG – Leiria

- 12/10 – FEUP – Porto

- 25/10 – IST-TagusPark – Oeiras

- 26/10 – IST Alameda – Lisboa

- 27/10 – ISCTE – Lisboa

- 28/10 – FCT UNL – Costa da Caparica

- 29/10 – XNA Pizza Night – Microsoft

In all of this events people will have opportunity to take a ride with KinectSmile with tongue out Come and try, the more the merrier!

 

Here you have some videos of our Microsoft Student Partners playing Kinect!

alt
alt
Silverlight - Adding margins and navigation to the WrapPanel control : Part 2

Now that the easy part is out of the way let’s see how to add navigation to the WrapPanel. What we want to accomplish is being able to add, for example, 50 elements to the WrapPanel and have an option to go back and forth enabling us to see every element. Remember to download and open the Solution attached to this post so you can follow this tutorial properly. This Part is going to be a bit long but bear with me cause i'll explain the navigation logic as best as i can.

The main intervenients in the navigation process are the Fill, NextPage and PreviousPage methods, the Ready Event and the Content_Resized and FillWrapPanel EventHandlers. The logic is as follows:

Fill method: you use this to pass a List of elements of any Type that will be used to populate the WrapPanel along with the Size of the margin. For now ignore the third argument (it's an optional parameter). (Note – The first argument can be a List of any Type of Object constrained to UserControl Objects. This gives you lots of freedom and code reusability since you’re not limited to, for example, a List of my SimpleControl elements). 

NextPage method: this enables you to browse forward.

PreviousPage method: this enables you to browse backward.

Ready Event: this event is used to tell us when the WrapPanel has the conditions needed that will allow us to start adding elements to it. I’ll elaborate more on this later.

Content_Resized event handler: this handler is called whenever the application content is resized. We need this so that we can add or remove elements depending on the application’s new size.

FillWrapPanel event handler: this is the handler for the Ready event. When the Ready event is triggered, this handler will populate the WrapPanel.

The Fill method will set the MarginSize if it was provided with a valid marginSize, if not, it will use a (0,0) value for MarginSize (default value).  Then it will check if the WrapPanel is ready to be populated. If so we can populate it using the FillWrapPanel. If not, we add the FillWrapPanel as a subscriber to the Ready event so that it will execute when we trigger the Ready event.

I have been talking about knowing when the WrapPanel is ready to have elements added to it, but I haven’t explained what ready really means. The problem resides on the fact that UserControls don’t have a size before they’re “drawn”. When you use the ActualHeight and ActualWidth on a UserControl that hasn’t been “drawn”, it will return zero.  That is unfortunate since we need to know both the WrapPanel’s size as well as the element’s size so we can do some basic math and figure out how many elements fit in the WrapPanel (this math is done by the CalculateMaxItems method. This method will take into account the margins when calculating the maximum number of elements that can fit into the WrapPanel).

To work around this, we add an EventHandler to the Content.Resized event (see MyWrapPanel constructor). This event will trigger every time the application changes size. When this happens, the Content_Resized method checks if we can get the WrapPanel’s size. If that’s possible we set the IsReady property to true and trigger the Ready event which will then run the FillWrapPanel and populate the WrapPanel.  The !IsReady condition on the first if clause (on the Content_Resized method) is there because we only want to do this once when the WrapPanel is first “drawn”. In subsequent application resizes the WrapPanel has already been “drawn” and we can use the ActualHeight and ActualWidth methods to get its size. In other words, we know that the WrapPanel is ready and therefore we don’t need to trigger the event. All we need to do is populate the WrapPanel as the code in the second if clause shows.

Now let’s examine the FillWrapPanel method. What we need to do here is calculate how many items can fit into the WrapPanel and add them! It sounds easy and it is. The only problem here is getting the element’s size which suffers from the ActualWidth = ActualHeight = zero before the element is “drawn”.  The workaround here is to add one of the elements to the WrapPanel, force a layout update and the use the DesiredSize method to get the element’s size. Once this is done we clear the WrapPanel’s children and proceed with the logic stated above.

The final piece of the WrapPanel’s populating process is the AddItems method.  This method should be as easy as adding elements to the WrapPanel until we reach the limit given by CalculateMaxItems. However, since we want to add margins between elements, we need put some more logic into this. I think you can easily understand this method, it’s two for loops that will create the rows and columns of elements while letting us insert margins. The only thing I would like to refer here is the WPChildren property. This property maintains a count of how many elements we’ve added to the WrapPanel. We can’t use the Children.Count() method of the WrapPanel because of the margins we’ve added that we don’t care of as elements.  With this WPChildren (WrapPanelChildren) property we can now update de ItemIdx. The ItemIdx is the index of the first element being displayed in the WrapPanel. We update this index with the WPChildren property every time we browse forward or backward.

The NextPage and PreviousPage methods are quite simple too. All we need to do is update the index, clear the children and add more children. We just have to make sure we have more elements to add or that we reset the index to zero if it gets negative (which can happen if you change window size while browsing).

Remember the third argument in the Fill method? This argument indicates from which element you start displaying when you finish populating the WrapPanel. Why is this useful you ask? It’s true you might not need this (that’s why by default it’s zero, you can call this method with just the first two arguments) but it’s helpful, for example, to keep state. Do you remember the example of the radio station list I gave at the beginning? Imagine now that instead of a radio station you have a list of video channels and when you click on a video channel you repopulate your WrapPanel with a list of videos. Then when you click on a video it would open a link to it. In this example if you’re in, say page 3/5 of the video channels list, and you’ve chosen one of the video channels and then you want to go back to the video channels list, you want to show the user page 3/5 not page 1/5 right?  This is where the third argument comes in handy. It will let you specify the index so that the WrapPanel gets filled with all the video channel elements but starts showing at page 3/5 instead 1/5. All you need to do is retrieve the current index with ItemIdx property before refilling the WrapPanel with the video elements and then, when you want to go back to the video channels, just fill it using that index.

This concludes my tutorial on adding functionality to the WrapPanel.  Hope you’ve understood it and found it useful. If you have any question don't hesitate to ask!

Silverlight - Adding margins and navigation to the WrapPanel control : Part 1

In this post I’m going to show you how to add vertical and horizontal margins between child elements of the WrapPanel as well as how to add navigation to it.  Due to the size of the post i've divided it into two parts: adding margins is Part 1 and adding navigation is Part 2.  I’m assuming you have some knowledge with C# and some experience with Silverlight. In this post I won’t insert any pieces of code so I advise you to download the solution (attached to this post) and have it open while you’re following the tutorial for better understanding. All the code discussed in this tutorial is implemented in the MyWrapPanelControl.cs. Also, i've documented the code to ease your understanding Smile

Before we start you must have the Silverlight Toolkit installed, which will give you access to more controls, such as the WrapPanel. Go to http://silverlight.codeplex.com/ to download the toolkit.

For those of you who aren’t familiar with this control, the WrapPanel is an extension of the StackPanel, with the additional feature of wrapping content either vertically or horizontally (depending on the orientation you choose). Also, when you resize your application window, the WrapPanel will adjust its content showing more or less elements according to the available space. One thing I consider a problem with the WrapPanel is that it will clip the last row (with horizontal orientation) or the last column (with vertical orientation) if it doesn’t have enough space to display it (see Figure 1). We will correct this issue and I’ll explain how while talking about adding navigation (Part 2).

I’m going to use a horizontal orientation (default orientation) for the WrapPanel, however, after reading this tutorial (Part 1 and 2), you should be able to easily adapt the code to work with a vertical orientation.

For this tutorial I’ve created a simple UserControl named SimpleControl which consists of a black border around an Image and a TextBlock (you can see it in Figure 1). This SimpleControl will be the element with which we’re going to fill our WrapPanel. While in this example, for the sake of simplicity, the Image and the TextBlock of all SimpleControl elements will always have the same content, in a real example you would probably change the Image and TextBlock content’s depending on what you wish to accomplish. For example you could make a list of radio stations and each Image would have the logo of a station and the TextBlock would have the description. And when you click on a station you would open its page or start streaming it.

So let’s begin by talking about margins. Something that might be a problem when you’re using the WrapPanel is that when you’re adding elements to it, there’s no vertical nor horizontal spacing between them as shown in Figure 1. What will do to solve this is add Rectangles between elements to create our margins (see Figure 2 and Figure 3).

The two methods needed to make this work are AddHorizontalMargin and AddVerticalMargin. These methods are very simple, as you can see in the solution attached, and they will be called while we're adding elements to the WrapPanel so that the rectangles give us an ilusion of margins. The ItemSize property holds the size (width and height) for the child elements. It is set before filling the first screen of the WrapPanel and I will talk about it on Part 2. The MarginSize property defines the horizontal margin’s height and the vertical margin’s width. By default it’s (0,0).  With the help of Figure 3, I believe you can easily understand why the horizontal margin’s width is the same as the WrapPanel’s width and why the vertical margin’s height is the same as the element’s height.  The horizontal's margin height and the vertical's margin width are chosen by us when calling the Fill method (see Part2).

Figure 1 - Normal WrapPanel. No margins and showing the clipping issue. Sad

 

 

Figure 2 - WrapPanel with margins between elements and no clipping. Big Smile

 

Figure 3 - You can use the MarginDebug field (on the MyWrapPanel.cs) to enable or disable margin debug. If enabled, horizontal margins will be shown in red and vertical margins in green.

While Part 1 was very simple, Part2 will be more challenging. In part 2 i'll tell you how to add navigation to the WrapPanel and i'll also show you how to populate the WrapPanel with a collectin of any Type of elements. This means that the code will work whether you choose to populate the WrapPanel with a collection of objects from the MySimpleControl.cs or a collection of objects from any other class as long as it inherits from UserControl. 

Introduction

Hello everyone!

Me (Eduardo) and Vando decided to create a blog to share our experience during our interneship at Microsoft. Currently I'm working with Silverlight (http://www.silverlight.net/) and Vando is working with XNA (http://creators.xna.com/en-US/) . We both plan to make some work involving Windows Phone 7 (http://developer.windowsphone.com/) and, if things go well, I should be making my thesis around Windows Azure (http://www.microsoft.com/windowsazure/), so you should expect posts pertaining these tecnologies.

We hope you find our posts helpfull and easy to understand.

See you soon!