Thursday 25 November 2010

How to convert Chm files to Pdf ?

How to convert chm files to pdf? So why do we need to convert chm file to pdf? The reason is that chm file actually takes long time to load. For example, if you have a text book in chm file format. It’s around 100MB in size then switching between pages takes a long time and sometimes there might be chance of locking up your system. So how to tackle this problem?


So here comes pdf file. Although there will be reduction in large pdf file and it will be definetly faster then chm file. If we convert chm file to pdf then it might work out and solve our problem. So how to go for it. Well you can visit this website called convert chm to pdf and read the tutorials. It’s very easy. So just convert your chm file into pdf and start reading and what ever you want to do.

Note: - For Linux user, there is a very simple tool called chm2pdf. You give it the file name and it spews out a close to perfect PDF.

If you come across better then the site I referred you then please share with us here. I will update it for my readers. It will be beneficial for all of us.

Saturday 20 November 2010

Why can’t we Create a Folder by name CON

While browsing through the orkut community, I came across the discussion that folder can’t be name as Con. Then I started googling about Con and got some cool solution to it.
Also read this amazing fact:-
An Indian discovered that nobody can’t create a FOLDER anywhere named as “con“. This is something pretty cool….and unbelievable . At Microsoft the whole Team, including Bill Gates, couldn’t answer why this happened!!!
Source-lists.evolt.org
I am sure that many people still don’t know that they can’t create a Con folder in windows XP and in some other Operating System.
So Why cannot we create a folder by a name Con? What’s the reason behind it?
It’s pretty simple, Con is a reserved name from the early days from DOS, it stands for the “CONSOLE” I/O device, Since it is already used by the system. If we create one with some evil tricks then the system will get confused. There will be an ambiguity.
Check out other reserved words to understand what are all the reserved words using which you can’t create folders in windows.
Like Con, many other reserve words are there which we can’t create. They are
PRN – It stands for printer.
AUX – It stands for Auxiliary device.
COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9 – They stands for serial ports.
LPT1, LPT2, PRN – They stands for Parallel ports.
NUL - It stands for Bid Bucket.
Did I said that the Con folder can’t be created, what a big typo. Well friends, There’s a evil trick to create a Con folder. Here goes the evil tricks.
Open the Command prompt by Start->Run and type in cmd
Type MD\\.\\C:\CON
C is the drive path, you can change this drive to your own choice of path.
Now Open My Computer and browse through the path where you created the Con folder. surprising huh!!! yeah buddy, you have successfully created a Con folder.
Now try to delete the folder, it won’t get deleted by simple delete option. Better try this:-
To delete the folder, type RD\\.C:\CON
Another method to create Con folder without the use of the Dos.
Create a new folder. Name it Con and press Alt + 255 simultaneously.
Well Alt+255 stands for a blank character in ASCII so it allows you to use this folder name.
Note:- Actually you’ll have to press the number’s of the number pad or else it won’t work. That is, create a new folder, rename it Con but don’t press enter yet. Hold down Alt and type 255 on the number pad and then press enter. (for laptop users, press Fn key and press the letter keys k-i-i to make use of number pad).
The next time when someone asks the question that why can’t we create a folder by name Con, say with confidence that it is not true…

Friday 5 November 2010

My First program using Jounce

This is the first program I wrote to see how much code I need to write and how hard to do simple data binding. Jeremy is doing getting started on Jounce in his blog. What I am doing here is related to his Jounce Part 2.  Here is the final result of the program

image

All this program does is to shows my name in the text box, nothing else. When i started the application I dreaded I will ended up writing lot of code or the process will be complex but to my surprise it is very easy. To make this work, make sure you head down to Code Plex and download the Jounce. We need following three dll from jounce and one from MEF (Which is already part of Framework 4).

Ok Lets start. Fire up VS 2010, create new Silverlight application. Add the above references into the project. Now we are going to add Jounce Framework in the XAML like the following

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="simplelabel.App"
             xmlns:Service="clr-namespace:Jounce.Framework.Services;assembly=Jounce.Framework"
             >
    <Application.ApplicationLifetimeObjects>
        <Service:ApplicationService />
    </Application.ApplicationLifetimeObjects>
    <Application.Resources>
    </Application.Resources>
</Application>

xmlns:Service is the reference to Jounce Framework. Next we add the Jounce to silverlight application lifetime object. Ok, lets start coding, lets go to  app.xaml.cs and remove everything except the InitializeComponent, so the code will look like the following

namespace simplelabel
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
        }       
    }
}

Simple huh? What is happenings here is that, since we interjected Jounce to the application life time object, Jounce does all the plumbing for us. Now that we have everything cleaned up in the app side, lets look at the view and view model. I left MainPage.XAML as our view. There is nothing special in here

<Grid x:Name="LayoutRoot" Background="White">
        <sdk:Label Height="28" HorizontalAlignment="Left" Margin="38,32,0,0" Name="label1" VerticalAlignment="Top" Width="47" Content="Name:" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="81,28,0,0" Name="textBox1" VerticalAlignment="Top" Width="235" Text="{Binding Name}" />
    </Grid>

I have one label and one textbox. In the text box, I am binding it to a variable called Name. Which will be discovered by silverlight when running. Lets look at the code behind of mainpage

namespace simplelabel
{
    using Jounce.Core.View;
    using System.ComponentModel.Composition;
    using Jounce.Core.ViewModel;

    [ExportAsView("Shell", IsShell=true)]
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        [Export]
        public ViewModelRoute Binding
        {
            get
            {
                ViewModelRoute route = ViewModelRoute.Create("Shell", "Shell");
                return route;
            }
        }       
    }
}

In this example code, I have one view and viewmodel. Since ‘MainPage’ is my view I need to decorate the view as ‘ExportAsView’ and for view model, decorate it with ‘ExportAsViewModel’. It has name, to bind view and viewmodel, the name must be same. We named the view as ‘Shell’ so make sure the mainpageviewmodel will have the same name as Shell as well. Also since Main page is the start up page for us, add IsShell=true.

Next the most important part, is making sure jounce know which viewmodel belongs to which view, by doing the viewmodel routing. Here we are binding view with name ‘Shell’ (Decorated in attribute ExportAsView) to view model with name ‘Shell’ (will see next). Make sure you decorate the property as [Export] so that jounce finds it.

Time to create view model by creating a class called MainPageViewModel.cs and add the following code

namespace simplelabel
{
    using Jounce.Core.ViewModel;
    using Jounce.Core.View;
    using System.ComponentModel.Composition;

    [ExportAsViewModel("Shell")]
    public class MainPageViewModel:BaseViewModel
    {
        public string Name
        {
            get
            {
                return "Kiran";
            }
        }
    }
}

First thing when we create view model, we make sure we tell Jounce which view it belongs to by decorating it with ‘ExportAsViewModel’ with a name. Next make sure the view model is derived from ‘BaseViewModel’. If you remember in the view, we bound ‘Name’ field to the text block which is coming from this view model. That is it. Now if you run the application, you will the screen shot I showed in the beginning.

I am still learning, long way to go…

Tuesday 2 November 2010

Jounce – First look

When it comes to Silverlight, one of my favorite blog is none other than Jeremy Likness (Silverlight MVP). I follow his blogs religiously for the simplicity and straight to the point. If you haven’t seen his blog and you are working on Silverlight, make sure you subscribe to his blog.

Couple of weeks ago, in one of his blog he explained he is on to create a new guidance called Jounce for creating silverlight application. I have been looking for a good solution my self was very happy to see the guidance. I downloaded the frame work started playing with it. I really like the frame work. It is very simple, less code and easy to understand. One other reason I like this very much is that, he leverages MEF for most of the application development and MEF is now part of .Net Framework 4.

I am learning how to use Jounce myself thought, I will share my simple examples with you so that we can learn together. In the codeplex, there is excellent documentation and also the download will give you good quick start examples as well.