mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-04 04:06:05 +13:00
Added companion cubes
This commit is contained in:
parent
ea3d3bb47e
commit
6fafea7a17
9 changed files with 392 additions and 15 deletions
114
ShareX/CompanionCubeManager.cs
Normal file
114
ShareX/CompanionCubeManager.cs
Normal file
|
@ -0,0 +1,114 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2015 ShareX Team
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using ShareX.ScreenCaptureLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public static class CompanionCubeManager
|
||||
{
|
||||
public static bool IsActive { get; set; }
|
||||
public static int CubeCount { get; } = 100;
|
||||
|
||||
private static List<CompanionCubeForm> cubes;
|
||||
private static Timer timer;
|
||||
private static Stopwatch startTime;
|
||||
private static TimeSpan previousElapsed;
|
||||
private static Rectangle screen;
|
||||
|
||||
static CompanionCubeManager()
|
||||
{
|
||||
cubes = new List<CompanionCubeForm>();
|
||||
timer = new Timer();
|
||||
timer.Interval = 20;
|
||||
timer.Tick += Timer_Tick;
|
||||
}
|
||||
|
||||
public static void Toggle()
|
||||
{
|
||||
if (!IsActive)
|
||||
{
|
||||
IsActive = true;
|
||||
|
||||
screen = CaptureHelpers.GetScreenWorkingArea();
|
||||
|
||||
for (int i = 0; i < CubeCount; i++)
|
||||
{
|
||||
CompanionCubeForm cube = new CompanionCubeForm(MathHelpers.Random(100, 500), MathHelpers.Random(50, 100));
|
||||
cube.Location = new Point(MathHelpers.Random(screen.X, screen.X + screen.Width - cube.CubeSize),
|
||||
MathHelpers.Random(screen.Y - cube.CubeSize - 500, screen.Y - cube.CubeSize));
|
||||
cube.Show();
|
||||
Console.WriteLine(cube.Location);
|
||||
cubes.Add(cube);
|
||||
}
|
||||
|
||||
startTime = Stopwatch.StartNew();
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private static void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
TimeSpan elapsed = startTime.Elapsed - previousElapsed;
|
||||
previousElapsed = startTime.Elapsed;
|
||||
|
||||
foreach (CompanionCubeForm cube in cubes)
|
||||
{
|
||||
int velocityY = (int)(cube.Gravity * elapsed.TotalSeconds);
|
||||
Point newLoc = new Point(cube.Location.X, cube.Location.Y + velocityY);
|
||||
Rectangle newRect = new Rectangle(newLoc, new Size(cube.CubeSize, cube.CubeSize));
|
||||
bool intersect = false;
|
||||
|
||||
foreach (CompanionCubeForm cube2 in cubes)
|
||||
{
|
||||
if (cube != cube2 && newRect.IntersectsWith(cube2.CubeRectangle))
|
||||
{
|
||||
intersect = true;
|
||||
newLoc = new Point(cube.Location.X, cube2.Location.Y - cube.CubeSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!intersect && newLoc.Y + cube.CubeSize > screen.Y + screen.Height)
|
||||
{
|
||||
newLoc = new Point(cube.Location.X, screen.Height - cube.CubeSize);
|
||||
}
|
||||
|
||||
if (cube.Location != newLoc)
|
||||
{
|
||||
cube.Location = newLoc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -228,27 +228,34 @@ private void cLogo_Draw(Graphics g)
|
|||
|
||||
private void cLogo_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!isEasterEggStarted)
|
||||
if (e.Button == MouseButtons.Middle)
|
||||
{
|
||||
isPaused = !isPaused;
|
||||
|
||||
clickCount++;
|
||||
|
||||
if (clickCount >= 10)
|
||||
{
|
||||
isEasterEggStarted = true;
|
||||
cLogo.Stop();
|
||||
RunEasterEgg();
|
||||
}
|
||||
CompanionCubeManager.Toggle();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bounceTimer != null)
|
||||
if (!isEasterEggStarted)
|
||||
{
|
||||
bounceTimer.Stop();
|
||||
}
|
||||
isPaused = !isPaused;
|
||||
|
||||
isEasterEggStarted = false;
|
||||
clickCount++;
|
||||
|
||||
if (clickCount >= 10)
|
||||
{
|
||||
isEasterEggStarted = true;
|
||||
cLogo.Stop();
|
||||
RunEasterEgg();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bounceTimer != null)
|
||||
{
|
||||
bounceTimer.Stop();
|
||||
}
|
||||
|
||||
isEasterEggStarted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
54
ShareX/Forms/CompanionCubeForm.Designer.cs
generated
Normal file
54
ShareX/Forms/CompanionCubeForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,54 @@
|
|||
namespace ShareX
|
||||
{
|
||||
partial class CompanionCubeForm
|
||||
{
|
||||
/// <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.SuspendLayout();
|
||||
//
|
||||
// CompanionCubeForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||
this.ClientSize = new System.Drawing.Size(284, 261);
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Name = "CompanionCubeForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "CompanionCubeForm";
|
||||
this.TopMost = true;
|
||||
this.Load += new System.EventHandler(this.CompanionCubeForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
58
ShareX/Forms/CompanionCubeForm.cs
Normal file
58
ShareX/Forms/CompanionCubeForm.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2015 ShareX Team
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using ShareX.Properties;
|
||||
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;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public partial class CompanionCubeForm : Form
|
||||
{
|
||||
public Rectangle CubeRectangle => new Rectangle(Location, new Size(CubeSize, CubeSize));
|
||||
public int CubeSize { get; private set; }
|
||||
public int Gravity { get; private set; }
|
||||
|
||||
public CompanionCubeForm(int gravity, int size)
|
||||
{
|
||||
CubeSize = size;
|
||||
Gravity = gravity;
|
||||
InitializeComponent();
|
||||
BackgroundImage = (Bitmap)ImageHelpers.ResizeImage(Resources.CompanionCube, CubeSize, CubeSize);
|
||||
}
|
||||
|
||||
private void CompanionCubeForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
Size = new Size(CubeSize, CubeSize);
|
||||
}
|
||||
}
|
||||
}
|
120
ShareX/Forms/CompanionCubeForm.resx
Normal file
120
ShareX/Forms/CompanionCubeForm.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?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>
|
||||
</root>
|
10
ShareX/Properties/Resources.Designer.cs
generated
10
ShareX/Properties/Resources.Designer.cs
generated
|
@ -551,6 +551,16 @@ public static System.Drawing.Bitmap color {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
public static System.Drawing.Bitmap CompanionCube {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("CompanionCube", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
|
|
@ -799,4 +799,7 @@ Would you like to restart ShareX?</value>
|
|||
<data name="AboutForm_AboutForm_Changelog" xml:space="preserve">
|
||||
<value>Changelog</value>
|
||||
</data>
|
||||
<data name="CompanionCube" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\CompanionCube.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
ShareX/Resources/CompanionCube.png
Normal file
BIN
ShareX/Resources/CompanionCube.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
|
@ -97,6 +97,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CompanionCubeManager.cs" />
|
||||
<Compile Include="Controls\BeforeUploadControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
@ -121,6 +122,12 @@
|
|||
<Compile Include="Forms\ClipboardFormatForm.Designer.cs">
|
||||
<DependentUpon>ClipboardFormatForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\CompanionCubeForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\CompanionCubeForm.Designer.cs">
|
||||
<DependentUpon>CompanionCubeForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EncoderProgramForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -540,6 +547,9 @@
|
|||
<EmbeddedResource Include="Forms\ClipboardFormatForm.zh-CN.resx">
|
||||
<DependentUpon>ClipboardFormatForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\CompanionCubeForm.resx">
|
||||
<DependentUpon>CompanionCubeForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\EncoderProgramForm.de.resx">
|
||||
<DependentUpon>EncoderProgramForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
@ -1065,6 +1075,7 @@
|
|||
<None Include="Resources\cross.png" />
|
||||
<None Include="Resources\arrow-270.png" />
|
||||
<None Include="Resources\ru.png" />
|
||||
<None Include="Resources\CompanionCube.png" />
|
||||
<Content Include="ShareX_Icon.ico" />
|
||||
<None Include="Resources\globe--pencil.png" />
|
||||
<None Include="Resources\camcorder--pencil.png" />
|
||||
|
|
Loading…
Reference in a new issue