Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2576 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
8 changed files with 215 additions and 18 deletions
@ -0,0 +1,55 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <author name="Daniel Grunwald"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpDevelop; |
||||||
|
using ICSharpCode.SharpDevelop.Project; |
||||||
|
using ICSharpCode.SharpDevelop.Dom; |
||||||
|
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.AddIn |
||||||
|
{ |
||||||
|
public class PropertyDescriptionService : IPropertyDescriptionService |
||||||
|
{ |
||||||
|
OpenedFile file; |
||||||
|
|
||||||
|
public PropertyDescriptionService(OpenedFile file) |
||||||
|
{ |
||||||
|
if (file == null) |
||||||
|
throw new ArgumentNullException("file"); |
||||||
|
this.file = file; |
||||||
|
} |
||||||
|
|
||||||
|
public object GetDescription(DesignItemProperty property) |
||||||
|
{ |
||||||
|
IProjectContent pc = GetProjectContent(); |
||||||
|
if (pc != null) { |
||||||
|
string fullName = property.DeclaringType.FullName + "." + property.Name; |
||||||
|
IDecoration dec = pc.GetElement(fullName); |
||||||
|
if (dec != null) |
||||||
|
return CodeCompletionData.GetDocumentation(dec.Documentation); |
||||||
|
foreach (IProjectContent rpc in pc.ReferencedContents) { |
||||||
|
dec = rpc.GetElement(fullName); |
||||||
|
if (dec != null) |
||||||
|
return CodeCompletionData.GetDocumentation(dec.Documentation); |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
IProjectContent GetProjectContent() |
||||||
|
{ |
||||||
|
if (ProjectService.OpenSolution != null) { |
||||||
|
IProject p = ProjectService.OpenSolution.FindProjectContainingFile(file.FileName); |
||||||
|
if (p != null) { |
||||||
|
return ParserService.GetProjectContent(p); |
||||||
|
} |
||||||
|
} |
||||||
|
return ParserService.DefaultProjectContent; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,94 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <author name="Daniel Grunwald"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Input; |
||||||
|
using System.Windows.Forms.Integration; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.AddIn |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Hosts a WPF element inside a Windows.Forms application.
|
||||||
|
/// </summary>
|
||||||
|
public class SharpDevelopElementHost : ElementHost, IUndoHandler, IClipboardHandler |
||||||
|
{ |
||||||
|
static bool IsEnabled(ICommand command) |
||||||
|
{ |
||||||
|
return command.CanExecute(null); |
||||||
|
} |
||||||
|
|
||||||
|
static void Run(ICommand command) |
||||||
|
{ |
||||||
|
command.Execute(null); |
||||||
|
} |
||||||
|
|
||||||
|
public bool EnableUndo { |
||||||
|
get { return IsEnabled(ApplicationCommands.Undo); } |
||||||
|
} |
||||||
|
|
||||||
|
public bool EnableRedo { |
||||||
|
get { return IsEnabled(ApplicationCommands.Redo); } |
||||||
|
} |
||||||
|
|
||||||
|
public void Undo() |
||||||
|
{ |
||||||
|
Run(ApplicationCommands.Undo); |
||||||
|
} |
||||||
|
|
||||||
|
public void Redo() |
||||||
|
{ |
||||||
|
Run(ApplicationCommands.Redo); |
||||||
|
} |
||||||
|
|
||||||
|
public bool EnableCut { |
||||||
|
get { return IsEnabled(ApplicationCommands.Undo); } |
||||||
|
} |
||||||
|
|
||||||
|
public bool EnableCopy { |
||||||
|
get { return IsEnabled(ApplicationCommands.Copy); } |
||||||
|
} |
||||||
|
|
||||||
|
public bool EnablePaste { |
||||||
|
get { return IsEnabled(ApplicationCommands.Paste); } |
||||||
|
} |
||||||
|
|
||||||
|
public bool EnableDelete { |
||||||
|
get { return IsEnabled(ApplicationCommands.Delete); } |
||||||
|
} |
||||||
|
|
||||||
|
public bool EnableSelectAll { |
||||||
|
get { return IsEnabled(ApplicationCommands.SelectAll); } |
||||||
|
} |
||||||
|
|
||||||
|
public void Cut() |
||||||
|
{ |
||||||
|
Run(ApplicationCommands.Cut); |
||||||
|
} |
||||||
|
|
||||||
|
public void Copy() |
||||||
|
{ |
||||||
|
Run(ApplicationCommands.Copy); |
||||||
|
} |
||||||
|
|
||||||
|
public void Paste() |
||||||
|
{ |
||||||
|
Run(ApplicationCommands.Paste); |
||||||
|
} |
||||||
|
|
||||||
|
public void Delete() |
||||||
|
{ |
||||||
|
Run(ApplicationCommands.Delete); |
||||||
|
} |
||||||
|
|
||||||
|
public void SelectAll() |
||||||
|
{ |
||||||
|
Run(ApplicationCommands.SelectAll); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue