Browse Source

Fix snippet compiler sample.

Remaining problems:

Application can hang after debugging.
Selecting item in Errors list does not jump to text editor line.
pull/39/merge
Matt Ward 13 years ago
parent
commit
de6619b247
  1. 43
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/DelegateCommand.cs
  2. 96
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarManager.cs
  3. 259
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarMargin.cs
  4. 305
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/MainViewContent.cs
  5. 37
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj
  6. 48
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.Designer.cs
  7. 51
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.cs
  8. 120
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.resx
  9. 28
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetProjectBinding.cs
  10. 33
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetTextEditorAdapter.cs
  11. 64
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs
  12. 14
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetFile.cs
  13. 54
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/StatusBarService.cs
  14. 306
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/TextMarkerService.cs
  15. 86
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/Workbench.cs
  16. 122
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/WpfSynchronizeInvoke.cs
  17. 2
      samples/SharpSnippetCompiler/SharpSnippetCompiler.sln
  18. 100
      samples/SharpSnippetCompiler/SharpSnippetCompiler/AddIns/SharpSnippetCompiler.addin
  19. 7
      samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml
  20. 37
      samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml.cs
  21. 458
      samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.Designer.cs
  22. 378
      samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.cs
  23. 123
      samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.resx
  24. 315
      samples/SharpSnippetCompiler/SharpSnippetCompiler/MainViewModel.cs
  25. 106
      samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml
  26. 16
      samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml.cs
  27. 6
      samples/SharpSnippetCompiler/SharpSnippetCompiler/NewFileDialog.cs
  28. 63
      samples/SharpSnippetCompiler/SharpSnippetCompiler/PadViewModel.cs
  29. 6
      samples/SharpSnippetCompiler/SharpSnippetCompiler/PreBuildEvent.proj
  30. 37
      samples/SharpSnippetCompiler/SharpSnippetCompiler/Program.cs
  31. 88
      samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj
  32. 18
      samples/SharpSnippetCompiler/SharpSnippetCompiler/TextEditorDisplayBinding.cs
  33. 21
      samples/SharpSnippetCompiler/SharpSnippetCompiler/ViewModels.cs
  34. 24
      samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchLayout.cs
  35. 21
      samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchWindow.cs
  36. 4
      samples/SharpSnippetCompiler/SharpSnippetCompiler/app.config

43
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/DelegateCommand.cs

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
// 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.Windows.Input;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
public class DelegateCommand : ICommand
{
Action<object> execute;
Predicate<object> canExecute;
public DelegateCommand(Action<object> execute, Predicate<object> canExecute)
{
this.execute = execute;
this.canExecute = canExecute;
}
public DelegateCommand(Action<object> execute)
: this(execute, null)
{
}
public event EventHandler CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameter)
{
execute(parameter);
}
public bool CanExecute(object parameter)
{
if (canExecute != null) {
return canExecute(parameter);
}
return true;
}
}
}

96
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarManager.cs

@ -0,0 +1,96 @@ @@ -0,0 +1,96 @@
// 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 ICSharpCode.AvalonEdit.Document;
using ICSharpCode.SharpDevelop.Dom;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
/// <summary>
/// Stores the entries in the icon bar margin. Multiple icon bar margins
/// can use the same manager if split view is used.
/// </summary>
public class IconBarManager : IBookmarkMargin
{
ObservableCollection<IBookmark> bookmarks = new ObservableCollection<IBookmark>();
public IconBarManager()
{
bookmarks.CollectionChanged += bookmarks_CollectionChanged;
}
public IList<IBookmark> Bookmarks {
get { return bookmarks; }
}
void bookmarks_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
Redraw();
}
public void Redraw()
{
if (RedrawRequested != null)
RedrawRequested(this, EventArgs.Empty);
}
public event EventHandler RedrawRequested;
[Obsolete("Please provide a TextDocument; this is necessary so that the bookmarks can move when lines are inserted/removed")]
public void UpdateClassMemberBookmarks(ParseInformation parseInfo)
{
UpdateClassMemberBookmarks(parseInfo, null);
}
public void UpdateClassMemberBookmarks(ParseInformation parseInfo, TextDocument document)
{
for (int i = bookmarks.Count - 1; i >= 0; i--) {
if (IsClassMemberBookmark(bookmarks[i]))
bookmarks.RemoveAt(i);
}
if (parseInfo == null)
return;
foreach (IClass c in parseInfo.CompilationUnit.Classes) {
AddClassMemberBookmarks(c, document);
}
}
void AddClassMemberBookmarks(IClass c, TextDocument document)
{
if (c.IsSynthetic) return;
if (!c.Region.IsEmpty) {
bookmarks.Add(new ClassBookmark(c, document));
}
foreach (IClass innerClass in c.InnerClasses) {
AddClassMemberBookmarks(innerClass, document);
}
foreach (IMethod m in c.Methods) {
if (m.Region.IsEmpty || m.IsSynthetic) continue;
bookmarks.Add(new ClassMemberBookmark(m, document));
}
foreach (IProperty p in c.Properties) {
if (p.Region.IsEmpty || p.IsSynthetic) continue;
bookmarks.Add(new ClassMemberBookmark(p, document));
}
foreach (IField f in c.Fields) {
if (f.Region.IsEmpty || f.IsSynthetic) continue;
bookmarks.Add(new ClassMemberBookmark(f, document));
}
foreach (IEvent e in c.Events) {
if (e.Region.IsEmpty || e.IsSynthetic) continue;
bookmarks.Add(new ClassMemberBookmark(e, document));
}
}
static bool IsClassMemberBookmark(IBookmark b)
{
return b is ClassMemberBookmark || b is ClassBookmark;
}
}
}

259
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarMargin.cs

@ -0,0 +1,259 @@ @@ -0,0 +1,259 @@
// 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.Windows;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
/// <summary>
/// Icon bar: contains breakpoints and other icons.
/// </summary>
public class IconBarMargin : AbstractMargin, IDisposable
{
readonly IBookmarkMargin manager;
public IconBarMargin(IBookmarkMargin manager)
{
if (manager == null)
throw new ArgumentNullException("manager");
this.manager = manager;
}
#region OnTextViewChanged
/// <inheritdoc/>
protected override void OnTextViewChanged(TextView oldTextView, TextView newTextView)
{
if (oldTextView != null) {
oldTextView.VisualLinesChanged -= OnRedrawRequested;
manager.RedrawRequested -= OnRedrawRequested;
}
base.OnTextViewChanged(oldTextView, newTextView);
if (newTextView != null) {
newTextView.VisualLinesChanged += OnRedrawRequested;
manager.RedrawRequested += OnRedrawRequested;
}
InvalidateVisual();
}
void OnRedrawRequested(object sender, EventArgs e)
{
// Don't invalidate the IconBarMargin if it'll be invalidated again once the
// visual lines become valid.
if (this.TextView != null && this.TextView.VisualLinesValid) {
InvalidateVisual();
}
}
public virtual void Dispose()
{
this.TextView = null; // detach from TextView (will also detach from manager)
}
#endregion
/// <inheritdoc/>
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
{
// accept clicks even when clicking on the background
return new PointHitTestResult(this, hitTestParameters.HitPoint);
}
/// <inheritdoc/>
protected override Size MeasureOverride(Size availableSize)
{
return new Size(18, 0);
}
protected override void OnRender(DrawingContext drawingContext)
{
Size renderSize = this.RenderSize;
drawingContext.DrawRectangle(SystemColors.ControlBrush, null,
new Rect(0, 0, renderSize.Width, renderSize.Height));
drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1),
new Point(renderSize.Width - 0.5, 0),
new Point(renderSize.Width - 0.5, renderSize.Height));
TextView textView = this.TextView;
if (textView != null && textView.VisualLinesValid) {
// create a dictionary line number => first bookmark
Dictionary<int, IBookmark> bookmarkDict = new Dictionary<int, IBookmark>();
foreach (IBookmark bm in manager.Bookmarks) {
int line = bm.LineNumber;
IBookmark existingBookmark;
if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder)
bookmarkDict[line] = bm;
}
Size pixelSize = PixelSnapHelpers.GetPixelSize(this);
foreach (VisualLine line in textView.VisualLines) {
int lineNumber = line.FirstDocumentLine.LineNumber;
IBookmark bm;
if (bookmarkDict.TryGetValue(lineNumber, out bm)) {
double lineMiddle = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextMiddle) - textView.VerticalOffset;
Rect rect = new Rect(0, PixelSnapHelpers.Round(lineMiddle - 8, pixelSize.Height), 16, 16);
if (dragDropBookmark == bm && dragStarted)
drawingContext.PushOpacity(0.5);
drawingContext.DrawImage((bm.Image ?? BookmarkBase.DefaultBookmarkImage).ImageSource, rect);
if (dragDropBookmark == bm && dragStarted)
drawingContext.Pop();
}
}
if (dragDropBookmark != null && dragStarted) {
Rect rect = new Rect(0, PixelSnapHelpers.Round(dragDropCurrentPoint - 8, pixelSize.Height), 16, 16);
drawingContext.DrawImage((dragDropBookmark.Image ?? BookmarkBase.DefaultBookmarkImage).ImageSource, rect);
}
}
}
IBookmark dragDropBookmark; // bookmark being dragged (!=null if drag'n'drop is active)
double dragDropStartPoint;
double dragDropCurrentPoint;
bool dragStarted; // whether drag'n'drop operation has started (mouse was moved minimum distance)
protected override void OnMouseDown(MouseButtonEventArgs e)
{
CancelDragDrop();
base.OnMouseDown(e);
int line = GetLineFromMousePosition(e);
if (!e.Handled && line > 0) {
IBookmark bm = GetBookmarkFromLine(line);
if (bm != null) {
bm.MouseDown(e);
if (!e.Handled) {
if (e.ChangedButton == MouseButton.Left && bm.CanDragDrop && CaptureMouse()) {
StartDragDrop(bm, e);
e.Handled = true;
}
}
}
}
// don't allow selecting text through the IconBarMargin
if (e.ChangedButton == MouseButton.Left)
e.Handled = true;
}
IBookmark GetBookmarkFromLine(int line)
{
IBookmark result = null;
foreach (IBookmark bm in manager.Bookmarks) {
if (bm.LineNumber == line) {
if (result == null || bm.ZOrder > result.ZOrder)
result = bm;
}
}
return result;
}
protected override void OnLostMouseCapture(MouseEventArgs e)
{
CancelDragDrop();
base.OnLostMouseCapture(e);
}
void StartDragDrop(IBookmark bm, MouseEventArgs e)
{
dragDropBookmark = bm;
dragDropStartPoint = dragDropCurrentPoint = e.GetPosition(this).Y;
if (TextView != null) {
TextArea area = TextView.Services.GetService(typeof(TextArea)) as TextArea;
if (area != null)
area.PreviewKeyDown += TextArea_PreviewKeyDown;
}
}
void CancelDragDrop()
{
if (dragDropBookmark != null) {
dragDropBookmark = null;
dragStarted = false;
if (TextView != null) {
TextArea area = TextView.Services.GetService(typeof(TextArea)) as TextArea;
if (area != null)
area.PreviewKeyDown -= TextArea_PreviewKeyDown;
}
ReleaseMouseCapture();
InvalidateVisual();
}
}
void TextArea_PreviewKeyDown(object sender, KeyEventArgs e)
{
// any key press cancels drag'n'drop
CancelDragDrop();
if (e.Key == Key.Escape)
e.Handled = true;
}
int GetLineFromMousePosition(MouseEventArgs e)
{
TextView textView = this.TextView;
if (textView == null)
return 0;
VisualLine vl = textView.GetVisualLineFromVisualTop(e.GetPosition(textView).Y + textView.ScrollOffset.Y);
if (vl == null)
return 0;
return vl.FirstDocumentLine.LineNumber;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (dragDropBookmark != null) {
dragDropCurrentPoint = e.GetPosition(this).Y;
if (Math.Abs(dragDropCurrentPoint - dragDropStartPoint) > SystemParameters.MinimumVerticalDragDistance)
dragStarted = true;
InvalidateVisual();
}
}
protected override void OnMouseUp(MouseButtonEventArgs e)
{
base.OnMouseUp(e);
int line = GetLineFromMousePosition(e);
if (!e.Handled && dragDropBookmark != null) {
if (dragStarted) {
if (line != 0)
dragDropBookmark.Drop(line);
e.Handled = true;
}
CancelDragDrop();
}
if (!e.Handled && line != 0) {
IBookmark bm = GetBookmarkFromLine(line);
if (bm != null) {
bm.MouseUp(e);
if (e.Handled)
return;
}
if (e.ChangedButton == MouseButton.Left && TextView != null) {
// no bookmark on the line: create a new breakpoint
ITextEditor textEditor = TextView.Services.GetService(typeof(ITextEditor)) as ITextEditor;
if (textEditor != null) {
DebuggerService.ToggleBreakpointAt(textEditor, line, typeof(BreakpointBookmark));
return;
}
// create breakpoint for the other posible active contents
var viewContent = WorkbenchSingleton.Workbench.ActiveContent as AbstractViewContentWithoutFile;
if (viewContent != null) {
textEditor = viewContent.Services.GetService(typeof(ITextEditor)) as ITextEditor;
if (textEditor != null) {
DebuggerService.ToggleBreakpointAt(textEditor, line, typeof(DecompiledBreakpointBookmark));
return;
}
}
}
}
}
}
}

305
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/MainViewContent.cs

@ -7,107 +7,118 @@ @@ -7,107 +7,118 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using System.Windows.Controls;
using System.Windows.Media;
using ICSharpCode.AvalonEdit;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
public class MainViewContent : IViewContent, ITextEditorControlProvider, IClipboardHandler, IUndoHandler, IPositionable, IParseInformationListener, IEditable
public class MainViewContent : IViewContent, ITextEditorProvider, IPositionable
{
IWorkbenchWindow workbenchWindow;
TextEditorControl textEditor;
SharpSnippetCompilerControl snippetControl;
TextEditor textEditor;
SharpSnippetTextEditorAdapter adapter;
SnippetFile file;
IconBarManager iconBarManager;
public MainViewContent(string fileName, SharpSnippetCompilerControl snippetControl, IWorkbenchWindow workbenchWindow)
public MainViewContent(string fileName, IWorkbenchWindow workbenchWindow)
{
file = new SnippetFile(fileName);
this.snippetControl = snippetControl;
this.textEditor = snippetControl.TextEditor;
this.textEditor = new TextEditor();
this.textEditor.FontFamily = new FontFamily("Consolas");
this.adapter = new SharpSnippetTextEditorAdapter(textEditor);
this.workbenchWindow = workbenchWindow;
textEditor.TextArea.TextView.Services.AddService(typeof(ITextEditor), adapter);
this.LoadFile(fileName);
iconBarManager = new IconBarManager();
this.textEditor.TextArea.LeftMargins.Insert(0, new IconBarMargin(iconBarManager));
var textMarkerService = new TextMarkerService(textEditor.Document);
textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
textEditor.TextArea.TextView.Services.AddService(typeof(ITextMarkerService), textMarkerService);
textEditor.TextArea.TextView.Services.AddService(typeof(IBookmarkMargin), iconBarManager);
BookmarkManager.Added += BookmarkManager_Added;
BookmarkManager.Removed += BookmarkManager_Removed;
}
public event EventHandler TabPageTextChanged;
public event EventHandler TitleNameChanged;
public event EventHandler Disposed;
public event EventHandler Disposed;
public event EventHandler IsDirtyChanged;
public bool EnableUndo {
get { return textEditor.EnableUndo; }
}
public bool EnableRedo {
get { return textEditor.EnableRedo; }
}
public void Undo()
{
textEditor.Undo();
}
public void Redo()
{
textEditor.Redo();
}
public bool EnableCut {
get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCut; }
}
public bool EnableCopy {
get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCopy; }
}
public bool EnablePaste {
get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnablePaste; }
}
public bool EnableDelete {
get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableDelete; }
}
public bool EnableSelectAll {
get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableSelectAll; }
}
public void Cut()
{
textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.Cut(null, null);
}
public void Copy()
{
textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.Copy(null, null);
}
public void Paste()
{
textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.Paste(null, null);
}
public void Delete()
{
textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.Delete(null, null);
}
public void SelectAll()
{
textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.SelectAll(null, null);
}
public TextEditorControl TextEditorControl {
get { return textEditor; }
}
//
// public bool EnableUndo {
// get { return textEditor.EnableUndo; }
// }
//
// public bool EnableRedo {
// get { return textEditor.EnableRedo; }
// }
//
// public void Undo()
// {
// textEditor.Undo();
// }
//
// public void Redo()
// {
// textEditor.Redo();
// }
//
// public bool EnableCut {
// get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCut; }
// }
//
// public bool EnableCopy {
// get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCopy; }
// }
//
// public bool EnablePaste {
// get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnablePaste; }
// }
//
// public bool EnableDelete {
// get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableDelete; }
// }
//
// public bool EnableSelectAll {
// get { return textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableSelectAll; }
// }
//
// public void Cut()
// {
// textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.Cut(null, null);
// }
//
// public void Copy()
// {
// textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.Copy(null, null);
// }
//
// public void Paste()
// {
// textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.Paste(null, null);
// }
//
// public void Delete()
// {
// textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.Delete(null, null);
// }
//
// public void SelectAll()
// {
// textEditor.ActiveTextAreaControl.TextArea.ClipboardHandler.SelectAll(null, null);
// }
public Control Control {
get { return snippetControl; }
get { return textEditor; }
}
public IWorkbenchWindow WorkbenchWindow {
@ -116,9 +127,7 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -116,9 +127,7 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
}
public string TabPageText {
get {
throw new NotImplementedException();
}
get { return Path.GetFileName(file.FileName); }
}
public string TitleName {
@ -137,7 +146,7 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -137,7 +146,7 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
get { return file; }
}
public string PrimaryFileName {
public FileName PrimaryFileName {
get { return file.FileName; }
}
@ -171,11 +180,6 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -171,11 +180,6 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
}
}
public void RedrawContent()
{
throw new NotImplementedException();
}
public void Save(OpenedFile file, Stream stream)
{
throw new NotImplementedException();
@ -213,47 +217,41 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -213,47 +217,41 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
public void Dispose()
{
BookmarkManager.Added -= BookmarkManager_Added;
BookmarkManager.Removed -= BookmarkManager_Removed;
}
public IDocument GetDocumentForFile(OpenedFile file)
{
return null;
}
}
public void JumpTo(int line, int column)
{
textEditor.ActiveTextAreaControl.JumpTo(line, column);
// // we need to delay this call here because the text editor does not know its height if it was just created
// WorkbenchSingleton.SafeThreadAsyncCall(
// delegate {
// textEditor.ActiveTextAreaControl.CenterViewOn(
// line, (int)(0.3 * textEditor.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount));
// });
adapter.JumpTo(line, column);
}
public int Line {
get { return textEditor.ActiveTextAreaControl.Caret.Line; }
get { return textEditor.TextArea.Caret.Line; }
}
public int Column {
get { return textEditor.ActiveTextAreaControl.Caret.Column; }
get { return textEditor.TextArea.Caret.Column; }
}
public void ParseInformationUpdated(ParseInformation parseInfo)
{
if (textEditor.TextEditorProperties.EnableFolding) {
WorkbenchSingleton.SafeThreadAsyncCall(ParseInformationUpdatedInvoked, parseInfo);
}
}
// public void ParseInformationUpdated(ParseInformation parseInfo)
// {
// if (textEditor.TextEditorProperties.EnableFolding) {
// WorkbenchSingleton.SafeThreadAsyncCall(ParseInformationUpdatedInvoked, parseInfo);
// }
// }
public delegate string GetTextHelper();
public string Text {
get {
if (WorkbenchSingleton.InvokeRequired) {
return (string)WorkbenchSingleton.MainForm.Invoke(new GetTextHelper(GetText));
//return WorkbenchSingleton.SafeThreadFunction<string>(GetText);
return (string)WorkbenchSingleton.SafeThreadFunction(GetText);
} else {
return GetText();
}
@ -293,27 +291,88 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -293,27 +291,88 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
if (IsDirtyChanged != null) {
IsDirtyChanged(this, e);
}
}
void ParseInformationUpdatedInvoked(ParseInformation parseInfo)
{
try {
textEditor.Document.FoldingManager.UpdateFoldings(file.FileName, parseInfo);
textEditor.ActiveTextAreaControl.TextArea.Refresh(textEditor.ActiveTextAreaControl.TextArea.FoldMargin);
textEditor.ActiveTextAreaControl.TextArea.Refresh(textEditor.ActiveTextAreaControl.TextArea.IconBarMargin);
} catch (Exception ex) {
MessageService.ShowError(ex);
}
}
//
// void ParseInformationUpdatedInvoked(ParseInformation parseInfo)
// {
// try {
// textEditor.Document.FoldingManager.UpdateFoldings(file.FileName, parseInfo);
// textEditor.ActiveTextAreaControl.TextArea.Refresh(textEditor.ActiveTextAreaControl.TextArea.FoldMargin);
// textEditor.ActiveTextAreaControl.TextArea.Refresh(textEditor.ActiveTextAreaControl.TextArea.IconBarMargin);
// } catch (Exception ex) {
// MessageService.ShowError(ex);
// }
// }
string GetText()
{
return textEditor.Document.TextContent;
return textEditor.Document.Text;
}
void SetText(string value)
{
textEditor.Document.Replace(0, textEditor.Document.TextLength, value);
}
}
public ITextEditor TextEditor {
get { return adapter; }
}
public event EventHandler InfoTipChanged;
protected virtual void OnInfoTipChanged(EventArgs e)
{
if (InfoTipChanged != null) {
InfoTipChanged(this, e);
}
}
object IViewContent.Control {
get { return this.TextEditor; }
}
public object InitiallyFocusedControl {
get { return this.TextEditor; }
}
public string InfoTip {
get { return String.Empty; }
}
public bool CloseWithSolution {
get { return false; }
}
public object GetService(Type serviceType)
{
return null;
}
public void LoadFile(string fileName)
{
this.file = new SnippetFile(fileName);
adapter.LoadFile(fileName);
}
public void Save()
{
textEditor.Save(file.FileName);
}
void BookmarkManager_Removed(object sender, BookmarkEventArgs e)
{
iconBarManager.Bookmarks.Remove(e.Bookmark);
if (e.Bookmark.Document == adapter.Document) {
e.Bookmark.Document = null;
}
}
void BookmarkManager_Added(object sender, BookmarkEventArgs e)
{
if (FileUtility.IsEqualFileName(this.PrimaryFileName, e.Bookmark.FileName)) {
iconBarManager.Bookmarks.Add(e.Bookmark);
e.Bookmark.Document = adapter.Document;
}
}
}
}

37
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj

@ -38,8 +38,8 @@ @@ -38,8 +38,8 @@
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="Aga.Controls">
<HintPath>..\..\..\bin\Aga.Controls.dll</HintPath>
<Reference Include="ICSharpCode.AvalonEdit">
<HintPath>..\..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.Build.Tasks">
<HintPath>..\..\..\bin\ICSharpCode.Build.Tasks.dll</HintPath>
@ -59,46 +59,53 @@ @@ -59,46 +59,53 @@
<Reference Include="ICSharpCode.SharpDevelop.Sda">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.Sda.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.TextEditor">
<HintPath>..\..\..\bin\ICSharpCode.TextEditor.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\..\..\bin\log4net.dll</HintPath>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="BuildSnippetCommand.cs" />
<Compile Include="DelegateCommand.cs" />
<Compile Include="IconBarManager.cs" />
<Compile Include="IconBarMargin.cs" />
<Compile Include="MainViewContent.cs" />
<Compile Include="SharpSnippetCompilerControl.cs" />
<Compile Include="SharpSnippetCompilerControl.Designer.cs">
<DependentUpon>SharpSnippetCompilerControl.cs</DependentUpon>
</Compile>
<Compile Include="SharpSnippetCompilerManager.cs" />
<Compile Include="SharpSnippetProjectBinding.cs" />
<Compile Include="SharpSnippetTextEditorAdapter.cs" />
<Compile Include="SnippetCompilerProject.cs" />
<Compile Include="SnippetFile.cs" />
<Compile Include="StatusBarService.cs" />
<Compile Include="TextMarkerService.cs" />
<Compile Include="Workbench.cs" />
<Compile Include="WpfSynchronizeInvoke.cs" />
<EmbeddedResource Include="..\..\..\src\Main\StartUp\Project\Resources\BitmapResources.resources">
<Link>Resources\BitmapResources.resources</Link>
<LogicalName>Resources.BitmapResources.resources</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="..\..\..\src\Main\StartUp\Project\Resources\StringResources.resources">
<EmbeddedResource Include="..\..\..\data\Resources\StringResources.resx">
<Link>Resources\StringResources.resources</Link>
<LogicalName>Resources.StringResources.resources</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="SharpSnippetCompilerControl.resx">
<DependentUpon>SharpSnippetCompilerControl.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources" />

48
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.Designer.cs generated

@ -1,48 +0,0 @@ @@ -1,48 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// </file>
namespace ICSharpCode.SharpSnippetCompiler.Core
{
partial class SharpSnippetCompilerControl
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the control.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// SharpSnippetCompilerControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "SharpSnippetCompilerControl";
this.Size = new System.Drawing.Size(491, 310);
this.ResumeLayout(false);
}
}
}

51
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.cs

@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// </file>
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
public partial class SharpSnippetCompilerControl : UserControl
{
SharpDevelopTextAreaControl textEditor;
public SharpSnippetCompilerControl()
{
InitializeComponent();
textEditor = new SharpDevelopTextAreaControl();
textEditor.Dock = DockStyle.Fill;
this.Controls.Add(textEditor);
}
public TextEditorControl TextEditor {
get { return textEditor; }
}
public void LoadFile(string fileName)
{
textEditor.LoadFile(fileName);
}
public void Save()
{
textEditor.SaveFile(textEditor.FileName);
}
}
}

120
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.resx

@ -1,120 +0,0 @@ @@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

28
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetProjectBinding.cs

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
// 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 ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
public class SharpSnippetProjectBinding : IProjectBinding
{
public string Language{
get { return "C#"; }
}
public IProject LoadProject(ProjectLoadInformation loadInformation)
{
return new SnippetCompilerProject(loadInformation);
}
public IProject CreateProject(ProjectCreateInformation info)
{
return null;
}
public bool HandlingMissingProject { get; private set; }
}
}

33
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetTextEditorAdapter.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
// 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 ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
public class SharpSnippetTextEditorAdapter : AvalonEditTextEditorAdapter
{
FileName fileName;
public SharpSnippetTextEditorAdapter(TextEditor textEditor)
: base(textEditor)
{
}
public override FileName FileName {
get { return this.fileName; }
}
public void LoadFile(string fileName)
{
TextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(fileName));
TextEditor.Load(fileName);
this.fileName = new FileName(fileName);
}
}
}

64
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs

@ -24,10 +24,30 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -24,10 +24,30 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
"\t{\r\n" +
"\t}\r\n" +
"}";
SnippetCompilerProject() : base(new Solution())
public const string DefaultTargetsFile = @"$(MSBuildToolsPath)\Microsoft.CSharp.targets";
public SnippetCompilerProject(ProjectLoadInformation loadInformation)
: base(loadInformation)
{
}
SnippetCompilerProject()
: this(GetProjectCreateInfo())
{
Create();
}
SnippetCompilerProject(ProjectCreateInformation createInfo)
: base(createInfo)
{
this.Parent = createInfo.Solution;
this.AddImport(DefaultTargetsFile, null);
SetProperty("Debug", null, "CheckForOverflowUnderflow", "True", PropertyStorageLocations.ConfigurationSpecific, true);
SetProperty("Release", null, "CheckForOverflowUnderflow", "False", PropertyStorageLocations.ConfigurationSpecific, true);
SetProperty("Debug", null, "DefineConstants", "DEBUG;TRACE",PropertyStorageLocations.ConfigurationSpecific, false);
SetProperty("Release", null, "DefineConstants", "TRACE", PropertyStorageLocations.ConfigurationSpecific, false);
}
public static string SnippetFileName {
@ -46,27 +66,6 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -46,27 +66,6 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
get { return "C#"; }
}
public const string DefaultTargetsFile = @"$(MSBuildBinPath)\Microsoft.CSharp.Targets";
protected override void Create(ProjectCreateInformation information)
{
this.AddImport(DefaultTargetsFile, null);
// Add import before base.Create call - base.Create will call AddOrRemoveExtensions, which
// needs to change the import when the compact framework is targeted.
base.Create(information);
SetProperty("Debug", null, "CheckForOverflowUnderflow", "True",
PropertyStorageLocations.ConfigurationSpecific, true);
SetProperty("Release", null, "CheckForOverflowUnderflow", "False",
PropertyStorageLocations.ConfigurationSpecific, true);
SetProperty("Debug", null, "DefineConstants", "DEBUG;TRACE",
PropertyStorageLocations.ConfigurationSpecific, false);
SetProperty("Release", null, "DefineConstants", "TRACE",
PropertyStorageLocations.ConfigurationSpecific, false);
}
public override ItemType GetDefaultItemType(string fileName)
{
if (string.Equals(Path.GetExtension(fileName), ".cs", StringComparison.OrdinalIgnoreCase)) {
@ -80,17 +79,16 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -80,17 +79,16 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
{
CreateSnippetProject();
CreateSnippetFile();
ProjectService.LoadProject(SnippetProjectFileName);
ProjectService.LoadProject(SnippetProjectFileName);
}
void Create()
static ProjectCreateInformation GetProjectCreateInfo()
{
ProjectCreateInformation info = new ProjectCreateInformation();
info.Solution = new Solution();
info.OutputProjectFileName = Path.Combine(PropertyService.ConfigDirectory, "SharpSnippet.exe");
info.ProjectName = "SharpSnippet";
Create(info);
this.Parent = info.Solution;
return new ProjectCreateInformation {
Solution = new Solution(new ProjectChangeWatcher(String.Empty)),
OutputProjectFileName = Path.Combine(PropertyService.ConfigDirectory, "SharpSnippet.exe"),
ProjectName = "SharpSnippet"
};
}
/// <summary>
@ -100,7 +98,7 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -100,7 +98,7 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
{
string fileName = SnippetProjectFileName;
if (!File.Exists(fileName)) {
// Add single snippet file to project.
SnippetCompilerProject project = new SnippetCompilerProject();
FileProjectItem item = new FileProjectItem(project, ItemType.Compile, "Snippet.cs");

14
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetFile.cs

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
@ -16,8 +16,8 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -16,8 +16,8 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
{
public SnippetFile(string fileName)
{
this.FileName = fileName;
IsUntitled = false;
this.FileName = new FileName(fileName);
IsUntitled = false;
}
public override IList<IViewContent> RegisteredViewContents {
@ -36,5 +36,13 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -36,5 +36,13 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
throw new NotImplementedException();
}
public override event EventHandler FileClosed;
protected virtual void OnFileClosed(EventArgs e)
{
if (FileClosed != null) {
FileClosed(this, e);
}
}
}
}

54
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/StatusBarService.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
// SharpDevelop samples
// Copyright (c) 2013, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Threading;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
public class StatusBarService : IStatusBarService
{
public void SetCaretPosition(int x, int y, int charOffset)
{
}
public void SetMessage(string message, bool highlighted, ICSharpCode.SharpDevelop.IImage icon)
{
}
public IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken)
{
return new DummyProgressMonitor();
}
public void AddProgress(ProgressCollector progress)
{
}
}
}

306
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/TextMarkerService.cs

@ -0,0 +1,306 @@ @@ -0,0 +1,306 @@
// 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.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
/// <summary>
/// Handles the text markers for a code editor.
/// </summary>
public sealed class TextMarkerService : DocumentColorizingTransformer, IBackgroundRenderer, ITextMarkerService, ITextViewConnect
{
TextSegmentCollection<TextMarker> markers;
TextDocument document;
public TextMarkerService(TextDocument document)
{
if (document == null)
throw new ArgumentNullException("document");
this.document = document;
this.markers = new TextSegmentCollection<TextMarker>(document);
}
#region ITextMarkerService
public ITextMarker Create(int startOffset, int length)
{
if (markers == null)
throw new InvalidOperationException("Cannot create a marker when not attached to a document");
int textLength = document.TextLength;
if (startOffset < 0 || startOffset > textLength)
throw new ArgumentOutOfRangeException("startOffset", startOffset, "Value must be between 0 and " + textLength);
if (length < 0 || startOffset + length > textLength)
throw new ArgumentOutOfRangeException("length", length, "length must not be negative and startOffset+length must not be after the end of the document");
TextMarker m = new TextMarker(this, startOffset, length);
markers.Add(m);
// no need to mark segment for redraw: the text marker is invisible until a property is set
return m;
}
public IEnumerable<ITextMarker> GetMarkersAtOffset(int offset)
{
if (markers == null)
return Enumerable.Empty<ITextMarker>();
else
return markers.FindSegmentsContaining(offset);
}
public IEnumerable<ITextMarker> TextMarkers {
get { return markers ?? Enumerable.Empty<ITextMarker>(); }
}
public void RemoveAll(Predicate<ITextMarker> predicate)
{
if (predicate == null)
throw new ArgumentNullException("predicate");
if (markers != null) {
foreach (TextMarker m in markers.ToArray()) {
if (predicate(m))
Remove(m);
}
}
}
public void Remove(ITextMarker marker)
{
if (marker == null)
throw new ArgumentNullException("marker");
TextMarker m = marker as TextMarker;
if (markers != null && markers.Remove(m)) {
Redraw(m);
m.OnDeleted();
}
}
/// <summary>
/// Redraws the specified text segment.
/// </summary>
internal void Redraw(ISegment segment)
{
foreach (var view in textViews) {
view.Redraw(segment, DispatcherPriority.Normal);
}
}
#endregion
#region DocumentColorizingTransformer
protected override void ColorizeLine(DocumentLine line)
{
if (markers == null)
return;
int lineStart = line.Offset;
int lineEnd = lineStart + line.Length;
foreach (TextMarker marker in markers.FindOverlappingSegments(lineStart, line.Length)) {
Brush foregroundBrush = null;
if (marker.ForegroundColor != null) {
foregroundBrush = new SolidColorBrush(marker.ForegroundColor.Value);
foregroundBrush.Freeze();
}
ChangeLinePart(
Math.Max(marker.StartOffset, lineStart),
Math.Min(marker.EndOffset, lineEnd),
element => {
if (foregroundBrush != null) {
element.TextRunProperties.SetForegroundBrush(foregroundBrush);
}
}
);
}
}
#endregion
#region IBackgroundRenderer
public KnownLayer Layer {
get {
// draw behind selection
return KnownLayer.Selection;
}
}
public void Draw(TextView textView, DrawingContext drawingContext)
{
if (textView == null)
throw new ArgumentNullException("textView");
if (drawingContext == null)
throw new ArgumentNullException("drawingContext");
if (markers == null || !textView.VisualLinesValid)
return;
var visualLines = textView.VisualLines;
if (visualLines.Count == 0)
return;
int viewStart = visualLines.First().FirstDocumentLine.Offset;
int viewEnd = visualLines.Last().LastDocumentLine.EndOffset;
foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart)) {
if (marker.BackgroundColor != null) {
BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
geoBuilder.AlignToWholePixels = true;
geoBuilder.CornerRadius = 3;
geoBuilder.AddSegment(textView, marker);
Geometry geometry = geoBuilder.CreateGeometry();
if (geometry != null) {
Color color = marker.BackgroundColor.Value;
SolidColorBrush brush = new SolidColorBrush(color);
brush.Freeze();
drawingContext.DrawGeometry(brush, null, geometry);
}
}
if (marker.MarkerType != TextMarkerType.None) {
foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker)) {
Point startPoint = r.BottomLeft;
Point endPoint = r.BottomRight;
Pen usedPen = new Pen(new SolidColorBrush(marker.MarkerColor), 1);
usedPen.Freeze();
switch (marker.MarkerType) {
case TextMarkerType.SquigglyUnderline:
double offset = 2.5;
int count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4);
StreamGeometry geometry = new StreamGeometry();
using (StreamGeometryContext ctx = geometry.Open()) {
ctx.BeginFigure(startPoint, false, false);
ctx.PolyLineTo(CreatePoints(startPoint, endPoint, offset, count).ToArray(), true, false);
}
geometry.Freeze();
drawingContext.DrawGeometry(Brushes.Transparent, usedPen, geometry);
break;
}
}
}
}
}
IEnumerable<Point> CreatePoints(Point start, Point end, double offset, int count)
{
for (int i = 0; i < count; i++)
yield return new Point(start.X + i * offset, start.Y - ((i + 1) % 2 == 0 ? offset : 0));
}
#endregion
#region ITextViewConnect
readonly List<TextView> textViews = new List<TextView>();
void ITextViewConnect.AddToTextView(TextView textView)
{
if (textView != null && !textViews.Contains(textView)) {
Debug.Assert(textView.Document == document);
textViews.Add(textView);
}
}
void ITextViewConnect.RemoveFromTextView(TextView textView)
{
if (textView != null) {
Debug.Assert(textView.Document == document);
textViews.Remove(textView);
}
}
#endregion
}
public sealed class TextMarker : TextSegment, ITextMarker
{
readonly TextMarkerService service;
public TextMarker(TextMarkerService service, int startOffset, int length)
{
if (service == null)
throw new ArgumentNullException("service");
this.service = service;
this.StartOffset = startOffset;
this.Length = length;
this.markerType = TextMarkerType.None;
}
public event EventHandler Deleted;
public bool IsDeleted {
get { return !this.IsConnectedToCollection; }
}
public void Delete()
{
service.Remove(this);
}
internal void OnDeleted()
{
if (Deleted != null)
Deleted(this, EventArgs.Empty);
}
void Redraw()
{
service.Redraw(this);
}
Color? backgroundColor;
public Color? BackgroundColor {
get { return backgroundColor; }
set {
if (backgroundColor != value) {
backgroundColor = value;
Redraw();
}
}
}
Color? foregroundColor;
public Color? ForegroundColor {
get { return foregroundColor; }
set {
if (foregroundColor != value) {
foregroundColor = value;
Redraw();
}
}
}
public object Tag { get; set; }
TextMarkerType markerType;
public TextMarkerType MarkerType {
get { return markerType; }
set {
if (markerType != value) {
markerType = value;
Redraw();
}
}
}
Color markerColor;
public Color MarkerColor {
get { return markerColor; }
set {
if (markerColor != value) {
markerColor = value;
Redraw();
}
}
}
public object ToolTip { get; set; }
}
}

86
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/Workbench.cs

@ -1,7 +1,13 @@ @@ -1,7 +1,13 @@
// 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
@ -12,27 +18,23 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -12,27 +18,23 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
{
readonly static string viewContentPath = "/SharpDevelop/Workbench/Pads";
Form mainForm;
Window mainWindow;
List<PadDescriptor> padDescriptors = new List<PadDescriptor>();
List<IViewContent> views = new List<IViewContent>();
IWorkbenchLayout workbenchLayout;
IViewContent activeViewContent;
object activeContent;
StatusBarService statusBarService = new StatusBarService();
public event EventHandler ActiveWorkbenchWindowChanged;
public event EventHandler ActiveViewContentChanged;
public event EventHandler ActiveContentChanged;
public event ViewContentEventHandler ViewOpened;
public event EventHandler ActiveViewContentChanged;
public event EventHandler ActiveContentChanged;
public event ViewContentEventHandler ViewOpened;
public event ViewContentEventHandler ViewClosed;
public event KeyEventHandler ProcessCommandKey;
public Workbench(Form mainForm)
public Workbench(Window mainWindow)
{
this.mainForm = mainForm;
}
public Form MainForm {
get { return mainForm; }
this.mainWindow = mainWindow;
}
public string Title {
@ -95,16 +97,16 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -95,16 +97,16 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
OnViewOpened(new ViewContentEventArgs(content));
}
public void ShowPad(PadDescriptor content)
public void ShowView(IViewContent content, bool switchToOpenedView)
{
throw new NotImplementedException();
}
public void ShowView(IViewContent content, bool switchToOpenedView)
public void ShowPad(PadDescriptor content)
{
throw new NotImplementedException();
}
}
public void UnloadPad(PadDescriptor content)
{
throw new NotImplementedException();
@ -117,16 +119,7 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -117,16 +119,7 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
return pad;
}
}
return null;
}
public void CloseContent(IViewContent content)
{
if (views.Contains(content)) {
views.Remove(content);
}
content.Dispose();
return null;
}
public void CloseAllViews()
@ -134,11 +127,6 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -134,11 +127,6 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
throw new NotImplementedException();
}
public void RedrawAllComponents()
{
throw new NotImplementedException();
}
public Properties CreateMemento()
{
throw new NotImplementedException();
@ -149,21 +137,17 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -149,21 +137,17 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
Console.WriteLine("Workbench.SetMemento not implemented");
}
public void UpdateRenderer()
{
Console.WriteLine("Workbench.UpdateRenderer not implemented");
}
public void Initialize()
{
SynchronizingObject = new WpfSynchronizeInvoke(mainWindow.Dispatcher);
try {
ArrayList contents = AddInTree.GetTreeNode(viewContentPath).BuildChildItems(this);
List<PadDescriptor> contents = AddInTree.GetTreeNode(viewContentPath).BuildChildItems<PadDescriptor>(this);
foreach (PadDescriptor content in contents) {
if (content != null) {
padDescriptors.Add(content);
}
}
} catch (TreePathNotFoundException) {}
} catch (TreePathNotFoundException) {}
}
protected virtual void OnActiveWorkbenchWindowChanged(EventArgs e)
@ -200,12 +184,28 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -200,12 +184,28 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
ViewClosed(this, e);
}
}
protected virtual void OnProcessCommandKey(KeyEventArgs e)
{
if (ProcessCommandKey != null) {
ProcessCommandKey(this, e);
public IWin32Window MainWin32Window {
get {
throw new NotImplementedException();
}
}
}
public ISynchronizeInvoke SynchronizingObject { get; private set; }
public Window MainWindow {
get { return mainWindow; }
}
public IStatusBarService StatusBar {
get { return statusBarService; }
}
public bool FullScreen { get; set; }
public bool CloseAllSolutionViews()
{
return true;
}
}
}

122
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/WpfSynchronizeInvoke.cs

@ -0,0 +1,122 @@ @@ -0,0 +1,122 @@
// 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.ComponentModel;
using System.Reflection;
using System.Threading;
using System.Windows.Threading;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.SharpSnippetCompiler.Core
{
/// <summary>
/// Implements the ISynchronizeInvoke interface by using a WPF dispatcher
/// to perform the cross-thread call.
/// </summary>
sealed class WpfSynchronizeInvoke : ISynchronizeInvoke
{
readonly Dispatcher dispatcher;
public WpfSynchronizeInvoke(Dispatcher dispatcher)
{
if (dispatcher == null)
throw new ArgumentNullException("dispatcher");
this.dispatcher = dispatcher;
}
public bool InvokeRequired {
get {
return !dispatcher.CheckAccess();
}
}
public IAsyncResult BeginInvoke(Delegate method, object[] args)
{
DispatcherOperation op;
if (args == null || args.Length == 0)
op = dispatcher.BeginInvoke(DispatcherPriority.Normal, method);
else if (args.Length == 1)
op = dispatcher.BeginInvoke(DispatcherPriority.Normal, method, args[0]);
else
op = dispatcher.BeginInvoke(DispatcherPriority.Normal, method, args[0], args.Splice(1));
return new AsyncResult(op);
}
sealed class AsyncResult : IAsyncResult
{
internal readonly DispatcherOperation op;
readonly object lockObj = new object();
ManualResetEvent resetEvent;
public AsyncResult(DispatcherOperation op)
{
this.op = op;
}
public bool IsCompleted {
get {
return op.Status == DispatcherOperationStatus.Completed;
}
}
public WaitHandle AsyncWaitHandle {
get {
lock (lockObj) {
if (resetEvent == null) {
op.Completed += op_Completed;
resetEvent = new ManualResetEvent(false);
if (IsCompleted)
resetEvent.Set();
}
return resetEvent;
}
}
}
void op_Completed(object sender, EventArgs e)
{
lock (lockObj) {
resetEvent.Set();
}
}
public object AsyncState {
get { return null; }
}
public bool CompletedSynchronously {
get { return false; }
}
}
public object EndInvoke(IAsyncResult result)
{
AsyncResult r = result as AsyncResult;
if (r == null)
throw new ArgumentException("result must be the return value of a WpfSynchronizeInvoke.BeginInvoke call!");
r.op.Wait();
return r.op.Result;
}
public object Invoke(Delegate method, object[] args)
{
object result = null;
Exception exception = null;
dispatcher.Invoke(
DispatcherPriority.Normal,
(Action)delegate {
try {
result = method.DynamicInvoke(args);
} catch (TargetInvocationException ex) {
exception = ex.InnerException;
}
});
// if an exception occurred, re-throw it on the calling thread
if (exception != null)
throw new TargetInvocationException(exception);
return result;
}
}
}

2
samples/SharpSnippetCompiler/SharpSnippetCompiler.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.5584
# SharpDevelop 4.3
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSnippetCompiler", "SharpSnippetCompiler\SharpSnippetCompiler.csproj", "{A63633B4-2C31-4CFF-B2A3-92EAB1AB448E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSnippetCompiler.Core", "SharpSnippetCompiler.Core\SharpSnippetCompiler.Core.csproj", "{5A2EC8F7-2274-4EA3-AC7A-6D1C8598F938}"

100
samples/SharpSnippetCompiler/SharpSnippetCompiler/AddIns/SharpSnippetCompiler.addin

@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
<AddIn name = "SharpSnippetCompiler"
author = ""
copyright = "prj:///doc/copyright.txt"
url = "http://www.icsharpcode.net"
description = "SharpSnippetCompiler main module"
addInManagerHidden = "true">
<Manifest>
<Identity name="SharpSnippetCompiler" version="0.1"/>
</Manifest>
<Runtime>
<Import assembly=":ICSharpCode.SharpDevelop">
<Doozer name="Pad" class="ICSharpCode.SharpDevelop.PadDoozer"/>
<Doozer name="ProjectBinding" class="ICSharpCode.SharpDevelop.ProjectBindingDoozer"/>
<Doozer name="Parser" class="ICSharpCode.SharpDevelop.ParserDoozer"/>
<Doozer name="Debugger" class="ICSharpCode.SharpDevelop.Debugging.DebuggerDoozer"/>
</Import>
<Import assembly=":SharpSnippetCompiler.Core"/>
</Runtime>
<Path name="/SharpDevelop/Workbench/DisplayBindings">
</Path>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "CompilerMessageView"
category = "Main"
title = "${res:MainWindow.Windows.OutputWindow}"
icon = "PadIcons.Output"
class = "ICSharpCode.SharpDevelop.Gui.CompilerMessageView"
defaultPosition = "Bottom" />
<Pad id = "ErrorList"
category = "Main"
title = "${res:MainWindow.Windows.ErrorList}"
icon = "PadIcons.ErrorList"
class = "ICSharpCode.SharpDevelop.Gui.ErrorListPad"
defaultPosition = "Bottom" />
</Path>
<Path name="/SharpDevelop/Pads/ErrorList/Toolbar">
</Path>
<Path name="/SharpDevelop/Pads/CompilerMessageView/Toolbar">
</Path>
<Path path = "/SharpDevelop/Workbench/ProjectBindings">
<ProjectBinding id = "C#"
guid = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
supportedextensions = ".cs"
projectfileextension = ".csproj"
class = "ICSharpCode.SharpSnippetCompiler.Core.SharpSnippetProjectBinding" />
</Path>
<Path name = "/SharpDevelop/Pads/ErrorList/Toolbar">
<ToolbarItem id = "Errors"
type = "CheckBox"
icon = "Icons.16x16.Error"
label = "${res:MainWindow.Windows.ErrorList.ErrorButton.Label}"
tooltip = "${res:MainWindow.Windows.ErrorList.ErrorButton.ToolTip}"
class = "ICSharpCode.SharpDevelop.Gui.ShowErrorsToggleButton"/>
<ToolbarItem id = "ErrorsSeparator" type = "Separator"/>
<ToolbarItem id = "Warnings"
type = "CheckBox"
icon = "Icons.16x16.Warning"
label = "${res:MainWindow.Windows.ErrorList.WarningButton.Label}"
tooltip = "${res:MainWindow.Windows.ErrorList.WarningButton.ToolTip}"
class = "ICSharpCode.SharpDevelop.Gui.ShowWarningsToggleButton"/>
<ToolbarItem id = "WarningsSeparator" type = "Separator"/>
<ToolbarItem id = "Messages"
type = "CheckBox"
icon = "Icons.16x16.Information"
label = "${res:MainWindow.Windows.ErrorList.MessageButton.Label}"
tooltip = "${res:MainWindow.Windows.ErrorList.MessageButton.ToolTip}"
class = "ICSharpCode.SharpDevelop.Gui.ShowMessagesToggleButton"/>
</Path>
<Path name = "/SharpDevelop/Pads/CompilerMessageView/Toolbar">
<ToolbarItem id = "CategorySelect"
type = "ComboBox"
tooltip = "${res:MainWindow.Windows.CompilerMessageView.ShowOutputFromComboBox.ToolTip}"
class = "ICSharpCode.SharpDevelop.Gui.ShowOutputFromComboBox"/>
<ToolbarItem id = "CategorySelectSeparator" type = "Separator"/>
<ToolbarItem id = "Clear"
icon = "OutputPad.Toolbar.ClearOutputWindow"
tooltip = "${res:MainWindow.Windows.CompilerMessageView.ClearAllButton.ToolTip}"
class = "ICSharpCode.SharpDevelop.Gui.ClearOutputWindow"/>
<ToolbarItem id = "ToggleWordWrap"
type = "CheckBox"
icon = "OutputPad.Toolbar.ToggleWordWrap"
tooltip = "${res:MainWindow.Windows.CompilerMessageView.ToggleWordWrapButton.ToolTip}"
class = "ICSharpCode.SharpDevelop.Gui.ToggleMessageViewWordWrap"/>
</Path>
</AddIn>

7
samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
<Application x:Class="ICSharpCode.SharpSnippetCompiler.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

37
samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml.cs

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
// SharpDevelop samples
// Copyright (c) 2013, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Windows;
namespace ICSharpCode.SharpSnippetCompiler
{
public partial class App : Application
{
}
}

458
samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.Designer.cs generated

@ -1,458 +0,0 @@ @@ -1,458 +0,0 @@
// SharpDevelop samples
// Copyright (c) 2008, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace ICSharpCode.SharpSnippetCompiler
{
partial class MainForm
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.mainMenuStrip = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fileNewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fileOpenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fileCloseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fileExitToolStripSeparator = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.redoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.redoSeparatorToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator();
this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.selectAllSeparatorToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator();
this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buildtoolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buildCurrentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.runToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.stopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.continueSeparatorToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator();
this.continueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.stepSeparatorToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator();
this.stepOverToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.stepIntoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.stepOutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.referencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.fileTabControl = new System.Windows.Forms.TabControl();
this.tabControl = new System.Windows.Forms.TabControl();
this.errorsTabPage = new System.Windows.Forms.TabPage();
this.outputTabPage = new System.Windows.Forms.TabPage();
this.mainMenuStrip.SuspendLayout();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
this.tabControl.SuspendLayout();
this.SuspendLayout();
//
// mainMenuStrip
//
this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.editToolStripMenuItem,
this.buildtoolStripMenuItem,
this.debugToolStripMenuItem,
this.toolsToolStripMenuItem});
this.mainMenuStrip.Location = new System.Drawing.Point(0, 0);
this.mainMenuStrip.Name = "mainMenuStrip";
this.mainMenuStrip.Size = new System.Drawing.Size(757, 24);
this.mainMenuStrip.TabIndex = 0;
this.mainMenuStrip.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileNewToolStripMenuItem,
this.fileOpenToolStripMenuItem,
this.fileCloseToolStripMenuItem,
this.fileExitToolStripSeparator,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "&File";
//
// fileNewToolStripMenuItem
//
this.fileNewToolStripMenuItem.Name = "fileNewToolStripMenuItem";
this.fileNewToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.fileNewToolStripMenuItem.Text = "&New...";
this.fileNewToolStripMenuItem.Click += new System.EventHandler(this.FileNewToolStripMenuItemClick);
//
// fileOpenToolStripMenuItem
//
this.fileOpenToolStripMenuItem.Name = "fileOpenToolStripMenuItem";
this.fileOpenToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.fileOpenToolStripMenuItem.Text = "&Open...";
this.fileOpenToolStripMenuItem.Click += new System.EventHandler(this.FileOpenToolStripMenuItemClick);
//
// fileCloseToolStripMenuItem
//
this.fileCloseToolStripMenuItem.Name = "fileCloseToolStripMenuItem";
this.fileCloseToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.fileCloseToolStripMenuItem.Text = "&Close";
this.fileCloseToolStripMenuItem.Click += new System.EventHandler(this.FileCloseToolStripMenuItemClick);
//
// fileExitToolStripSeparator
//
this.fileExitToolStripSeparator.Name = "fileExitToolStripSeparator";
this.fileExitToolStripSeparator.Size = new System.Drawing.Size(149, 6);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolStripMenuItemClick);
//
// editToolStripMenuItem
//
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.undoToolStripMenuItem,
this.redoToolStripMenuItem,
this.redoSeparatorToolStripMenuItem,
this.cutToolStripMenuItem,
this.copyToolStripMenuItem,
this.pasteToolStripMenuItem,
this.deleteToolStripMenuItem,
this.selectAllSeparatorToolStripMenuItem,
this.selectAllToolStripMenuItem});
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this.editToolStripMenuItem.Text = "&Edit";
//
// undoToolStripMenuItem
//
this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
this.undoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));
this.undoToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
this.undoToolStripMenuItem.Text = "&Undo";
this.undoToolStripMenuItem.Click += new System.EventHandler(this.UndoToolStripMenuItemClick);
//
// redoToolStripMenuItem
//
this.redoToolStripMenuItem.Name = "redoToolStripMenuItem";
this.redoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y)));
this.redoToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
this.redoToolStripMenuItem.Text = "&Redo";
this.redoToolStripMenuItem.Click += new System.EventHandler(this.RedoToolStripMenuItemClick);
//
// redoSeparatorToolStripMenuItem
//
this.redoSeparatorToolStripMenuItem.Name = "redoSeparatorToolStripMenuItem";
this.redoSeparatorToolStripMenuItem.Size = new System.Drawing.Size(161, 6);
//
// cutToolStripMenuItem
//
this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X)));
this.cutToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
this.cutToolStripMenuItem.Text = "Cu&t";
this.cutToolStripMenuItem.Click += new System.EventHandler(this.CutToolStripMenuItemClick);
//
// copyToolStripMenuItem
//
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this.copyToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
this.copyToolStripMenuItem.Text = "&Copy";
this.copyToolStripMenuItem.Click += new System.EventHandler(this.CopyToolStripMenuItemClick);
//
// pasteToolStripMenuItem
//
this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V)));
this.pasteToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
this.pasteToolStripMenuItem.Text = "&Paste";
this.pasteToolStripMenuItem.Click += new System.EventHandler(this.PasteToolStripMenuItemClick);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
this.deleteToolStripMenuItem.Text = "&Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItemClick);
//
// selectAllSeparatorToolStripMenuItem
//
this.selectAllSeparatorToolStripMenuItem.Name = "selectAllSeparatorToolStripMenuItem";
this.selectAllSeparatorToolStripMenuItem.Size = new System.Drawing.Size(161, 6);
//
// selectAllToolStripMenuItem
//
this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem";
this.selectAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
this.selectAllToolStripMenuItem.Text = "Select &All";
this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.SelectAllToolStripMenuItemClick);
//
// buildtoolStripMenuItem
//
this.buildtoolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.buildCurrentToolStripMenuItem});
this.buildtoolStripMenuItem.Name = "buildtoolStripMenuItem";
this.buildtoolStripMenuItem.Size = new System.Drawing.Size(46, 20);
this.buildtoolStripMenuItem.Text = "&Build";
//
// buildCurrentToolStripMenuItem
//
this.buildCurrentToolStripMenuItem.Name = "buildCurrentToolStripMenuItem";
this.buildCurrentToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.B)));
this.buildCurrentToolStripMenuItem.Size = new System.Drawing.Size(217, 22);
this.buildCurrentToolStripMenuItem.Text = "&Build Current";
this.buildCurrentToolStripMenuItem.Click += new System.EventHandler(this.BuildCurrentToolStripMenuItemClick);
//
// debugToolStripMenuItem
//
this.debugToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.runToolStripMenuItem,
this.stopToolStripMenuItem,
this.continueSeparatorToolStripMenuItem,
this.continueToolStripMenuItem,
this.stepSeparatorToolStripMenuItem,
this.stepOverToolStripMenuItem,
this.stepIntoToolStripMenuItem,
this.stepOutToolStripMenuItem});
this.debugToolStripMenuItem.Name = "debugToolStripMenuItem";
this.debugToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
this.debugToolStripMenuItem.Text = "&Debug";
//
// runToolStripMenuItem
//
this.runToolStripMenuItem.Name = "runToolStripMenuItem";
this.runToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F5;
this.runToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.runToolStripMenuItem.Text = "&Run";
this.runToolStripMenuItem.Click += new System.EventHandler(this.RunToolStripMenuItemClick);
//
// stopToolStripMenuItem
//
this.stopToolStripMenuItem.Name = "stopToolStripMenuItem";
this.stopToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.stopToolStripMenuItem.Text = "St&op";
this.stopToolStripMenuItem.Click += new System.EventHandler(this.StopToolStripMenuItemClick);
//
// continueSeparatorToolStripMenuItem
//
this.continueSeparatorToolStripMenuItem.Name = "continueSeparatorToolStripMenuItem";
this.continueSeparatorToolStripMenuItem.Size = new System.Drawing.Size(174, 6);
//
// continueToolStripMenuItem
//
this.continueToolStripMenuItem.Name = "continueToolStripMenuItem";
this.continueToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F6;
this.continueToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.continueToolStripMenuItem.Text = "&Continue";
this.continueToolStripMenuItem.Click += new System.EventHandler(this.ContinueToolStripMenuItemClick);
//
// stepSeparatorToolStripMenuItem
//
this.stepSeparatorToolStripMenuItem.Name = "stepSeparatorToolStripMenuItem";
this.stepSeparatorToolStripMenuItem.Size = new System.Drawing.Size(174, 6);
//
// stepOverToolStripMenuItem
//
this.stepOverToolStripMenuItem.Name = "stepOverToolStripMenuItem";
this.stepOverToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F10;
this.stepOverToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.stepOverToolStripMenuItem.Text = "Step O&ver";
this.stepOverToolStripMenuItem.Click += new System.EventHandler(this.StepOverToolStripMenuItemClick);
//
// stepIntoToolStripMenuItem
//
this.stepIntoToolStripMenuItem.Name = "stepIntoToolStripMenuItem";
this.stepIntoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F11;
this.stepIntoToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.stepIntoToolStripMenuItem.Text = "Step &Into";
this.stepIntoToolStripMenuItem.Click += new System.EventHandler(this.StepIntoToolStripMenuItemClick);
//
// stepOutToolStripMenuItem
//
this.stepOutToolStripMenuItem.Name = "stepOutToolStripMenuItem";
this.stepOutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.F11)));
this.stepOutToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.stepOutToolStripMenuItem.Text = "Step O&ut";
this.stepOutToolStripMenuItem.Click += new System.EventHandler(this.StepOutToolStripMenuItemClick);
//
// toolsToolStripMenuItem
//
this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.referencesToolStripMenuItem});
this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";
this.toolsToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this.toolsToolStripMenuItem.Text = "&Tools";
//
// referencesToolStripMenuItem
//
this.referencesToolStripMenuItem.Name = "referencesToolStripMenuItem";
this.referencesToolStripMenuItem.Size = new System.Drawing.Size(140, 22);
this.referencesToolStripMenuItem.Text = "&References...";
this.referencesToolStripMenuItem.Click += new System.EventHandler(this.ReferencesToolStripMenuItemClick);
//
// splitContainer
//
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer.Location = new System.Drawing.Point(0, 24);
this.splitContainer.Name = "splitContainer";
this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer.Panel1
//
this.splitContainer.Panel1.Controls.Add(this.fileTabControl);
//
// splitContainer.Panel2
//
this.splitContainer.Panel2.Controls.Add(this.tabControl);
this.splitContainer.Size = new System.Drawing.Size(757, 349);
this.splitContainer.SplitterDistance = 225;
this.splitContainer.TabIndex = 1;
//
// fileTabControl
//
this.fileTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.fileTabControl.Location = new System.Drawing.Point(0, 0);
this.fileTabControl.Name = "fileTabControl";
this.fileTabControl.SelectedIndex = 0;
this.fileTabControl.Size = new System.Drawing.Size(757, 225);
this.fileTabControl.TabIndex = 0;
this.fileTabControl.SelectedIndexChanged += new System.EventHandler(this.FileTabControlSelectedIndexChanged);
//
// tabControl
//
this.tabControl.Controls.Add(this.errorsTabPage);
this.tabControl.Controls.Add(this.outputTabPage);
this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl.Location = new System.Drawing.Point(0, 0);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(757, 120);
this.tabControl.TabIndex = 0;
//
// errorsTabPage
//
this.errorsTabPage.Location = new System.Drawing.Point(4, 22);
this.errorsTabPage.Name = "errorsTabPage";
this.errorsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.errorsTabPage.Size = new System.Drawing.Size(749, 94);
this.errorsTabPage.TabIndex = 0;
this.errorsTabPage.Text = "Errors";
this.errorsTabPage.UseVisualStyleBackColor = true;
//
// outputTabPage
//
this.outputTabPage.Location = new System.Drawing.Point(4, 22);
this.outputTabPage.Name = "outputTabPage";
this.outputTabPage.Padding = new System.Windows.Forms.Padding(3);
this.outputTabPage.Size = new System.Drawing.Size(749, 94);
this.outputTabPage.TabIndex = 1;
this.outputTabPage.Text = "Output";
this.outputTabPage.UseVisualStyleBackColor = true;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(757, 373);
this.Controls.Add(this.splitContainer);
this.Controls.Add(this.mainMenuStrip);
this.MainMenuStrip = this.mainMenuStrip;
this.Name = "MainForm";
this.Text = "SharpSnippetCompiler";
this.mainMenuStrip.ResumeLayout(false);
this.mainMenuStrip.PerformLayout();
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
this.splitContainer.ResumeLayout(false);
this.tabControl.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.ToolStripSeparator fileExitToolStripSeparator;
private System.Windows.Forms.ToolStripMenuItem fileCloseToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fileOpenToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fileNewToolStripMenuItem;
private System.Windows.Forms.TabControl fileTabControl;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator redoSeparatorToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator selectAllSeparatorToolStripMenuItem;
private System.Windows.Forms.TabPage outputTabPage;
private System.Windows.Forms.TabPage errorsTabPage;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.SplitContainer splitContainer;
private System.Windows.Forms.ToolStripMenuItem referencesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem redoToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem undoToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem stepOutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem stepIntoToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem stepOverToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator stepSeparatorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem continueToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator continueSeparatorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem stopToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem buildCurrentToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem buildtoolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem runToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.MenuStrip mainMenuStrip;
}
}

378
samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.cs

@ -1,378 +0,0 @@ @@ -1,378 +0,0 @@
// SharpDevelop samples
// Copyright (c) 2010, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Commands;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Project.Commands;
using ICSharpCode.SharpSnippetCompiler.Core;
using ICSharpCode.TextEditor;
namespace ICSharpCode.SharpSnippetCompiler
{
public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
}
public Control ErrorList {
get {
if (errorsTabPage.Controls.Count > 0) {
return errorsTabPage.Controls[0];
}
return null;
}
set {
errorsTabPage.Controls.Clear();
value.Dock = DockStyle.Fill;
errorsTabPage.Controls.Add(value);
}
}
public Control OutputList {
get {
if (outputTabPage.Controls.Count > 0) {
return outputTabPage.Controls[0];
}
return null;
}
set {
outputTabPage.Controls.Clear();
value.Dock = DockStyle.Fill;
outputTabPage.Controls.Add(value);
}
}
/// <summary>
/// Gets the active text editor control.
/// </summary>
public TextEditorControl TextEditor {
get {
return ActiveSnippetTabPage.SnippetCompilerControl.TextEditor;
}
}
public SnippetTabPage ActiveSnippetTabPage {
get { return fileTabControl.SelectedTab as SnippetTabPage; }
}
public IViewContent LoadFile(string fileName)
{
// Create a new tab page.
SharpSnippetCompilerControl snippetControl = new SharpSnippetCompilerControl();
snippetControl.Dock = DockStyle.Fill;
SnippetTabPage tabPage = new SnippetTabPage(snippetControl);
tabPage.Text = Path.GetFileName(fileName);
fileTabControl.TabPages.Add(tabPage);
// Load file
snippetControl.LoadFile(fileName);
snippetControl.Focus();
WorkbenchWindow window = new WorkbenchWindow(fileTabControl, tabPage);
MainViewContent view = new MainViewContent(fileName, snippetControl, window);
WorkbenchSingleton.Workbench.ShowView(view);
UpdateActiveView(view);
return view;
}
public void ActivateErrorList()
{
tabControl.SelectedIndex = 0;
}
public void ActivateOutputList()
{
tabControl.SelectedIndex = 1;
}
void ExitToolStripMenuItemClick(object sender, EventArgs e)
{
SaveAll();
Close();
}
void BuildCurrentToolStripMenuItemClick(object sender, EventArgs e)
{
SaveAll();
BuildSnippetCommand buildSnippet = new BuildSnippetCommand(ProjectService.CurrentProject);
buildSnippet.Run();
}
void RunToolStripMenuItemClick(object sender, EventArgs e)
{
SaveAll();
Execute execute = new Execute();
execute.Run();
}
void ContinueToolStripMenuItemClick(object sender, EventArgs e)
{
ContinueDebuggingCommand continueCommand = new ContinueDebuggingCommand();
continueCommand.Run();
}
void StepOverToolStripMenuItemClick(object sender, EventArgs e)
{
StepDebuggingCommand stepCommand = new StepDebuggingCommand();
stepCommand.Run();
}
void StepIntoToolStripMenuItemClick(object sender, EventArgs e)
{
StepIntoDebuggingCommand stepCommand = new StepIntoDebuggingCommand();
stepCommand.Run();
}
void StepOutToolStripMenuItemClick(object sender, EventArgs e)
{
StepOutDebuggingCommand stepCommand = new StepOutDebuggingCommand();
stepCommand.Run();
}
void StopToolStripMenuItemClick(object sender, EventArgs e)
{
StopDebuggingCommand stopCommand = new StopDebuggingCommand();
stopCommand.Run();
}
void UndoToolStripMenuItemClick(object sender, EventArgs e)
{
Undo undo = new Undo();
undo.Run();
}
void RedoToolStripMenuItemClick(object sender, EventArgs e)
{
Redo redo = new Redo();
redo.Run();
}
void CutToolStripMenuItemClick(object sender, EventArgs e)
{
Cut cut = new Cut();
cut.Run();
}
void CopyToolStripMenuItemClick(object sender, EventArgs e)
{
Copy copy = new Copy();
copy.Run();
}
void PasteToolStripMenuItemClick(object sender, EventArgs e)
{
Paste paste = new Paste();
paste.Run();
}
void DeleteToolStripMenuItemClick(object sender, EventArgs e)
{
Delete delete = new Delete();
delete.Run();
}
void SelectAllToolStripMenuItemClick(object sender, EventArgs e)
{
SelectAll selectAll = new SelectAll();
selectAll.Run();
}
void ReferencesToolStripMenuItemClick(object sender, EventArgs e)
{
IProject project = ProjectService.CurrentProject;
using (SelectReferenceDialog referenceDialog = new SelectReferenceDialog(project)) {
// Add existing project references to dialog.
List<ReferenceProjectItem> references = GetReferences(project);
AddReferences(referenceDialog as ISelectReferenceDialog, references);
DialogResult result = referenceDialog.ShowDialog();
if (result == DialogResult.OK) {
ArrayList selectedReferences = referenceDialog.ReferenceInformations;
// Remove any references removed in the select reference dialog.
foreach (ReferenceProjectItem existingReference in references) {
if (!selectedReferences.Contains(existingReference)) {
ProjectService.RemoveProjectItem(project, existingReference);
}
}
// Add new references.
foreach (ReferenceProjectItem reference in referenceDialog.ReferenceInformations) {
ProjectService.AddProjectItem(project, reference);
}
project.Save();
}
}
}
List<ReferenceProjectItem> GetReferences(IProject project)
{
List<ReferenceProjectItem> references = new List<ReferenceProjectItem>();
foreach (ProjectItem item in project.Items) {
ReferenceProjectItem reference = item as ReferenceProjectItem;
if (reference != null) {
references.Add(reference);
}
}
return references;
}
void AddReferences(ISelectReferenceDialog dialog, List<ReferenceProjectItem> references)
{
foreach (ReferenceProjectItem reference in references) {
dialog.AddReference(reference.Include, "Gac", reference.FileName, reference);
}
}
void UpdateActiveView(IViewContent view)
{
Workbench workbench = WorkbenchSingleton.Workbench as Workbench;
workbench.ActiveViewContent = view;
workbench.ActiveContent = view;
}
void FileTabControlSelectedIndexChanged(object sender, EventArgs e)
{
UpdateActiveView();
}
void UpdateActiveView()
{
if (ActiveSnippetTabPage != null) {
SharpSnippetCompilerControl control = ActiveSnippetTabPage.SnippetCompilerControl;
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) {
if (view.Control == control) {
UpdateActiveView(view);
return;
}
}
} else {
UpdateActiveView(null);
}
}
void SaveAll()
{
foreach (SnippetTabPage tabPage in fileTabControl.TabPages) {
tabPage.SnippetCompilerControl.Save();
}
}
void FileNewToolStripMenuItemClick(object sender, EventArgs e)
{
using (NewFileDialog dialog = new NewFileDialog()) {
dialog.FileName = GetNewFileName();
if (dialog.ShowDialog() == DialogResult.OK) {
string fileName = dialog.FileName;
using (StreamWriter file = File.CreateText(fileName)) {
file.Write(String.Empty);
}
LoadFile(fileName);
AddFileToProject(fileName);
}
}
}
string GetNewFileName()
{
string fileName = SnippetCompilerProject.GetFullFileName("Snippet1.cs");
string baseFolder = Path.GetDirectoryName(fileName);
int count = 1;
while (File.Exists(fileName)) {
count++;
fileName = Path.Combine(baseFolder, "Snippet" + count.ToString() + ".cs");
}
return fileName;
}
void FileOpenToolStripMenuItemClick(object sender, EventArgs e)
{
using (OpenFileDialog dialog = new OpenFileDialog()) {
dialog.CheckFileExists = true;
if (dialog.ShowDialog() == DialogResult.OK) {
foreach (string fileName in dialog.FileNames) {
LoadFile(fileName);
AddFileToProject(fileName);
}
}
}
}
void AddFileToProject(string fileName)
{
IProject project = ProjectService.CurrentProject;
FileProjectItem item = new FileProjectItem(project, ItemType.Compile, fileName);
ProjectService.AddProjectItem(project, item);
project.Save();
}
void FileCloseToolStripMenuItemClick(object sender, EventArgs e)
{
SnippetTabPage activeTabPage = ActiveSnippetTabPage;
if (activeTabPage != null) {
SharpSnippetCompilerControl snippetControl = activeTabPage.SnippetCompilerControl;
snippetControl.Save();
string fileName = ActiveSnippetTabPage.SnippetCompilerControl.TextEditor.FileName;
IProject project = ProjectService.CurrentProject;
FileProjectItem item = project.FindFile(fileName);
if (item != null) {
ProjectService.RemoveProjectItem(project, item);
project.Save();
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) {
if (view.Control == snippetControl) {
WorkbenchSingleton.Workbench.CloseContent(view);
break;
}
}
fileTabControl.TabPages.Remove(activeTabPage);
activeTabPage.Dispose();
}
}
}
}
}

123
samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.resx

@ -1,123 +0,0 @@ @@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

315
samples/SharpSnippetCompiler/SharpSnippetCompiler/MainViewModel.cs

@ -0,0 +1,315 @@ @@ -0,0 +1,315 @@
// SharpDevelop samples
// Copyright (c) 2013, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Project.Commands;
using ICSharpCode.SharpSnippetCompiler.Core;
using Microsoft.Win32;
namespace ICSharpCode.SharpSnippetCompiler
{
public class MainViewModel : INotifyPropertyChanged
{
ObservableCollection<MainViewContent> files = new ObservableCollection<MainViewContent>();
ObservableCollection<PadViewModel> pads = new ObservableCollection<PadViewModel>();
public MainViewModel()
{
ExitCommand = new DelegateCommand(param => Exit());
NewFileCommand = new DelegateCommand(param => NewFile());
BuildCurrentCommand = new DelegateCommand(param => BuildCurrentProject());
RunCommand = new DelegateCommand(param => Run());
StopCommand = new DelegateCommand(param => StopDebugging());
ContinueCommand = new DelegateCommand(param => ContinueDebugging());
StepOverCommand = new DelegateCommand(param => StepOver());
StepIntoCommand = new DelegateCommand(param => StepInto());
StepOutCommand = new DelegateCommand(param => StepOut());
AddReferencesCommand = new DelegateCommand(param => AddReferences());
OpenFileCommand = new DelegateCommand(param => OpenFile());
CloseFileCommand = new DelegateCommand(param => CloseFile());
}
public ICommand ExitCommand { get; private set; }
public ICommand NewFileCommand { get; private set; }
public ICommand BuildCurrentCommand { get; private set; }
public ICommand RunCommand { get; private set; }
public ICommand StopCommand { get; private set; }
public ICommand ContinueCommand { get; private set; }
public ICommand StepOverCommand { get; private set; }
public ICommand StepIntoCommand { get; private set; }
public ICommand StepOutCommand { get; private set; }
public ICommand AddReferencesCommand { get; private set; }
public ICommand OpenFileCommand { get; private set; }
public ICommand CloseFileCommand { get; private set; }
public ObservableCollection<MainViewContent> Files {
get { return files; }
}
public ObservableCollection<PadViewModel> Pads {
get { return pads; }
}
public MainViewContent SelectedFile { get; set; }
public void AddInitialPads()
{
AddPad(typeof(ErrorListPad));
AddPad(typeof(CompilerMessageView));
}
void AddPad(Type type)
{
PadDescriptor descriptor = WorkbenchSingleton.Workbench.GetPad(type);
Pads.Add(new PadViewModel(descriptor));
}
public IViewContent LoadFile(string fileName)
{
var window = new WorkbenchWindow();
var view = new MainViewContent(fileName, window);
WorkbenchSingleton.Workbench.ShowView(view);
UpdateActiveView(view);
files.Add(view);
return view;
}
void UpdateActiveView(IViewContent view)
{
Workbench workbench = WorkbenchSingleton.Workbench as Workbench;
workbench.ActiveViewContent = view;
workbench.ActiveContent = view;
}
void Exit()
{
SaveAll();
Application.Current.Shutdown();
}
void SaveAll()
{
foreach (MainViewContent view in files) {
view.Save();
}
}
void NewFile()
{
using (var dialog = new NewFileDialog()) {
dialog.FileName = GetNewFileName();
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
string fileName = dialog.FileName;
using (StreamWriter file = File.CreateText(fileName)) {
file.Write(String.Empty);
}
LoadFile(fileName);
AddFileToProject(fileName);
}
}
}
string GetNewFileName()
{
string fileName = SnippetCompilerProject.GetFullFileName("Snippet1.cs");
string baseFolder = Path.GetDirectoryName(fileName);
int count = 1;
while (File.Exists(fileName)) {
count++;
fileName = Path.Combine(baseFolder, "Snippet" + count.ToString() + ".cs");
}
return fileName;
}
void AddFileToProject(string fileName)
{
IProject project = ProjectService.CurrentProject;
var item = new FileProjectItem(project, ItemType.Compile, fileName);
ProjectService.AddProjectItem(project, item);
project.Save();
}
void BuildCurrentProject()
{
SaveAll();
var buildSnippet = new BuildSnippetCommand(ProjectService.CurrentProject);
buildSnippet.Run();
}
void Run()
{
SaveAll();
var execute = new Execute();
execute.Run();
}
void ContinueDebugging()
{
var continueCommand = new ContinueDebuggingCommand();
continueCommand.Run();
}
void StopDebugging()
{
var stopCommand = new StopDebuggingCommand();
stopCommand.Run();
}
void StepOver()
{
var stepCommand = new StepDebuggingCommand();
stepCommand.Run();
}
void StepInto()
{
var stepCommand = new StepIntoDebuggingCommand();
stepCommand.Run();
}
void StepOut()
{
var stepCommand = new StepOutDebuggingCommand();
stepCommand.Run();
}
void AddReferences()
{
IProject project = ProjectService.CurrentProject;
using (var referenceDialog = new SelectReferenceDialog(project)) {
// Add existing project references to dialog.
List<ReferenceProjectItem> references = GetReferences(project);
AddReferences(referenceDialog as ISelectReferenceDialog, references);
System.Windows.Forms.DialogResult result = referenceDialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK) {
ArrayList selectedReferences = referenceDialog.ReferenceInformations;
// Remove any references removed in the select reference dialog.
foreach (ReferenceProjectItem existingReference in references) {
if (!selectedReferences.Contains(existingReference)) {
ProjectService.RemoveProjectItem(project, existingReference);
}
}
// Add new references.
foreach (ReferenceProjectItem reference in referenceDialog.ReferenceInformations) {
if (!references.Contains(reference)) {
ProjectService.AddProjectItem(project, reference);
}
}
project.Save();
}
}
}
List<ReferenceProjectItem> GetReferences(IProject project)
{
List<ReferenceProjectItem> references = new List<ReferenceProjectItem>();
foreach (ProjectItem item in project.Items) {
ReferenceProjectItem reference = item as ReferenceProjectItem;
if (reference != null) {
references.Add(reference);
}
}
return references;
}
void AddReferences(ISelectReferenceDialog dialog, List<ReferenceProjectItem> references)
{
foreach (ReferenceProjectItem reference in references) {
dialog.AddReference(reference.Include, "Gac", reference.FileName, reference);
}
}
void OpenFile()
{
var dialog = new OpenFileDialog();
dialog.CheckFileExists = true;
if (dialog.ShowDialog() == true) {
foreach (string fileName in dialog.FileNames) {
LoadFile(fileName);
AddFileToProject(fileName);
}
}
}
void CloseFile()
{
if (SelectedFile != null) {
SelectedFile.Save();
string fileName = SelectedFile.PrimaryFileName;
IProject project = ProjectService.CurrentProject;
FileProjectItem item = project.FindFile(fileName);
if (item != null) {
ProjectService.RemoveProjectItem(project, item);
project.Save();
files.Remove(SelectedFile);
}
}
}
public PadViewModel SelectedPad { get; set; }
public void ActivateOutputList()
{
SelectedPad = pads[1];
NotifyPropertyChanged("SelectedPad");
}
public void ActivateErrorList()
{
SelectedPad = pads[0];
NotifyPropertyChanged("SelectedPad");
}
public event PropertyChangedEventHandler PropertyChanged;
void NotifyPropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
}

106
samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml

@ -0,0 +1,106 @@ @@ -0,0 +1,106 @@
<Window
x:Class="ICSharpCode.SharpSnippetCompiler.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:snippet="clr-namespace:ICSharpCode.SharpSnippetCompiler"
DataContext="{x:Static snippet:ViewModels.MainViewModel}"
Title="Sharp Snippet Compiler"
Height="480"
Width="640">
<Window.InputBindings>
<KeyBinding
Key="N"
Modifiers="Ctrl"
Command="{Binding NewFileCommand}"/>
<KeyBinding
Key="B"
Modifiers="Ctrl+Shift"
Command="{Binding BuildCurrentCommand}"/>
<KeyBinding
Key="F5"
Command="{Binding RunCommand}"/>
<KeyBinding
Key="F6"
Command="{Binding ContinueCommand}"/>
<KeyBinding
Key="F10"
Command="{Binding StepOverCommand}"/>
<KeyBinding
Key="F11"
Command="{Binding StepIntoCommand}"/>
<KeyBinding
Key="F11"
Modifiers="Shift"
Command="{Binding StepOutCommand}"/>
</Window.InputBindings>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Menu IsMainMenu="True">
<MenuItem Header="_File">
<MenuItem Header="_New..." Command="{Binding NewFileCommand}" InputGestureText="Ctrl+N"/>
<MenuItem Header="_Open..." Command="{Binding OpenFileCommand}"/>
<MenuItem Header="_Close" Command="{Binding CloseFileCommand}"/>
<Separator />
<MenuItem Header="E_xit" Command="{Binding ExitCommand}"/>
</MenuItem>
<MenuItem Header="_Edit">
<MenuItem Header="_Undo"/>
<MenuItem Header="_Redo"/>
<Separator />
<MenuItem Header="Cu_t" Command="ApplicationCommands.Cut"/>
<MenuItem Header="_Copy" Command="ApplicationCommands.Copy"/>
<MenuItem Header="_Paste" Command="ApplicationCommands.Paste"/>
<MenuItem Header="_Delete" Command="ApplicationCommands.Delete"/>
<Separator />
<MenuItem Header="Select _All" Command="ApplicationCommands.SelectAll"/>
</MenuItem>
<MenuItem Header="_Build">
<MenuItem Header="Build Current" Command="{Binding BuildCurrentCommand}" InputGestureText="Ctrl+Shift+B"/>
</MenuItem>
<MenuItem Header="_Debug">
<MenuItem Header="_Run" Command="{Binding RunCommand}" InputGestureText="F5"/>
<MenuItem Header="St_op"/>
<Separator />
<MenuItem Header="_Continue" Command="{Binding ContinueCommand}" InputGestureText="F6"/>
<Separator />
<MenuItem Header="Step O_ver" Command="{Binding StepOverCommand}" InputGestureText="F10"/>
<MenuItem Header="Step _Into" Command="{Binding StepIntoCommand}" InputGestureText="F11"/>
<MenuItem Header="Step O_ut" Command="{Binding StepOutCommand}" InputGestureText="Shift+F11"/>
</MenuItem>
<MenuItem Header="_Tools">
<MenuItem Header="_References..." Command="{Binding AddReferencesCommand}"/>
</MenuItem>
</Menu>
<TabControl
Grid.Row="1"
SelectedItem="{Binding SelectedFile}"
ItemsSource="{Binding Files}">
<TabControl.ItemContainerStyle>
<Style TargetType="TabItem">
<Setter Property="Header" Value="{Binding TabPageText}"/>
<Setter Property="Content" Value="{Binding Control}"/>
</Style>
</TabControl.ItemContainerStyle>
</TabControl>
<TabControl
Grid.Row="2"
SelectedItem="{Binding SelectedPad}"
ItemsSource="{Binding Pads}">
<TabControl.ItemContainerStyle>
<Style TargetType="TabItem">
<Setter Property="Header" Value="{Binding Title}"/>
<Setter Property="Content" Value="{Binding Control}"/>
</Style>
</TabControl.ItemContainerStyle>
</TabControl>
</Grid>
</Window>

16
samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml.cs

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
// 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.Windows;
namespace ICSharpCode.SharpSnippetCompiler
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

6
samples/SharpSnippetCompiler/SharpSnippetCompiler/NewFileDialog.cs

@ -31,16 +31,10 @@ using System.Windows.Forms; @@ -31,16 +31,10 @@ using System.Windows.Forms;
namespace ICSharpCode.SharpSnippetCompiler
{
/// <summary>
/// Description of NewFileDialog.
/// </summary>
public partial class NewFileDialog : Form
{
public NewFileDialog()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
}

63
samples/SharpSnippetCompiler/SharpSnippetCompiler/PadViewModel.cs

@ -0,0 +1,63 @@ @@ -0,0 +1,63 @@
// SharpDevelop samples
// Copyright (c) 2013, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Windows.Controls;
using System.Windows.Forms.Integration;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.SharpSnippetCompiler
{
public class PadViewModel
{
PadDescriptor padDescriptor;
object control;
public PadViewModel(PadDescriptor padDescriptor)
{
this.padDescriptor = padDescriptor;
this.padDescriptor.CreatePad();
this.control = padDescriptor.PadContent.Control;
if (control is System.Windows.Forms.Control) {
var host = new WindowsFormsHost();
host.Child = (System.Windows.Forms.Control)padDescriptor.PadContent.Control;
this.control = host;
}
}
public object Control {
get { return control; }
}
public string Title {
get { return StringParser.Parse(padDescriptor.Title); }
}
}
}

6
samples/SharpSnippetCompiler/SharpSnippetCompiler/PreBuildEvent.proj

@ -3,11 +3,13 @@ @@ -3,11 +3,13 @@
<PrepareForBuildDependsOn>$(PrepareForBuildDependsOn);MyPreBuildTarget</PrepareForBuildDependsOn>
</PropertyGroup>
<ItemGroup>
<CSharpBindingFile Include="..\..\..\AddIns\AddIns\BackendBindings\CSharpBinding\CSharpBinding.*" />
<DebuggerAddInFile Include="..\..\..\AddIns\AddIns\Misc\Debugger\Debugger.*" />
<CSharpBindingFile Include="..\..\..\AddIns\BackendBindings\CSharpBinding\CSharpBinding.*" />
<DebuggerAddInFile Include="..\..\..\AddIns\Debugger\Debugger.*" />
<ILSpyAddInFile Include="..\..\..\AddIns\DisplayBindings\Decompiler\ILSpyAddIn.*" />
</ItemGroup>
<Target Name="MyPreBuildTarget">
<Copy SourceFiles="@(CSharpBindingFile)" DestinationFolder="$(OutputPath)AddIns\CSharpBinding" />
<Copy SourceFiles="@(DebuggerAddInFile)" DestinationFolder="$(OutputPath)AddIns\Debugger" />
<Copy SourceFiles="@(ILSpyAddInFile)" DestinationFolder="$(OutputPath)AddIns\ILSpy" />
</Target>
</Project>

37
samples/SharpSnippetCompiler/SharpSnippetCompiler/Program.cs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
// SharpDevelop samples
// Copyright (c) 2010, AlphaSierraPapa
// Copyright (c) 2013, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
@ -28,7 +28,6 @@ @@ -28,7 +28,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
@ -40,8 +39,9 @@ using ICSharpCode.SharpSnippetCompiler.Core; @@ -40,8 +39,9 @@ using ICSharpCode.SharpSnippetCompiler.Core;
namespace ICSharpCode.SharpSnippetCompiler
{
public sealed class Program
{
MainForm mainForm;
{
App app;
MainWindow mainWindow;
[STAThread]
static void Main(string[] args)
@ -51,43 +51,34 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -51,43 +51,34 @@ namespace ICSharpCode.SharpSnippetCompiler
}
void Run(string[] args)
{
{
SharpSnippetCompilerManager.Init();
mainForm = new MainForm();
app = new App();
// Force creation of the debugger before workbench is created.
IDebugger debugger = DebuggerService.CurrentDebugger;
Workbench workbench = new Workbench(mainForm);
mainWindow = new MainWindow();
var workbench = new Workbench(mainWindow);
WorkbenchSingleton.InitializeWorkbench(workbench, new WorkbenchLayout());
PadDescriptor errorList = workbench.GetPad(typeof(ErrorListPad));
errorList.CreatePad();
mainForm.ErrorList = errorList.PadContent.Control;
PadDescriptor outputList = workbench.GetPad(typeof(CompilerMessageView));
outputList.CreatePad();
mainForm.OutputList = outputList.PadContent.Control;
mainForm.Visible = true;
ViewModels.MainViewModel.AddInitialPads();
SnippetCompilerProject.Load();
IProject project = GetCurrentProject();
ProjectService.CurrentProject = project;
LoadFiles(project);
ParserService.StartParserThread();
// ParserService.StartParserThread();
//WorkbenchSingleton.SafeThreadAsyncCall(new Action<Program>(LoadFile));
try {
Application.Run(mainForm);
app.Run(WorkbenchSingleton.MainWindow);
} finally {
try {
// Save properties
//PropertyService.Save();
} catch (Exception ex) {
MessageService.ShowError(ex, "Properties could not be saved.");
MessageService.ShowException(ex, "Properties could not be saved.");
}
}
}
@ -97,11 +88,11 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -97,11 +88,11 @@ namespace ICSharpCode.SharpSnippetCompiler
foreach (ProjectItem item in project.Items) {
FileProjectItem fileItem = item as FileProjectItem;
if (fileItem != null && File.Exists(item.FileName)) {
mainForm.LoadFile(item.FileName);
ViewModels.MainViewModel.LoadFile(item.FileName);
}
}
}
IProject GetCurrentProject()
{
foreach (IProject project in ProjectService.OpenSolution.Projects) {

88
samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj

@ -39,14 +39,20 @@ @@ -39,14 +39,20 @@
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<Import Project="PreBuildEvent.proj" />
<ItemGroup>
<Reference Include="ICSharpCode.AvalonEdit">
<HintPath>..\..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.Core">
<HintPath>..\..\..\bin\ICSharpCode.Core.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.TextEditor">
<HintPath>..\..\..\bin\ICSharpCode.TextEditor.dll</HintPath>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
@ -55,33 +61,76 @@ @@ -55,33 +61,76 @@
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsFormsIntegration">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="MainForm.cs" />
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
<Compile Include="MainViewModel.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="NewFileDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="NewFileDialog.cs" />
<Compile Include="NewFileDialog.Designer.cs">
<DependentUpon>NewFileDialog.cs</DependentUpon>
</Compile>
<Compile Include="PadViewModel.cs" />
<Compile Include="Program.cs" />
<Compile Include="SnippetTabPage.cs" />
<Compile Include="TextEditorDisplayBinding.cs" />
<Compile Include="ViewModels.cs" />
<Compile Include="WorkbenchLayout.cs" />
<Compile Include="WorkbenchWindow.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="NewFileDialog.resx">
<DependentUpon>NewFileDialog.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="bin\AddIns\SharpSnippetCompiler.addin">
<Link>SharpSnippetCompiler.addin</Link>
<None Include="..\..\..\bin\GraphSharp.Contracts.dll">
<Link>GraphSharp.Contracts.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\..\bin\GraphSharp.Controls.dll">
<Link>GraphSharp.Controls.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\..\bin\GraphSharp.dll">
<Link>GraphSharp.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\..\bin\ICSharpCode.SharpDevelop.BuildWorker40.exe">
<Link>ICSharpCode.SharpDevelop.BuildWorker40.exe</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\..\bin\ICSharpCode.SharpDevelop.BuildWorker40.exe.config">
<Link>ICSharpCode.SharpDevelop.BuildWorker40.exe.config</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\..\bin\ICSharpCode.TreeView.dll">
<Link>ICSharpCode.TreeView.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\..\bin\QuickGraph.dll">
<Link>QuickGraph.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\..\bin\SharpDevelop.TargetingPack.targets">
<Link>SharpDevelop.TargetingPack.targets</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharpSnippetCompiler.Core\SharpSnippetCompiler.Core.csproj">
@ -89,4 +138,17 @@ @@ -89,4 +138,17 @@
<Name>SharpSnippetCompiler.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="App.xaml" />
<Page Include="MainWindow.xaml" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\..\data\resources\languages\LanguageDefinition.xml">
<Link>data\resources\languages\LanguageDefinition.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="AddIns\SharpSnippetCompiler.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

18
samples/SharpSnippetCompiler/SharpSnippetCompiler/TextEditorDisplayBinding.cs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
// SharpDevelop samples
// Copyright (c) 2010, AlphaSierraPapa
// Copyright (c) 2013, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
@ -26,6 +26,7 @@ @@ -26,6 +26,7 @@
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.IO;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpSnippetCompiler.Core;
@ -45,8 +46,19 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -45,8 +46,19 @@ namespace ICSharpCode.SharpSnippetCompiler
public IViewContent CreateContentForFile(OpenedFile file)
{
MainForm form = WorkbenchSingleton.MainForm as MainForm;
return form.LoadFile(file.FileName);
//MainForm form = WorkbenchSingleton.MainWindow as MainForm;
//return form.LoadFile(file.FileName);
return null;
}
public bool IsPreferredBindingForFile(string fileName)
{
return true;
}
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType)
{
return 0;
}
}
}

21
samples/SharpSnippetCompiler/SharpSnippetCompiler/SnippetTabPage.cs → samples/SharpSnippetCompiler/SharpSnippetCompiler/ViewModels.cs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
// SharpDevelop samples
// Copyright (c) 2008, AlphaSierraPapa
// SharpDevelop samples
// Copyright (c) 2013, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
@ -26,24 +26,15 @@ @@ -26,24 +26,15 @@
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Windows.Forms;
using ICSharpCode.SharpSnippetCompiler.Core;
namespace ICSharpCode.SharpSnippetCompiler
{
public class SnippetTabPage : TabPage
public static class ViewModels
{
SharpSnippetCompilerControl snippetControl;
public SnippetTabPage(SharpSnippetCompilerControl snippetControl)
{
this.snippetControl = snippetControl;
Controls.Add(snippetControl);
}
static readonly MainViewModel mainViewModel = new MainViewModel();
public SharpSnippetCompilerControl SnippetCompilerControl {
get { return snippetControl; }
public static MainViewModel MainViewModel {
get { return mainViewModel; }
}
}
}

24
samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchLayout.cs

@ -73,13 +73,10 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -73,13 +73,10 @@ namespace ICSharpCode.SharpSnippetCompiler
public void ActivatePad(string fullyQualifiedTypeName)
{
Console.WriteLine("WorkbenchLayout.ActivatePad not implemented");
if (fullyQualifiedTypeName.EndsWith("ErrorListPad")) {
MainForm mainForm = WorkbenchSingleton.MainForm as MainForm;
mainForm.ActivateErrorList();
ViewModels.MainViewModel.ActivateErrorList();
} else if (fullyQualifiedTypeName.EndsWith("CompilerMessageView")) {
MainForm mainForm = WorkbenchSingleton.MainForm as MainForm;
mainForm.ActivateOutputList();
ViewModels.MainViewModel.ActivateOutputList();
}
}
@ -128,6 +125,21 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -128,6 +125,21 @@ namespace ICSharpCode.SharpSnippetCompiler
if (ActiveWorkbenchWindowChanged != null) {
ActiveWorkbenchWindowChanged(this, e);
}
}
}
public event EventHandler ActiveContentChanged;
protected virtual void OnActiveContentChanged(EventArgs e)
{
if (ActiveContentChanged != null) {
ActiveContentChanged(this, e);
}
}
public System.Collections.Generic.IList<IWorkbenchWindow> WorkbenchWindows {
get {
throw new NotImplementedException();
}
}
}
}

21
samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchWindow.cs

@ -29,6 +29,8 @@ using System; @@ -29,6 +29,8 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Media;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
@ -36,21 +38,12 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -36,21 +38,12 @@ namespace ICSharpCode.SharpSnippetCompiler
{
public class WorkbenchWindow : IWorkbenchWindow
{
TabControl tabControl;
SnippetTabPage tabPage;
public WorkbenchWindow(TabControl tabControl, SnippetTabPage tabPage)
{
this.tabControl = tabControl;
this.tabPage = tabPage;
}
public event EventHandler ActiveViewContentChanged;
public event EventHandler WindowSelected;
public event EventHandler WindowSelected;
public event EventHandler WindowDeselected;
public event EventHandler TitleChanged;
public event EventHandler CloseEvent;
public string Title {
get {
throw new NotImplementedException();
@ -68,7 +61,7 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -68,7 +61,7 @@ namespace ICSharpCode.SharpSnippetCompiler
set { }
}
public Icon Icon {
public ImageSource Icon {
get {
throw new NotImplementedException();
}
@ -95,7 +88,7 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -95,7 +88,7 @@ namespace ICSharpCode.SharpSnippetCompiler
public void SelectWindow()
{
tabControl.SelectedTab = tabPage;
//tabControl.SelectedTab = tabPage;
OnWindowSelected(new EventArgs());
}
@ -137,6 +130,6 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -137,6 +130,6 @@ namespace ICSharpCode.SharpSnippetCompiler
if (CloseEvent != null) {
CloseEvent(this, e);
}
}
}
}
}

4
samples/SharpSnippetCompiler/SharpSnippetCompiler/app.config

@ -6,8 +6,8 @@ @@ -6,8 +6,8 @@
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
</dependentAssembly>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<log4net>

Loading…
Cancel
Save