Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 1507ada

Browse files
Starting to display the RepositoryPublishView
co-authored-by: Jamie Cansdale <[email protected]>
1 parent d0a1cd8 commit 1507ada

File tree

6 files changed

+44
-12
lines changed

6 files changed

+44
-12
lines changed

src/GitHub.VisualStudio.16/GitHub.VisualStudio.16.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
8989
<IncludeInVSIX>true</IncludeInVSIX>
9090
</Content>
91+
<Content Include="UI\GitHub.Resources.dll">
92+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
93+
<IncludeInVSIX>true</IncludeInVSIX>
94+
</Content>
9195
<None Include="source.extension.vsixmanifest">
9296
<SubType>Designer</SubType>
9397
</None>

src/GitHub.VisualStudio.16/Sync/PublishSection.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44
*/
55
using System;
66
using System.ComponentModel;
7+
using System.Windows.Input;
8+
using GitHub.Factories;
9+
using GitHub.Primitives;
10+
using GitHub.ViewModels.TeamExplorer;
711
using Microsoft.TeamFoundation.Controls;
12+
using Microsoft.VisualStudio.ComponentModelHost;
13+
using GitHub.VisualStudio;
14+
using Microsoft.VisualStudio.Threading;
15+
using Task = System.Threading.Tasks.Task;
816

917
namespace Microsoft.TeamExplorerSample.Sync
1018
{
@@ -19,7 +27,7 @@ public class PublishSection : TeamExplorerBaseSection
1927

2028
readonly Guid PushToRemoteSectionId = new Guid("99ADF41C-0022-4C03-B3C2-05047A3F6C2C");
2129
readonly Guid GitHubPublishSectionId = new Guid("92655B52-360D-4BF5-95C5-D9E9E596AC76");
22-
30+
2331
/// <summary>
2432
/// Constructor.
2533
/// </summary>
@@ -29,7 +37,9 @@ public PublishSection()
2937
this.Title = "Publish to GitHub";
3038
this.IsExpanded = true;
3139
this.IsBusy = false;
32-
this.SectionContent = new PublishView();
40+
this.SectionContent = new PublishView(){
41+
DataContext = this
42+
};
3343
this.View.ParentSection = this;
3444
}
3545

@@ -41,6 +51,8 @@ protected PublishView View
4151
get { return this.SectionContent as PublishView; }
4252
}
4353

54+
public ICommand PublishToGitHub { get; set; }
55+
4456
/// <summary>
4557
/// Initialize override.
4658
/// </summary>
@@ -62,8 +74,31 @@ public override void Initialize(object sender, SectionInitializeEventArgs e)
6274
gitHubPublishSection.PropertyChanged += Section_PropertyChanged;
6375
}
6476
}
77+
78+
PublishToGitHub = new RelayCommand(o => DoPublishToGitHub().Forget());
6579
}
6680

81+
async Task DoPublishToGitHub()
82+
{
83+
var componentModel = await Microsoft.VisualStudio.Shell.ServiceProvider.GetGlobalServiceAsync<SComponentModel, IComponentModel>();
84+
ShowPublishDialog(componentModel);
85+
}
86+
87+
void ShowPublishDialog(IComponentModel componentModel)
88+
{
89+
var compositionServices = new CompositionServices();
90+
var compositionContainer = compositionServices.CreateVisualStudioCompositionContainer(componentModel.DefaultExportProvider);
91+
92+
var factory = compositionContainer.GetExportedValue<IViewViewModelFactory>();
93+
var viewModel = compositionContainer.GetExportedValue<IRepositoryPublishViewModel>();
94+
95+
var frameworkElement = factory.CreateView<IRepositoryPublishViewModel>();
96+
frameworkElement.DataContext = viewModel;
97+
98+
this.SectionContent = frameworkElement;
99+
}
100+
101+
67102
void Section_PropertyChanged(object sender, PropertyChangedEventArgs e)
68103
{
69104
switch (e.PropertyName)

src/GitHub.VisualStudio.16/Sync/PublishView.xaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
xmlns:mtcw="clr-namespace:Microsoft.TeamFoundation.Controls.WPF;assembly=Microsoft.TeamFoundation.Controls"
88
xmlns:local="clr-namespace:GitHub.VisualStudio;assembly="
99
mc:Ignorable="d"
10-
d:DesignHeight="300" d:DesignWidth="300"
11-
DataContext="{Binding RelativeSource={RelativeSource Self}}">
10+
d:DesignHeight="300" d:DesignWidth="300">
1211

1312
<UserControl.Resources>
1413
<SolidColorBrush
@@ -67,7 +66,7 @@
6766
</WrapPanel>
6867
<WrapPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Margin="0,0,14,0">
6968
<Button x:Uid="publishARepoButton" x:Name="publishARepoButton"
70-
Grid.Column="0" Content="Publish to GitHub" />
69+
Grid.Column="0" Content="Publish to GitHub" Command="{Binding PublishToGitHub}" />
7170
</WrapPanel>
7271
</Grid>
7372

src/GitHub.VisualStudio.16/Sync/PublishView.xaml.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,5 @@ public PublishSection ParentSection
3939
}
4040
public static readonly DependencyProperty ParentSectionProperty =
4141
DependencyProperty.Register("ParentSection", typeof(PublishSection), typeof(PublishView));
42-
43-
/// <summary>
44-
/// Set encoding button Click event handler.
45-
/// </summary>
46-
private void setEncodingButton_Click(object sender, RoutedEventArgs e)
47-
{
48-
}
4942
}
5043
}
59.5 KB
Binary file not shown.

src/GitHub.VisualStudio.16/source.extension.vsixmanifest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
2020
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="GitHub.VisualStudio.UI.16" d:VsixSubPath="UI" Path="|GitHub.VisualStudio.UI.16|" AssemblyName="|GitHub.VisualStudio.UI.16;AssemblyName|" />
2121
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />
22+
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="UI\GitHub.Resources.dll" AssemblyName="GitHub.Resources, Version=2.10.2.0, Culture=neutral, PublicKeyToken=bc1bd09f2901c82e" d:VsixSubPath="UI" />
2223
</Assets>
2324
</PackageManifest>

0 commit comments

Comments
 (0)