Archive for the ‘Programming’ Category

Notepad++ my Preferred Programming Notepad

June 13, 2011

If you have not tried Notepad++ in about a year, you will be surprised of how it has changed.

If you have not tried Notepad++ you should.  We here at 1-800-The-Nerd feel that it very rich in its ability to edit all types of documents.

Help system is very clear and its index is very nice.

Download it today and remember its FREE!

How To: Turning On or Off a Control with IsEnable and the “Not” Command

March 2, 2011

You can simplify the following VB.NET code snippet by using NOT instead of IIF

Code Snippet
  1.        DeleteButton.IsEnabled = IIf(DeleteButton.IsEnabled = True, False, True)

can be restated in a simplified syntax as

Code Snippet
  1. DeleteButton.IsEnabled = Not DeleteButton.IsEnabled

How to: Use UserControls in WPF XAML Windows

February 28, 2011

I created a UserControl called: “StatusBarControl” and it has a StatusBar contol with the following contols:  UserNameTextBlock, a  Lable for reporting progress, a ComboBox for displaying Styles of the form so the user can change them using the my.settings.UserStyle string,  and a StatusBar for showing progress. 

You first have to put in the header of the XAML Window the Following

In order to use a local UserControl you have to define the NameSpace of the Project that the Control resides in.

xmls:local=”clr-namespace:MyProjectWPF_GUI

Code Snippet
  1. <Window x:Class="MyProjectWindow"
  2.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
  3.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
  4.     WindowStartupLocation="CenterOwner"
  5.     ResizeMode="NoResize"
  6.     Title="My Project" Height="480" Width="647"
  7.       xmlns:local="clr-namespace:MyProjectWPF_GUI"  
  8.     Name="MyProject">

 

Next you create the UserControl as a UserControl in your project.  My UserContol is called “StatusBarControl”.  Then you assign it its local name.

<local:StatusBarControl x:Name=”StatusBarControl…  />

Code Snippet
  1.         <StackPanel VerticalAlignment="Top" Orientation="Horizontal" HorizontalAlignment="Left" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" Grid.RowSpan="2" Height="26" Margin="0,4,0,0" Name="StackPanel3" Width="526">
  2.             <Button Name="GetSmartIndexButton" Width="132" Height="23" ToolTip="You must get Smart Index Data before you can Submit to Mobius">Get Smart Index Data</Button>
  3.             <Button Name="ClearFieldsButton" Margin="3,0,0,0" Width="82" Height="23" ToolTip="Clears all Fields on this Tab.">Clear Fields</Button>
  4.             <Button Name="SubmitButton" Margin="3,0,0,0" Height="23" Width="116" ClickMode="Release" ToolTip="Submit the images to Mobius">Submit to Mobius</Button >
  5.         </StackPanel>
  6.             
  7.         <!–<Rating Height="100" HorizontalAlignment="Right" Margin="0,0,-285.057,-48.343" Name="Rating1" VerticalAlignment="Bottom" Width="200" xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" />–>
  8.         <local:StatusBarControl x:Name="StatusBarControl" HorizontalAlignment="Left" Grid.Row="3" Height="30" VerticalAlignment="Bottom" Grid.ColumnSpan="5" Width="655" Margin="-12,0,0,-5" />
  9.  
  10.     </Grid>
  11. </Window>

 

It reference the UserControl File called “StatusBarControl.xaml” under a directory “UserControls” in the Project “MyProjectWPF_GUI”

StatusBarControl.xaml

Code Snippet
  1. <UserControl x:Class="StatusBarControl"
  2.              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
  3.              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
  4.              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
  5.              xmlns:d="http://schemas.microsoft.com/expression/blend/2008&quot;
  6.              mc:Ignorable="d"
  7.              d:DesignHeight="25" d:DesignWidth="650">
  8.     <Grid Height="31" Width="609">
  9.         <Grid Height="25" VerticalAlignment="Top">
  10.             <StatusBar Height="25" Name="statusBar1" VerticalAlignment="Top" Margin="-20,0,-41,0" />
  11.             <Label Content="Progress" FlowDirection="RightToLeft" Margin="0,0,41,0" Name="ProgressLabel" HorizontalAlignment="Right" Width="390" Visibility="Hidden" Height="25" VerticalAlignment="Top" />
  12.             <!–</StackPanel>–>
  13.         </Grid>
  14.         <StackPanel Orientation="Horizontal" Height="25" Name="StackPanel1" Margin="0,1,433,0" VerticalAlignment="Top">
  15.             <ComboBox DataContext="{Binding}" Height="23" ItemsSource="{Binding}" Name="StylesComboBox" Text="Hello" Visibility="Collapsed" Width="121" />
  16.             <Label Content="User: " Height="24" Name="UserNameTextBlock" Width="50" />
  17.         </StackPanel>
  18.     </Grid>
  19. </UserControl>

 

To update/refresj  the “StatusBarControl” you will need the Application.DoEvents that is in the System.Windows.Forms NameSpace…  System.Windows.Forms.Application.DoEvents()

Code Snippet
  1.     'In order to get the following code to update the color and the cursor you have to call the System.Windows.Forms.Application.DoEvents()
  2.         Me.Background = New SolidColorBrush(My.Settings.WaitFormColor)
  3.         Me.Cursor = Cursors.Wait
  4.         'Application.DoEvents()
  5.         System.Windows.Forms.Application.DoEvents()

 

That is it.  If you have any Questions, please leave me a comment.

How To: Use Windows.Resources and Resource.Dictionary for Setting Default Styles for ToolTip and Button Controls

February 28, 2011

 

<Window.Resources/>

In the XAML file you are working on add the following code if the Resource.Dictionary is named StylesDictionary.xaml and is located in a root directory called Styles.  The Project name is called MyProjectWPF_GUI.

Code Snippet
  1.  
  2. <Window.Resources>
  3.     <ResourceDictionary>
  4.         <ResourceDictionary.MergedDictionaries>
  5.             <ResourceDictionary Source="pack://application:,,,/MYProjectWPF_GUI;component/Styles/StylesDictionary.xaml" />
  6.         </ResourceDictionary.MergedDictionaries>
  7.     </ResourceDictionary>
  8. </Window.Resources>

 

Note:

The Source  = pack://application:,,,/MyProjectWPF_GUI;component/Styles/StylesDictionary.xaml”

needs to have this “pack” syntax if you have a namespace declaration for “UserControls” like is used in this Window.

xmlns:local="clr-namespace:MyProjectWPF_GUI" 

The error at runtime will be: “Set property ‘System.Windows.ResourceDictionary.Source’ threw an exception.”

 

Otherwise if you do not declare a namespace for a “UserControl” then you can call it by

Source=”/Styles/StylesDictionary.xaml”

Code Snippet
  1. <Window x:Class="MobiusWindow"
  2.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
  3.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
  4.     WindowStartupLocation="CenterOwner"
  5.     ResizeMode="NoResize"
  6.     Title="Submit to Mobius" Height="480" Width="647"
  7.       xmlns:local="clr-namespace:MYProjectWPF_GUI"  
  8.     Name="MobiusWin">

 

<Resource.Dictionary/>

The Resource.Dictionary looks like the following.  Its filename is called StylesDictionary.xaml and is under a directory called Styles.

Code Snippet
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
  2.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
  3.  
  4.     <!– Default Button Style–>
  5.           <Style TargetType="Button">
  6.             <Setter Property="FontWeight" Value="Bold" />
  7.         </Style>
  8.     
  9.     <!– Default ToolTip tyle–>
  10.         <Style x:Key="{x:Type ToolTip}" TargetType="ToolTip">
  11.             <Setter Property="OverridesDefaultStyle" Value="true"/>
  12.             <Setter Property="HasDropShadow" Value="True"/>
  13.             <Setter Property="Template">
  14.                 <Setter.Value>
  15.                     <ControlTemplate TargetType="ToolTip">
  16.                         <Border CornerRadius="7" HorizontalAlignment="Center" VerticalAlignment="Top" Padding="5" BorderThickness="3,3,3,3">
  17.                             <Border.Background>
  18.                                 <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
  19.                                     <GradientStop Color="#CF181818" Offset="0"/>
  20.                                     <GradientStop Color="#BE1C1C1C" Offset="1"/>
  21.                                 </LinearGradientBrush>
  22.                             </Border.Background>
  23.                             <Border.BorderBrush>
  24.                                 <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
  25.                                     <GradientStop Color="#80FFFFFF" Offset="0"/>
  26.                                     <GradientStop Color="#7FFFFFFF" Offset="1"/>
  27.                                     <GradientStop Color="#FFFFF18D" Offset="0.344"/>
  28.                                     <GradientStop Color="#FFFFF4AB" Offset="0.647"/>
  29.                                 </LinearGradientBrush>
  30.                             </Border.BorderBrush>
  31.                             <StackPanel>
  32.                                 <TextBlock FontFamily="Tahoma" FontSize="11" Text="{TemplateBinding Content}" Foreground="#FFFFFFFF" />
  33.                             </StackPanel>
  34.                         </Border>
  35.                     </ControlTemplate>
  36.                 </Setter.Value>
  37.             </Setter>
  38.         </Style>
  39. </ResourceDictionary>

 

Good Luck

Picture Resizer 5.0 Application used in an “Right Click/Send” To Application

December 22, 2010

 

Batch Picture Resize

 

Advanced PhotoResize.exe settings

This is the area where I used the command line arguments to resize to a specific size of image. 

 

Example of C# code is:

s is the image location and name: 

Code Snippet
  1. OpenPhotoResize(@"-o " + "-cC:\\ResizedImages\\<PATH><NAME>.jpg " + s);

OpenPhotoResize method is:

f is the parameter that is passed to the PhotoResizer400

Code Snippet
  1. static void OpenPhotoResize(string f)
  2. {
  3.     ProcessStartInfo startInfo = new ProcessStartInfo();
  4.     startInfo.FileName = "C:\\PhotoResize400.exe";
  5.     startInfo.Arguments = f;
  6.     Process.Start(startInfo);
  7. }

Microsoft Enterprise Library 5.0 (MEL5) – Hands on Labs

December 20, 2010

Microsoft is offering the Microsoft Enterprise Library 5.0 (MEL5) – Hands on Labs.  This is to instruct you on the features and benefits of MEL5.

Learning by sharing blog has a great description of the features and benefits of the new Enterprise library.

Installation

Here is where you download it at:  http://www.microsoft.com/downloads/en/details.aspx?FamilyID=4f8cd377-5522-4f45-a024-44a6ca5111ec&displaylang=en 

It installs by default at:  C:\Documents and Settings\[username]\My Documents\Microsoft Enterprise Library 5.0 – Hands On Labs\

When you run the program to install the labs you get this screen.

image 

A great option in the install process is that it ask if you wish to install both VB.NET and C#.NET

image

 

List of the Hands on Labs it covers:

  • Caching Lab
  • Configuration Sources Lab
  • Cryptography Lab
  • Data Access Lab
  • Exception Handling Lab
  • Interception Lab
  • Security Lab
  • Unity Lab
  • Validation Lab

FREE Virtual CDRom Drive to Read ISO files from Microsoft

December 20, 2010

Virtual CDRom Control Panel is an application that Microsoft created so you could read the ISO files form a virtual CD.

This article discusses it:   Microsoft Virtual CD-ROM  Microsoft Windows  TechRepublic.com

Microsoft released Virtual CD-ROM Control Panel v2.0.1.1, a utility for Windows XP that allows you to create a virtual CD-ROM drive on your computer. This is especially helpful if you have a library of ISO images. If you are a Virtual PC fan, this utility will come in very handy considering you cannot use DVD ISO images within the Virtual PC software.

Let’s begin by downloading the software to a computer of your choice. This utility supports Windows XP Professional and Windows XP Home Edition. Next, extract the files to your %systemroot%system32\drivers folder and double-click the VcdControlTool.exe and click Driver Control. Click the Install Driver button and navigate to the %systemroot%system32\drivers folder and choose VcdRom.sys and click Open and Start and OK.

You are now ready to click Add drive in order to add a virtual drive letter. After you click Add Drive, the drive letter appears. Choose Mount to mount your ISO image to the virtual drive letter. You can now use the drive letter as if it is a physical CD-ROM device. When you are finished with the ISO image, choose Eject |Remove Drive | Driver Control| Stop | Remove Driver | OK

 

image

APP HUB – Windows Phone 7 app hub FAQ

December 13, 2010

Sign in at:  windows phone my apps

FAQ are at: App Hub – windows phone 7 – frequently asked questions

Check you status at: EUROPA site – Validation

App Hub: Develop for Windows Phone and Xbox 360

December 10, 2010

Great Video at: http://phone.microsoftplatformready.com/Default.aspx

This video describes the components needed to build apps for Browser, Phone, and Desktop

  1. Visual Studio
  2. Microsoft .NET
  3. Expression Blend 4
  4. Silverlight
  5. Browser, Phone, Desktop
  6. Cloud with Azure

Then if you replace Silverlight with XNA you get Phone, Desktop and Xbox

  1. Visual Studio
  2. Microsoft .NET
  3. Expression Blend 4
  4. XNA
  5. Phone, Desktop and Xbox

Expression Blend 4.0 Mockup Controls

December 2, 2010

Open Expression Blend 4.0 and go to Samples Tab and select the “MockupDemonstrations” item in the Samples list.

Once you have selected the “MockupDemonstrations” item in the Samples list you get the following screens.

The web resources for this is  in the following locations:

http://go.microsoft.com/fwlink/?LinkId=190841

http://expressionblend.codeplex.com

image

image

image

image

image

image

image