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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,12 @@ function Resolve-Xaml
Remove-Item -Path $OutputDir -Recurse -Force -ErrorAction SilentlyContinue
mkdir -Path $OutputDir -Force > $null

$SourceDir = ConvertFrom-Xaml -Configuration $MSBuildConfiguration -OutputDir $OutputDir -XamlDir $XamlDir
# For GraphicalHost we will get failures, but it's ok: we only need to copy *.g.cs files in the dotnet cli project.
# For over projects we leave the check just in case.
# We can revisit it on case-by-case basis.
$IgnoreFailure = [bool]($XamlDir -match 'GraphicalHost')

$SourceDir = ConvertFrom-Xaml -Configuration $MSBuildConfiguration -OutputDir $OutputDir -XamlDir $XamlDir -IgnoreMsbuildFailure:$IgnoreFailure
$DestinationDir = Join-Path -Path $_.FullName -ChildPath gen

if (-not (Test-Path $DestinationDir -PathType Container))
Expand Down Expand Up @@ -1072,9 +1077,13 @@ function script:ConvertFrom-Xaml {
[string] $OutputDir,

[Parameter(Mandatory=$true)]
[string] $XamlDir
[string] $XamlDir,

[switch] $IgnoreMsbuildFailure
)

Write-Verbose "ConvertFrom-Xaml for $XamlDir"

$Pages = ""
Get-ChildItem -Path "$XamlDir\*.xaml" | % {
$Page = $Script:XamlProjPage -f $_.FullName
Expand All @@ -1089,7 +1098,15 @@ function script:ConvertFrom-Xaml {

if ($LASTEXITCODE -ne 0)
{
throw "'msbuild $XamlProjPath > `$null' failed with exit code $LASTEXITCODE"
$message = "When processing $XamlDir 'msbuild $XamlProjPath > `$null' failed with exit code $LASTEXITCODE"
if ($IgnoreMsbuildFailure)
{
Write-Warning $message
}
else
{
throw $message
}
}

return (Join-Path -Path $OutputDir -ChildPath "obj\Any CPU\$Configuration")
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.PowerShell.ConsoleHost/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"net451": {
"dependencies": {
"Microsoft.PowerShell.ScheduledJob": "1.0.0-*",
"Microsoft.PowerShell.Workflow.ServiceCore": "1.0.0-*"
"Microsoft.PowerShell.Workflow.ServiceCore": "1.0.0-*",
"Microsoft.PowerShell.GraphicalHost": "1.0.0-*"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.PowerShell.GraphicalHost/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo(@"Microsoft.PowerShell.GPowerShell"+@",PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
74 changes: 74 additions & 0 deletions src/Microsoft.PowerShell.GraphicalHost/CommonHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//-----------------------------------------------------------------------
// <copyright file="CommonHelper.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <summary>
// Implements HelpWindow.
// </summary>
//-----------------------------------------------------------------------

namespace Microsoft.Management.UI
{
using System.Windows;

/// <summary>
/// Utilities in common in this assembly
/// </summary>
internal static class CommonHelper
{
/// <summary>
/// Restore the values from the settings to the actual window position, size and state.
/// </summary>
/// <param name="target">the window we are setting position and size of</param>
/// <param name="userSettingTop">the value for top from the user settings</param>
/// <param name="userSettingLeft">the value for left from the user settings</param>
/// <param name="userSettingWidth">the value for width from the user settings</param>
/// <param name="userSettingHeight">the value for height from the user settings</param>
/// <param name="defaultWidth">the with used if <paramref name="userSettingWidth"/> is not valid</param>
/// <param name="defaultHeight">the height used if <paramref name="userSettingHeight"/> is not valid</param>
/// <param name="userSettingMaximized">true if the window is maximized in the user setting</param>
internal static void SetStartingPositionAndSize(Window target, double userSettingTop, double userSettingLeft, double userSettingWidth, double userSettingHeight, double defaultWidth, double defaultHeight, bool userSettingMaximized)
{
bool leftInvalid = userSettingLeft < System.Windows.SystemParameters.VirtualScreenLeft ||
userSettingWidth > System.Windows.SystemParameters.VirtualScreenLeft +
System.Windows.SystemParameters.VirtualScreenWidth;

bool topInvalid = userSettingTop < System.Windows.SystemParameters.VirtualScreenTop ||
userSettingTop > System.Windows.SystemParameters.VirtualScreenTop +
System.Windows.SystemParameters.VirtualScreenHeight;

bool widthInvalid = userSettingWidth < 0 ||
userSettingWidth > System.Windows.SystemParameters.VirtualScreenWidth;

bool heightInvalid = userSettingHeight < 0 ||
userSettingHeight > System.Windows.SystemParameters.VirtualScreenHeight;

if (leftInvalid || topInvalid)
{
target.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
}
else
{
target.Left = userSettingLeft;
target.Top = userSettingTop;
}

// If any saved coordinate is invalid, we set the window to the default position
if (widthInvalid || heightInvalid)
{
target.Width = defaultWidth;
target.Height = defaultHeight;
}
else
{
target.Width = userSettingWidth;
target.Height = userSettingHeight;
}

if (userSettingMaximized)
{
target.WindowState = WindowState.Maximized;
}
}
}
}
Loading