Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RetailCoder.VBE/Inspections/Abstract/IInspectionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public interface IInspectionResult : IComparable<IInspectionResult>, IComparable
QualifiedSelection QualifiedSelection { get; }
IInspection Inspection { get; }
object[] ToArray();
string ToClipboardString();
}
}
40 changes: 28 additions & 12 deletions RetailCoder.VBE/Inspections/Abstract/InspectionResultBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Antlr4.Runtime;
using Rubberduck.Inspections.Resources;
Expand Down Expand Up @@ -87,18 +88,33 @@ public virtual int CompareTo(IInspectionResult other)
return Inspection.CompareTo(other.Inspection);
}

//public override string ToString()
//{
// var module = QualifiedSelection.QualifiedName;
// return string.Format(
// InspectionsUI.QualifiedSelectionInspection,
// Inspection.Severity,
// Description,
// "(" + module.ProjectDisplayName + ")",
// module.ProjectName,
// module.ComponentName,
// QualifiedSelection.Selection.StartLine);
//}
/// <summary>
/// WARNING: This property can have side effects. It can change the ActiveVBProject if the result has a null Declaration,
/// which causes a flicker in the VBE. This should only be called if it is *absolutely* necessary.
/// </summary>
public string ToClipboardString()
{
var module = QualifiedSelection.QualifiedName;
var documentName = _target != null ? _target.ProjectDisplayName : string.Empty;
if (string.IsNullOrEmpty(documentName))
{
var component = module.Component;
documentName = component != null ? component.ParentProject.ProjectDisplayName : string.Empty;
}
if (string.IsNullOrEmpty(documentName))
{
documentName = Path.GetFileName(module.ProjectPath);
}

return string.Format(
InspectionsUI.QualifiedSelectionInspection,
Inspection.Severity,
Description,
"(" + documentName + ")",
module.ProjectName,
module.ComponentName,
QualifiedSelection.Selection.StartLine);
}

public virtual NavigateCodeEventArgs GetNavigationArgs()
{
Expand Down
5 changes: 5 additions & 0 deletions RetailCoder.VBE/Rubberduck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@
<Reference Include="extensibility, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="ICSharpCode.AvalonEdit">
<HintPath>..\packages\AvalonEdit.5.0.3\lib\Net40\ICSharpCode.AvalonEdit.dll</HintPath>
</Reference>
<Reference Include="Infralution.Localization.Wpf">
<HintPath>..\libs\Infralution.Localization.Wpf.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -504,6 +507,7 @@
<Compile Include="UI\Command\MenuItems\RegexAssistantCommand.cs" />
<Compile Include="UI\Command\MenuItems\RegexAssistantCommandMenuItem.cs" />
<Compile Include="UI\Command\MenuItems\ParentMenus\ToolsParentMenu.cs" />
<Compile Include="UI\Controls\BindableTextEditor.cs" />
<Compile Include="UI\Controls\LinkButton.xaml.cs">
<DependentUpon>LinkButton.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -1155,6 +1159,7 @@
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<EmbeddedResource Include="UI\Controls\vba.xshd" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\minus-circle.png" />
Expand Down
14 changes: 14 additions & 0 deletions RetailCoder.VBE/UI/About/AboutDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,19 @@ private AboutControlViewModel ViewModel
AboutControl.DataContext = _viewModel;
}
}

private void AboutDialog_Load(object sender, System.EventArgs e)
{

}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Escape)
{
this.Close();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
}
76 changes: 76 additions & 0 deletions RetailCoder.VBE/UI/Controls/BindableTextEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.ComponentModel;
using System.Reflection;
using System.Windows;
using System.Windows.Media;
using System.Xml;
using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Highlighting.Xshd;

namespace Rubberduck.UI.Controls
{
//see http://stackoverflow.com/a/20823917/4088852
public class BindableTextEditor : TextEditor, INotifyPropertyChanged
{
public BindableTextEditor()
{
WordWrap = false;

var highlighter = LoadHighlighter("Rubberduck.UI.Controls.vba.xshd");
SyntaxHighlighting = highlighter;

//Style hyperlinks so they look like comments. Note - this needs to move if used for user code.
TextArea.TextView.LinkTextUnderline = false;
TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush(Colors.Green);
Options.RequireControlModifierForHyperlinkClick = false;
Options.EnableHyperlinks = true;
Options.EnableEmailHyperlinks = true;
}

public new string Text
{
get { return base.Text; }
set { base.Text = value; }
}

public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(BindableTextEditor), new PropertyMetadata((obj, args) =>
{
var target = (BindableTextEditor)obj;
target.Text = (string)args.NewValue;
}));

protected override void OnTextChanged(EventArgs e)
{
RaisePropertyChanged("Text");
base.OnTextChanged(e);
}

public void RaisePropertyChanged(string property)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}

public event PropertyChangedEventHandler PropertyChanged;

private static IHighlightingDefinition LoadHighlighter(string resource)
{
var assembly = Assembly.GetExecutingAssembly();
using (var stream = assembly.GetManifestResourceStream(resource))
{
if (stream == null)
{
return null;
}
using (var reader = new XmlTextReader(stream))
{
return HighlightingLoader.Load(reader, HighlightingManager.Instance);
}
}
}
}
}
Loading