Skip to content

Commit 8e95c36

Browse files
authored
Merge pull request #115 from mjcheetham/extract-winui
Extract various shared WPF components into a separate project
2 parents 235bc09 + 27eb556 commit 8e95c36

31 files changed

+350
-345
lines changed

Git-Credential-Manager.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlassian.Bitbucket", "src\
6464
EndProject
6565
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlassian.Bitbucket.Tests", "src\shared\Atlassian.Bitbucket.Tests\Atlassian.Bitbucket.Tests.csproj", "{025E5329-A0B1-4BA9-9203-B70B44A5F9E0}"
6666
EndProject
67+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.UI.Windows", "src\windows\Shared.UI.Windows\Shared.UI.Windows.csproj", "{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}"
68+
EndProject
6769
Global
6870
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6971
Debug|Any CPU = Debug|Any CPU
@@ -234,6 +236,14 @@ Global
234236
{025E5329-A0B1-4BA9-9203-B70B44A5F9E0}.MacDebug|Any CPU.Build.0 = Debug|Any CPU
235237
{025E5329-A0B1-4BA9-9203-B70B44A5F9E0}.MacRelease|Any CPU.ActiveCfg = Debug|Any CPU
236238
{025E5329-A0B1-4BA9-9203-B70B44A5F9E0}.MacRelease|Any CPU.Build.0 = Debug|Any CPU
239+
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
240+
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
241+
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
242+
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
243+
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
244+
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
245+
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
246+
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
237247
EndGlobalSection
238248
GlobalSection(SolutionProperties) = preSolution
239249
HideSolutionNode = FALSE
@@ -257,6 +267,7 @@ Global
257267
{4C2DBC8A-B3F2-4C64-870A-BA79DA4BD403} = {66722747-1B61-40E4-A89B-1AC8E6D62EA9}
258268
{B49881A6-E734-490E-8EA7-FB0D9E296CFB} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
259269
{025E5329-A0B1-4BA9-9203-B70B44A5F9E0} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
270+
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7} = {66722747-1B61-40E4-A89B-1AC8E6D62EA9}
260271
EndGlobalSection
261272
GlobalSection(ExtensibilityGlobals) = postSolution
262273
SolutionGuid = {0EF9FC65-E6BA-45D4-A455-262A9EA4366B}

src/windows/GitHub.UI.Windows/AuthenticationPrompts.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
3-
using GitHub.UI.Controls;
4-
using GitHub.UI.Dialog;
3+
54
using GitHub.UI.Login;
5+
using Microsoft.Git.CredentialManager.UI;
6+
using Microsoft.Git.CredentialManager.UI.Controls;
67

78
namespace GitHub.UI
89
{
@@ -25,7 +26,7 @@ public CredentialPromptResult ShowCredentialPrompt(string enterpriseUrl, bool sh
2526
GitHubEnterpriseUrl = enterpriseUrl
2627
};
2728

28-
bool valid = _gui.ShowDialogWindow(() => new GitHubDialogWindow(viewModel, new LoginCredentialsView()));
29+
bool valid = _gui.ShowDialogWindow(viewModel, () => new LoginCredentialsView());
2930

3031
if (viewModel.UseBrowserLogin)
3132
{
@@ -46,7 +47,7 @@ public bool ShowAuthenticationCodePrompt(bool isSms, out string authenticationCo
4647
{
4748
var viewModel = new Login2FaViewModel(isSms ? TwoFactorType.Sms : TwoFactorType.AuthenticatorApp);
4849

49-
bool valid = _gui.ShowViewModel(viewModel, () => new GitHubDialogWindow(viewModel, new Login2FaView()));
50+
bool valid = _gui.ShowDialogWindow(viewModel, () => new Login2FaView());
5051

5152
authenticationCode = valid ? viewModel.AuthenticationCode : null;
5253

src/windows/GitHub.UI.Windows/Colors.xaml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,7 @@
4545
<Color x:Key="TextBoxTextDisabled">yellow</Color>
4646
<Color x:Key="TextBoxBorderDisabled">black</Color>
4747

48-
<Color x:Key="WindowPanel">#FBFBFB</Color>
49-
<Color x:Key="WindowPanelText">#1E1E1E</Color>
50-
<Color x:Key="WindowBorder">#CCCEDB</Color>
5148

52-
<Color x:Key="WindowButton">#FBFBFB</Color>
53-
<Color x:Key="WindowButtonGlyph">#332C21</Color>
54-
55-
<Color x:Key="WindowButtonHover">#FCD8A2</Color>
56-
<Color x:Key="WindowButtonHoverGlyph">#332C21</Color>
57-
<Color x:Key="WindowButtonHoverBorder">#FFFFFF</Color>
58-
59-
<Color x:Key="WindowButtonDown">#FCD8A2</Color>
60-
<Color x:Key="WindowButtonDownGlyph">#332C21</Color>
61-
<Color x:Key="WindowButtonDownBorder">#FFFFFF</Color>
6249

6350
<Color x:Key="ToolWindowBackground">#F1F1F1</Color>
6451
<Color x:Key="ToolWindowText">#F1F1F1</Color>
@@ -106,18 +93,5 @@
10693
<SolidColorBrush x:Key="TextBoxTextDisabledBrush" Color="{DynamicResource TextBoxTextDisabled}" />
10794
<SolidColorBrush x:Key="TextBoxBorderDisabledBrush" Color="{DynamicResource TextBoxBorderDisabled}" />
10895

109-
<SolidColorBrush x:Key="WindowPanelBrush" Color="{DynamicResource WindowPanel}" />
110-
<SolidColorBrush x:Key="WindowPanelTextBrush" Color="{DynamicResource WindowPanelText}" />
111-
<SolidColorBrush x:Key="WindowBorderBrush" Color="{DynamicResource WindowBorder}" />
112-
113-
<SolidColorBrush x:Key="WindowButtonBrush" Color="{DynamicResource WindowButton}" />
114-
<SolidColorBrush x:Key="WindowButtonGlyphBrush" Color="{DynamicResource WindowButtonGlyph}" />
115-
116-
<SolidColorBrush x:Key="WindowButtonHoverBrush" Color="{DynamicResource WindowButtonHover}" />
117-
<SolidColorBrush x:Key="WindowButtonHoverGlyphBrush" Color="{DynamicResource WindowButtonHoverGlyph}" />
118-
<SolidColorBrush x:Key="WindowButtonHoverBorderBrush" Color="{DynamicResource WindowButtonHoverBorder}" />
11996

120-
<SolidColorBrush x:Key="WindowButtonDownBrush" Color="{DynamicResource WindowButtonDown}" />
121-
<SolidColorBrush x:Key="WindowButtonDownGlyphBrush" Color="{DynamicResource WindowButtonDownGlyph}" />
122-
<SolidColorBrush x:Key="WindowButtonDownBorderBrush" Color="{DynamicResource WindowButtonDownBorder}" />
12397
</ResourceDictionary>

src/windows/GitHub.UI.Windows/Controls/IShortcutContainer.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/windows/GitHub.UI.Windows/Dialog/GitHubDialogWindow.xaml

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/windows/GitHub.UI.Windows/Dialog/GitHubDialogWindow.xaml.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/windows/GitHub.UI.Windows/GitHub.UI.Windows.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
<ItemGroup>
1313
<ProjectReference Include="..\..\shared\Microsoft.Git.CredentialManager\Microsoft.Git.CredentialManager.csproj" />
14+
<ProjectReference Include="..\Shared.UI.Windows\Shared.UI.Windows.csproj" />
1415
</ItemGroup>
1516

1617
<ItemGroup Condition="'$(OSPlatform)' != 'windows'">

src/windows/GitHub.UI.Windows/Login/Login2FaView.xaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:controls="clr-namespace:GitHub.UI.Controls"
55
xmlns:octicons="clr-namespace:GitHub.UI.Octicons"
6-
Style="{DynamicResource DialogUserControl}"
7-
Background="{DynamicResource WindowPanelBrush}"
8-
Foreground="{DynamicResource WindowPanelTextBrush}">
6+
Style="{DynamicResource DialogUserControl}">
97

108
<Control.Resources>
119
<ResourceDictionary>
@@ -18,10 +16,10 @@
1816
<StackPanel Style="{DynamicResource DialogContainerStackPanel}">
1917
<octicons:OcticonImage Icon="logo_github" Style="{DynamicResource GitHubLogo}" />
2018
<WrapPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="0,0,0,12">
21-
<TextBlock Text="Two-factor authentication"
22-
Padding="0"
19+
<TextBlock Text="Two-factor authentication"
20+
Padding="0"
2321
Margin="0,0,12,0"
24-
Style="{DynamicResource GitHubH1TextBlock}"
22+
Style="{DynamicResource GitHubH1TextBlock}"
2523
x:Uid="titleBlock"/>
2624
</WrapPanel>
2725

src/windows/GitHub.UI.Windows/Login/Login2FaViewModel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using Microsoft.Git.CredentialManager;
2-
using System.Windows.Input;
1+
using System.Windows.Input;
2+
using Microsoft.Git.CredentialManager;
3+
using Microsoft.Git.CredentialManager.UI;
4+
using Microsoft.Git.CredentialManager.UI.ViewModels;
35

46
namespace GitHub.UI.Login
57
{

src/windows/GitHub.UI.Windows/Login/LoginCredentialsView.xaml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<UserControl x:Class="GitHub.UI.Login.LoginCredentialsView"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
Style="{DynamicResource DialogUserControl}"
66
xmlns:controls="clr-namespace:GitHub.UI.Controls"
7-
xmlns:converters="clr-namespace:GitHub.UI.Converters"
7+
xmlns:sharedControls="clr-namespace:Microsoft.Git.CredentialManager.UI.Controls;assembly=Microsoft.Git.CredentialManager.UI"
8+
xmlns:sharedConverters="clr-namespace:Microsoft.Git.CredentialManager.UI.Converters;assembly=Microsoft.Git.CredentialManager.UI"
89
xmlns:octicons="clr-namespace:GitHub.UI.Octicons"
9-
Background="{DynamicResource WindowPanelBrush}"
10-
Foreground="{DynamicResource WindowPanelTextBrush}"
1110
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
1211
mc:Ignorable="d"
1312
d:DesignWidth="414"
@@ -18,23 +17,23 @@
1817
<ResourceDictionary.MergedDictionaries>
1918
<ResourceDictionary Source="..\Styles.xaml" />
2019
</ResourceDictionary.MergedDictionaries>
21-
<converters:NonEmptyStringToVisibleConverter x:Key="NonEmptyStringToVisibleConverter" />
22-
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
23-
<converters:BooleanAndVisibilityConverter x:Key="BooleanAndVisibilityConverter" />
20+
<sharedConverters:NonEmptyStringToVisibleConverter x:Key="NonEmptyStringToVisibleConverter" />
21+
<sharedConverters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
22+
<sharedConverters:BooleanAndVisibilityConverter x:Key="BooleanAndVisibilityConverter" />
2423
</ResourceDictionary>
2524
</Control.Resources>
2625

2726
<DockPanel Style="{DynamicResource DialogContainerDockPanel}">
2827
<DockPanel.Resources>
29-
<Style TargetType="{x:Type controls:PromptTextBox}"
30-
BasedOn="{StaticResource {x:Type controls:PromptTextBox}}">
28+
<Style TargetType="{x:Type sharedControls:PromptTextBox}"
29+
BasedOn="{StaticResource {x:Type sharedControls:PromptTextBox}}">
3130
<Setter Property="Margin" Value="0" />
3231
</Style>
3332
<Style TargetType="{x:Type Border}" x:Key="LoginButtonBorder">
3433
<Setter Property="Margin" Value="0,0,0,15" />
3534
<Setter Property="HorizontalAlignment" Value="Center" />
3635
</Style>
37-
<Style TargetType="{x:Type controls:SecurePasswordBox}" BasedOn="{StaticResource {x:Type controls:SecurePasswordBox}}">
36+
<Style TargetType="{x:Type sharedControls:SecurePasswordBox}" BasedOn="{StaticResource {x:Type sharedControls:SecurePasswordBox}}">
3837
<Setter Property="Margin" Value="0" />
3938
</Style>
4039
</DockPanel.Resources>
@@ -47,7 +46,7 @@
4746
Margin="0,0,0,10"
4847
Style="{DynamicResource GitHubH1TextBlock}"
4948
IsHitTestVisible="False"
50-
Text="Sign in"
49+
Text="Sign in"
5150
x:Uid="loginLabel"/>
5251

5352
<controls:HorizontalShadowDivider Margin="0" />
@@ -83,18 +82,18 @@
8382
<StackPanel VerticalAlignment="Center" x:Name="dotComloginControlsPanel" Margin="0,0,0,30">
8483
<StackPanel>
8584
<StackPanel Visibility="{Binding IsLoginUsingUsernameAndPasswordVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
86-
<controls:PromptTextBox Text="{Binding UsernameOrEmail, UpdateSourceTrigger=PropertyChanged, Delay=300}"
87-
PromptText="Username or email"
88-
Margin="0,0,0,10"
89-
x:Uid="loginBox"
90-
x:Name="loginBox"
91-
Localization.Attributes="PromptText (Modifiable Readable Text)"/>
85+
<sharedControls:PromptTextBox Text="{Binding UsernameOrEmail, UpdateSourceTrigger=PropertyChanged, Delay=300}"
86+
PromptText="Username or email"
87+
Margin="0,0,0,10"
88+
x:Uid="loginBox"
89+
x:Name="loginBox"
90+
Localization.Attributes="PromptText (Modifiable Readable Text)"/>
9291

93-
<controls:SecurePasswordBox Password="{Binding Password, UpdateSourceTrigger=PropertyChanged, Delay=300, Mode=OneWayToSource}"
94-
PromptText="Password"
95-
x:Uid="passwordBox"
96-
x:Name="passwordBox"
97-
Localization.Attributes="PromptText (Modifiable Readable Text)"/>
92+
<sharedControls:SecurePasswordBox Password="{Binding Password, UpdateSourceTrigger=PropertyChanged, Delay=300, Mode=OneWayToSource}"
93+
PromptText="Password"
94+
x:Uid="passwordBox"
95+
x:Name="passwordBox"
96+
Localization.Attributes="PromptText (Modifiable Readable Text)"/>
9897

9998
<Border Style="{StaticResource LoginButtonBorder}" Margin="0 16 0 0">
10099
<Button Content="Sign in"

0 commit comments

Comments
 (0)