@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
<AddIn name="AddInManager 2nd Generation" |
||||
author ="Andreas Weizel" |
||||
description="Allows installing and updating SharpDevelop AddIns." |
||||
addInManagerHidden = "preinstalled"> |
||||
|
||||
<Manifest> |
||||
<Identity name="ICSharpCode.AddInManager2" version="@ICSharpCode.AddInManager2.dll" /> |
||||
</Manifest> |
||||
|
||||
<Runtime> |
||||
<Import assembly="ICSharpCode.AddInManager2.dll"/> |
||||
<Import assembly="NuGet.Core.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/Tools"> |
||||
<MenuItem id="ShowAddInManager2" |
||||
label="${res:AddInManager.Title}" |
||||
class="ICSharpCode.AddInManager2.ShowCommand"/> |
||||
</Path> |
||||
|
||||
<!-- Option dialog --> |
||||
<Path name="/SharpDevelop/Dialogs/OptionsDialog"> |
||||
<OptionPanel |
||||
id="AddInManager2" |
||||
label="${res:AddInManager2.OptionPanel.Tree.AddIns}" |
||||
insertafter="FormsDesignerOptions"> |
||||
<OptionPanel |
||||
id="AddInRepositories" |
||||
label="${res:AddInManager2.OptionPanel.Tree.Repositories}" |
||||
class="ICSharpCode.AddInManager2.View.PackageRepositoriesView"/> |
||||
</OptionPanel> |
||||
</Path> |
||||
|
||||
<!-- Autostart commands for initialization --> |
||||
<Path name = "/SharpDevelop/Autostart"> |
||||
<Class id = "AddInManagerInitialization" |
||||
class = "ICSharpCode.AddInManager2.AddInManagerInitializationCommand"/> |
||||
</Path> |
||||
</AddIn> |
||||
@ -0,0 +1,189 @@
@@ -0,0 +1,189 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{60480C2F-F228-4D86-B98F-AF75A7DCEC34}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.AddInManager2</RootNamespace> |
||||
<AssemblyName>ICSharpCode.AddInManager2</AssemblyName> |
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
||||
<SignAssembly>False</SignAssembly> |
||||
<DelaySign>False</DelaySign> |
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
<RunCodeAnalysis>False</RunCodeAnalysis> |
||||
<SourceAnalysisOverrideSettingsFile>C:\Users\WheizWork\AppData\Roaming\ICSharpCode/SharpDevelop4\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> |
||||
<TargetFrameworkProfile /> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\Misc\AddInManager2\</OutputPath> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<StartAction>Project</StartAction> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\Misc\OnlineUpdate\</OutputPath> |
||||
<DebugSymbols>false</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<StartAction>Project</StartAction> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="ICSharpCode.SharpZipLib"> |
||||
<HintPath>..\RequiredLibraries\ICSharpCode.SharpZipLib.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="NuGet.Core"> |
||||
<HintPath>..\..\PackageManagement\RequiredLibraries\NuGet.Core.dll</HintPath> |
||||
<Private>True</Private> |
||||
</Reference> |
||||
<Reference Include="PresentationCore" /> |
||||
<Reference Include="PresentationFramework" /> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Data.DataSetExtensions"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xaml" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Xml.Linq"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="WindowsBase" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="AddInManager2.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Resource Include="Resources\packageicon_small.png" /> |
||||
<Resource Include="Resources\sd_packageicon.png" /> |
||||
<Resource Include="Resources\accept.png" /> |
||||
<Resource Include="Resources\exclamation.png" /> |
||||
<None Include="Resources\license.txt" /> |
||||
<Resource Include="Resources\magnifier.png" /> |
||||
<Resource Include="Resources\packageicon.png" /> |
||||
<Resource Include="Resources\resultset_next.png" /> |
||||
<Resource Include="Resources\resultset_previous.png" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\AddInManager.cs" /> |
||||
<Compile Include="Src\AddInManagerTask.cs" /> |
||||
<Compile Include="Src\BooleanToFontWeightConverter.cs" /> |
||||
<Compile Include="Src\Commands.cs" /> |
||||
<Compile Include="Src\DelegateCommand.cs" /> |
||||
<Compile Include="Src\EnumerableExtensions.cs" /> |
||||
<Compile Include="Src\Model\AcceptLicensesEventArgs.cs" /> |
||||
<Compile Include="Src\Model\AddInDependency.cs" /> |
||||
<Compile Include="Src\Model\AddInInstallationEventArgs.cs" /> |
||||
<Compile Include="Src\Model\ManagedAddIn.cs" /> |
||||
<Compile Include="Src\Model\Interfaces\IAddInManagerEvents.cs" /> |
||||
<Compile Include="Src\Model\Interfaces\IAddInPackage.cs" /> |
||||
<Compile Include="Src\Model\Interfaces\IAddInSetup.cs" /> |
||||
<Compile Include="Src\Model\Interfaces\INuGetPackageManager.cs" /> |
||||
<Compile Include="Src\Model\Interfaces\IPackageRepositories.cs" /> |
||||
<Compile Include="Src\Model\NuGetPackageManager.cs" /> |
||||
<Compile Include="Src\Model\AddInSetup.cs" /> |
||||
<Compile Include="Src\Model\AddInManagerEvents.cs" /> |
||||
<Compile Include="Src\Model\AddInExceptionEventArgs.cs" /> |
||||
<Compile Include="Src\Model\NuGetPackageOperationEventArgs.cs" /> |
||||
<Compile Include="Src\Model\PackageMessageLoggedEventArgs.cs" /> |
||||
<Compile Include="Src\Model\PackageRepositories.cs" /> |
||||
<Compile Include="Src\Model\PackageRepository.cs" /> |
||||
<Compile Include="Src\Model\Page.cs" /> |
||||
<Compile Include="Src\Model\Pages.cs" /> |
||||
<Compile Include="Src\Model\Model.cs" /> |
||||
<Compile Include="Src\Model\ReadPackagesResult.cs" /> |
||||
<Compile Include="Src\ViewModel\AddInManagerViewModel.cs" /> |
||||
<Compile Include="Src\ViewModel\AddInPackageViewModelBase.cs" /> |
||||
<Compile Include="Src\ViewModel\AddInsViewModelBase.cs" /> |
||||
<Compile Include="Src\ViewModel\AvailableAddInsViewModel.cs" /> |
||||
<Compile Include="Src\ViewModel\InstalledAddInsViewModel.cs" /> |
||||
<Compile Include="Src\ViewModel\LicenseAcceptanceViewModel.cs" /> |
||||
<Compile Include="Src\ViewModel\NuGetAddInsViewModelBase.cs" /> |
||||
<Compile Include="Src\ViewModel\NuGetPackageViewModel.cs" /> |
||||
<Compile Include="Src\ViewModel\OfflineAddInViewModel.cs" /> |
||||
<Compile Include="Src\ViewModel\OpenHyperlinkCommand.cs" /> |
||||
<Compile Include="Src\ViewModel\PackageRepositoriesViewModel.cs" /> |
||||
<Compile Include="Src\ViewModel\UpdatedAddInsViewModel.cs" /> |
||||
<Compile Include="Src\View\AddInManagerView.xaml.cs"> |
||||
<DependentUpon>AddInManagerView.xaml</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Src\View\AddInsView.xaml.cs"> |
||||
<DependentUpon>AddInsView.xaml</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Src\View\LicenseAcceptanceView.xaml.cs"> |
||||
<SubType>Code</SubType> |
||||
<DependentUpon>LicenseAcceptanceView.xaml</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Src\View\PagedResultsView.xaml.cs"> |
||||
<DependentUpon>PagedResultsView.xaml</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Src\View\PackageRepositoriesView.xaml.cs"> |
||||
<DependentUpon>PackageRepositoriesView.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj"> |
||||
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project> |
||||
<Name>ICSharpCode.Core.Presentation</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj"> |
||||
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project> |
||||
<Name>ICSharpCode.Core.WinForms</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Resources" /> |
||||
<Folder Include="Src" /> |
||||
<Folder Include="Src\Model" /> |
||||
<Folder Include="Src\Model\Interfaces" /> |
||||
<Folder Include="Src\ViewModel" /> |
||||
<Folder Include="Src\View" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Page Include="Src\View\AddInManagerView.xaml" /> |
||||
<Page Include="Src\View\AddInsView.xaml" /> |
||||
<Page Include="Src\View\LicenseAcceptanceView.xaml" /> |
||||
<Page Include="Src\View\PagedResultsView.xaml" /> |
||||
<Page Include="Src\View\PackageRepositoriesView.xaml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<EmbeddedResource Include="Resources\StringResources.resx" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
||||
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
// 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.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AddInManager2")] |
||||
[assembly: AssemblyDescription("AddInManager 2nd Generation for ICSharpCode.Core")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
@ -0,0 +1,248 @@
@@ -0,0 +1,248 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<root> |
||||
<!-- |
||||
Microsoft ResX Schema |
||||
|
||||
Version 2.0 |
||||
|
||||
The primary goals of this format is to allow a simple XML format |
||||
that is mostly human readable. The generation and parsing of the |
||||
various data types are done through the TypeConverter classes |
||||
associated with the data types. |
||||
|
||||
Example: |
||||
|
||||
... ado.net/XML headers & schema ... |
||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
<resheader name="version">2.0</resheader> |
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
</data> |
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
<comment>This is a comment</comment> |
||||
</data> |
||||
|
||||
There are any number of "resheader" rows that contain simple |
||||
name/value pairs. |
||||
|
||||
Each data row contains a name, and value. The row also contains a |
||||
type or mimetype. Type corresponds to a .NET class that support |
||||
text/value conversion through the TypeConverter architecture. |
||||
Classes that don't support this are serialized and stored with the |
||||
mimetype set. |
||||
|
||||
The mimetype is used for serialized objects, and tells the |
||||
ResXResourceReader how to depersist the object. This is currently not |
||||
extensible. For a given mimetype the value must be set accordingly: |
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
that the ResXResourceWriter will generate, however the reader can |
||||
read any of the formats listed below. |
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
value : The object must be serialized into a byte array |
||||
: using a System.ComponentModel.TypeConverter |
||||
: and then encoded with base64 encoding. |
||||
--> |
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
<xsd:complexType> |
||||
<xsd:choice maxOccurs="unbounded"> |
||||
<xsd:element name="metadata"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||
<xsd:attribute name="type" type="xsd:string" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="assembly"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="alias" type="xsd:string" /> |
||||
<xsd:attribute name="name" type="xsd:string" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="data"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="resheader"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:choice> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:schema> |
||||
<resheader name="resmimetype"> |
||||
<value>text/microsoft-resx</value> |
||||
</resheader> |
||||
<resheader name="version"> |
||||
<value>2.0</value> |
||||
</resheader> |
||||
<resheader name="reader"> |
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<resheader name="writer"> |
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<data name="AddInManager2.DisableDependentWarning" xml:space="preserve"> |
||||
<value>Following installed AddIns are dependent from "{0}": |
||||
|
||||
{1} |
||||
|
||||
They will stop working after disabling this AddIn! Are you sure you want to continue?</value> |
||||
</data> |
||||
<data name="AddInManager2.CannotRemoveAddInManager" xml:space="preserve"> |
||||
<value>You cannot uninstall the AddInManager because you need it to re-install AddIns!</value> |
||||
</data> |
||||
<data name="AddInManager2.LicenseAcceptance.Introduction.Packages" xml:space="preserve"> |
||||
<value>The following packages require a click-to-accept license:</value> |
||||
</data> |
||||
<data name="AddInManager2.RemoveDependentWarning" xml:space="preserve"> |
||||
<value>Following installed AddIns are dependent from "{0}": |
||||
|
||||
{1} |
||||
|
||||
They will stop working after removing this AddIn! Are you sure you want to continue?</value> |
||||
</data> |
||||
<data name="AddInManager2.LicenseAcceptance.Introduction.Package" xml:space="preserve"> |
||||
<value>The following package requires a click-to-accept license:</value> |
||||
</data> |
||||
<data name="AddInManager2.LicenseAcceptance.Explanation.Packages" xml:space="preserve"> |
||||
<value>By clicking "I Accept" you agree to the license terms for the packages listed above. |
||||
If you do not agree to the license terms click "I Decline".</value> |
||||
</data> |
||||
<data name="AddInManager2.LicenseAcceptance.Explanation.Package" xml:space="preserve"> |
||||
<value>By clicking "I Accept" you agree to the license terms for the package listed above. |
||||
If you do not agree to the license terms click "I Decline".</value> |
||||
</data> |
||||
<data name="AddInManager2.LicenseAcceptance.AcceptButton" xml:space="preserve"> |
||||
<value>I &Accept</value> |
||||
</data> |
||||
<data name="AddInManager2.LicenseAcceptance.DeclineButton" xml:space="preserve"> |
||||
<value>I &Decline</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.ViewLicenseTerms" xml:space="preserve"> |
||||
<value>View License Terms</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.CreatedBy" xml:space="preserve"> |
||||
<value>Created by:</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.Version" xml:space="preserve"> |
||||
<value>Version:</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.InstalledVersion" xml:space="preserve"> |
||||
<value>Installed version:</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.NewVersion" xml:space="preserve"> |
||||
<value>New version:</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.LastUpdated" xml:space="preserve"> |
||||
<value>Last updated:</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.DownloadCount" xml:space="preserve"> |
||||
<value>Downloads:</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.Rating" xml:space="preserve"> |
||||
<value>Rating:</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.ReportAbuse" xml:space="preserve"> |
||||
<value>Report abuse</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.Dependencies" xml:space="preserve"> |
||||
<value>Dependencies:</value> |
||||
</data> |
||||
<data name="AddInManager2.AddInsView.ShowPreinstalledAddIns" xml:space="preserve"> |
||||
<value>Show preinstalled AddIns</value> |
||||
</data> |
||||
<data name="AddInManager2.AddInsView.ShowPrereleaseAddIns" xml:space="preserve"> |
||||
<value>Show prereleases</value> |
||||
</data> |
||||
<data name="AddInManager2.AddInsView.InstallFromArchive" xml:space="preserve"> |
||||
<value>Install from archive...</value> |
||||
</data> |
||||
<data name="AddInManager2.Views.Installed" xml:space="preserve"> |
||||
<value>Installed</value> |
||||
</data> |
||||
<data name="AddInManager2.Views.Updates" xml:space="preserve"> |
||||
<value>Updates</value> |
||||
</data> |
||||
<data name="AddInManager2.Views.Available" xml:space="preserve"> |
||||
<value>Available</value> |
||||
</data> |
||||
<data name="AddInManager2.Details.MoreInformation" xml:space="preserve"> |
||||
<value>More information</value> |
||||
</data> |
||||
<data name="AddInManager2.OptionPanel.Tree.AddIns" xml:space="preserve"> |
||||
<value>AddIns</value> |
||||
</data> |
||||
<data name="AddInManager2.OptionPanel.Tree.Repositories" xml:space="preserve"> |
||||
<value>Repositories</value> |
||||
</data> |
||||
<data name="AddInManager2.OptionPanel.MoveUp" xml:space="preserve"> |
||||
<value>Move Up</value> |
||||
</data> |
||||
<data name="AddInManager2.OptionPanel.MoveDown" xml:space="preserve"> |
||||
<value>Move Down</value> |
||||
</data> |
||||
<data name="AddInManager2.OptionPanel.Remove" xml:space="preserve"> |
||||
<value>Remove</value> |
||||
</data> |
||||
<data name="AddInManager2.OptionPanel.Add" xml:space="preserve"> |
||||
<value>Add</value> |
||||
</data> |
||||
<data name="AddInManager2.OptionPanel.Name" xml:space="preserve"> |
||||
<value>Name:</value> |
||||
</data> |
||||
<data name="AddInManager2.OptionPanel.Source" xml:space="preserve"> |
||||
<value>Source:</value> |
||||
</data> |
||||
<data name="AddInManager2.DefaultRepository" xml:space="preserve"> |
||||
<value>Default Repository</value> |
||||
</data> |
||||
<data name="AddInManager2.LicenseAcceptance.Title" xml:space="preserve"> |
||||
<value>License Agreements</value> |
||||
</data> |
||||
<data name="AddInManager2.SDAddInFileFilter" xml:space="preserve"> |
||||
<value>SharpDevelop AddIns|*.sdaddin|All files|*.*</value> |
||||
</data> |
||||
<data name="AddInManager2.InstallDependentMessage" xml:space="preserve"> |
||||
<value>Package "{0}" needs at least one additional package: |
||||
|
||||
{1} |
||||
|
||||
The application will try to download and install them, as well. Do you want to continue?</value> |
||||
</data> |
||||
</root> |
||||
|
After Width: | Height: | Size: 582 B |
|
After Width: | Height: | Size: 658 B |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
NuGet Package Icon: |
||||
License: Apache 2.0 |
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
Fugue Icons: |
||||
License: Creative Commons Attribution 3.0 License |
||||
http://p.yusukekamiyamane.com/ |
||||
|
After Width: | Height: | Size: 664 B |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 938 B |
|
After Width: | Height: | Size: 525 B |
|
After Width: | Height: | Size: 539 B |
|
After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
// 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.AddInManager2.Model; |
||||
|
||||
namespace ICSharpCode.AddInManager2 |
||||
{ |
||||
/// <summary>
|
||||
/// Container for public services of AddInManager AddIn.
|
||||
/// </summary>
|
||||
public class AddInManager |
||||
{ |
||||
private static readonly AddInManagerEvents _events; |
||||
private static readonly PackageRepositories _repositories; |
||||
private static readonly AddInSetup _setup; |
||||
private static readonly NuGetPackageManager _nuGet; |
||||
|
||||
static AddInManager() |
||||
{ |
||||
_events = new AddInManagerEvents(); |
||||
_repositories = new PackageRepositories(); |
||||
_nuGet = new NuGetPackageManager(_repositories, _events); |
||||
_setup = new AddInSetup(_events, _nuGet); |
||||
} |
||||
|
||||
public static IAddInManagerEvents Events |
||||
{ |
||||
get |
||||
{ |
||||
return _events; |
||||
} |
||||
} |
||||
|
||||
public static IPackageRepositories Repositories |
||||
{ |
||||
get |
||||
{ |
||||
return _repositories; |
||||
} |
||||
} |
||||
|
||||
public static IAddInSetup Setup |
||||
{ |
||||
get |
||||
{ |
||||
return _setup; |
||||
} |
||||
} |
||||
|
||||
public static INuGetPackageManager NuGet |
||||
{ |
||||
get |
||||
{ |
||||
return _nuGet; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
// 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.Threading; |
||||
using System.Threading.Tasks; |
||||
|
||||
namespace ICSharpCode.AddInManager2 |
||||
{ |
||||
public class AddInManagerTask |
||||
{ |
||||
public static AddInManagerTask<TResult> Create<TResult>( |
||||
Func<TResult> function, |
||||
Action<AddInManagerTask<TResult>> continueWith) |
||||
{ |
||||
return new AddInManagerTask<TResult>(function, continueWith); |
||||
} |
||||
} |
||||
|
||||
public class AddInManagerTask<TResult> |
||||
{ |
||||
Task<TResult> task; |
||||
Action<AddInManagerTask<TResult>> continueWith; |
||||
CancellationTokenSource cancellationTokenSource; |
||||
|
||||
public AddInManagerTask( |
||||
Func<TResult> function, |
||||
Action<AddInManagerTask<TResult>> continueWith) |
||||
{ |
||||
this.continueWith = continueWith; |
||||
CreateTask(function); |
||||
} |
||||
|
||||
private void CreateTask(Func<TResult> function) |
||||
{ |
||||
TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext(); |
||||
cancellationTokenSource = new CancellationTokenSource(); |
||||
task = new Task<TResult>(function, cancellationTokenSource.Token); |
||||
task.ContinueWith(result => OnContinueWith(result), scheduler); |
||||
} |
||||
|
||||
private void OnContinueWith(Task<TResult> task) |
||||
{ |
||||
continueWith(this); |
||||
} |
||||
|
||||
public void Start() |
||||
{ |
||||
task.Start(); |
||||
} |
||||
|
||||
public TResult Result |
||||
{ |
||||
get |
||||
{ |
||||
return task.Result; |
||||
} |
||||
} |
||||
|
||||
public void Cancel() |
||||
{ |
||||
cancellationTokenSource.Cancel(); |
||||
} |
||||
|
||||
public bool IsCancelled |
||||
{ |
||||
get |
||||
{ |
||||
return task.IsCanceled; |
||||
} |
||||
} |
||||
|
||||
public bool IsFaulted |
||||
{ |
||||
get |
||||
{ |
||||
return task.IsFaulted; |
||||
} |
||||
} |
||||
|
||||
public AggregateException Exception |
||||
{ |
||||
get |
||||
{ |
||||
return task.Exception; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
// 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.Globalization; |
||||
using System.Windows; |
||||
using System.Windows.Data; |
||||
|
||||
namespace ICSharpCode.AddInManager2 |
||||
{ |
||||
[ValueConversion(typeof(Boolean), typeof(FontWeight))] |
||||
public class BooleanToFontWeightConverter : IValueConverter |
||||
{ |
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
if (value is Boolean) |
||||
{ |
||||
Boolean fontIsBold = (Boolean)value; |
||||
return ConvertToFontWeight(fontIsBold); |
||||
} |
||||
return DependencyProperty.UnsetValue; |
||||
} |
||||
|
||||
FontWeight ConvertToFontWeight(Boolean bold) |
||||
{ |
||||
if (bold) |
||||
{ |
||||
return FontWeights.Bold; |
||||
} |
||||
return FontWeights.Normal; |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
if (value is FontWeight) |
||||
{ |
||||
FontWeight fontWeight = (FontWeight)value; |
||||
return ConvertToBoolean(fontWeight); |
||||
} |
||||
return DependencyProperty.UnsetValue; |
||||
} |
||||
|
||||
bool ConvertToBoolean(FontWeight fontWeight) |
||||
{ |
||||
return fontWeight == FontWeights.Bold; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
// 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; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.AddInManager2.View; |
||||
|
||||
namespace ICSharpCode.AddInManager2 |
||||
{ |
||||
public class ShowCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
// Open AddInManager2 main dialog
|
||||
using (AddInManagerView view = CreateManagerView()) |
||||
{ |
||||
view.ShowDialog(); |
||||
} |
||||
} |
||||
|
||||
private AddInManagerView CreateManagerView() |
||||
{ |
||||
return new AddInManagerView() |
||||
{ |
||||
Owner = SD.Workbench.MainWindow |
||||
}; |
||||
} |
||||
} |
||||
|
||||
public class AddInManagerInitializationCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
// Load string resources needed by AddInManager2
|
||||
SD.ResourceService.RegisterStrings("ICSharpCode.AddInManager2.Resources.StringResources", GetType().Assembly); |
||||
|
||||
// Remove all unreferenced NuGet packages
|
||||
AddInManager.Setup.RemoveUnreferencedNuGetPackages(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// 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.AddInManager2 |
||||
{ |
||||
public class DelegateCommand : ICommand |
||||
{ |
||||
Action<object> execute; |
||||
Predicate<object> canExecute; |
||||
|
||||
public DelegateCommand(Action<object> execute, Predicate<object> canExecute) |
||||
{ |
||||
this.execute = execute; |
||||
this.canExecute = canExecute; |
||||
} |
||||
|
||||
public DelegateCommand(Action<object> 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; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2 |
||||
{ |
||||
public static class EnumerableExtensions |
||||
{ |
||||
public static IEnumerable<T> DistinctLast<T>(this IEnumerable<T> source, IEqualityComparer<T> comparer) |
||||
{ |
||||
T previousItem = default(T); |
||||
|
||||
foreach (T currentItem in source) |
||||
{ |
||||
if (previousItem != null) |
||||
{ |
||||
if (!comparer.Equals(previousItem, currentItem)) |
||||
{ |
||||
yield return previousItem; |
||||
} |
||||
} |
||||
previousItem = currentItem; |
||||
} |
||||
|
||||
if (previousItem != null) |
||||
{ |
||||
yield return previousItem; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public class AcceptLicensesEventArgs : EventArgs |
||||
{ |
||||
public AcceptLicensesEventArgs(IEnumerable<IPackage> packages) |
||||
{ |
||||
this.Packages = packages; |
||||
} |
||||
|
||||
public IEnumerable<IPackage> Packages |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public bool IsAccepted |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,143 @@
@@ -0,0 +1,143 @@
|
||||
// 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.Text; |
||||
using ICSharpCode.Core; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// Object describing a dependency constraint of an AddIn.
|
||||
/// </summary>
|
||||
public class AddInDependency |
||||
{ |
||||
public AddInDependency() |
||||
{ |
||||
} |
||||
|
||||
public AddInDependency(PackageDependency packageDependency) |
||||
{ |
||||
if (packageDependency != null) |
||||
{ |
||||
IVersionSpec versionSpec = packageDependency.VersionSpec; |
||||
|
||||
Id = packageDependency.Id; |
||||
if (versionSpec.MinVersion != null) |
||||
{ |
||||
MinimumVersion = versionSpec.MinVersion.Version; |
||||
} |
||||
if (versionSpec.MaxVersion != null) |
||||
{ |
||||
MaximumVersion = versionSpec.MaxVersion.Version; |
||||
} |
||||
IncludeMinimumVersion = packageDependency.VersionSpec.IsMinInclusive; |
||||
IncludeMaximumVersion = packageDependency.VersionSpec.IsMaxInclusive; |
||||
} |
||||
} |
||||
|
||||
public AddInDependency(AddInReference reference) |
||||
{ |
||||
if (reference != null) |
||||
{ |
||||
Id = reference.Name; |
||||
|
||||
// Hint: An absolutely minimal or maximal version means no version constraint at all!
|
||||
Version absMinimumVersion = new Version(0, 0, 0, 0); |
||||
Version absMaximumVersion = new Version(Int32.MaxValue, Int32.MaxValue); |
||||
|
||||
if ((reference.MinimumVersion != null) && (reference.MinimumVersion != absMinimumVersion)) |
||||
{ |
||||
MinimumVersion = reference.MinimumVersion; |
||||
} |
||||
if ((reference.MaximumVersion != null) && (reference.MaximumVersion != absMaximumVersion)) |
||||
{ |
||||
MaximumVersion = reference.MaximumVersion; |
||||
} |
||||
|
||||
IncludeMinimumVersion = true; |
||||
IncludeMaximumVersion = true; |
||||
} |
||||
} |
||||
|
||||
public string Id |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public Version MinimumVersion |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public bool IncludeMinimumVersion |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public Version MaximumVersion |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public bool IncludeMaximumVersion |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
string printedMinimalDependency = FormatVersionConstraint(MinimumVersion, IncludeMinimumVersion, true); |
||||
string printedMaximalDependency = FormatVersionConstraint(MaximumVersion, IncludeMaximumVersion, false); |
||||
|
||||
StringBuilder formattedDependency = new StringBuilder(); |
||||
if (Id != null) |
||||
{ |
||||
formattedDependency.Append(Id); |
||||
} |
||||
if ((printedMinimalDependency != null) || (printedMaximalDependency != null)) |
||||
{ |
||||
formattedDependency.Append(" ("); |
||||
} |
||||
if (printedMinimalDependency != null) |
||||
{ |
||||
formattedDependency.Append(printedMinimalDependency); |
||||
} |
||||
if ((printedMinimalDependency != null) && (printedMaximalDependency != null)) |
||||
{ |
||||
formattedDependency.Append(" && "); |
||||
} |
||||
if (printedMaximalDependency != null) |
||||
{ |
||||
formattedDependency.Append(printedMaximalDependency); |
||||
} |
||||
if ((printedMinimalDependency != null) || (printedMaximalDependency != null)) |
||||
{ |
||||
formattedDependency.Append(")"); |
||||
} |
||||
|
||||
return formattedDependency.ToString(); |
||||
} |
||||
|
||||
|
||||
private string FormatVersionConstraint(Version version, bool includeVersion, bool isMinimum) |
||||
{ |
||||
if (version == null) |
||||
{ |
||||
return null; |
||||
} |
||||
else |
||||
{ |
||||
string constraintOperator = isMinimum ? ">" : "<"; |
||||
string equalityOperator = includeVersion ? "=" : ""; |
||||
return String.Format("{0}{1} {2}", constraintOperator, equalityOperator, version.ToString()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
// 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.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// Data for events indicating an exception during package-related operations.
|
||||
/// </summary>
|
||||
public class AddInExceptionEventArgs : EventArgs |
||||
{ |
||||
public AddInExceptionEventArgs(Exception exception) |
||||
{ |
||||
Exception = exception; |
||||
} |
||||
|
||||
public Exception Exception |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// 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.Core; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// EventArgs for local AddIn installation events.
|
||||
/// </summary>
|
||||
public class AddInInstallationEventArgs : EventArgs |
||||
{ |
||||
public AddInInstallationEventArgs(AddIn addIn) |
||||
{ |
||||
AddIn = addIn; |
||||
PreviousVersionRemains = false; |
||||
} |
||||
|
||||
public AddIn AddIn |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public bool PreviousVersionRemains |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// Catches and broadcasts package-related events.
|
||||
/// </summary>
|
||||
public class AddInManagerEvents : IAddInManagerEvents |
||||
{ |
||||
public event EventHandler OperationStarted; |
||||
|
||||
public void OnOperationStarted(EventArgs e) |
||||
{ |
||||
if (OperationStarted != null) |
||||
{ |
||||
OperationStarted(this, e); |
||||
} |
||||
} |
||||
|
||||
public event EventHandler<AddInInstallationEventArgs> AddInInstalled; |
||||
|
||||
public void OnAddInInstalled(AddInInstallationEventArgs e) |
||||
{ |
||||
if (AddInInstalled != null) |
||||
{ |
||||
AddInInstalled(this, e); |
||||
} |
||||
} |
||||
|
||||
public event EventHandler<AddInInstallationEventArgs> AddInUninstalled; |
||||
|
||||
public void OnAddInUninstalled(AddInInstallationEventArgs e) |
||||
{ |
||||
if (AddInUninstalled != null) |
||||
{ |
||||
AddInUninstalled(this, e); |
||||
} |
||||
} |
||||
|
||||
public event EventHandler<AddInExceptionEventArgs> AddInOperationError; |
||||
|
||||
public void OnAddInOperationError(AddInExceptionEventArgs e) |
||||
{ |
||||
if (AddInOperationError != null) |
||||
{ |
||||
AddInOperationError(this, e); |
||||
} |
||||
} |
||||
|
||||
public event EventHandler<PackageOperationEventArgs> AddInPackageDownloaded; |
||||
|
||||
public void OnAddInPackageDownloaded(PackageOperationEventArgs e) |
||||
{ |
||||
if (AddInPackageDownloaded != null) |
||||
{ |
||||
AddInPackageDownloaded(this, e); |
||||
} |
||||
} |
||||
|
||||
public event EventHandler<PackageOperationEventArgs> AddInPackageRemoved; |
||||
|
||||
public void OnAddInPackageRemoved(PackageOperationEventArgs e) |
||||
{ |
||||
if (AddInPackageRemoved != null) |
||||
{ |
||||
AddInPackageRemoved(this, e); |
||||
} |
||||
} |
||||
|
||||
public event EventHandler<AddInInstallationEventArgs> AddInStateChanged; |
||||
|
||||
public void OnAddInStateChanged(AddInInstallationEventArgs e) |
||||
{ |
||||
if (AddInStateChanged != null) |
||||
{ |
||||
AddInStateChanged(this, e); |
||||
} |
||||
} |
||||
|
||||
public event EventHandler<PackageMessageLoggedEventArgs> PackageMessageLogged; |
||||
|
||||
public void OnPackageMessageLogged(PackageMessageLoggedEventArgs e) |
||||
{ |
||||
if (PackageMessageLogged != null) |
||||
{ |
||||
PackageMessageLogged(this, e); |
||||
} |
||||
} |
||||
|
||||
public event EventHandler<AcceptLicensesEventArgs> AcceptLicenses; |
||||
|
||||
public void OnAcceptLicenses(AcceptLicensesEventArgs e) |
||||
{ |
||||
if (AcceptLicenses != null) |
||||
{ |
||||
AcceptLicenses(this, e); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,655 @@
@@ -0,0 +1,655 @@
|
||||
// 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.IO; |
||||
using System.Linq; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpZipLib.Zip; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// Helper class for AddIn setup operations.
|
||||
/// </summary>
|
||||
public class AddInSetup : IAddInSetup |
||||
{ |
||||
private IAddInManagerEvents _events = null; |
||||
private INuGetPackageManager _nuGet = null; |
||||
|
||||
private List<ManagedAddIn> _addInsMarkedForInstall; |
||||
|
||||
public AddInSetup(IAddInManagerEvents events, INuGetPackageManager nuGet) |
||||
{ |
||||
_events = events; |
||||
_nuGet = nuGet; |
||||
|
||||
_addInsMarkedForInstall = new List<ManagedAddIn>(); |
||||
|
||||
// Register event handlers
|
||||
_events.AddInPackageDownloaded += events_AddInPackageDownloaded; |
||||
} |
||||
|
||||
public IEnumerable<ManagedAddIn> AddInsWithMarkedForInstallation |
||||
{ |
||||
get |
||||
{ |
||||
return SD.AddInTree.AddIns.Select(a => new ManagedAddIn(a) { IsTemporary = false, IsUpdate = false }) |
||||
.GroupJoin( |
||||
_addInsMarkedForInstall, |
||||
installedAddIn => installedAddIn.AddIn.Manifest.PrimaryIdentity, |
||||
markedAddIn => markedAddIn.AddIn.Manifest.PrimaryIdentity, |
||||
(installedAddIn, e) => e.ElementAtOrDefault(0) ?? installedAddIn); |
||||
} |
||||
} |
||||
|
||||
private void events_AddInPackageDownloaded(object sender, PackageOperationEventArgs e) |
||||
{ |
||||
try |
||||
{ |
||||
InstallAddIn(e.Package, e.InstallPath); |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
_events.OnAddInOperationError(new AddInExceptionEventArgs(ex)); |
||||
} |
||||
} |
||||
|
||||
private AddIn LoadAddInFromZip(ZipFile file) |
||||
{ |
||||
AddIn resultAddIn = null; |
||||
ZipEntry addInEntry = null; |
||||
foreach (ZipEntry entry in file) |
||||
{ |
||||
if (entry.Name.EndsWith(".addin")) |
||||
{ |
||||
if (addInEntry != null) |
||||
{ |
||||
throw new AddInLoadException("The package may only contain one .addin file."); |
||||
} |
||||
addInEntry = entry; |
||||
} |
||||
} |
||||
if (addInEntry == null) |
||||
{ |
||||
throw new AddInLoadException("The package must contain one .addin file."); |
||||
} |
||||
using (Stream s = file.GetInputStream(addInEntry)) |
||||
{ |
||||
using (StreamReader r = new StreamReader(s)) |
||||
{ |
||||
resultAddIn = AddIn.Load(SD.AddInTree, r); |
||||
} |
||||
} |
||||
|
||||
return resultAddIn; |
||||
} |
||||
|
||||
public AddIn InstallAddIn(string archiveFileName) |
||||
{ |
||||
if (archiveFileName != null) |
||||
{ |
||||
// Try to load the *.sdaddin file as ZIP archive
|
||||
AddIn addIn = null; |
||||
ZipFile zipFile = new ZipFile(archiveFileName); |
||||
try |
||||
{ |
||||
addIn = LoadAddInFromZip(zipFile); |
||||
} |
||||
finally |
||||
{ |
||||
zipFile.Close(); |
||||
} |
||||
|
||||
if (addIn != null) |
||||
{ |
||||
if (addIn.Manifest.PrimaryIdentity == null) |
||||
{ |
||||
throw new AddInLoadException(ResourceService.GetString("AddInManager.AddInMustHaveIdentity")); |
||||
} |
||||
|
||||
// Try to find this AddIn in current registry
|
||||
string identity = addIn.Manifest.PrimaryIdentity; |
||||
AddIn foundAddIn = null; |
||||
foreach (AddIn treeAddIn in SD.AddInTree.AddIns) |
||||
{ |
||||
if (treeAddIn.Manifest.Identities.ContainsKey(identity)) |
||||
{ |
||||
foundAddIn = treeAddIn; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
// Prevent this AddIn from being uninstalled, if marked for deinstallation
|
||||
foreach (string installedIdentity in addIn.Manifest.Identities.Keys) |
||||
{ |
||||
ICSharpCode.Core.AddInManager.AbortRemoveUserAddInOnNextStart(installedIdentity); |
||||
} |
||||
|
||||
// Create target directory for AddIn in user profile & copy package contents there
|
||||
CopyAddInFromZip(addIn, archiveFileName); |
||||
|
||||
// Install the AddIn using manifest
|
||||
if (foundAddIn != null) |
||||
{ |
||||
addIn.Action = AddInAction.Update; |
||||
} |
||||
else |
||||
{ |
||||
addIn.Action = AddInAction.Install; |
||||
((AddInTreeImpl)SD.AddInTree).InsertAddIn(addIn); |
||||
} |
||||
|
||||
// Mark this AddIn
|
||||
ManagedAddIn markedAddIn = new ManagedAddIn(addIn) |
||||
{ |
||||
IsTemporary = true, |
||||
IsUpdate = (foundAddIn != null), |
||||
OldVersion = (foundAddIn != null) ? foundAddIn.Version : null |
||||
}; |
||||
_addInsMarkedForInstall.Add(markedAddIn); |
||||
|
||||
// Successful installation
|
||||
AddInInstallationEventArgs eventArgs = new AddInInstallationEventArgs(addIn); |
||||
_events.OnAddInInstalled(eventArgs); |
||||
_events.OnAddInStateChanged(eventArgs); |
||||
|
||||
return addIn; |
||||
} |
||||
else |
||||
{ |
||||
// This is not a valid SharpDevelop AddIn package!
|
||||
// TODO Throw something.
|
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public AddIn InstallAddIn(IPackage package, string packageDirectory) |
||||
{ |
||||
// Lookup for .addin file in package output
|
||||
var addInManifestFile = Directory.EnumerateFiles(packageDirectory, "*.addin", SearchOption.TopDirectoryOnly).FirstOrDefault(); |
||||
if (addInManifestFile != null) |
||||
{ |
||||
AddIn addIn = AddIn.Load(SD.AddInTree, addInManifestFile); |
||||
if (addIn.Manifest.PrimaryIdentity == null) |
||||
{ |
||||
throw new AddInLoadException(ResourceService.GetString("AddInManager.AddInMustHaveIdentity")); |
||||
} |
||||
|
||||
// Try to find this AddIn in current registry
|
||||
string identity = addIn.Manifest.PrimaryIdentity; |
||||
AddIn foundAddIn = null; |
||||
foreach (AddIn treeAddIn in SD.AddInTree.AddIns) |
||||
{ |
||||
if (treeAddIn.Manifest.Identities.ContainsKey(identity)) |
||||
{ |
||||
foundAddIn = treeAddIn; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
// Prevent this AddIn from being uninstalled, if marked for deinstallation
|
||||
foreach (string installedIdentity in addIn.Manifest.Identities.Keys) |
||||
{ |
||||
ICSharpCode.Core.AddInManager.AbortRemoveUserAddInOnNextStart(installedIdentity); |
||||
} |
||||
|
||||
// Create target directory for AddIn in user profile & copy package contents there
|
||||
CopyAddInFromPackage(addIn, packageDirectory); |
||||
|
||||
// Install the AddIn using manifest
|
||||
if (foundAddIn != null) |
||||
{ |
||||
addIn.Action = AddInAction.Update; |
||||
} |
||||
else |
||||
{ |
||||
addIn.Action = AddInAction.Install; |
||||
((AddInTreeImpl)SD.AddInTree).InsertAddIn(addIn); |
||||
} |
||||
|
||||
// Mark this AddIn
|
||||
ManagedAddIn markedAddIn = new ManagedAddIn(addIn) |
||||
{ |
||||
IsTemporary = true, |
||||
IsUpdate = (foundAddIn != null), |
||||
OldVersion = (foundAddIn != null) ? foundAddIn.Version : null |
||||
}; |
||||
_addInsMarkedForInstall.Add(markedAddIn); |
||||
|
||||
// Successful installation
|
||||
AddInInstallationEventArgs eventArgs = new AddInInstallationEventArgs(addIn); |
||||
_events.OnAddInInstalled(eventArgs); |
||||
_events.OnAddInStateChanged(eventArgs); |
||||
|
||||
return addIn; |
||||
} |
||||
else |
||||
{ |
||||
// This is not a valid SharpDevelop AddIn package!
|
||||
// TODO Throw something.
|
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
private bool CopyAddInFromZip(AddIn addIn, string zipFile) |
||||
{ |
||||
try |
||||
{ |
||||
string targetDir = Path.Combine(ICSharpCode.Core.AddInManager.AddInInstallTemp, |
||||
addIn.Manifest.PrimaryIdentity); |
||||
if (Directory.Exists(targetDir)) |
||||
{ |
||||
Directory.Delete(targetDir, true); |
||||
} |
||||
Directory.CreateDirectory(targetDir); |
||||
FastZip fastZip = new FastZip(); |
||||
fastZip.CreateEmptyDirectories = true; |
||||
fastZip.ExtractZip(zipFile, targetDir, null); |
||||
|
||||
return true; |
||||
} |
||||
catch (Exception) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
private bool CopyAddInFromPackage(AddIn addIn, string packageDirectory) |
||||
{ |
||||
try |
||||
{ |
||||
string targetDir = Path.Combine(ICSharpCode.Core.AddInManager.AddInInstallTemp, |
||||
addIn.Manifest.PrimaryIdentity); |
||||
if (Directory.Exists(targetDir)) |
||||
{ |
||||
Directory.Delete(targetDir, true); |
||||
} |
||||
Directory.CreateDirectory(targetDir); |
||||
var packageContentsFiles = Directory.EnumerateFiles(packageDirectory, "*.*", SearchOption.TopDirectoryOnly); |
||||
if (packageContentsFiles != null) |
||||
{ |
||||
foreach (var file in packageContentsFiles) |
||||
{ |
||||
// Don't copy the .nupkg file
|
||||
FileInfo fileInfo = new FileInfo(file); |
||||
if (fileInfo.Extension != ".nupkg") |
||||
{ |
||||
File.Copy(file, Path.Combine(targetDir, fileInfo.Name)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
catch (Exception) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public void CancelUpdate(AddIn addIn) |
||||
{ |
||||
if (addIn != null) |
||||
{ |
||||
CancelPendingUpdate(addIn); |
||||
|
||||
// If there is also a NuGet package installed for this, delete it as well
|
||||
IPackage addInPackage = GetNuGetPackageForAddIn(addIn, true); |
||||
if (addInPackage != null) |
||||
{ |
||||
_nuGet.Packages.UninstallPackage(addInPackage, true, false); |
||||
} |
||||
|
||||
AddInInstallationEventArgs eventArgs = new AddInInstallationEventArgs(addIn); |
||||
eventArgs.PreviousVersionRemains = true; |
||||
_events.OnAddInUninstalled(eventArgs); |
||||
_events.OnAddInStateChanged(eventArgs); |
||||
} |
||||
} |
||||
|
||||
private void CancelPendingUpdate(AddIn addIn) |
||||
{ |
||||
if (addIn != null) |
||||
{ |
||||
foreach (string identity in addIn.Manifest.Identities.Keys) |
||||
{ |
||||
// Delete from installation temp (if installation or update is pending)
|
||||
string targetDir = Path.Combine(ICSharpCode.Core.AddInManager.AddInInstallTemp, identity); |
||||
if (Directory.Exists(targetDir)) |
||||
{ |
||||
Directory.Delete(targetDir, true); |
||||
} |
||||
} |
||||
|
||||
_addInsMarkedForInstall.RemoveAll(markedAddIn => markedAddIn.AddIn == addIn); |
||||
} |
||||
} |
||||
|
||||
public void CancelInstallation(AddIn addIn) |
||||
{ |
||||
if (addIn != null) |
||||
{ |
||||
_addInsMarkedForInstall.RemoveAll(markedAddIn => markedAddIn.AddIn == addIn); |
||||
UninstallAddIn(addIn); |
||||
|
||||
// If there is also a NuGet package installed for this, delete it as well
|
||||
IPackage addInPackage = GetNuGetPackageForAddIn(addIn, true); |
||||
if (addInPackage != null) |
||||
{ |
||||
_nuGet.Packages.UninstallPackage(addInPackage, true, false); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void CancelUninstallation(AddIn addIn) |
||||
{ |
||||
if (addIn != null) |
||||
{ |
||||
// Abort uninstallation of this AddIn
|
||||
foreach (string identity in addIn.Manifest.Identities.Keys) |
||||
{ |
||||
ICSharpCode.Core.AddInManager.AbortRemoveUserAddInOnNextStart(identity); |
||||
} |
||||
ICSharpCode.Core.AddInManager.Enable(new AddIn[] { addIn }); |
||||
_events.OnAddInStateChanged(new AddInInstallationEventArgs(addIn)); |
||||
} |
||||
} |
||||
|
||||
public void UninstallAddIn(AddIn addIn) |
||||
{ |
||||
if (addIn != null) |
||||
{ |
||||
List<AddIn> addInList = new List<AddIn>(); |
||||
addInList.Add(addIn); |
||||
ICSharpCode.Core.AddInManager.RemoveExternalAddIns(addInList); |
||||
|
||||
CancelPendingUpdate(addIn); |
||||
foreach (string identity in addIn.Manifest.Identities.Keys) |
||||
{ |
||||
// Remove the user AddIn
|
||||
string targetDir = Path.Combine(ICSharpCode.Core.AddInManager.UserAddInPath, identity); |
||||
if (Directory.Exists(targetDir)) |
||||
{ |
||||
if (!addIn.Enabled) |
||||
{ |
||||
try |
||||
{ |
||||
Directory.Delete(targetDir, true); |
||||
continue; |
||||
} |
||||
catch |
||||
{ |
||||
// TODO Throw something?
|
||||
} |
||||
} |
||||
|
||||
ICSharpCode.Core.AddInManager.RemoveUserAddInOnNextStart(identity); |
||||
} |
||||
} |
||||
|
||||
// Successfully uninstalled
|
||||
AddInInstallationEventArgs eventArgs = new AddInInstallationEventArgs(addIn); |
||||
_events.OnAddInUninstalled(eventArgs); |
||||
_events.OnAddInStateChanged(eventArgs); |
||||
} |
||||
} |
||||
|
||||
public void SwitchAddInActivation(AddIn addIn) |
||||
{ |
||||
if (addIn != null) |
||||
{ |
||||
// Decide whether to enable or to disable the AddIn
|
||||
bool disable = addIn.Enabled; |
||||
if (addIn.Action == AddInAction.Disable) |
||||
{ |
||||
disable = false; |
||||
} |
||||
else if (addIn.Action == AddInAction.Enable) |
||||
{ |
||||
disable = true; |
||||
} |
||||
|
||||
if (disable) |
||||
{ |
||||
ICSharpCode.Core.AddInManager.Disable(new AddIn[] { addIn }); |
||||
} |
||||
else |
||||
{ |
||||
ICSharpCode.Core.AddInManager.Enable(new AddIn[] { addIn }); |
||||
} |
||||
|
||||
_events.OnAddInStateChanged(new AddInInstallationEventArgs(addIn)); |
||||
} |
||||
} |
||||
|
||||
public AddIn GetInstalledAddInByIdentity(string identity) |
||||
{ |
||||
if (!String.IsNullOrEmpty(identity)) |
||||
{ |
||||
return SD.AddInTree.AddIns |
||||
.Where(a => (a.Manifest != null) && a.Manifest.Identities.ContainsKey(identity)) |
||||
.FirstOrDefault(); |
||||
} |
||||
else |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public bool IsAddInInstalled(AddIn addIn) |
||||
{ |
||||
if ((addIn == null) || (addIn.Manifest == null)) |
||||
{ |
||||
// Without a valid AddIn instance or a manifest we can't do anything...
|
||||
return false; |
||||
} |
||||
|
||||
string identity = addIn.Manifest.PrimaryIdentity; |
||||
if (!String.IsNullOrEmpty(identity)) |
||||
{ |
||||
return (SD.AddInTree.AddIns |
||||
.Where(a => (addIn == a) || ((a.Manifest != null) && a.Manifest.Identities.ContainsKey(identity))) |
||||
.FirstOrDefault() != null); |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public bool IsAddInPreinstalled(AddIn addIn) |
||||
{ |
||||
if (addIn != null) |
||||
{ |
||||
return |
||||
String.Equals(addIn.Properties["addInManagerHidden"], "preinstalled", StringComparison.OrdinalIgnoreCase) |
||||
&& FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, addIn.FileName); |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public IPackage GetNuGetPackageForAddIn(AddIn addIn, bool getLatest) |
||||
{ |
||||
if (addIn == null) |
||||
{ |
||||
throw new ArgumentNullException("addIn"); |
||||
} |
||||
|
||||
IPackage package = null; |
||||
string nuGetPackageID = null; |
||||
if (addIn.Properties.Contains("nuGetPackageID")) |
||||
{ |
||||
nuGetPackageID = addIn.Properties["nuGetPackageID"]; |
||||
} |
||||
string primaryIdentity = null; |
||||
if (addIn.Manifest != null) |
||||
{ |
||||
primaryIdentity = addIn.Manifest.PrimaryIdentity; |
||||
} |
||||
|
||||
if (!String.IsNullOrEmpty(nuGetPackageID)) |
||||
{ |
||||
// Find installed package with mapped NuGet package ID
|
||||
var matchingPackages = _nuGet.Packages.LocalRepository.GetPackages() |
||||
.Where(p => (p.Id == primaryIdentity) || (p.Id == nuGetPackageID)) |
||||
.OrderBy(p => p.Version); |
||||
if (getLatest) |
||||
{ |
||||
// Return latest package version
|
||||
package = matchingPackages.LastOrDefault(); |
||||
} |
||||
else |
||||
{ |
||||
// Return oldest installed package version
|
||||
package = matchingPackages.FirstOrDefault(); |
||||
} |
||||
} |
||||
|
||||
return package; |
||||
} |
||||
|
||||
public AddIn GetAddInForNuGetPackage(IPackage package) |
||||
{ |
||||
return GetAddInForNuGetPackage(package, false); |
||||
} |
||||
|
||||
public AddIn GetAddInForNuGetPackage(IPackage package, bool withAddInsMarkedForInstallation) |
||||
{ |
||||
if (withAddInsMarkedForInstallation) |
||||
{ |
||||
return GetInstalledOrMarkedAddInForNuGetPackage(package); |
||||
} |
||||
else |
||||
{ |
||||
return GetInstalledAddInForNuGetPackage(package); |
||||
} |
||||
} |
||||
|
||||
private AddIn GetInstalledAddInForNuGetPackage(IPackage package) |
||||
{ |
||||
if (package == null) |
||||
{ |
||||
throw new ArgumentNullException("package"); |
||||
} |
||||
|
||||
AddIn foundAddIn = SD.AddInTree.AddIns.Where( |
||||
a => ((a.Manifest != null) && (a.Manifest.PrimaryIdentity == package.Id)) |
||||
|| (a.Properties.Contains("nuGetPackageID") && (a.Properties["nuGetPackageID"] == package.Id))) |
||||
.FirstOrDefault(); |
||||
|
||||
return foundAddIn; |
||||
} |
||||
|
||||
private AddIn GetInstalledOrMarkedAddInForNuGetPackage(IPackage package) |
||||
{ |
||||
if (package == null) |
||||
{ |
||||
throw new ArgumentNullException("package"); |
||||
} |
||||
|
||||
ManagedAddIn foundAddIn = AddInsWithMarkedForInstallation.Where( |
||||
a => ((a.AddIn.Manifest != null) && (a.AddIn.Manifest.PrimaryIdentity == package.Id)) |
||||
|| (a.AddIn.Properties.Contains("nuGetPackageID") && (a.AddIn.Properties["nuGetPackageID"] == package.Id))) |
||||
.FirstOrDefault(); |
||||
|
||||
return (foundAddIn != null) ? foundAddIn.AddIn : null; |
||||
} |
||||
|
||||
public IEnumerable<ManagedAddIn> GetDependentAddIns(AddIn addIn) |
||||
{ |
||||
if ((addIn != null) && (addIn.Manifest != null) && (addIn.Manifest.PrimaryIdentity != null)) |
||||
{ |
||||
// Get all AddIns which are dependent from given AddIn
|
||||
var dependentAddIns = AddInsWithMarkedForInstallation.Where( |
||||
a => (a.AddIn.Manifest != null) && a.AddIn.Manifest.Dependencies.Any( |
||||
reference => reference.Name == addIn.Manifest.PrimaryIdentity)); |
||||
return dependentAddIns; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public void RemoveUnreferencedNuGetPackages() |
||||
{ |
||||
// Get list of installed NuGet packages
|
||||
var localRepositoryPackages = _nuGet.Packages.LocalRepository.GetPackages(); |
||||
if (localRepositoryPackages != null) |
||||
{ |
||||
List<IPackage> installedNuGetPackages = new List<IPackage>(localRepositoryPackages); |
||||
foreach (var installedPackage in installedNuGetPackages) |
||||
{ |
||||
bool removeThisPackage = false; |
||||
AddIn addIn = GetAddInForNuGetPackage(installedPackage); |
||||
if (addIn == null) |
||||
{ |
||||
// There is no AddIn for this package -> remove it
|
||||
removeThisPackage = true; |
||||
} |
||||
else |
||||
{ |
||||
// Try to get the most recent (= with highest version) package for this AddIn
|
||||
IPackage latestPackage = installedNuGetPackages |
||||
.Where(p => p.Id == installedPackage.Id) |
||||
.OrderBy(p => p.Version) |
||||
.LastOrDefault(); |
||||
if (latestPackage.Version != installedPackage.Version) |
||||
{ |
||||
// This is not the most recent installed package for this AddIn -> remove it
|
||||
removeThisPackage = true; |
||||
} |
||||
} |
||||
|
||||
if (removeThisPackage) |
||||
{ |
||||
// We decided to remove this package
|
||||
LoggingService.InfoFormatted("Removing unreferenced NuGet package {0} {1}.", |
||||
installedPackage.Id, installedPackage.Version.ToString()); |
||||
_nuGet.Packages.UninstallPackage(installedPackage, true, false); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
// private void LoadMappings()
|
||||
// {
|
||||
// var savedMappings = PropertyService.Get<string[]>("AddInManager2.AddInPackageMappings", null);
|
||||
// if (savedMappings != null)
|
||||
// {
|
||||
// foreach (var mapping in savedMappings)
|
||||
// {
|
||||
// string[] mappingParts = mapping.Split(new char[] { '|' }, 2);
|
||||
// if ((mappingParts != null) && (mappingParts.Length == 2))
|
||||
// {
|
||||
// _addInToNuGetMapping[mappingParts[0]] = mappingParts[1];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Save empty mapping
|
||||
// SaveMappings();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void SaveMappings()
|
||||
// {
|
||||
// List<string> mappingList = new List<string>();
|
||||
// foreach (var mapping in _addInToNuGetMapping)
|
||||
// {
|
||||
// mappingList.Add(mapping.Key + "|" + mapping.Value);
|
||||
// }
|
||||
//
|
||||
// PropertyService.Set<string[]>("AddInManager2.AddInPackageMappings", mappingList.ToArray());
|
||||
// }
|
||||
} |
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// Interface for AddInManager event service.
|
||||
/// </summary>
|
||||
public interface IAddInManagerEvents |
||||
{ |
||||
event EventHandler OperationStarted; |
||||
void OnOperationStarted(EventArgs e); |
||||
|
||||
event EventHandler<AddInInstallationEventArgs> AddInInstalled; |
||||
void OnAddInInstalled(AddInInstallationEventArgs e); |
||||
|
||||
event EventHandler<AddInInstallationEventArgs> AddInUninstalled; |
||||
void OnAddInUninstalled(AddInInstallationEventArgs e); |
||||
|
||||
event EventHandler<AddInExceptionEventArgs> AddInOperationError; |
||||
void OnAddInOperationError(AddInExceptionEventArgs e); |
||||
|
||||
event EventHandler<PackageOperationEventArgs> AddInPackageDownloaded; |
||||
void OnAddInPackageDownloaded(PackageOperationEventArgs e); |
||||
|
||||
event EventHandler<PackageOperationEventArgs> AddInPackageRemoved; |
||||
void OnAddInPackageRemoved(PackageOperationEventArgs e); |
||||
|
||||
event EventHandler<AddInInstallationEventArgs> AddInStateChanged; |
||||
void OnAddInStateChanged(AddInInstallationEventArgs e); |
||||
|
||||
event EventHandler<PackageMessageLoggedEventArgs> PackageMessageLogged; |
||||
void OnPackageMessageLogged(PackageMessageLoggedEventArgs e); |
||||
|
||||
event EventHandler<AcceptLicensesEventArgs> AcceptLicenses; |
||||
void OnAcceptLicenses(AcceptLicensesEventArgs e); |
||||
} |
||||
} |
||||
@ -0,0 +1,130 @@
@@ -0,0 +1,130 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// Describes an AddIn package entry in AddInManager.
|
||||
/// </summary>
|
||||
public interface IAddInPackage |
||||
{ |
||||
string Name |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool HasLicenseUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
Uri LicenseUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool HasProjectUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
Uri ProjectUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool HasReportAbuseUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
Uri ReportAbuseUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool IsAdded |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
IEnumerable<AddInDependency> Dependencies |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool HasDependencies |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool HasNoDependencies |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
IEnumerable<string> Authors |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool HasDownloadCount |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
string Id |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
Uri IconUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
string Summary |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
Version Version |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
int DownloadCount |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
string Description |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
DateTime? LastUpdated |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool HasLastUpdated |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool HasVersion |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
bool IsManaged |
||||
{ |
||||
get; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
// 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.IO; |
||||
using System.Linq; |
||||
using ICSharpCode.Core; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public interface IAddInSetup |
||||
{ |
||||
IEnumerable<ManagedAddIn> AddInsWithMarkedForInstallation |
||||
{ |
||||
get; |
||||
} |
||||
AddIn InstallAddIn(string archiveFileName); |
||||
AddIn InstallAddIn(IPackage package, string packageDirectory); |
||||
void UninstallAddIn(AddIn addIn); |
||||
void CancelUpdate(AddIn addIn); |
||||
void CancelInstallation(AddIn addIn); |
||||
void CancelUninstallation(AddIn addIn); |
||||
void SwitchAddInActivation(AddIn addIn); |
||||
AddIn GetInstalledAddInByIdentity(string identity); |
||||
bool IsAddInInstalled(AddIn addIn); |
||||
bool IsAddInPreinstalled(AddIn addin); |
||||
IPackage GetNuGetPackageForAddIn(AddIn addIn, bool getLatest); |
||||
AddIn GetAddInForNuGetPackage(IPackage package); |
||||
AddIn GetAddInForNuGetPackage(IPackage package, bool withAddInsMarkedForInstallation); |
||||
IEnumerable<ManagedAddIn> GetDependentAddIns(AddIn addIn); |
||||
void RemoveUnreferencedNuGetPackages(); |
||||
} |
||||
} |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
// 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.Core; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public interface INuGetPackageManager |
||||
{ |
||||
IPackageManager Packages |
||||
{ |
||||
get; |
||||
} |
||||
string PackageOutputDirectory |
||||
{ |
||||
get; |
||||
} |
||||
bool PackageContainsAddIn(IPackage package); |
||||
IPackageOperationResolver CreateInstallPackageOperationResolver(bool allowPrereleaseVersions); |
||||
void ExecuteOperation(PackageOperation operation); |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -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.Collections.Generic; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public interface IPackageRepositories |
||||
{ |
||||
IPackageRepository Registered |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
IPackageRepository Active |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
PackageSource ActiveSource |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
IEnumerable<PackageSource> RegisteredPackageSources |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// 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.Core; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public enum AddInInstallationSource |
||||
{ |
||||
Offline, |
||||
NuGetRepository |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Extension of AddIn class used in AddInManager internally.
|
||||
/// </summary>
|
||||
public class ManagedAddIn |
||||
{ |
||||
private AddIn _addIn; |
||||
|
||||
public ManagedAddIn(AddIn addIn) |
||||
{ |
||||
_addIn = addIn; |
||||
InstallationSource = AddInInstallationSource.Offline; |
||||
} |
||||
|
||||
public bool IsTemporary |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public bool IsUpdate |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public Version OldVersion |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public AddInInstallationSource InstallationSource |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public AddIn AddIn |
||||
{ |
||||
get |
||||
{ |
||||
return _addIn; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -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.ComponentModel; |
||||
using System.Linq.Expressions; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public abstract class Model<TModel> : INotifyPropertyChanged |
||||
{ |
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
public string PropertyChangedFor<TProperty>(Expression<Func<TModel, TProperty>> expression) |
||||
{ |
||||
MemberExpression memberExpression = expression.Body as MemberExpression; |
||||
return PropertyChangedFor(memberExpression); |
||||
} |
||||
|
||||
private string PropertyChangedFor(MemberExpression memberExpression) |
||||
{ |
||||
if (memberExpression != null) |
||||
{ |
||||
return memberExpression.Member.Name; |
||||
} |
||||
return String.Empty; |
||||
} |
||||
|
||||
protected void OnPropertyChanged<TProperty>(Expression<Func<TModel, TProperty>> expression) |
||||
{ |
||||
string propertyName = PropertyChangedFor(expression); |
||||
OnPropertyChanged(propertyName); |
||||
} |
||||
|
||||
protected void OnPropertyChanged(string propertyName) |
||||
{ |
||||
if (PropertyChanged != null) |
||||
{ |
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,155 @@
@@ -0,0 +1,155 @@
|
||||
// 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.IO; |
||||
using System.Linq; |
||||
using System.Runtime.Versioning; |
||||
using ICSharpCode.Core; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// Wrapper around native NuGet package manager.
|
||||
/// </summary>
|
||||
public class NuGetPackageManager : INuGetPackageManager |
||||
{ |
||||
/// <summary>
|
||||
/// Helper for log messages generated by NuGet component.
|
||||
/// </summary>
|
||||
public class PackageMessageLogger : ILogger |
||||
{ |
||||
IAddInManagerEvents _events = null; |
||||
|
||||
public PackageMessageLogger(IAddInManagerEvents events) |
||||
{ |
||||
_events = events; |
||||
} |
||||
|
||||
public void Log(MessageLevel level, string message, params object[] args) |
||||
{ |
||||
_events.OnPackageMessageLogged(new PackageMessageLoggedEventArgs(level, message, args)); |
||||
} |
||||
} |
||||
|
||||
private NuGetPackageManagerImplementation _packageManager = null; |
||||
private IPackageRepositories _repositories = null; |
||||
private IAddInManagerEvents _events = null; |
||||
private ILogger _logger = null; |
||||
private string _packageOutputDirectory; |
||||
|
||||
public NuGetPackageManager(IPackageRepositories repositories, IAddInManagerEvents events) |
||||
{ |
||||
_repositories = repositories; |
||||
_events = events; |
||||
_packageOutputDirectory = Path.Combine(PropertyService.ConfigDirectory, "NuGet"); |
||||
|
||||
_logger = new PackageMessageLogger(_events); |
||||
|
||||
_events.PackageMessageLogged += Events_PackageMessageLogged; |
||||
} |
||||
|
||||
public IPackageManager Packages |
||||
{ |
||||
get |
||||
{ |
||||
// Create PackageManager instance lazily
|
||||
return EnsurePackageManagerInstance(); |
||||
} |
||||
} |
||||
|
||||
public ILogger Logger |
||||
{ |
||||
get |
||||
{ |
||||
return _logger; |
||||
} |
||||
} |
||||
|
||||
public string PackageOutputDirectory |
||||
{ |
||||
get |
||||
{ |
||||
return _packageOutputDirectory; |
||||
} |
||||
} |
||||
|
||||
public bool PackageContainsAddIn(IPackage package) |
||||
{ |
||||
return (package != null) && (package.Tags != null) && package.Tags.Contains("SharpDevelopAddIn"); |
||||
} |
||||
|
||||
public IPackageOperationResolver CreateInstallPackageOperationResolver(bool allowPrereleaseVersions) |
||||
{ |
||||
EnsurePackageManagerInstance(); |
||||
|
||||
return new InstallWalker( |
||||
_packageManager.LocalRepository, |
||||
_packageManager.SourceRepository, |
||||
null, |
||||
_logger, |
||||
false, |
||||
allowPrereleaseVersions); |
||||
} |
||||
|
||||
public void ExecuteOperation(PackageOperation operation) |
||||
{ |
||||
EnsurePackageManagerInstance(); |
||||
_packageManager.ExecuteOperation(operation); |
||||
} |
||||
|
||||
private IPackageManager EnsurePackageManagerInstance() |
||||
{ |
||||
if (_packageManager != null) |
||||
{ |
||||
return _packageManager; |
||||
} |
||||
|
||||
// Ensure that package directory exists
|
||||
if (!Directory.Exists(_packageOutputDirectory)) |
||||
{ |
||||
Directory.CreateDirectory(_packageOutputDirectory); |
||||
} |
||||
|
||||
// Create new package manager instance
|
||||
_packageManager = new NuGetPackageManagerImplementation(_repositories.Registered, _packageOutputDirectory); |
||||
_packageManager.PackageInstalled += _packageEvents_NuGetPackageInstalled; |
||||
_packageManager.PackageUninstalled += _packageEvents_NuGetPackageUninstalled; |
||||
return _packageManager; |
||||
} |
||||
|
||||
private void _packageEvents_NuGetPackageInstalled(object sender, PackageOperationEventArgs e) |
||||
{ |
||||
// NuGet package has been downloaded and extracted, now install the AddIn from it
|
||||
// TODO Error management?
|
||||
|
||||
_events.OnAddInPackageDownloaded(e); |
||||
} |
||||
|
||||
private void _packageEvents_NuGetPackageUninstalled(object sender, PackageOperationEventArgs e) |
||||
{ |
||||
_events.OnAddInPackageRemoved(e); |
||||
} |
||||
|
||||
private void Events_PackageMessageLogged(object sender, PackageMessageLoggedEventArgs e) |
||||
{ |
||||
LoggingService.InfoFormatted("[NuGetPackageManager] {0}", e.Message); |
||||
} |
||||
|
||||
private class NuGetPackageManagerImplementation : PackageManager |
||||
{ |
||||
public NuGetPackageManagerImplementation(IPackageRepository sourceRepository, string path) |
||||
: base(sourceRepository, path) |
||||
{ |
||||
} |
||||
|
||||
public void ExecuteOperation(PackageOperation operation) |
||||
{ |
||||
// Allow to call this method from outside of the class
|
||||
base.Execute(operation); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// Event data for operations related to NuGet packages.
|
||||
/// </summary>
|
||||
public class NuGetPackageOperationEventArgs : EventArgs |
||||
{ |
||||
public NuGetPackageOperationEventArgs(IPackage package) |
||||
{ |
||||
Package = package; |
||||
} |
||||
|
||||
public IPackage Package |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public class PackageMessageLoggedEventArgs : EventArgs |
||||
{ |
||||
public PackageMessageLoggedEventArgs(MessageLevel level, string message, params object[] args) |
||||
{ |
||||
this.Message = new PackageOperationMessage(level, message, args); |
||||
} |
||||
|
||||
public PackageOperationMessage Message |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
} |
||||
|
||||
public class PackageOperationMessage |
||||
{ |
||||
string message; |
||||
object[] args; |
||||
|
||||
public PackageOperationMessage(MessageLevel level, string message, params object[] args) |
||||
{ |
||||
this.Level = level; |
||||
this.message = message; |
||||
this.args = args; |
||||
} |
||||
|
||||
public MessageLevel Level |
||||
{ |
||||
get; private set; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return String.Format(message, args); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,136 @@
@@ -0,0 +1,136 @@
|
||||
// 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.Linq; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
/// <summary>
|
||||
/// Holds reference to currently used NuGet package repositories to install AddIns from.
|
||||
/// </summary>
|
||||
public class PackageRepositories : IPackageRepositories |
||||
{ |
||||
private IPackageRepository _currentRepository; |
||||
private IPackageRepository _activeRepository; |
||||
private PackageSource _activeSource; |
||||
private List<PackageSource> _registeredPackageSources; |
||||
|
||||
public PackageRepositories() |
||||
{ |
||||
_registeredPackageSources = new List<PackageSource>(); |
||||
LoadPackageSources(); |
||||
UpdateCurrentRepository(); |
||||
UpdateActiveRepository(); |
||||
} |
||||
|
||||
public IPackageRepository Registered |
||||
{ |
||||
get |
||||
{ |
||||
return _currentRepository; |
||||
} |
||||
} |
||||
|
||||
public IPackageRepository Active |
||||
{ |
||||
get |
||||
{ |
||||
return _activeRepository; |
||||
} |
||||
} |
||||
|
||||
public PackageSource ActiveSource |
||||
{ |
||||
get |
||||
{ |
||||
return _activeSource; |
||||
} |
||||
set |
||||
{ |
||||
_activeSource = value; |
||||
UpdateActiveRepository(); |
||||
} |
||||
} |
||||
|
||||
public IEnumerable<PackageSource> RegisteredPackageSources |
||||
{ |
||||
get |
||||
{ |
||||
return _registeredPackageSources; |
||||
} |
||||
set |
||||
{ |
||||
_registeredPackageSources.Clear(); |
||||
_registeredPackageSources.AddRange(value); |
||||
SavePackageSources(); |
||||
} |
||||
} |
||||
|
||||
private void LoadPackageSources() |
||||
{ |
||||
_registeredPackageSources.Clear(); |
||||
var savedRepositories = SD.PropertyService.Get<string[]>("AddInManager2.PackageRepositories", null); |
||||
if ((savedRepositories != null) && (savedRepositories.Length > 0)) |
||||
{ |
||||
foreach (string repositoryEntry in savedRepositories) |
||||
{ |
||||
string[] splittedEntry = repositoryEntry.Split(new char[] { '=' }, 2); |
||||
if ((splittedEntry != null) && (splittedEntry.Length == 2)) |
||||
{ |
||||
// Create PackageSource from this entry
|
||||
PackageSource savedPackageSource = new PackageSource(splittedEntry[1], splittedEntry[0]); |
||||
_registeredPackageSources.Add(savedPackageSource); |
||||
} |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
// If we don't have any repositories, so add the default one
|
||||
PackageSource defaultPackageSource = |
||||
new PackageSource("https://nuget.org/api/v2", ResourceService.GetString("AddInManager2.DefaultRepository")); |
||||
_registeredPackageSources.Add(defaultPackageSource); |
||||
SavePackageSources(); |
||||
} |
||||
} |
||||
|
||||
private void SavePackageSources() |
||||
{ |
||||
var savedRepositories = _registeredPackageSources.Select(ps => ps.Name + "=" + ps.Source); |
||||
PropertyService.Set<string[]>("AddInManager2.PackageRepositories", savedRepositories.ToArray()); |
||||
UpdateCurrentRepository(); |
||||
} |
||||
|
||||
private void UpdateCurrentRepository() |
||||
{ |
||||
var repositories = |
||||
_registeredPackageSources.Select(packageSource => PackageRepositoryFactory.Default.CreateRepository(packageSource.Source)); |
||||
if (repositories.Any()) |
||||
{ |
||||
_currentRepository = new AggregateRepository(repositories); |
||||
} |
||||
} |
||||
|
||||
private void UpdateActiveRepository() |
||||
{ |
||||
if ((_activeSource == null) && (_registeredPackageSources != null)) |
||||
{ |
||||
_activeSource = _registeredPackageSources[0]; |
||||
} |
||||
|
||||
if (_activeSource != null) |
||||
{ |
||||
_activeRepository = PackageRepositoryFactory.Default.CreateRepository(_activeSource.Source); |
||||
} |
||||
else |
||||
{ |
||||
// If no active repository is set, get packages from all repositories
|
||||
_activeRepository = _currentRepository; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public class PackageRepository : Model<PackageRepository> |
||||
{ |
||||
// RegisteredPackageSource packageSource;
|
||||
|
||||
public PackageRepository() |
||||
{ |
||||
} |
||||
|
||||
public PackageRepository(PackageSource packageSource) |
||||
{ |
||||
// this.packageSource = new RegisteredPackageSource(packageSource);
|
||||
Name = packageSource.Name; |
||||
SourceUrl = packageSource.Source; |
||||
} |
||||
|
||||
public string Name |
||||
{ |
||||
// get
|
||||
// {
|
||||
// return packageSource.Name;
|
||||
// TODO
|
||||
// return null;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// packageSource.Name = value;
|
||||
// }
|
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public string SourceUrl |
||||
{ |
||||
// get
|
||||
// {
|
||||
// return packageSource.Source;
|
||||
// TODO
|
||||
// return null;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// packageSource.Source = value;
|
||||
// }
|
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public PackageSource ToPackageSource() |
||||
{ |
||||
return new PackageSource(SourceUrl, Name); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
// 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.AddInManager2.Model |
||||
{ |
||||
public class Page |
||||
{ |
||||
public int Number { get; set; } |
||||
public bool IsSelected { get; set; } |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return String.Format("[Page] Number={0}, IsSelected={1}", Number, IsSelected); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,155 @@
@@ -0,0 +1,155 @@
|
||||
// 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.ObjectModel; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public class Pages : ObservableCollection<Page> |
||||
{ |
||||
public const int DefaultPageSize = 10; |
||||
public const int DefaultMaximumSelectablePages = 5; |
||||
|
||||
int pageSize = DefaultPageSize; |
||||
int selectedPageNumber = 1; |
||||
int maximumSelectablePages = DefaultMaximumSelectablePages; |
||||
int totalItems = 0; |
||||
int itemsOnSelectedPage = 0; |
||||
|
||||
public int TotalItems { |
||||
get { return totalItems; } |
||||
set { |
||||
if (totalItems != value) { |
||||
totalItems = value; |
||||
UpdatePages(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public int SelectedPageNumber { |
||||
get { return selectedPageNumber; } |
||||
set { |
||||
if (selectedPageNumber != value) { |
||||
selectedPageNumber = value; |
||||
UpdatePages(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public int MaximumSelectablePages { |
||||
get { return maximumSelectablePages; } |
||||
set { |
||||
if (maximumSelectablePages != value) { |
||||
maximumSelectablePages = value; |
||||
UpdatePages(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public int ItemsBeforeFirstPage { |
||||
get { |
||||
return (selectedPageNumber - 1) * pageSize; |
||||
} |
||||
} |
||||
|
||||
public bool IsPaged { |
||||
get { return totalItems > pageSize; } |
||||
} |
||||
|
||||
public bool HasPreviousPage { |
||||
get { return IsPaged && !IsFirstPageSelected; } |
||||
} |
||||
|
||||
bool IsFirstPageSelected { |
||||
get { return selectedPageNumber == 1; } |
||||
} |
||||
|
||||
public bool HasNextPage { |
||||
get { return IsPaged && !IsLastPageSelected; } |
||||
} |
||||
|
||||
bool IsLastPageSelected { |
||||
get { return selectedPageNumber == TotalPages; } |
||||
} |
||||
|
||||
public int TotalPages { |
||||
get { return (totalItems + pageSize - 1) / pageSize; } |
||||
} |
||||
|
||||
public int PageSize { |
||||
get { return pageSize; } |
||||
set { |
||||
if (pageSize != value) { |
||||
pageSize = value; |
||||
UpdatePages(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void UpdatePages() |
||||
{ |
||||
Clear(); |
||||
|
||||
int startPage = GetStartPage(); |
||||
for (int pageNumber = startPage; pageNumber <= TotalPages; ++pageNumber) { |
||||
if (Count >= maximumSelectablePages) { |
||||
break; |
||||
} |
||||
Page page = CreatePage(pageNumber); |
||||
Add(page); |
||||
} |
||||
} |
||||
|
||||
int GetStartPage() |
||||
{ |
||||
// Less pages than can be selected?
|
||||
int totalPages = TotalPages; |
||||
if (totalPages <= maximumSelectablePages) { |
||||
return 1; |
||||
} |
||||
|
||||
// First choice for start page.
|
||||
int startPage = selectedPageNumber - (maximumSelectablePages / 2); |
||||
if (startPage <= 0) { |
||||
return 1; |
||||
} |
||||
|
||||
// Do we have enough pages?
|
||||
int totalPagesBasedOnStartPage = totalPages - startPage + 1; |
||||
if (totalPagesBasedOnStartPage >= maximumSelectablePages) { |
||||
return startPage; |
||||
} |
||||
|
||||
// Ensure we have enough pages.
|
||||
startPage -= maximumSelectablePages - totalPagesBasedOnStartPage; |
||||
if (startPage > 0) { |
||||
return startPage; |
||||
} |
||||
return 1; |
||||
} |
||||
|
||||
Page CreatePage(int pageNumber) |
||||
{ |
||||
var page = new Page(); |
||||
page.Number = pageNumber; |
||||
page.IsSelected = IsSelectedPage(pageNumber); |
||||
return page; |
||||
} |
||||
|
||||
bool IsSelectedPage(int pageNumber) |
||||
{ |
||||
return pageNumber == selectedPageNumber; |
||||
} |
||||
|
||||
public int TotalItemsOnSelectedPage { |
||||
get { return itemsOnSelectedPage; } |
||||
set { |
||||
itemsOnSelectedPage = value; |
||||
if (itemsOnSelectedPage < pageSize) { |
||||
TotalItems = (selectedPageNumber - 1) * pageSize + itemsOnSelectedPage; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// 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.Linq; |
||||
using ICSharpCode.AddInManager2.ViewModel; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.Model |
||||
{ |
||||
public class ReadPackagesResult |
||||
{ |
||||
public ReadPackagesResult(IEnumerable<IPackage> packages, int totalPackages) |
||||
{ |
||||
this.Packages = packages; |
||||
this.TotalPackagesOnPage = packages.Count(); |
||||
this.TotalPackages = totalPackages; |
||||
} |
||||
|
||||
public IEnumerable<IPackage> Packages { get; set; } |
||||
public int TotalPackagesOnPage { get; set; } |
||||
public int TotalPackages { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
<Window |
||||
x:Class="ICSharpCode.AddInManager2.View.AddInManagerView" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:core="clr-namespace:ICSharpCode.Core.Presentation;assembly=ICSharpCode.Core.Presentation" |
||||
xmlns:aimview="clr-namespace:ICSharpCode.AddInManager2.View" |
||||
xmlns:aimvm="clr-namespace:ICSharpCode.AddInManager2.ViewModel" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
Height="480" |
||||
Width="640" |
||||
MinHeight="380" |
||||
MinWidth="440" |
||||
Style="{x:Static core:GlobalStyles.DialogWindowStyle}" |
||||
WindowStartupLocation="CenterOwner"> |
||||
|
||||
<Window.Resources> |
||||
<Style TargetType="Button" BasedOn="{x:Static core:GlobalStyles.ButtonStyle}"/> |
||||
<aimvm:AddInManagerViewModel x:Key="ViewModel"/> |
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/> |
||||
|
||||
<BitmapImage x:Key="ErrorIcon" |
||||
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/exclamation.png"/> |
||||
|
||||
<Style x:Key="tabHeaderTextStyle" TargetType="{x:Type TextBlock}"> |
||||
<Style.Triggers> |
||||
<DataTrigger Binding="{Binding DataContext.HasHighlightCount}" Value="True"> |
||||
<Setter Property="FontWeight" Value="Bold" /> |
||||
</DataTrigger> |
||||
</Style.Triggers> |
||||
<Setter Property="Text" Value="{Binding DataContext.TitleWithHighlight}" /> |
||||
</Style> |
||||
|
||||
<DataTemplate x:Key="tabItemHeaderTemplate"> |
||||
<Grid> |
||||
<TextBlock Style="{StaticResource tabHeaderTextStyle}" /> |
||||
</Grid> |
||||
</DataTemplate> |
||||
|
||||
<Style TargetType="{x:Type TabItem}"> |
||||
<Setter Property="HeaderTemplate" Value="{Binding Source={StaticResource tabItemHeaderTemplate}}" /> |
||||
</Style> |
||||
</Window.Resources> |
||||
|
||||
<Window.DataContext> |
||||
<Binding Source="{StaticResource ViewModel}" /> |
||||
</Window.DataContext> |
||||
|
||||
<Window.Title> |
||||
<Binding Path="Title"/> |
||||
</Window.Title> |
||||
|
||||
<DockPanel x:Name="MainPanel"> |
||||
<Grid |
||||
DockPanel.Dock="Bottom" |
||||
Margin="4, 4"> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition Width="*"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
</Grid.ColumnDefinitions> |
||||
<StackPanel> |
||||
<Image |
||||
Margin="4, 4" |
||||
Visibility="{Binding Path=HasError, Converter={StaticResource BoolToVisibility}}" |
||||
Source="{StaticResource ErrorIcon}"/> |
||||
</StackPanel> |
||||
<TextBlock |
||||
Grid.Column="1" |
||||
Margin="4, 4" |
||||
TextTrimming="CharacterEllipsis" |
||||
Text="{Binding Path=Message}"/> |
||||
<Button |
||||
Grid.Column="2" |
||||
Content="{core:Localize Global.CloseButtonText}" |
||||
IsCancel="True"/> |
||||
</Grid> |
||||
<TabControl> |
||||
<TabItem> |
||||
<TabItem.Header> |
||||
<TextBlock Style="{StaticResource tabHeaderTextStyle}" DataContext="{Binding InstalledAddInsViewModel}" /> |
||||
</TabItem.Header> |
||||
<aimview:AddInsView |
||||
x:Name="InstalledPackagesView" |
||||
DataContext="{Binding InstalledAddInsViewModel}" /> |
||||
</TabItem> |
||||
<TabItem> |
||||
<TabItem.Header> |
||||
<TextBlock Style="{StaticResource tabHeaderTextStyle}" DataContext="{Binding UpdatedAddInsViewModel}" /> |
||||
</TabItem.Header> |
||||
<aimview:AddInsView |
||||
x:Name="PackageUpdatesView" |
||||
DataContext="{Binding UpdatedAddInsViewModel}" /> |
||||
</TabItem> |
||||
<TabItem> |
||||
<TabItem.Header> |
||||
<TextBlock Style="{StaticResource tabHeaderTextStyle}" DataContext="{Binding AvailableAddInsViewModel}" /> |
||||
</TabItem.Header> |
||||
<aimview:AddInsView |
||||
x:Name="AvailablePackagesView" |
||||
DataContext="{Binding AvailableAddInsViewModel}" /> |
||||
</TabItem> |
||||
</TabControl> |
||||
</DockPanel> |
||||
</Window> |
||||
@ -0,0 +1,28 @@
@@ -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 System.Windows; |
||||
using ICSharpCode.AddInManager2.ViewModel; |
||||
|
||||
namespace ICSharpCode.AddInManager2.View |
||||
{ |
||||
public partial class AddInManagerView : Window, IDisposable |
||||
{ |
||||
public AddInManagerView() |
||||
{ |
||||
InitializeComponent(); |
||||
|
||||
ICSharpCode.SharpDevelop.Gui.FormLocationHelper.ApplyWindow(this, "AddInManager2.WindowBounds", true); |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
var viewModel = DataContext as AddInManagerViewModel; |
||||
if (viewModel != null) |
||||
{ |
||||
viewModel.Dispose(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,554 @@
@@ -0,0 +1,554 @@
|
||||
<UserControl |
||||
x:Class="ICSharpCode.AddInManager2.View.AddInsView" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:core="clr-namespace:ICSharpCode.Core.Presentation;assembly=ICSharpCode.Core.Presentation" |
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
xmlns:aimview="clr-namespace:ICSharpCode.AddInManager2.View" |
||||
xmlns:aimvm="clr-namespace:ICSharpCode.AddInManager2.ViewModel" |
||||
mc:Ignorable="d" |
||||
d:DesignHeight="250" |
||||
d:DesignWidth="500"> |
||||
|
||||
<UserControl.Resources> |
||||
<aimvm:OpenHyperlinkCommand x:Key="OpenHyperlinkCommand"/> |
||||
<BitmapImage x:Key="DefaultPackageIcon" |
||||
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/packageicon.png"/> |
||||
<BitmapImage x:Key="SmallPackageIcon" |
||||
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/packageicon_small.png"/> |
||||
<BitmapImage x:Key="SDPackageIcon" |
||||
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/sd_packageicon.png"/> |
||||
<BitmapImage x:Key="PackageAddedIcon" |
||||
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/accept.png"/> |
||||
<BitmapImage x:Key="SearchIcon" |
||||
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/magnifier.png"/> |
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/> |
||||
|
||||
<DataTemplate x:Key="PackageSourceComboBoxItemTemplate"> |
||||
<TextBlock Text="{Binding Path=Name}"/> |
||||
</DataTemplate> |
||||
|
||||
<Style x:Key="AddInImageStyle" TargetType="{x:Type Image}"> |
||||
<Style.Triggers> |
||||
<DataTrigger Binding="{Binding IsOffline}" Value="False"> |
||||
<Setter Property="Source" Value="{Binding Path=IconUrl, TargetNullValue={StaticResource DefaultPackageIcon}}" /> |
||||
</DataTrigger> |
||||
<DataTrigger Binding="{Binding IsOffline}" Value="True"> |
||||
<Setter Property="Source" Value="{Binding Path=IconUrl, TargetNullValue={StaticResource SDPackageIcon}}" /> |
||||
</DataTrigger> |
||||
<DataTrigger Binding="{Binding IsEnabled}" Value="False"> |
||||
<Setter Property="Opacity" Value="0.5" /> |
||||
</DataTrigger> |
||||
</Style.Triggers> |
||||
</Style> |
||||
|
||||
<Style x:Key="AddInOnlineStateImageStyle" TargetType="{x:Type Image}"> |
||||
<Setter Property="Source" Value="{StaticResource SmallPackageIcon}" /> |
||||
<Setter Property="Visibility" Value="{Binding Path=HasNuGetConnection, Converter={StaticResource BoolToVisibility}}" /> |
||||
<Style.Triggers> |
||||
<DataTrigger Binding="{Binding IsEnabled}" Value="False"> |
||||
<Setter Property="Opacity" Value="0.5" /> |
||||
</DataTrigger> |
||||
</Style.Triggers> |
||||
</Style> |
||||
|
||||
<Style x:Key="addInListButtonStyle" TargetType="{x:Type Button}" BasedOn="{x:Static core:GlobalStyles.ButtonStyle}"> |
||||
<Setter Property="Visibility" Value="Collapsed" /> |
||||
<Style.Triggers> |
||||
<MultiDataTrigger> |
||||
<MultiDataTrigger.Conditions> |
||||
<Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}" Value="True" /> |
||||
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled}" Value="True" /> |
||||
</MultiDataTrigger.Conditions> |
||||
<Setter Property="Visibility" Value="Visible" /> |
||||
</MultiDataTrigger> |
||||
</Style.Triggers> |
||||
</Style> |
||||
|
||||
<Style x:Key="addInDetailsButtonStyle" TargetType="{x:Type Button}" BasedOn="{x:Static core:GlobalStyles.ButtonStyle}"> |
||||
<Setter Property="Visibility" Value="Collapsed" /> |
||||
<Style.Triggers> |
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled}" Value="True"> |
||||
<Setter Property="Visibility" Value="Visible" /> |
||||
</DataTrigger> |
||||
</Style.Triggers> |
||||
</Style> |
||||
|
||||
<DataTemplate x:Key="PackageListBoxItemTemplate"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="60"/> |
||||
<ColumnDefinition Width="*"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
</Grid.ColumnDefinitions> |
||||
|
||||
<Grid.RowDefinitions> |
||||
<RowDefinition Height="60"/> |
||||
</Grid.RowDefinitions> |
||||
|
||||
<Image |
||||
Grid.Column="0" |
||||
Height="32" |
||||
Style="{StaticResource AddInImageStyle}" /> |
||||
<Image |
||||
Grid.Column="0" |
||||
Height="16" |
||||
Margin="36,0,0,0" |
||||
VerticalAlignment="Top" |
||||
Style="{StaticResource AddInOnlineStateImageStyle}" /> |
||||
<StackPanel |
||||
Grid.Column="1" |
||||
Margin="4, 0"> |
||||
<TextBlock |
||||
x:Name="nameTextBlock" |
||||
Text="{Binding Path=Name}" |
||||
FontWeight="Bold"/> |
||||
<TextBlock |
||||
x:Name="summaryTextBlock" |
||||
Text="{Binding Path=Summary}" |
||||
TextWrapping="Wrap" |
||||
TextTrimming="CharacterEllipsis" |
||||
MaxHeight="40"/> |
||||
</StackPanel> |
||||
<Image |
||||
Grid.Column="2" |
||||
VerticalAlignment="Top" |
||||
HorizontalAlignment="Right" |
||||
Height="16" |
||||
Width="16" |
||||
Source="{StaticResource PackageAddedIcon}" |
||||
Visibility="{Binding Path=IsAdded, Converter={StaticResource BoolToVisibility}}" |
||||
Margin="2,2,2,2"/> |
||||
<Button |
||||
x:Name="addPackageButton" |
||||
Grid.Column="2" |
||||
Content="{core:Localize AddInManager.ActionInstall}" |
||||
IsDefault="True" |
||||
Command="{Binding Path=AddPackageCommand}" |
||||
VerticalAlignment="Top" |
||||
Style="{StaticResource addInListButtonStyle}" |
||||
Margin="2,2,2,2"/> |
||||
<Button |
||||
x:Name="updatePackageButton" |
||||
Grid.Column="2" |
||||
Content="{core:Localize AddInManager.ActionUpdate}" |
||||
IsDefault="True" |
||||
Command="{Binding Path=UpdatePackageCommand}" |
||||
VerticalAlignment="Top" |
||||
Style="{StaticResource addInListButtonStyle}" |
||||
Margin="2,2,2,2"/> |
||||
<Button |
||||
x:Name="disablePackageButton" |
||||
Grid.Column="2" |
||||
Content="{core:Localize AddInManager.ActionDisable}" |
||||
IsDefault="True" |
||||
Command="{Binding Path=DisablePackageCommand}" |
||||
VerticalAlignment="Top" |
||||
Style="{StaticResource addInListButtonStyle}" |
||||
Margin="2,2,2,2"/> |
||||
<Button |
||||
x:Name="removePackageButton" |
||||
Grid.Column="2" |
||||
Content="{core:Localize AddInManager.ActionUninstall}" |
||||
Command="{Binding Path=RemovePackageCommand}" |
||||
VerticalAlignment="Bottom" |
||||
Style="{StaticResource addInListButtonStyle}" |
||||
Margin="2,2,2,2"/> |
||||
<Button |
||||
x:Name="cancelInstallationButton" |
||||
Grid.Column="2" |
||||
Content="{core:Localize AddInManager.ActionCancelInstallation}" |
||||
Command="{Binding Path=CancelInstallationCommand}" |
||||
VerticalAlignment="Bottom" |
||||
Style="{StaticResource addInListButtonStyle}" |
||||
Margin="2,2,2,2"/> |
||||
<Button |
||||
x:Name="cancelUpdateButton" |
||||
Grid.Column="2" |
||||
Content="{core:Localize AddInManager.ActionCancelUpdate}" |
||||
Command="{Binding Path=CancelUpdateCommand}" |
||||
VerticalAlignment="Bottom" |
||||
Style="{StaticResource addInListButtonStyle}" |
||||
Margin="2,2,2,2"/> |
||||
<Button |
||||
x:Name="cancelUninstallationButton" |
||||
Grid.Column="2" |
||||
Content="{core:Localize AddInManager.ActionCancelDeinstallation}" |
||||
Command="{Binding Path=CancelUninstallationCommand}" |
||||
VerticalAlignment="Bottom" |
||||
Style="{StaticResource addInListButtonStyle}" |
||||
Margin="2,2,2,2"/> |
||||
</Grid> |
||||
|
||||
<DataTemplate.Triggers> |
||||
<!-- Disabled AddIns --> |
||||
<DataTrigger Binding="{Binding Path=IsEnabled}" Value="False"> |
||||
<Setter |
||||
TargetName="disablePackageButton" |
||||
Property="Content" |
||||
Value="Enable" /> |
||||
<Setter |
||||
TargetName="nameTextBlock" |
||||
Property="Foreground" |
||||
Value="Gray"/> |
||||
<Setter |
||||
TargetName="summaryTextBlock" |
||||
Property="Foreground" |
||||
Value="Gray"/> |
||||
<Setter |
||||
TargetName="nameTextBlock" |
||||
Property="TextDecorations" |
||||
Value="Strikethrough"/> |
||||
</DataTrigger> |
||||
|
||||
<!-- AddIns marked for installation --> |
||||
<DataTrigger Binding="{Binding Path=IsAdded}" Value="True"> |
||||
<Setter |
||||
TargetName="nameTextBlock" |
||||
Property="FontStyle" |
||||
Value="Italic"/> |
||||
<Setter |
||||
TargetName="summaryTextBlock" |
||||
Property="FontStyle" |
||||
Value="Italic"/> |
||||
</DataTrigger> |
||||
|
||||
<!-- AddIns marked for uninstallation --> |
||||
<DataTrigger Binding="{Binding Path=IsRemoved}" Value="True"> |
||||
<Setter |
||||
TargetName="nameTextBlock" |
||||
Property="FontStyle" |
||||
Value="Italic"/> |
||||
<Setter |
||||
TargetName="summaryTextBlock" |
||||
Property="FontStyle" |
||||
Value="Italic"/> |
||||
</DataTrigger> |
||||
|
||||
<!-- AddIns with dependency conflicts --> |
||||
<MultiDataTrigger> |
||||
<MultiDataTrigger.Conditions> |
||||
<Condition |
||||
Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}" |
||||
Value="False"/> |
||||
<Condition |
||||
Binding="{Binding Path=HasDependencyConflicts}" |
||||
Value="True"/> |
||||
</MultiDataTrigger.Conditions> |
||||
<Setter |
||||
TargetName="nameTextBlock" |
||||
Property="Foreground" |
||||
Value="Red"/> |
||||
<Setter |
||||
TargetName="summaryTextBlock" |
||||
Property="Foreground" |
||||
Value="Red"/> |
||||
</MultiDataTrigger> |
||||
</DataTemplate.Triggers> |
||||
</DataTemplate> |
||||
|
||||
<DataTemplate x:Key="PackageTemplate"> |
||||
<ScrollViewer |
||||
VerticalScrollBarVisibility="Auto"> |
||||
<StackPanel Margin="8, 4"> |
||||
<StackPanel |
||||
Orientation="Horizontal" |
||||
Margin="0,4,0,8"> |
||||
<TextBlock |
||||
Text="{Binding Name}" |
||||
FontWeight="Bold" |
||||
FontSize="14"/> |
||||
</StackPanel> |
||||
<StackPanel |
||||
Orientation="Horizontal" |
||||
Margin="0, 4"> |
||||
<TextBlock |
||||
Text="{core:Localize AddInManager2.Details.CreatedBy}" |
||||
FontWeight="Bold"/> |
||||
<ItemsControl |
||||
Margin="4, 0" |
||||
ItemsSource="{Binding Path=Authors}"/> |
||||
</StackPanel> |
||||
<StackPanel |
||||
Orientation="Horizontal" |
||||
Visibility="{Binding Path=HasVersion, Converter={StaticResource BoolToVisibility}}" |
||||
Margin="0, 4"> |
||||
<TextBlock |
||||
Text="{core:Localize AddInManager2.Details.Version}" |
||||
FontWeight="Bold" |
||||
Margin="0, 0, 4, 0"/> |
||||
<TextBlock Text="{Binding Path=Version}"/> |
||||
</StackPanel> |
||||
<StackPanel |
||||
Orientation="Horizontal" |
||||
Visibility="{Binding Path=HasOldVersion, Converter={StaticResource BoolToVisibility}}" |
||||
Margin="0, 4"> |
||||
<TextBlock |
||||
Text="{core:Localize AddInManager2.Details.InstalledVersion}" |
||||
FontWeight="Bold" |
||||
Margin="0, 0, 4, 0"/> |
||||
<TextBlock Text="{Binding Path=OldVersion}"/> |
||||
</StackPanel> |
||||
<StackPanel |
||||
Orientation="Horizontal" |
||||
Visibility="{Binding Path=HasNewVersion, Converter={StaticResource BoolToVisibility}}" |
||||
Margin="0, 4"> |
||||
<TextBlock |
||||
Text="{core:Localize AddInManager2.Details.NewVersion}" |
||||
FontWeight="Bold" |
||||
Margin="0, 0, 4, 0"/> |
||||
<TextBlock Text="{Binding Path=Version}"/> |
||||
</StackPanel> |
||||
<StackPanel |
||||
Orientation="Horizontal" |
||||
Visibility="{Binding Path=HasLastUpdated, Converter={StaticResource BoolToVisibility}}" |
||||
Margin="0, 4"> |
||||
<TextBlock |
||||
Margin="0, 0, 4, 0" |
||||
Text="{core:Localize AddInManager2.Details.LastUpdated}" |
||||
FontWeight="Bold"/> |
||||
<TextBlock Text="{Binding Path=LastUpdated, StringFormat=d}"/> |
||||
</StackPanel> |
||||
<StackPanel |
||||
Orientation="Horizontal" |
||||
Visibility="{Binding Path=HasDownloadCount, Converter={StaticResource BoolToVisibility}}" |
||||
Margin="0, 4"> |
||||
<TextBlock |
||||
Margin="0, 0, 4, 0" |
||||
Text="{core:Localize AddInManager2.Details.DownloadCount}" |
||||
FontWeight="Bold"/> |
||||
<TextBlock Text="{Binding Path=DownloadCount}"/> |
||||
</StackPanel> |
||||
<StackPanel |
||||
Visibility="Collapsed" |
||||
Orientation="Horizontal" |
||||
Margin="0, 4"> |
||||
<TextBlock |
||||
Margin="0, 0, 4, 0" |
||||
Text="{core:Localize AddInManager2.Details.Rating}" |
||||
FontWeight="Bold"/> |
||||
<TextBlock Text="{Binding Path=Rating}"/> |
||||
</StackPanel> |
||||
<TextBlock |
||||
Visibility="{Binding Path=HasLicenseUrl, Converter={StaticResource BoolToVisibility}}"> |
||||
<Hyperlink |
||||
Command="{StaticResource OpenHyperlinkCommand}" |
||||
CommandParameter="{Binding Path=LicenseUrl}"> |
||||
<TextBlock Text="{core:Localize AddInManager2.Details.ViewLicenseTerms}"/> |
||||
</Hyperlink> |
||||
</TextBlock> |
||||
<TextBlock |
||||
Visibility="{Binding Path=HasProjectUrl, Converter={StaticResource BoolToVisibility}}"> |
||||
<Hyperlink |
||||
Command="{StaticResource OpenHyperlinkCommand}" |
||||
CommandParameter="{Binding Path=ProjectUrl}"> |
||||
<TextBlock Text="{core:Localize AddInManager2.Details.MoreInformation}"/> |
||||
</Hyperlink> |
||||
</TextBlock> |
||||
<TextBlock |
||||
Visibility="{Binding Path=HasReportAbuseUrl, Converter={StaticResource BoolToVisibility}}"> |
||||
<Hyperlink |
||||
Command="{StaticResource OpenHyperlinkCommand}" |
||||
CommandParameter="{Binding Path=ReportAbuseUrl}"> |
||||
<TextBlock Text="{core:Localize AddInManager2.Details.ReportAbuse}"/> |
||||
</Hyperlink> |
||||
</TextBlock> |
||||
<TextBlock |
||||
Margin="0, 4" |
||||
TextWrapping="Wrap" |
||||
Text="{Binding Path=Description}"/> |
||||
<StackPanel Margin="0, 4"> |
||||
<StackPanel Orientation="Horizontal"> |
||||
<TextBlock |
||||
Text="{core:Localize AddInManager2.Details.Dependencies}" |
||||
Margin="0, 0, 4, 0" |
||||
FontWeight="Bold"/> |
||||
<TextBlock |
||||
Text="None" |
||||
Visibility="{Binding Path=HasNoDependencies, Converter={StaticResource BoolToVisibility}}"/> |
||||
</StackPanel> |
||||
<ItemsControl |
||||
Margin="4, 4" |
||||
ItemsSource="{Binding Path=Dependencies}"/> |
||||
</StackPanel> |
||||
<Grid Margin="0,20,0,0"> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="Auto" /> |
||||
<ColumnDefinition Width="*" /> |
||||
</Grid.ColumnDefinitions> |
||||
<Button |
||||
x:Name="optionsButton" |
||||
Grid.Column="0" |
||||
Content="{core:Localize AddInManager.Options}" |
||||
Command="{Binding Path=OptionsCommand}" |
||||
Style="{StaticResource addInDetailsButtonStyle}"/> |
||||
</Grid> |
||||
</StackPanel> |
||||
</ScrollViewer> |
||||
|
||||
<DataTemplate.Triggers> |
||||
<DataTrigger |
||||
Binding="{Binding}" |
||||
Value="{x:Null}"> |
||||
<Setter |
||||
Property="StackPanel.Visibility" |
||||
Value="Hidden"/> |
||||
</DataTrigger> |
||||
</DataTemplate.Triggers> |
||||
</DataTemplate> |
||||
</UserControl.Resources> |
||||
|
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition MinWidth="100"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition MinWidth="100"/> |
||||
</Grid.ColumnDefinitions> |
||||
|
||||
|
||||
<Grid Grid.Column="0"> |
||||
<Grid> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition/> |
||||
<RowDefinition Height="Auto"/> |
||||
</Grid.RowDefinitions> |
||||
|
||||
<Grid |
||||
Visibility="{Binding Path=IsSearchable, Converter={StaticResource BoolToVisibility}}" |
||||
Grid.Row="0"> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition /> |
||||
<ColumnDefinition Width="Auto"/> |
||||
</Grid.ColumnDefinitions> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition Height="Auto"/> |
||||
</Grid.RowDefinitions> |
||||
<ComboBox |
||||
Grid.Row="0" |
||||
Grid.ColumnSpan="2" |
||||
Margin="0, 0, 0, 2" |
||||
SelectedItem="{Binding Path=SelectedPackageSource}" |
||||
ItemsSource="{Binding Path=PackageSources}" |
||||
ItemTemplate="{StaticResource PackageSourceComboBoxItemTemplate}" |
||||
Visibility="{Binding Path=ShowPackageSources, Converter={StaticResource BoolToVisibility}}"/> |
||||
<TextBox |
||||
Grid.Row="1" |
||||
Grid.Column="0" |
||||
Text="{Binding Path=SearchTerms, UpdateSourceTrigger=PropertyChanged}"> |
||||
<TextBox.InputBindings> |
||||
<KeyBinding |
||||
Key="Enter" |
||||
Command="{Binding Path=SearchCommand}"/> |
||||
</TextBox.InputBindings> |
||||
</TextBox> |
||||
<TextBlock |
||||
Grid.Row="1" |
||||
Grid.Column="1" |
||||
Margin="4"> |
||||
<Hyperlink |
||||
TextDecorations="{x:Null}" |
||||
Command="{Binding Path=SearchCommand}"> |
||||
<Image |
||||
Source="{StaticResource SearchIcon}" |
||||
Height="16" |
||||
Width="16"/> |
||||
</Hyperlink> |
||||
</TextBlock> |
||||
</Grid> |
||||
|
||||
<Grid Grid.Row="1"> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition /> |
||||
<RowDefinition Height="Auto"/> |
||||
</Grid.RowDefinitions> |
||||
<ListBox |
||||
x:Name="allPackagesListBox" |
||||
Grid.Row="0" |
||||
SelectedIndex="0" |
||||
ItemTemplate="{StaticResource PackageListBoxItemTemplate}" |
||||
ItemsSource="{Binding Path=AddInPackages}" |
||||
HorizontalContentAlignment="Stretch" |
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"/> |
||||
<ProgressBar |
||||
Grid.Row="0" |
||||
Height="20" |
||||
Width="100" |
||||
IsIndeterminate="True" |
||||
Visibility="{Binding Path=IsReadingPackages, Converter={StaticResource BoolToVisibility}}" |
||||
HorizontalAlignment="Center" |
||||
VerticalAlignment="Center"/> |
||||
<TextBlock |
||||
x:Name="ErrorMessageText" |
||||
Grid.Row="0" |
||||
Visibility="{Binding Path=HasError, Converter={StaticResource BoolToVisibility}}" |
||||
Text="{Binding Path=ErrorMessage}" |
||||
TextWrapping="Wrap"/> |
||||
<aimview:PagedResultsView |
||||
x:Name="pagedResultsView" |
||||
Grid.Row="1" |
||||
HorizontalAlignment="Center" |
||||
Visibility="{Binding Path=IsPaged, Converter={StaticResource BoolToVisibility}}" |
||||
DataContext="{Binding}"/> |
||||
</Grid> |
||||
|
||||
<Grid Grid.Row="2"> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="*" /> |
||||
<ColumnDefinition Width="Auto" /> |
||||
</Grid.ColumnDefinitions> |
||||
|
||||
<StackPanel Grid.Column="0" Orientation="Vertical"> |
||||
<Grid |
||||
Visibility="{Binding Path=HasFilterForPreinstalled, Converter={StaticResource BoolToVisibility}}"> |
||||
<CheckBox |
||||
x:Name="preinstalledAddInsCheckBox" |
||||
Margin="4" |
||||
Content="{core:Localize AddInManager2.AddInsView.ShowPreinstalledAddIns}" |
||||
IsChecked="{Binding Path=ShowPreinstalledAddIns, UpdateSourceTrigger=PropertyChanged}" |
||||
Command="{Binding Path=UpdatePreinstalledFilterCommand}" /> |
||||
</Grid> |
||||
|
||||
<Grid |
||||
Visibility="{Binding Path=HasFilterForPrereleases, Converter={StaticResource BoolToVisibility}}"> |
||||
<CheckBox |
||||
x:Name="prereleaseAddInsCheckBox" |
||||
Margin="4" |
||||
Content="{core:Localize AddInManager2.AddInsView.ShowPrereleaseAddIns}" |
||||
IsChecked="{Binding Path=ShowPrereleaseAddins, UpdateSourceTrigger=PropertyChanged}" |
||||
Command="{Binding Path=UpdatePrereleaseFilterCommand}" /> |
||||
</Grid> |
||||
</StackPanel> |
||||
|
||||
<Grid Grid.Column="1"> |
||||
<Button |
||||
x:Name="installFromFileButton" |
||||
Visibility="{Binding Path=AllowInstallFromArchive, Converter={StaticResource BoolToVisibility}}" |
||||
Content="{core:Localize AddInManager2.AddInsView.InstallFromArchive}" |
||||
Command="{Binding Path=InstallFromArchiveCommand}" |
||||
Style="{StaticResource addInDetailsButtonStyle}" |
||||
Margin="4,4,4,4" /> |
||||
</Grid> |
||||
</Grid> |
||||
</Grid> |
||||
</Grid> |
||||
<GridSplitter |
||||
Grid.Column="1" |
||||
Width="5" |
||||
HorizontalAlignment="Stretch" |
||||
VerticalAlignment="Stretch"/> |
||||
<Grid |
||||
Grid.Column="2"> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition /> |
||||
</Grid.RowDefinitions> |
||||
<ContentControl |
||||
Grid.Row="1" |
||||
ContentTemplate="{StaticResource PackageTemplate}" |
||||
Content="{Binding ElementName=allPackagesListBox, Path=SelectedItem}"/> |
||||
</Grid> |
||||
</Grid> |
||||
</UserControl> |
||||
@ -0,0 +1,16 @@
@@ -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.Controls; |
||||
|
||||
namespace ICSharpCode.AddInManager2.View |
||||
{ |
||||
public partial class AddInsView : UserControl |
||||
{ |
||||
public AddInsView() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,124 @@
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Window |
||||
x:Class="ICSharpCode.AddInManager2.View.LicenseAcceptanceView" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:core="clr-namespace:ICSharpCode.Core.Presentation;assembly=ICSharpCode.Core.Presentation" |
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
xmlns:aimvm="clr-namespace:ICSharpCode.AddInManager2.ViewModel" |
||||
mc:Ignorable="d" |
||||
WindowStartupLocation="CenterOwner" |
||||
Style="{x:Static core:GlobalStyles.DialogWindowStyle}" |
||||
Title="{core:Localize AddInManager2.LicenseAcceptance.Title}" |
||||
Height="300" |
||||
Width="480" |
||||
MinHeight="300" |
||||
MinWidth="300"> |
||||
<Window.Resources> |
||||
<Style |
||||
TargetType="Button" |
||||
BasedOn="{x:Static core:GlobalStyles.ButtonStyle}" /> |
||||
<BooleanToVisibilityConverter |
||||
x:Key="BoolToVisibility" /> |
||||
<aimvm:OpenHyperlinkCommand |
||||
x:Key="OpenHyperlinkCommand" /> |
||||
<DataTemplate |
||||
x:Key="ListBoxItemTemplate"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition |
||||
Width="Auto" /> |
||||
<ColumnDefinition /> |
||||
</Grid.ColumnDefinitions> |
||||
<StackPanel |
||||
Margin="4"> |
||||
<TextBlock |
||||
FontWeight="Bold" |
||||
Text="{Binding Id}" /> |
||||
<TextBlock> |
||||
<Hyperlink |
||||
Command="{StaticResource OpenHyperlinkCommand}" |
||||
CommandParameter="{Binding Path=LicenseUrl}"> |
||||
<TextBlock |
||||
Text="{core:Localize AddInManager2.Details.ViewLicenseTerms}" /> |
||||
</Hyperlink> |
||||
</TextBlock> |
||||
</StackPanel> |
||||
<TextBlock |
||||
Grid.Column="1" |
||||
Margin="4" |
||||
TextTrimming="CharacterEllipsis" |
||||
TextWrapping="Wrap" |
||||
MaxHeight="40" |
||||
Text="{Binding Summary}" /> |
||||
</Grid> |
||||
</DataTemplate> |
||||
</Window.Resources> |
||||
<Grid> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition |
||||
Height="Auto" /> |
||||
<RowDefinition /> |
||||
<RowDefinition |
||||
Height="Auto" /> |
||||
<RowDefinition |
||||
Height="Auto" /> |
||||
</Grid.RowDefinitions> |
||||
<StackPanel |
||||
Margin="4, 2"> |
||||
<TextBlock |
||||
Visibility="{Binding Path=HasMultiplePackages, Converter={StaticResource BoolToVisibility}}" |
||||
TextWrapping="Wrap" |
||||
Text="{core:Localize AddInManager2.LicenseAcceptance.Introduction.Packages}" /> |
||||
<TextBlock |
||||
Visibility="{Binding Path=HasOnePackage, Converter={StaticResource BoolToVisibility}}" |
||||
TextWrapping="Wrap" |
||||
Text="{core:Localize AddInManager2.LicenseAcceptance.Introduction.Package}" /> |
||||
</StackPanel> |
||||
<Border |
||||
Grid.Row="1" |
||||
BorderThickness="1" |
||||
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"> |
||||
<ScrollViewer |
||||
VerticalScrollBarVisibility="Auto" |
||||
HorizontalScrollBarVisibility="Disabled"> |
||||
<ItemsControl |
||||
Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" |
||||
ItemTemplate="{StaticResource ListBoxItemTemplate}" |
||||
ItemsSource="{Binding Path=Packages}" /> |
||||
</ScrollViewer> |
||||
</Border> |
||||
<StackPanel |
||||
Grid.Row="2" |
||||
Margin="4"> |
||||
<TextBlock |
||||
Visibility="{Binding Path=HasMultiplePackages, Converter={StaticResource BoolToVisibility}}" |
||||
TextWrapping="Wrap"> |
||||
<TextBlock.Text> |
||||
<core:LocalizeExtension Key="AddInManager2.LicenseAcceptance.Explanation.Packages" /> |
||||
</TextBlock.Text> |
||||
</TextBlock> |
||||
<TextBlock |
||||
Visibility="{Binding Path=HasOnePackage, Converter={StaticResource BoolToVisibility}}" |
||||
TextWrapping="Wrap"> |
||||
<TextBlock.Text> |
||||
<core:LocalizeExtension Key="AddInManager2.LicenseAcceptance.Explanation.Package" /> |
||||
</TextBlock.Text> |
||||
</TextBlock> |
||||
</StackPanel> |
||||
<StackPanel |
||||
Grid.Row="3" |
||||
Margin="4" |
||||
Orientation="Horizontal" |
||||
HorizontalAlignment="Right"> |
||||
<Button |
||||
Content="{core:Localize Key=AddInManager2.LicenseAcceptance.DeclineButton, UsesAccessors=True}" |
||||
IsCancel="True" |
||||
Margin="0,0,4,0"/> |
||||
<Button |
||||
Content="{core:Localize Key=AddInManager2.LicenseAcceptance.AcceptButton, UsesAccessors=True}" |
||||
Click="AcceptButtonClick"/> |
||||
</StackPanel> |
||||
</Grid> |
||||
</Window> |
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// 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.AddInManager2.View |
||||
{ |
||||
public partial class LicenseAcceptanceView : Window |
||||
{ |
||||
public LicenseAcceptanceView() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
void AcceptButtonClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
DialogResult = true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,145 @@
@@ -0,0 +1,145 @@
|
||||
<gui:OptionPanel |
||||
x:Class="ICSharpCode.AddInManager2.View.PackageRepositoriesView" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
xmlns:core="clr-namespace:ICSharpCode.Core.Presentation;assembly=ICSharpCode.Core.Presentation" |
||||
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" |
||||
xmlns:aimvm="clr-namespace:ICSharpCode.AddInManager2.ViewModel" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
mc:Ignorable="d"> |
||||
|
||||
<Grid x:Name="MainGrid"> |
||||
<Grid.Resources> |
||||
<aimvm:PackageRepositoriesViewModel x:Key="ViewModel"/> |
||||
</Grid.Resources> |
||||
|
||||
<Grid.DataContext> |
||||
<Binding Source="{StaticResource ViewModel}" /> |
||||
</Grid.DataContext> |
||||
<Grid> |
||||
<Grid.Resources> |
||||
<Style |
||||
x:Key="ListBoxItemStyle" |
||||
TargetType="{x:Type ListBoxItem}"> |
||||
|
||||
<Style.Resources> |
||||
<SolidColorBrush |
||||
x:Key="{x:Static SystemColors.ControlBrushKey}" |
||||
Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" /> |
||||
</Style.Resources> |
||||
|
||||
<Setter |
||||
Property="Background" |
||||
Value="LightGray"/> |
||||
|
||||
<Style.Triggers> |
||||
<Trigger |
||||
Property="ItemsControl.AlternationIndex" |
||||
Value="0"> |
||||
<Setter |
||||
Property="Background" |
||||
Value="White"/> |
||||
</Trigger> |
||||
</Style.Triggers> |
||||
</Style> |
||||
|
||||
<DataTemplate x:Key="PackageSourceListBoxTemplate"> |
||||
<StackPanel |
||||
x:Name="PackageSourceStackPanel" |
||||
Margin="4"> |
||||
<TextBlock Text="{Binding Path=Name}"/> |
||||
<TextBlock> |
||||
<Hyperlink> |
||||
<TextBlock Text="{Binding Path=SourceUrl}"/> |
||||
</Hyperlink> |
||||
</TextBlock> |
||||
</StackPanel> |
||||
</DataTemplate> |
||||
</Grid.Resources> |
||||
|
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition /> |
||||
<ColumnDefinition Width="Auto"/> |
||||
</Grid.ColumnDefinitions> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition /> |
||||
<RowDefinition Height="Auto"/> |
||||
</Grid.RowDefinitions> |
||||
<ListBox |
||||
Grid.Row="0" |
||||
HorizontalContentAlignment="Stretch" |
||||
AlternationCount="2" |
||||
ItemContainerStyle="{StaticResource ListBoxItemStyle}" |
||||
ItemTemplate="{StaticResource PackageSourceListBoxTemplate}" |
||||
ItemsSource="{Binding Path=PackageRepositories}" |
||||
SelectedItem="{Binding Path=SelectedPackageRepository}"/> |
||||
<Grid |
||||
Grid.Row="1" |
||||
Margin="4"> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition /> |
||||
</Grid.ColumnDefinitions> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition /> |
||||
<RowDefinition /> |
||||
</Grid.RowDefinitions> |
||||
<TextBlock |
||||
Grid.Row="0" |
||||
Grid.Column="0" |
||||
Margin="4" |
||||
Text="{core:Localize AddInManager2.OptionPanel.Name}"/> |
||||
<TextBox |
||||
Grid.Row="0" |
||||
Grid.Column="1" |
||||
Text="{Binding Path=NewPackageSourceName, UpdateSourceTrigger=PropertyChanged}" |
||||
Margin="4, 2"/> |
||||
<TextBlock |
||||
Grid.Row="1" |
||||
Grid.Column="0" |
||||
Margin="4" |
||||
Text="{core:Localize AddInManager2.OptionPanel.Source}"/> |
||||
<TextBox |
||||
Grid.Row="1" |
||||
Grid.Column="1" |
||||
Text="{Binding Path=NewPackageSourceUrl, UpdateSourceTrigger=PropertyChanged}" |
||||
Margin="4,2"/> |
||||
</Grid> |
||||
<StackPanel |
||||
Grid.Column="1" |
||||
Grid.Row="0"> |
||||
<Button |
||||
Content="{core:Localize AddInManager2.OptionPanel.MoveUp}" |
||||
Command="{Binding Path=MovePackageSourceUpCommand}" |
||||
Margin="4, 2" |
||||
Padding="7, 0"/> |
||||
<Button |
||||
Content="{core:Localize AddInManager2.OptionPanel.MoveDown}" |
||||
Command="{Binding Path=MovePackageSourceDownCommand}" |
||||
Margin="4, 2" |
||||
Padding="7, 0"/> |
||||
<Button |
||||
Content="{core:Localize AddInManager2.OptionPanel.Remove}" |
||||
Command="{Binding Path=RemovePackageSourceCommand}" |
||||
Margin="4, 2" |
||||
Padding="7, 0"/> |
||||
</StackPanel> |
||||
<StackPanel |
||||
Grid.Column="1" |
||||
Grid.Row="1"> |
||||
<Button |
||||
Content="{core:Localize AddInManager2.OptionPanel.Add}" |
||||
Command="{Binding Path=AddPackageSourceCommand}" |
||||
Margin="4, 6, 4, 4" |
||||
Padding="7, 0"/> |
||||
<Button |
||||
Content="..." |
||||
Command="{Binding Path=BrowsePackageFolderCommand}" |
||||
HorizontalAlignment="Left" |
||||
Margin="4, 4" |
||||
Padding="7, 0"/> |
||||
</StackPanel> |
||||
</Grid> |
||||
</Grid> |
||||
</gui:OptionPanel> |
||||
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// 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.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using ICSharpCode.AddInManager2.ViewModel; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.AddInManager2.View |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for PackageRepositoriesView.xaml
|
||||
/// </summary>
|
||||
public partial class PackageRepositoriesView : OptionPanel |
||||
{ |
||||
PackageRepositoriesViewModel viewModel; |
||||
|
||||
public PackageRepositoriesView() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
private PackageRepositoriesViewModel ViewModel |
||||
{ |
||||
get |
||||
{ |
||||
if (viewModel == null) |
||||
{ |
||||
viewModel = MainGrid.DataContext as PackageRepositoriesViewModel; |
||||
} |
||||
return viewModel; |
||||
} |
||||
} |
||||
|
||||
public override void LoadOptions() |
||||
{ |
||||
ViewModel.Load(); |
||||
} |
||||
|
||||
public override bool SaveOptions() |
||||
{ |
||||
ViewModel.Save(); |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
<UserControl |
||||
x:Class="ICSharpCode.AddInManager2.View.PagedResultsView" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
xmlns:aim="clr-namespace:ICSharpCode.AddInManager2" |
||||
mc:Ignorable="d"> |
||||
|
||||
<UserControl.Resources> |
||||
<BitmapImage x:Key="PreviousPageIcon" |
||||
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/resultset_previous.png"/> |
||||
<BitmapImage x:Key="NextPageIcon" |
||||
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/resultset_next.png"/> |
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/> |
||||
<aim:BooleanToFontWeightConverter x:Key="BoolToFontWeight"/> |
||||
|
||||
<DataTemplate x:Key="PagedListTemplate"> |
||||
<Button |
||||
Background="Transparent" |
||||
BorderBrush="Transparent" |
||||
Padding="4,0,4,0" |
||||
MinWidth="0" |
||||
Content="{Binding Path=Number}" |
||||
Command="{Binding Path=DataContext.ShowPageCommand, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}" |
||||
CommandParameter="{Binding Path=Number}" |
||||
FontWeight="{Binding Path=IsSelected, Converter={StaticResource BoolToFontWeight}}"/> |
||||
</DataTemplate> |
||||
</UserControl.Resources> |
||||
|
||||
<StackPanel Orientation="Horizontal"> |
||||
<Button |
||||
Visibility="{Binding Path=HasPreviousPage, Converter={StaticResource BoolToVisibility}}" |
||||
Command="{Binding Path=ShowPreviousPageCommand}" |
||||
Background="Transparent" |
||||
BorderBrush="Transparent" |
||||
MinWidth="0" |
||||
Padding="0,2" |
||||
VerticalAlignment="Top"> |
||||
<Image Source="{StaticResource PreviousPageIcon}" |
||||
Height="16" |
||||
Width="16"/> |
||||
</Button> |
||||
<ListBox |
||||
VerticalAlignment="Top" |
||||
HorizontalAlignment="Center" |
||||
BorderBrush="Transparent" |
||||
ItemTemplate="{StaticResource PagedListTemplate}" |
||||
ItemsSource="{Binding Path=Pages}"> |
||||
<ListBox.ItemsPanel> |
||||
<ItemsPanelTemplate> |
||||
<StackPanel Orientation="Horizontal"/> |
||||
</ItemsPanelTemplate> |
||||
</ListBox.ItemsPanel> |
||||
</ListBox> |
||||
<Button |
||||
Visibility="{Binding Path=HasNextPage, Converter={StaticResource BoolToVisibility}}" |
||||
Command="{Binding Path=ShowNextPageCommand}" |
||||
Background="Transparent" |
||||
BorderBrush="Transparent" |
||||
MinWidth="0" |
||||
Padding="0,2" |
||||
VerticalAlignment="Top"> |
||||
<Image |
||||
Source="{StaticResource NextPageIcon}" |
||||
Height="16" |
||||
Width="16"/> |
||||
</Button> |
||||
</StackPanel> |
||||
</UserControl> |
||||
@ -0,0 +1,16 @@
@@ -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.Controls; |
||||
|
||||
namespace ICSharpCode.AddInManager2.View |
||||
{ |
||||
public partial class PagedResultsView : UserControl |
||||
{ |
||||
public PagedResultsView() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,144 @@
@@ -0,0 +1,144 @@
|
||||
// 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.Collections.ObjectModel; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using ICSharpCode.AddInManager2.View; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class AddInManagerViewModel : Model<AddInManagerViewModel>, IDisposable |
||||
{ |
||||
private string _message; |
||||
private bool _hasError; |
||||
|
||||
public AddInManagerViewModel() |
||||
{ |
||||
// Visuals
|
||||
this.Title = ResourceService.GetString("AddInManager.Title"); |
||||
|
||||
// Add event handlers
|
||||
AddInManager.Events.OperationStarted += AddInManager_Events_OperationStarted; |
||||
AddInManager.Events.AddInOperationError += AddInManager_Events_NuGetPackageOperationError; |
||||
AddInManager.Events.AcceptLicenses += AddInManager_Events_AcceptLicenses; |
||||
|
||||
AvailableAddInsViewModel = new AvailableAddInsViewModel(); |
||||
InstalledAddInsViewModel = new InstalledAddInsViewModel(); |
||||
UpdatedAddInsViewModel = new UpdatedAddInsViewModel(); |
||||
|
||||
// Read the packages
|
||||
AvailableAddInsViewModel.ReadPackages(); |
||||
InstalledAddInsViewModel.ReadPackages(); |
||||
UpdatedAddInsViewModel.ReadPackages(); |
||||
} |
||||
|
||||
public AvailableAddInsViewModel AvailableAddInsViewModel |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public InstalledAddInsViewModel InstalledAddInsViewModel |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public UpdatedAddInsViewModel UpdatedAddInsViewModel |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public string Title |
||||
{ |
||||
// get { return viewTitle.Title; }
|
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
AddInManager.Events.AddInOperationError -= AddInManager_Events_NuGetPackageOperationError; |
||||
AddInManager.Events.AcceptLicenses -= AddInManager_Events_AcceptLicenses; |
||||
} |
||||
|
||||
private void ShowErrorMessage(string message) |
||||
{ |
||||
this.Message = message; |
||||
this.HasError = true; |
||||
} |
||||
|
||||
public string Message |
||||
{ |
||||
get |
||||
{ |
||||
return _message; |
||||
} |
||||
set |
||||
{ |
||||
_message = value; |
||||
OnPropertyChanged(model => model.Message); |
||||
} |
||||
} |
||||
|
||||
public bool HasError |
||||
{ |
||||
get |
||||
{ |
||||
return _hasError; |
||||
} |
||||
set |
||||
{ |
||||
_hasError = value; |
||||
OnPropertyChanged(model => model.HasError); |
||||
} |
||||
} |
||||
|
||||
private void AddInManager_Events_OperationStarted(object sender, EventArgs e) |
||||
{ |
||||
ClearMessage(); |
||||
} |
||||
|
||||
private void ClearMessage() |
||||
{ |
||||
this.Message = null; |
||||
this.HasError = false; |
||||
} |
||||
|
||||
private void AddInManager_Events_NuGetPackageOperationError(object sender, AddInExceptionEventArgs e) |
||||
{ |
||||
ShowErrorMessage(e.Exception.Message); |
||||
} |
||||
|
||||
private void AddInManager_Events_AcceptLicenses(object sender, AcceptLicensesEventArgs e) |
||||
{ |
||||
// Show a license acceptance prompt to the user
|
||||
e.IsAccepted = ShowLicenseAcceptancePrompt(e.Packages); |
||||
} |
||||
|
||||
private bool ShowLicenseAcceptancePrompt(IEnumerable<IPackage> packages) |
||||
{ |
||||
if (packages == null) |
||||
{ |
||||
// No package -> nothing to accept
|
||||
return true; |
||||
} |
||||
|
||||
// Create a license acceptance view
|
||||
var viewModel = new LicenseAcceptanceViewModel(packages); |
||||
var view = new LicenseAcceptanceView(); |
||||
view.DataContext = viewModel; |
||||
view.Owner = SD.Workbench.MainWindow; |
||||
return view.ShowDialog() ?? false; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,415 @@
@@ -0,0 +1,415 @@
|
||||
// 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.Linq; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public abstract class AddInPackageViewModelBase : Model<AddInPackageViewModelBase>, IAddInPackage |
||||
{ |
||||
private DelegateCommand addPackageCommand; |
||||
private DelegateCommand updatePackageCommand; |
||||
private DelegateCommand removePackageCommand; |
||||
private DelegateCommand disablePackageCommand; |
||||
private DelegateCommand cancelInstallationCommand; |
||||
private DelegateCommand cancelUpdateCommand; |
||||
private DelegateCommand cancelUninstallationCommand; |
||||
private DelegateCommand optionsCommand; |
||||
|
||||
public AddInPackageViewModelBase() |
||||
{ |
||||
CreateCommands(); |
||||
} |
||||
|
||||
private void CreateCommands() |
||||
{ |
||||
addPackageCommand = new DelegateCommand( |
||||
param => AddPackage(), |
||||
param => !IsAdded && !IsRemoved && !IsInstalled && IsInstallable |
||||
); |
||||
updatePackageCommand = new DelegateCommand( |
||||
param => UpdatePackage(), |
||||
param => !IsAdded && !IsRemoved && IsUpdate && IsInstallable |
||||
); |
||||
removePackageCommand = new DelegateCommand( |
||||
param => RemovePackage(), |
||||
param => !IsAdded && !IsRemoved && IsInstalled && !IsUpdate && IsUninstallable |
||||
); |
||||
disablePackageCommand = new DelegateCommand( |
||||
param => DisablePackage(), |
||||
param => !IsAdded && !IsRemoved && IsInstalled && IsOffline |
||||
); |
||||
cancelInstallationCommand = new DelegateCommand( |
||||
param => CancelInstallation(), |
||||
param => IsAdded && !IsUpdate |
||||
); |
||||
cancelUpdateCommand = new DelegateCommand( |
||||
param => CancelUpdate(), |
||||
param => IsAdded && IsUpdate |
||||
); |
||||
cancelUninstallationCommand = new DelegateCommand( |
||||
param => CancelUninstallation(), |
||||
param => IsRemoved |
||||
); |
||||
optionsCommand = new DelegateCommand( |
||||
param => ShowOptions(), |
||||
param => HasOptions |
||||
); |
||||
} |
||||
|
||||
public ICommand AddPackageCommand |
||||
{ |
||||
get |
||||
{ |
||||
return addPackageCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand UpdatePackageCommand |
||||
{ |
||||
get |
||||
{ |
||||
return updatePackageCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand RemovePackageCommand |
||||
{ |
||||
get |
||||
{ |
||||
return removePackageCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand DisablePackageCommand |
||||
{ |
||||
get |
||||
{ |
||||
return disablePackageCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand CancelInstallationCommand |
||||
{ |
||||
get |
||||
{ |
||||
return cancelInstallationCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand CancelUpdateCommand |
||||
{ |
||||
get |
||||
{ |
||||
return cancelUpdateCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand CancelUninstallationCommand |
||||
{ |
||||
get |
||||
{ |
||||
return cancelUninstallationCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand OptionsCommand |
||||
{ |
||||
get |
||||
{ |
||||
return optionsCommand; |
||||
} |
||||
} |
||||
|
||||
public abstract string Name |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public bool HasLicenseUrl |
||||
{ |
||||
get |
||||
{ |
||||
return LicenseUrl != null; |
||||
} |
||||
} |
||||
|
||||
public bool HasProjectUrl |
||||
{ |
||||
get |
||||
{ |
||||
return ProjectUrl != null; |
||||
} |
||||
} |
||||
|
||||
public bool HasReportAbuseUrl |
||||
{ |
||||
get |
||||
{ |
||||
return ReportAbuseUrl != null; |
||||
} |
||||
} |
||||
|
||||
public bool HasNoDependencies |
||||
{ |
||||
get |
||||
{ |
||||
return !HasDependencies; |
||||
} |
||||
} |
||||
|
||||
public bool HasLastUpdated |
||||
{ |
||||
get |
||||
{ |
||||
return LastUpdated.HasValue; |
||||
} |
||||
} |
||||
|
||||
public abstract bool HasDependencyConflicts |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public bool HasVersion |
||||
{ |
||||
get |
||||
{ |
||||
return !ShowSplittedVersions && (Version != null) && (Version.ToString() != "0.0.0.0"); |
||||
} |
||||
} |
||||
|
||||
public bool HasOldVersion |
||||
{ |
||||
get |
||||
{ |
||||
return ShowSplittedVersions && (OldVersion != null) && (OldVersion.ToString() != "0.0.0.0"); |
||||
} |
||||
} |
||||
|
||||
public bool HasNewVersion |
||||
{ |
||||
get |
||||
{ |
||||
return ShowSplittedVersions && (Version != null) && (Version.ToString() != "0.0.0.0"); |
||||
} |
||||
} |
||||
|
||||
public virtual bool ShowSplittedVersions |
||||
{ |
||||
get |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public abstract bool IsOffline |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract bool IsPreinstalled |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract bool IsEnabled |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract bool IsRemoved |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public virtual bool HasNuGetConnection |
||||
{ |
||||
get |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public virtual void AddPackage() |
||||
{ |
||||
} |
||||
|
||||
public virtual void UpdatePackage() |
||||
{ |
||||
} |
||||
|
||||
public virtual void RemovePackage() |
||||
{ |
||||
} |
||||
|
||||
public virtual void DisablePackage() |
||||
{ |
||||
} |
||||
|
||||
public virtual void CancelInstallation() |
||||
{ |
||||
} |
||||
|
||||
public virtual void CancelUpdate() |
||||
{ |
||||
} |
||||
|
||||
public virtual void CancelUninstallation() |
||||
{ |
||||
} |
||||
|
||||
public virtual void ShowOptions() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public void UpdateInstallationState() |
||||
{ |
||||
OnPropertyChanged(m => m.IsAdded); |
||||
OnPropertyChanged(m => m.IsUpdate); |
||||
OnPropertyChanged(m => m.IsInstallable); |
||||
OnPropertyChanged(m => m.IsInstalled); |
||||
OnPropertyChanged(m => m.IsEnabled); |
||||
OnPropertyChanged(m => m.IsRemoved); |
||||
OnPropertyChanged(m => m.Summary); |
||||
} |
||||
|
||||
public bool IsManaged |
||||
{ |
||||
get |
||||
{ |
||||
// if (selectedProjects.HasMultipleProjects()) {
|
||||
// return true;
|
||||
// }
|
||||
// return !selectedProjects.HasSingleProjectSelected();
|
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public abstract Uri LicenseUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract Uri ProjectUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract Uri ReportAbuseUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract bool IsAdded |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract bool IsUpdate |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract bool IsInstalled |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract bool IsInstallable |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract bool IsUninstallable |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract IEnumerable<AddInDependency> Dependencies |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public virtual bool HasDependencies |
||||
{ |
||||
get |
||||
{ |
||||
return (Dependencies != null) && Dependencies.Any(); |
||||
} |
||||
} |
||||
|
||||
public abstract IEnumerable<string> Authors |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract bool HasDownloadCount |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract string Id |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract Uri IconUrl |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract string Summary |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract Version Version |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public virtual Version OldVersion |
||||
{ |
||||
get |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
|
||||
public virtual bool HasOptions |
||||
{ |
||||
get |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public abstract int DownloadCount |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract string Description |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
public abstract DateTime? LastUpdated |
||||
{ |
||||
get; |
||||
} |
||||
|
||||
protected string SurroundWithParantheses(string content) |
||||
{ |
||||
return "(" + content + ")"; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,430 @@
@@ -0,0 +1,430 @@
|
||||
// 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.Collections.ObjectModel; |
||||
using System.Collections.Specialized; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public abstract class AddInsViewModelBase : Model<AddInsViewModelBase>, IDisposable |
||||
{ |
||||
private Pages _pages; |
||||
private int _highlightCount; |
||||
private string _title; |
||||
|
||||
public AddInsViewModelBase() |
||||
{ |
||||
_pages = new Pages(); |
||||
_highlightCount = 0; |
||||
AddInPackages = new ObservableCollection<AddInPackageViewModelBase>(); |
||||
ErrorMessage = String.Empty; |
||||
|
||||
CreateCommands(); |
||||
} |
||||
|
||||
void CreateCommands() |
||||
{ |
||||
ShowNextPageCommand = new DelegateCommand(param => ShowNextPage()); |
||||
ShowPreviousPageCommand = new DelegateCommand(param => ShowPreviousPage()); |
||||
ShowPageCommand = new DelegateCommand(param => ExecuteShowPageCommand(param)); |
||||
SearchCommand = new DelegateCommand(param => Search()); |
||||
UpdatePreinstalledFilterCommand = new DelegateCommand(param => UpdatePreinstalledFilter()); |
||||
UpdatePrereleaseFilterCommand = new DelegateCommand(param => UpdatePrereleaseFilter()); |
||||
InstallFromArchiveCommand = new DelegateCommand(param => InstallFromArchive()); |
||||
} |
||||
|
||||
public ICommand ShowNextPageCommand |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public ICommand ShowPreviousPageCommand |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public ICommand ShowPageCommand |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public ICommand SearchCommand |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public ICommand UpdatePreinstalledFilterCommand |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public ICommand UpdatePrereleaseFilterCommand |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public ICommand InstallFromArchiveCommand |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
OnDispose(); |
||||
IsDisposed = true; |
||||
} |
||||
|
||||
protected virtual void OnDispose() |
||||
{ |
||||
} |
||||
|
||||
public bool IsDisposed |
||||
{ |
||||
get; |
||||
protected set; |
||||
} |
||||
|
||||
public bool HasError |
||||
{ |
||||
get; |
||||
protected set; |
||||
} |
||||
|
||||
public string ErrorMessage |
||||
{ |
||||
get; |
||||
protected set; |
||||
} |
||||
|
||||
public int HighlightCount |
||||
{ |
||||
get |
||||
{ |
||||
return _highlightCount; |
||||
} |
||||
protected set |
||||
{ |
||||
_highlightCount = value; |
||||
OnPropertyChanged(vm => vm.HighlightCount); |
||||
OnPropertyChanged(vm => vm.HasHighlightCount); |
||||
OnPropertyChanged(vm => vm.TitleWithHighlight); |
||||
} |
||||
} |
||||
|
||||
public bool HasHighlightCount |
||||
{ |
||||
get |
||||
{ |
||||
return (_highlightCount > 0); |
||||
} |
||||
} |
||||
|
||||
public string Title |
||||
{ |
||||
get |
||||
{ |
||||
return _title; |
||||
} |
||||
set |
||||
{ |
||||
_title = value; |
||||
OnPropertyChanged(vm => vm.HighlightCount); |
||||
OnPropertyChanged(vm => vm.HasHighlightCount); |
||||
OnPropertyChanged(vm => vm.TitleWithHighlight); |
||||
} |
||||
} |
||||
|
||||
public string TitleWithHighlight |
||||
{ |
||||
get |
||||
{ |
||||
if (_highlightCount > 0) |
||||
{ |
||||
return String.Format("{0} ({1})", Title, _highlightCount); |
||||
} |
||||
else |
||||
{ |
||||
return Title; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public ObservableCollection<AddInPackageViewModelBase> AddInPackages |
||||
{ |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public ObservableCollection<Page> Pages |
||||
{ |
||||
get |
||||
{ |
||||
return _pages; |
||||
} |
||||
} |
||||
|
||||
protected Pages PagesCollection |
||||
{ |
||||
get |
||||
{ |
||||
return _pages; |
||||
} |
||||
} |
||||
|
||||
public bool IsReadingPackages |
||||
{ |
||||
get; |
||||
protected set; |
||||
} |
||||
|
||||
public virtual void ReadPackages() |
||||
{ |
||||
_pages.SelectedPageNumber = 1; |
||||
} |
||||
|
||||
protected void SaveError(AggregateException ex) |
||||
{ |
||||
HasError = true; |
||||
ErrorMessage = GetErrorMessage(ex); |
||||
ICSharpCode.Core.LoggingService.Debug(ex); |
||||
} |
||||
|
||||
protected string GetErrorMessage(AggregateException ex) |
||||
{ |
||||
StringBuilder errorMessage = new StringBuilder(); |
||||
BuildErrorMessage(ex.InnerExceptions, errorMessage); |
||||
return errorMessage.ToString().TrimEnd(); |
||||
} |
||||
|
||||
private void BuildErrorMessage(IEnumerable<Exception> exceptions, StringBuilder errorMessage) |
||||
{ |
||||
foreach (Exception ex in exceptions) |
||||
{ |
||||
var aggregateEx = ex as AggregateException; |
||||
if (aggregateEx != null) |
||||
{ |
||||
BuildErrorMessage(aggregateEx.InnerExceptions, errorMessage); |
||||
} |
||||
else |
||||
{ |
||||
errorMessage.AppendLine(ex.Message); |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected void UpdatePackageViewModels(IEnumerable<AddInPackageViewModelBase> newPackageViewModels) |
||||
{ |
||||
ClearPackages(); |
||||
AddInPackages.AddRange(newPackageViewModels); |
||||
UpdateInstallationState(); |
||||
} |
||||
|
||||
protected void ClearPackages() |
||||
{ |
||||
AddInPackages.Clear(); |
||||
} |
||||
|
||||
public virtual int SelectedPageNumber |
||||
{ |
||||
get |
||||
{ |
||||
return _pages.SelectedPageNumber; |
||||
} |
||||
set |
||||
{ |
||||
if (_pages.SelectedPageNumber != value) |
||||
{ |
||||
_pages.SelectedPageNumber = value; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public int PageSize |
||||
{ |
||||
get |
||||
{ |
||||
return _pages.PageSize; |
||||
} |
||||
set |
||||
{ |
||||
_pages.PageSize = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsPaged |
||||
{ |
||||
get |
||||
{ |
||||
return _pages.IsPaged; |
||||
} |
||||
} |
||||
|
||||
public bool HasPreviousPage |
||||
{ |
||||
get |
||||
{ |
||||
return _pages.HasPreviousPage; |
||||
} |
||||
} |
||||
|
||||
public bool HasNextPage |
||||
{ |
||||
get |
||||
{ |
||||
return _pages.HasNextPage; |
||||
} |
||||
} |
||||
|
||||
public int MaximumSelectablePages |
||||
{ |
||||
get |
||||
{ |
||||
return _pages.MaximumSelectablePages; |
||||
} |
||||
set |
||||
{ |
||||
_pages.MaximumSelectablePages = value; |
||||
} |
||||
} |
||||
|
||||
public int TotalItems |
||||
{ |
||||
get; |
||||
protected set; |
||||
} |
||||
|
||||
public void ShowNextPage() |
||||
{ |
||||
SelectedPageNumber += 1; |
||||
} |
||||
|
||||
public void ShowPreviousPage() |
||||
{ |
||||
SelectedPageNumber -= 1; |
||||
} |
||||
|
||||
private void ExecuteShowPageCommand(object param) |
||||
{ |
||||
int pageNumber = (int)param; |
||||
ShowPage(pageNumber); |
||||
} |
||||
|
||||
public void ShowPage(int pageNumber) |
||||
{ |
||||
SelectedPageNumber = pageNumber; |
||||
} |
||||
|
||||
public bool IsSearchable |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public bool HasFilterForPreinstalled |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public bool HasFilterForPrereleases |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public bool AllowInstallFromArchive |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public string SearchTerms |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public void Search() |
||||
{ |
||||
ReadPackages(); |
||||
OnPropertyChanged(null); |
||||
} |
||||
|
||||
protected virtual void UpdatePreinstalledFilter() |
||||
{ |
||||
} |
||||
|
||||
protected virtual void UpdatePrereleaseFilter() |
||||
{ |
||||
} |
||||
|
||||
protected virtual void InstallFromArchive() |
||||
{ |
||||
} |
||||
|
||||
public bool ShowPackageSources |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public IEnumerable<PackageSource> PackageSources |
||||
{ |
||||
get |
||||
{ |
||||
foreach (PackageSource packageSource in AddInManager.Repositories.RegisteredPackageSources) |
||||
{ |
||||
yield return packageSource; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public PackageSource SelectedPackageSource |
||||
{ |
||||
get |
||||
{ |
||||
return AddInManager.Repositories.ActiveSource; |
||||
} |
||||
set |
||||
{ |
||||
AddInManager.Repositories.ActiveSource = value; |
||||
ReadPackages(); |
||||
} |
||||
} |
||||
|
||||
public bool ShowPreinstalledAddIns |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public bool ShowPrereleases |
||||
{ |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public void UpdateInstallationState() |
||||
{ |
||||
// Update installation-state-related properties of all AddIn items in here
|
||||
foreach (var packageViewModel in AddInPackages) |
||||
{ |
||||
packageViewModel.UpdateInstallationState(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
// 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.Collections.ObjectModel; |
||||
using System.Collections.Specialized; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using ICSharpCode.Core; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class AvailableAddInsViewModel : NuGetAddInsViewModelBase |
||||
{ |
||||
public AvailableAddInsViewModel() |
||||
: base() |
||||
{ |
||||
IsSearchable = true; |
||||
ShowPackageSources = true; |
||||
Title = ResourceService.GetString("AddInManager2.Views.Available"); |
||||
|
||||
AddInManager.Events.AddInInstalled += AddInInstallationStateChanged; |
||||
AddInManager.Events.AddInUninstalled += AddInInstallationStateChanged; |
||||
AddInManager.Events.AddInStateChanged += AddInInstallationStateChanged; |
||||
} |
||||
|
||||
protected override void OnDispose() |
||||
{ |
||||
AddInManager.Events.AddInInstalled -= AddInInstallationStateChanged; |
||||
AddInManager.Events.AddInUninstalled -= AddInInstallationStateChanged; |
||||
AddInManager.Events.AddInStateChanged += AddInInstallationStateChanged; |
||||
} |
||||
|
||||
protected override IQueryable<IPackage> GetAllPackages() |
||||
{ |
||||
return AddInManager.Repositories.Active.GetPackages(); |
||||
} |
||||
|
||||
protected override IEnumerable<IPackage> GetFilteredPackagesBeforePagingResults(IQueryable<IPackage> allPackages) |
||||
{ |
||||
return base.GetFilteredPackagesBeforePagingResults(allPackages) |
||||
.Where(package => AddInManager.NuGet.PackageContainsAddIn(package)) |
||||
.Where(package => package.IsReleaseVersion()) |
||||
.DistinctLast(PackageEqualityComparer.Id); |
||||
} |
||||
|
||||
protected override IQueryable<IPackage> OrderPackages(IQueryable<IPackage> packages) |
||||
{ |
||||
return packages.OrderByDescending(package => package.DownloadCount); |
||||
} |
||||
|
||||
protected override void UpdatePrereleaseFilter() |
||||
{ |
||||
ReadPackages(); |
||||
} |
||||
|
||||
private void AddInInstallationStateChanged(object sender, AddInInstallationEventArgs e) |
||||
{ |
||||
UpdateInstallationState(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,165 @@
@@ -0,0 +1,165 @@
|
||||
// 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.Collections.ObjectModel; |
||||
using System.Collections.Specialized; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using ICSharpCode.Core; |
||||
using Microsoft.Win32; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class InstalledAddInsViewModel : NuGetAddInsViewModelBase |
||||
{ |
||||
public InstalledAddInsViewModel() |
||||
: base() |
||||
{ |
||||
AllowInstallFromArchive = true; |
||||
HasFilterForPreinstalled = true; |
||||
Title = ResourceService.GetString("AddInManager2.Views.Installed"); |
||||
|
||||
// Load preinstalled AddIn filter
|
||||
LoadPreinstalledAddInFilter(); |
||||
|
||||
AddInManager.Events.AddInInstalled += InstalledAddInsChanged; |
||||
AddInManager.Events.AddInUninstalled += InstalledAddInsChanged; |
||||
AddInManager.Events.AddInStateChanged += InstalledAddInStateChanged; |
||||
} |
||||
|
||||
protected override void OnDispose() |
||||
{ |
||||
AddInManager.Events.AddInInstalled -= InstalledAddInsChanged; |
||||
AddInManager.Events.AddInUninstalled -= InstalledAddInsChanged; |
||||
AddInManager.Events.AddInStateChanged -= InstalledAddInStateChanged; |
||||
} |
||||
|
||||
protected override IQueryable<IPackage> GetAllPackages() |
||||
{ |
||||
return AddInManager.NuGet.Packages.LocalRepository.GetPackages(); |
||||
} |
||||
|
||||
protected override IEnumerable<IPackage> GetFilteredPackagesBeforePagingResults(IQueryable<IPackage> allPackages) |
||||
{ |
||||
return base.GetFilteredPackagesBeforePagingResults(allPackages) |
||||
.Where(package => package.IsReleaseVersion()) |
||||
.DistinctLast(PackageEqualityComparer.Id); |
||||
} |
||||
|
||||
protected override void UpdatePackageViewModels(IEnumerable<IPackage> packages) |
||||
{ |
||||
IEnumerable<AddInPackageViewModelBase> offlineAddInViewModels = GetInstalledAddIns(packages); |
||||
// IEnumerable<AddInPackageViewModelBase> nuGetViewModels = ConvertToAddInViewModels(packages);
|
||||
|
||||
// Merge lists of offline entries (internal AddIn objects) and online entries (installed NuGet packages)
|
||||
// IEnumerable<AddInPackageViewModelBase> viewModels = CombineOnlineAndOfflineAddIns(nuGetViewModels, offlineAddInViewModels);
|
||||
// UpdatePackageViewModels(viewModels.OrderBy(vm => vm.Name));
|
||||
|
||||
UpdatePackageViewModels(offlineAddInViewModels.OrderBy(vm => vm.Name)); |
||||
} |
||||
|
||||
private IEnumerable<AddInPackageViewModelBase> CombineOnlineAndOfflineAddIns( |
||||
IEnumerable<AddInPackageViewModelBase> onlineAddIns, IEnumerable<AddInPackageViewModelBase> offlineAddIns) |
||||
{ |
||||
return offlineAddIns.GroupJoin( |
||||
onlineAddIns, |
||||
offlinevm => offlinevm.Id, |
||||
onlinevm => onlinevm.Id, |
||||
(offlinevm, e) => e.ElementAtOrDefault(0) ?? offlinevm); |
||||
} |
||||
|
||||
private IEnumerable<AddInPackageViewModelBase> GetInstalledAddIns(IEnumerable<IPackage> installedPackages) |
||||
{ |
||||
AddInPackageViewModelBase addInPackage; |
||||
|
||||
// Fill set of ID of installed NuGet packages, so we can later quickly check, whether NuGet package is installed for an AddIn
|
||||
HashSet<string> nuGetPackageIDs = new HashSet<string>(); |
||||
foreach (IPackage package in installedPackages) |
||||
{ |
||||
if (!nuGetPackageIDs.Contains(package.Id)) |
||||
{ |
||||
nuGetPackageIDs.Add(package.Id); |
||||
} |
||||
} |
||||
|
||||
List<ManagedAddIn> addInList = new List<ManagedAddIn>(AddInManager.Setup.AddInsWithMarkedForInstallation); |
||||
addInList.Sort(delegate(ManagedAddIn a, ManagedAddIn b) |
||||
{ |
||||
return a.AddIn.Name.CompareTo(b.AddIn.Name); |
||||
}); |
||||
foreach (ManagedAddIn addIn in addInList) |
||||
{ |
||||
if (string.Equals(addIn.AddIn.Properties["addInManagerHidden"], "true", StringComparison.OrdinalIgnoreCase)) |
||||
{ |
||||
// This excludes the SharpDevelop application appearing as AddIn in the tree
|
||||
continue; |
||||
} |
||||
if (!ShowPreinstalledAddIns && AddInManager.Setup.IsAddInPreinstalled(addIn.AddIn)) |
||||
{ |
||||
continue; |
||||
} |
||||
|
||||
string nuGetPackageID = addIn.AddIn.Properties["nuGetPackageID"]; |
||||
if (!string.IsNullOrEmpty(nuGetPackageID)) |
||||
{ |
||||
if (nuGetPackageIDs.Contains(nuGetPackageID)) |
||||
{ |
||||
addIn.InstallationSource = AddInInstallationSource.NuGetRepository; |
||||
} |
||||
} |
||||
|
||||
addInPackage = new OfflineAddInsViewModelBase(addIn); |
||||
yield return addInPackage; |
||||
} |
||||
} |
||||
|
||||
protected override void UpdatePreinstalledFilter() |
||||
{ |
||||
// Save the preinstalled AddIn filter
|
||||
SavePreinstalledAddInFilter(); |
||||
|
||||
// Update the list
|
||||
Search(); |
||||
} |
||||
|
||||
private void InstalledAddInsChanged(object sender, AddInInstallationEventArgs e) |
||||
{ |
||||
ReadPackages(); |
||||
} |
||||
|
||||
private void InstalledAddInStateChanged(object sender, AddInInstallationEventArgs e) |
||||
{ |
||||
UpdateInstallationState(); |
||||
} |
||||
|
||||
private void LoadPreinstalledAddInFilter() |
||||
{ |
||||
ShowPreinstalledAddIns = PropertyService.Get<bool>("AddInManager2.ShowPreinstalledAddIns", false); |
||||
} |
||||
|
||||
private void SavePreinstalledAddInFilter() |
||||
{ |
||||
PropertyService.Set<bool>("AddInManager2.ShowPreinstalledAddIns", ShowPreinstalledAddIns); |
||||
} |
||||
|
||||
protected override void InstallFromArchive() |
||||
{ |
||||
OpenFileDialog dlg = new OpenFileDialog(); |
||||
dlg.Filter = ResourceService.GetString("AddInManager2.SDAddInFileFilter"); |
||||
dlg.Multiselect = true; |
||||
var showDialogResult = dlg.ShowDialog(); |
||||
if (showDialogResult.HasValue && showDialogResult.Value) |
||||
{ |
||||
foreach (var file in dlg.FileNames) |
||||
{ |
||||
AddInManager.Setup.InstallAddIn(file); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
// 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.Linq; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class LicenseAcceptanceViewModel : Model<LicenseAcceptanceViewModel> |
||||
{ |
||||
IList<IPackage> packages; |
||||
|
||||
public LicenseAcceptanceViewModel(IEnumerable<IPackage> packages) |
||||
{ |
||||
this.packages = packages.ToList(); |
||||
} |
||||
|
||||
public IEnumerable<IPackage> Packages |
||||
{ |
||||
get |
||||
{ |
||||
return packages; |
||||
} |
||||
} |
||||
|
||||
public bool HasOnePackage |
||||
{ |
||||
get |
||||
{ |
||||
return packages.Count == 1; |
||||
} |
||||
} |
||||
|
||||
public bool HasMultiplePackages |
||||
{ |
||||
get |
||||
{ |
||||
return packages.Count > 1; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,213 @@
@@ -0,0 +1,213 @@
|
||||
// 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.Collections.ObjectModel; |
||||
using System.Collections.Specialized; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class NuGetAddInsViewModelBase : AddInsViewModelBase |
||||
{ |
||||
private AddInManagerTask<ReadPackagesResult> _task; |
||||
private IEnumerable<IPackage> _allPackages; |
||||
|
||||
public NuGetAddInsViewModelBase() |
||||
: base() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns all the packages.
|
||||
/// </summary>
|
||||
protected virtual IQueryable<IPackage> GetAllPackages() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public override void ReadPackages() |
||||
{ |
||||
base.ReadPackages(); |
||||
_allPackages = null; |
||||
UpdateRepositoryBeforeReadPackagesTaskStarts(); |
||||
StartReadPackagesTask(); |
||||
} |
||||
|
||||
private void StartReadPackagesTask() |
||||
{ |
||||
IsReadingPackages = true; |
||||
HasError = false; |
||||
ClearPackages(); |
||||
CancelReadPackagesTask(); |
||||
CreateReadPackagesTask(); |
||||
_task.Start(); |
||||
} |
||||
|
||||
protected virtual void UpdateRepositoryBeforeReadPackagesTaskStarts() |
||||
{ |
||||
} |
||||
|
||||
private void CancelReadPackagesTask() |
||||
{ |
||||
if (_task != null) |
||||
{ |
||||
_task.Cancel(); |
||||
} |
||||
} |
||||
|
||||
private void CreateReadPackagesTask() |
||||
{ |
||||
_task = AddInManagerTask.Create( |
||||
() => GetPackagesForSelectedPageResult(), |
||||
(result) => OnPackagesReadForSelectedPage(result)); |
||||
} |
||||
|
||||
private ReadPackagesResult GetPackagesForSelectedPageResult() |
||||
{ |
||||
IEnumerable<IPackage> packages = GetPackagesForSelectedPage(); |
||||
return new ReadPackagesResult(packages, TotalItems); |
||||
} |
||||
|
||||
private void OnPackagesReadForSelectedPage(AddInManagerTask<ReadPackagesResult> task) |
||||
{ |
||||
IsReadingPackages = false; |
||||
if (task.IsFaulted) |
||||
{ |
||||
SaveError(task.Exception); |
||||
} |
||||
else if (task.IsCancelled) |
||||
{ |
||||
// Ignore
|
||||
} |
||||
else |
||||
{ |
||||
UpdatePackagesForSelectedPage(task.Result); |
||||
} |
||||
base.OnPropertyChanged(null); |
||||
} |
||||
|
||||
private void UpdatePackagesForSelectedPage(ReadPackagesResult result) |
||||
{ |
||||
PagesCollection.TotalItems = result.TotalPackages; |
||||
PagesCollection.TotalItemsOnSelectedPage = result.TotalPackagesOnPage; |
||||
UpdatePackageViewModels(result.Packages); |
||||
} |
||||
|
||||
private void PagesChanged(object sender, NotifyCollectionChangedEventArgs e) |
||||
{ |
||||
StartReadPackagesTask(); |
||||
base.OnPropertyChanged(null); |
||||
} |
||||
|
||||
private IEnumerable<IPackage> GetPackagesForSelectedPage() |
||||
{ |
||||
IEnumerable<IPackage> filteredPackages = GetFilteredPackagesBeforePagingResults(); |
||||
return GetPackagesForSelectedPage(filteredPackages); |
||||
} |
||||
|
||||
private IEnumerable<IPackage> GetFilteredPackagesBeforePagingResults() |
||||
{ |
||||
if (_allPackages == null) |
||||
{ |
||||
IQueryable<IPackage> packages = GetAllPackages(); |
||||
packages = OrderPackages(packages); |
||||
packages = FilterPackagesBySearchCriteria(packages); |
||||
TotalItems = packages.Count(); |
||||
_allPackages = GetFilteredPackagesBeforePagingResults(packages); |
||||
} |
||||
return _allPackages; |
||||
} |
||||
|
||||
protected virtual IQueryable<IPackage> OrderPackages(IQueryable<IPackage> packages) |
||||
{ |
||||
return packages |
||||
.OrderBy(package => package.Id); |
||||
} |
||||
|
||||
private IQueryable<IPackage> FilterPackagesBySearchCriteria(IQueryable<IPackage> packages) |
||||
{ |
||||
string searchCriteria = GetSearchCriteria(); |
||||
return FilterPackagesBySearchCriteria(packages, searchCriteria); |
||||
} |
||||
|
||||
private string GetSearchCriteria() |
||||
{ |
||||
if (String.IsNullOrWhiteSpace(SearchTerms)) |
||||
{ |
||||
return null; |
||||
} |
||||
return SearchTerms; |
||||
} |
||||
|
||||
protected IQueryable<IPackage> FilterPackagesBySearchCriteria(IQueryable<IPackage> packages, string searchCriteria) |
||||
{ |
||||
return packages.Find(searchCriteria); |
||||
} |
||||
|
||||
private IEnumerable<IPackage> GetPackagesForSelectedPage(IEnumerable<IPackage> allPackages) |
||||
{ |
||||
int packagesToSkip = PagesCollection.ItemsBeforeFirstPage; |
||||
return allPackages |
||||
.Skip(packagesToSkip) |
||||
.Take(PagesCollection.PageSize); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Allows filtering of the packages before paging the results. Call base class method
|
||||
/// to run default filtering.
|
||||
/// </summary>
|
||||
protected virtual IEnumerable<IPackage> GetFilteredPackagesBeforePagingResults(IQueryable<IPackage> allPackages) |
||||
{ |
||||
return GetBufferedPackages(allPackages) |
||||
.Where(package => package.IsReleaseVersion()) |
||||
.DistinctLast(PackageEqualityComparer.Id); |
||||
} |
||||
|
||||
private IEnumerable<IPackage> GetBufferedPackages(IQueryable<IPackage> allPackages) |
||||
{ |
||||
return allPackages.AsBufferedEnumerable(30); |
||||
} |
||||
|
||||
protected virtual void UpdatePackageViewModels(IEnumerable<IPackage> packages) |
||||
{ |
||||
IEnumerable<AddInPackageViewModelBase> currentViewModels = ConvertToAddInViewModels(packages); |
||||
UpdatePackageViewModels(currentViewModels); |
||||
} |
||||
|
||||
protected IEnumerable<AddInPackageViewModelBase> ConvertToAddInViewModels(IEnumerable<IPackage> packages) |
||||
{ |
||||
foreach (IPackage package in packages) |
||||
{ |
||||
yield return CreateAddInViewModel(package); |
||||
} |
||||
} |
||||
|
||||
protected virtual AddInPackageViewModelBase CreateAddInViewModel(IPackage package) |
||||
{ |
||||
return new NuGetPackageViewModel(package); |
||||
} |
||||
|
||||
public override int SelectedPageNumber |
||||
{ |
||||
get |
||||
{ |
||||
return base.SelectedPageNumber; |
||||
} |
||||
set |
||||
{ |
||||
if (base.SelectedPageNumber != value) |
||||
{ |
||||
base.SelectedPageNumber = value; |
||||
StartReadPackagesTask(); |
||||
base.OnPropertyChanged(null); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,464 @@
@@ -0,0 +1,464 @@
|
||||
// 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.IO; |
||||
using System.Linq; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using ICSharpCode.Core; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class NuGetPackageViewModel : AddInPackageViewModelBase |
||||
{ |
||||
private IPackage _package; |
||||
private IEnumerable<PackageOperation> _packageOperations = new PackageOperation[0]; |
||||
|
||||
public NuGetPackageViewModel(IPackage package) |
||||
: base() |
||||
{ |
||||
this._package = package; |
||||
} |
||||
|
||||
public IPackage Package |
||||
{ |
||||
get |
||||
{ |
||||
return _package; |
||||
} |
||||
} |
||||
|
||||
public override string Name |
||||
{ |
||||
get |
||||
{ |
||||
return _package.Id; |
||||
} |
||||
} |
||||
|
||||
public override Uri LicenseUrl |
||||
{ |
||||
get |
||||
{ |
||||
return _package.LicenseUrl; |
||||
} |
||||
} |
||||
|
||||
public override Uri ProjectUrl |
||||
{ |
||||
get |
||||
{ |
||||
return _package.ProjectUrl; |
||||
} |
||||
} |
||||
|
||||
public override Uri ReportAbuseUrl |
||||
{ |
||||
get |
||||
{ |
||||
return _package.ReportAbuseUrl; |
||||
} |
||||
} |
||||
|
||||
public override bool IsOffline |
||||
{ |
||||
get |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override bool IsPreinstalled |
||||
{ |
||||
get |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override bool IsAdded |
||||
{ |
||||
get |
||||
{ |
||||
AddIn installedAddIn = AddInManager.Setup.GetAddInForNuGetPackage(_package, true); |
||||
|
||||
// if (installedAddIn != null)
|
||||
// LoggingService.DebugFormatted("isAdded: installedAddIn.Action = {0}", installedAddIn.Action);
|
||||
// else
|
||||
// LoggingService.DebugFormatted("isAdded: installedAddIn for {0} is null", _package.Id);
|
||||
|
||||
return (installedAddIn != null) && ((installedAddIn.Action == AddInAction.Install) || (installedAddIn.Action == AddInAction.Update)); |
||||
} |
||||
} |
||||
|
||||
public override bool IsUpdate |
||||
{ |
||||
get |
||||
{ |
||||
AddIn installedAddIn = AddInManager.Setup.GetAddInForNuGetPackage(_package); |
||||
|
||||
// if (installedAddIn != null)
|
||||
// LoggingService.DebugFormatted("isUpdate: installed {0}, package {1}", installedAddIn.Version.ToString(), _package.Version.Version.ToString());
|
||||
// else
|
||||
// LoggingService.DebugFormatted("isUpdate: installedAddIn for {0} is null", _package.Id);
|
||||
|
||||
return (installedAddIn != null) |
||||
&& AddInManager.Setup.IsAddInInstalled(installedAddIn) |
||||
&& (installedAddIn.Version < _package.Version.Version); |
||||
} |
||||
} |
||||
|
||||
public override bool IsInstalled |
||||
{ |
||||
get |
||||
{ |
||||
AddIn installedAddIn = AddInManager.Setup.GetAddInForNuGetPackage(_package); |
||||
return (installedAddIn != null) && AddInManager.Setup.IsAddInInstalled(installedAddIn); |
||||
} |
||||
} |
||||
|
||||
public override bool IsInstallable |
||||
{ |
||||
get |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public override bool IsUninstallable |
||||
{ |
||||
get |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public override bool IsEnabled |
||||
{ |
||||
get |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public override bool IsRemoved |
||||
{ |
||||
get |
||||
{ |
||||
AddIn installedAddIn = AddInManager.Setup.GetAddInForNuGetPackage(_package); |
||||
return (installedAddIn != null) && (installedAddIn.Action == AddInAction.Uninstall); |
||||
} |
||||
} |
||||
|
||||
private bool IsPackageInstalled() |
||||
{ |
||||
return AddInManager.NuGet.Packages.LocalRepository.Exists(_package); |
||||
} |
||||
|
||||
public override IEnumerable<AddInDependency> Dependencies |
||||
{ |
||||
get |
||||
{ |
||||
if ((_package.DependencySets != null) && _package.DependencySets.Any()) |
||||
{ |
||||
PackageDependencySet firstSet = _package.DependencySets.First(); |
||||
if ((firstSet != null) && (firstSet.Dependencies != null) && (firstSet.Dependencies.Count > 0)) |
||||
{ |
||||
return firstSet.Dependencies.Select(d => new AddInDependency(d)); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public override IEnumerable<string> Authors |
||||
{ |
||||
get |
||||
{ |
||||
return _package.Authors; |
||||
} |
||||
} |
||||
|
||||
public override bool HasDownloadCount |
||||
{ |
||||
get |
||||
{ |
||||
return _package.DownloadCount >= 0; |
||||
} |
||||
} |
||||
|
||||
public override string Id |
||||
{ |
||||
get |
||||
{ |
||||
return _package.Id; |
||||
} |
||||
} |
||||
|
||||
public override Uri IconUrl |
||||
{ |
||||
get |
||||
{ |
||||
return _package.IconUrl; |
||||
} |
||||
} |
||||
|
||||
public override string Summary |
||||
{ |
||||
get |
||||
{ |
||||
if (IsAdded) |
||||
{ |
||||
if (IsUpdate) |
||||
{ |
||||
return ResourceService.GetString("AddInManager.AddInUpdated"); |
||||
} |
||||
else |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInInstalled")); |
||||
} |
||||
} |
||||
else if (IsRemoved) |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInRemoved")); |
||||
} |
||||
else if (!IsEnabled) |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInDisabled")); |
||||
} |
||||
else |
||||
{ |
||||
return _package.Summary; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override Version Version |
||||
{ |
||||
get |
||||
{ |
||||
return _package.Version.Version; |
||||
} |
||||
} |
||||
|
||||
public override int DownloadCount |
||||
{ |
||||
get |
||||
{ |
||||
return _package.DownloadCount; |
||||
} |
||||
} |
||||
|
||||
public override string Description |
||||
{ |
||||
get |
||||
{ |
||||
return _package.Description; |
||||
} |
||||
} |
||||
|
||||
public override DateTime? LastUpdated |
||||
{ |
||||
get |
||||
{ |
||||
// TODO
|
||||
// return package.LastUpdated;
|
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public override bool HasDependencyConflicts |
||||
{ |
||||
get |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override void AddPackage() |
||||
{ |
||||
ClearReportedMessages(); |
||||
TryInstallingPackage(); |
||||
} |
||||
|
||||
public override void UpdatePackage() |
||||
{ |
||||
ClearReportedMessages(); |
||||
TryInstallingPackage(); |
||||
} |
||||
|
||||
private void ClearReportedMessages() |
||||
{ |
||||
// packageManagementEvents.OnPackageOperationsStarting();
|
||||
} |
||||
|
||||
private void GetPackageOperations() |
||||
{ |
||||
var packageOperationResolver = AddInManager.NuGet.CreateInstallPackageOperationResolver(false); |
||||
_packageOperations = packageOperationResolver.ResolveOperations(_package); |
||||
} |
||||
|
||||
private bool CanInstallPackage() |
||||
{ |
||||
// Ask for downloading dependent packages
|
||||
if ((_packageOperations != null) && _packageOperations.Any()) |
||||
{ |
||||
var operationsForDependencies = _packageOperations.Where(p => p.Package.Id != _package.Id); |
||||
if ((operationsForDependencies != null) && operationsForDependencies.Any()) |
||||
{ |
||||
string addInNames = ""; |
||||
foreach (var packageOperation in operationsForDependencies) |
||||
{ |
||||
addInNames += "\t " + |
||||
packageOperation.Package.Id + " " + packageOperation.Package.Version.ToString() + Environment.NewLine; |
||||
} |
||||
if (!MessageService.AskQuestionFormatted( |
||||
"${res:AddInManager.Title}", "${res:AddInManager2.InstallDependentMessage}", _package.Id, addInNames)) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Ask for license acceptance
|
||||
IEnumerable<IPackage> packages = GetPackagesRequiringLicenseAcceptance(); |
||||
if (packages.Any()) |
||||
{ |
||||
AcceptLicensesEventArgs acceptLicenses = new AcceptLicensesEventArgs(packages); |
||||
acceptLicenses.IsAccepted = true; |
||||
AddInManager.Events.OnAcceptLicenses(acceptLicenses); |
||||
return acceptLicenses.IsAccepted; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
private IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance() |
||||
{ |
||||
IList<IPackage> packagesToBeInstalled = GetPackagesToBeInstalled(); |
||||
return GetPackagesRequiringLicenseAcceptance(packagesToBeInstalled); |
||||
} |
||||
|
||||
private IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance(IList<IPackage> packagesToBeInstalled) |
||||
{ |
||||
return packagesToBeInstalled.Where(package => PackageRequiresLicenseAcceptance(package)); |
||||
} |
||||
|
||||
private IList<IPackage> GetPackagesToBeInstalled() |
||||
{ |
||||
List<IPackage> packages = new List<IPackage>(); |
||||
foreach (PackageOperation operation in _packageOperations) |
||||
{ |
||||
if (operation.Action == PackageAction.Install) |
||||
{ |
||||
packages.Add(operation.Package); |
||||
} |
||||
} |
||||
return packages; |
||||
} |
||||
|
||||
private bool PackageRequiresLicenseAcceptance(IPackage package) |
||||
{ |
||||
return package.RequireLicenseAcceptance && !IsPackageInstalled(); |
||||
} |
||||
|
||||
private void TryInstallingPackage() |
||||
{ |
||||
try |
||||
{ |
||||
if (IsPackageInstalled()) |
||||
{ |
||||
// Package is already installed, but seems to be not registered as SD AddIn
|
||||
string assumedPackageOutputDir = |
||||
Path.Combine(AddInManager.NuGet.PackageOutputDirectory, _package.Id + "." + _package.Version.Version.ToString()); |
||||
AddInManager.Setup.InstallAddIn(_package, assumedPackageOutputDir); |
||||
} |
||||
else |
||||
{ |
||||
// Perform a normal download and AddIn installation
|
||||
GetPackageOperations(); |
||||
if (CanInstallPackage()) |
||||
{ |
||||
InstallPackage(_packageOperations); |
||||
} |
||||
} |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
ReportError(ex); |
||||
LoggingService.Error("Error when trying to install package.", ex); |
||||
} |
||||
} |
||||
|
||||
private void InstallPackage(IEnumerable<PackageOperation> packageOperations) |
||||
{ |
||||
foreach (PackageOperation operation in packageOperations) |
||||
{ |
||||
AddInManager.NuGet.ExecuteOperation(operation); |
||||
} |
||||
} |
||||
|
||||
private void ReportError(Exception ex) |
||||
{ |
||||
AddInManager.Events.OnAddInOperationError(new AddInExceptionEventArgs(ex)); |
||||
} |
||||
|
||||
public override void RemovePackage() |
||||
{ |
||||
TryUninstallingPackage(); |
||||
} |
||||
|
||||
private void TryUninstallingPackage() |
||||
{ |
||||
try |
||||
{ |
||||
UninstallPackage(); |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
ReportError(ex); |
||||
LoggingService.Error("Error when trying to uninstall package.", ex); |
||||
} |
||||
} |
||||
|
||||
public void UninstallPackage() |
||||
{ |
||||
ClearReportedMessages(); |
||||
|
||||
AddIn installedAddIn = AddInManager.Setup.GetAddInForNuGetPackage(_package); |
||||
if (installedAddIn != null) |
||||
{ |
||||
AddInManager.Setup.UninstallAddIn(installedAddIn); |
||||
} |
||||
} |
||||
|
||||
public override void CancelInstallation() |
||||
{ |
||||
AddIn addIn = AddInManager.Setup.GetAddInForNuGetPackage(_package, true); |
||||
if (addIn != null) |
||||
{ |
||||
AddInManager.Setup.CancelInstallation(addIn); |
||||
} |
||||
} |
||||
|
||||
public override void CancelUpdate() |
||||
{ |
||||
AddIn addIn = AddInManager.Setup.GetAddInForNuGetPackage(_package, true); |
||||
if (addIn != null) |
||||
{ |
||||
AddInManager.Setup.CancelUpdate(addIn); |
||||
} |
||||
} |
||||
|
||||
public override void CancelUninstallation() |
||||
{ |
||||
AddIn addIn = AddInManager.Setup.GetAddInForNuGetPackage(_package); |
||||
if (addIn != null) |
||||
{ |
||||
AddInManager.Setup.CancelUninstallation(addIn); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,527 @@
@@ -0,0 +1,527 @@
|
||||
// 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.Linq; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using ICSharpCode.Core; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class OfflineAddInsViewModelBase : AddInPackageViewModelBase |
||||
{ |
||||
private AddIn _addIn; |
||||
private ManagedAddIn _markedAddIn; |
||||
|
||||
private string _name; |
||||
private Uri _licenseUrl; |
||||
private Uri _projectUrl; |
||||
private Uri _reportAbuseUrl; |
||||
private IEnumerable<AddInDependency> _dependencies; |
||||
private IEnumerable<string> _authors; |
||||
private bool _hasDownloadCount; |
||||
private string _id; |
||||
private Uri _iconUrl; |
||||
private string _summary; |
||||
private Version _version; |
||||
private Version _oldVersion; |
||||
private int _downloadCount; |
||||
private string _description; |
||||
private DateTime? _lastUpdated; |
||||
|
||||
public OfflineAddInsViewModelBase(ManagedAddIn addIn) |
||||
: base() |
||||
{ |
||||
_markedAddIn = addIn; |
||||
if (_markedAddIn != null) |
||||
{ |
||||
_addIn = addIn.AddIn; |
||||
} |
||||
if (_addIn != null) |
||||
{ |
||||
UpdateMembers(); |
||||
} |
||||
} |
||||
|
||||
public void UpdateMembers() |
||||
{ |
||||
if ((_addIn == null) || (_markedAddIn == null)) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
_id = _addIn.Manifest.PrimaryIdentity; |
||||
_name = _addIn.Name; |
||||
if (_addIn.Version != null) |
||||
{ |
||||
_version = _addIn.Version; |
||||
} |
||||
_description = _addIn.Properties["description"]; |
||||
_summary = _addIn.Properties["description"]; |
||||
if (!String.IsNullOrEmpty(_addIn.Properties["url"])) |
||||
{ |
||||
_projectUrl = new Uri(_addIn.Properties["url"]); |
||||
} |
||||
if (!String.IsNullOrEmpty(_addIn.Properties["license"])) |
||||
{ |
||||
_licenseUrl = new Uri(_addIn.Properties["license"]); |
||||
} |
||||
if (!String.IsNullOrEmpty(_addIn.Properties["author"])) |
||||
{ |
||||
_authors = new string[] { _addIn.Properties["author"] }; |
||||
} |
||||
|
||||
if ((_addIn.Manifest != null) && (_addIn.Manifest.Dependencies != null)) |
||||
{ |
||||
_dependencies = _addIn.Manifest.Dependencies.Select(d => new AddInDependency(d)); |
||||
} |
||||
|
||||
if (_markedAddIn.IsUpdate) |
||||
{ |
||||
_oldVersion = _markedAddIn.OldVersion; |
||||
} |
||||
|
||||
_iconUrl = null; |
||||
_hasDownloadCount = false; |
||||
_downloadCount = 0; |
||||
_lastUpdated = null; |
||||
_reportAbuseUrl = null; |
||||
} |
||||
|
||||
public AddIn AddIn |
||||
{ |
||||
get |
||||
{ |
||||
return _addIn; |
||||
} |
||||
} |
||||
|
||||
public override string Name |
||||
{ |
||||
get |
||||
{ |
||||
return _name; |
||||
} |
||||
} |
||||
|
||||
public override Uri LicenseUrl |
||||
{ |
||||
get |
||||
{ |
||||
return _licenseUrl; |
||||
} |
||||
} |
||||
|
||||
public override Uri ProjectUrl |
||||
{ |
||||
get |
||||
{ |
||||
return _projectUrl; |
||||
} |
||||
} |
||||
|
||||
public override Uri ReportAbuseUrl |
||||
{ |
||||
get |
||||
{ |
||||
return _reportAbuseUrl; |
||||
} |
||||
} |
||||
|
||||
public override bool IsOffline |
||||
{ |
||||
get |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public override bool IsPreinstalled |
||||
{ |
||||
get |
||||
{ |
||||
if (_addIn != null) |
||||
{ |
||||
return AddInManager.Setup.IsAddInPreinstalled(_addIn); |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override bool IsAdded |
||||
{ |
||||
get |
||||
{ |
||||
if (_addIn != null) |
||||
{ |
||||
// return (_addIn.Action == AddInAction.Install) || (_addIn.Action == AddInAction.Update);
|
||||
return _markedAddIn.IsTemporary; |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override bool IsUpdate |
||||
{ |
||||
get |
||||
{ |
||||
return _markedAddIn.IsUpdate; |
||||
} |
||||
} |
||||
|
||||
public override bool IsInstalled |
||||
{ |
||||
get |
||||
{ |
||||
if (_addIn != null) |
||||
{ |
||||
return AddInManager.Setup.IsAddInInstalled(_addIn); |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override bool IsInstallable |
||||
{ |
||||
get |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override bool IsUninstallable |
||||
{ |
||||
get |
||||
{ |
||||
return !IsPreinstalled; |
||||
} |
||||
} |
||||
|
||||
public override bool IsEnabled |
||||
{ |
||||
get |
||||
{ |
||||
if (_addIn != null) |
||||
{ |
||||
return (_addIn.Action != AddInAction.Disable); |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override bool IsRemoved |
||||
{ |
||||
get |
||||
{ |
||||
if (_addIn != null) |
||||
{ |
||||
return !_markedAddIn.IsTemporary && (_addIn.Action == AddInAction.Uninstall); |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override IEnumerable<AddInDependency> Dependencies |
||||
{ |
||||
get |
||||
{ |
||||
return _dependencies; |
||||
} |
||||
} |
||||
|
||||
public override IEnumerable<string> Authors |
||||
{ |
||||
get |
||||
{ |
||||
return _authors; |
||||
} |
||||
} |
||||
|
||||
public override bool HasDownloadCount |
||||
{ |
||||
get |
||||
{ |
||||
return _hasDownloadCount; |
||||
} |
||||
} |
||||
|
||||
public override string Id |
||||
{ |
||||
get |
||||
{ |
||||
return _id; |
||||
} |
||||
} |
||||
|
||||
public override Uri IconUrl |
||||
{ |
||||
get |
||||
{ |
||||
return _iconUrl; |
||||
} |
||||
} |
||||
|
||||
public override string Summary |
||||
{ |
||||
get |
||||
{ |
||||
if (_addIn != null) |
||||
{ |
||||
if (_addIn.Action == AddInAction.Install) |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInInstalled")); |
||||
} |
||||
else if (_addIn.Action == AddInAction.Update) |
||||
{ |
||||
return ResourceService.GetString("AddInManager.AddInUpdated"); |
||||
} |
||||
else if (HasDependencyConflicts) |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInDependencyFailed")); |
||||
} |
||||
else if (IsRemoved) |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInRemoved")); |
||||
} |
||||
else if (IsEnabled && !_addIn.Enabled) |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInEnabled")); |
||||
} |
||||
else if (!IsEnabled) |
||||
{ |
||||
if (_addIn.Enabled) |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInWillBeDisabled")); |
||||
} |
||||
else |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInDisabled")); |
||||
} |
||||
} |
||||
else if (_addIn.Action == AddInAction.InstalledTwice) |
||||
{ |
||||
return SurroundWithParantheses(ResourceService.GetString("AddInManager.AddInInstalledTwice")); |
||||
} |
||||
else |
||||
{ |
||||
return _summary; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override Version Version |
||||
{ |
||||
get |
||||
{ |
||||
return _version; |
||||
} |
||||
} |
||||
|
||||
public override Version OldVersion |
||||
{ |
||||
get |
||||
{ |
||||
return _oldVersion; |
||||
} |
||||
} |
||||
|
||||
public override bool ShowSplittedVersions |
||||
{ |
||||
get |
||||
{ |
||||
return IsUpdate; |
||||
} |
||||
} |
||||
|
||||
public override int DownloadCount |
||||
{ |
||||
get |
||||
{ |
||||
return _downloadCount; |
||||
} |
||||
} |
||||
|
||||
public override string Description |
||||
{ |
||||
get |
||||
{ |
||||
return _description; |
||||
} |
||||
} |
||||
|
||||
public override DateTime? LastUpdated |
||||
{ |
||||
get |
||||
{ |
||||
return _lastUpdated; |
||||
} |
||||
} |
||||
|
||||
public override bool HasDependencyConflicts |
||||
{ |
||||
get |
||||
{ |
||||
if (_addIn != null) |
||||
{ |
||||
return (_addIn.Action == AddInAction.DependencyError); |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override bool HasNuGetConnection |
||||
{ |
||||
get |
||||
{ |
||||
if (_markedAddIn != null) |
||||
{ |
||||
return (_markedAddIn.InstallationSource == AddInInstallationSource.NuGetRepository); |
||||
} |
||||
else |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override void AddPackage() |
||||
{ |
||||
} |
||||
|
||||
public override void RemovePackage() |
||||
{ |
||||
if (_addIn.Manifest.PrimaryIdentity == "ICSharpCode.AddInManager2") |
||||
{ |
||||
MessageService.ShowMessage("${res:AddInManager2.CannotRemoveAddInManager}", "${res:AddInManager.Title}"); |
||||
return; |
||||
} |
||||
|
||||
if (!this.IsRemoved) |
||||
{ |
||||
var dependentAddIns = AddInManager.Setup.GetDependentAddIns(_addIn); |
||||
if ((dependentAddIns != null) && dependentAddIns.Any()) |
||||
{ |
||||
string addInNames = ""; |
||||
foreach (var dependentAddIn in dependentAddIns) |
||||
{ |
||||
addInNames += "\t " + dependentAddIn.AddIn.Name + Environment.NewLine; |
||||
} |
||||
if (!MessageService.AskQuestionFormatted( |
||||
"${res:AddInManager.Title}", "${res:AddInManager2.DisableDependentWarning}", _addIn.Name, addInNames)) |
||||
{ |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
|
||||
AddInManager.Setup.UninstallAddIn(_addIn); |
||||
} |
||||
|
||||
public override void CancelInstallation() |
||||
{ |
||||
AddInManager.Setup.CancelInstallation(_addIn); |
||||
} |
||||
|
||||
public override void CancelUpdate() |
||||
{ |
||||
AddInManager.Setup.CancelUpdate(_addIn); |
||||
} |
||||
|
||||
public override void CancelUninstallation() |
||||
{ |
||||
AddInManager.Setup.CancelUninstallation(_addIn); |
||||
} |
||||
|
||||
public override void DisablePackage() |
||||
{ |
||||
if (_addIn == null) |
||||
{ |
||||
return; |
||||
} |
||||
if (_addIn.Manifest.PrimaryIdentity == "ICSharpCode.AddInManager2") |
||||
{ |
||||
MessageService.ShowMessage("${res:AddInManager.CannotDisableAddInManager}", "${res:AddInManager.Title}"); |
||||
return; |
||||
} |
||||
|
||||
if (this.IsEnabled) |
||||
{ |
||||
var dependentAddIns = AddInManager.Setup.GetDependentAddIns(_addIn); |
||||
if ((dependentAddIns != null) && dependentAddIns.Any()) |
||||
{ |
||||
string addInNames = ""; |
||||
foreach (var dependentAddIn in dependentAddIns) |
||||
{ |
||||
addInNames += "\t " + dependentAddIn.AddIn.Name + Environment.NewLine; |
||||
} |
||||
if (!MessageService.AskQuestionFormatted( |
||||
"${res:AddInManager.Title}", "${res:AddInManager2.DisableDependentWarning}", _addIn.Name, addInNames)) |
||||
{ |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
|
||||
AddInManager.Setup.SwitchAddInActivation(_addIn); |
||||
} |
||||
|
||||
public override bool HasOptions |
||||
{ |
||||
get |
||||
{ |
||||
if (_addIn.Enabled) |
||||
{ |
||||
foreach (KeyValuePair<string, ExtensionPath> pair in _addIn.Paths) |
||||
{ |
||||
if (pair.Key.StartsWith("/SharpDevelop/Dialogs/OptionsDialog")) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override void ShowOptions() |
||||
{ |
||||
AddInTreeNode dummyNode = new AddInTreeNode(); |
||||
foreach (KeyValuePair<string, ExtensionPath> pair in _addIn.Paths) |
||||
{ |
||||
if (pair.Key.StartsWith("/SharpDevelop/Dialogs/OptionsDialog")) |
||||
{ |
||||
dummyNode.AddCodons(pair.Value.Codons); |
||||
} |
||||
} |
||||
ICSharpCode.SharpDevelop.Commands.OptionsCommand.ShowTabbedOptions( |
||||
_addIn.Name + " " + ResourceService.GetString("AddInManager.Options"), |
||||
dummyNode); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// 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.Diagnostics; |
||||
using System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class OpenHyperlinkCommand : ICommand |
||||
{ |
||||
public event EventHandler CanExecuteChanged; |
||||
|
||||
protected virtual void OnCanExecuteChanged() |
||||
{ |
||||
if (CanExecuteChanged != null) |
||||
{ |
||||
CanExecuteChanged(this, new EventArgs()); |
||||
} |
||||
} |
||||
|
||||
public bool CanExecute(object parameter) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public void Execute(object parameter) |
||||
{ |
||||
Uri uri = parameter as Uri; |
||||
if (uri != null) |
||||
{ |
||||
StartProcess(uri.AbsoluteUri); |
||||
} |
||||
else |
||||
{ |
||||
StartProcess(parameter as string); |
||||
} |
||||
} |
||||
|
||||
protected virtual void StartProcess(string fileName) |
||||
{ |
||||
try |
||||
{ |
||||
System.Diagnostics.Process.Start(fileName); |
||||
} |
||||
catch (Exception) |
||||
{ |
||||
// TODO Show error message or ignore silently?
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,315 @@
@@ -0,0 +1,315 @@
|
||||
// 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.ObjectModel; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Windows.Forms; |
||||
using System.Windows.Input; |
||||
using System.Windows.Interop; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class PackageRepositoriesViewModel : Model<PackageRepositoriesViewModel> |
||||
{ |
||||
ObservableCollection<PackageRepository> packageRepositories = |
||||
new ObservableCollection<PackageRepository>(); |
||||
ObservableCollection<PackageSource> packageSources; |
||||
|
||||
DelegateCommand addPackageSourceCommmand; |
||||
DelegateCommand removePackageSourceCommand; |
||||
DelegateCommand movePackageSourceUpCommand; |
||||
DelegateCommand movePackageSourceDownCommand; |
||||
DelegateCommand browsePackageFolderCommand; |
||||
|
||||
PackageRepository newPackageSource = new PackageRepository(); |
||||
PackageRepository selectedPackageRepository; |
||||
|
||||
public PackageRepositoriesViewModel() |
||||
{ |
||||
this.packageSources = new ObservableCollection<PackageSource>(); |
||||
CreateCommands(); |
||||
} |
||||
|
||||
private void CreateCommands() |
||||
{ |
||||
addPackageSourceCommmand = |
||||
new DelegateCommand(param => AddPackageSource(), |
||||
param => CanAddPackageSource); |
||||
|
||||
removePackageSourceCommand = |
||||
new DelegateCommand(param => RemovePackageSource(), |
||||
param => CanRemovePackageSource); |
||||
|
||||
movePackageSourceUpCommand = |
||||
new DelegateCommand(param => MovePackageSourceUp(), |
||||
param => CanMovePackageSourceUp); |
||||
|
||||
movePackageSourceDownCommand = |
||||
new DelegateCommand(param => MovePackageSourceDown(), |
||||
param => CanMovePackageSourceDown); |
||||
|
||||
browsePackageFolderCommand = |
||||
new DelegateCommand(param => BrowsePackageFolder()); |
||||
} |
||||
|
||||
public ICommand AddPackageSourceCommand |
||||
{ |
||||
get |
||||
{ |
||||
return addPackageSourceCommmand; |
||||
} |
||||
} |
||||
|
||||
public ICommand RemovePackageSourceCommand |
||||
{ |
||||
get |
||||
{ |
||||
return removePackageSourceCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand MovePackageSourceUpCommand |
||||
{ |
||||
get |
||||
{ |
||||
return movePackageSourceUpCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand MovePackageSourceDownCommand |
||||
{ |
||||
get |
||||
{ |
||||
return movePackageSourceDownCommand; |
||||
} |
||||
} |
||||
|
||||
public ICommand BrowsePackageFolderCommand |
||||
{ |
||||
get |
||||
{ |
||||
return browsePackageFolderCommand; |
||||
} |
||||
} |
||||
|
||||
public ObservableCollection<PackageRepository> PackageRepositories |
||||
{ |
||||
get |
||||
{ |
||||
return packageRepositories; |
||||
} |
||||
} |
||||
|
||||
public void Load() |
||||
{ |
||||
packageSources.Clear(); |
||||
// packageSources.AddRange(AddInManager.Repositories.RegisteredPackageSources);
|
||||
NuGet.CollectionExtensions.AddRange(packageSources, AddInManager.Repositories.RegisteredPackageSources); |
||||
foreach (PackageSource packageSource in packageSources) |
||||
{ |
||||
AddPackageSourceToViewModel(packageSource); |
||||
} |
||||
} |
||||
|
||||
private void AddPackageSourceToViewModel(PackageSource packageSource) |
||||
{ |
||||
var packageRepository = new PackageRepository(packageSource); |
||||
packageRepositories.Add(packageRepository); |
||||
} |
||||
|
||||
public void Save() |
||||
{ |
||||
packageSources.Clear(); |
||||
foreach (PackageRepository packageRepository in packageRepositories) |
||||
{ |
||||
PackageSource source = packageRepository.ToPackageSource(); |
||||
packageSources.Add(source); |
||||
} |
||||
AddInManager.Repositories.RegisteredPackageSources = packageSources; |
||||
} |
||||
|
||||
public string NewPackageSourceName |
||||
{ |
||||
get |
||||
{ |
||||
return newPackageSource.Name; |
||||
} |
||||
set |
||||
{ |
||||
newPackageSource.Name = value; |
||||
OnPropertyChanged(viewModel => viewModel.NewPackageSourceName); |
||||
} |
||||
} |
||||
|
||||
public string NewPackageSourceUrl |
||||
{ |
||||
get |
||||
{ |
||||
return newPackageSource.SourceUrl; |
||||
} |
||||
set |
||||
{ |
||||
newPackageSource.SourceUrl = value; |
||||
OnPropertyChanged(viewModel => viewModel.NewPackageSourceUrl); |
||||
} |
||||
} |
||||
|
||||
public PackageRepository SelectedPackageRepository |
||||
{ |
||||
get |
||||
{ |
||||
return selectedPackageRepository; |
||||
} |
||||
set |
||||
{ |
||||
selectedPackageRepository = value; |
||||
OnPropertyChanged(viewModel => viewModel.SelectedPackageRepository); |
||||
OnPropertyChanged(viewModel => viewModel.CanAddPackageSource); |
||||
} |
||||
} |
||||
|
||||
public void AddPackageSource() |
||||
{ |
||||
AddNewPackageSourceToViewModel(); |
||||
SelectLastPackageSourceViewModel(); |
||||
} |
||||
|
||||
private void AddNewPackageSourceToViewModel() |
||||
{ |
||||
var packageSource = newPackageSource.ToPackageSource(); |
||||
AddPackageSourceToViewModel(packageSource); |
||||
} |
||||
|
||||
private void SelectLastPackageSourceViewModel() |
||||
{ |
||||
SelectedPackageRepository = GetLastPackageSourceViewModel(); |
||||
} |
||||
|
||||
public bool CanAddPackageSource |
||||
{ |
||||
get |
||||
{ |
||||
return NewPackageSourceHasUrl && NewPackageSourceHasName; |
||||
} |
||||
} |
||||
|
||||
private bool NewPackageSourceHasUrl |
||||
{ |
||||
get |
||||
{ |
||||
return !String.IsNullOrEmpty(NewPackageSourceUrl); |
||||
} |
||||
} |
||||
|
||||
private bool NewPackageSourceHasName |
||||
{ |
||||
get |
||||
{ |
||||
return !String.IsNullOrEmpty(NewPackageSourceName); |
||||
} |
||||
} |
||||
|
||||
public void RemovePackageSource() |
||||
{ |
||||
RemoveSelectedPackageSourceViewModel(); |
||||
} |
||||
|
||||
public bool CanRemovePackageSource |
||||
{ |
||||
get |
||||
{ |
||||
return selectedPackageRepository != null; |
||||
} |
||||
} |
||||
|
||||
private void RemoveSelectedPackageSourceViewModel() |
||||
{ |
||||
packageRepositories.Remove(selectedPackageRepository); |
||||
} |
||||
|
||||
public void MovePackageSourceUp() |
||||
{ |
||||
int selectedPackageSourceIndex = GetSelectedPackageSourceViewModelIndex(); |
||||
int destinationPackageSourceIndex = selectedPackageSourceIndex--; |
||||
packageRepositories.Move(selectedPackageSourceIndex, destinationPackageSourceIndex); |
||||
} |
||||
|
||||
private int GetSelectedPackageSourceViewModelIndex() |
||||
{ |
||||
return packageRepositories.IndexOf(selectedPackageRepository); |
||||
} |
||||
|
||||
public bool CanMovePackageSourceUp |
||||
{ |
||||
get |
||||
{ |
||||
return HasAtLeastTwoPackageSources() && !IsFirstPackageSourceSelected(); |
||||
} |
||||
} |
||||
|
||||
private bool IsFirstPackageSourceSelected() |
||||
{ |
||||
return selectedPackageRepository == packageRepositories[0]; |
||||
} |
||||
|
||||
public void MovePackageSourceDown() |
||||
{ |
||||
int selectedPackageSourceIndex = GetSelectedPackageSourceViewModelIndex(); |
||||
int destinationPackageSourceIndex = selectedPackageSourceIndex++; |
||||
packageRepositories.Move(selectedPackageSourceIndex, destinationPackageSourceIndex); |
||||
} |
||||
|
||||
public bool CanMovePackageSourceDown |
||||
{ |
||||
get |
||||
{ |
||||
return HasAtLeastTwoPackageSources() && !IsLastPackageSourceSelected(); |
||||
} |
||||
} |
||||
|
||||
private bool HasAtLeastTwoPackageSources() |
||||
{ |
||||
return packageRepositories.Count >= 2; |
||||
} |
||||
|
||||
private bool IsLastPackageSourceSelected() |
||||
{ |
||||
PackageRepository lastViewModel = GetLastPackageSourceViewModel(); |
||||
return lastViewModel == selectedPackageRepository; |
||||
} |
||||
|
||||
private PackageRepository GetLastPackageSourceViewModel() |
||||
{ |
||||
return packageRepositories.Last(); |
||||
} |
||||
|
||||
public void BrowsePackageFolder() |
||||
{ |
||||
using (var dialog = new FolderBrowserDialog()) |
||||
{ |
||||
var owner = SD.WinForms.MainWin32Window; |
||||
if (dialog.ShowDialog(owner) == DialogResult.OK) |
||||
{ |
||||
UpdateNewPackageSourceUsingSelectedFolder(dialog.SelectedPath); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void UpdateNewPackageSourceUsingSelectedFolder(string folder) |
||||
{ |
||||
NewPackageSourceUrl = folder; |
||||
NewPackageSourceName = GetPackageSourceNameFromFolder(folder); |
||||
} |
||||
|
||||
private string GetPackageSourceNameFromFolder(string folder) |
||||
{ |
||||
return Path.GetFileName(folder); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,108 @@
@@ -0,0 +1,108 @@
|
||||
// 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.Collections.ObjectModel; |
||||
using System.Collections.Specialized; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.AddInManager2.Model; |
||||
using ICSharpCode.Core; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.AddInManager2.ViewModel |
||||
{ |
||||
public class UpdatedAddInsViewModel : NuGetAddInsViewModelBase |
||||
{ |
||||
private IQueryable<IPackage> installedPackages; |
||||
private string errorMessage = String.Empty; |
||||
private bool hasSavedException = false; |
||||
|
||||
public UpdatedAddInsViewModel() |
||||
: base() |
||||
{ |
||||
IsSearchable = true; |
||||
HasFilterForPrereleases = true; |
||||
Title = ResourceService.GetString("AddInManager2.Views.Updates");; |
||||
|
||||
AddInManager.Events.AddInInstalled += NuGetPackagesChanged; |
||||
AddInManager.Events.AddInUninstalled += NuGetPackagesChanged; |
||||
AddInManager.Events.AddInStateChanged += InstalledAddInStateChanged; |
||||
} |
||||
|
||||
protected override void OnDispose() |
||||
{ |
||||
AddInManager.Events.AddInInstalled -= NuGetPackagesChanged; |
||||
AddInManager.Events.AddInUninstalled -= NuGetPackagesChanged; |
||||
AddInManager.Events.AddInStateChanged -= InstalledAddInStateChanged; |
||||
} |
||||
|
||||
protected override IQueryable<IPackage> GetAllPackages() |
||||
{ |
||||
if (hasSavedException) |
||||
{ |
||||
ThrowSavedException(); |
||||
} |
||||
return GetUpdatedPackages(); |
||||
} |
||||
|
||||
protected override void UpdateRepositoryBeforeReadPackagesTaskStarts() |
||||
{ |
||||
try |
||||
{ |
||||
installedPackages = GetInstalledPackages(); |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
hasSavedException = true; |
||||
errorMessage = ex.Message; |
||||
} |
||||
} |
||||
|
||||
private IQueryable<IPackage> GetInstalledPackages() |
||||
{ |
||||
return AddInManager.NuGet.Packages.LocalRepository.GetPackages(); |
||||
} |
||||
|
||||
private IQueryable<IPackage> GetUpdatedPackages() |
||||
{ |
||||
IQueryable<IPackage> localPackages = installedPackages; |
||||
localPackages = FilterPackages(localPackages); |
||||
var updatedPackages = GetUpdatedPackages(AddInManager.Repositories.Registered, localPackages); |
||||
HighlightCount = updatedPackages.Count(); |
||||
return updatedPackages.AsQueryable(); |
||||
} |
||||
|
||||
private IEnumerable<IPackage> GetUpdatedPackages(IPackageRepository sourceRepository, IQueryable<IPackage> localPackages) |
||||
{ |
||||
return sourceRepository.GetUpdates(localPackages, ShowPrereleases, false); |
||||
} |
||||
|
||||
private IQueryable<IPackage> FilterPackages(IQueryable<IPackage> localPackages) |
||||
{ |
||||
return localPackages.Find(SearchTerms); |
||||
} |
||||
|
||||
private void ThrowSavedException() |
||||
{ |
||||
throw new ApplicationException(errorMessage); |
||||
} |
||||
|
||||
protected override void UpdatePrereleaseFilter() |
||||
{ |
||||
ReadPackages(); |
||||
} |
||||
|
||||
private void NuGetPackagesChanged(object sender, AddInInstallationEventArgs e) |
||||
{ |
||||
ReadPackages(); |
||||
} |
||||
|
||||
private void InstalledAddInStateChanged(object sender, AddInInstallationEventArgs e) |
||||
{ |
||||
UpdateInstallationState(); |
||||
} |
||||
} |
||||
} |
||||