gwycon.com
Silverlight, WPF and C# .NET development
User NamePassword

PHP

12
Feb

Ok, so any self respecting site developing applications for the desktop and the web needs to be able to display code clearly. This means formatting it so it is laid out in a similar style to the code editor it was created in. So, mono-spaced font type and code highlighting is essential to making your code readable to others. Of course this doesn’t simply mean covering HTML and CSS languages to code highlight, and be assured that will be posting code snippets in a whole range of programming and scripting languages!

With this in mind we have implemented a system to highlight code written in many different programming languages. See below for a couple of quick examples:

Here is some formatted C# code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsFormsApplication22
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Hello World!");
        }
    }
}

Below is some more formatted code. This time XAML (XAML, or Extensible Application Markup Language, is the new mark-up language used in Microsoft’s WPF language).

This time no line numbers this time, so this gives us flexible options for displaying formatted code:

<window x:Class="WpfApplication6.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Window1" Height="300" Width="300">
  <grid>
    <textblock Text="Hello" Height="21" HorizontalAlignment="Stretch"
     Margin="10,10,0,0" Name="textBlock1" VerticalAlignment="Stretch"
     Width="120" Background="Coral" TextAlignment="Center" />
  </grid>
</window>

continue

Category : Misc | PHP | Programming | Blog