Copy / Paste from Visual Studio to HTML

Aug 23, 2008 at 3:32 PM
Edited Aug 23, 2008 at 3:59 PM
Judging by the message content I can see we all suffer through the process of copy/pasting our code into HTML sources,  I probably spend more time formatting then actually typing.  

I found an excellent Visual Studio add-in (works with VS2008) that does the job nicely and only took me a few minutes to install and run - the results...   I'll copy/paste some code that we have been using in one of CodeHulks messages.  Note: you can paste without line numbers - more HERE

1.  Ctrl - A
2.  Ctrl - C
2.  Ctrl - Shift - H
3.  Ctrl - V  (walla!)
[Edited]  4.  Had to edit line lengths so I didn't have wordwrap :)

    1 <Window x:Class="WpfApplication2.Window1"

    2  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    3  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    4  xmlns:local="clr-namespace:WpfApplication2" 

    5  Height="300"

    6  Width="300">

    7 <Grid>

    8     <Grid.RowDefinitions>

    9         <RowDefinition Height="75*"/>

   10         <RowDefinition Height="25*"/>

   11     </Grid.RowDefinitions>

   12     <ListView Grid.Row="0" x:Name="lstPersons"

   13             ItemsSource="{Binding Persons}" 

   14             IsSynchronizedWithCurrentItem="True">

   15         <ListView.ContextMenu>

   16             <ContextMenu>

   17                 <MenuItem x:Name="cmMenuItem"

   18                         Header="Retirement"

   19                         Command="{Binding

   20                         RetirementCommand}" />

   21             </ContextMenu>

   22         </ListView.ContextMenu>

   23         <ListView.View>

   24             <GridView>

   25                 <GridViewColumn Header="Name"

   26                 DisplayMemberBinding="{Binding Name}"/>

   27                 <GridViewColumn Header="Age"

   28                 DisplayMemberBinding="{Binding Age}"/>

   29             </GridView>

   30         </ListView.View>

   31     </ListView>

   32     <Button Grid.Row="1" Content="Click Me"

   33            Command="{Binding RetirementCommand}"

   34            CommandParameter="{Binding ElementName=lstPersons,

   35            Path=SelectedItem}"/>

   36 </Grid>

   37 </Window>

<!--EndFragment-->

 

 

   10     public partial class Window1 : Window

   11     {

   12         public ObservableCollection<Person>

   13             Persons { get; set; }

   14 

   15         public DelegateCommand<Person>

   16             RetirementCommand { get; set; }

   17 

   18         public Window1()

   19         {

   20             Persons = new ObservableCollection<Person>();

   21             Persons.Add(new Person() {

   22                 Name = "OleBob", Age = 73 });

   23             Persons.Add(new Person() {

   24                 Name = "OleLou", Age = 82 });

   25             Persons.Add(new Person() {

   26                 Name = "LilJohn", Age = 20 });

   27             Persons.Add(new Person() {

   28                 Name = "LilJames", Age = 32 });

   29 

   30             InitializeComponent();

   31 

   32             RetirementCommand =

   33                 new DelegateCommand<Person>(Execute, CanExecute);

   34             DataContext = this;

   35 

   36             lstPersons.SelectionChanged += delegate {

   37                 cmMenuItem.CommandParameter =

   38                     lstPersons.SelectedValue;

   39 

   40                 RetirementCommand.RaiseCanExecuteChanged();

   41             };

   42 

   43         }

   44 

   45         public void Execute(Person p)

   46         {

   47             MessageBox.Show(((Person)p).Name);

   48         }

   49 

   50         public bool CanExecute(object p)

   51         {

   52             if ((p != null) && (p is Person))

   53                 return ((Person)p).Age >= 65;

   54 

   55             return false;

   56         }

   57     }

   58 

   59     public class Person

   60     {

   61         public string Name { get; set; }

   62         public int Age { get; set; }

   63     }

   64 }

<!--EndFragment-->