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

a reasonable implementation of Aero2 #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Bililive_dm/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</Style>
</ResourceDictionary>
<ResourceDictionary x:Key="Default" Source="/PresentationFramework.Luna,Version=0.0.0.0,PublicKeyToken=31bf3856ad364e35;component/Themes/Luna.NormalColor.xaml"/>
<ResourceDictionary x:Key="Win8" Source="/PresentationTheme.Aero.Win8;component/Themes/Aero.Win8.NormalColor.xaml"/>
</ResourceDictionary>
</Application.Resources>

Expand Down
33 changes: 33 additions & 0 deletions Bililive_dm/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Bililive_dm
/// </summary>
public partial class App: Application
{
internal ResourceDictionary AeroWin8 { get; private set; }
internal Collection<ResourceDictionary> merged { get; private set; }

public App()
Expand Down Expand Up @@ -92,6 +93,38 @@ private void AddArchSpecificDirectory()

private void Application_Startup(object sender, StartupEventArgs e)
{
var assemblies = new Dictionary<string, Assembly>(StringComparer.OrdinalIgnoreCase);

AppDomain.CurrentDomain.AssemblyResolve += (_, args) =>
{
var an = new AssemblyName(args.Name);
var name = an.Name;

switch (name)
{
case "PresentationTheme.Aero":
case "PresentationTheme.Aero.Win8":
break;
default:
return null;
}

if (assemblies.TryGetValue(name, out var assembly)) return assembly;

var ms = new MemoryStream();
using (var rs = Assembly.GetExecutingAssembly().GetManifestResourceStream($"Bililive_dm.Assets.{name}.dll.gz"))
using (var zs = new GZipStream(rs, CompressionMode.Decompress))
zs.CopyTo(ms);

var data = new byte[ms.Length];
ms.Position = 0;
ms.Read(data, 0, data.Length);

return assemblies[name] = Assembly.Load(data);
};

AeroWin8 = (ResourceDictionary)Resources["Win8"];

merged = Resources.MergedDictionaries;
merged.Add((ResourceDictionary)Resources["Default"]);
}
Expand Down
Binary file not shown.
Binary file added Bililive_dm/Assets/PresentationTheme.Aero.dll.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions Bililive_dm/Bililive_dm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
<EmbeddedResource Include="Assets\PresentationTheme.Aero.dll.gz" />
<EmbeddedResource Include="Assets\PresentationTheme.Aero.Win8.dll.gz" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BilibiliDM_PluginFramework\BilibiliDM_PluginFramework.csproj">
Expand Down
8 changes: 8 additions & 0 deletions Bililive_dm/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,14 @@ private void Skin_Click(object sender, RoutedEventArgs e)
if (selector.Select() is ResourceDictionary result)
{
App.Current.merged[0] = result;

if (result != App.Current.AeroWin8) return;

Skin.Click -= Skin_Click;

Skin.ToolTip = "既然被你發現了,就不能輕易讓你離開了!";
ToolTipService.SetShowOnDisabled(Skin, true);
Skin.IsEnabled = false;
}
merged[0] = new ResourceDictionary();
}
Expand Down
4 changes: 2 additions & 2 deletions Bililive_dm/Selector.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void Button_Click(object sender, RoutedEventArgs e)
public ResourceDictionary Select()
{
if (!ShowDialog().GetValueOrDefault()) return null;
return selected ?? new ResourceDictionary();
return selected ?? App.Current.AeroWin8;
}

private void list_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand All @@ -80,7 +80,7 @@ private void list_MouseDoubleClick(object sender, MouseButtonEventArgs e)
private void list_Loaded(object sender, RoutedEventArgs e)
{
var li = (UIElement)list.ItemContainerGenerator.ContainerFromItem(list.SelectedItem);
li?.Focus();
li.Focus();
}
}
}