18 changed files with 159 additions and 1048 deletions
@ -1,22 +0,0 @@
@@ -1,22 +0,0 @@
|
||||
<UserControl x:Class="Debugger.AddIn.Pads.Controls.ConditionCell" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:SDGui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" |
||||
xmlns:local="clr-namespace:Debugger.AddIn.Pads.Controls"> |
||||
<UserControl.Resources> |
||||
<DataTemplate x:Key="ConditionCellTemplate"> |
||||
<Grid HorizontalAlignment="Stretch"> |
||||
<local:ConditionCell |
||||
CommandText="{Binding Path=Condition, UpdateSourceTrigger=LostFocus}" |
||||
Tag="{Binding Path=Tag, Mode=TwoWay}"/> |
||||
</Grid> |
||||
</DataTemplate> |
||||
</UserControl.Resources> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="Auto" MinWidth="200"/> |
||||
</Grid.ColumnDefinitions> |
||||
<ContentPresenter |
||||
Name="ConsolePanel" /> |
||||
</Grid> |
||||
</UserControl> |
@ -1,196 +0,0 @@
@@ -1,196 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
|
||||
using ICSharpCode.AvalonEdit; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Core.Presentation; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace Debugger.AddIn.Pads.Controls |
||||
{ |
||||
public partial class ConditionCell : UserControl |
||||
{ |
||||
private string language; |
||||
|
||||
protected ConsoleControl console; |
||||
|
||||
public static readonly DependencyProperty CommandTextProperty = |
||||
DependencyProperty.Register("CommandText", typeof(string), typeof(ConditionCell), |
||||
new UIPropertyMetadata(null, new PropertyChangedCallback(OnCommandTextChanged))); |
||||
|
||||
private NRefactoryResolver resolver; |
||||
|
||||
public ConditionCell() |
||||
{ |
||||
InitializeComponent(); |
||||
|
||||
console = new ConsoleControl(); |
||||
console.TextAreaTextEntered += new TextCompositionEventHandler(consoleControl_TextAreaTextEntered); |
||||
console.TextAreaPreviewKeyDown += new KeyEventHandler(console_TextAreaPreviewKeyDown); |
||||
console.LostFocus += new RoutedEventHandler(console_LostFocus); |
||||
console.HideScrollBar(); |
||||
ConsolePanel.Content = console; |
||||
|
||||
// get language
|
||||
if (ProjectService.CurrentProject == null) |
||||
language = "C#"; |
||||
else |
||||
language = ProjectService.CurrentProject.Language; |
||||
resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language)); |
||||
|
||||
// FIXME set language
|
||||
if (language == "VB" || language == "VBNet") { |
||||
console.SetHighlighting("VBNET"); |
||||
} |
||||
else { |
||||
console.SetHighlighting("C#"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the command text displayed at the command prompt.
|
||||
/// </summary>
|
||||
public string CommandText { |
||||
get { return console.CommandText.Trim(); } |
||||
set { console.CommandText = value; } |
||||
} |
||||
|
||||
private BreakpointBookmark Breakpoint { |
||||
get { |
||||
var model = Model; |
||||
return model.Mark as BreakpointBookmark; |
||||
} |
||||
} |
||||
|
||||
private ListViewPadItemModel Model { |
||||
get { return Tag as ListViewPadItemModel; } |
||||
} |
||||
|
||||
private ITextEditor TextEditor { |
||||
get { |
||||
return console.TextEditor; |
||||
} |
||||
} |
||||
|
||||
private void console_TextAreaPreviewKeyDown(object sender, KeyEventArgs e) |
||||
{ |
||||
if (e.Key == Key.Return || e.Key == Key.Escape) { |
||||
|
||||
if (e.Key == Key.Escape) |
||||
CommandText = string.Empty; |
||||
else { |
||||
if(!CheckSyntax()) |
||||
return; |
||||
} |
||||
|
||||
UpdateBreakpoint(); |
||||
|
||||
e.Handled = true; |
||||
} |
||||
} |
||||
|
||||
private void console_LostFocus(object sender, RoutedEventArgs e) |
||||
{ |
||||
if (string.IsNullOrEmpty(CommandText) || !this.CheckSyntax()) |
||||
return; |
||||
|
||||
UpdateBreakpoint(); |
||||
} |
||||
|
||||
private void UpdateBreakpoint() |
||||
{ |
||||
Breakpoint.Condition = CommandText; |
||||
Model.Condition = CommandText; |
||||
Breakpoint.ScriptLanguage = language; |
||||
Model.Language = language; |
||||
|
||||
if (!string.IsNullOrEmpty(console.CommandText)) { |
||||
Breakpoint.Action = BreakpointAction.Condition; |
||||
if (Breakpoint.IsEnabled) |
||||
Model.Image = BreakpointBookmark.BreakpointConditionalImage.ImageSource; |
||||
} |
||||
else { |
||||
Breakpoint.Action = BreakpointAction.Break; |
||||
if (Breakpoint.IsEnabled) |
||||
Model.Image = BreakpointBookmark.BreakpointImage.ImageSource; |
||||
} |
||||
} |
||||
|
||||
private bool CheckSyntax() |
||||
{ |
||||
string command = CommandText; |
||||
if (string.IsNullOrEmpty(command)) |
||||
return true; |
||||
|
||||
// FIXME workaround the NRefactory issue that needs a ; at the end
|
||||
if (language == "C#") { |
||||
if(!command.EndsWith(";")) |
||||
command += ";"; |
||||
// FIXME only one string should be available; highlighting expects C#, supproted language, CSharp
|
||||
language = "CSharp"; |
||||
} |
||||
|
||||
SupportedLanguage supportedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), language.ToString(), true); |
||||
using (var parser = ParserFactory.CreateParser(supportedLanguage, new StringReader(TextEditor.Document.Text))) { |
||||
parser.ParseExpression(); |
||||
if (parser.Errors.Count > 0) { |
||||
MessageService.ShowError(parser.Errors.ErrorOutput); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
private void consoleControl_TextAreaTextEntered(object sender, TextCompositionEventArgs e) |
||||
{ |
||||
foreach (char ch in e.Text) { |
||||
if (ch == '.') { |
||||
ShowDotCompletion(console.CommandText); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void ShowDotCompletion(string currentText) |
||||
{ |
||||
var seg = Breakpoint; |
||||
|
||||
var expressionFinder = ParserService.GetExpressionFinder(seg.FileName.ToString()); |
||||
var info = ParserService.GetParseInformation(seg.FileName.ToString()); |
||||
|
||||
string text = ParserService.GetParseableFileContent(seg.FileName.ToString()).Text; |
||||
|
||||
int currentOffset = TextEditor.Caret.Offset - console.CommandOffset - 1; |
||||
|
||||
var expr = expressionFinder.FindExpression(currentText, currentOffset); |
||||
|
||||
expr.Region = new DomRegion(seg.LineNumber, seg.ColumnNumber, seg.LineNumber, seg.ColumnNumber); |
||||
|
||||
var rr = resolver.Resolve(expr, info, text); |
||||
|
||||
if (rr != null) { |
||||
TextEditor.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context)); |
||||
} |
||||
} |
||||
|
||||
private static void OnCommandTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { |
||||
var cell = d as ConditionCell; |
||||
cell.CommandText = e.NewValue.ToString(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Grid |
||||
x:Class="ICSharpCode.SharpDevelop.Bookmarks.BookmarkPadContent" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition Height="Auto" /> |
||||
<RowDefinition /> |
||||
</Grid.RowDefinitions> |
||||
<ListView |
||||
Grid.Row="1" |
||||
Name="listView" |
||||
x:FieldModifier="public"> |
||||
<ListView.View> |
||||
<GridView> |
||||
<GridViewColumn Header="{core:Localize MainWindow.Windows.BookmarkPad.LocationText}" Width="Auto"> |
||||
<GridViewColumn.CellTemplate> |
||||
<DataTemplate> |
||||
<StackPanel Orientation="Horizontal"> |
||||
<Image Source="{Binding ImageSource}" Margin="1, 1, 5, 1" /> |
||||
<TextBlock Text="{Binding FileNameAndLineNumber}" /> |
||||
</StackPanel> |
||||
</DataTemplate> |
||||
</GridViewColumn.CellTemplate> |
||||
</GridViewColumn> |
||||
</GridView> |
||||
</ListView.View> |
||||
</ListView> |
||||
</Grid> |
@ -1,41 +0,0 @@
@@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<UserControl |
||||
x:Class="ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls.ListViewPad" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls" xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"> |
||||
<Grid> |
||||
<Grid.Resources> |
||||
<DataTemplate |
||||
x:Key="CheckBoxTemplate"> |
||||
<CheckBox |
||||
IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" /> |
||||
</DataTemplate> |
||||
<DataTemplate |
||||
x:Key="InformationTemplate"> |
||||
<StackPanel Orientation="Horizontal"> |
||||
<Image Source="{Binding Path=Image, UpdateSourceTrigger=PropertyChanged}" Margin="1, 1, 5, 1" /> |
||||
<TextBlock Text="{Binding Path=Location}" /> |
||||
</StackPanel> |
||||
</DataTemplate> |
||||
</Grid.Resources> |
||||
<ListView |
||||
Name="MyListView" |
||||
ItemsSource="{Binding ItemCollection}"> |
||||
<ListView.View> |
||||
<GridView> |
||||
<GridViewColumn |
||||
Header="" |
||||
Width="Auto" |
||||
CellTemplate="{StaticResource CheckBoxTemplate}" /> |
||||
<GridViewColumn |
||||
Header="{core:Localize MainWindow.Windows.BookmarkPad.LocationText}" |
||||
Width="Auto" |
||||
CellTemplate="{StaticResource InformationTemplate}" /> |
||||
<GridViewColumn |
||||
Header="{core:Localize MainWindow.Windows.Debug.CallStack.Language}" |
||||
Width="Auto" |
||||
DisplayMemberBinding="{Binding Path=Language, UpdateSourceTrigger=PropertyChanged}" /> |
||||
</GridView> |
||||
</ListView.View> |
||||
</ListView> |
||||
</Grid> |
||||
</UserControl> |
@ -1,241 +0,0 @@
@@ -1,241 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.ObjectModel; |
||||
using System.ComponentModel; |
||||
using System.IO; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls |
||||
{ |
||||
/// <summary>
|
||||
/// ListViewPad inside WPF pads.
|
||||
/// </summary>
|
||||
public sealed partial class ListViewPad : UserControl |
||||
{ |
||||
ObservableCollection<ListViewPadItemModel> itemCollection = new ObservableCollection<ListViewPadItemModel>(); |
||||
|
||||
public ObservableCollection<ListViewPadItemModel> ItemCollection { |
||||
get { return itemCollection; } |
||||
} |
||||
|
||||
public event EventHandler ItemActivated; |
||||
|
||||
public ListViewPad() |
||||
{ |
||||
InitializeComponent(); |
||||
|
||||
this.MyListView.PreviewMouseDoubleClick += new MouseButtonEventHandler(ListViewPad_PreviewMouseDoubleClick); |
||||
this.MyListView.KeyDown += new KeyEventHandler(ListViewPad_KeyDown); |
||||
} |
||||
|
||||
public ListViewPadItemModel CurrentItem { |
||||
get { |
||||
if (MyListView.SelectedItem == null && MyListView.Items.Count > 0) |
||||
this.MyListView.SelectedItem = MyListView.Items[0]; |
||||
|
||||
return MyListView.SelectedItem as ListViewPadItemModel; |
||||
} |
||||
set { |
||||
if (value == null) return; |
||||
|
||||
this.MyListView.SelectedItem = value; |
||||
} |
||||
} |
||||
|
||||
public ListViewPadItemModel NextItem { |
||||
get { |
||||
bool found = false; |
||||
foreach (var line in ItemCollection) { |
||||
if (found) |
||||
return line; |
||||
if (line == CurrentItem) |
||||
found = true; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public ListViewPadItemModel PreviousItem { |
||||
get { |
||||
bool found = false; |
||||
ListViewPadItemModel prev = null; |
||||
foreach (var line in ItemCollection) { |
||||
if (found) |
||||
return prev; |
||||
if (line == CurrentItem) { |
||||
found = true; |
||||
} |
||||
else { |
||||
prev = line; |
||||
} |
||||
} |
||||
|
||||
return prev; |
||||
} |
||||
} |
||||
|
||||
public void Add(ListViewPadItemModel item) |
||||
{ |
||||
if (item == null) return; |
||||
ItemCollection.Add(item); |
||||
} |
||||
|
||||
public ListViewPadItemModel Remove(SDBookmark bookmark) |
||||
{ |
||||
if (bookmark is CurrentLineBookmark) |
||||
return null; |
||||
|
||||
foreach (var model in itemCollection) { |
||||
SDBookmark currentBookmark = model.Mark as SDBookmark; |
||||
|
||||
if (bookmark.FileName == currentBookmark.FileName && |
||||
bookmark.LineNumber == currentBookmark.LineNumber) { |
||||
ItemCollection.Remove(model); |
||||
return model; |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public void AddColumn(string header, DataTemplate cellTemplate) |
||||
{ |
||||
GridViewColumn column = new GridViewColumn(); |
||||
column.Header = header; |
||||
column.CellTemplate = cellTemplate; |
||||
((GridView)this.MyListView.View).Columns.Add(column); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Indexes from end to start.
|
||||
/// </summary>
|
||||
/// <param name="columnIndex"></param>
|
||||
public void HideColumns(params int[] columnIndexes) |
||||
{ |
||||
foreach(int i in columnIndexes) |
||||
((GridView)MyListView.View).Columns.RemoveAt(i); |
||||
} |
||||
|
||||
private void ListViewPad_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
var handler = ItemActivated; |
||||
|
||||
if (handler != null) |
||||
ItemActivated(this, EventArgs.Empty); |
||||
} |
||||
|
||||
private void ListViewPad_KeyDown(object sender, KeyEventArgs e) |
||||
{ |
||||
if (e.Key == Key.Escape) { |
||||
this.MyListView.UnselectAll(); |
||||
e.Handled = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public sealed class ListViewPadItemModel : INotifyPropertyChanged |
||||
{ |
||||
bool isChecked; |
||||
object tag; |
||||
string language; |
||||
string condition; |
||||
ImageSource imageSource; |
||||
|
||||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
public ListViewPadItemModel(SDBookmark mark) |
||||
{ |
||||
if (mark is BreakpointBookmark) { |
||||
isChecked = ((BreakpointBookmark)mark).IsEnabled; |
||||
condition = ((BreakpointBookmark)mark).Condition; |
||||
language = ((BreakpointBookmark)mark).ScriptLanguage; |
||||
} |
||||
|
||||
imageSource = mark.Image.ImageSource; |
||||
|
||||
Location = GetLocation(mark); |
||||
Mark = mark; |
||||
tag = this; |
||||
} |
||||
|
||||
public bool IsChecked { |
||||
get { |
||||
return isChecked; |
||||
} |
||||
set { |
||||
if (value != isChecked) |
||||
{ |
||||
isChecked = value; |
||||
NotifyPropertyChanged("IsChecked"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public SDBookmark Mark { |
||||
get; set; |
||||
} |
||||
|
||||
public ImageSource Image { |
||||
get { return imageSource; } |
||||
set { |
||||
imageSource = value; |
||||
NotifyPropertyChanged("Image"); |
||||
} |
||||
} |
||||
|
||||
public string Location { |
||||
get; private set; |
||||
} |
||||
|
||||
public string Language { |
||||
get { return language; } |
||||
set { |
||||
language = value; |
||||
NotifyPropertyChanged("Language"); |
||||
} |
||||
} |
||||
|
||||
public string Condition { |
||||
get { return condition; } |
||||
set { |
||||
condition = value; |
||||
NotifyPropertyChanged("Condition"); |
||||
} |
||||
} |
||||
|
||||
public object Tag { |
||||
get { return tag;} |
||||
set { |
||||
tag = value; |
||||
NotifyPropertyChanged("Tag"); |
||||
} |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return Location; |
||||
} |
||||
|
||||
private string GetLocation(SDBookmark bookmark) |
||||
{ |
||||
return string.Format(StringParser.Parse("${res:MainWindow.Windows.BookmarkPad.LineText}"), |
||||
Path.GetFileName(bookmark.FileName), bookmark.LineNumber); |
||||
} |
||||
|
||||
private void NotifyPropertyChanged(string property) |
||||
{ |
||||
if (PropertyChanged != null) { |
||||
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(property)); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,127 +0,0 @@
@@ -1,127 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Drawing; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Bookmarks |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SearchFolderNode.
|
||||
/// </summary>
|
||||
public class BookmarkFolderNode : ExtFolderNode |
||||
{ |
||||
List<SDBookmark> marks = new List<SDBookmark>(); |
||||
string fileName; |
||||
string fileNameText; |
||||
string occurences; |
||||
Image icon; |
||||
|
||||
public List<SDBookmark> Marks { |
||||
get { |
||||
return marks; |
||||
} |
||||
} |
||||
|
||||
public BookmarkFolderNode(string fileName) |
||||
{ |
||||
drawDefault = false; |
||||
this.fileName = fileName; |
||||
fileNameText = Path.GetFileName(fileName) + StringParser.Parse(" ${res:MainWindow.Windows.SearchResultPanel.In} ") + Path.GetDirectoryName(fileName); |
||||
icon = IconService.GetBitmap(IconService.GetImageForFile(fileName)); |
||||
Nodes.Add(new TreeNode()); |
||||
} |
||||
|
||||
public void SetText() |
||||
{ |
||||
if (marks.Count == 1) { |
||||
occurences = " (1 bookmark)"; |
||||
} else { |
||||
occurences = " (" + marks.Count + " bookmarks)"; |
||||
} |
||||
this.Text = fileNameText + occurences; |
||||
} |
||||
|
||||
protected override int MeasureItemWidth(DrawTreeNodeEventArgs e) |
||||
{ |
||||
Graphics g = e.Graphics; |
||||
int x = MeasureTextWidth(g, fileNameText, RegularBigFont); |
||||
x += MeasureTextWidth(g, occurences, ItalicBigFont); |
||||
if (icon != null) { |
||||
x += icon.Width; |
||||
} |
||||
return x + 3; |
||||
} |
||||
protected override void DrawForeground(DrawTreeNodeEventArgs e) |
||||
{ |
||||
Graphics g = e.Graphics; |
||||
float x = e.Bounds.X; |
||||
if (icon != null) { |
||||
g.DrawImage(icon, x, e.Bounds.Y, icon.Width, icon.Height); |
||||
x += icon.Width + 2; |
||||
} |
||||
DrawText(e, fileNameText, SystemBrushes.WindowText, RegularBigFont, ref x); |
||||
DrawText(e, occurences, SystemBrushes.GrayText, ItalicBigFont, ref x); |
||||
} |
||||
|
||||
public void AddMark(SDBookmark mark) |
||||
{ |
||||
int index = -1; |
||||
for (int i = 0; i < marks.Count; ++i) { |
||||
if (mark.LineNumber < marks[i].LineNumber) { |
||||
index = i; |
||||
break; |
||||
} |
||||
} |
||||
if (index < 0) |
||||
marks.Add(mark); |
||||
else |
||||
marks.Insert(index, mark); |
||||
|
||||
if (isInitialized) { |
||||
BookmarkNode newNode = new BookmarkNode(mark); |
||||
if (index < 0) |
||||
Nodes.Add(newNode); |
||||
else |
||||
Nodes.Insert(index, newNode); |
||||
newNode.EnsureVisible(); |
||||
} |
||||
SetText(); |
||||
} |
||||
|
||||
public void RemoveMark(SDBookmark mark) |
||||
{ |
||||
marks.Remove(mark); |
||||
if (isInitialized) { |
||||
for (int i = 0; i < Nodes.Count; ++i) { |
||||
if (((BookmarkNode)Nodes[i]).Bookmark == mark) { |
||||
Nodes.RemoveAt(i); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
SetText(); |
||||
} |
||||
|
||||
protected override void Initialize() |
||||
{ |
||||
Nodes.Clear(); |
||||
if (marks.Count > 0) { |
||||
// IDocument document = marks[0].Document;
|
||||
// if (document != null && document.HighlightingStrategy == null) {
|
||||
// document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(fileName);
|
||||
// }
|
||||
foreach (SDBookmark mark in marks) { |
||||
TreeNode newResult = new BookmarkNode(mark); |
||||
Nodes.Add(newResult); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,146 +0,0 @@
@@ -1,146 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Bookmarks |
||||
{ |
||||
/// <summary>
|
||||
/// ExtTreeNode representing a bookmark.
|
||||
/// </summary>
|
||||
public class BookmarkNode : ExtTreeNode |
||||
{ |
||||
SDBookmark bookmark; |
||||
//LineSegment line;
|
||||
|
||||
SizeF spaceSize; |
||||
static StringFormat sf = (StringFormat)System.Drawing.StringFormat.GenericTypographic.Clone(); |
||||
|
||||
string positionText; |
||||
|
||||
public SDBookmark Bookmark { |
||||
get { |
||||
return bookmark; |
||||
} |
||||
} |
||||
|
||||
public BookmarkNode(SDBookmark bookmark) |
||||
{ |
||||
drawDefault = false; |
||||
this.bookmark = bookmark; |
||||
Tag = bookmark; |
||||
// Checked = bookmark.IsEnabled;
|
||||
positionText = "(" + (bookmark.LineNumber) + ") "; |
||||
|
||||
bookmark.DocumentChanged += BookmarkDocumentChanged; |
||||
bookmark.LineNumberChanged += BookmarkLineNumberChanged; |
||||
if (bookmark.Document != null) { |
||||
BookmarkDocumentChanged(null, null); |
||||
} else { |
||||
Text = positionText; |
||||
} |
||||
} |
||||
|
||||
public override void CheckedChanged() |
||||
{ |
||||
// bookmark.IsEnabled = Checked;
|
||||
} |
||||
|
||||
void BookmarkDocumentChanged(object sender, EventArgs e) |
||||
{ |
||||
if (bookmark.Document != null) { |
||||
// line = bookmark.Document.GetLineSegment(Math.Min(bookmark.LineNumber, bookmark.Document.TotalNumberOfLines));
|
||||
// Text = positionText + bookmark.Document.GetText(line);
|
||||
} |
||||
} |
||||
|
||||
void BookmarkLineNumberChanged(object sender, EventArgs e) |
||||
{ |
||||
positionText = "(" + (bookmark.LineNumber) + ") "; |
||||
BookmarkDocumentChanged(sender, e); |
||||
} |
||||
|
||||
protected override int MeasureItemWidth(DrawTreeNodeEventArgs e) |
||||
{ |
||||
Graphics g = e.Graphics; |
||||
int x = MeasureTextWidth(g, positionText, BoldMonospacedFont); |
||||
// if (line != null && !line.IsDeleted) {
|
||||
// x += MeasureTextWidth(g, bookmark.Document.GetText(line).Replace("\t", " "), BoldMonospacedFont);
|
||||
// }
|
||||
return x; |
||||
} |
||||
|
||||
protected override void DrawForeground(DrawTreeNodeEventArgs e) |
||||
{ |
||||
Graphics g = e.Graphics; |
||||
float x = e.Bounds.X; |
||||
DrawText(e, positionText, SystemBrushes.WindowText, RegularBigFont, ref x); |
||||
|
||||
spaceSize = g.MeasureString("-", RegularBigFont, new PointF(0, 0), StringFormat.GenericTypographic); |
||||
|
||||
// if (line != null && !line.IsDeleted) {
|
||||
// DrawLine(g, line, e.Bounds.Y, x, e.State);
|
||||
// }
|
||||
} |
||||
|
||||
public override void ActivateItem() |
||||
{ |
||||
FileService.JumpToFilePosition(bookmark.FileName, bookmark.LineNumber, 1); |
||||
} |
||||
|
||||
/* |
||||
float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor) |
||||
{ |
||||
if (word == null || word.Length == 0) { |
||||
return 0f; |
||||
} |
||||
SizeF wordSize = g.MeasureString(word, font, 32768, sf); |
||||
|
||||
g.DrawString(word, |
||||
font, |
||||
BrushRegistry.GetBrush(foreColor), |
||||
position, |
||||
sf); |
||||
return wordSize.Width; |
||||
} |
||||
|
||||
void DrawLine(Graphics g, LineSegment line, float yPos, float xPos, TreeNodeStates state) |
||||
{ |
||||
int logicalX = 0; |
||||
if (line.Words != null) { |
||||
foreach (TextWord word in line.Words) { |
||||
switch (word.Type) { |
||||
case TextWordType.Space: |
||||
xPos += spaceSize.Width; |
||||
logicalX++; |
||||
break; |
||||
case TextWordType.Tab: |
||||
xPos += spaceSize.Width * 4; |
||||
logicalX++; |
||||
break; |
||||
case TextWordType.Word: |
||||
xPos += DrawDocumentWord(g, |
||||
word.Word, |
||||
new PointF(xPos, yPos), |
||||
word.Bold ? BoldMonospacedFont : RegularMonospacedFont, |
||||
GetTextColor(state, word.Color) |
||||
); |
||||
logicalX += word.Word.Length; |
||||
break; |
||||
} |
||||
} |
||||
} else { |
||||
// DrawDocumentWord(g,
|
||||
// bookmark.Document.GetText(line),
|
||||
// new PointF(xPos, yPos),
|
||||
// RegularMonospacedFont,
|
||||
// GetTextColor(state, Color.Black)
|
||||
// );
|
||||
} |
||||
}*/ |
||||
} |
||||
} |
Loading…
Reference in new issue