📄 task.cs
字号:
// DINAMIC XML Editor
//
// Copyright (c) 2002-2003 Dusan Hlavaty
// mailto: duddo@atlas.cz
//
// This software is licensed under the terms of
// GNU General Public license
//
using System;
using XML_editor.MyForms;
using XML_editor.TabPages;
using Crownwood.Magic.Controls;
namespace XML_editor.Common
{
/// <summary>
/// Typ ulohy (TASKu)
/// </summary>
public enum TaskType
{ /// <summary>
/// Chyba
/// </summary> Error, /// <summary>
/// Upozornenie
/// </summary> Warning, /// <summary>
/// Informacia
/// </summary> Information }
/// <summary>
/// Tato trieda popisuje ulohu (task). Ulohy bude zobrazovat
/// 'Task List Panel' (<see cref="XML_editor.DockingPanels.TaskListPanel"/>)
/// </summary>
public class Task : IPosition
{
/// <summary>
/// Popis ulohy
/// </summary>
private string description;
/// <summary>
/// Nazov suboru (aj s cestou), ku ktoremu sa vztahuje tato uloha
/// </summary>
private string fileName;
/// <summary>
/// Typ ulohy (tasku) ako je definovany v <see cref="TaskType"/>
/// </summary>
private TaskType type;
/// <summary>
/// Cislo riadku, na ktory sa vztahuje tato uloha
/// </summary>
private int line;
/// <summary>
/// Poradove cislo znaku v riadku (<see cref="line"/>), na ktory sa vztahuje tato uloha
/// </summary>
private int column;
/// <summary>
/// Odkaz na hlavny formular aplikacie
/// </summary>
private MainForm mainForm = null;
// -------------------------------------------------------------------------
/// <summary>
/// Odkaz na hlavny formular aplikacie
/// </summary>
public MainForm MainForm
{
get
{
return this.mainForm;
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Cislo riadku, na ktory sa vztahuje tato uloha
/// </summary>
public int Line
{
get
{
return this.line;
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Poradove cislo znaku v riadku (<see cref="Line"/>), na ktory sa vztahuje tato uloha
/// </summary>
public int Column
{
get
{
return this.column;
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Popis ulohy
/// </summary>
public string Description
{
get
{
return this.description;
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Nazov suboru (aj s cestou), ku ktoremu sa vztahuje tato uloha
/// </summary>
public string FileName
{
get
{
return this.fileName;
}
// set
// {
// fileName = value;
// }
}
// -------------------------------------------------------------------------
/// <summary>
/// Typ ulohy (tasku) ako je definovany v <see cref="TaskType"/>
/// </summary>
public TaskType TaskType
{
get
{
return this.type;
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Inicializuje instanciu <see cref="Task"/>
/// </summary>
/// <param name="mainForm">Odkaz na Hlavny formular aplikacie</param>
/// <param name="taskType">Typ ulohy (tasku) ako je definovany v <see cref="TaskType"/></param>
/// <param name="description">Popis ulohy</param>
/// <param name="fullFileName">Nazov suboru (aj s cestou), ku ktoremu sa vztahuje tato uloha</param>
/// <param name="line">Cislo riadku, na ktory sa vztahuje tato uloha</param>
/// <param name="character">Poradove cislo znaku v riadku (<paramref name="line"/>), na ktory sa vztahuje tato uloha</param>
public Task(MainForm mainForm, TaskType taskType, string fullFileName, string description, int line, int character)
{
this.mainForm = mainForm;
this.type = taskType;
this.fileName = fullFileName;
this.description = description.Trim();
this.column = character - 1;
this.line = line - 1;
}
// -------------------------------------------------------------------------
/// <summary>
/// Skoci na poziciu v dokumente, ktoru oznacuje
/// </summary>
public void JumpToPosition()
{
#if DEBUG
System.Diagnostics.Debug.WriteLine("Task.cs :: JumpToPosition() => " + this.ToString());
#endif
if ((this.FileName == null) || (this.FileName.Length < 1))
{
return;
}
TextAreaTabPage tab = this.MainForm.GetTabPageByFileName(this.FileName);
if (tab == null)
{
return;
}
tab.TextAreaControl.JumpTo(Math.Max(0, line), Math.Max(0, column));
tab.Selected = true;
#if !LINUX
tab.Focus();
#endif
// if (fileName != null && fileName.Length > 0)
// {
// IFileService fileService = (IFileService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
// fileService.OpenFile(fileName);
// IWorkbenchWindow window = fileService.GetOpenFile(fileName);
// if (window == null)
// {
// return;
// }
// IViewContent content = window.ViewContent;
// if (content is IPositionable)
// {
// ((IPositionable)content).JumpTo(Math.Max(0, line), Math.Max(0, column));
//#if !LINUX
// // Begin Svante Lidman (by mike : May be workaround for .NET bug ... ?)
// content.Control.Focus();
// // End Svante Lidman
//#endif
// }
// }
// CompilerResultListItem li = (CompilerResultListItem)OpenTaskView.FocusedItem;
//
// string filename = li.FileName;
//
// if (filename == null || filename.Equals(""))
// return;
//
// if (File.Exists(filename)) {
// string directory = Path.GetDirectoryName(filename);
// if (directory[directory.Length - 1] != Path.DirectorySeparatorChar) {
// directory += Path.DirectorySeparatorChar;
// }
//
// ContentWindow window = OpenWindow(filename);
// }
}
// -------------------------------------------------------------------------
/// <summary>
/// Skonvertuje instanciu <see cref="Task"/> na string (pre lahsie odladovanie)
/// </summary>
/// <returns></returns>
public override string ToString()
{
return String.Format("[Task:File={0}, Line={1}, Column={2}, Type={3}, Description={4}]",
this.FileName,
this.Line,
this.Column,
this.TaskType,
this.Description);
}
} // public class Task
} // namespace XML_editor.Common
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -