diff --git a/BluescreenSimulator/App.xaml b/BluescreenSimulator/App.xaml
index 6099ee5..b625c1e 100644
--- a/BluescreenSimulator/App.xaml
+++ b/BluescreenSimulator/App.xaml
@@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BluescreenSimulator"
+ xmlns:converters="clr-namespace:BluescreenSimulator.Converters"
Startup="Application_Startup">
@@ -13,5 +14,7 @@
+
+
diff --git a/BluescreenSimulator/App.xaml.cs b/BluescreenSimulator/App.xaml.cs
index 997e90a..6c1cc8e 100644
--- a/BluescreenSimulator/App.xaml.cs
+++ b/BluescreenSimulator/App.xaml.cs
@@ -1,13 +1,16 @@
using System;
using System.Collections.Generic;
+using System.Drawing;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Media;
+using System.Windows.Threading;
using BluescreenSimulator.ViewModels;
using BluescreenSimulator.Views;
-using static BluescreenSimulator.Views.MainWindow;
+using Color = System.Windows.Media.Color;
+using ColorConverter = System.Windows.Media.ColorConverter;
+
namespace BluescreenSimulator
{
public partial class App : Application
@@ -23,11 +26,20 @@ public partial class App : Application
private void Application_Startup(object sender, EventArgs e)
{
-
+ DispatcherUnhandledException += (o, eventArgs) =>
+ {
+ ShowErrorMessage(eventArgs.Exception);
+ eventArgs.Handled = true;
+ };
+ AppDomain.CurrentDomain.UnhandledException +=
+ delegate (object o, UnhandledExceptionEventArgs eventArgs)
+ {
+ ShowErrorMessage(eventArgs.ExceptionObject as Exception);
+ };
var args = Environment.GetCommandLineArgs();
if (args.Length > 1) // #0 is file path
{
- var bluescreenData = new BluescreenDataViewModel();
+ var bluescreenData = new Windows10BluescreenViewModel();
var showHelp = false;
var enableUnsafe = false;
@@ -40,8 +52,8 @@ private void Application_Startup(object sender, EventArgs e)
{ "mi|moreinfo=", "{Text} for More Info", t => bluescreenData.MoreInfo = t },
{ "s|supportperson=", "{Text} for Support Person", t => bluescreenData.SupportPerson = t },
{ "sc|stopcode=", "{Text} for Stop code", t => bluescreenData.StopCode = t },
- { "b|background=", "Background color in rgb {value} hex format (#FFFFFF)", r => bluescreenData.BackgroundColor = (Color)(ColorConverter.ConvertFromString(r) ?? bluescreenData.BackgroundColor) },
- { "f|foreground=", "Foreground (text) in rgb {value} hex format (#FFFFFF)", r => bluescreenData.ForegroundColor = (Color)(ColorConverter.ConvertFromString(r) ?? bluescreenData.ForegroundColor) },
+ { "b|background=", "Background color in rgb {value} hex format (#FFFFFF)", r => bluescreenData.BackgroundColor = TryGetColor(r, bluescreenData.BackgroundColor) },
+ { "f|foreground=", "Foreground (text) in rgb {value} hex format (#FFFFFF)", r => bluescreenData.ForegroundColor = TryGetColor(r, bluescreenData.ForegroundColor) },
{ "oq|origqr", "Use original QR code", o => bluescreenData.UseOriginalQR = o != null },
{ "hq|hideqr", "Hides the QR code", h => bluescreenData.HideQR = h != null },
{ "d|delay=", "Bluescreen Delay {duration} in seconds (0-86400)", (int d) => {
@@ -90,8 +102,7 @@ private void Application_Startup(object sender, EventArgs e)
}
else
{
- void Act() => ShowBluescreenWindow(bluescreenData);
- bluescreenData.ExecuteCommand.Execute((Action) Act);
+ bluescreenData.ShowView();
}
}
else
@@ -100,6 +111,26 @@ private void Application_Startup(object sender, EventArgs e)
}
}
+ private static MessageBoxResult ShowErrorMessage(Exception ex)
+ {
+ return MessageBox.Show($"Sorry, some error occured, {ex}", "Oops",
+ MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+ private static Color TryGetColor(string c, Color defaultValue)
+ {
+ if (!c.StartsWith("#")) c = $"#{c}";
+ try
+ {
+ var color = ColorConverter.ConvertFromString(c) as Color?;
+ return color ?? defaultValue;
+ }
+ catch (FormatException e)
+ {
+ MessageBox.Show($"Something bad occured when parsing the color: {c}, \n {e}");
+ }
+ return defaultValue;
+ }
private void RunGui(bool enableUnsafe)
{
var mainWindow = new MainWindow(enableUnsafe);
diff --git a/BluescreenSimulator/BluescreenSimulator.csproj b/BluescreenSimulator/BluescreenSimulator.csproj
index bd89a7c..100ed57 100644
--- a/BluescreenSimulator/BluescreenSimulator.csproj
+++ b/BluescreenSimulator/BluescreenSimulator.csproj
@@ -114,13 +114,45 @@
MSBuild:Compile
Designer
+
ColorPickerForm.xaml
+
-
+
+
+
+
+ True
+ True
+ Windows10BluescreenResources.resx
+
+
+ True
+ True
+ Windows7BluescreenResources.resx
+
+
+ True
+ True
+ Windows9xBluescreenResources.resx
+
+
+
+
+
+
+
+
+ BluescreenWindow9x.xaml
+
+
+
+ BluescreenWindowWin7.xaml
+
ColorChooserWindow.xaml
@@ -138,10 +170,18 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
@@ -164,7 +204,7 @@
BluescreenWindow.xaml
-
+
MainWindow.xaml
Code
@@ -190,6 +230,18 @@
Resources.Designer.cs
Designer
+
+ PublicResXFileCodeGenerator
+ Windows10BluescreenResources.Designer.cs
+
+
+ PublicResXFileCodeGenerator
+ Windows7BluescreenResources.Designer.cs
+
+
+ PublicResXFileCodeGenerator
+ Windows9xBluescreenResources.Designer.cs
+
@@ -198,6 +250,7 @@
Settings.Designer.cs
+
diff --git a/BluescreenSimulator/BluescreenViewAttribute.cs b/BluescreenSimulator/BluescreenViewAttribute.cs
new file mode 100644
index 0000000..03e67d0
--- /dev/null
+++ b/BluescreenSimulator/BluescreenViewAttribute.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Reflection;
+using System.Windows;
+using BluescreenSimulator.ViewModels;
+
+namespace BluescreenSimulator
+{
+ [AttributeUsage(AttributeTargets.Class, Inherited = false)]
+ public class BluescreenViewAttribute : Attribute
+ {
+ public Type WindowType { get; set; }
+ public BluescreenViewAttribute(Type windowType)
+ {
+ WindowType = windowType;
+ }
+ }
+
+ public static class BluescreenExtensions
+ {
+ public static void ShowView(this IBluescreenViewModel bluescreen)
+ {
+ var attribute = bluescreen.GetType().GetCustomAttribute();
+ if (attribute is null) throw new InvalidOperationException("No BluescreenViewAttribute has been found");
+ var type = attribute.WindowType;
+
+ void DispatcherWindowShow()
+ {
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ var window = (Window) Activator.CreateInstance(type, bluescreen);
+ window.Show();
+ return window;
+ });
+ }
+ bluescreen.ExecuteCommand.Execute((Action)DispatcherWindowShow);
+ }
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/Converters/EqualsVisibilityConverter.cs b/BluescreenSimulator/Converters/EqualsVisibilityConverter.cs
new file mode 100644
index 0000000..118a369
--- /dev/null
+++ b/BluescreenSimulator/Converters/EqualsVisibilityConverter.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace BluescreenSimulator.Converters
+{
+ public class EqualsVisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value == parameter ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value != parameter ? Visibility.Visible : Visibility.Collapsed;
+ }
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/Models/BluescreenBase.cs b/BluescreenSimulator/Models/BluescreenBase.cs
new file mode 100644
index 0000000..d664c6c
--- /dev/null
+++ b/BluescreenSimulator/Models/BluescreenBase.cs
@@ -0,0 +1,18 @@
+using System.Windows.Media;
+
+namespace BluescreenSimulator
+{
+ public class BluescreenBase
+ {
+ public string CmdCommand { get; set; } = null;
+
+ public virtual Color BackgroundColor { get; set; } = Color.FromRgb(10, 112, 169);
+
+ public virtual Color ForegroundColor { get; set; } = Colors.White;
+
+ public int Delay { get; set; } = 0;
+ public bool EnableUnsafe { get; set; } = false;
+
+ public bool RainbowMode { get; set; } = false;
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/Models/BluescreenData.cs b/BluescreenSimulator/Models/BluescreenData.cs
deleted file mode 100644
index ca1614e..0000000
--- a/BluescreenSimulator/Models/BluescreenData.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Windows.Media;
-
-namespace BluescreenSimulator
-{
- public class BluescreenData
- {
- public string Emoticon { get; set; } = ":(";
-
- public string MainText1 { get; set; } = "Your PC ran into a problem and needs to restart. We're just";
-
- public string MainText2 { get; set; } = "collecting some error info, and then we'll restart for you.";
-
- public string Complete { get; set; } = "complete";
-
- public string MoreInfo { get; set; } = "For more information about this issue and possible fixes, visit https://www.windows.com/stopcode";
-
- public string SupportPerson { get; set; } = "If you call a support person, give them this info:";
-
- public string StopCode { get; set; } = "Stop code: DRIVER_IRQL_NOT_LESS_OR_EQUAL";
-
- public string CmdCommand { get; set; } = null;
-
- public Color BackgroundColor { get; set; } = Color.FromRgb(10, 112, 169);
-
- public Color ForegroundColor { get; set; } = Colors.White;
-
- public int Delay { get; set; } = 0;
-
- public bool EnableUnsafe { get; set; } = false;
-
- public bool HideQR { get; set; } = false;
-
- public bool UseOriginalQR { get; set; }
-
- public bool RainbowMode { get; set; } = false;
- }
-}
diff --git a/BluescreenSimulator/Models/Windows10Bluescreen.cs b/BluescreenSimulator/Models/Windows10Bluescreen.cs
new file mode 100644
index 0000000..5ed757a
--- /dev/null
+++ b/BluescreenSimulator/Models/Windows10Bluescreen.cs
@@ -0,0 +1,25 @@
+using System.Windows.Media;
+using Strings = BluescreenSimulator.Properties.Windows10BluescreenResources;
+namespace BluescreenSimulator
+{
+ public class Windows10Bluescreen : BluescreenBase
+ {
+ public string Emoticon { get; set; } = Strings.Emoticon;
+
+ public string MainText1 { get; set; } = Strings.MainText1;
+
+ public string MainText2 { get; set; } = Strings.MainText2;
+
+ public string Complete { get; set; } = Strings.Complete;
+
+ public string MoreInfo { get; set; } = Strings.MoreInfo;
+
+ public string SupportPerson { get; set; } = Strings.SupportPerson;
+
+ public string StopCode { get; set; } = Strings.StopCode;
+
+ public bool HideQR { get; set; } = false;
+
+ public bool UseOriginalQR { get; set; }
+ }
+}
diff --git a/BluescreenSimulator/Models/Windows7Bluescreen.cs b/BluescreenSimulator/Models/Windows7Bluescreen.cs
new file mode 100644
index 0000000..5927bc0
--- /dev/null
+++ b/BluescreenSimulator/Models/Windows7Bluescreen.cs
@@ -0,0 +1,26 @@
+using System.Windows.Media;
+using Strings = BluescreenSimulator.Properties.Windows7BluescreenResources;
+namespace BluescreenSimulator
+{
+ public class Windows7Bluescreen : BluescreenBase
+ {
+ public string Header { get; set; } = Strings.Header;
+
+ public string ErrorCode { get; set; } = Strings.ErrorCode;
+
+ public string StepsHeader { get; set; } = Strings.StepsHeader;
+
+ public string Steps { get; set; } = Strings.Steps;
+
+ public string TechnicalInfoHeader { get; set; } = Strings.TechnicalInfoHeader;
+ public string StopCode { get; set; } = Strings.StopCode;
+ public string DumpStart { get; set; } = Strings.DumpStart;
+
+ public string DumpProgress { get; set; } = Strings.DumpProgress;
+
+ public string DumpComplete { get; set; } = Strings.DumpComplete;
+
+
+ public override Color BackgroundColor { get; set; } = Colors.DarkBlue;
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/Models/Windows9xBluescreen.cs b/BluescreenSimulator/Models/Windows9xBluescreen.cs
new file mode 100644
index 0000000..dde76a1
--- /dev/null
+++ b/BluescreenSimulator/Models/Windows9xBluescreen.cs
@@ -0,0 +1,22 @@
+using System.Windows.Media;
+using Strings = BluescreenSimulator.Properties.Windows9xBluescreenResources;
+namespace BluescreenSimulator
+{
+ public class Windows9xBluescreen : BluescreenBase
+ {
+ public string Header { get; set; } = Strings.Header;
+
+ public string InfoLine1 { get; set; } = Strings.InfoLine1;
+
+ public string InfoLine2 { get; set; } = Strings.InfoLine2;
+
+ public string Instructions { get; set; } = Strings.Instructions;
+
+ public string Error { get; set; } = Strings.Error;
+
+ public string ToContinue { get; set; } = Strings.ToContinue;
+
+
+ public override Color BackgroundColor { get; set; } = Colors.DarkBlue;
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/Properties/Windows10BluescreenResources.Designer.cs b/BluescreenSimulator/Properties/Windows10BluescreenResources.Designer.cs
new file mode 100644
index 0000000..39bcc17
--- /dev/null
+++ b/BluescreenSimulator/Properties/Windows10BluescreenResources.Designer.cs
@@ -0,0 +1,126 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace BluescreenSimulator.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ public class Windows10BluescreenResources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Windows10BluescreenResources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BluescreenSimulator.Properties.Windows10BluescreenResources", typeof(Windows10BluescreenResources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to complete.
+ ///
+ public static string Complete {
+ get {
+ return ResourceManager.GetString("Complete", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to :(.
+ ///
+ public static string Emoticon {
+ get {
+ return ResourceManager.GetString("Emoticon", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Your PC ran into a problem and needs to restart. We're just.
+ ///
+ public static string MainText1 {
+ get {
+ return ResourceManager.GetString("MainText1", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to collecting some error info, and then we'll restart for you..
+ ///
+ public static string MainText2 {
+ get {
+ return ResourceManager.GetString("MainText2", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to For more information about this issue and possible fixes, visit https://www.windows.com/stopcode.
+ ///
+ public static string MoreInfo {
+ get {
+ return ResourceManager.GetString("MoreInfo", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Stop code: DRIVER_IRQL_NOT_LESS_OR_EQUAL.
+ ///
+ public static string StopCode {
+ get {
+ return ResourceManager.GetString("StopCode", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to If you call a support person, give them this info:.
+ ///
+ public static string SupportPerson {
+ get {
+ return ResourceManager.GetString("SupportPerson", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BluescreenSimulator/Properties/Windows10BluescreenResources.resx b/BluescreenSimulator/Properties/Windows10BluescreenResources.resx
new file mode 100644
index 0000000..e35c2ae
--- /dev/null
+++ b/BluescreenSimulator/Properties/Windows10BluescreenResources.resx
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ :(
+
+
+ Your PC ran into a problem and needs to restart. We're just
+
+
+ collecting some error info, and then we'll restart for you.
+
+
+ complete
+
+
+ For more information about this issue and possible fixes, visit https://www.windows.com/stopcode
+
+
+ If you call a support person, give them this info:
+
+
+ Stop code: DRIVER_IRQL_NOT_LESS_OR_EQUAL
+
+
\ No newline at end of file
diff --git a/BluescreenSimulator/Properties/Windows7BluescreenResources.Designer.cs b/BluescreenSimulator/Properties/Windows7BluescreenResources.Designer.cs
new file mode 100644
index 0000000..c1c3a83
--- /dev/null
+++ b/BluescreenSimulator/Properties/Windows7BluescreenResources.Designer.cs
@@ -0,0 +1,150 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace BluescreenSimulator.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ public class Windows7BluescreenResources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Windows7BluescreenResources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BluescreenSimulator.Properties.Windows7BluescreenResources", typeof(Windows7BluescreenResources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Physical memory dump complete.
+ ///Contact your system administator or technical support group for further assistance..
+ ///
+ public static string DumpComplete {
+ get {
+ return ResourceManager.GetString("DumpComplete", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Dumping physical memory to disk: @p.
+ ///
+ public static string DumpProgress {
+ get {
+ return ResourceManager.GetString("DumpProgress", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Collecting data for crash dump...
+ ///Initializing disk for crash dump...
+ ///Beginning dump of physical memory..
+ ///
+ public static string DumpStart {
+ get {
+ return ResourceManager.GetString("DumpStart", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to IRQL_NOT_LESS_OR_EQUAL.
+ ///
+ public static string ErrorCode {
+ get {
+ return ResourceManager.GetString("ErrorCode", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to A problem has been detected and windows has been shutdown to prevent damage to your computer..
+ ///
+ public static string Header {
+ get {
+ return ResourceManager.GetString("Header", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Check to make sure any hardware or software is properly installed.
+ ///If this is a new installation. ask your hardware or software manufacturer for any windows updates you might need.
+ ///
+ ///If problems continue, disable or remove any newly installed hardware or software. Disable BIOS memory options such as caching or shadowing. If you need to use Safe Mode to remove or disable components, restart your computer, press F8 to select Advanced Startup Options, and then select Safe Mode..
+ ///
+ public static string Steps {
+ get {
+ return ResourceManager.GetString("Steps", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to If this is the first time you've seen this error screen, restart your computer. if this screen appears again. follow these steps:.
+ ///
+ public static string StepsHeader {
+ get {
+ return ResourceManager.GetString("StepsHeader", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to *** STOP: 0x000000FE (0x00000008, 0x000000006, 0x00000009, 0x847075cc).
+ ///
+ public static string StopCode {
+ get {
+ return ResourceManager.GetString("StopCode", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Technical information:.
+ ///
+ public static string TechnicalInfoHeader {
+ get {
+ return ResourceManager.GetString("TechnicalInfoHeader", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BluescreenSimulator/Properties/Windows7BluescreenResources.resx b/BluescreenSimulator/Properties/Windows7BluescreenResources.resx
new file mode 100644
index 0000000..8d4fa81
--- /dev/null
+++ b/BluescreenSimulator/Properties/Windows7BluescreenResources.resx
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ A problem has been detected and windows has been shutdown to prevent damage to your computer.
+
+
+ IRQL_NOT_LESS_OR_EQUAL
+
+
+ If this is the first time you've seen this error screen, restart your computer. if this screen appears again. follow these steps:
+
+
+ Check to make sure any hardware or software is properly installed.
+If this is a new installation. ask your hardware or software manufacturer for any windows updates you might need.
+
+If problems continue, disable or remove any newly installed hardware or software. Disable BIOS memory options such as caching or shadowing. If you need to use Safe Mode to remove or disable components, restart your computer, press F8 to select Advanced Startup Options, and then select Safe Mode.
+
+
+ Technical information:
+
+
+ *** STOP: 0x000000FE (0x00000008, 0x000000006, 0x00000009, 0x847075cc)
+
+
+ Collecting data for crash dump...
+Initializing disk for crash dump...
+Beginning dump of physical memory.
+
+
+ Dumping physical memory to disk: @p
+
+
+ Physical memory dump complete.
+Contact your system administator or technical support group for further assistance.
+
+
\ No newline at end of file
diff --git a/BluescreenSimulator/Properties/Windows9xBluescreenResources.Designer.cs b/BluescreenSimulator/Properties/Windows9xBluescreenResources.Designer.cs
new file mode 100644
index 0000000..0110592
--- /dev/null
+++ b/BluescreenSimulator/Properties/Windows9xBluescreenResources.Designer.cs
@@ -0,0 +1,118 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace BluescreenSimulator.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ public class Windows9xBluescreenResources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Windows9xBluescreenResources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BluescreenSimulator.Properties.Windows9xBluescreenResources", typeof(Windows9xBluescreenResources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Error : 0E : 016F : BFF9B3D4.
+ ///
+ public static string Error {
+ get {
+ return ResourceManager.GetString("Error", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Windows.
+ ///
+ public static string Header {
+ get {
+ return ResourceManager.GetString("Header", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to An error has occurred. To continue:.
+ ///
+ public static string InfoLine1 {
+ get {
+ return ResourceManager.GetString("InfoLine1", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Press Enter to return to Windows, or.
+ ///
+ public static string InfoLine2 {
+ get {
+ return ResourceManager.GetString("InfoLine2", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Press CTRL+ALT+DEL to restart your computer. If you do this,
+ ///you will lose any unsaved information in all open applications..
+ ///
+ public static string Instructions {
+ get {
+ return ResourceManager.GetString("Instructions", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Press any key to continue.
+ ///
+ public static string ToContinue {
+ get {
+ return ResourceManager.GetString("ToContinue", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BluescreenSimulator/Properties/Windows9xBluescreenResources.resx b/BluescreenSimulator/Properties/Windows9xBluescreenResources.resx
new file mode 100644
index 0000000..b4b8089
--- /dev/null
+++ b/BluescreenSimulator/Properties/Windows9xBluescreenResources.resx
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Windows
+
+
+ An error has occurred. To continue:
+
+
+ Press Enter to return to Windows, or
+
+
+ Press CTRL+ALT+DEL to restart your computer. If you do this,
+you will lose any unsaved information in all open applications.
+
+
+ Error : 0E : 016F : BFF9B3D4
+
+
+ Press any key to continue
+
+
\ No newline at end of file
diff --git a/BluescreenSimulator/Resolution.cs b/BluescreenSimulator/Resolution.cs
new file mode 100644
index 0000000..5bb220b
--- /dev/null
+++ b/BluescreenSimulator/Resolution.cs
@@ -0,0 +1,131 @@
+
+using System;
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+
+[StructLayout(LayoutKind.Sequential)]
+public struct DEVMODE1
+{
+ [MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)] public string dmDeviceName;
+ public short dmSpecVersion;
+ public short dmDriverVersion;
+ public short dmSize;
+ public short dmDriverExtra;
+ public int dmFields;
+
+ public short dmOrientation;
+ public short dmPaperSize;
+ public short dmPaperLength;
+ public short dmPaperWidth;
+
+ public short dmScale;
+ public short dmCopies;
+ public short dmDefaultSource;
+ public short dmPrintQuality;
+ public short dmColor;
+ public short dmDuplex;
+ public short dmYResolution;
+ public short dmTTOption;
+ public short dmCollate;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string dmFormName;
+ public short dmLogPixels;
+ public short dmBitsPerPel;
+ public int dmPelsWidth;
+ public int dmPelsHeight;
+
+ public int dmDisplayFlags;
+ public int dmDisplayFrequency;
+
+ public int dmICMMethod;
+ public int dmICMIntent;
+ public int dmMediaType;
+ public int dmDitherType;
+ public int dmReserved1;
+ public int dmReserved2;
+
+ public int dmPanningWidth;
+ public int dmPanningHeight;
+};
+
+
+
+class User_32
+{
+ [DllImport("user32.dll")]
+ public static extern int EnumDisplaySettings (string deviceName, int modeNum, ref DEVMODE1 devMode );
+ [DllImport("user32.dll")]
+ public static extern int ChangeDisplaySettings(ref DEVMODE1 devMode, int flags);
+
+ public const int ENUM_CURRENT_SETTINGS = -1;
+ public const int CDS_UPDATEREGISTRY = 0x01;
+ public const int CDS_TEST = 0x02;
+ public const int DISP_CHANGE_SUCCESSFUL = 0;
+ public const int DISP_CHANGE_RESTART = 1;
+ public const int DISP_CHANGE_FAILED = -1;
+}
+
+
+namespace Resolution
+{
+ class CResolution
+ {
+ public CResolution(int a,int b)
+ {
+ Screen screen = Screen.PrimaryScreen;
+
+
+ int iWidth =a;
+ int iHeight =b;
+
+
+ DEVMODE1 dm = new DEVMODE1();
+ dm.dmDeviceName = new String (new char[32]);
+ dm.dmFormName = new String (new char[32]);
+ dm.dmSize = (short)Marshal.SizeOf (dm);
+
+ if (0 != User_32.EnumDisplaySettings (null, User_32.ENUM_CURRENT_SETTINGS, ref dm))
+ {
+
+ dm.dmPelsWidth = iWidth;
+ dm.dmPelsHeight = iHeight;
+
+ int iRet = User_32.ChangeDisplaySettings (ref dm, User_32.CDS_TEST);
+
+ if (iRet == User_32.DISP_CHANGE_FAILED)
+ {
+ MessageBox.Show("Unable to process your request");
+ MessageBox.Show("Description: Unable To Process Your Request. Sorry For This Inconvenience.","Information",MessageBoxButtons.OK,MessageBoxIcon.Information);
+ }
+ else
+ {
+ iRet = User_32.ChangeDisplaySettings (ref dm, User_32.CDS_UPDATEREGISTRY);
+
+ switch (iRet)
+ {
+ case User_32.DISP_CHANGE_SUCCESSFUL:
+ {
+ break;
+
+ //successfull change
+ }
+ case User_32.DISP_CHANGE_RESTART:
+ {
+
+ MessageBox.Show("Description: You Need To Reboot For The Change To Happen.\n If You Feel Any Problem After Rebooting Your Machine\nThen Try To Change Resolution In Safe Mode.","Information",MessageBoxButtons.OK,MessageBoxIcon.Information);
+ break;
+ //windows 9x series you have to restart... in .net framework 4.5, sure.
+ }
+ default:
+ {
+
+ MessageBox.Show("Description: Failed To Change The Resolution.","Information",MessageBoxButtons.OK,MessageBoxIcon.Information);
+ break;
+ //failed to change
+ }
+ }
+ }
+
+ }
+ }
+ }
+}
diff --git a/BluescreenSimulator/Resources/Perfect DOS VGA 437 Win.ttf b/BluescreenSimulator/Resources/Perfect DOS VGA 437 Win.ttf
new file mode 100644
index 0000000..d03b1c5
Binary files /dev/null and b/BluescreenSimulator/Resources/Perfect DOS VGA 437 Win.ttf differ
diff --git a/BluescreenSimulator/ViewModels/BluescreenDataViewModel.cs b/BluescreenSimulator/ViewModels/BluescreenViewModelBase.cs
similarity index 63%
rename from BluescreenSimulator/ViewModels/BluescreenDataViewModel.cs
rename to BluescreenSimulator/ViewModels/BluescreenViewModelBase.cs
index 985c97c..c5e70d3 100644
--- a/BluescreenSimulator/ViewModels/BluescreenDataViewModel.cs
+++ b/BluescreenSimulator/ViewModels/BluescreenViewModelBase.cs
@@ -1,36 +1,38 @@
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media;
-
+using BluescreenSimulator;
namespace BluescreenSimulator.ViewModels
{
- public class BluescreenDataViewModel : ViewModelBase
+ public class BluescreenViewModelBase : ViewModelBase, IBluescreenViewModel where T : BluescreenBase, new()
{
- public BluescreenDataViewModel() : this(null)
+ public virtual string StyleName => "Bluescreen";
+
+ public BluescreenViewModelBase() : this(null)
{
}
- public BluescreenDataViewModel(BluescreenData model = null) : base(model)
+ public BluescreenViewModelBase(T model = null) : base(model)
{
ExecuteCommand = new DelegateCommand(async p => await Execute(p));
ResetAllCommand = new DelegateCommand(ResetAll);
InterruptCommand = new DelegateCommand(Interrupt, () => IsWaiting);
}
+
public DelegateCommand ExecuteCommand { get; }
+ private CancellationTokenSource _source = new CancellationTokenSource();
public DelegateCommand ResetAllCommand { get; }
public DelegateCommand InterruptCommand { get; }
-
- private CancellationTokenSource _source = new CancellationTokenSource();
public async Task Execute(object p)
{
if (!(p is Action show)) return;
Interrupt();
_source = new CancellationTokenSource();
+ Progress = StartingProgress;
if (Delay <= 0)
{
show();
@@ -38,14 +40,7 @@ public async Task Execute(object p)
}
IsWaiting = true;
var token = _source.Token;
- try
- {
- await Task.Delay(Delay * 1000, token);
- }
- catch (TaskCanceledException)
- {
- // ok
- }
+ await Task.Delay(Delay * 1000, token).ContinueWith(_ => { });
IsWaiting = false;
if (token.IsCancellationRequested)
{
@@ -53,112 +48,83 @@ public async Task Execute(object p)
}
show();
}
-
private void Interrupt()
{
_source.Cancel();
IsWaiting = false;
}
+ private bool _isWaiting;
- public async Task StartProgress(CancellationToken token = default)
+ public bool IsWaiting
{
- var r = new Random();
- while (Progress < 100)
+ get => _isWaiting;
+ set
{
- if (token.IsCancellationRequested)
- {
- Progress = 0;
- return;
- }
- await Task.Delay(r.Next(5000), token);
- Progress += r.Next(11);
- if (Progress > 100)
- {
- Progress = 100;
- }
+ _isWaiting = value;
+ OnPropertyChanged();
+ OnPropertyChanged(nameof(IsNotWaiting));
+ InterruptCommand.RaiseCanExecuteChanged();
}
- await Task.Delay(3000, token);
- if (token.IsCancellationRequested)
+ }
+ public bool IsNotWaiting => !IsWaiting;
+ [CmdParameter("-d")]
+ public int Delay
+ {
+ get => Model.Delay;
+ set
{
- Progress = 0;
- return;
+ value = Math.Min(Math.Max(value, 0), 86400); SetModelProperty(value);
}
- if (EnableUnsafe && !string.IsNullOrWhiteSpace(CmdCommand))
+ }
+
+ public string CreateCommandParameters()
+ {
+ var commandBuilder = new StringBuilder();
+ commandBuilder.Append("--direct ");
+ var type = GetType();
+ var @default = Activator.CreateInstance(type);
+ foreach (var info in type.GetProperties().Select(p => new
{
- Utils.ExecuteCmdCommands(CmdCommand);
+ DefaultValue = p.GetValue(@default),
+ Value = p.GetValue(this),
+ p.GetCustomAttribute()?.Parameter,
+ IsStandalone = p.PropertyType == typeof(bool),
+ p.Name
+ }).Where(p => p.Parameter != null && p.Value != null))
+ {
+ if (info.Value is false || info.Value == info.DefaultValue || (info.Value?.Equals(info.DefaultValue) ?? false)) continue; // is default
+ var value = info.Value.ToString();
+ if (value.Contains(' ') || value.Any(c => !char.IsLetterOrDigit(c))) value = $@"""{value}"""; // something like `my string with spaces` => "my string with spaces"
+ commandBuilder.Append($"{info.Parameter} {(info.Value is bool ? "" : value)} ");
}
+ return commandBuilder.ToString().Trim();
}
-
private void ResetAll()
{
- Model = new BluescreenData();
+ Model = new T();
foreach (var property in GetType().GetProperties())
{
OnPropertyChanged(property.Name);
}
}
- [CmdParameter("-e")]
- public string Emoticon
- {
- get => Model.Emoticon;
- set => SetModelProperty(value);
- }
- [CmdParameter("-m1")]
- public string MainText1
- {
- get => Model.MainText1;
- set => SetModelProperty(value);
- }
- [CmdParameter("-m2")]
- public string MainText2
- {
- get => Model.MainText2;
- set => SetModelProperty(value);
- }
private int _progress;
- public int Progress
+ public virtual int Progress
{
get => _progress;
- set { _progress = value; OnPropertyChanged(); }
+ set { _progress = Math.Min(value, 100); OnPropertyChanged(); }
}
+ private int _startingProgress;
- private bool _isWaiting;
-
- public bool IsWaiting
+ public int StartingProgress
{
- get => _isWaiting;
- set
- {
- _isWaiting = value;
- OnPropertyChanged();
- OnPropertyChanged(nameof(IsNotWaiting));
- InterruptCommand.RaiseCanExecuteChanged();
- }
- }
- public bool IsNotWaiting => !IsWaiting;
- [CmdParameter("-p")]
- public string Complete
- {
- get => Model.Complete;
- set => SetModelProperty(value);
- }
- [CmdParameter("-mi")]
- public string MoreInfo
- {
- get => Model.MoreInfo;
- set => SetModelProperty(value);
+ get { return _startingProgress; }
+ set { _startingProgress = Math.Min(value, 100); OnPropertyChanged(); }
}
- [CmdParameter("-s")]
- public string SupportPerson
- {
- get => Model.SupportPerson;
- set => SetModelProperty(value);
- }
- [CmdParameter("-sc")]
- public string StopCode
+
+ public bool EnableUnsafe
{
- get => Model.StopCode;
+ get => Model.EnableUnsafe;
set => SetModelProperty(value);
}
[CmdParameter("-c")]
@@ -179,58 +145,41 @@ public Color BackgroundColor
get => Model.BackgroundColor;
set => SetModelProperty(value);
}
- [CmdParameter("-d")]
- public int Delay
- {
- get => Model.Delay;
- set
- {
- value = Math.Min(Math.Max(value, 0), 86400); SetModelProperty(value);
- }
- }
-
- public bool EnableUnsafe
- {
- get => Model.EnableUnsafe;
- set => SetModelProperty(value);
- }
- [CmdParameter("--hideqr")]
- public bool HideQR
- {
- get => Model.HideQR;
- set => SetModelProperty(value, others: nameof(ShowQR));
- }
-
- public bool ShowQR => !HideQR;
- [CmdParameter("--origqr")]
- public bool UseOriginalQR
- {
- get => Model.UseOriginalQR;
- set => SetModelProperty(value);
- }
public bool RainbowMode
{
get => Model.RainbowMode;
set => SetModelProperty(value);
}
+ public virtual bool SupportsRainbow => false;
- public string CreateCommandParameters()
+ public async Task StartProgress(CancellationToken token = default)
{
- var commandBuilder = new StringBuilder();
- foreach (var info in GetType().GetProperties().Select(p => new
+ var r = new Random();
+ while (Progress < 100)
{
- Value = p.PropertyType == typeof(bool) ? "" : p.GetValue(this),
- p.GetCustomAttribute()?.Parameter,
- IsStandalone = p.PropertyType == typeof(bool),
- }).Where(p => p.Parameter != null && p.Value != null))
+ if (token.IsCancellationRequested)
+ {
+ Progress = 0;
+ return;
+ }
+ await Task.Delay(r.Next(5000), token);
+ Progress += r.Next(11);
+ if (Progress > 100)
+ {
+ Progress = 100;
+ }
+ }
+ await Task.Delay(3000, token);
+ if (token.IsCancellationRequested)
{
- if (info.Value is false) continue;
- var value = info.Value.ToString();
- if (value.Contains(' ')) value = $@"""{value}"""; // something like `my string with spaces` => "my string with spaces"
- commandBuilder.Append($"{info.Parameter} {value} ");
+ Progress = 0;
+ return;
+ }
+ if (EnableUnsafe && !string.IsNullOrWhiteSpace(CmdCommand))
+ {
+ Utils.ExecuteCmdCommands(CmdCommand);
}
- return commandBuilder.ToString();
}
}
}
\ No newline at end of file
diff --git a/BluescreenSimulator/ViewModels/IBluescreenViewModel.cs b/BluescreenSimulator/ViewModels/IBluescreenViewModel.cs
new file mode 100644
index 0000000..01fb9aa
--- /dev/null
+++ b/BluescreenSimulator/ViewModels/IBluescreenViewModel.cs
@@ -0,0 +1,32 @@
+using System.ComponentModel;
+using System.Windows.Media;
+using System.Windows.Input;
+namespace BluescreenSimulator.ViewModels
+{
+ public interface IBluescreenViewModel : INotifyPropertyChanged
+ {
+ string StyleName { get; }
+ DelegateCommand ExecuteCommand { get; }
+ DelegateCommand InterruptCommand { get; }
+ DelegateCommand ResetAllCommand { get; }
+
+ bool IsWaiting { get; }
+ bool IsNotWaiting { get; }
+
+ string CreateCommandParameters();
+ bool EnableUnsafe { get; set; }
+ string CmdCommand { get; set; }
+
+ Color ForegroundColor { get; set; }
+ Color BackgroundColor { get; set; }
+
+ int Delay { get; set; }
+ int Progress { get; set; }
+ int StartingProgress { get; set; }
+
+ bool SupportsRainbow { get; }
+ bool RainbowMode { get; }
+
+
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/ViewModels/MainWindowViewModel.cs b/BluescreenSimulator/ViewModels/MainWindowViewModel.cs
new file mode 100644
index 0000000..ff08391
--- /dev/null
+++ b/BluescreenSimulator/ViewModels/MainWindowViewModel.cs
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace BluescreenSimulator.ViewModels
+{
+ public class MainWindowViewModel : PropertyChangedObject
+ {
+ public IEnumerable Bluescreens { get; set; } = new IBluescreenViewModel[]
+ {
+ new Windows10BluescreenViewModel(),
+ new Windows7BluescreenViewModel(),
+ new Windows9xBluescreenViewModel()
+ };
+ private IBluescreenViewModel _selectedBluescreen;
+
+ public IBluescreenViewModel SelectedBluescreen
+ {
+ get { return _selectedBluescreen ?? (_selectedBluescreen = Bluescreens.FirstOrDefault()); }
+ set { _selectedBluescreen = value; OnPropertyChanged(); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/ViewModels/Windows10BluescreenViewModel.cs b/BluescreenSimulator/ViewModels/Windows10BluescreenViewModel.cs
new file mode 100644
index 0000000..74edb2d
--- /dev/null
+++ b/BluescreenSimulator/ViewModels/Windows10BluescreenViewModel.cs
@@ -0,0 +1,87 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Media;
+using BluescreenSimulator.Views;
+
+namespace BluescreenSimulator.ViewModels
+{
+ [BluescreenView(typeof(BluescreenWindow))]
+ public class Windows10BluescreenViewModel : BluescreenViewModelBase
+ {
+ public override string StyleName => "Windows 10 Style";
+
+ public Windows10BluescreenViewModel() : this(null)
+ {
+
+ }
+ public Windows10BluescreenViewModel(Windows10Bluescreen model = null) : base(model)
+ {
+
+ }
+ private CancellationTokenSource _source = new CancellationTokenSource();
+
+ [CmdParameter("-e")]
+ public string Emoticon
+ {
+ get => Model.Emoticon;
+ set => SetModelProperty(value);
+ }
+ [CmdParameter("-m1")]
+ public string MainText1
+ {
+ get => Model.MainText1;
+ set => SetModelProperty(value);
+ }
+ [CmdParameter("-m2")]
+ public string MainText2
+ {
+ get => Model.MainText2;
+ set => SetModelProperty(value);
+ }
+ [CmdParameter("-p")]
+ public string Complete
+ {
+ get => Model.Complete;
+ set => SetModelProperty(value);
+ }
+ [CmdParameter("-mi")]
+ public string MoreInfo
+ {
+ get => Model.MoreInfo;
+ set => SetModelProperty(value);
+ }
+ [CmdParameter("-s")]
+ public string SupportPerson
+ {
+ get => Model.SupportPerson;
+ set => SetModelProperty(value);
+ }
+ [CmdParameter("-sc")]
+ public string StopCode
+ {
+ get => Model.StopCode;
+ set => SetModelProperty(value);
+ }
+ [CmdParameter("--hideqr")]
+ public bool HideQR
+ {
+ get => Model.HideQR;
+ set => SetModelProperty(value, others: nameof(ShowQR));
+ }
+
+ public bool ShowQR => !HideQR;
+ [CmdParameter("--origqr")]
+ public bool UseOriginalQR
+ {
+ get => Model.UseOriginalQR;
+ set => SetModelProperty(value);
+ }
+
+ public override bool SupportsRainbow => true;
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/ViewModels/Windows7BluescreenViewModel.cs b/BluescreenSimulator/ViewModels/Windows7BluescreenViewModel.cs
new file mode 100644
index 0000000..b51f7a6
--- /dev/null
+++ b/BluescreenSimulator/ViewModels/Windows7BluescreenViewModel.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using BluescreenSimulator.Views;
+
+namespace BluescreenSimulator.ViewModels
+{
+ [BluescreenView(typeof(BluescreenWindowWin7))]
+ public class Windows7BluescreenViewModel : BluescreenViewModelBase
+ {
+ public override string StyleName => "Windows 7 Style";
+
+ public string DumpComplete
+ {
+ get => Model.DumpComplete;
+ set => SetModelProperty(value);
+ }
+
+ public string DumpProgress
+ {
+ get => Model.DumpProgress.Replace("@p", Progress.ToString());
+ set => SetModelProperty(value, others: nameof(DumpProgressEdit));
+ }
+ public string DumpProgressEdit
+ {
+ get => Model.DumpProgress;
+ set => DumpProgress = value;
+ }
+ public string DumpStart
+ {
+ get => Model.DumpStart;
+ set => SetModelProperty(value);
+ }
+
+ public string ErrorCode
+ {
+ get => Model.ErrorCode;
+ set => SetModelProperty(value);
+ }
+
+ public string Header
+ {
+ get => Model.Header;
+ set => SetModelProperty(value);
+ }
+
+ public string Steps
+ {
+ get => Model.Steps;
+ set => SetModelProperty(value);
+ }
+
+ public string StepsHeader
+ {
+ get => Model.StepsHeader;
+ set => SetModelProperty(value);
+ }
+
+ public string TechnicalInfoHeader
+ {
+ get => Model.TechnicalInfoHeader;
+ set => SetModelProperty(value);
+ }
+
+ public string StopCode
+ {
+ get => Model.StopCode;
+ set => SetModelProperty(value);
+ }
+ public override int Progress
+ {
+ get => base.Progress;
+ set { base.Progress = value; OnPropertyChanged(nameof(IsDumpComplete)); OnPropertyChanged(nameof(DumpProgress));}
+ }
+
+ public bool IsDumpComplete => Progress >= 100;
+ }
+}
diff --git a/BluescreenSimulator/ViewModels/Windows9xBluescreenViewModel.cs b/BluescreenSimulator/ViewModels/Windows9xBluescreenViewModel.cs
new file mode 100644
index 0000000..39e1782
--- /dev/null
+++ b/BluescreenSimulator/ViewModels/Windows9xBluescreenViewModel.cs
@@ -0,0 +1,56 @@
+using System.Diagnostics.CodeAnalysis;
+using BluescreenSimulator.Views;
+
+namespace BluescreenSimulator.ViewModels
+{
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ [BluescreenView(typeof(BluescreenWindow9x))]
+ public class Windows9xBluescreenViewModel : BluescreenViewModelBase
+ {
+ public override string StyleName => "Windows 9x Style";
+
+ public Windows9xBluescreenViewModel() : this(null)
+ {
+
+ }
+
+ public Windows9xBluescreenViewModel(Windows9xBluescreen model = null) : base(model)
+ {
+ }
+
+ public string Error
+ {
+ get => Model.Error;
+ set => SetModelProperty(value);
+ }
+
+ public string Header
+ {
+ get => Model.Header;
+ set => SetModelProperty(value);
+ }
+
+ public string InfoLine1
+ {
+ get => Model.InfoLine1;
+ set => SetModelProperty(value);
+ }
+ public string InfoLine2
+ {
+ get => Model.InfoLine2;
+ set => SetModelProperty(value);
+ }
+
+ public string Instructions
+ {
+ get => Model.Instructions;
+ set => SetModelProperty(value);
+ }
+
+ public string ToContinue
+ {
+ get => Model.ToContinue;
+ set => SetModelProperty(value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/Views/About.xaml b/BluescreenSimulator/Views/About.xaml
index abc7af0..13dbebb 100644
--- a/BluescreenSimulator/Views/About.xaml
+++ b/BluescreenSimulator/Views/About.xaml
@@ -7,7 +7,7 @@
mc:Ignorable="d"
Icon="/frown.ico"
ResizeMode="NoResize" WindowStartupLocation="CenterOwner"
- Title="Instructions" Height="490" Width="680">
+ Title="Instructions" Height="523" Width="680">
BlueScreen Simulator v2.0
@@ -26,7 +26,7 @@
• Click "Give me an error" to trigger the BSOD.
• To leave the BSOD screen, press Alt + F4 or F7.
• If you have specified a delay, you can cancel it by clicking "Cancel BSOD".
- • Leaving fields empty will set them to default values, which are set to replicate a Windows 10 BSOD.
+ • Leaving fields empty will set them to default values, which are set to replicate a Windows 9x/7/10 BSOD.
• Delay defaults to 0 and command defaults to "no command".
• The progress counter advances automatically.
• A command line interface exists. Run BluescreenSimulator --help for more info.
@@ -43,7 +43,7 @@
Bluescreen Simulator is open source!
-
+
Check out our Github repository
@@ -58,5 +58,11 @@
MIT License |
Project page
+
+ This software is using the CPOL-licensed library 'Dynamic Screen Resolution'. |
+ CPOL License |
+ Project page
+
+
diff --git a/BluescreenSimulator/Views/About.xaml.cs b/BluescreenSimulator/Views/About.xaml.cs
index 3030beb..6cf60f0 100644
--- a/BluescreenSimulator/Views/About.xaml.cs
+++ b/BluescreenSimulator/Views/About.xaml.cs
@@ -16,11 +16,5 @@ private void Hyperlink_Click(object sender, RoutedEventArgs e)
var link = (Hyperlink)sender;
Process.Start(link.NavigateUri.ToString());
}
-
- private void Hyperlink_Github_Click(object sender, RoutedEventArgs e)
- {
- var link = (Hyperlink)sender;
- Process.Start(link.NavigateUri.ToString());
- }
}
}
diff --git a/BluescreenSimulator/Views/BluescreenWindow.xaml b/BluescreenSimulator/Views/BluescreenWindow.xaml
index ef0ea6a..ac456cc 100644
--- a/BluescreenSimulator/Views/BluescreenWindow.xaml
+++ b/BluescreenSimulator/Views/BluescreenWindow.xaml
@@ -18,7 +18,8 @@
Title="BluescreenWindow"
Topmost="True"
PreviewKeyDown="Window_PreviewKeyDown"
- d:DataContext="{d:DesignInstance viewModels:BluescreenDataViewModel, IsDesignTimeCreatable=True}">
+ Cursor="None"
+ d:DataContext="{d:DesignInstance viewModels:Windows10BluescreenViewModel, IsDesignTimeCreatable=True}">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BluescreenSimulator/Views/BluescreenWindow9x.xaml.cs b/BluescreenSimulator/Views/BluescreenWindow9x.xaml.cs
new file mode 100644
index 0000000..29af88b
--- /dev/null
+++ b/BluescreenSimulator/Views/BluescreenWindow9x.xaml.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using BluescreenSimulator.ViewModels;
+using static System.Windows.Forms.Screen;
+
+
+namespace BluescreenSimulator.Views
+{
+ ///
+ /// Interaction logic for BluescreenWindow9x.xaml
+ ///
+ public partial class BluescreenWindow9x : Window
+ {
+ // for Resolution stuff
+ private int _tempHeight = 0, _tempWidth = 0;
+ private const int FixHeight = 800, FixWidth = 600;
+ private Windows9xBluescreenViewModel _vm;
+ public BluescreenWindow9x(Windows9xBluescreenViewModel vm = null)
+ {
+ DataContext = _vm = vm ?? new Windows9xBluescreenViewModel();
+
+ var primaryScreen = PrimaryScreen;
+ _tempHeight = primaryScreen.Bounds.Width; // current
+ _tempWidth = primaryScreen.Bounds.Height; // current
+ //
+ InitializeComponent();
+ Resolution.CResolution ChangeRes = new Resolution.CResolution(FixHeight, FixWidth);
+ KeyDown += BluescreenWindow9x_KeyDown;
+ }
+
+ private void BluescreenWindow9x_KeyDown(object sender, KeyEventArgs e)
+ {
+ Resolution.CResolution ChangeRes = new Resolution.CResolution(_tempHeight, _tempWidth);
+ Close();
+ }
+ }
+}
diff --git a/BluescreenSimulator/Views/BluescreenWindowWin7.xaml b/BluescreenSimulator/Views/BluescreenWindowWin7.xaml
new file mode 100644
index 0000000..24618ec
--- /dev/null
+++ b/BluescreenSimulator/Views/BluescreenWindowWin7.xaml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BluescreenSimulator/Views/BluescreenWindowWin7.xaml.cs b/BluescreenSimulator/Views/BluescreenWindowWin7.xaml.cs
new file mode 100644
index 0000000..619c3c4
--- /dev/null
+++ b/BluescreenSimulator/Views/BluescreenWindowWin7.xaml.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Forms;
+using System.Windows.Input;
+using BluescreenSimulator.ViewModels;
+using KeyEventArgs = System.Windows.Input.KeyEventArgs;
+
+namespace BluescreenSimulator.Views
+{
+ ///
+ /// Interaction logic for BluescreenWindowWin7.xaml
+ ///
+ public partial class BluescreenWindowWin7 : Window
+ {
+ //Variables
+ private readonly Random _random = new Random();
+ private Windows7BluescreenViewModel _vm;
+
+ // for Resolution stuff
+ private int _tempHeight = 0, _tempWidth = 0;
+ private const int FixHeight = 800, FixWidth = 600;
+
+ public BluescreenWindowWin7(Windows7BluescreenViewModel vm = null)
+ { // gets the main screen current Resolution
+ DataContext = _vm = vm ?? new Windows7BluescreenViewModel();
+ var primaryScreen = Screen.PrimaryScreen;
+ _tempHeight = primaryScreen.Bounds.Width; // current
+ _tempWidth = primaryScreen.Bounds.Height; // current
+ //
+ InitializeComponent();
+ Task.Run(SetupScreen);
+ }
+
+ private readonly CancellationTokenSource _source = new CancellationTokenSource();
+ private async Task SetupScreen()
+ {
+ //sets the main screen current res to 800*600
+ var changeRes = new Resolution.CResolution(FixHeight, FixWidth);
+ try
+ {
+ await _vm.StartProgress(_source.Token);
+ }
+ catch (TaskCanceledException)
+ {
+ // ok
+ }
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ _source.Cancel(); // cancel the current progress.
+ //sets the main screen Resolution to the defualt Resolution so it can reset to it while closing
+ var changeRes = new Resolution.CResolution(_tempHeight, _tempWidth);
+ }
+
+ private void Window_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.F7)
+ {
+ Close();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/BluescreenSimulator/Views/ColorChooserWindow.xaml b/BluescreenSimulator/Views/ColorChooserWindow.xaml
index 0585a30..af30796 100644
--- a/BluescreenSimulator/Views/ColorChooserWindow.xaml
+++ b/BluescreenSimulator/Views/ColorChooserWindow.xaml
@@ -215,10 +215,10 @@
-
+
-
-
+
+
diff --git a/BluescreenSimulator/Views/ColorChooserWindow.xaml.cs b/BluescreenSimulator/Views/ColorChooserWindow.xaml.cs
index 8dc10d5..9335f1a 100644
--- a/BluescreenSimulator/Views/ColorChooserWindow.xaml.cs
+++ b/BluescreenSimulator/Views/ColorChooserWindow.xaml.cs
@@ -7,7 +7,7 @@
namespace BluescreenSimulator.Views
{
///
- /// Logique d'interaction pour ColorChooserWindow.xaml
+ /// Wow a color chooser
///
public partial class ColorChooserWindow : Window
{
@@ -105,7 +105,7 @@ public void SetValueFromDrawingColor(System.Drawing.Color c)
OnPropertyChanged(nameof(FullSaturationColor));
}
- public Color FullSaturationColor => ChangeOpacity(HslToRgb(_hue / 100, 1, _lightness / 100));
+ public Color FullSaturationColor => ChangeOpacity(HslToRgb(_hue / 100, 1, 0.5));
// Given H,S,L in range of 0-1
diff --git a/BluescreenSimulator/Views/ExeCreator.xaml b/BluescreenSimulator/Views/ExeCreator.xaml
index 1db2452..be4eea0 100644
--- a/BluescreenSimulator/Views/ExeCreator.xaml
+++ b/BluescreenSimulator/Views/ExeCreator.xaml
@@ -49,7 +49,7 @@
-
+
diff --git a/BluescreenSimulator/Views/ExeCreator.xaml.cs b/BluescreenSimulator/Views/ExeCreator.xaml.cs
index 8056265..ae90d94 100644
--- a/BluescreenSimulator/Views/ExeCreator.xaml.cs
+++ b/BluescreenSimulator/Views/ExeCreator.xaml.cs
@@ -1,4 +1,5 @@
-using System.Windows;
+using System.IO;
+using System.Windows;
namespace BluescreenSimulator.Views
{
@@ -10,6 +11,7 @@ public partial class ExeCreator : Window
public ExeCreator()
{
InitializeComponent();
+ Loaded += (sender, args) => { FileName.Text = Path.GetRandomFileName(); };
}
private void OkButton_Click(object sender, RoutedEventArgs e)
diff --git a/BluescreenSimulator/Views/MainWindow.xaml b/BluescreenSimulator/Views/MainWindow.xaml
index 3841f3d..14a1a0e 100644
--- a/BluescreenSimulator/Views/MainWindow.xaml
+++ b/BluescreenSimulator/Views/MainWindow.xaml
@@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:BluescreenSimulator"
xmlns:controls="clr-namespace:BluescreenSimulator.Controls"
xmlns:converters="clr-namespace:BluescreenSimulator.Converters"
xmlns:viewModels="clr-namespace:BluescreenSimulator.ViewModels"
@@ -12,17 +11,179 @@
ResizeMode="NoResize"
Name="MainWindowFrame"
Height="475" Width="545" WindowStartupLocation="CenterScreen"
- d:DataContext="{d:DesignInstance viewModels:BluescreenDataViewModel, IsDesignTimeCreatable=True}">
+ d:DataContext="{d:DesignInstance viewModels:MainWindowViewModel, IsDesignTimeCreatable=True}">
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -32,95 +193,55 @@
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
diff --git a/BluescreenSimulator/Views/MainWindow.xaml.cs b/BluescreenSimulator/Views/MainWindow.xaml.cs
index 8809d3d..5bb0758 100644
--- a/BluescreenSimulator/Views/MainWindow.xaml.cs
+++ b/BluescreenSimulator/Views/MainWindow.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Windows;
using BluescreenSimulator.ViewModels;
@@ -9,11 +10,12 @@ namespace BluescreenSimulator.Views
public partial class MainWindow : Window
{
private bool enableUnsafe;
- private BluescreenDataViewModel _vm;
+ private MainWindowViewModel _vm;
+ private IBluescreenViewModel CurrentBluescreen => _vm.SelectedBluescreen;
public MainWindow(bool enableUnsafe)
{
InitializeComponent();
- DataContext = _vm = new BluescreenDataViewModel();
+ DataContext = _vm = new MainWindowViewModel();
this.enableUnsafe = enableUnsafe;
var title = "BluescreenSimulator v2.0";
@@ -23,15 +25,13 @@ public MainWindow(bool enableUnsafe)
}
MainWindowFrame.Title = title;
-
- Closing += WarnClose;
}
private void ShowBSOD(object sender, RoutedEventArgs e)
{
if (CheckData())
{
- _vm.ExecuteCommand.Execute(ShowBluescreen);
+ CurrentBluescreen.ShowView();
}
}
@@ -104,43 +104,8 @@ private void GenerateExe(object sender, RoutedEventArgs e)
private string GenerateCommand()
{
var success = CheckData();
- if (!success) return null;
- return _vm.CreateCommandParameters();
- }
- private void WarnClose(object sender, CancelEventArgs e)
- {
- if (_vm.IsWaiting)
- {
- var messageBoxResult = MessageBox.Show("Do you want to exit? The scheduled BSOD will remain scheduled. If you want to interrupt it, you have to kill the process.",
- "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question);
- if (messageBoxResult == MessageBoxResult.Yes)
- {
- e.Cancel = false;
- }
- else
- {
- e.Cancel = true;
- }
- }
- }
-
- public Action ShowBluescreen => ShowBlueScreenImpl;
-
- private void ShowBlueScreenImpl()
- {
- ShowBluescreenWindow(_vm);
- }
-
- public static void ShowBluescreenWindow(BluescreenDataViewModel vm)
- {
- Application.Current.Dispatcher.Invoke(() =>
- {
- foreach (var s in System.Windows.Forms.Screen.AllScreens)
- {
- var bluescreenView = new BluescreenWindow(vm);
- ShowOnMonitor(s, bluescreenView);
- }
- });
+ if (!success) return "";
+ return CurrentBluescreen.CreateCommandParameters();
}
private static void ShowOnMonitor(System.Windows.Forms.Screen screen, Window window)
@@ -160,11 +125,11 @@ private static void ShowOnMonitor(System.Windows.Forms.Screen screen, Window win
private bool CheckData()
{
- if (_vm.EnableUnsafe && !string.IsNullOrEmpty(CmdCommand.Text.Trim()))
+ if (CurrentBluescreen.EnableUnsafe && !string.IsNullOrEmpty(CurrentBluescreen.CmdCommand.Trim()))
{
var messageBoxResult = MessageBox.Show("Using a CMD command can be dangerous. " +
"I will not be responsible for any data loss or other damage arising from irresponsible or careless use of the CMD command option. " +
- "Please re-check your command to make sure that you execute what you intended:\r\n\r\n" + CmdCommand.Text.Trim() + "\r\n\r\n" + "Do you want to proceed?",
+ "Please re-check your command to make sure that you execute what you intended:\r\n\r\n" + CurrentBluescreen.CmdCommand.Trim() + "\r\n\r\n" + "Do you want to proceed?",
"Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (messageBoxResult == MessageBoxResult.No)
{