diff --git a/src/AddIns/BackendBindings/Scripting/Test/Utils/MockTextEditorOptions.cs b/src/AddIns/BackendBindings/Scripting/Test/Utils/MockTextEditorOptions.cs index 8b002010e0..25ebe17d96 100644 --- a/src/AddIns/BackendBindings/Scripting/Test/Utils/MockTextEditorOptions.cs +++ b/src/AddIns/BackendBindings/Scripting/Test/Utils/MockTextEditorOptions.cs @@ -30,5 +30,11 @@ namespace ICSharpCode.Scripting.Tests.Utils throw new NotImplementedException(); } } + + public string FontFamily { + get { + throw new NotImplementedException(); + } + } } } diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs index 647efc217c..63f3881a7a 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs +++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs @@ -172,7 +172,14 @@ namespace ICSharpCode.VBNetBinding bool? GetValue(string name, bool defaultVal) { - string val = GetEvaluatedProperty(name); + string val; + try { + val = GetEvaluatedProperty(name); + } catch (ObjectDisposedException) { + // This can happen when the project is disposed but the resolver still tries + // to access Option Infer (or similar). + val = null; + } if (val == null) return defaultVal; diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditorOptions.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditorOptions.cs index ff2bb39fd8..e39db855f5 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditorOptions.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditorOptions.cs @@ -50,5 +50,11 @@ namespace WixBinding.Tests.Utils } public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged { add { } remove { } } + + public string FontFamily { + get { + throw new NotImplementedException(); + } + } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs index 8379c1ca13..51b5de4694 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs @@ -50,8 +50,6 @@ namespace ICSharpCode.AvalonEdit.AddIn if (textView != null && textView.VisualLinesValid) { var zeroLineInfo = changeWatcher.GetChange(0); - Debug.Assert(zeroLineInfo.Change == ChangeType.None || zeroLineInfo.Change == ChangeType.Deleted); - foreach (VisualLine line in textView.VisualLines) { Rect rect = new Rect(0, line.VisualTop - textView.ScrollOffset.Y, 5, line.Height); @@ -202,7 +200,7 @@ namespace ICSharpCode.AvalonEdit.AddIn differ.editor.Visibility = Visibility.Collapsed; differ.copyButton.Visibility = Visibility.Collapsed; } else { - var baseDocument = new TextDocument(changeWatcher.BaseDocument.Text); + var baseDocument = new TextDocument(DocumentUtilitites.GetTextSource(changeWatcher.BaseDocument)); if (differ.editor.SyntaxHighlighting != null) { var mainHighlighter = new DocumentHighlighter(baseDocument, differ.editor.SyntaxHighlighting.MainRuleSet); var popupHighlighter = differ.editor.TextArea.GetService(typeof(IHighlighter)) as DocumentHighlighter; diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs index 4f68a185dc..4ce0afc5e4 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs @@ -118,8 +118,9 @@ namespace ICSharpCode.AvalonEdit.AddIn } else { this.errorPainter.UpdateErrors(); } - changeWatcher.Initialize(this.Document, value); - + if (changeWatcher != null) { + changeWatcher.Initialize(this.Document, value); + } FetchParseInformation(); } } @@ -146,8 +147,9 @@ namespace ICSharpCode.AvalonEdit.AddIn textMarkerService = new TextMarkerService(this); iconBarManager = new IconBarManager(); - changeWatcher = new DefaultChangeWatcher(); - + if (CodeEditorOptions.Instance.EnableChangeMarkerMargin) { + changeWatcher = new DefaultChangeWatcher(); + } primaryTextEditor = CreateTextEditor(); primaryTextEditorAdapter = (CodeEditorAdapter)primaryTextEditor.TextArea.GetService(typeof(ITextEditor)); Debug.Assert(primaryTextEditorAdapter != null); @@ -206,7 +208,9 @@ namespace ICSharpCode.AvalonEdit.AddIn textView.Services.AddService(typeof(IBookmarkMargin), iconBarManager); codeEditorView.TextArea.LeftMargins.Insert(0, new IconBarMargin(iconBarManager)); - codeEditorView.TextArea.LeftMargins.Add(new ChangeMarkerMargin(changeWatcher)); + if (CodeEditorOptions.Instance.EnableChangeMarkerMargin) { + codeEditorView.TextArea.LeftMargins.Add(new ChangeMarkerMargin(changeWatcher)); + } textView.Services.AddService(typeof(ISyntaxHighlighter), new AvalonEditSyntaxHighlighterAdapter(textView)); diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs index 9bfa4394a6..a2cbb176f7 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DefaultChangeWatcher.cs @@ -25,7 +25,7 @@ namespace ICSharpCode.AvalonEdit.AddIn IDocument baseDocument; IDocumentVersionProvider usedProvider; IDisposable watcher; - FileName fileName; + FileName currentFileName; public event EventHandler ChangeOccurred; @@ -43,36 +43,38 @@ namespace ICSharpCode.AvalonEdit.AddIn public void Initialize(IDocument document, FileName fileName) { - if (changeList != null && changeList.Any()) - return; + if (this.document == null) { + this.document = document; + this.textDocument = (TextDocument)document.GetService(typeof(TextDocument)); + this.changeList = new CompressingTreeList((x, y) => x.Equals(y)); + } - this.document = document; - this.fileName = fileName; - this.textDocument = (TextDocument)document.GetService(typeof(TextDocument)); - this.changeList = new CompressingTreeList((x, y) => x.Equals(y)); - InitializeBaseDocument(); + InitializeBaseDocument(fileName); + if (watcher != null) + watcher.Dispose(); - if (usedProvider != null) { + if (usedProvider != null) watcher = usedProvider.WatchBaseVersionChanges(fileName, HandleBaseVersionChanges); - } - SetupInitialFileState(false); + SetupInitialFileState(fileName != currentFileName); + currentFileName = fileName; - this.textDocument.LineTrackers.Add(this); - this.textDocument.UndoStack.PropertyChanged += UndoStackPropertyChanged; + if (!this.textDocument.LineTrackers.Contains(this)) { + this.textDocument.LineTrackers.Add(this); + this.textDocument.UndoStack.PropertyChanged += UndoStackPropertyChanged; + } } void HandleBaseVersionChanges(object sender, EventArgs e) { - ICSharpCode.Core.LoggingService.Info("HandleBaseVersionChanges"); - InitializeBaseDocument(); + InitializeBaseDocument(currentFileName); SetupInitialFileState(true); } - void InitializeBaseDocument() + void InitializeBaseDocument(FileName fileName) { - Stream baseFileStream = GetBaseVersion(); + Stream baseFileStream = GetBaseVersion(fileName); if (baseFileStream != null) { // ReadAll() is taking care of closing the stream baseDocument = new ReadOnlyDocument(ReadAll(baseFileStream)); @@ -140,7 +142,7 @@ namespace ICSharpCode.AvalonEdit.AddIn return FileReader.ReadFileContent(memory, ParserService.DefaultFileEncoding); } - Stream GetBaseVersion() + Stream GetBaseVersion(FileName fileName) { foreach (IDocumentVersionProvider provider in VersioningServices.Instance.DocumentVersionProviders) { var result = provider.OpenBaseVersion(fileName); diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs index fde16a5eb4..0d07b6111e 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs @@ -66,6 +66,19 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options } } + bool enableChangeMarkerMargin = true; + + [DefaultValue(true)] + public bool EnableChangeMarkerMargin { + get { return enableChangeMarkerMargin; } + set { + if (enableChangeMarkerMargin != value) { + enableChangeMarkerMargin = value; + OnPropertyChanged("EnableChangeMarkerMargin"); + } + } + } + bool wordWrap; [DefaultValue(false)] diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml index 3902d79de4..6ff4d01738 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml @@ -17,6 +17,9 @@ + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs index 000d8ed2de..d865a1f6e2 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs @@ -142,34 +142,40 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView public bool CanInsert(IEnumerable nodes, OutlineNode after, bool copy) { - var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); var placementBehavior = DesignItem.GetBehavior(); - if(operation!=null) - return placementBehavior.CanEnterContainer(operation); + if (placementBehavior == null) + return false; + var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); + if (operation != null) { + bool canEnter = placementBehavior.CanEnterContainer(operation); + operation.Abort(); + return canEnter; + } return false; } public void Insert(IEnumerable nodes, OutlineNode after, bool copy) { - if (copy) { - nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())); - } - else { - foreach (var node in nodes) { - node.DesignItem.Remove(); + using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) { + if (copy) { + nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList(); + } else { + foreach (var node in nodes) { + node.DesignItem.Remove(); + } } - } - var index = after == null ? 0 : Children.IndexOf(after) + 1; + var index = after == null ? 0 : Children.IndexOf(after) + 1; - var content = DesignItem.ContentProperty; - if (content.IsCollection) { - foreach (var node in nodes) { - content.CollectionElements.Insert(index++, node.DesignItem); + var content = DesignItem.ContentProperty; + if (content.IsCollection) { + foreach (var node in nodes) { + content.CollectionElements.Insert(index++, node.DesignItem); + } + } else { + content.SetValue(nodes.First().DesignItem); } - } - else { - content.SetValue(nodes.First().DesignItem); + moveTransaction.Commit(); } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs index 5142c51963..42e302894c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs @@ -16,13 +16,15 @@ namespace ICSharpCode.WpfDesign.Designer.Services sealed class DragMoveMouseGesture : ClickOrDragMouseGesture { bool isDoubleClick; + bool setSelectionIfNotMoving; MoveLogic moveLogic; - internal DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick) + internal DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick, bool setSelectionIfNotMoving = false) { Debug.Assert(clickedOn != null); this.isDoubleClick = isDoubleClick; + this.setSelectionIfNotMoving = setSelectionIfNotMoving; this.positionRelativeTo = clickedOn.Services.DesignPanel; moveLogic = new MoveLogic(clickedOn); @@ -41,10 +43,14 @@ namespace ICSharpCode.WpfDesign.Designer.Services protected override void OnMouseUp(object sender, MouseButtonEventArgs e) { - if (!hasDragStarted && isDoubleClick) { - // user made a double-click - Debug.Assert(moveLogic.Operation == null); - moveLogic.HandleDoubleClick(); + if (!hasDragStarted) { + if (isDoubleClick) { + // user made a double-click + Debug.Assert(moveLogic.Operation == null); + moveLogic.HandleDoubleClick(); + } else if (setSelectionIfNotMoving) { + services.Selection.SetSelectedComponents(new DesignItem[] { moveLogic.ClickedOn }, SelectionTypes.Auto); + } } moveLogic.Stop(); Stop(); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs index cc9c4af1bc..5d44ae00aa 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs @@ -37,9 +37,18 @@ namespace ICSharpCode.WpfDesign.Designer.Services if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) { e.Handled = true; ISelectionService selectionService = designPanel.Context.Services.Selection; - selectionService.SetSelectedComponents(new DesignItem[] { result.ModelHit }, SelectionTypes.Auto); + bool setSelectionIfNotMoving = false; if (selectionService.IsComponentSelected(result.ModelHit)) { - new DragMoveMouseGesture(result.ModelHit, e.ClickCount == 2).Start(designPanel, e); + setSelectionIfNotMoving = true; + // There might be multiple components selected. We might have + // to set the selection to only the item clicked on + // (or deselect the item clicked on if Ctrl is pressed), + // but we should do so only if the user isn't performing a drag operation. + } else { + selectionService.SetSelectedComponents(new DesignItem[] { result.ModelHit }, SelectionTypes.Auto); + } + if (selectionService.IsComponentSelected(result.ModelHit)) { + new DragMoveMouseGesture(result.ModelHit, e.ClickCount == 2, setSelectionIfNotMoving).Start(designPanel, e); } } } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditorOptions.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditorOptions.cs index e373e3ca12..a88969bab1 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditorOptions.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockTextEditorOptions.cs @@ -46,5 +46,11 @@ namespace XmlEditor.Tests.Utils throw new NotImplementedException(); } } + + public string FontFamily { + get { + throw new NotImplementedException(); + } + } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsView.xaml b/src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsView.xaml index 3bed9bab26..92c3ca8c9c 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsView.xaml +++ b/src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsView.xaml @@ -55,12 +55,12 @@ Margin="4" Orientation="Horizontal" HorizontalAlignment="Right"> -