After Width: | Height: | Size: 713 B |
Before Width: | Height: | Size: 653 B After Width: | Height: | Size: 777 B |
Before Width: | Height: | Size: 625 B After Width: | Height: | Size: 729 B |
Before Width: | Height: | Size: 727 B After Width: | Height: | Size: 749 B |
After Width: | Height: | Size: 822 B |
After Width: | Height: | Size: 525 B |
@ -0,0 +1,27 @@ |
|||||||
|
// 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 ICSharpCode.Core.Presentation; |
||||||
|
using ICSharpCode.TreeView; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser |
||||||
|
{ |
||||||
|
public class AssemblyLoadErrorTreeNode : SharpTreeNode |
||||||
|
{ |
||||||
|
public override object Text { |
||||||
|
get { |
||||||
|
return "(Assembly not loadable)"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override object Icon { |
||||||
|
get { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
@ -0,0 +1,75 @@ |
|||||||
|
// 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>
|
||||||
|
/// 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) |
||||||
|
{ |
||||||
|
IAssemblyModel assemblyModel = ClassBrowserPad.CreateAssemblyModelFromFile(openFileDialog.FileName); |
||||||
|
if (assemblyModel != null) |
||||||
|
classBrowser.AssemblyList.Assemblies.Add(assemblyModel); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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) { |
||||||
|
IAssemblyModel assemblyModel = ClassBrowserPad.CreateAssemblyModelFromFile(assemblyFile); |
||||||
|
if (assemblyModel != null) |
||||||
|
classBrowser.AssemblyList.Assemblies.Add(assemblyModel); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,29 +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; |
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of OpenAssemblyFromFileCommand.
|
|
||||||
/// </summary>
|
|
||||||
class OpenAssemblyFromFileCommand : SimpleCommand |
|
||||||
{ |
|
||||||
public override void Execute(object parameter) |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Description of OpenAssemblyFromGACCommand.
|
|
||||||
/// </summary>
|
|
||||||
class OpenAssemblyFromGACCommand : SimpleCommand |
|
||||||
{ |
|
||||||
public override void Execute(object parameter) |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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 = "{x:Static core:GlobalStyles.DialogWindowStyle}" |
||||||
|
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 @@ |
|||||||
|
// 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(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |