Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@145 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
15 changed files with 322 additions and 94 deletions
@ -1,30 +0,0 @@
@@ -1,30 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version value="$version"/>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// This interface flags an object beeing "mementocapable". This means that the
|
||||
/// state of the object could be saved to an <see cref="Properties"/> object
|
||||
/// and set from a object from the same class.
|
||||
/// This is used to save and restore the state of GUI objects.
|
||||
/// </summary>
|
||||
public interface IMementoCapable |
||||
{ |
||||
/// <summary>
|
||||
/// Creates a new memento from the state.
|
||||
/// </summary>
|
||||
Properties CreateMemento(); |
||||
|
||||
/// <summary>
|
||||
/// Sets the state to the given memento.
|
||||
/// </summary>
|
||||
void SetMemento(Properties memento); |
||||
} |
||||
} |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version value="$version"/>
|
||||
// </file>
|
||||
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Text; |
||||
using System.Globalization; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.TextEditor.Document; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Bookmarks |
||||
{ |
||||
public sealed class BookmarkConverter : TypeConverter |
||||
{ |
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) |
||||
{ |
||||
if (sourceType == typeof(string)) { |
||||
return true; |
||||
} else { |
||||
return base.CanConvertFrom(context, sourceType); |
||||
} |
||||
} |
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) |
||||
{ |
||||
if (value is string) { |
||||
string[] v = ((string)value).Split('|'); |
||||
string fileName = v[1]; |
||||
int lineNumber = int.Parse(v[2], culture); |
||||
SDBookmark bookmark; |
||||
switch (v[0]) { |
||||
case "Breakpoint": |
||||
bookmark = new Breakpoint(null, fileName, lineNumber).Bookmark; |
||||
break; |
||||
default: |
||||
bookmark = new SDBookmark(fileName, null, lineNumber); |
||||
break; |
||||
} |
||||
bookmark.IsEnabled = bool.Parse(v[3]); |
||||
return bookmark; |
||||
} else { |
||||
return base.ConvertFrom(context, culture, value); |
||||
} |
||||
} |
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) |
||||
{ |
||||
SDBookmark bookmark = value as SDBookmark; |
||||
if (destinationType == typeof(string) && bookmark != null) { |
||||
StringBuilder b = new StringBuilder(); |
||||
if (bookmark is BreakpointBookmark) { |
||||
b.Append("Breakpoint"); |
||||
} else { |
||||
b.Append("Bookmark"); |
||||
} |
||||
b.Append('|'); |
||||
b.Append(bookmark.FileName); |
||||
b.Append('|'); |
||||
b.Append(bookmark.LineNumber); |
||||
b.Append('|'); |
||||
b.Append(bookmark.IsEnabled.ToString()); |
||||
return b.ToString(); |
||||
} else { |
||||
return base.ConvertTo(context, culture, value, destinationType); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue