From de6619b247ee27b95bf5a9f027bbc8047d1c83c4 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sun, 17 Mar 2013 11:40:56 +0000 Subject: [PATCH 01/19] Fix snippet compiler sample. Remaining problems: Application can hang after debugging. Selecting item in Errors list does not jump to text editor line. --- .../DelegateCommand.cs | 43 ++ .../IconBarManager.cs | 96 ++++ .../IconBarMargin.cs | 259 ++++++++++ .../MainViewContent.cs | 305 +++++++----- .../SharpSnippetCompiler.Core.csproj | 37 +- .../SharpSnippetCompilerControl.Designer.cs | 48 -- .../SharpSnippetCompilerControl.cs | 51 -- .../SharpSnippetCompilerControl.resx | 120 ----- .../SharpSnippetProjectBinding.cs | 28 ++ .../SharpSnippetTextEditorAdapter.cs | 33 ++ .../SnippetCompilerProject.cs | 64 ++- .../SharpSnippetCompiler.Core/SnippetFile.cs | 14 +- .../StatusBarService.cs | 54 +++ .../TextMarkerService.cs | 306 ++++++++++++ .../SharpSnippetCompiler.Core/Workbench.cs | 86 ++-- .../WpfSynchronizeInvoke.cs | 122 +++++ .../SharpSnippetCompiler.sln | 2 +- .../AddIns/SharpSnippetCompiler.addin | 100 ++++ .../SharpSnippetCompiler/App.xaml | 7 + .../SharpSnippetCompiler/App.xaml.cs | 37 ++ .../SharpSnippetCompiler/MainForm.Designer.cs | 458 ------------------ .../SharpSnippetCompiler/MainForm.cs | 378 --------------- .../SharpSnippetCompiler/MainForm.resx | 123 ----- .../SharpSnippetCompiler/MainViewModel.cs | 315 ++++++++++++ .../SharpSnippetCompiler/MainWindow.xaml | 106 ++++ .../SharpSnippetCompiler/MainWindow.xaml.cs | 16 + .../SharpSnippetCompiler/NewFileDialog.cs | 6 - .../SharpSnippetCompiler/PadViewModel.cs | 63 +++ .../SharpSnippetCompiler/PreBuildEvent.proj | 6 +- .../SharpSnippetCompiler/Program.cs | 37 +- .../SharpSnippetCompiler.csproj | 88 +++- .../TextEditorDisplayBinding.cs | 18 +- .../{SnippetTabPage.cs => ViewModels.cs} | 21 +- .../SharpSnippetCompiler/WorkbenchLayout.cs | 24 +- .../SharpSnippetCompiler/WorkbenchWindow.cs | 21 +- .../SharpSnippetCompiler/app.config | 4 +- 36 files changed, 2016 insertions(+), 1480 deletions(-) create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/DelegateCommand.cs create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarManager.cs create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarMargin.cs delete mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.Designer.cs delete mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.cs delete mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.resx create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetProjectBinding.cs create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetTextEditorAdapter.cs create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/StatusBarService.cs create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/TextMarkerService.cs create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/WpfSynchronizeInvoke.cs create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/AddIns/SharpSnippetCompiler.addin create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml.cs delete mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.Designer.cs delete mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.cs delete mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.resx create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/MainViewModel.cs create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml.cs create mode 100644 samples/SharpSnippetCompiler/SharpSnippetCompiler/PadViewModel.cs rename samples/SharpSnippetCompiler/SharpSnippetCompiler/{SnippetTabPage.cs => ViewModels.cs} (77%) diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/DelegateCommand.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/DelegateCommand.cs new file mode 100644 index 0000000000..034d60e819 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/DelegateCommand.cs @@ -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 execute; + Predicate canExecute; + + public DelegateCommand(Action execute, Predicate canExecute) + { + this.execute = execute; + this.canExecute = canExecute; + } + + public DelegateCommand(Action 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; + } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarManager.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarManager.cs new file mode 100644 index 0000000000..806a961eb9 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarManager.cs @@ -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 +{ + /// + /// Stores the entries in the icon bar margin. Multiple icon bar margins + /// can use the same manager if split view is used. + /// + public class IconBarManager : IBookmarkMargin + { + ObservableCollection bookmarks = new ObservableCollection(); + + public IconBarManager() + { + bookmarks.CollectionChanged += bookmarks_CollectionChanged; + } + + public IList 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; + } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarMargin.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarMargin.cs new file mode 100644 index 0000000000..3ec131ff70 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/IconBarMargin.cs @@ -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 +{ + /// + /// Icon bar: contains breakpoints and other icons. + /// + public class IconBarMargin : AbstractMargin, IDisposable + { + readonly IBookmarkMargin manager; + + public IconBarMargin(IBookmarkMargin manager) + { + if (manager == null) + throw new ArgumentNullException("manager"); + this.manager = manager; + } + + #region OnTextViewChanged + /// + 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 + + /// + protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters) + { + // accept clicks even when clicking on the background + return new PointHitTestResult(this, hitTestParameters.HitPoint); + } + + /// + 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 bookmarkDict = new Dictionary(); + 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; + } + } + } + } + } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/MainViewContent.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/MainViewContent.cs index c180a0c301..deb031cc17 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/MainViewContent.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/MainViewContent.cs @@ -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 } public string TabPageText { - get { - throw new NotImplementedException(); - } + get { return Path.GetFileName(file.FileName); } } public string TitleName { @@ -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 } } - public void RedrawContent() - { - throw new NotImplementedException(); - } - public void Save(OpenedFile file, Stream stream) { throw new NotImplementedException(); @@ -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(GetText); + return (string)WorkbenchSingleton.SafeThreadFunction(GetText); } else { return GetText(); } @@ -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; + } + } } } diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj index de41f1abcb..ec12474e85 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj @@ -38,8 +38,8 @@ - - ..\..\..\bin\Aga.Controls.dll + + ..\..\..\bin\ICSharpCode.AvalonEdit.dll ..\..\..\bin\ICSharpCode.Build.Tasks.dll @@ -59,46 +59,53 @@ ..\..\..\bin\ICSharpCode.SharpDevelop.Sda.dll - - ..\..\..\bin\ICSharpCode.TextEditor.dll - ..\..\..\bin\log4net.dll + + 3.0 + + + 3.0 + 3.5 + + 4.0 + - - 3.5 + + 3.0 + + + - - - SharpSnippetCompilerControl.cs - + + + + + Resources\BitmapResources.resources Resources.BitmapResources.resources - + Resources\StringResources.resources Resources.StringResources.resources - - SharpSnippetCompilerControl.cs - diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.Designer.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.Designer.cs deleted file mode 100644 index b44909fac6..0000000000 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.Designer.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// -// -// -// - -namespace ICSharpCode.SharpSnippetCompiler.Core -{ - partial class SharpSnippetCompilerControl - { - /// - /// Designer variable used to keep track of non-visual components. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Disposes resources used by the control. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing) { - if (components != null) { - components.Dispose(); - } - } - base.Dispose(disposing); - } - - /// - /// 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. - /// - 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); - } - } -} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.cs deleted file mode 100644 index 0c8a0680a6..0000000000 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// -// -// -// - -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); - } - } -} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.resx b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.resx deleted file mode 100644 index 7080a7d118..0000000000 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompilerControl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetProjectBinding.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetProjectBinding.cs new file mode 100644 index 0000000000..955947a6cf --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetProjectBinding.cs @@ -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; } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetTextEditorAdapter.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetTextEditorAdapter.cs new file mode 100644 index 0000000000..78a6a3ec53 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetTextEditorAdapter.cs @@ -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); + } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs index aa663183b7..f5e3ce889e 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs @@ -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 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 { 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" + }; } /// @@ -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"); diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetFile.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetFile.cs index 2ea21094a0..9edeca462d 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetFile.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetFile.cs @@ -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 { public SnippetFile(string fileName) { - this.FileName = fileName; - IsUntitled = false; + this.FileName = new FileName(fileName); + IsUntitled = false; } public override IList RegisteredViewContents { @@ -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); + } + } } } diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/StatusBarService.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/StatusBarService.cs new file mode 100644 index 0000000000..6a3ce334f3 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/StatusBarService.cs @@ -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) + { + + } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/TextMarkerService.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/TextMarkerService.cs new file mode 100644 index 0000000000..9474994617 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/TextMarkerService.cs @@ -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 +{ + /// + /// Handles the text markers for a code editor. + /// + public sealed class TextMarkerService : DocumentColorizingTransformer, IBackgroundRenderer, ITextMarkerService, ITextViewConnect + { + TextSegmentCollection markers; + TextDocument document; + + public TextMarkerService(TextDocument document) + { + if (document == null) + throw new ArgumentNullException("document"); + this.document = document; + this.markers = new TextSegmentCollection(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 GetMarkersAtOffset(int offset) + { + if (markers == null) + return Enumerable.Empty(); + else + return markers.FindSegmentsContaining(offset); + } + + public IEnumerable TextMarkers { + get { return markers ?? Enumerable.Empty(); } + } + + public void RemoveAll(Predicate 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(); + } + } + + /// + /// Redraws the specified text segment. + /// + 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 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 textViews = new List(); + + 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; } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/Workbench.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/Workbench.cs index 5570fac10a..cf9734102e 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/Workbench.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/Workbench.cs @@ -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 { readonly static string viewContentPath = "/SharpDevelop/Workbench/Pads"; - Form mainForm; + Window mainWindow; List padDescriptors = new List(); List views = new List(); 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 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 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 throw new NotImplementedException(); } - public void RedrawAllComponents() - { - throw new NotImplementedException(); - } - public Properties CreateMemento() { throw new NotImplementedException(); @@ -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 contents = AddInTree.GetTreeNode(viewContentPath).BuildChildItems(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 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; + } } } diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/WpfSynchronizeInvoke.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/WpfSynchronizeInvoke.cs new file mode 100644 index 0000000000..4d561b8f02 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/WpfSynchronizeInvoke.cs @@ -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 +{ + /// + /// Implements the ISynchronizeInvoke interface by using a WPF dispatcher + /// to perform the cross-thread call. + /// + 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; + } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.sln b/samples/SharpSnippetCompiler/SharpSnippetCompiler.sln index 6e52498599..d96707d59c 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.sln +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.sln @@ -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}" diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/AddIns/SharpSnippetCompiler.addin b/samples/SharpSnippetCompiler/SharpSnippetCompiler/AddIns/SharpSnippetCompiler.addin new file mode 100644 index 0000000000..2a576ee5f5 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/AddIns/SharpSnippetCompiler.addin @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml b/samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml new file mode 100644 index 0000000000..117fea5703 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml.cs new file mode 100644 index 0000000000..cc8d6732b9 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/App.xaml.cs @@ -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 + { + } +} \ No newline at end of file diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.Designer.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.Designer.cs deleted file mode 100644 index 9204e234af..0000000000 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.Designer.cs +++ /dev/null @@ -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 - { - /// - /// Designer variable used to keep track of non-visual components. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Disposes resources used by the form. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing) { - if (components != null) { - components.Dispose(); - } - } - base.Dispose(disposing); - } - - /// - /// 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. - /// - 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; - } -} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.cs deleted file mode 100644 index e3e906f237..0000000000 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.cs +++ /dev/null @@ -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); - } - } - - /// - /// Gets the active text editor control. - /// - 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 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 GetReferences(IProject project) - { - List references = new List(); - foreach (ProjectItem item in project.Items) { - ReferenceProjectItem reference = item as ReferenceProjectItem; - if (reference != null) { - references.Add(reference); - } - } - return references; - } - - void AddReferences(ISelectReferenceDialog dialog, List 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(); - } - } - } - } -} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.resx b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.resx deleted file mode 100644 index cff2051ccf..0000000000 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainViewModel.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainViewModel.cs new file mode 100644 index 0000000000..fb7fded112 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainViewModel.cs @@ -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 files = new ObservableCollection(); + ObservableCollection pads = new ObservableCollection(); + + 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 Files { + get { return files; } + } + + public ObservableCollection 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 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 GetReferences(IProject project) + { + List references = new List(); + foreach (ProjectItem item in project.Items) { + ReferenceProjectItem reference = item as ReferenceProjectItem; + if (reference != null) { + references.Add(reference); + } + } + return references; + } + + void AddReferences(ISelectReferenceDialog dialog, List 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)); + } + } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml new file mode 100644 index 0000000000..100793385f --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml.cs new file mode 100644 index 0000000000..16217c4411 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml.cs @@ -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(); + } + } +} \ No newline at end of file diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/NewFileDialog.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/NewFileDialog.cs index a997b790b6..5f8625304d 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/NewFileDialog.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/NewFileDialog.cs @@ -31,16 +31,10 @@ using System.Windows.Forms; namespace ICSharpCode.SharpSnippetCompiler { - /// - /// Description of NewFileDialog. - /// public partial class NewFileDialog : Form { public NewFileDialog() { - // - // The InitializeComponent() call is required for Windows Forms designer support. - // InitializeComponent(); } diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/PadViewModel.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/PadViewModel.cs new file mode 100644 index 0000000000..b4e7697738 --- /dev/null +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/PadViewModel.cs @@ -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); } + } + } +} diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/PreBuildEvent.proj b/samples/SharpSnippetCompiler/SharpSnippetCompiler/PreBuildEvent.proj index 5fb4134345..6fa2142ebe 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/PreBuildEvent.proj +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/PreBuildEvent.proj @@ -3,11 +3,13 @@ $(PrepareForBuildDependsOn);MyPreBuildTarget - - + + + + \ No newline at end of file diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/Program.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/Program.cs index 8316b04261..b929c2dedb 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/Program.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/Program.cs @@ -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 @@ 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; 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 } 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(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 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) { diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj b/samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj index 949c7a4aaf..049ae8f873 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj @@ -39,14 +39,20 @@ + + ..\..\..\bin\ICSharpCode.AvalonEdit.dll + ..\..\..\bin\ICSharpCode.Core.dll ..\..\..\bin\ICSharpCode.SharpDevelop.dll - - ..\..\..\bin\ICSharpCode.TextEditor.dll + + 3.0 + + + 3.0 @@ -55,33 +61,76 @@ + + 4.0 + + + 3.0 + + + 3.0 + + + App.xaml + Code + - - - MainForm.cs + + + MainWindow.xaml + Code + + + Form - NewFileDialog.cs + - + - - MainForm.cs - NewFileDialog.cs - - - SharpSnippetCompiler.addin + + GraphSharp.Contracts.dll + Always + + + GraphSharp.Controls.dll + Always + + + GraphSharp.dll + Always + + ICSharpCode.SharpDevelop.BuildWorker40.exe + Always + + + ICSharpCode.SharpDevelop.BuildWorker40.exe.config + Always + + + ICSharpCode.TreeView.dll + Always + + + QuickGraph.dll + Always + + + SharpDevelop.TargetingPack.targets + Always + + @@ -89,4 +138,17 @@ SharpSnippetCompiler.Core + + + + + + + data\resources\languages\LanguageDefinition.xml + Always + + + Always + + \ No newline at end of file diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/TextEditorDisplayBinding.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/TextEditorDisplayBinding.cs index 58e830a270..d2c9578275 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/TextEditorDisplayBinding.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/TextEditorDisplayBinding.cs @@ -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 @@ // 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 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; } } } diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/SnippetTabPage.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/ViewModels.cs similarity index 77% rename from samples/SharpSnippetCompiler/SharpSnippetCompiler/SnippetTabPage.cs rename to samples/SharpSnippetCompiler/SharpSnippetCompiler/ViewModels.cs index 794a91317e..10be0f9851 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/SnippetTabPage.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/ViewModels.cs @@ -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 @@ // 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; } } } } diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchLayout.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchLayout.cs index cc343a6aa3..29b21f0b8f 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchLayout.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchLayout.cs @@ -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 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 WorkbenchWindows { + get { + throw new NotImplementedException(); + } + } } } diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchWindow.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchWindow.cs index 62e220b0ef..1cf47cdf16 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchWindow.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/WorkbenchWindow.cs @@ -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 { 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 set { } } - public Icon Icon { + public ImageSource Icon { get { throw new NotImplementedException(); } @@ -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 if (CloseEvent != null) { CloseEvent(this, e); } - } + } } } diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/app.config b/samples/SharpSnippetCompiler/SharpSnippetCompiler/app.config index a5f9cf81e7..f2338848e6 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/app.config +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/app.config @@ -6,8 +6,8 @@ - - + + From a500e37ef88e8d53a31d532825ff6fda2ff32ddd Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Mon, 18 Mar 2013 16:41:06 +0000 Subject: [PATCH 02/19] Fix debugger hang in snippet compiler sample. --- .../SharpSnippetCompiler.Core.csproj | 6 +++++- .../SharpSnippetCompiler.Core/SnippetCompilerProject.cs | 5 +++-- .../SharpSnippetCompiler/SharpSnippetCompiler.csproj | 7 +++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj index ec12474e85..ccd2e0f549 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SharpSnippetCompiler.Core.csproj @@ -10,8 +10,10 @@ False False 4 - false + False v4.0 + False + obj\$(Configuration)\ ..\SharpSnippetCompiler\bin\ @@ -20,6 +22,7 @@ False True DEBUG;TRACE + obj\ ..\SharpSnippetCompiler\bin\ @@ -35,6 +38,7 @@ 4194304 AnyCPU 4096 + False diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs index f5e3ce889e..5f5a72d9a9 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/SnippetCompilerProject.cs @@ -46,7 +46,7 @@ namespace ICSharpCode.SharpSnippetCompiler.Core 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("Debug", null, "DefineConstants", "DEBUG;TRACE", PropertyStorageLocations.ConfigurationSpecific, false); SetProperty("Release", null, "DefineConstants", "TRACE", PropertyStorageLocations.ConfigurationSpecific, false); } @@ -87,7 +87,8 @@ namespace ICSharpCode.SharpSnippetCompiler.Core return new ProjectCreateInformation { Solution = new Solution(new ProjectChangeWatcher(String.Empty)), OutputProjectFileName = Path.Combine(PropertyService.ConfigDirectory, "SharpSnippet.exe"), - ProjectName = "SharpSnippet" + ProjectName = "SharpSnippet", + Platform = "x86" }; } diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj b/samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj index 049ae8f873..8d631f16e5 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj @@ -10,8 +10,10 @@ False False 4 - false + False v4.0 + False + obj\$(Configuration)\ bin\ @@ -20,6 +22,7 @@ False True DEBUG;TRACE + obj\ bin\ @@ -33,7 +36,7 @@ False Auto 4194304 - AnyCPU + x86 4096 From 8516c9bdd977916ae1eda17837aafe7d74586fc1 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Mon, 18 Mar 2013 16:42:44 +0000 Subject: [PATCH 03/19] Make snippet compiler main window bigger. --- .../SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml index 100793385f..14de7f2a42 100644 --- a/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml +++ b/samples/SharpSnippetCompiler/SharpSnippetCompiler/MainWindow.xaml @@ -5,8 +5,8 @@ xmlns:snippet="clr-namespace:ICSharpCode.SharpSnippetCompiler" DataContext="{x:Static snippet:ViewModels.MainViewModel}" Title="Sharp Snippet Compiler" - Height="480" - Width="640"> + Height="768" + Width="1024"> Date: Wed, 20 Mar 2013 10:22:43 +0100 Subject: [PATCH 04/19] Version increment --- src/Main/GlobalAssemblyInfo.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Main/GlobalAssemblyInfo.template b/src/Main/GlobalAssemblyInfo.template index 742b78d46a..7340dd5134 100644 --- a/src/Main/GlobalAssemblyInfo.template +++ b/src/Main/GlobalAssemblyInfo.template @@ -28,7 +28,7 @@ internal static class RevisionClass { public const string Major = "4"; public const string Minor = "3"; - public const string Build = "0"; + public const string Build = "1"; public const string Revision = "$INSERTREVISION$"; public const string VersionName = null; // "" is not valid for no version name, you have to use null if you don't want a version name (eg "Beta 1") From adf14f4f8ca8759bbc5392ab181e47981feac9d5 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 21 Mar 2013 17:33:56 +0100 Subject: [PATCH 05/19] Fix "ArgumentException: An item with the same key has already been added" when an attribute has multiple named arguments with the same name. --- .../Src/NRefactoryResolver/NRefactoryASTConvertVisitor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryASTConvertVisitor.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryASTConvertVisitor.cs index 0c6b8f77c9..5b1e434425 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryASTConvertVisitor.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryASTConvertVisitor.cs @@ -317,7 +317,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } Dictionary namedArguments = new Dictionary(); foreach (AST.NamedArgumentExpression namedArgumentExpression in attribute.NamedArguments) { - namedArguments.Add(namedArgumentExpression.Name, ConvertAttributeArgument(namedArgumentExpression.Expression)); + namedArguments[namedArgumentExpression.Name] = ConvertAttributeArgument(namedArgumentExpression.Expression); } result.Add(new DefaultAttribute(new AttributeReturnType(context, attribute.Name), target, positionalArguments, namedArguments) From 33070393e199da4e234d1f2bf3bf63ac92419d1a Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sun, 24 Mar 2013 19:44:45 +0000 Subject: [PATCH 06/19] Fix standard headers not being saved. --- .../EditStandardHeaderPanel.xaml.cs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.xaml.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.xaml.cs index b4958866fe..1765d396a6 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.xaml.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/EditStandardHeaderPanel.xaml.cs @@ -1,11 +1,6 @@ -/* - * Created by SharpDevelop. - * User: Peter Forstmeier - * Date: 30.03.2012 - * Time: 20:41 - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ +// 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.Controls; using System.Windows.Media; @@ -14,9 +9,6 @@ using ICSharpCode.SharpDevelop.Internal.Templates; namespace ICSharpCode.SharpDevelop.Gui.OptionPanels { - /// - /// Interaction logic for EditStandardHeaderPanelXaml.xaml - /// public partial class EditStandardHeaderPanel : OptionPanel { public EditStandardHeaderPanel() @@ -24,7 +16,6 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels InitializeComponent(); } - public override void LoadOptions() { headerTextBox.FontFamily = new FontFamily("Consolas, Courier New"); @@ -40,9 +31,9 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels void HeaderChooser_SelectionChanged(object sender, SelectionChangedEventArgs e) { headerTextBox.TextChanged -= HeaderTextBox_TextChanged; - int idx =headerChooser.SelectedIndex; + int idx = headerChooser.SelectedIndex; if (idx >= 0) { - headerTextBox.Text = ((StandardHeader)((ComboBox)headerChooser).SelectedItem).Header; + headerTextBox.Text = SelectedHeader.Header; headerTextBox.IsEnabled = true; } else { headerTextBox.Text = ""; @@ -51,10 +42,19 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels headerTextBox.TextChanged += HeaderTextBox_TextChanged; } + StandardHeader SelectedHeader { + get { return (StandardHeader)headerChooser.SelectedItem; } + } void HeaderTextBox_TextChanged(object sender, TextChangedEventArgs e) { - ((StandardHeader)((ComboBox)headerChooser).SelectedItem).Header = headerTextBox.Text; + SelectedHeader.Header = headerTextBox.Text; + } + + public override bool SaveOptions() + { + StandardHeader.StoreHeaders(); + return true; } } } \ No newline at end of file From 0f282ad56cc323a46a4a9a652ef1a25fd83914de Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Wed, 27 Mar 2013 11:56:30 +0000 Subject: [PATCH 07/19] Add MVC 4 project templates. --- .../project/CSharp/EmptyMvc4WebProject.xpt | 84 ++++ .../project/CSharp/Mvc4RazorProject.xpt | 374 ++++++++++++++++++ .../project/CSharp/Mvc4WebProject.xpt | 352 +++++++++++++++++ .../project/VB/EmptyMvc4WebProject.xpt | 82 ++++ .../templates/project/VB/Mvc4RazorProject.xpt | 366 +++++++++++++++++ data/templates/project/VB/Mvc4WebProject.xpt | 344 ++++++++++++++++ 6 files changed, 1602 insertions(+) create mode 100644 data/templates/project/CSharp/EmptyMvc4WebProject.xpt create mode 100644 data/templates/project/CSharp/Mvc4RazorProject.xpt create mode 100644 data/templates/project/CSharp/Mvc4WebProject.xpt create mode 100644 data/templates/project/VB/EmptyMvc4WebProject.xpt create mode 100644 data/templates/project/VB/Mvc4RazorProject.xpt create mode 100644 data/templates/project/VB/Mvc4WebProject.xpt diff --git a/data/templates/project/CSharp/EmptyMvc4WebProject.xpt b/data/templates/project/CSharp/EmptyMvc4WebProject.xpt new file mode 100644 index 0000000000..2e90828bdc --- /dev/null +++ b/data/templates/project/CSharp/EmptyMvc4WebProject.xpt @@ -0,0 +1,84 @@ + diff --git a/data/templates/project/CSharp/Mvc4RazorProject.xpt b/data/templates/project/CSharp/Mvc4RazorProject.xpt new file mode 100644 index 0000000000..00bea48ec0 --- /dev/null +++ b/data/templates/project/CSharp/Mvc4RazorProject.xpt @@ -0,0 +1,374 @@ + diff --git a/data/templates/project/CSharp/Mvc4WebProject.xpt b/data/templates/project/CSharp/Mvc4WebProject.xpt new file mode 100644 index 0000000000..6ff631187c --- /dev/null +++ b/data/templates/project/CSharp/Mvc4WebProject.xpt @@ -0,0 +1,352 @@ + diff --git a/data/templates/project/VB/EmptyMvc4WebProject.xpt b/data/templates/project/VB/EmptyMvc4WebProject.xpt new file mode 100644 index 0000000000..6356dc1425 --- /dev/null +++ b/data/templates/project/VB/EmptyMvc4WebProject.xpt @@ -0,0 +1,82 @@ + diff --git a/data/templates/project/VB/Mvc4RazorProject.xpt b/data/templates/project/VB/Mvc4RazorProject.xpt new file mode 100644 index 0000000000..b97ff08548 --- /dev/null +++ b/data/templates/project/VB/Mvc4RazorProject.xpt @@ -0,0 +1,366 @@ + diff --git a/data/templates/project/VB/Mvc4WebProject.xpt b/data/templates/project/VB/Mvc4WebProject.xpt new file mode 100644 index 0000000000..d469c538db --- /dev/null +++ b/data/templates/project/VB/Mvc4WebProject.xpt @@ -0,0 +1,344 @@ + From ad860bcac0f6f8f06d45d4399bf9ec4ff8022a6a Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Wed, 27 Mar 2013 12:17:30 +0000 Subject: [PATCH 08/19] Rename MVC 3 project templates. --- .../{EmptyMvcWebProject.xpt => EmptyMvc3WebProject.xpt} | 6 +++--- .../CSharp/{MvcRazorProject.xpt => Mvc3RazorProject.xpt} | 6 +++--- .../CSharp/{MvcWebProject.xpt => Mvc3WebProject.xpt} | 6 +++--- .../VB/{EmptyMvcWebProject.xpt => EmptyMvc3WebProject.xpt} | 6 +++--- .../VB/{MvcRazorProject.xpt => Mvc3RazorProject.xpt} | 6 +++--- .../project/VB/{MvcWebProject.xpt => Mvc3WebProject.xpt} | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) rename data/templates/project/CSharp/{EmptyMvcWebProject.xpt => EmptyMvc3WebProject.xpt} (93%) rename data/templates/project/CSharp/{MvcRazorProject.xpt => Mvc3RazorProject.xpt} (98%) rename data/templates/project/CSharp/{MvcWebProject.xpt => Mvc3WebProject.xpt} (98%) rename data/templates/project/VB/{EmptyMvcWebProject.xpt => EmptyMvc3WebProject.xpt} (93%) rename data/templates/project/VB/{MvcRazorProject.xpt => Mvc3RazorProject.xpt} (98%) rename data/templates/project/VB/{MvcWebProject.xpt => Mvc3WebProject.xpt} (98%) diff --git a/data/templates/project/CSharp/EmptyMvcWebProject.xpt b/data/templates/project/CSharp/EmptyMvc3WebProject.xpt similarity index 93% rename from data/templates/project/CSharp/EmptyMvcWebProject.xpt rename to data/templates/project/CSharp/EmptyMvc3WebProject.xpt index b8c38b86d0..c287d0877e 100644 --- a/data/templates/project/CSharp/EmptyMvcWebProject.xpt +++ b/data/templates/project/CSharp/EmptyMvc3WebProject.xpt @@ -5,11 +5,11 @@ - Empty MVC Application + Empty MVC 3 Application C# - ASP.NET MVC + ASP.NET MVC 3 C#.Project.WebProject - Empty ASP.NET MVC Application + Empty ASP.NET MVC 3 Application v4.0 diff --git a/data/templates/project/CSharp/MvcRazorProject.xpt b/data/templates/project/CSharp/Mvc3RazorProject.xpt similarity index 98% rename from data/templates/project/CSharp/MvcRazorProject.xpt rename to data/templates/project/CSharp/Mvc3RazorProject.xpt index bcc6657ea3..2189d63154 100644 --- a/data/templates/project/CSharp/MvcRazorProject.xpt +++ b/data/templates/project/CSharp/Mvc3RazorProject.xpt @@ -5,11 +5,11 @@ - Razor MVC Application + Razor MVC 3 Application C# - ASP.NET MVC + ASP.NET MVC 3 C#.Project.MvcRazorProject - ASP.NET MVC Application using Razor + ASP.NET MVC 3 Application using Razor v4.0 diff --git a/data/templates/project/CSharp/MvcWebProject.xpt b/data/templates/project/CSharp/Mvc3WebProject.xpt similarity index 98% rename from data/templates/project/CSharp/MvcWebProject.xpt rename to data/templates/project/CSharp/Mvc3WebProject.xpt index adf0344bac..16d7c92e92 100644 --- a/data/templates/project/CSharp/MvcWebProject.xpt +++ b/data/templates/project/CSharp/Mvc3WebProject.xpt @@ -5,11 +5,11 @@ - MVC Application + MVC 3 Application C# - ASP.NET MVC + ASP.NET MVC 3 C#.Project.WebProject - ASP.NET MVC Application + ASP.NET MVC 3 Application v4.0 diff --git a/data/templates/project/VB/EmptyMvcWebProject.xpt b/data/templates/project/VB/EmptyMvc3WebProject.xpt similarity index 93% rename from data/templates/project/VB/EmptyMvcWebProject.xpt rename to data/templates/project/VB/EmptyMvc3WebProject.xpt index e193864653..4a42584fe1 100644 --- a/data/templates/project/VB/EmptyMvcWebProject.xpt +++ b/data/templates/project/VB/EmptyMvc3WebProject.xpt @@ -5,11 +5,11 @@ - Empty MVC Application + Empty MVC 3 Application VB - ASP.NET MVC + ASP.NET MVC 3 VBNet.Project.WebProject - Empty ASP.NET MVC Application + Empty ASP.NET MVC 3 Application v4.0 diff --git a/data/templates/project/VB/MvcRazorProject.xpt b/data/templates/project/VB/Mvc3RazorProject.xpt similarity index 98% rename from data/templates/project/VB/MvcRazorProject.xpt rename to data/templates/project/VB/Mvc3RazorProject.xpt index decfdf7ab0..183b3adcf7 100644 --- a/data/templates/project/VB/MvcRazorProject.xpt +++ b/data/templates/project/VB/Mvc3RazorProject.xpt @@ -5,11 +5,11 @@ - Razor MVC Application + Razor MVC 3 Application VB - ASP.NET MVC + ASP.NET MVC 3 VBNet.Project.MvcRazorProject - ASP.NET MVC Application using Razor + ASP.NET MVC 3 Application using Razor v4.0 diff --git a/data/templates/project/VB/MvcWebProject.xpt b/data/templates/project/VB/Mvc3WebProject.xpt similarity index 98% rename from data/templates/project/VB/MvcWebProject.xpt rename to data/templates/project/VB/Mvc3WebProject.xpt index f108b972d0..df0f2c3cc3 100644 --- a/data/templates/project/VB/MvcWebProject.xpt +++ b/data/templates/project/VB/Mvc3WebProject.xpt @@ -5,11 +5,11 @@ - MVC Application + MVC 3 Application VB - ASP.NET MVC + ASP.NET MVC 3 VBNet.Project.WebProject - ASP.NET MVC Application + ASP.NET MVC 3 Application v4.0 From 08ddba725c73aa46277dff037088de006fb36073 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Wed, 27 Mar 2013 13:30:53 +0000 Subject: [PATCH 09/19] Update installer with new MVC project templates. --- src/Setup/Files.wxs | 42 ++++++++++++++++++++++++++++++------------ src/Setup/Setup.wxs | 18 ++++++++++++------ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/Setup/Files.wxs b/src/Setup/Files.wxs index 180471eb34..6da6c4b56c 100644 --- a/src/Setup/Files.wxs +++ b/src/Setup/Files.wxs @@ -697,11 +697,17 @@ - - + + - - + + + + + + + + @@ -709,8 +715,11 @@ - - + + + + + @@ -744,11 +753,17 @@ - - + + - - + + + + + + + + @@ -756,8 +771,11 @@ - - + + + + + diff --git a/src/Setup/Setup.wxs b/src/Setup/Setup.wxs index c021810755..34964d3f8c 100644 --- a/src/Setup/Setup.wxs +++ b/src/Setup/Setup.wxs @@ -240,11 +240,15 @@ - - + + + + - - + + + + @@ -543,8 +547,10 @@ - - + + + + From ed91c296ff811c830e639aa5f235ef36afec9c75 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 26 Mar 2013 02:10:47 +0100 Subject: [PATCH 10/19] Clear property container on designer unload so that the ComboBox of selectable objects stays empty when the designer cannot be reloaded due to syntax errors. --- .../FormsDesigner/Project/Src/DesignerViewContent.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs index d4218544ce..18ab43cc33 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs @@ -477,6 +477,7 @@ namespace ICSharpCode.FormsDesigner this.typeResolutionService = null; this.loader = null; + UpdatePropertyPad(); foreach (KeyValuePair entry in this.addedTypeDescriptionProviders) { TypeDescriptor.RemoveProvider(entry.Value, entry.Key); @@ -767,6 +768,9 @@ namespace ICSharpCode.FormsDesigner if (selectionService != null) { UpdatePropertyPadSelection(selectionService); } + } else { + propertyContainer.Host = null; + propertyContainer.SelectableObjects = null; } } From be2f73fa40f5a6f485bdce20af85e0c6846384f5 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 27 Mar 2013 21:01:31 +0100 Subject: [PATCH 11/19] Make AvalonEdit xshd schema more flexible: allow elements and attributes from other namespaces. --- .../Highlighting/Resources/ModeV2.xsd | 18 ++++++++++++++++-- .../Highlighting/Xshd/V2Loader.cs | 5 +++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd index 53cd376e26..1b23a7bd54 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd @@ -14,7 +14,7 @@ - + @@ -35,6 +35,7 @@ + @@ -54,6 +55,7 @@ + @@ -76,7 +78,15 @@ - + + + + + + + + + @@ -132,9 +142,11 @@ + + @@ -145,9 +157,11 @@ + + \ No newline at end of file diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs index 93519ae958..80684c363a 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs @@ -60,6 +60,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd return; while (reader.Read() && reader.NodeType != XmlNodeType.EndElement) { Debug.Assert(reader.NodeType == XmlNodeType.Element); + if (reader.NamespaceURI != Namespace) { + if (!reader.IsEmptyElement) + reader.Skip(); + continue; + } switch (reader.Name) { case "RuleSet": c.Add(ParseRuleSet(reader)); From f2b352c21f543d9e2598f6cf37674cce9ec56880 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Thu, 28 Mar 2013 11:11:56 +0000 Subject: [PATCH 12/19] Fix Get-Package output in NuGet console window. --- .../Project/Scripts/Package.Format.ps1xml | 264 +++++++++++++++--- 1 file changed, 224 insertions(+), 40 deletions(-) diff --git a/src/AddIns/Misc/PackageManagement/Project/Scripts/Package.Format.ps1xml b/src/AddIns/Misc/PackageManagement/Project/Scripts/Package.Format.ps1xml index 9ec6e76ce4..82338ab9d7 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Scripts/Package.Format.ps1xml +++ b/src/AddIns/Misc/PackageManagement/Project/Scripts/Package.Format.ps1xml @@ -1,41 +1,225 @@ - - - - IPackage.Table - - NuGet.DataServicePackage - NuGet.ZipPackage - - - - - - 35 - - - - 18 - - - - - - - - - - Id - - - Version - - - Description - - - - - - - + + + + + NuGet.IPackage.Table + + NuGet.ZipPackage + NuGet.DataServicePackage + NuGet.UnzippedPackage + + + + + + + 30 + + + + 20 + + + + + + + + + + Id + + + Version + + + + $description = if ($_.IsUpdate -and $_.ReleaseNotes) { + $_.ReleaseNotes + } + else { + $_.Description + } + $description = [System.Net.WebUtility]::HtmlDecode($description) + return $description + + + + + + + + + + NuGet.IPackage.List + + NuGet.ZipPackage + NuGet.UnzippedPackage + + + + + + + + Id + + + Version + + + + + $authors = if ($_.Authors -is [string[]]) { $_.Authors -join ',' } else { $_.Authors }; + return $authors; + + + + + + $description = if ($_.IsUpdate -and $_.ReleaseNotes) { + $_.ReleaseNotes + } + else { + $_.Description + } + $description = [System.Net.WebUtility]::HtmlDecode($description) + return $description + + + + + + $dependencies = if ($_.Dependencies -is [string]) { $_.Dependencies.Split('|') } else { $_.Dependencies }; + return $dependencies; + + + + + + + + + + NuGet.IPackage.List + + NuGet.DataServicePackage + + + + + + + + Id + + + Version + + + + + $authors = if ($_.Authors -is [string[]]) { $_.Authors -join ',' } else { $_.Authors }; + return $authors; + + + + + + $description = if ($_.IsUpdate -and $_.ReleaseNotes) { + $_.ReleaseNotes + } + else { + $_.Description + } + $description = [System.Net.WebUtility]::HtmlDecode($description) + return $description + + + + + + $dependencies = if ($_.Dependencies -is [string]) { $_.Dependencies.Split('|') } else { $_.Dependencies }; + return $dependencies; + + + + + DownloadCount + + + + + + + + + EnvDTE.Project + + ICSharpCode.PackageManagement.EnvDTE.Project + + + + + + 40 + + + 20 + + + + + + + + + + + UniqueName + + + Type + + + FullName + + + + + + + + + NuGet.Runtime.AssemblyBinding + + NuGet.Runtime.AssemblyBinding + + + + + 40 + + + + + + + + + Name + + + OldVersion + + + NewVersion + + + + + + + + \ No newline at end of file From 7c49a3e05094f3d0f494d74597fe543777f06543 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 27 Mar 2013 21:15:24 +0100 Subject: [PATCH 13/19] Use processContent="lax" as recommended in http://xml.coverpages.org/HP-StephensonSchemaBestPractices.pdf --- .../Highlighting/Resources/ModeV2.xsd | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd index 1b23a7bd54..047ef38a19 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd @@ -1,5 +1,5 @@ - + @@ -35,7 +35,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -142,11 +142,11 @@ - + - + @@ -157,11 +157,11 @@ - + - + \ No newline at end of file From 78e3f4a5170373de5e7a2ee262970bd1c9802cc6 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 29 Mar 2013 19:13:59 +0100 Subject: [PATCH 14/19] add highlighting definition for MarkDown syntax --- .../Highlighting/Resources/MarkDown-Mode.xshd | 61 +++++++++++++++++++ .../Highlighting/Resources/Resources.cs | 1 + .../ICSharpCode.AvalonEdit.csproj | 3 + 3 files changed, 65 insertions(+) create mode 100644 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/MarkDown-Mode.xshd diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/MarkDown-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/MarkDown-Mode.xshd new file mode 100644 index 0000000000..8192cc6d0f --- /dev/null +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/MarkDown-Mode.xshd @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + ^\# + + + \*\* + \*\* + + + __ + __ + + + \*(?![ ]) + \* + + + _ + _ + + + ` + ` + + + ^\t + ^(?!\t) + + + ^[ ]{4} + ^(?![ ]{4}) + + + ^> + ^(?!>) + + + \!\[.*\]\[.*\] + + + \[.*\]\(.*\) + + + \[.*\]\[.*\] + + + [ ]{2}$ + + + \ No newline at end of file diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs index 07827576cb..3dc7f08c09 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs @@ -42,6 +42,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting ".booproj;.build;.xfrm;.targets;.xaml;.xpt;" + ".xft;.map;.wsdl;.disco;.ps1xml;.nuspec").Split(';'), "XML-Mode.xshd"); + hlm.RegisterHighlighting("MarkDown", new[] { ".md" }, "MarkDown-Mode.xshd"); } } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj index 3c8bdf8d74..f2ee9b23ff 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj @@ -448,4 +448,7 @@ + + + \ No newline at end of file From 1c3161d42e0ccd3ed56566093a45b70643f5de3d Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 30 Mar 2013 14:58:05 +0000 Subject: [PATCH 15/19] Check known file extensions for icons when collecting usage data. Check the file extension against file filters first and then check the file extensions that have an associated icon. --- .../AvalonEdit.AddIn/Src/AvalonEditViewContent.cs | 8 +++++++- src/Main/Base/Project/Src/Services/IconService.cs | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs index c5be104c46..54683f7d9e 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs @@ -41,7 +41,7 @@ namespace ICSharpCode.AvalonEdit.AddIn if (file.FileName != null) { string filetype = Path.GetExtension(file.FileName); - if (!ProjectService.GetFileFilters().Any(f => f.ContainsExtension(filetype))) + if (!IsKnownFileExtension(filetype)) filetype = ".?"; trackedFeature = AnalyticsMonitorService.TrackFeature(typeof(AvalonEditViewContent), "open" + filetype.ToLowerInvariant()); } @@ -55,6 +55,12 @@ namespace ICSharpCode.AvalonEdit.AddIn codeEditor.TextCopied += codeEditor_TextCopied; } + bool IsKnownFileExtension(string filetype) + { + return ProjectService.GetFileFilters().Any(f => f.ContainsExtension(filetype)) || + IconService.HasImageForFile(filetype); + } + void codeEditor_Document_UndoStack_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (!isLoading) diff --git a/src/Main/Base/Project/Src/Services/IconService.cs b/src/Main/Base/Project/Src/Services/IconService.cs index 638a8f422e..3b7c622b80 100644 --- a/src/Main/Base/Project/Src/Services/IconService.cs +++ b/src/Main/Base/Project/Src/Services/IconService.cs @@ -102,6 +102,12 @@ namespace ICSharpCode.SharpDevelop return "Icons.16x16.MiscFiles"; } + public static bool HasImageForFile(string fileName) + { + string extension = Path.GetExtension(fileName).ToUpperInvariant(); + return extensionHashtable.ContainsKey(extension); + } + static void InitializeIcons(AddInTreeNode treeNode) { extensionHashtable[".PRJX"] = "Icons.16x16.SolutionIcon"; From cfa96921518bf1b9572fb85b13203d7131306195 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 30 Mar 2013 16:14:07 +0000 Subject: [PATCH 16/19] Add .aspx file filter. --- .../BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.addin | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.addin b/src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.addin index d68ee53668..c49b66ece7 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.addin +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.addin @@ -84,6 +84,11 @@ insertbefore="AllFiles" name="VB Razor Files (*.vbhtml)" extensions="*.vbhtml"/> + From 80aff3005848f0e8d6990e242335a7791a1863d7 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 30 Mar 2013 17:32:41 +0100 Subject: [PATCH 17/19] Fix several issues with SearchPanel. --- .../Search/SearchCommands.cs | 3 +- .../Search/SearchPanel.cs | 45 +++++++++---------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchCommands.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchCommands.cs index b7c125528e..884717b46b 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchCommands.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchCommands.cs @@ -74,7 +74,8 @@ namespace ICSharpCode.AvalonEdit.Search void ExecuteFind(object sender, ExecutedRoutedEventArgs e) { panel.Open(); - panel.SearchPattern = TextArea.Selection.GetText(); + if (!(TextArea.Selection.IsEmpty || TextArea.Selection.IsMultiline)) + panel.SearchPattern = TextArea.Selection.GetText(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, (Action)delegate { panel.Reactivate(); }); } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs index 634309520e..47cd06352d 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs @@ -29,7 +29,6 @@ namespace ICSharpCode.AvalonEdit.Search TextArea textArea; TextDocument currentDocument; SearchResultBackgroundRenderer renderer; - SearchResult currentResult; TextBox searchTextBox; SearchPanelAdorner adorner; @@ -176,15 +175,13 @@ namespace ICSharpCode.AvalonEdit.Search if (textArea == null) throw new ArgumentNullException("textArea"); this.textArea = textArea; - var layer = AdornerLayer.GetAdornerLayer(textArea); adorner = new SearchPanelAdorner(textArea, this); - if (layer != null) - layer.Add(adorner); DataContext = this; renderer = new SearchResultBackgroundRenderer(); currentDocument = textArea.Document; - currentDocument.TextChanged += textArea_Document_TextChanged; + if (currentDocument != null) + currentDocument.TextChanged += textArea_Document_TextChanged; textArea.DocumentChanged += textArea_DocumentChanged; KeyDown += SearchLayerKeyDown; @@ -251,8 +248,7 @@ namespace ICSharpCode.AvalonEdit.Search if (result == null) result = renderer.CurrentResults.FirstSegment; if (result != null) { - currentResult = result; - SetResult(result); + SelectResult(result); } } @@ -267,8 +263,7 @@ namespace ICSharpCode.AvalonEdit.Search if (result == null) result = renderer.CurrentResults.LastSegment; if (result != null) { - currentResult = result; - SetResult(result); + SelectResult(result); } } @@ -276,20 +271,20 @@ namespace ICSharpCode.AvalonEdit.Search void DoSearch(bool changeSelection) { + if (IsClosed) + return; renderer.CurrentResults.Clear(); - currentResult = null; if (!string.IsNullOrEmpty(SearchPattern)) { int offset = textArea.Caret.Offset; if (changeSelection) { textArea.ClearSelection(); } + // We cast from ISearchResult to SearchResult; this is safe because we always use the built-in strategy foreach (SearchResult result in strategy.FindAll(textArea.Document, 0, textArea.Document.TextLength)) { - if (currentResult == null && result.StartOffset >= offset) { - currentResult = result; - if (changeSelection) { - SetResult(result); - } + if (changeSelection && result.StartOffset >= offset) { + SelectResult(result); + changeSelection = false; } renderer.CurrentResults.Add(result); } @@ -303,15 +298,10 @@ namespace ICSharpCode.AvalonEdit.Search textArea.TextView.InvalidateLayer(KnownLayer.Selection); } - void SetResult(SearchResult result) + void SelectResult(SearchResult result) { - textArea.Caret.Offset = currentResult.StartOffset; - textArea.Selection = Selection.Create(textArea, currentResult.StartOffset, currentResult.EndOffset); - var foldingManager = textArea.GetService(typeof(FoldingManager)) as FoldingManager; - if (foldingManager != null) { - foreach (var folding in foldingManager.GetFoldingsContaining(result.StartOffset)) - folding.IsFolded = false; - } + textArea.Caret.Offset = result.StartOffset; + textArea.Selection = Selection.Create(textArea, result.StartOffset, result.EndOffset); textArea.Caret.BringCaretToView(); // show caret even if the editor does not have the Keyboard Focus textArea.Caret.Show(); @@ -353,13 +343,19 @@ namespace ICSharpCode.AvalonEdit.Search /// public void Close() { + bool hasFocus = this.IsKeyboardFocusWithin; + var layer = AdornerLayer.GetAdornerLayer(textArea); if (layer != null) layer.Remove(adorner); messageView.IsOpen = false; textArea.TextView.BackgroundRenderers.Remove(renderer); - textArea.Focus(); + if (hasFocus) + textArea.Focus(); IsClosed = true; + + // Clear existing search results so that the segments don't have to be maintained + renderer.CurrentResults.Clear(); } /// @@ -384,6 +380,7 @@ namespace ICSharpCode.AvalonEdit.Search layer.Add(adorner); textArea.TextView.BackgroundRenderers.Add(renderer); IsClosed = false; + DoSearch(false); } /// From 8e799bf3d4236c384be898057a695632c3a1bf65 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 30 Mar 2013 17:33:29 +0100 Subject: [PATCH 18/19] Allow running actions as part of file templates. --- .../Project/Src/Gui/Dialogs/NewFileDialog.cs | 15 ++-- .../Internal/Templates/File/FileTemplate.cs | 72 +++++++++++++++++++ 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs index f201e5abd4..aebb1ec5c5 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs @@ -159,9 +159,7 @@ namespace ICSharpCode.SharpDevelop.Gui Category cat = GetCategory(StringParser.Parse(titem.Template.Category), StringParser.Parse(titem.Template.Subcategory)); cat.Templates.Add(titem); - if (cat.Selected == false && template.WizardPath == null) { - cat.Selected = true; - } + cat.Selected = true; if (!cat.HasSelectedTemplate && titem.Template.FileDescriptionTemplates.Count == 1) { if (((FileDescriptionTemplate)titem.Template.FileDescriptionTemplates[0]).Name.StartsWith("Empty")) { titem.Selected = true; @@ -473,16 +471,24 @@ namespace ICSharpCode.SharpDevelop.Gui StringParserPropertyContainer.FileCreation["StandardNamespace"] = CustomToolsService.GetDefaultNamespace(project, fileName); } } + + FileTemplateOptions options = new FileTemplateOptions(); + options.ClassName = GenerateValidClassOrNamespaceName(Path.GetFileNameWithoutExtension(fileName), false); + options.FileName = FileName.Create(fileName); + options.IsUntitled = allowUntitledFiles; + options.Namespace = StringParserPropertyContainer.FileCreation["StandardNamespace"]; + StringParserPropertyContainer.FileCreation["FullName"] = fileName; StringParserPropertyContainer.FileCreation["FileName"] = Path.GetFileName(fileName); StringParserPropertyContainer.FileCreation["FileNameWithoutExtension"] = Path.GetFileNameWithoutExtension(fileName); StringParserPropertyContainer.FileCreation["Extension"] = Path.GetExtension(fileName); StringParserPropertyContainer.FileCreation["Path"] = Path.GetDirectoryName(fileName); - StringParserPropertyContainer.FileCreation["ClassName"] = GenerateValidClassOrNamespaceName(Path.GetFileNameWithoutExtension(fileName), false); + StringParserPropertyContainer.FileCreation["ClassName"] = options.ClassName; // when adding a file to a project (but not when creating a standalone file while a project is open): if (ProjectService.CurrentProject != null && !this.allowUntitledFiles) { + options.Project = ProjectService.CurrentProject; // add required assembly references to the project bool changes = false; foreach (ReferenceProjectItem reference in item.Template.RequiredAssemblyReferences) { @@ -525,6 +531,7 @@ namespace ICSharpCode.SharpDevelop.Gui foreach (KeyValuePair entry in createdFiles) { FileService.FireFileCreated(entry.Key, false); } + item.Template.RunActions(options); } } diff --git a/src/Main/Base/Project/Src/Internal/Templates/File/FileTemplate.cs b/src/Main/Base/Project/Src/Internal/Templates/File/FileTemplate.cs index 838497486f..f5faecb38c 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/File/FileTemplate.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/File/FileTemplate.cs @@ -95,6 +95,37 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates } } + public class FileTemplateOptions + { + /// + /// Gets/Sets whether the file being created will be untitled. + /// + public bool IsUntitled { get; set; } + + /// + /// The parent project to which this file is added. + /// Can be null when creating a file outside of a project. + /// + public IProject Project { get; set; } + + /// + /// The name of the file + /// + public FileName FileName { get; set; } + + /// + /// The default namespace to use for the newly created file. + /// + public string Namespace { get; set; } + + /// + /// The class name (generated from the file name). + /// + public string ClassName { get; set; } + + //IDictionary properties; + } + /// /// This class defines and holds the new file templates. /// @@ -120,6 +151,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates List requiredAssemblyReferences = new List(); XmlElement fileoptions = null; + Action actions; int IComparable.CompareTo(object other) { @@ -165,6 +197,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates return description; } } + [Obsolete] public string WizardPath { get { return wizardpath; @@ -275,6 +308,14 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates } } + if (doc.DocumentElement["Actions"] != null) { + foreach (XmlElement el in doc.DocumentElement["Actions"]) { + Action action = ReadAction(el); + if (action != null) + actions += action; + } + } + fileoptions = doc.DocumentElement["AdditionalOptions"]; doc.DocumentElement.SetAttribute("fileName", filename); // used for template loading warnings @@ -289,6 +330,37 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates } } + static Action ReadAction(XmlElement el) + { + switch (el.Name) { + case "RunCommand": + if (el.HasAttribute("path")) { + try { + ICommand command = (ICommand)AddInTree.BuildItem(el.GetAttribute("path"), null); + return fileCreateInformation => { + command.Owner = fileCreateInformation; + command.Run(); + }; + } catch (TreePathNotFoundException ex) { + MessageService.ShowWarning(ex.Message + " - in " + el.OwnerDocument.DocumentElement.GetAttribute("fileName")); + return null; + } + } else { + ProjectTemplate.WarnAttributeMissing(el, "path"); + return null; + } + default: + ProjectTemplate.WarnObsoleteNode(el, "Unknown action element is ignored"); + return null; + } + } + + public void RunActions(FileTemplateOptions options) + { + if (actions != null) + actions(options); + } + public static void UpdateTemplates() { string dataTemplateDir = Path.Combine(PropertyService.DataDirectory, "templates", "file"); From 406354bee0e349186868288447f23301a679c95c Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 30 Mar 2013 21:08:09 +0100 Subject: [PATCH 19/19] further improvements and bugfixes for MarkDown-Mode --- .../Highlighting/Resources/MarkDown-Mode.xshd | 47 +++++++++---------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/MarkDown-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/MarkDown-Mode.xshd index 8192cc6d0f..ead5045ab8 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/MarkDown-Mode.xshd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/MarkDown-Mode.xshd @@ -10,38 +10,33 @@ - - ^\# - - - \*\* - \*\* - - - __ - __ - - - \*(?![ ]) - \* - - - _ - _ - - - ` - ` - - + + ^\#.* + + + \*\*.*\*\* + + + __.*__ + + + \*(?![ ]).*\* + + + _.*_ + + + `.*` + + ^\t ^(?!\t) - + ^[ ]{4} ^(?![ ]{4}) - + ^> ^(?!>)