From c50de05af35a5d1cc04fab7a3ee5691c6ce71226 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 28 Feb 2021 20:30:48 +0000 Subject: [PATCH] Initial commit --- .gitignore | 3 + Program.cs | 49 +++++++++++++ Properties/AssemblyInfo.cs | 36 ++++++++++ Properties/Resources.Designer.cs | 70 ++++++++++++++++++ Properties/Resources.resx | 117 +++++++++++++++++++++++++++++++ Properties/Settings.Designer.cs | 29 ++++++++ Properties/Settings.settings | 7 ++ ScreenForm.cs | 100 ++++++++++++++++++++++++++ ScreenSaver.csproj | 72 +++++++++++++++++++ ScreenSaver.sln | 25 +++++++ 10 files changed, 508 insertions(+) create mode 100644 .gitignore create mode 100644 Program.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings create mode 100644 ScreenForm.cs create mode 100644 ScreenSaver.csproj create mode 100644 ScreenSaver.sln diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..28bcb4a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.vs +/bin +/obj diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..b2762be --- /dev/null +++ b/Program.cs @@ -0,0 +1,49 @@ +using System; +using System.Windows.Forms; + +namespace ScreenSaver +{ + static class Program + { + [STAThread] + static void Main(string[] args) + { + if (args.Length > 0) + { + string arg = args[0]?.ToLower()?.Trim()?.Substring(0, 2); + + if (arg == "/c") + { + MessageBox.Show("There are no options.", "Screen Saver", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else if (arg == "/p") + { + ShowScreenSaver(); + } + else if (arg == "/s") + { + ShowScreenSaver(); + } + } + else + { + ShowScreenSaver(); + } + } + + static void ShowScreenSaver() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + for (int i = 0; i < Screen.AllScreens.Length; i++) + { + ScreenForm screen = new ScreenForm(i); + screen.Show(); + } + + Application.Run(); + } + + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fc45007 --- /dev/null +++ b/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("Hi, I'm Ray")] +[assembly: AssemblyProduct("ScreenSaver")] +[assembly: AssemblyCopyright("Copyright © Ray Lam 2007")] +[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("79801e77-c175-473e-aadf-e049959209c5")] + +// 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.1")] +[assembly: AssemblyFileVersion("1.0.0.1")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..613933d --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// 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 +{ + /// + /// 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", "4.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 ((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/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/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/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..d899909 --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// 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", "11.0.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/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ScreenForm.cs b/ScreenForm.cs new file mode 100644 index 0000000..e4d9d30 --- /dev/null +++ b/ScreenForm.cs @@ -0,0 +1,100 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace ScreenSaver +{ + public class ScreenForm : Form + { + protected Timer timer = null; + + protected Point startMousePos; + protected int screenNo; + + public ScreenForm(int num) + { + this.AutoScaleBaseSize = new Size(1, 1); + this.BackColor = Color.Black; + this.BackgroundImageLayout = ImageLayout.Zoom; + //this.Bounds = Screen.AllScreens[screenNo].Bounds; + this.ClientSize = new Size(320, 240); + this.FormBorderStyle = FormBorderStyle.None; + this.Name = "ScreenSaverForm"; + this.StartPosition = FormStartPosition.Manual; + this.Text = "Screen " + screenNo.ToString(); + this.TopMost = true; + //this.WindowState = FormWindowState.Maximized; + + timer = new Timer(); + timer.Interval = 4000; + timer.Tick += timer_Tick; + timer.Enabled = true; + + this.screenNo = num; + } + + //protected override void OnPaint(PaintEventArgs e) + //{ + // base.OnPaint(e); + + // e.Graphics.DrawString(screenNo.ToString() + " " + this.Bounds.ToString(), this.Font, new SolidBrush(Color.White), new PointF(100, 100)); + //} + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + this.Bounds = Screen.AllScreens[screenNo].Bounds; + + Cursor.Hide(); + + this.TopMost = true; + } + + protected override void OnKeyDown(KeyEventArgs e) => this.Close(); + + protected override void OnKeyPress(KeyPressEventArgs e) => this.Close(); + + protected override void OnKeyUp(KeyEventArgs e) => this.Close(); + + protected override void OnPreviewKeyDown(PreviewKeyDownEventArgs e) => this.Close(); + + protected override void OnClosing(CancelEventArgs e) => Application.Exit(); + + protected override void OnMouseMove(MouseEventArgs e) + { + //base.OnMouseMove(e); + if (!startMousePos.IsEmpty) + { + if (startMousePos != new Point(e.X, e.Y)) + { + this.Close(); + } + + if (e.Clicks > 0) + { + this.Close(); + } + } + + this.startMousePos = new Point(e.X, e.Y); + } + + protected override void OnMouseDoubleClick(MouseEventArgs e) => this.OnMouseMove(e); + + protected override void OnMouseClick(MouseEventArgs e) => this.OnMouseMove(e); + + protected override void OnMouseDown(MouseEventArgs e) => this.OnMouseMove(e); + + protected override void OnMouseUp(MouseEventArgs e) => this.OnMouseMove(e); + + protected override void OnMouseWheel(MouseEventArgs e) => this.OnMouseMove(e); + + private void timer_Tick(object sender, EventArgs e) + { + //throw new NotImplementedException(); + } + + } +} \ No newline at end of file diff --git a/ScreenSaver.csproj b/ScreenSaver.csproj new file mode 100644 index 0000000..8daa12e --- /dev/null +++ b/ScreenSaver.csproj @@ -0,0 +1,72 @@ + + + + + Debug + AnyCPU + {79801E77-C175-473E-AADF-E049959209C5} + WinExe + ScreenSaver + ScreenSaver + v4.8 + 512 + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + none + true + bin\Release\ + + + prompt + 4 + false + + + true + + + + + + + + + + + Form + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + \ No newline at end of file diff --git a/ScreenSaver.sln b/ScreenSaver.sln new file mode 100644 index 0000000..747074f --- /dev/null +++ b/ScreenSaver.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31019.35 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScreenSaver", "ScreenSaver.csproj", "{79801E77-C175-473E-AADF-E049959209C5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {79801E77-C175-473E-AADF-E049959209C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79801E77-C175-473E-AADF-E049959209C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79801E77-C175-473E-AADF-E049959209C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79801E77-C175-473E-AADF-E049959209C5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B22A9FAE-B98F-4D9D-B5E8-F7B4E61EFFEC} + EndGlobalSection +EndGlobal