Showing posts with label Live Writer. Show all posts
Showing posts with label Live Writer. Show all posts

Friday, 13 August 2010

Live Writer Source code highlighter plugins test (Плагін для підсвітки коду в Live Writer)

Перш за все хочу сказати про нововведення в моєму блозі, це те що можна замітити в шапці, а саме імя посту на англійській мові. Зроблено це для пошукової оптимізації, з метою збільшення кількості відвідувачів, атже більшість людей шукають інформацю технічоного характеру на англійській мові.

INTRO

Все почалось з того що в твітері наткнувся на повідомлення Дениса Резника про те що він шукає собі плагін для підсвітки коду у Live Writer-і. До цього я ніколи не користувався подібними програмами отож вирішив спробувати. Скажу чесно сподобалось мені в ній не все, але писати та оформляти пости стало набагато легше. В певний момент я зіткнувся з тою ж проблемою що й денис, поставивши декілька плагінів для підсвітки коду я не отримав бажаного результату доки не наткнувся на … ) а це ми зараз і попробуємо вияснити, провівши невелике тестування плагінів для підсвітки коду!

Let’s start!

Кандидати:

Заінстальовані плагіни добавляться вам до списку зправа та в меню “Insert”, виглядають вони наступним чином :

Снимок

На палароїд піксер і снаджіт, увагу не звертаємо )

 

Отож переходимо безпосередньо до тестування, яке проходитиму в нас наступним чином, спочатку ми протестуємо відображення xaml а потім C#. Фрагменти будуть однакові. При можливості додаткових опцій які можуть покращити вигляд коду вони будуть увімкнені.

Paste Code

Судячи з інтерфесу цей плагін передбачає додаткове налаштування на блозі і код який він нам вставив в блог по змовчуванню був без кольорової схеми.

Безымянный

xaml:

 

<UserControl x:Class="Allscripts.Common.UI.UserControls.UCBrowsableTextBox" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="browsableGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="350" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<TextBox Name="brTextBox" Grid.Column="0" IsReadOnly="True" Margin="0,0,20,0" FocusVisualStyle="{x:Null}" TabIndex="0" Focusable="True" />

<Button Name="btnBrowseImportFilePath" Grid.Column="1" Content="Browse" TabIndex="2" BorderThickness="2" FontSize="13" HorizontalAlignment="Left" Height="23" Width="100" VerticalAlignment="Center" Click="btnBrowseImportFilePath_Click">
<Button.Effect>
<DropShadowEffect BlurRadius="5" Color="DarkOrange" />
</Button.Effect>
</Button>

</Grid>

</UserControl>

 


C#:

        /// <summary>
/// Greate new Schelder task, wich will start every hour
/// </summary>
/// <param name="user">User name with domain</param>
/// <param name="pass">User password</param>
/// <param name="pathToFile">Path to the executable file</param>
/// <returns>True if operation completed successful </returns>
public static bool CreateTask(string user, string pass, string pathToFile)
{
Process schedule = new Process();
schedule.StartInfo.FileName = "schtasks";

StringBuilder commandLineParams = new StringBuilder();

if (OSInfo.Name == OSInfo.OSNames.Windows_XP || OSInfo.Name == OSInfo.OSNames.Windows_2000 || OSInfo.Name == OSInfo.OSNames.Windows_Server_2003)
{
commandLineParams.AppendFormat("/Create /TN PMReadyTask /SC HOURLY /TR \"\\\"{2}\\\" auto \" /ST 06:00:00 /RU {0} /RP {1} ", user, pass, pathToFile);
schedule.StartInfo.Arguments = commandLineParams.ToString();
}
else if (OSInfo.Name == OSInfo.OSNames.Windows_Vista || OSInfo.Name == OSInfo.OSNames.Windows_7 || OSInfo.Name == OSInfo.OSNames.Windows_Server_2008)
{
commandLineParams.AppendFormat("/Create /TN PMReadyTask /SC HOURLY /TR \"\\\"{2}\\\" auto \" /ST 06:00:00 /RU {0} /RP {1} /DISABLE", user, pass, pathToFile);
schedule.StartInfo.Arguments = commandLineParams.ToString();
}
schedule.Start();

schedule.WaitForExit();
if (0 != schedule.ExitCode)
{
return false;
}
return true;

}


Code Formatter for Windows Live Writer


Інтерфейс набагато кращий, більше опцій і тд. Одним словом досить хороший варіант.


Безымянный1 


xaml:


<UserControl x:Class="Allscripts.Common.UI.UserControls.UCBrowsableTextBox"
xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="browsableGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="350" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<TextBox Name="brTextBox" Grid.Column="0" IsReadOnly="True" Margin="0,0,20,0" FocusVisualStyle="{x:Null}" TabIndex="0" Focusable="True" />

<Button Name="btnBrowseImportFilePath" Grid.Column="1" Content="Browse" TabIndex="2" BorderThickness="2" FontSize="13" HorizontalAlignment="Left" Height="23" Width="100" VerticalAlignment="Center" Click="btnBrowseImportFilePath_Click">
<Button.Effect>
<DropShadowEffect BlurRadius="5" Color="DarkOrange" />
</Button.Effect>
</Button>

</Grid>

</UserControl>

C#:


/// <summary>
/// Greate new Schelder task, wich will start every hour
/// </summary>
/// <param name="user">User name with domain</param>
/// <param name="pass">User password</param>
/// <param name="pathToFile">Path to the executable file</param>
/// <returns>True if operation completed successful </returns>
public static bool CreateTask(string user, string pass, string pathToFile)
{
Process schedule
= new Process();
schedule.StartInfo.FileName
= "schtasks";

StringBuilder commandLineParams
= new StringBuilder();

if (OSInfo.Name == OSInfo.OSNames.Windows_XP || OSInfo.Name == OSInfo.OSNames.Windows_2000 || OSInfo.Name == OSInfo.OSNames.Windows_Server_2003)
{
commandLineParams.AppendFormat(
"/Create /TN PMReadyTask /SC HOURLY /TR \"\\\"{2}\\\" auto \" /ST 06:00:00 /RU {0} /RP {1} ", user, pass, pathToFile);
schedule.StartInfo.Arguments
= commandLineParams.ToString();
}
else if (OSInfo.Name == OSInfo.OSNames.Windows_Vista || OSInfo.Name == OSInfo.OSNames.Windows_7 || OSInfo.Name == OSInfo.OSNames.Windows_Server_2008)
{
commandLineParams.AppendFormat(
"/Create /TN PMReadyTask /SC HOURLY /TR \"\\\"{2}\\\" auto \" /ST 06:00:00 /RU {0} /RP {1} /DISABLE", user, pass, pathToFile);
schedule.StartInfo.Arguments
= commandLineParams.ToString();
}
schedule.Start();

schedule.WaitForExit();
if (0 != schedule.ExitCode)
{
return false;
}
return true;

}


Source Code Formatter


Один з найкращих варіантів. Порадувала функція підсвітки пених фрагментів коду та простота інтерфейсу.


Безымянный2


 xaml:

  1: <UserControl x:Class="Allscripts.Common.UI.UserControls.UCBrowsableTextBox" 
  2:              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3: 	<Grid x:Name="browsableGrid">
  4: 		<Grid.ColumnDefinitions>
  5: 			<ColumnDefinition Width="350" />
  6: 			<ColumnDefinition Width="*" />
  7: 		</Grid.ColumnDefinitions>
  8: 
  9: 		<TextBox Name="brTextBox" Grid.Column="0" IsReadOnly="True" Margin="0,0,20,0" FocusVisualStyle="{x:Null}" TabIndex="0" Focusable="True" />
 10: 
 11: 		<Button Name="btnBrowseImportFilePath" Grid.Column="1" Content="Browse" TabIndex="2" BorderThickness="2" FontSize="13" HorizontalAlignment="Left" Height="23" Width="100" VerticalAlignment="Center" Click="btnBrowseImportFilePath_Click">
 12: 			<Button.Effect>
 13: 				<DropShadowEffect BlurRadius="5" Color="DarkOrange" />
 14: 			</Button.Effect>
 15: 		</Button>
 16: 
 17: 	</Grid>
 18: 
 19: </UserControl>

C#: 

  1:         /// <summary>
  2:         /// Greate new Schelder task, wich will start every hour
  3:         /// </summary>
  4:         /// <param name="user">User name with domain</param>
  5:         /// <param name="pass">User password</param>
  6:         /// <param name="pathToFile">Path to the executable file</param>
  7:         /// <returns>True if operation completed successful </returns>
  8:         public static bool CreateTask(string user, string pass, string pathToFile)
  9:         {
 10:             Process schedule = new Process();
 11:             schedule.StartInfo.FileName = "schtasks";
 12: 
 13:             StringBuilder commandLineParams = new StringBuilder();
 14: 
 15:             if (OSInfo.Name == OSInfo.OSNames.Windows_XP || OSInfo.Name == OSInfo.OSNames.Windows_2000 || OSInfo.Name == OSInfo.OSNames.Windows_Server_2003)
 16:             {
 17:                 commandLineParams.AppendFormat("/Create /TN PMReadyTask /SC HOURLY /TR \"\\\"{2}\\\" auto \" /ST 06:00:00 /RU {0} /RP {1}  ", user, pass, pathToFile);
 18:                 schedule.StartInfo.Arguments = commandLineParams.ToString();
 19:             }
 20:             else if (OSInfo.Name == OSInfo.OSNames.Windows_Vista || OSInfo.Name == OSInfo.OSNames.Windows_7 || OSInfo.Name == OSInfo.OSNames.Windows_Server_2008)
 21:             {
 22:                 commandLineParams.AppendFormat("/Create /TN PMReadyTask /SC HOURLY /TR \"\\\"{2}\\\" auto \" /ST 06:00:00 /RU {0} /RP {1} /DISABLE", user, pass, pathToFile);
 23:                 schedule.StartInfo.Arguments = commandLineParams.ToString();
 24:             }
 25:             schedule.Start();
 26: 
 27:             schedule.WaitForExit();
 28:             if (0 != schedule.ExitCode)
 29:             {
 30:                 return false;
 31:             }
 32:             return true;
 33: 
 34:         }

Syntax Higlighter 2.0 for Windows Live Writer


Знову ж виявилось що цей плагін (я так зрозумів) передбачає додавання до блогу додаткових сккриптів. Що не завжди зручно і може виявитись для декого досить важкою проблемою.


 Безымянный3


 xaml:


 

<UserControl x:Class="Allscripts.Common.UI.UserControls.UCBrowsableTextBox" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="browsableGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="350" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<TextBox Name="brTextBox" Grid.Column="0" IsReadOnly="True" Margin="0,0,20,0" FocusVisualStyle="{x:Null}" TabIndex="0" Focusable="True" />

<Button Name="btnBrowseImportFilePath" Grid.Column="1" Content="Browse" TabIndex="2" BorderThickness="2" FontSize="13" HorizontalAlignment="Left" Height="23" Width="100" VerticalAlignment="Center" Click="btnBrowseImportFilePath_Click">
<Button.Effect>
<DropShadowEffect BlurRadius="5" Color="DarkOrange" />
</Button.Effect>
</Button>

</Grid>

</UserControl>

 C#:


 

/// <summary>
/// Greate new Schelder task, wich will start every hour
/// </summary>
/// <param name="user">User name with domain</param>
/// <param name="pass">User password</param>
/// <param name="pathToFile">Path to the executable file</param>
/// <returns>True if operation completed successful </returns>
public static bool CreateTask(string user, string pass, string pathToFile)
{
Process schedule = new Process();
schedule.StartInfo.FileName = "schtasks";

StringBuilder commandLineParams = new StringBuilder();

if (OSInfo.Name == OSInfo.OSNames.Windows_XP || OSInfo.Name == OSInfo.OSNames.Windows_2000 || OSInfo.Name == OSInfo.OSNames.Windows_Server_2003)
{
commandLineParams.AppendFormat("/Create /TN PMReadyTask /SC HOURLY /TR \"\\\"{2}\\\" auto \" /ST 06:00:00 /RU {0} /RP {1} ", user, pass, pathToFile);
schedule.StartInfo.Arguments = commandLineParams.ToString();
}
else if (OSInfo.Name == OSInfo.OSNames.Windows_Vista || OSInfo.Name == OSInfo.OSNames.Windows_7 || OSInfo.Name == OSInfo.OSNames.Windows_Server_2008)
{
commandLineParams.AppendFormat("/Create /TN PMReadyTask /SC HOURLY /TR \"\\\"{2}\\\" auto \" /ST 06:00:00 /RU {0} /RP {1} /DISABLE", user, pass, pathToFile);
schedule.StartInfo.Arguments = commandLineParams.ToString();
}
schedule.Start();

schedule.WaitForExit();
if (0 != schedule.ExitCode)
{
return false;
}
return true;

}

 RESUME


З чотирьох встановдених мною плагінів лише 2 виявились придатними для застосування без додаткових налаштувань, через що чесно кажучи огляд не дав нам великого вибору. Особисто для себе я залишив Source Code Formatter, він легкий та зручний в використанні, містить все необхідне для мене та думаю для більшості користувачів Live Writer-а, але вибір за вами.


Якщо у вас є кращі варіанти форматування тексту буду радий почути їх.