Emanuele Bartolesi

don't try this at home.
posts - 12, comments - 5, trackbacks - 0

My Links

News

View Emanuele Bartolesi's profile on LinkedIn

Emanuele Bartolesi

Create Your Badge

My status



Software tracking

Software tracking

hacker emblem

Twitter







Archives

Thursday, February 02, 2012

My favorites visual studio extensions

Visual Studio 2010 offers a collection of extensions that help the developer's life.
In this list I try to share some that I hope will help you as they have helped me.

Visual Studio Achievement Extension

This extension is less useful than the whole list, but one of my favorites.

NuGet Package Manager

This is a package management system for the platform. NET that simplifies the inclusion of third-party libraries in your projects. The included libraries are automatically updated.

Productivity Power Tools

The first extension that I installed on my dev machine. Sorriso

PowerCommands for Visual Studio 2010

This extension adds many features to the IDE.

VSCommands 2010

Navigation and generation code improvements.

Code Compare

With this extension you can compare code (in file and folder) very easily.

GhostDOC

I use this extension since many years and I can’t live without it. Sorriso
It creates XML documentation from comments.

 

If you found other interesting extensions, do not hesitate to contact me!

Posted On Thursday, February 02, 2012 9:18 PM | Feedback (0) |

Thursday, November 24, 2011

Open a popup window from Silverlight

Silverlight has a method called HtmlPage.PopupWindow() that opens new web browser window with a specific page.
You can find this method in the namespace System.Windows.Browser.
If you haven’t in your project, add a reference to System.Windows.Browser.

The method HtmlPage.PopupWindow() has three parameters:

  1. Uri – location to browse
  2. String – the target window
  3. HtmlPopupWindowOptions – a class with the window options (full list of properties http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpopupwindowoptions(v=vs.95).aspx)

For a security reason of Silverlight the call to HtmlPage.PopupWindow() is allowed through any user input like a button, hyperlink, etc.

The code is very simple:

            var options = new HtmlPopupWindowOptions {Left = 0, Top = 0, Width = 800, Height = 600};

            if (HtmlPage.IsPopupWindowAllowed)
                HtmlPage.PopupWindow(new Uri("http://geekswithblogs.net/"), "new", options);

The property IsPopupWindowAllowed is used to check whether the window is enabled to open popup.

Posted On Thursday, November 24, 2011 2:59 PM | Feedback (3) |

Add control to grid from code behind in Silverlight

In this post I show how you can easily add a control to a silverlight grid layout from code behind.
First you draw the grid in the xaml.

    <Grid x:Name="LayoutRoot" Background="Red"> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="20"> 
            </RowDefinition> 
        </Grid.RowDefinitions> 
        <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="300"> 
            </ColumnDefinition> 
        </Grid.ColumnDefinitions> 
    </Grid>

Now in the page constructor add the following code.

        public MainPage()
        {
            InitializeComponent();

            var myButton = new Button
            {
                Name = "btnOk",
                Content = "Ok",

            };

            myButton.SetValue(Grid.RowProperty, 1);
            myButton.SetValue(Grid.ColumnProperty, 1);
            myButton.Click += myButton_Click;

            LayoutRoot.Children.Add(myButton); 
        }

Also add the evento of the button.

        void myButton_Click(object sender, RoutedEventArgs e)
        {

        }

The code needs no comment because it’s very simple.
The only important thing is the method SetValue because it is used to set XAML attribute of element.

For a better understanding I have created an example that you can download from here.

Posted On Thursday, November 24, 2011 12:42 AM | Feedback (0) |

Monday, August 08, 2011

Create a custom control in a Lightswitch application

In many projects we need to show data in a complex way. For example graphs, table or more.
In the Lightswitch applications you can create custom controls in Silverlight and simply implement them.
In this article I want to show a small example of how to implement Silverlight slider control during data entry.

 

Create a new Lightswitch project.

1

Create new table.

2

Call the new table “ClassRoom” and insert the follow fields.

3

Add a new screen with the follow options.

5

Run the project and insert some example data.

6

Stop the debugging and insert a new screen with follow options.

4

After this, select File –> Add –> New Project, select a Silverlight Class Library type. Call it “SilverlightControlLibrary”.

7

Select the SilverlightControlLibrary project –> Add –> New Item and select Silverlight User Control.
Call it “SliderControl.xaml”.
In the SliderControl.xaml drag and drop the control “Slider” from Toolbox.

8

It appears like this.

9

In the xaml add this property to the slider properties.

Value="{Binding Screen.ClassRooms.SelectedItem.Age}"

Return to the “ClassRoomsListDetail” screen. Select “Rows Layout – Class Room Details”. Click Add –> New Custom Control. Appears a screen like this.

10

Click “Add Reference”. Click “Projects”, select “SilverlightControlLibrary” and click “Ok”.

11

Open the new reference and select “SliderControl”.

12

Press “F5” and run project. The new screen appears like this.

13

Now you can enjoy with Silverlight Custom Control into Lightswitch application. With this method you can create a thousand kind of controls. Sorriso
As always I include a sample project.

Posted On Monday, August 08, 2011 7:41 AM | Feedback (2) |

Sunday, July 31, 2011

Install Microsoft Visual Studio Lightswitch

My last love is called Microsoft Visual Studio Lightswitch.
After the official launch (26th of July) I installed the official release instantly.
The setup is very easy but I want to share my installation tutorial because Lightswitch was created for develop application easily and quickly way.
That’s why you can install it even though you are not a programmer.

First of all, mount the iso image of installation and launch the setup.
Accept the license.

Step1

Click customize.

Step2

Check if the path of Microsoft Visual Studio installation is right.

Step3
Click next and wait the finish of installation.

Step4

Click Launch.

Step5

When Visual Studio is started, choose New Project and select Lightswitch type of project.
Select your preferred language (I hope that is C# Sorriso )

Step6

When you see the follow screenshot, you can start to enjoy with Microsoft Visual Studio Lightswitch.

Step7

Posted On Sunday, July 31, 2011 9:43 PM | Feedback (0) |

Monday, July 11, 2011

Use IIS Express to debug an Asp.Net application

IIS Express is a lightweight, self-contained version of IIS optimized for developers.
It is installed when you install Visual Studio 2010 SP1 or you can install separately using Web Platform Installer.
Convert your application for using IIS Express is very simple.
You can right clicking on the project and select "Use IIS Express"

01


You can also access to this feature from Project Properties. Right click on the project, select "Properties" and then switch to tab "Web". Select "Use Local IIS Web server" and check "Use IIS Express".

02


If you want to use IIS Express in all new project, you go to Tools -> Options -> Projects and Solutions -> Web Projects and select "Use IIS Express for new file based web sites and projects".
The new projects will use IIS Express by default.

03

Posted On Monday, July 11, 2011 1:25 PM | Feedback (0) |

Thursday, June 30, 2011

Tracking Protection List in IE9

To protect the privacy when I surf over the internet, I use AdBlockPlus add-in for Firefox. But when I use Internet Explorer 9, this add-in don’t work.
Internet Explorer 9 (and I hope Internet Explorer 10) has built in feature to add a TPL. There is a javascript function to call named msAddTrackingProtectionList. This function has two parameter: the first one is the link of TPL and the second one is the Title of TPL.
To do this is very easy. Add this simple javascript function on your website or in a blank html page.

<a href="javascript:window.external.msAddTrackingProtectionList('http://easylist-msie.adblockplus.org/easyprivacy.tpl', 'EasyList Privacy')">EasyPrivacy TPL</a>

The effect is below:
EasyPrivacy TPL

After click appears a confirmation prompt.


For security reason this javascript function can only be called from a user interaction: buttons, links, forms.
For more information about msAddTrackingProtectionList function  go to Msdn Library.
For more information about EasyList go to Easy List TPL.

Posted On Thursday, June 30, 2011 11:21 AM | Feedback (0) |

Tuesday, June 14, 2011

Debug a Windows Phone application without using Zune

When you develop a Windows Phone 7 application you can debug it on emulator or on the device. If you use the device you must open the Zune software to connect to the phone. But with this method you can’t access to the hub and to media library.

The workaround is very simple.
Close Zune and from command line launch the WPConnect.exe that is located in C:\Program Files\Microsoft SDKs\Windows Phone\v7.0\Tools\WPConnect (64 bit operative system) or C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Tools\WPConnect. When you obtain the message “Connection established” you can debug the application on Windows Phone 7 without Zune.

wpconnect

Posted On Tuesday, June 14, 2011 5:28 PM | Feedback (0) |

Thursday, June 09, 2011

Run application under lock screen on Windows Phone 7

In the previous post I explained how to prevent the automatic lock screen of Windows Phone.
This feature is very good but it uses a lot of power. The workaround is to run the application under the lock screen.
Similar to UserIdleDetectionMode in the class PhoneApplicationService there is a property called ApplicationIdleDetectionMode. By default is set to Enable. When you set to Disabled the Windows Phone 7 doesn’t deactivate the application when the phone is locked and your application keep running.
Unlike with UserIdleDetectionMode when you set to Disabled it doesn’t re-enabled. Will be reset next time you restart the application.

Be careful because the Application Certification Requirements document (PDF) specifies the users must be able to configure this option from UI.

Posted On Thursday, June 09, 2011 3:34 PM | Feedback (0) |

Wednesday, June 01, 2011

Disable lock screen on Windows Phone 7

As everyone knows, Windows Phone 7 allows the execution of a single application developed by third parties to guarantee performance and resources needed to execute the application.
The process is terminated when the user exits by pressing the back button, the windows button and when you call task or chooser (see the relative articles), with some exceptions.

The process can also be closed after a period of inactivity (you can set this period in the Windows Phone 7 Settings).
Windows Phone 7 if it does not receive user input through touch or hardware buttons,the device locks the screen, turning it off and closing the running application.

However, there are applications that need to work even without that the user is working (web browser, document visualizer and much more) and it is therefore necessary to keep alive the screen. In this case there is a simple property to change called PhoneApplicationService.Current.UserIdleDetectionMode

As always I attach to the article an example that you can download here.

 

That’s all folks!!!

Posted On Wednesday, June 01, 2011 3:44 PM | Feedback (0) |

Powered by: