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

Commit 4f13637

Browse files
committed
Move all the styles to VS.UI, style infopanel
1 parent 9c8daef commit 4f13637

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+438
-368
lines changed

src/GitHub.App/SampleData/SampleViewModels.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,9 @@ public bool OpenRepository()
493493

494494
public IConnection SectionConnection { get; }
495495
}
496+
497+
public class InfoPanelDesigner
498+
{
499+
public string Message => "This is an informational message for the info panel to test things in design mode. This is not meant to be run in release.";
500+
}
496501
}

src/GitHub.TeamFoundation.14/Home/PullRequestsNavigationItem.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ public class PullRequestsNavigationItem : TeamExplorerNavigationItemBase
1919
{
2020
public const string PullRequestsNavigationItemId = "5245767A-B657-4F8E-BFEE-F04159F1DDA3";
2121

22-
readonly Lazy<IVisualStudioBrowser> browser;
2322
readonly IMenuProvider menuProvider;
2423

2524
[ImportingConstructor]
26-
public PullRequestsNavigationItem(ISimpleApiClientFactory apiFactory, Lazy<IVisualStudioBrowser> browser,
27-
ITeamExplorerServiceHolder holder, IMenuProvider menuProvider)
25+
public PullRequestsNavigationItem(ISimpleApiClientFactory apiFactory,
26+
ITeamExplorerServiceHolder holder, IMenuProvider menuProvider)
2827
: base(apiFactory, holder, Octicon.git_pull_request)
2928
{
30-
this.browser = browser;
3129
this.menuProvider = menuProvider;
3230
Text = Resources.PullRequestsNavigationItemText;
3331
ArgbColor = Colors.RedNavigationItem.ToInt32();

src/GitHub.UI/Assets/Buttons.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<ResourceDictionary.MergedDictionaries>
1111
<ResourceDictionary Source="../Controls/Buttons/OcticonCircleButton.xaml" />
1212
<ResourceDictionary Source="../Controls/Buttons/OcticonLinkButton.xaml" />
13+
<ResourceDictionary Source="../Controls/Buttons/OcticonButton.xaml" />
1314
<ResourceDictionary Source="../Controls/ToggleButtons/OcticonCircleToggleButton.xaml" />
1415
<ResourceDictionary Source="../Controls/ToggleButtons/OcticonLinkToggleButton.xaml" />
1516
</ResourceDictionary.MergedDictionaries>

src/GitHub.UI/Controls/Buttons/OcticonButton.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using NullGuard;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
@@ -7,7 +8,7 @@
78

89
namespace GitHub.UI
910
{
10-
public class OcticonButton: Button
11+
public class OcticonButton : Button
1112
{
1213
public static readonly DependencyProperty IconRotationAngleProperty = DependencyProperty.Register(
1314
"IconRotationAngle", typeof(double), typeof(OcticonButton),
@@ -18,5 +19,15 @@ public double IconRotationAngle
1819
get { return (double)GetValue(IconRotationAngleProperty); }
1920
set { SetValue(IconRotationAngleProperty, value); }
2021
}
22+
23+
public static DependencyProperty IconProperty =
24+
OcticonPath.IconProperty.AddOwner(typeof(OcticonButton));
25+
26+
public Octicon Icon
27+
{
28+
[return: AllowNull]
29+
get { return (Octicon)GetValue(OcticonPath.IconProperty); }
30+
set { SetValue(OcticonPath.IconProperty, value); }
31+
}
2132
}
2233
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:GitHub.UI">
2+
3+
<Style x:Key="OcticonButton" TargetType="{x:Type ui:OcticonButton}">
4+
<Setter Property="Focusable" Value="True"/>
5+
<Setter Property="Foreground" Value="Black"/>
6+
<Setter Property="Height" Value="16"/>
7+
<Setter Property="Width" Value="16"/>
8+
<Setter Property="HorizontalAlignment" Value="Center"/>
9+
<Setter Property="VerticalAlignment" Value="Center"/>
10+
<Setter Property="Template">
11+
<Setter.Value>
12+
<ControlTemplate TargetType="ui:OcticonButton">
13+
<Grid x:Name="content" Background="Transparent">
14+
<Grid.ColumnDefinitions>
15+
<ColumnDefinition Width="Auto"/>
16+
</Grid.ColumnDefinitions>
17+
<ui:FixedAspectRatioPanel HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsHitTestVisible="False">
18+
<Viewbox>
19+
<ui:OcticonPath Height="16"
20+
Fill="{TemplateBinding Foreground}"
21+
Icon="{TemplateBinding Icon}"
22+
SnapsToDevicePixels="True"/>
23+
</Viewbox>
24+
</ui:FixedAspectRatioPanel>
25+
</Grid>
26+
<ControlTemplate.Triggers>
27+
<Trigger Property="IsMouseOver" Value="True">
28+
<Setter TargetName="content" Property="Background" Value="#11FFFFFF"/>
29+
</Trigger>
30+
<Trigger Property="IsPressed" Value="True">
31+
<Setter TargetName="content" Property="Background" Value="#11FFFFFF"/>
32+
</Trigger>
33+
</ControlTemplate.Triggers>
34+
</ControlTemplate>
35+
</Setter.Value>
36+
</Setter>
37+
</Style>
38+
39+
<Style BasedOn="{StaticResource OcticonButton}" TargetType="{x:Type ui:OcticonButton}"/>
40+
</ResourceDictionary>

src/GitHub.UI/Controls/Buttons/OcticonCircleButton.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ public class OcticonCircleButton : OcticonButton
2828
FrameworkPropertyMetadataOptions.AffectsMeasure |
2929
FrameworkPropertyMetadataOptions.AffectsRender));
3030

31-
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
32-
"Icon", typeof(Octicon), typeof(OcticonCircleButton),
33-
new FrameworkPropertyMetadata(defaultValue: Octicon.mark_github, flags:
34-
FrameworkPropertyMetadataOptions.AffectsArrange |
35-
FrameworkPropertyMetadataOptions.AffectsMeasure |
36-
FrameworkPropertyMetadataOptions.AffectsRender,
37-
propertyChangedCallback: OnIconChanged
38-
)
39-
);
40-
4131
public bool ShowSpinner
4232
{
4333
get { return (bool)GetValue(ShowSpinnerProperty); }
@@ -78,13 +68,6 @@ public double IconSize
7868
set { SetValue(IconSizeProperty, value); }
7969
}
8070

81-
public Octicon Icon
82-
{
83-
[return: AllowNull]
84-
get { return (Octicon)GetValue(OcticonPath.IconProperty); }
85-
set { SetValue(OcticonPath.IconProperty, value); }
86-
}
87-
8871
public Geometry Data
8972
{
9073
[return: AllowNull]

src/GitHub.UI/Controls/Buttons/OcticonLinkButton.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ namespace GitHub.UI
1616
{
1717
public partial class OcticonLinkButton : OcticonButton
1818
{
19-
public Octicon Icon
20-
{
21-
get { return (Octicon)GetValue(OcticonPath.IconProperty); }
22-
set { SetValue(OcticonPath.IconProperty, value); }
23-
}
24-
2519
public Geometry Data
2620
{
2721
[return: AllowNull]

src/GitHub.UI/Controls/Octicons/OcticonPath.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public class OcticonPath : Shape
2828
new FrameworkPropertyMetadata(defaultValue: Octicon.mark_github, flags:
2929
FrameworkPropertyMetadataOptions.AffectsArrange |
3030
FrameworkPropertyMetadataOptions.AffectsMeasure |
31-
FrameworkPropertyMetadataOptions.AffectsRender
31+
FrameworkPropertyMetadataOptions.AffectsRender,
32+
propertyChangedCallback: OnIconChanged
3233
)
3334
);
3435

@@ -85,5 +86,9 @@ static Geometry LoadGeometry(Octicon icon)
8586

8687
return path;
8788
}
89+
static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
90+
{
91+
d.SetValue(Path.DataProperty, OcticonPath.GetGeometryForIcon((Octicon)e.NewValue));
92+
}
8893
}
8994
}

src/GitHub.UI/GitHub.UI.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@
194194
<Generator>MSBuild:Compile</Generator>
195195
<SubType>Designer</SubType>
196196
</Page>
197+
<Page Include="Controls\Buttons\OcticonButton.xaml">
198+
<Generator>MSBuild:Compile</Generator>
199+
<SubType>Designer</SubType>
200+
</Page>
197201
<Page Include="Controls\Buttons\OcticonLinkButton.xaml">
198202
<Generator>MSBuild:Compile</Generator>
199203
<SubType>Designer</SubType>

src/GitHub.VisualStudio.UI/GitHub.VisualStudio.UI.csproj

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,31 @@
1313
<FileAlignment>512</FileAlignment>
1414
<OutputPath>..\..\build\$(Configuration)\</OutputPath>
1515
<BuildType Condition="Exists('..\..\script\src\ApiClientConfiguration.cs')">Internal</BuildType>
16-
<NuGetPackageImportStamp>
17-
</NuGetPackageImportStamp>
18-
<TargetFrameworkProfile />
16+
<WarningLevel>4</WarningLevel>
17+
<RunCodeAnalysis>true</RunCodeAnalysis>
18+
<CodeAnalysisRuleSet>..\common\GitHubVS.ruleset</CodeAnalysisRuleSet>
19+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
20+
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
1921
</PropertyGroup>
2022
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2123
<DebugSymbols>true</DebugSymbols>
2224
<DebugType>full</DebugType>
2325
<Optimize>false</Optimize>
24-
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS</DefineConstants>
2527
<ErrorReport>prompt</ErrorReport>
26-
<WarningLevel>4</WarningLevel>
2728
</PropertyGroup>
2829
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2930
<DebugType>pdbonly</DebugType>
3031
<Optimize>true</Optimize>
3132
<DefineConstants>TRACE</DefineConstants>
3233
<ErrorReport>prompt</ErrorReport>
33-
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
3535
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'XamlDesign|AnyCPU'">
3636
<DebugSymbols>true</DebugSymbols>
3737
<DebugType>full</DebugType>
3838
<Optimize>false</Optimize>
3939
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;XAML_DESIGNER</DefineConstants>
4040
<ErrorReport>prompt</ErrorReport>
41-
<WarningLevel>4</WarningLevel>
42-
<RunCodeAnalysis>true</RunCodeAnalysis>
43-
<CodeAnalysisRuleSet>..\common\GitHubVS.ruleset</CodeAnalysisRuleSet>
44-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
45-
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
4641
<CreateVsixContainer>True</CreateVsixContainer>
4742
<DeployExtension>True</DeployExtension>
4843
<IncludeDebugSymbolsInVSIXContainer>true</IncludeDebugSymbolsInVSIXContainer>
@@ -79,6 +74,7 @@
7974
<Compile Include="Base\TeamExplorerItemBase.cs" />
8075
<Compile Include="Colors.cs" />
8176
<Compile Include="Constants.cs" />
77+
<Compile Include="Helpers\SharedDictionaryManager.cs" />
8278
<Compile Include="RepositoryOrigin.cs" />
8379
<Compile Include="Resources.Designer.cs">
8480
<DependentUpon>Resources.resx</DependentUpon>
@@ -107,15 +103,40 @@
107103
</Compile>
108104
<Compile Include="Properties\AssemblyInfo.cs" />
109105
<None Include="packages.config" />
110-
<Compile Include="..\common\SharedDictionaryManager.cs">
111-
<Link>Helpers\SharedDictionaryManager.cs</Link>
112-
</Compile>
113106
</ItemGroup>
114107
<ItemGroup>
115108
<Page Include="SharedDictionary.xaml">
116109
<Generator>MSBuild:Compile</Generator>
117110
<SubType>Designer</SubType>
118111
</Page>
112+
<Page Include="Styles\ActionLinkButton.xaml">
113+
<Generator>MSBuild:Compile</Generator>
114+
<SubType>Designer</SubType>
115+
</Page>
116+
<Page Include="Styles\Buttons.xaml">
117+
<Generator>MSBuild:Compile</Generator>
118+
<SubType>Designer</SubType>
119+
</Page>
120+
<Page Include="Styles\GitHubActionLink.xaml">
121+
<Generator>MSBuild:Compile</Generator>
122+
<SubType>Designer</SubType>
123+
</Page>
124+
<Page Include="Styles\GitHubComboBox.xaml">
125+
<Generator>MSBuild:Compile</Generator>
126+
<SubType>Designer</SubType>
127+
</Page>
128+
<Page Include="Styles\GitHubTabControl.xaml">
129+
<Generator>MSBuild:Compile</Generator>
130+
<SubType>Designer</SubType>
131+
</Page>
132+
<Page Include="Styles\LinkDropDown.xaml">
133+
<Generator>MSBuild:Compile</Generator>
134+
<SubType>Designer</SubType>
135+
</Page>
136+
<Page Include="Styles\TextBlocks.xaml">
137+
<Generator>MSBuild:Compile</Generator>
138+
<SubType>Designer</SubType>
139+
</Page>
119140
<Page Include="Styles\ThemeBlue.xaml">
120141
<Generator>MSBuild:Compile</Generator>
121142
<SubType>Designer</SubType>
@@ -181,6 +202,7 @@
181202
<SubType>Designer</SubType>
182203
</EmbeddedResource>
183204
</ItemGroup>
205+
<ItemGroup />
184206
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
185207
<Import Project="..\..\packages\Fody.1.28.0\build\Fody.targets" Condition="Exists('..\..\packages\Fody.1.28.0\build\Fody.targets')" />
186208
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Windows;
4+
using Microsoft.VisualStudio.PlatformUI;
5+
using GitHub.VisualStudio.Helpers;
6+
7+
namespace GitHub.VisualStudio.UI.Helpers
8+
{
9+
public class SharedDictionaryManager : ResourceDictionary
10+
{
11+
public SharedDictionaryManager()
12+
{
13+
currentTheme = Colors.DetectTheme();
14+
}
15+
16+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
17+
string currentTheme;
18+
19+
#if !XAML_DESIGNER
20+
static readonly Dictionary<Uri, ResourceDictionary> resourceDicts = new Dictionary<Uri, ResourceDictionary>();
21+
static string baseThemeUri = "pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/";
22+
23+
Uri sourceUri;
24+
bool themed = false;
25+
public new Uri Source
26+
{
27+
get { return sourceUri; }
28+
set
29+
{
30+
if (value.ToString() == "pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/ThemeDesignTime.xaml")
31+
{
32+
if (!themed)
33+
{
34+
themed = true;
35+
VSColorTheme.ThemeChanged += OnThemeChange;
36+
}
37+
value = new Uri(baseThemeUri + "Theme" + currentTheme + ".xaml");
38+
}
39+
40+
sourceUri = value;
41+
ResourceDictionary ret;
42+
if (resourceDicts.TryGetValue(value, out ret))
43+
{
44+
if (ret != this)
45+
{
46+
MergedDictionaries.Add(ret);
47+
return;
48+
}
49+
}
50+
base.Source = value;
51+
if (ret == null)
52+
resourceDicts.Add(value, this);
53+
}
54+
}
55+
56+
void OnThemeChange(ThemeChangedEventArgs e)
57+
{
58+
var uri = new Uri(baseThemeUri + "Theme" + currentTheme + ".xaml");
59+
ResourceDictionary ret;
60+
if (resourceDicts.TryGetValue(uri, out ret))
61+
MergedDictionaries.Remove(ret);
62+
currentTheme = Colors.DetectTheme();
63+
Source = uri;
64+
}
65+
#endif
66+
}
67+
}

0 commit comments

Comments
 (0)