first commit

This commit is contained in:
zongor 2022-09-03 23:45:44 -04:00
commit 1240185b86
40 changed files with 994 additions and 0 deletions

BIN
.vs/._ScreenSaver Executable file

Binary file not shown.

BIN
.vs/ScreenSaver/._DesignTimeBuild Executable file

Binary file not shown.

BIN
.vs/ScreenSaver/._v14 Executable file

Binary file not shown.

BIN
.vs/ScreenSaver/._v15 Executable file

Binary file not shown.

BIN
.vs/ScreenSaver/._v16 Executable file

Binary file not shown.

Binary file not shown.

BIN
.vs/ScreenSaver/v14/.suo Executable file

Binary file not shown.

BIN
.vs/ScreenSaver/v15/._Server Executable file

Binary file not shown.

BIN
.vs/ScreenSaver/v15/.suo Executable file

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.vs/ScreenSaver/v16/._Server Executable file

Binary file not shown.

BIN
.vs/ScreenSaver/v16/.suo Executable file

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

5
README.md Executable file
View File

@ -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

31
ScreenSaver.sln Executable file
View File

@ -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

BIN
ScreenSaver.suo Executable file

Binary file not shown.

BIN
ScreenSaver/.vs/._ScreenSaver Executable file

Binary file not shown.

View File

@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}

BIN
ScreenSaver/.vs/ScreenSaver/._v16 Executable file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\ScreenSaverForm.cs",
"PreviewInSolutionExplorer": false
}

BIN
ScreenSaver/.vs/slnx.sqlite Executable file

Binary file not shown.

88
ScreenSaver/Program.cs Executable file
View File

@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace ScreenSaver
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[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");
}
}
/// <summary>
/// Display the form on each of the computer's monitors.
/// </summary>
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();
}
}
}

View File

@ -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")]

63
ScreenSaver/Properties/Resources.Designer.cs generated Executable file
View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ScreenSaver.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<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>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

26
ScreenSaver/Properties/Settings.Designer.cs generated Executable file
View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

100
ScreenSaver/ScreenSaver.csproj Executable file
View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C79DC106-23F3-4FA7-BA69-6B8684C4AD9F}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ScreenSaver</RootNamespace>
<AssemblyName>Stars</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ScreenSaverForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ScreenSaverForm.Designer.cs">
<DependentUpon>ScreenSaverForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="ScreenSaverForm.resx">
<DependentUpon>ScreenSaverForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>/s</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<StartArguments>/s</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<StartArguments>/s</StartArguments>
</PropertyGroup>
</Project>

64
ScreenSaver/ScreenSaverForm.Designer.cs generated Executable file
View File

@ -0,0 +1,64 @@
namespace ScreenSaver
{
partial class ScreenSaverForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

309
ScreenSaver/ScreenSaverForm.cs Executable file
View File

@ -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;
}
}
}

123
ScreenSaver/ScreenSaverForm.resx Executable file
View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<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">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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" 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">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="moveTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

3
ScreenSaver/app.config Executable file
View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>