Wednesday, April 20, 2011

Silverlight 5 : Improvements in Text

I hope you must have installed Silverlight 5 Beta bits on your machine and wondering what’s new you got in those bits.Well, there are lots of new things hidden inside which are worth exploring.I am doing the same with equal passion and enthusiasm.

Today in this little blog post I am going to talk about some smart improvements for Text.

Character Spacing :

CharacterSpacing is a property of type Integer (System.Int32),If you refer official Silverlight 5 documentation,you will find the definition of CharacterSpacing as :

Gets or sets the distance between characters of text in the control measured in 1000ths of the font size

Let me add some more information here as well since we are talking about stuff from Document. For those who are new to Silverlight 5 documentation you will see following icon :

txticon

In front of many properties you will see such icons, well left side of the icon represents the property as Public property and right side of the icon represents that the property is supported by Silverlight on Windows Phone. Well,coming back to the topic, I hope you got the idea what CharacterSpacing does for you. Its basically help you to manage and have full control over character space of your text in your Silverlight application. Here is how it looks like :

TextImprove1

You can see how the Text gets compressed and expand on varying the CharacterSpacing. Here is a piece of XAML which you can play and checkout how exactly it will look in your application when you implement CharacterSpacing.

XAML :

<Grid.RowDefinitions>
            <RowDefinition Height="20"/>
            <RowDefinition Height="20"/>
</Grid.RowDefinitions>
<TextBlock FontSize="12" x:Name="myTxt" Grid.Row="0" >
            Silverlight हे सर्व वेब-ब्राउजर वर चालणारे Plug-in आहे, तसेच हे विविध Operating Systems वर ही वापरता येते.
</TextBlock>
<Slider x:Name="mySlide" Grid.Row="1" Maximum="400" Minimum="-400" SmallChange="50" ValueChanged="mySlide_ValueChanged" />

C# Code :

private void mySlide_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
    myTxt.CharacterSpacing = Convert.ToInt32(mySlide.Value);
}

Note : CharacterSpacing property can be set from XAML as well.

..and here is the output :

txt1

txt2

txt3

In each of the output shot you can see how the character spacing varies and thus gives you full control over text in your Silverlight 5 Application.Well how you are going to use in your business scenario it upto you only.

RichTextBoxOverflow,Multi-column and Linked text :

Many times we see that inside application for TextBoxes or RichTextBoxes we have massive scrollers since the content is big and there is no facility to handle overflow of the content in the given Text container. So if you see our normal Multicolumn magzines, its sometimes becomes difficult to put Text in that Multicolumn magazine kind of fashion since its difficult to manage flow of text.

With Silverlight 5 you can create wonders, All you need is to set OverflowContentTarget Property and you will be able to handle all linked,multicolumn text without any much heavy efforts.The official Silverlight 5 documentation describes OverflowContentTarge as :

Gets or sets the RichTextBoxOverflow that will consume the overflow content of this RichTextBox.

Let me show you this via piece of XAML here :

<StackPanel Width="400">
        <RichTextBox x:Name="MasterRTB" Width="300" Height="50" OverflowContentTarget="{Binding ElementName='overflowContainer'}">
            <Paragraph>
                    Silverlight हे सर्व वेब-ब्राउजर वर चालणारे Plug-in आहे, तसेच हे विविध Operating Systems वर ही वापरता येते, गेली अनेक वर्षे Microsoft ASP.NET च्या मदतीने आपण अनेक प्रकारचे प्रकल्प कार्यान्वित करत आलो आहोत, काही वर्षांपूर्वी त्याला AJAX ने ही चांगलाच हातभार लावला आहे, आता त्याच धर्तीवर Microsoft आपल्याला Silverlight बरोबर एक पाउल पुढे नेत आहे.
             </Paragraph>
        </RichTextBox>
<RichTextBoxOverflow x:Name="overflowContainer"/>
</StackPanel>

As you can see that I have big chunk of data in <Paragraph> tag and if I look at Dimensions of RichTextBox, there is a fear that either I will loose some of my Text just because it will not fit in or I need to put scrollbar and other stuff. Instead of that now what we can do in this particular example is to add one more control <RichTextBoxOverflow> (You can have multiple RichTextBoxOverflow Controls or even you might want to form chain of those controls which is possible) and set OverflowContentTarget of the base Rich Text box. This will point at where your extra overflow Text should go and then it will flow freely in another text container. Hence with such implementations you can achieve Multicolumn text requirements as well. Here is a small output of above XAML where you can clearly see how text is flowing smoothly across those Rich Text containers.

RTFM

Well, I hope you got these two small features introduced in Silverlight 5 Beta. With this you can move ahead and create PoCs where you can test the capability and power of these features with high design quality keeping in mind. With this I end this post here and by the time you finish exploring this feature I will be back with more new features of Silverlight 5. In coming articles we will also discuss the pain points of each features and how we can address those issues. So see you very soon !

Vikram.

Thursday, April 14, 2011

Silverlight 5 : A step ahead from Microsoft

Hello folks, Hope you all had fun at Mix 11 keynote online/offline. Well almost 10+ hours back Scott Gu announced availability of Silverlight 5 Bits for Public which was formally announced earlier. I have composed few post last night, Just giving final touches, till the time I want you people to get sync with me by downloading Silverlight 5 bits so that we can enjoy it together !

silverlight

What Should be your First Step ? :

Download Silverlight Bits,Videos and necessary documentation from here :

http://www.silverlight.net/getstarted/silverlight-5-beta/

Should I migrate my Silverlight 3/4 Apps to Silverlight 5 ? :

I personally will not recommend that. Silverlight 5 is in Beta right now,so its better to create some smart PoCs and test it out inside out then you can have migration plan in place.

Will these bits will cause trouble to my current Silverlight/WP7/Expression setup ? :

You can run these new bits can parallel without tampering anything from earlier installations. Installations are smooth and straight forward, No complex steps involved.There is a Runtime for Mac OS is made available, check on the link I mentioned above.

What should I have as pre-requisite to go ahead with Silverlight 5 ? :

From tooling perspective, You need to have Visual Studio 2010 SP1,If you don’t have that, please get it today from Microsoft site. Beside that if you know XAML and C# fair enough, it will be smooth learning for those who are going to learn Silverlight 5,I mean to say fresh people to Silverlight Technology.

Silverlight is Core platform for Windows Phone 7, So with this Silverlight 5 anything got added to Windows Phone 7 toolkit ? :

What Microsoft released yesterday was totally to do with Web and OOB Silverlight, There were several announcements made by Microsoft for Windows Phone 7 including Mango update,but this bits have nothing directly to do with that. I will let you know about that in a separate post later.

What am I going to see here on this Blog in coming days ? :

Tons of good stuff including Silverlight 5,Windows Phone 7 and Silverlight 5 + Some third party stuff (Remember my Balder post for Windows Phone 7,Some more coming on the same line).

I will initially going to take a stab at new Silverlight 5 features and then I will take them each one deep dive like I try to do always.

So download bits today from :

http://www.silverlight.net/getstarted/silverlight-5-beta/

..and stay tune for my next post coming up.

Future is Bright .. Future is Silverlight !

Vikram.

Monday, March 21, 2011

3D on Windows Phone 7 using Balder

This is not my first time to talk on 3D on Silverlight or Phone platform,In past I wrote decent amount of stuff including Kit3D,3D in Silverlight and recently I wrote 3D on Windows Phone 7 using capabilities of Silverlight framework sitting inside phone.

While surfing I came across this wonderful 3D engine for Silverlight and amazed to know that it is also available for Windows Phone 7. As usual I went ahead to try this out and as our blog’s tradition, whatever I explore I share with you people,so today I am going to do the same. Note here that,its 3rd Party and I do not have expertise over this 3D engine,so if you plan to use this for your apps in production environment for Silverlight or apps for Marketplace for Windows Phone 7, I advice you to spend more time with the bits and just don’t blindly follow.Most of the source code here what I am sharing is mostly from predefined Balder samples as I told this is very new to me as well.

You can check more on Balder at their Codeplex home :

http://balder.codeplex.com/

Once you download those Balder Bits for Windows Phone 7,you need to refer them like this :

RefBalder

ReferBalder

Note that once you start coding your XAML for Balder, Make sure you exclusively work in Code windows that having mix of design and code,why? Simple answer is with the current bits of Balder, it does not allow you to see/edit for that matter in your designer like this i.e No Design time support :

DesignerBalder

So if you see such screen like above, No need to get panic, this is normal for Balder,So even if designer not working,Code does work.So do not get panic and close project even if you see some design time errors in error list, just ignore them.

Like we have layouts like Grid, Balder provides Render layout with Balder.Execution namespace and we can add various shapes by Balder.Geometrics namespace which by default provides some basic shapes like ring and box which I am going to demonstrate here. Also it supports animation and light effects, Remember the lights from 3D Max? Omnilights etc? well, those are supported here and we can adjust them programmatically as well from code behind, Setting “x:Name” attribute will allow you to play with them via C# code.

You can associate namespace like this :

xmlns:Execution="clr-namespace:Balder.Execution;assembly=Balder"
    xmlns:Geometries="clr-namespace:Balder.Objects.Geometries;assembly=Balder"

You can simply add Ring or Box like this :

<Geometries:Box x:Name="MyBox" Dimension="5,5,5">

<Geometries:Ring x:Name="Ring"
                             Size="8"
                             Segments="30"
                             InnerRadius="6"
                             OuterRadius="8"/>

You can do further Material settings to Box like this :

<Geometries:Box.Material>
                        <Material:Material Ambient="Black" Diffuse="Green" Specular="White" Shade="Gouraud" />                                                   
                    </Geometries:Box.Material>

In Balder’s online demos, they have also added Images on Cube’s surface which you can check with more examples here :

http://www.ingebrigtsen.info/Balder/SampleBrowser/TestPage.html

Once you hit F5 you can see output like this :

BoxBalder          RingBalder

 

You can add your own background to make it more real like this :

finalBalder

With Timer, you can control camera from code behind like this :

void timer_Tick(object sender, EventArgs e)
{

           MyCamera.Position.X = x;
           MyCamera.Position.Z = z;
           MyCamera.Position.Y = y;
}

Here x,y,z you can set with Sin,Cos functions under System.Math so as to achieve various angles across space.In the exact same way you can use all above code base to your Silverlight application however bits for Silverlight (dlls of Balder) are different.But the same approach can be carried out for Silverlight.This is what I like most about Balder.I have uploaded a small video on this like how Balder output looks on Emulator once you have Animation+Objects+Lights in place,check this out :

3D on Windows Phone 7 using Balder

What I have shown I know is very basic,but this will be a good start to you to dig more into Balder. Balder is very much powerful and have lot of potential, I am in process of creating much more interesting stuff with it,but right now I can only share this much with you,I will be back with much more stuff as on when I make progress in the same.

So take out some time and give a try today to Balder :

http://balder.codeplex.com/

I know few of folks use XNA to create all these and may find it friendly but I want you to try this also,its worth exploring for sure.

Following result I get for above example which I am sharing with you,I am not sure about results what I got meet any kind of benchmark or not,nor I am much bother about at the moment,but here are some facts and figures for above Ring and Box 3D example :

Render Thread FPS (Average)

023-025
User Interface Thread FPS (Average) 024
Texture memory usage (Constant) 002656
Surface counter (Constant) 001
Intermediate texture count (Constant) 001
Screen Fill Rate (Constant) 00.8835

I hope you will give a try to Balder today,meanwhile I will finish up some interesting stuff and get back to you,stay tuned,soon I will be start talking on Silverlight.

Vikram.

Tuesday, February 22, 2011

First Windows Phone 7 update February 2011 - Small update but Big start

After tons of rumors and set of predictions on Windows Phone 7 all over Internet, Microsoft came up with first Windows Phone 7 minor update today and it working seamlessly (Not like those “Fear” updates when you don’t know what will happen to your PC when it restarts ! ) along with Zune software from where you get that update.

What’s this update all about ? : (via Windows Phone Blog)

This first update for Windows Phone is designed to improve the software update process itself. So while it might not sound exciting, it’s still important because it’s paving the way for all future goodie-filled updates to your phone, such as copy and paste or improved Marketplace search.

In the future, I encourage you to check out our new update history page on the Windows Phone website for a brief, plain-English summary of what each update does or what features it adds to your phone.

 

We made some improvements to the way we deliver software updates to ensure that the process keeps working smoothly for you.

Why I say Small Update but Big start :

People going crazy over Mobile devices and Tabs especially after recent Dual Core mobile and HTC Tab announcements, War seems to be very big and long time ! There are also sad news about Steve Jobs ( I wish him speedy recovery and wish to see him on stage with brand new version of iPhone, great man ! )

There are so many things getting said about success of Windows Phone 7 (Still white elephant in Asia) but today Microsoft did a brave job by throwing updates to WP7 owners across the globes.

This update is small software update but for those who think Microsoft is just making announcements, Nope ! they are now actually started changing the game and today’s update was first move ! Wait for more updates, WP7 going to shake the world for sure ..after all its Microsoft :) 

Congratulations to Windows Phone 7 Team at Microsoft !

Updates are available.. Really? :

If you are WP7 owner, Check your settings tab and see the phone updates,you should have following on your actual phone

P1010252

How do I Install ? :

Microsoft given a step-by-step guide that you just need to (blindly) follow here :

http://www.microsoft.com/windowsphone/en-us/howto/wp7/basics/how-do-i-update-my-phone-software.aspx

Once you plug your phone to PC you will see following screen in Zune :

NoDo

Now just click on Update Now and sit back and relax ! Make sure you do not make any calls during this and also do not remove connectivity of device with PC,It will start throwing updates like this :

On phone it will look like :

P1010256

On Zune it will look like :

NoDo1

On your device it will look like this with a progress bar :

P1010257

It will do reboot your Phone (Not PC !, Thanks for that !!) and finally you can have beer if you see screen below (else throw the same beer bottle on phone and PC !) :

NoDo3

Done ! ..so our First update on Windows Phone 7 is success !

I will come back soon with more stuff on Silverlight (Yes ! soon I will be posting few Silverlight things but after some time) and Windows Phone 7, so stay tuned !

Vikram.

Friday, February 11, 2011

Nokia and Microsoft : Connecting People with Windows Phone 7 .. Really ?

Today’s announcement made about Nokia and Microsoft created lot of buzz all over internet. Some people calling it as smart move,Some are saying that Microsoft helped Nokia from sinking down.Really? 

What is the future looks like ?

Nokia7

Picture taken from : http://www.wired.com/images_blogs/gadgetlab/2011/02/3310wp7.jpg

Sweets for Asia ? :

Where ultramodern devices with 3G floating across US and Europe, Countries like India still in waiting mode for 3G (We recently had big 2G scam that’s a different story), Windows Phone 7 is still White Elephant in countries like India where we still have no clue about Marketplace and I am sure with today’s announcement we think situation will be relax now and soon something will work for we Indians (Claim to be biggest Offshore Development Hub in world and 2nd largest Microsoft Development Center is in India). You check or ask any Indian common man,what phone/device he/she got? Answer is Nokia ! So will today’s announcement is to attract more people from here where Phone users by numbers touching billion marks. So will it create big business for Microsoft and Nokia from Asia? Well, this is my guess, Business Analysts will have better views over me.

Symbian, Silverlight on S60 .. R.I.P ?

After Windows Mobile 6.x and Sky size success of iPhone and Android,Microsoft decided to change the equation and kept a vision where XBOX,Zune and Cloud will play with each other on one common mobile platform and hence there was birth of Windows Phone 7 having Silverlight as core platform for development.

I personally never saw any around me doing apps with Silverlight for S60 or running Silverlight Apps on S60,I never saw any technical session in any of the Microsoft events in India or community talks for Silverlight on S60.So what happen to that? Is it dead (unofficially?)

Symbian

http://www.silverlight.net/getstarted/devices/symbian/ for more information.

What still makes this page to be there that is something personally I don’t understand !

Will Nokia sell its devices with Symbian in future? or they will force customers for Windows Phone 7 is a big question.

Ok ! Application Market ?

Mobile without apps is like Car without wheel ! so what Symbian apps developers will plan for now? Nokia fans only can tell you this.Apple is clear winner here and even Android.Check this blogpost which is loud and clear !

Is Nokia going Samsung way? Samsung is with their Bada and also having WP7 device,So Nokia have something similar in mind? well coming future only can answer that !

Who is Jackpot Winner ?

Application Developers !

slots-winners

Tons of Apps and Millions of Users if it works out on Nokia, So there will be hell lot of development will happen (what they are saying as “burning platform”), More downloads will generate more money. Current Windows Phone 7 Developers will be easily jumping to Nokia devices.So this is very positive sign !

Microsoft’s amazing and growing Windows Phone 7 software platform and Nokia’s infrastructure will in future surely going to change equations of Mobility and business.

Future :

If Windows Phone 7 fills all the gaps as a platform if we compare to Windows Mobile 6.x and if Nokia manage to put this platform on Jazzy and low cost devices, Microsoft is winner at end of the day !

My 0.02 $ :

Learn Silverlight ! Read this announcement again :

http://www.microsoft.com/presspass/press/2011/feb11/02-11partnership.mspx

Check out what and how much you can earn from this ! Worry about your profit and loss and not profit and loss of Nokia and Microsoft. Let them take care of that, You focus on apps ! :)

Well, with this I am soon coming back with much more stuff on Windows Phone 7 and Silverlight.See you soon !

Vikram.

Sunday, February 6, 2011

Silverlight On Mobile : Copy and Paste functionality inside Windows Phone 7 Emulator

Already lot of discussions and forum threads heated up with the Copy and Paste support for Windows Phone 7 Actual Device. Few statements made the news all over the world like “Who needs Copy and Paste”,”iPhone took x amount of time and WP7 doing in y amount of time”,”we need it else what we will do on MS Office on WP7” etc and similar others.

You must have seen my last post titled as “White Elephant”,I am still suffering a lot and still my HTC HD7 is just another mobile phone since I still not have Marketplace here in India.My Live ID is also India based so doors are closed for me.Well, I am ready to wait and suffer from pain since this is not first time for me. Every other good things take hell lot of time to come to India.We say here that when Western world tag something as “outdated” we said its “new,hot and happening”.

Coming back to topic.Today after a long I got some free time to spend over my routine and finally I installed the

Windows Phone Developer Tools January 2011 Update (Download)

What it contains?

  • Windows Phone Emulator Update – Exposes copy/paste functionality in the Windows Phone 7 emulator
  • Windows Phone Developer Resources Update – Fixes a text selection bug in pivot and panorama controls.
  • Windows Phone Capability Detection Tool – Detects the phone capabilities used by your application.
  • Windows Phone Connect Tool – Allows you to connect your phone to a PC when Zune® software is not running and debug applications that use media APIs.
  • Updated Bing Maps Silverlight Control – Includes improvements to gesture performance when using Bing™ Maps Silverlight® Control.

What I am talking about now?

Windows Phone Emulator Update exposed copy/paste function inside our Windows Phone 7 Emulator.

Why I need that?

Currently,we do not have Copy Paste inside Emulator. Life becomes easy in Apps so as not to type same things multiple times. Copy/Paste is useful in such scenarios.Common examples can be while drafting SMS or working with MS Word on Mobile or typing Name,Address etc.

Ohh No! already submitted my App to Marketplace,what should I do now??

Answer from Release Notes :

Most applications already published to the Windows Phone Marketplace do not need to be recompiled to take advantage of copy and paste functionality. Copy and paste will work automatically for end users after they receive the corresponding update to the operating system.

Word of Caution ! (via Release Notes)

In applications that have pivot or panorama controls that contain text boxes, users can unintentionally change panes when trying to copy text. To prevent this problem, open your application, recompile it, and then resubmit it to the Windows Phone Marketplace.

Here are few bytes of Snaps how it will look like :

CopyWP7PasteWP7

There is no great code for this ! It’s a built in functionality. To demonstrate more clearly, I have today uploaded on small video (I took video by our own Microsoft product – Expression Screen Capture utility),Check this Video you will get more idea about Copy/Paste functionality inside Emulator.

Copy/Paste functionality on Windows Phone 7 Emulator

So, As per Release Notes,It suppose to work on :

  • System.Windows.Controls.TextBox

  • System.Windows.Controls.PasswordBox

  • Text input fields within the Microsoft.Phone.Controls.WebBrowser control.

You may have question about API or something like,Can we restrict User to use from Copy/Paste?, Well for all these types of questions,I am giving you to take control and explore ahead.

I hope this quick and small post will be helpful for you and turn out to be informative.Stay tuned ! much more on Windows Phone 7 and Silverlight is coming on your way.

Vikram.

Silverlight On Mobile : Using Bing Maps in your Windows Phone 7 Application

Few months back, I wrote one article on Integrating Bing Maps in Silverlight Application. Today on the same base I am putting my thoughts for Bing Maps on Windows Phone 7 in a very short demo. The way you integrate your Bing Maps in Silverlight Application and over here is almost same since platform for both is Silverlight. You need Key for Bing Maps and API in place so as to make things easy for you, You can refer my old article here.

For Windows Phone 7, Make sure you add reference to Microsoft.Phone.Controls.Maps like this :

Bing4

Then next step is to add Id in App.xaml file (Refer my old post,you will come to know where to get that Big long Id from) like this :

Bing5You need to add reference for the same in your MainPage.xaml file like this :

Bing6

Then just add BingMaps to content panel and you are ready !

Bing7

It will look like this on your emulator :

Bing3

If you want to provide more options like Zooming In and out you can put the same in App Bar like this :

Bing2

You can use ZoomLevel property which is of type double to play with Zooming capabilities.You can also add pushpin to put specific location on map using PushPin class like this :

pushpin.Content = "My Home";
pushpin.FontSize = 30;
BingMaps.Children.Add(pushpin);


Well, for setting exact location you need to take help of Location class.Both Location and PushPin you need Microsoft.Phone.Controls.Maps namespace which we have added as reference to our project.You can put Lat-Lon like this :


local.Latitude = 18.31;
local.Longitude = 73.55;


You can then see output like this :


Bing1


This is how you can integrate Bing Maps to your Windows Phone 7 application. I know this is very basic but this is first step for advance Map related apps,We will soon further discuss more aspects like Location based Apps and Services,GPS etc. I hope this small tutorial will help you to add Maps in your current ongoing Windows Phone 7 apps if there is a requirement of the same.Stay tuned ! more useful short and long articles coming on Windows Phone 7 and Silverlight together.



Vikram.