Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 436 B |
Before Width: | Height: | Size: 628 B After Width: | Height: | Size: 628 B |
After Width: | Height: | Size: 663 B |
After Width: | Height: | Size: 609 B |
After Width: | Height: | Size: 713 B |
After Width: | Height: | Size: 777 B |
After Width: | Height: | Size: 729 B |
After Width: | Height: | Size: 749 B |
After Width: | Height: | Size: 822 B |
After Width: | Height: | Size: 706 B |
After Width: | Height: | Size: 525 B |
@ -0,0 +1,110 @@
@@ -0,0 +1,110 @@
|
||||
// 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.NRefactory; |
||||
using ICSharpCode.NRefactory.Completion; |
||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion |
||||
{ |
||||
/// <summary>
|
||||
/// Code completion data for snippets.
|
||||
/// </summary>
|
||||
public class SnippetCompletionData : IFancyCompletionItem, ISnippetCompletionItem, ICompletionData, ICompletionItem |
||||
{ |
||||
#region ICompletionData implementation
|
||||
|
||||
void ICompletionData.AddOverload(ICompletionData data) { } |
||||
|
||||
CompletionCategory category; |
||||
CompletionCategory ICompletionData.CompletionCategory { |
||||
get { return category; } |
||||
set { category = value; } |
||||
} |
||||
|
||||
string ICompletionData.DisplayText { |
||||
get { return snippet.Text; } |
||||
set { } |
||||
} |
||||
|
||||
string ICompletionData.Description { |
||||
get { return snippet.Description; } |
||||
set { } |
||||
} |
||||
|
||||
string ICompletionData.CompletionText { |
||||
get { return snippet.Text; } |
||||
set { } |
||||
} |
||||
|
||||
DisplayFlags displayFlags; |
||||
DisplayFlags ICompletionData.DisplayFlags { |
||||
get { return displayFlags; } |
||||
set { displayFlags = value; } |
||||
} |
||||
|
||||
bool ICompletionData.HasOverloads { |
||||
get { return false; } |
||||
} |
||||
|
||||
System.Collections.Generic.IEnumerable<ICompletionData> ICompletionData.OverloadedData { |
||||
get { return EmptyList<ICompletionData>.Instance; } |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
ISnippetCompletionItem snippet; |
||||
|
||||
public SnippetCompletionData(ISnippetCompletionItem completionItem) |
||||
{ |
||||
snippet = completionItem; |
||||
} |
||||
|
||||
#region ISnippetCompletionItem implementation
|
||||
|
||||
public string Keyword { |
||||
get { return snippet.Keyword; } |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region ICompletionItem implementation
|
||||
|
||||
public void Complete(CompletionContext context) |
||||
{ |
||||
snippet.Complete(context); |
||||
} |
||||
|
||||
public string Text { |
||||
get { return snippet.Text; } |
||||
} |
||||
|
||||
string ICompletionItem.Description { |
||||
get { return snippet.Description; } |
||||
} |
||||
|
||||
public ICSharpCode.SharpDevelop.IImage Image { |
||||
get { return snippet.Image; } |
||||
} |
||||
|
||||
public double Priority { |
||||
get { return snippet.Priority; } |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region IFancyCompletionItem implementation
|
||||
|
||||
public object Content { |
||||
get { return snippet.Text; } |
||||
} |
||||
|
||||
public object Description { |
||||
get { return snippet.Description; } |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
// 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 System.Linq; |
||||
using Microsoft.Win32; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser |
||||
{ |
||||
/// <summary>
|
||||
/// Description of OpenAssemblyFromFileCommand.
|
||||
/// </summary>
|
||||
class OpenAssemblyFromFileCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
var classBrowser = SD.GetService<IClassBrowser>(); |
||||
if (classBrowser != null) { |
||||
OpenFileDialog openFileDialog = new OpenFileDialog(); |
||||
openFileDialog.Filter = "Assembly files (*.exe, *.dll)|*.exe;*.dll"; |
||||
openFileDialog.CheckFileExists = true; |
||||
openFileDialog.CheckPathExists = true; |
||||
if (openFileDialog.ShowDialog() ?? false) |
||||
{ |
||||
classBrowser.AssemblyList.Assemblies.Add(ClassBrowserPad.CreateAssemblyModelFromFile(openFileDialog.FileName)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Description of OpenAssemblyFromGACCommand.
|
||||
/// </summary>
|
||||
class OpenAssemblyFromGACCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
var classBrowser = SD.GetService<IClassBrowser>(); |
||||
if (classBrowser != null) { |
||||
OpenFromGacDialog gacDialog = new OpenFromGacDialog(); |
||||
if (gacDialog.ShowDialog() ?? false) |
||||
{ |
||||
foreach (string assemblyFile in gacDialog.SelectedFileNames) { |
||||
classBrowser.AssemblyList.Assemblies.Add(ClassBrowserPad.CreateAssemblyModelFromFile(assemblyFile)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Description of RemoveAssemblyCommand.
|
||||
/// </summary>
|
||||
class RemoveAssemblyCommand : SimpleCommand |
||||
{ |
||||
public override bool CanExecute(object parameter) |
||||
{ |
||||
return parameter is AssemblyModel; |
||||
} |
||||
|
||||
public override void Execute(object parameter) |
||||
{ |
||||
var classBrowser = SD.GetService<IClassBrowser>(); |
||||
if (classBrowser != null) { |
||||
IAssemblyModel assemblyModel = (IAssemblyModel) parameter; |
||||
classBrowser.AssemblyList.Assemblies.Remove(assemblyModel); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Description of RemoveAssemblyCommand.
|
||||
/// </summary>
|
||||
class ClassBrowserCollapseAllCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
// var classBrowser = SD.GetService<IClassBrowser>() as ClassBrowserPad;
|
||||
// if (classBrowser != null) {
|
||||
// classBrowser.TreeView
|
||||
// }
|
||||
} |
||||
} |
||||
} |
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
// 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 Microsoft.Win32; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser |
||||
{ |
||||
/// <summary>
|
||||
/// Description of OpenAssemblyCommand.
|
||||
/// </summary>
|
||||
class OpenAssemblyCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
<Window |
||||
x:Class="ICSharpCode.SharpDevelop.Dom.ClassBrowser.OpenFromGacDialog" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
Title="Open From GAC" |
||||
Style="{DynamicResource DialogWindow}" |
||||
WindowStartupLocation="CenterOwner" |
||||
ResizeMode="CanResizeWithGrip" |
||||
MinWidth="200" |
||||
MinHeight="150" |
||||
Height="350" |
||||
Width="750" |
||||
FocusManager.FocusedElement="{Binding ElementName=filterTextBox}"> |
||||
<Grid |
||||
Margin="12,8"> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition |
||||
Height="Auto" /> |
||||
<RowDefinition |
||||
Height="1*" /> |
||||
<RowDefinition |
||||
Height="Auto" /> |
||||
</Grid.RowDefinitions> |
||||
<DockPanel> |
||||
<Label DockPanel.Dock="Left" Target="{Binding ElementName=filterTextBox}">_Search:</Label> |
||||
<TextBox Name="filterTextBox" TextChanged="FilterTextBox_TextChanged" /> |
||||
</DockPanel> |
||||
<ListView Name="listView" Grid.Row="1" Margin="0, 8" core:SortableGridViewColumn.SortMode="Automatic" SelectionChanged="ListView_SelectionChanged"> |
||||
<ListView.View> |
||||
<GridView> |
||||
<core:SortableGridViewColumn x:Name="nameColumn" Width="300" Header="Reference Name" DisplayMemberBinding="{Binding ShortName}" /> |
||||
<core:SortableGridViewColumn Width="75" Header="Version" DisplayMemberBinding="{Binding Version}" /> |
||||
<core:SortableGridViewColumn Width="65" Header="Culture" DisplayMemberBinding="{Binding Culture}" /> |
||||
<core:SortableGridViewColumn Width="115" Header="Public Key Token" DisplayMemberBinding="{Binding PublicKeyToken}" /> |
||||
<core:SortableGridViewColumn Width="1000" Header="Location" DisplayMemberBinding="{Binding FileName}" /> |
||||
</GridView> |
||||
</ListView.View> |
||||
</ListView> |
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right"> |
||||
<Button IsDefault="True" Margin="2,0" Height="23" MinWidth="75" IsEnabled="False" Name="okButton" Click="OKButton_Click">Open</Button> |
||||
<Button IsCancel="True" Margin="2,0" Height="23" MinWidth="75">Cancel</Button> |
||||
</StackPanel> |
||||
<ProgressBar Grid.Row="1" Height="10" HorizontalAlignment="Stretch" Name="gacReadingProgressBar" VerticalAlignment="Bottom" Visibility="Hidden" /> |
||||
</Grid> |
||||
</Window> |
@ -0,0 +1,188 @@
@@ -0,0 +1,188 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.ComponentModel; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Threading; |
||||
using ICSharpCode.Core.Presentation; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Parser; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for OpenFromGacDialog.xaml
|
||||
/// </summary>
|
||||
public partial class OpenFromGacDialog : Window |
||||
{ |
||||
ObservableCollection<GacEntry> gacEntries = new ObservableCollection<GacEntry>(); |
||||
ObservableCollection<GacEntry> filteredEntries = new ObservableCollection<GacEntry>(); |
||||
Predicate<GacEntry> filterMethod = _ => true; |
||||
volatile bool cancelFetchThread; |
||||
|
||||
public OpenFromGacDialog() |
||||
{ |
||||
InitializeComponent(); |
||||
FormLocationHelper.ApplyWindow(this, "ICSharpCode.SharpDevelop.Dom.OpenFromGacDialog.Bounds", true); |
||||
listView.ItemsSource = filteredEntries; |
||||
SortableGridViewColumn.SetCurrentSortColumn(listView, nameColumn); |
||||
SortableGridViewColumn.SetSortDirection(listView, ColumnSortDirection.Ascending); |
||||
|
||||
new Thread(new ThreadStart(FetchGacContents)).Start(); |
||||
} |
||||
|
||||
protected override void OnClosing(CancelEventArgs e) |
||||
{ |
||||
base.OnClosing(e); |
||||
cancelFetchThread = true; |
||||
} |
||||
|
||||
#region Fetch Gac Contents
|
||||
sealed class GacEntry |
||||
{ |
||||
readonly DomAssemblyName r; |
||||
readonly string fileName; |
||||
string formattedVersion; |
||||
|
||||
public GacEntry(DomAssemblyName r, string fileName) |
||||
{ |
||||
this.r = r; |
||||
this.fileName = fileName; |
||||
} |
||||
|
||||
public string FullName { |
||||
get { return r.FullName; } |
||||
} |
||||
|
||||
public string ShortName { |
||||
get { return r.ShortName; } |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return fileName; } |
||||
} |
||||
|
||||
public Version Version { |
||||
get { return r.Version; } |
||||
} |
||||
|
||||
public string FormattedVersion { |
||||
get { |
||||
if (formattedVersion == null) |
||||
formattedVersion = Version.ToString(); |
||||
return formattedVersion; |
||||
} |
||||
} |
||||
|
||||
public string Culture { |
||||
get { return r.Culture; } |
||||
} |
||||
|
||||
public string PublicKeyToken { |
||||
get { |
||||
StringBuilder s = new StringBuilder(); |
||||
foreach (byte b in r.PublicKeyToken) |
||||
s.Append(b.ToString("x2")); |
||||
return s.ToString(); |
||||
} |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return r.FullName; |
||||
} |
||||
} |
||||
|
||||
void FetchGacContents() |
||||
{ |
||||
IGlobalAssemblyCacheService gacService = SD.GetService<IGlobalAssemblyCacheService>(); |
||||
HashSet<string> fullNames = new HashSet<string>(); |
||||
UpdateProgressBar(pg => { pg.Visibility = System.Windows.Visibility.Visible; pg.IsIndeterminate = true; }); |
||||
var list = gacService.Assemblies.TakeWhile(_ => !cancelFetchThread).ToList(); |
||||
UpdateProgressBar(pg => { pg.IsIndeterminate = false; pg.Maximum = list.Count; }); |
||||
foreach (var r in list) { |
||||
if (cancelFetchThread) |
||||
break; |
||||
if (fullNames.Add(r.FullName)) { // filter duplicates
|
||||
var file = gacService.FindAssemblyInNetGac(r); |
||||
if (file != null) { |
||||
var entry = new GacEntry(r, file); |
||||
UpdateProgressBar(pg => { pg.Value = pg.Value + 1; AddNewEntry(entry); }); |
||||
} |
||||
} |
||||
} |
||||
UpdateProgressBar(pg => { pg.Visibility = System.Windows.Visibility.Hidden; }); |
||||
} |
||||
|
||||
void UpdateProgressBar(Action<ProgressBar> updateAction) |
||||
{ |
||||
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => updateAction(gacReadingProgressBar))); |
||||
} |
||||
|
||||
void AddNewEntry(GacEntry entry) |
||||
{ |
||||
gacEntries.Add(entry); |
||||
if (filterMethod(entry)) |
||||
filteredEntries.Add(entry); |
||||
} |
||||
#endregion
|
||||
|
||||
void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e) |
||||
{ |
||||
string filterString = filterTextBox.Text.Trim(); |
||||
if (filterString.Length == 0) |
||||
filterMethod = _ => true; |
||||
else { |
||||
var elements = filterString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); |
||||
filterMethod = entry => elements.All(el => Contains(entry.FullName, el) || Contains(entry.FormattedVersion, el)); |
||||
} |
||||
|
||||
filteredEntries.Clear(); |
||||
filteredEntries.AddRange(gacEntries.Where(entry => filterMethod(entry))); |
||||
} |
||||
|
||||
static bool Contains(string s, string subString) |
||||
{ |
||||
return s.IndexOf(subString, StringComparison.OrdinalIgnoreCase) >= 0; |
||||
} |
||||
|
||||
void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) |
||||
{ |
||||
okButton.IsEnabled = listView.SelectedItems.Count > 0; |
||||
} |
||||
|
||||
void OKButton_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
this.DialogResult = true; |
||||
Close(); |
||||
} |
||||
|
||||
public string[] SelectedFileNames { |
||||
get { |
||||
return listView.SelectedItems.OfType<GacEntry>().Select(e => e.FileName).ToArray(); |
||||
} |
||||
} |
||||
} |
||||
} |