Skip to content

Commit

Permalink
background images are real
Browse files Browse the repository at this point in the history
  • Loading branch information
Eimaen committed Feb 24, 2023
1 parent 3ffbda4 commit 2725688
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 53 deletions.
10 changes: 10 additions & 0 deletions JustAsPlanned/JustAsPlanned.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -87,5 +88,14 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\marisa.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\koishi.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\youmu.jpg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
18 changes: 13 additions & 5 deletions JustAsPlanned/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<Border.Effect>
<DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" ShadowDepth="1" Color="Black" />
</Border.Effect>
<Border x:Name="bMain" BorderBrush="Transparent" Background="#FF22173C" CornerRadius="10">

<Border x:Name="bMain" BorderBrush="Transparent" CornerRadius="10">
<Border.OpacityMask>
<VisualBrush>
<VisualBrush.Visual>
Expand All @@ -26,9 +25,18 @@
</VisualBrush>
</Border.OpacityMask>
<Grid>
<Border x:Name="bProgress" Background="white" Opacity="0.05" HorizontalAlignment="Left" Width="0" Margin="0,0,0,0"/>
<Label Content="Just As Planned" Foreground="White" Margin="0,27,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="32" FontWeight="Bold" Width="382"/>
<Label x:Name="lblStatus" Content="Initializing..." Foreground="White" Margin="0,80,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="20" Width="550"/>
<Grid x:Name="gridBackgroundImage" Panel.ZIndex="1" Visibility="Visible"/>
<Grid x:Name="gridBackgroundBlur" Panel.ZIndex="2" Visibility="Visible">
<Grid.Background>
<SolidColorBrush Color="Black" Opacity=".5"/>
</Grid.Background>
</Grid>
<Grid x:Name="gridContent" Panel.ZIndex="3" Visibility="Visible">
<Border x:Name="bProgress" Background="White" Opacity="0.2" HorizontalAlignment="Left" Width="0" Margin="0,0,0,0"/>
<Label Content="Just As Planned" Foreground="White" Margin="0,27,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="32" FontWeight="Bold" Width="382"/>
<Label x:Name="lblStatus" Content="Initializing..." Foreground="White" Margin="0,80,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="20" Width="550"/>
<Label x:Name="lblCopyright" Content="" Foreground="#AAAAAA" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="10" MouseDown="OpenCopyrightReference"/>
</Grid>
</Grid>
</Border>
</Border>
Expand Down
76 changes: 71 additions & 5 deletions JustAsPlanned/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -12,6 +14,7 @@
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
Expand Down Expand Up @@ -48,14 +51,14 @@ void UpdateProgress()

void DisplayCriticalFailture() => Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
{
ColorAnimation ca = new ColorAnimation(Color.FromRgb(110, 5, 5), new Duration(TimeSpan.FromSeconds(2)));
bMain.Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
ColorAnimation ca = new ColorAnimation(System.Windows.Media.Color.FromRgb(110, 5, 5), new Duration(TimeSpan.FromSeconds(2)));
gridBackgroundBlur.Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
}));

void DisplaySuccess() => Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
{
ColorAnimation ca = new ColorAnimation(Color.FromRgb(5, 110, 5), new Duration(TimeSpan.FromSeconds(2)));
bMain.Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
ColorAnimation ca = new ColorAnimation(System.Windows.Media.Color.FromRgb(5, 110, 5), new Duration(TimeSpan.FromSeconds(2)));
gridBackgroundBlur.Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
}));

private void Run()
Expand Down Expand Up @@ -90,6 +93,7 @@ private void Run()
steamInstallationPath = System.IO.Path.Combine(steamInstallationPath.ToString(), "steam.exe");
actualProgress = 20;
UpdateStatus("Starting Muse Dash via Steam...");
Thread.Sleep(3000);
if (File.Exists(steamInstallationPath as string))
{
Process.Start(new ProcessStartInfo
Expand All @@ -101,7 +105,7 @@ private void Run()
else
{
DisplayCriticalFailture();
UpdateStatus("How? Steam is running and doesn't exist?! Contact devs NOW.");
UpdateStatus("How? Steam is running and doesn't exist?! Contact devs.");
Thread.Sleep(5000);
Environment.Exit(0);
}
Expand Down Expand Up @@ -158,16 +162,78 @@ private void Run()
threadMain.Start();
}

private struct BackgroundImage
{
public string CopyrightMessage;
public string SourceUrl;
public Bitmap Image;
}

private List<BackgroundImage> backgroundImages = new List<BackgroundImage>
{
new BackgroundImage {
SourceUrl = "https://www.pixiv.net/en/artworks/81691677",
CopyrightMessage = "Artwork by U-Joe, Pixiv ID: 81691677",
Image = Properties.Resources.Marisa
},
new BackgroundImage {
SourceUrl = "https://www.pixiv.net/en/artworks/105672733",
CopyrightMessage = "Artwork by Lanana, Pixiv ID: 105672733",
Image = Properties.Resources.Koishi
},
new BackgroundImage {
SourceUrl = "https://www.pixiv.net/en/artworks/64961553",
CopyrightMessage = "Artwork by 鳥成, Pixiv ID: 64961553",
Image = Properties.Resources.Youmu
}
};

BackgroundImage currentBackgroundImageData;

[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteObject([In] IntPtr hObject);

public ImageSource ImageSourceFromBitmap(Bitmap bmp)
{
var handle = bmp.GetHbitmap();
try
{
return Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
finally { DeleteObject(handle); }
}

public void LoadBackgroundImage()
{
currentBackgroundImageData = backgroundImages.OrderBy(x => Guid.NewGuid()).First();
Dispatcher.Invoke(DispatcherPriority.Render, new Action(() =>
{
lblCopyright.Content = currentBackgroundImageData.CopyrightMessage;
gridBackgroundImage.Background = new ImageBrush()
{
ImageSource = ImageSourceFromBitmap(currentBackgroundImageData.Image),
Stretch = Stretch.UniformToFill
};
}));
}

public MainWindow()
{
InitializeComponent();
LoadBackgroundImage();
Closed += OnClosedEvent;
MouseDown += OnDragEvent;
updateProgressThread = new Thread(UpdateProgress);
updateProgressThread.Start();
Run();
}

private void OpenCopyrightReference(object sender, MouseButtonEventArgs e)
{
Process.Start(currentBackgroundImageData.SourceUrl);
}

private void OnDragEvent(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
Expand Down
98 changes: 60 additions & 38 deletions JustAsPlanned/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions JustAsPlanned/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
Expand All @@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
Expand All @@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
Expand All @@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
Expand All @@ -109,9 +112,19 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Koishi" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\koishi.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Marisa" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\marisa.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Youmu" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\youmu.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added JustAsPlanned/Resources/koishi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added JustAsPlanned/Resources/marisa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added JustAsPlanned/Resources/youmu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2725688

Please sign in to comment.