Browse Source

fix samples/PInvokeAddIn

pull/297/head
Siegfried Pammer 12 years ago
parent
commit
8e16f5313a
  1. 3
      samples/PInvokeAddIn/Project/Src/InsertPInvokeSignaturesCommand.cs
  2. 14
      samples/PInvokeAddIn/Project/Src/InsertPInvokeSignaturesForm.cs

3
samples/PInvokeAddIn/Project/Src/InsertPInvokeSignaturesCommand.cs

@ -3,6 +3,7 @@
using System; using System;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.PInvokeAddIn namespace ICSharpCode.PInvokeAddIn
@ -20,7 +21,7 @@ namespace ICSharpCode.PInvokeAddIn
{ {
// Show PInvoke dialog. // Show PInvoke dialog.
using(InsertPInvokeSignaturesForm form = new InsertPInvokeSignaturesForm()) { using(InsertPInvokeSignaturesForm form = new InsertPInvokeSignaturesForm()) {
form.ShowDialog(WorkbenchSingleton.MainWin32Window); form.ShowDialog(SD.WinForms.MainWin32Window);
} }
} }
} }

14
samples/PInvokeAddIn/Project/Src/InsertPInvokeSignaturesForm.cs

@ -8,6 +8,7 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.PInvokeAddIn.WebServices; using ICSharpCode.PInvokeAddIn.WebServices;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
@ -140,7 +141,7 @@ namespace ICSharpCode.PInvokeAddIn
string signature = GetSelectedPInvokeSignature(language); string signature = GetSelectedPInvokeSignature(language);
if (signature.Length > 0) { if (signature.Length > 0) {
ITextEditor textEditor = GetTextEditor(); ITextEditor textEditor = SD.GetActiveViewContentService<ITextEditor>();
if (textEditor != null) { if (textEditor != null) {
generator.Generate(textEditor, signature); generator.Generate(textEditor, signature);
} }
@ -242,7 +243,7 @@ namespace ICSharpCode.PInvokeAddIn
string GetSourceFileLanguage() string GetSourceFileLanguage()
{ {
ITextEditor textEditor = GetTextEditor(); ITextEditor textEditor = SD.GetActiveViewContentService<ITextEditor>();
if (textEditor != null) { if (textEditor != null) {
string fileExtension = Path.GetExtension(textEditor.FileName); string fileExtension = Path.GetExtension(textEditor.FileName);
if (fileExtension.Equals(".vb", StringComparison.OrdinalIgnoreCase)) { if (fileExtension.Equals(".vb", StringComparison.OrdinalIgnoreCase)) {
@ -280,14 +281,5 @@ namespace ICSharpCode.PInvokeAddIn
} }
} }
} }
static ITextEditor GetTextEditor()
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
if (provider != null)
return provider.TextEditor;
else
return null;
}
} }
} }

Loading…
Cancel
Save