本文整理汇总了C#中TextEditor.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.ToString方法的具体用法?C# TextEditor.ToString怎么用?C# TextEditor.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEditor
的用法示例。
在下文中一共展示了TextEditor.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenEditor
/// <summary>
/// Open the defined editor for a file that the user has double clicked on.
/// </summary>
/// <param name="textEditor">Text editor object reference</param>
/// <param name="path">Fully qualified file path</param>
/// <param name="line">Line number</param>
/// <param name="column">Column position</param>
/// <history>
/// [Curtis_Beard] 07/10/2006 ADD: Initial
/// [Curtis_Beard] 07/26/2006 ADD: 1512026, column position
/// [Curtis_Beard] 08/13/2014 ADD: 80, add ability to open default app when no editor is specified
/// [Curtis_Beard] 03/06/2015 FIX: 65, check editor for using quotes around file name, cleanup
/// [Curtis_Beard] 04/08/2015 CHG: add logging
/// [Curtis_Beard] 08/20/2015 CHG: 80, make check for empty editor to use default app the first check.
/// </history>
private static void OpenEditor(TextEditor textEditor, string path, int line, int column)
{
try
{
if (string.IsNullOrEmpty(textEditor.Editor))
{
OpenFileWithDefaultApp(path);
}
else if (textEditor.Arguments.IndexOf("%1") == -1)
{
// no file argument specified
MessageBox.Show(Language.GetGenericText("TextEditorsErrorNoCmdLineForFile"),
ProductInformation.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
// replace
// %1 with filename
// %2 with line number
// %3 with column
string args = textEditor.Arguments;
if (textEditor.UseQuotesAroundFileName)
{
path = "\"" + path + "\"";
}
args = args.Replace("%1", path);
args = args.Replace("%2", line.ToString());
args = args.Replace("%3", column.ToString());
System.Diagnostics.Process.Start(textEditor.Editor, args);
}
}
catch (Exception ex)
{
LogClient.Instance.Logger.Error("Unable to open text editor for editor {0}, file {1} at line {2}, column {3}, with message {4}", textEditor.ToString(), path, line, column, ex.Message);
MessageBox.Show(String.Format(Language.GetGenericText("TextEditorsErrorGeneric"), path, ex.Message),
ProductInformation.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}