commit 1240185b866b4fc5c335d96ce261fcc4b5bfbb28 Author: zongor Date: Sat Sep 3 23:45:44 2022 -0400 first commit diff --git a/.vs/._ScreenSaver b/.vs/._ScreenSaver new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/.vs/._ScreenSaver differ diff --git a/.vs/ScreenSaver/._DesignTimeBuild b/.vs/ScreenSaver/._DesignTimeBuild new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/.vs/ScreenSaver/._DesignTimeBuild differ diff --git a/.vs/ScreenSaver/._v14 b/.vs/ScreenSaver/._v14 new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/.vs/ScreenSaver/._v14 differ diff --git a/.vs/ScreenSaver/._v15 b/.vs/ScreenSaver/._v15 new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/.vs/ScreenSaver/._v15 differ diff --git a/.vs/ScreenSaver/._v16 b/.vs/ScreenSaver/._v16 new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/.vs/ScreenSaver/._v16 differ diff --git a/.vs/ScreenSaver/DesignTimeBuild/.dtbcache b/.vs/ScreenSaver/DesignTimeBuild/.dtbcache new file mode 100755 index 0000000..65fb42e Binary files /dev/null and b/.vs/ScreenSaver/DesignTimeBuild/.dtbcache differ diff --git a/.vs/ScreenSaver/v14/.suo b/.vs/ScreenSaver/v14/.suo new file mode 100755 index 0000000..c950e85 Binary files /dev/null and b/.vs/ScreenSaver/v14/.suo differ diff --git a/.vs/ScreenSaver/v15/._Server b/.vs/ScreenSaver/v15/._Server new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/.vs/ScreenSaver/v15/._Server differ diff --git a/.vs/ScreenSaver/v15/.suo b/.vs/ScreenSaver/v15/.suo new file mode 100755 index 0000000..9ee8a65 Binary files /dev/null and b/.vs/ScreenSaver/v15/.suo differ diff --git a/.vs/ScreenSaver/v15/Server/._sqlite3 b/.vs/ScreenSaver/v15/Server/._sqlite3 new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/.vs/ScreenSaver/v15/Server/._sqlite3 differ diff --git a/.vs/ScreenSaver/v15/Server/sqlite3/db.lock b/.vs/ScreenSaver/v15/Server/sqlite3/db.lock new file mode 100755 index 0000000..e69de29 diff --git a/.vs/ScreenSaver/v15/Server/sqlite3/storage.ide b/.vs/ScreenSaver/v15/Server/sqlite3/storage.ide new file mode 100755 index 0000000..2bda690 Binary files /dev/null and b/.vs/ScreenSaver/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/ScreenSaver/v15/Server/sqlite3/storage.ide-shm b/.vs/ScreenSaver/v15/Server/sqlite3/storage.ide-shm new file mode 100755 index 0000000..228475d Binary files /dev/null and b/.vs/ScreenSaver/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/ScreenSaver/v15/Server/sqlite3/storage.ide-wal b/.vs/ScreenSaver/v15/Server/sqlite3/storage.ide-wal new file mode 100755 index 0000000..23f8361 Binary files /dev/null and b/.vs/ScreenSaver/v15/Server/sqlite3/storage.ide-wal differ diff --git a/.vs/ScreenSaver/v16/._Server b/.vs/ScreenSaver/v16/._Server new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/.vs/ScreenSaver/v16/._Server differ diff --git a/.vs/ScreenSaver/v16/.suo b/.vs/ScreenSaver/v16/.suo new file mode 100755 index 0000000..3c47800 Binary files /dev/null and b/.vs/ScreenSaver/v16/.suo differ diff --git a/.vs/ScreenSaver/v16/Server/._sqlite3 b/.vs/ScreenSaver/v16/Server/._sqlite3 new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/.vs/ScreenSaver/v16/Server/._sqlite3 differ diff --git a/.vs/ScreenSaver/v16/Server/sqlite3/db.lock b/.vs/ScreenSaver/v16/Server/sqlite3/db.lock new file mode 100755 index 0000000..e69de29 diff --git a/.vs/ScreenSaver/v16/Server/sqlite3/storage.ide b/.vs/ScreenSaver/v16/Server/sqlite3/storage.ide new file mode 100755 index 0000000..dabf1b0 Binary files /dev/null and b/.vs/ScreenSaver/v16/Server/sqlite3/storage.ide differ diff --git a/README.md b/README.md new file mode 100755 index 0000000..7fb89f5 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +This is a windows screen saver translation of one of the f90gl demos called 'Stars' + +Special thanks to the National Institute of Standards and Technology for that example program as insperation for this screensaver + +This heavily uses the code from the screensaver demo by Frank McCown at https://sites.harding.edu/fmccown/screensaver/screensaver.html diff --git a/ScreenSaver.sln b/ScreenSaver.sln new file mode 100755 index 0000000..c4c36b3 --- /dev/null +++ b/ScreenSaver.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2035 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScreenSaver", "ScreenSaver\ScreenSaver.csproj", "{C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}.Debug|x64.ActiveCfg = Debug|x64 + {C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}.Debug|x64.Build.0 = Debug|x64 + {C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}.Debug|x86.ActiveCfg = Debug|x86 + {C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}.Debug|x86.Build.0 = Debug|x86 + {C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}.Release|x64.ActiveCfg = Release|x64 + {C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}.Release|x64.Build.0 = Release|x64 + {C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}.Release|x86.ActiveCfg = Release|x86 + {C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {91FD7A09-FE53-428E-94A6-B45F328335ED} + EndGlobalSection +EndGlobal diff --git a/ScreenSaver.suo b/ScreenSaver.suo new file mode 100755 index 0000000..cf459b3 Binary files /dev/null and b/ScreenSaver.suo differ diff --git a/ScreenSaver/.vs/._ScreenSaver b/ScreenSaver/.vs/._ScreenSaver new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/ScreenSaver/.vs/._ScreenSaver differ diff --git a/ScreenSaver/.vs/ProjectSettings.json b/ScreenSaver/.vs/ProjectSettings.json new file mode 100755 index 0000000..866f1e1 --- /dev/null +++ b/ScreenSaver/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/ScreenSaver/.vs/ScreenSaver/._v16 b/ScreenSaver/.vs/ScreenSaver/._v16 new file mode 100755 index 0000000..169e65d Binary files /dev/null and b/ScreenSaver/.vs/ScreenSaver/._v16 differ diff --git a/ScreenSaver/.vs/ScreenSaver/v16/.suo b/ScreenSaver/.vs/ScreenSaver/v16/.suo new file mode 100755 index 0000000..e5dd8a3 Binary files /dev/null and b/ScreenSaver/.vs/ScreenSaver/v16/.suo differ diff --git a/ScreenSaver/.vs/VSWorkspaceState.json b/ScreenSaver/.vs/VSWorkspaceState.json new file mode 100755 index 0000000..27b241f --- /dev/null +++ b/ScreenSaver/.vs/VSWorkspaceState.json @@ -0,0 +1,7 @@ +{ + "ExpandedNodes": [ + "" + ], + "SelectedNode": "\\ScreenSaverForm.cs", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/ScreenSaver/.vs/slnx.sqlite b/ScreenSaver/.vs/slnx.sqlite new file mode 100755 index 0000000..caee789 Binary files /dev/null and b/ScreenSaver/.vs/slnx.sqlite differ diff --git a/ScreenSaver/Program.cs b/ScreenSaver/Program.cs new file mode 100755 index 0000000..c884a31 --- /dev/null +++ b/ScreenSaver/Program.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace ScreenSaver +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + if (args.Length > 0) + { + string firstArgument = args[0].ToLower().Trim(); + string secondArgument = null; + + // Handle cases where arguments are separated by colon. + // Examples: /c:1234567 or /P:1234567 + if (firstArgument.Length > 2) + { + secondArgument = firstArgument.Substring(3).Trim(); + firstArgument = firstArgument.Substring(0, 2); + } + else if (args.Length > 1) + secondArgument = args[1]; + + if (firstArgument == "/c") // Configuration mode + { + MessageBox.Show("There is no configuration for this screensaver"); + } + else if (firstArgument == "/p") // Preview mode + { + if (secondArgument == null) + { + MessageBox.Show("Sorry, but the expected window handle was not provided.", + "ScreenSaver", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + IntPtr previewWndHandle = new IntPtr(long.Parse(secondArgument)); + Application.Run(new ScreenSaverForm(previewWndHandle)); + } + else if (firstArgument == "/s") // Full-screen mode + { + ShowScreenSaver(); + Application.Run(); + } + else // Undefined argument + { + MessageBox.Show("Sorry, but the command line argument \"" + firstArgument + + "\" is not valid.", "ScreenSaver", + MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + else // No arguments - treat like /c + { + MessageBox.Show("There is no configuration for this screensaver"); + } + } + + /// + /// Display the form on each of the computer's monitors. + /// + static void ShowScreenSaver() + { + + int height = 0; + int width = 0; + foreach (var screen in System.Windows.Forms.Screen.AllScreens) + { + //take smallest height + height = screen.Bounds.Height; + width += screen.Bounds.Width; + } + + ScreenSaverForm screensaver = new ScreenSaverForm(new System.Drawing.Rectangle(Screen.AllScreens[0].Bounds.X, Screen.AllScreens[0].Bounds.Y, width, height)); + screensaver.Show(); + + } + } +} diff --git a/ScreenSaver/Properties/AssemblyInfo.cs b/ScreenSaver/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..96e3ea1 --- /dev/null +++ b/ScreenSaver/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ScreenSaver")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ScreenSaver")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b05a44d5-ef0f-4004-9ab2-894af28dc7d6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ScreenSaver/Properties/Resources.Designer.cs b/ScreenSaver/Properties/Resources.Designer.cs new file mode 100755 index 0000000..0e06218 --- /dev/null +++ b/ScreenSaver/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 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 ScreenSaver.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", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ScreenSaver.Properties.Resources", typeof(Resources).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)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/ScreenSaver/Properties/Resources.resx b/ScreenSaver/Properties/Resources.resx new file mode 100755 index 0000000..ffecec8 --- /dev/null +++ b/ScreenSaver/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ScreenSaver/Properties/Settings.Designer.cs b/ScreenSaver/Properties/Settings.Designer.cs new file mode 100755 index 0000000..ca2ab76 --- /dev/null +++ b/ScreenSaver/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 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 ScreenSaver.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/ScreenSaver/Properties/Settings.settings b/ScreenSaver/Properties/Settings.settings new file mode 100755 index 0000000..abf36c5 --- /dev/null +++ b/ScreenSaver/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ScreenSaver/ScreenSaver.csproj b/ScreenSaver/ScreenSaver.csproj new file mode 100755 index 0000000..f414771 --- /dev/null +++ b/ScreenSaver/ScreenSaver.csproj @@ -0,0 +1,100 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {C79DC106-23F3-4FA7-BA69-6B8684C4AD9F} + WinExe + Properties + ScreenSaver + Stars + v4.6.1 + + + 512 + + + x64 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + x64 + bin\x64\Debug\ + + + x64 + bin\x64\Release\ + + + + + + + + + + + + + + + + Form + + + ScreenSaverForm.cs + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + ScreenSaverForm.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/ScreenSaver/ScreenSaver.csproj.user b/ScreenSaver/ScreenSaver.csproj.user new file mode 100755 index 0000000..1ba44b0 --- /dev/null +++ b/ScreenSaver/ScreenSaver.csproj.user @@ -0,0 +1,12 @@ + + + + /s + + + /s + + + /s + + \ No newline at end of file diff --git a/ScreenSaver/ScreenSaverForm.Designer.cs b/ScreenSaver/ScreenSaverForm.Designer.cs new file mode 100755 index 0000000..349792e --- /dev/null +++ b/ScreenSaver/ScreenSaverForm.Designer.cs @@ -0,0 +1,64 @@ +namespace ScreenSaver +{ + partial class ScreenSaverForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.moveTimer = new System.Windows.Forms.Timer(this.components); + this.NitroTimer = new System.Windows.Forms.Timer(this.components); + this.SuspendLayout(); + // + // NitroTimer + // + this.NitroTimer.Tick += new System.EventHandler(this.NitroTimer_Tick); + // + // ScreenSaverForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(508, 260); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "ScreenSaverForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.ScreenSaverForm_Load); + this.Paint += new System.Windows.Forms.PaintEventHandler(this.ScreenSaverForm_Paint); + this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ScreenSaverForm_KeyPress); + this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ScreenSaverForm_MouseClick); + this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ScreenSaverForm_MouseMove); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Timer moveTimer; + private System.Windows.Forms.Timer NitroTimer; + } +} + diff --git a/ScreenSaver/ScreenSaverForm.cs b/ScreenSaver/ScreenSaverForm.cs new file mode 100755 index 0000000..26d4e67 --- /dev/null +++ b/ScreenSaver/ScreenSaverForm.cs @@ -0,0 +1,309 @@ +/* + * ScreenSaverForm.cs + * By Frank McCown + * Summer 2010 + * + * Feel free to modify this code. + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Runtime.InteropServices; +using Microsoft.Win32; + +namespace ScreenSaver +{ + public partial class ScreenSaverForm : Form + { + #region Win32 API functions + + [DllImport("user32.dll")] + static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); + + [DllImport("user32.dll")] + static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong); + + [DllImport("user32.dll", SetLastError = true)] + static extern int GetWindowLong(IntPtr hWnd, int nIndex); + + [DllImport("user32.dll")] + static extern bool GetClientRect(IntPtr hWnd, out Rectangle lpRect); + + #endregion + + private static readonly int MAXSTARS = 1000; + private static readonly int MAXPOS = 3000; + private static readonly int MAXWARP = 3; + + public struct StarRec + { + public decimal[] x, y, z; + public decimal offsetX, offsetY, offsetR, rotation; + }; + + decimal nitro = 0; + int m_windW; + int m_windH; + readonly int starCount = MAXSTARS / 2; + decimal m_speed = 0.2m; + StarRec[] m_stars; + private Point mouseLocation; + private bool previewMode = false; + private readonly Random rand = new Random((int)DateTime.Now.Ticks); + + public ScreenSaverForm() + { + InitializeComponent(); + Init(); + } + + public ScreenSaverForm(Rectangle Bounds) + { + InitializeComponent(); + this.Bounds = Bounds; + Init(); + } + + public ScreenSaverForm(IntPtr PreviewWndHandle) + { + InitializeComponent(); + Init(); + + // Set the preview window as the parent of this window + SetParent(this.Handle, PreviewWndHandle); + + // Make this a child window so it will close when the parent dialog closes + SetWindowLong(this.Handle, -16, new IntPtr(GetWindowLong(this.Handle, -16) | 0x40000000)); + + // Place our window inside the parent + GetClientRect(PreviewWndHandle, out Rectangle ParentRect); + Size = ParentRect.Size; + Location = new Point(0, 0); + + previewMode = true; + } + + private void ScreenSaverForm_Load(object sender, EventArgs e) + { + Cursor.Hide(); + TopMost = true; + + moveTimer.Interval = 10; + moveTimer.Tick += new EventHandler(MoveTimer_Tick); + moveTimer.Start(); + + NitroTimer.Interval = 180000; + NitroTimer.Start(); + } + + private void MoveTimer_Tick(object sender, System.EventArgs e) + { + this.Invalidate(); + } + + private void ScreenSaverForm_MouseMove(object sender, MouseEventArgs e) + { + if (!previewMode) + { + if (!mouseLocation.IsEmpty) + { + // Terminate if mouse is moved a significant distance + if (Math.Abs(mouseLocation.X - e.X) > 5 || + Math.Abs(mouseLocation.Y - e.Y) > 5) + Application.Exit(); + } + + // Update current mouse location + mouseLocation = e.Location; + } + } + + private void ScreenSaverForm_KeyPress(object sender, KeyPressEventArgs e) + { + switch (e.KeyChar) + { + case 'x': + nitro = 3; + break; + case '+': + case '=': + m_speed += 0.001m; + break; + case '-': + case '_': + m_speed -= 0.001m; + break; + default: + if (!previewMode) + Application.Exit(); + break; + } + } + + private void ScreenSaverForm_MouseClick(object sender, MouseEventArgs e) + { + if (!previewMode) + Application.Exit(); + } + + private void Init() + { + int n; + m_windW = Bounds.Width; + m_windH = Bounds.Height; + m_stars = new StarRec[MAXSTARS]; + + for (n = 0; n < MAXSTARS; n++) + { + NewStar(n, 100); + } + this.DoubleBuffered = true; + } + + void NewStar(int n, int d) + { + m_stars[n].x = new decimal[] { 0, 0 }; + m_stars[n].y = new decimal[] { 0, 0 }; + m_stars[n].z = new decimal[] { 0, 0 }; + + m_stars[n].x[0] = (rand.Next() % MAXPOS) - MAXPOS / 2; + m_stars[n].y[0] = (rand.Next() % MAXPOS) - MAXPOS / 2; + m_stars[n].z[0] = (rand.Next() % MAXPOS) + d; + m_stars[n].x[1] = m_stars[n].x[0]; + m_stars[n].y[1] = m_stars[n].y[0]; + m_stars[n].z[1] = m_stars[n].z[0]; + + m_stars[n].offsetX = 0; + m_stars[n].offsetY = 0; + m_stars[n].offsetR = 0; + } + + bool StarPoint(int n) + { + decimal x0, y0; + + x0 = m_stars[n].x[0] * m_windW / m_stars[n].z[0]; + y0 = m_stars[n].y[0] * m_windH / m_stars[n].z[0]; + x0 += m_windW / 2; + y0 += m_windH / 2; + + if (x0 >= 0 && x0 < m_windW && y0 >= 0 && y0 < m_windH) + { + return true; + } + + return false; + } + + void ShowStar(int n, PaintEventArgs e) + { + decimal x0, y0, x1, y1; + + x0 = m_stars[n].x[0] * m_windW / m_stars[n].z[0]; + y0 = m_stars[n].y[0] * m_windH / m_stars[n].z[0]; + x0 += m_windW / 2; + y0 += m_windH / 2; + + if (x0 >= 0 && x0 < m_windW && y0 >= 0 && y0 < m_windH) + { + x1 = m_stars[n].x[1] * m_windW / m_stars[n].z[1]; + y1 = m_stars[n].y[1] * m_windH / m_stars[n].z[1]; + x1 += m_windW / 2; + y1 += m_windH / 2; + + Color color = Color.FromArgb((int) (255 * ((MAXWARP - m_speed) / MAXWARP)), (int)(255 * ((MAXWARP - m_speed) / MAXWARP)), 255); + + using (Pen pen = new Pen(color, (float)(MAXPOS / 100 / m_stars[n].z[0] + 2))) + { + if (Math.Abs(x0 - x1) < 1 && Math.Abs(y0 - y1) < 1) + { + e.Graphics.DrawLine(pen, (float)x0, (float)y0, (float)x0, (float)y0); + } + else + { + e.Graphics.DrawLine(pen, (float)x0, (float)y0, (float)x1, (float)y1); + } + } + + var s = m_speed >= 1.0m ? $"Warp Factor {m_speed}" : $"Impulse {m_speed}"; + using (Brush b = new SolidBrush(Color.White)) + e.Graphics.DrawString(s, new Font(FontFamily.GenericMonospace, 8.0f), b, 0, 0); + } + } + + void ShowStars(PaintEventArgs e) + { + int n; + decimal offset; + + for (n = 0; n < starCount; n++) + { + if (nitro > 0) + { + m_speed = (nitro / 10.0m) + 0.2m; + if (m_speed > MAXWARP) + { + m_speed = MAXWARP; + } + nitro += 0.0001m; + if (nitro > MAXWARP * 10) + { + nitro = -nitro; + } + } + else if (nitro < 0) + { + nitro += 0.0001m; + m_speed = (-nitro / 10.0m) + 0.2m; + if (m_speed > MAXWARP) + { + m_speed = MAXWARP; + } + } + + offset = m_speed * 60; + + m_stars[n].x[1] = m_stars[n].x[0]; + m_stars[n].y[1] = m_stars[n].y[0]; + m_stars[n].z[1] = m_stars[n].z[0]; + m_stars[n].x[0] = m_stars[n].x[0] + m_stars[n].offsetX; + m_stars[n].y[0] = m_stars[n].y[0] + m_stars[n].offsetY; + m_stars[n].z[0] = m_stars[n].z[0] - offset; + m_stars[n].rotation = m_stars[n].rotation + m_stars[n].offsetR; + + if (m_stars[n].z[0] > m_speed || (m_stars[n].z[0] > 0 && m_speed < MAXWARP)) + { + if (!StarPoint(n)) + { + NewStar(n, MAXPOS); + } + } + else + { + NewStar(n, MAXPOS); + } + + if (m_stars[n].z[0] > m_speed || (m_stars[n].z[0] > 0 && m_speed < MAXWARP)) + { + ShowStar(n, e); + } + } + } + + private void ScreenSaverForm_Paint(object sender, PaintEventArgs e) + { + ShowStars(e); + } + + private void NitroTimer_Tick(object sender, EventArgs e) + { + nitro = 10; + } + } +} diff --git a/ScreenSaver/ScreenSaverForm.resx b/ScreenSaver/ScreenSaverForm.resx new file mode 100755 index 0000000..92ec711 --- /dev/null +++ b/ScreenSaver/ScreenSaverForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/ScreenSaver/app.config b/ScreenSaver/app.config new file mode 100755 index 0000000..d405098 --- /dev/null +++ b/ScreenSaver/app.config @@ -0,0 +1,3 @@ + + +