Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#545) Update to better support advanced installation #910

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -235,6 +236,7 @@
<Compile Include="Services\PackageArgumentsService.cs" />
<Compile Include="Utilities\Converters\LocalizationConverter.cs" />
<Compile Include="Utilities\Extensions\LocalizeExtension.cs" />
<Compile Include="Utilities\Converters\NullToInverseBool.cs" />
<Compile Include="Utilities\ToolTipBehavior.cs" />
<Compile Include="Bootstrapper.cs" />
<Compile Include="Commands\CommandExecutionManager.cs" />
Expand Down
9 changes: 9 additions & 0 deletions Source/ChocolateyGui.Common.Windows/Resources/Controls.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,15 @@
<Setter Property="AutomationProperties.HelpText" Value="Go's back" />
<Setter Property="AutomationProperties.AcceleratorKey" Value="B" />
<Setter Property="ToolTip" Value="Back" />
<Style.Triggers>
<Trigger Property="FlowDirection" Value="RightToLeft">
<Setter Property="Content">
<Setter.Value>
<iconPacks:PackIconModern Kind="ChevronRight" Width="18" Height="18" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>

<Style x:Key="IconFlatButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource MahApps.Styles.Button.Flat}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ public async Task<PackageOperationResult> InstallPackage(
config.InstallArguments = advancedInstallOptions.InstallArguments;
config.PackageParameters = advancedInstallOptions.PackageParameters;
config.CommandExecutionTimeoutSeconds = advancedInstallOptions.ExecutionTimeoutInSeconds;
config.AdditionalLogFileLocation = advancedInstallOptions.LogFile;
if (!string.IsNullOrEmpty(advancedInstallOptions.LogFile))
{
config.AdditionalLogFileLocation = advancedInstallOptions.LogFile;
}
config.Prerelease = advancedInstallOptions.PreRelease;
config.ForceX86 = advancedInstallOptions.Forcex86;
config.OverrideArguments = advancedInstallOptions.OverrideArguments;
Expand All @@ -222,6 +227,11 @@ public async Task<PackageOperationResult> InstallPackage(
config.Features.AllowEmptyChecksumsSecure = false;
}
if (!string.IsNullOrEmpty(advancedInstallOptions.CacheLocation))
{
config.CacheLocation = advancedInstallOptions.CacheLocation;
}
config.DownloadChecksum = advancedInstallOptions.DownloadChecksum;
config.DownloadChecksum64 = advancedInstallOptions.DownloadChecksum64bit;
config.DownloadChecksumType = advancedInstallOptions.DownloadChecksumType;
Expand Down Expand Up @@ -437,6 +447,11 @@ public async Task<ChocolateyFeature[]> GetFeatures()

public async Task SetFeature(ChocolateyFeature feature)
{
if (feature == null)
{
return;
}

using (await Lock.WriteLockAsync())
{
_choco.Set(
Expand Down
7 changes: 7 additions & 0 deletions Source/ChocolateyGui.Common.Windows/Services/DialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public DialogService()
_lock = new AsyncSemaphore(1);
}

public event EventHandler<object> ChildWindowOpened;

public event EventHandler<object> ChildWindowClosed;

public ShellView ShellView { get; set; }

/// <inheritdoc />
Expand Down Expand Up @@ -161,7 +165,10 @@ public async Task<TResult> ShowChildWindowAsync<TDialogContext, TResult>(

_childWindowLoadedHandler = (sender, e) =>
{
ChildWindowOpened?.Invoke(sender, e);
var cw = (ChildWindow)sender;
cw.ClosingFinished += (senderObj, r) => ChildWindowClosed?.Invoke(senderObj, r);
if (cw.DataContext is IClosableChildWindow<TResult> vm)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.Threading.Tasks;
using ChocolateyGui.Common.Windows.Controls.Dialogs;
using ChocolateyGui.Common.Windows.Views;
Expand All @@ -14,6 +15,10 @@ namespace ChocolateyGui.Common.Windows.Services
{
public interface IDialogService
{
event EventHandler<object> ChildWindowOpened;

event EventHandler<object> ChildWindowClosed;

ShellView ShellView { get; set; }

/// <summary>
Expand Down
18 changes: 18 additions & 0 deletions Source/ChocolateyGui.Common.Windows/Services/PersistenceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.IO;
using ChocolateyGui.Common.Services;
using Microsoft.Win32;
using DialogResult = System.Windows.Forms.DialogResult;
using FolderBrowserDialog = System.Windows.Forms.FolderBrowserDialog;

namespace ChocolateyGui.Common.Windows.Services
{
Expand All @@ -31,6 +33,22 @@ public Stream SaveFile(string defaultExtension, string filter)
return result != null && result.Value ? fd.OpenFile() : null;
}

public string GetFolderPath(string defaultLocation, string description = null)
{
var fd = new FolderBrowserDialog();
fd.SelectedPath = defaultLocation;
fd.Description = description;

if (fd.ShowDialog() == DialogResult.OK)
{
var path = fd.SelectedPath;

return path;
}

return null;
}

public string GetFilePath(string defaultExtension, string filter)
{
var fd = new SaveFileDialog { DefaultExt = defaultExtension, Filter = filter };
Expand Down
33 changes: 28 additions & 5 deletions Source/ChocolateyGui.Common.Windows/Startup/ChocolateyGuiModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Security.AccessControl;
using Autofac;
using AutoMapper;
using Caliburn.Micro;
Expand All @@ -27,14 +26,12 @@
using ChocolateyGui.Common.Utilities;
using ChocolateyGui.Common.ViewModels.Items;
using ChocolateyGui.Common.Windows.Services;
using ChocolateyGui.Common.Windows.Utilities;
using ChocolateyGui.Common.Windows.ViewModels;
using ChocolateyGui.Common.Windows.ViewModels.Items;
using ChocolateyGui.Common.Windows.Views;
using LiteDB;
using MahApps.Metro.Controls.Dialogs;
using NuGet;
using ChocolateySource = chocolatey.infrastructure.app.configuration.ChocolateySource;
using Environment = System.Environment;
using PackageViewModel = ChocolateyGui.Common.Windows.ViewModels.Items.PackageViewModel;

namespace ChocolateyGui.Common.Windows.Startup
Expand Down Expand Up @@ -111,7 +108,33 @@ protected override void Load(ContainerBuilder builder)
config.CreateMap<ChocolateySource, Common.Models.ChocolateySource>()
.ForMember(dest => dest.VisibleToAdminsOnly, opt => opt.MapFrom(src => src.VisibleToAdminOnly));
config.CreateMap<AdvancedInstallViewModel, AdvancedInstall>();
config.CreateMap<AdvancedInstallViewModel, AdvancedInstall>()
.ForMember(
dest => dest.DownloadChecksum,
opt => opt.Condition(source => !source.IgnoreChecksums))
.ForMember(
dest => dest.DownloadChecksumType,
opt => opt.Condition(source =>
!source.IgnoreChecksums && !string.IsNullOrEmpty(source.DownloadChecksum)))
.ForMember(
dest => dest.DownloadChecksum64bit,
opt => opt.Condition(source =>
Environment.Is64BitOperatingSystem
&& !source.IgnoreChecksums
&& !source.Forcex86))
.ForMember(
dest => dest.DownloadChecksumType64bit,
opt => opt.Condition(source =>
Environment.Is64BitOperatingSystem
&& !source.IgnoreChecksums
&& !source.Forcex86
&& !string.IsNullOrEmpty(source.DownloadChecksum64bit)))
.ForMember(
dest => dest.PackageParameters,
opt => opt.Condition(source => !source.SkipPowerShell))
.ForMember(
dest => dest.InstallArguments,
opt => opt.Condition(source => !source.SkipPowerShell && !source.NotSilent));
});

builder.RegisterType<BundledThemeService>().As<IBundledThemeService>().SingleInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static void UpdateLanguage(string languageCode)

var culture = GetSupportedCultureInfo(languageCode);

if (culture != existingLanguage)
if (!Equals(culture, existingLanguage))
{
TranslationSource.Instance.CurrentCulture = culture;
CultureInfo.DefaultThreadCurrentCulture = culture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

using System;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;

namespace ChocolateyGui.Common.Windows.Utilities.Converters
{
public class BooleanInverter : DependencyObject, IValueConverter
public class BooleanInverter : DependencyObject, IValueConverter, IMultiValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Expand All @@ -24,9 +25,19 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
return value as bool? == false;
}

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return values.All(value => value == null || value as bool? == false);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

using System;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;

namespace ChocolateyGui.Common.Windows.Utilities.Converters
{
public class BooleanToVisibilityInverted : DependencyObject, IValueConverter
public class BooleanToVisibilityInverted : DependencyObject, IValueConverter, IMultiValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Expand All @@ -21,11 +22,23 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
: Visibility.Collapsed;
}

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
var collapsed = values.Aggregate(false, (current, value) => current || !IsCollapsed(value, parameter));

return collapsed ? Visibility.Collapsed : Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

private static bool IsCollapsed(object value, object parameter)
{
var boolVal = (value != null && value != DependencyProperty.UnsetValue) && (bool)value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn

if (parameter is string sParameter)
{
format = string.Format(
TranslationSource.Instance[sParameter],
value);
format = TranslationSource.Instance[sParameter, value];
}

return format;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Chocolatey" file="NullToInverseBool.cs">
// Copyright 2017 - Present Chocolatey Software, LLC
// Copyright 2014 - 2017 Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace ChocolateyGui.Common.Windows.Utilities.Converters
{
public class NullToInverseBool : NullToValue
{
public NullToInverseBool()
{
TrueValue = false;
FalseValue = true;
}
}
}
Loading