Added Greenlight button

This commit is contained in:
Jaex 2015-07-25 18:06:32 +03:00
parent 35f835c2bf
commit e396c9260f
9 changed files with 237 additions and 88 deletions

View file

@ -0,0 +1,152 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright © 2007-2015 ShareX Developers
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 System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace ShareX.HelpersLib
{
[DefaultEvent("MouseClick")]
public class GreenlightButton : Control
{
[Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
public override string Text
{
get
{
return text;
}
set
{
if (value == null)
{
value = "";
}
if (text != value)
{
text = value;
Refresh();
}
}
}
private string text;
private bool isHover;
private LinearGradientBrush backgroundBrush, backgroundHoverBrush, borderBrush;
private Pen borderPen;
private bool ready;
public GreenlightButton()
{
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
}
private void Prepare()
{
ForeColor = Color.White;
backgroundBrush = new LinearGradientBrush(new Rectangle(0, 0, ClientSize.Width, ClientSize.Height), Color.FromArgb(121, 153, 5), Color.FromArgb(83, 105, 5),
LinearGradientMode.Vertical);
backgroundHoverBrush = new LinearGradientBrush(new Rectangle(0, 0, ClientSize.Width, ClientSize.Height), Color.FromArgb(140, 170, 5), Color.FromArgb(93, 115, 5),
LinearGradientMode.Vertical);
borderBrush = new LinearGradientBrush(new Rectangle(0, 0, ClientSize.Width, ClientSize.Height), Color.White, Color.Black, LinearGradientMode.Vertical);
borderPen = new Pen(borderBrush);
Font = new Font("Arial", 12);
ready = true;
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
if (ready)
{
Graphics g = pe.Graphics;
DrawBackground(g);
if (!string.IsNullOrEmpty(Text))
{
DrawText(g);
}
}
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
isHover = true;
Refresh();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
isHover = false;
Refresh();
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Prepare();
}
private void DrawBackground(Graphics g)
{
g.SetHighQuality();
if (isHover)
{
g.DrawRoundedRectangle(backgroundHoverBrush, borderPen, new Rectangle(0, 0, ClientSize.Width - 1, ClientSize.Height - 1), 2);
}
else
{
g.DrawRoundedRectangle(backgroundBrush, borderPen, new Rectangle(0, 0, ClientSize.Width - 1, ClientSize.Height - 1), 2);
}
}
private void DrawText(Graphics g)
{
TextRenderer.DrawText(g, Text, Font, new Rectangle(ClientRectangle.X, ClientRectangle.Y + 1, ClientRectangle.Width, ClientRectangle.Height + 1), Color.Black);
TextRenderer.DrawText(g, Text, Font, ClientRectangle, ForeColor);
}
protected override void Dispose(bool disposing)
{
if (backgroundBrush != null) backgroundBrush.Dispose();
if (backgroundHoverBrush != null) backgroundHoverBrush.Dispose();
if (borderBrush != null) borderBrush.Dispose();
if (borderPen != null) borderPen.Dispose();
base.Dispose(disposing);
}
}
}

View file

@ -448,20 +448,13 @@ public static string decode_mmioFOURCC(int code)
public static bool Is64Bit()
{
if (IntPtr.Size == 8 || (IntPtr.Size == 4 && Is32BitProcessOn64BitProcessor()))
{
return true;
}
return false;
return IntPtr.Size == 8 || (IntPtr.Size == 4 && Is32BitProcessOn64BitProcessor());
}
private static bool Is32BitProcessOn64BitProcessor()
{
bool retVal;
IsWow64Process(Process.GetCurrentProcess().Handle, out retVal);
return retVal;
}
}

View file

@ -103,6 +103,9 @@
<Compile Include="Colors\HSB.cs" />
<Compile Include="Colors\MyColor.cs" />
<Compile Include="Colors\RGBA.cs" />
<Compile Include="Controls\GreenlightButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\LabelNoCopy.cs">
<SubType>Component</SubType>
</Compile>

View file

@ -69,8 +69,8 @@
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="AWSSDK, Version=2.3.46.0, Culture=neutral, PublicKeyToken=9f476d3089b52be3, processorArchitecture=MSIL">
<HintPath>..\packages\AWSSDK.2.3.46.0\lib\net35\AWSSDK.dll</HintPath>
<Reference Include="AWSSDK, Version=2.3.48.0, Culture=neutral, PublicKeyToken=9f476d3089b52be3, processorArchitecture=MSIL">
<HintPath>..\packages\AWSSDK.2.3.48.0\lib\net35\AWSSDK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="crypto">
@ -85,8 +85,8 @@
<Private>True</Private>
</Reference>
<Reference Include="Renci.SshNet, Version=2014.4.6.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\SSH.NET.2014.4.6-beta1\lib\net40\Renci.SshNet.dll</HintPath>
<HintPath>..\packages\SSH.NET.2014.4.6-beta2\lib\net40\Renci.SshNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Design" />
@ -692,12 +692,12 @@
<None Include="Favicons\MediaFire.ico" />
<None Include="Favicons\OwnCloud.png" />
<None Include="Favicons\Pushbullet.ico" />
<None Include="Favicons\OneDrive.ico" />
<None Include="Favicons\Chevereto.png" />
<None Include="Favicons\Hastebin.png" />
<None Include="Favicons\hubic.ico" />
<None Include="Favicons\Up1.ico" />
<None Include="Favicons\CoinURL.ico" />
<None Include="Favicons\OneDrive.ico" />
<None Include="Favicons\Chevereto.png" />
<None Include="Favicons\Hastebin.png" />
<None Include="Favicons\hubic.ico" />
<None Include="Favicons\Up1.ico" />
<None Include="Favicons\CoinURL.ico" />
<None Include="Favicons\LnkU.ico" />
<None Include="Favicons\copy.ico" />
<None Include="Favicons\Lambda.ico" />

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AWSSDK" version="2.3.46.0" targetFramework="net40" />
<package id="MegaApiClient" version="1.1.1" targetFramework="net40" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net40" />
<package id="Portable.BouncyCastle" version="1.7.0.2" targetFramework="net40" />
<package id="SSH.NET" version="2014.4.6-beta1" targetFramework="net40" />
<package id="System.Net.FtpClient" version="1.0.5281.14359" targetFramework="net40" />
<package id="AWSSDK" version="2.3.48.0" targetFramework="net4" />
<package id="MegaApiClient" version="1.1.1" targetFramework="net4" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net4" />
<package id="Portable.BouncyCastle" version="1.7.0.2" targetFramework="net4" />
<package id="SSH.NET" version="2014.4.6-beta2" targetFramework="net4" />
<package id="System.Net.FtpClient" version="1.0.5281.14359" targetFramework="net4" />
</packages>

View file

@ -40,6 +40,7 @@ public class ApplicationConfig : SettingsBase<ApplicationConfig>
public bool ShowUploadWarning = true; // First time upload warning
public bool ShowMultiUploadWarning = true; // More than 10 files upload warning
public bool ShowTrayMiddleClickTip = true; // Tray icon middle click tip
public bool ShowGreenlightButton = true;
public int NameParserAutoIncrementNumber = 0;
public RecentItem[] RecentLinks = null;
public bool DisableHotkeys = false;

View file

@ -43,8 +43,8 @@ private void InitializeComponent()
this.chURL = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.pbPreview = new ShareX.HelpersLib.MyPictureBox();
this.pGreenlight = new System.Windows.Forms.Panel();
this.btnGreenlightHide = new ShareX.HelpersLib.BlackStyleButton();
this.btnGreenlightOpen = new ShareX.HelpersLib.BlackStyleButton();
this.btnGreenlightHide = new ShareX.HelpersLib.GreenlightButton();
this.btnGreenlightOpen = new ShareX.HelpersLib.GreenlightButton();
this.tsMain = new System.Windows.Forms.ToolStrip();
this.tsddbCapture = new System.Windows.Forms.ToolStripDropDownButton();
this.tsmiFullscreen = new System.Windows.Forms.ToolStripMenuItem();
@ -263,7 +263,7 @@ private void InitializeComponent()
//
// lblSplitter
//
this.lblSplitter.BackColor = System.Drawing.Color.Black;
this.lblSplitter.BackColor = System.Drawing.Color.Gray;
resources.ApplyResources(this.lblSplitter, "lblSplitter");
this.lblSplitter.Name = "lblSplitter";
//
@ -340,15 +340,19 @@ private void InitializeComponent()
//
// btnGreenlightHide
//
this.btnGreenlightHide.Cursor = System.Windows.Forms.Cursors.Hand;
resources.ApplyResources(this.btnGreenlightHide, "btnGreenlightHide");
this.btnGreenlightHide.ForeColor = System.Drawing.Color.White;
this.btnGreenlightHide.Name = "btnGreenlightHide";
this.btnGreenlightHide.MouseClick += new System.Windows.Forms.MouseEventHandler(this.btnGreenlightHide_MouseClick);
//
// btnGreenlightOpen
//
this.btnGreenlightOpen.Cursor = System.Windows.Forms.Cursors.Hand;
resources.ApplyResources(this.btnGreenlightOpen, "btnGreenlightOpen");
this.btnGreenlightOpen.ForeColor = System.Drawing.Color.White;
this.btnGreenlightOpen.Name = "btnGreenlightOpen";
this.btnGreenlightOpen.MouseClick += new System.Windows.Forms.MouseEventHandler(this.btnGreenlightOpen_MouseClick);
//
// tsMain
//
@ -1724,9 +1728,9 @@ private void InitializeComponent()
this.AllowDrop = true;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.pGreenlight);
this.Controls.Add(this.scMain);
this.Controls.Add(this.tsMain);
this.Controls.Add(this.pGreenlight);
this.DoubleBuffered = true;
this.Name = "MainForm";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
@ -1946,7 +1950,7 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem tsmiTrayWebpageCapture;
private System.Windows.Forms.ToolStripMenuItem tsmiTrayToggleHotkeys;
private System.Windows.Forms.Panel pGreenlight;
private HelpersLib.BlackStyleButton btnGreenlightHide;
private HelpersLib.BlackStyleButton btnGreenlightOpen;
private HelpersLib.GreenlightButton btnGreenlightOpen;
private HelpersLib.GreenlightButton btnGreenlightHide;
}
}

View file

@ -561,6 +561,8 @@ private void LoadSettings()
UpdateToggleHotkeyButton();
TaskbarManager.Enabled = Program.Settings.TaskbarProgressEnabled;
pGreenlight.Visible = Program.Settings.ShowGreenlightButton;
}
private void RegisterMenuClosing()
@ -1470,6 +1472,24 @@ private void tsmiImagePreviewAutomatic_Click(object sender, EventArgs e)
UpdateControls();
}
private void btnGreenlightOpen_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
URLHelpers.OpenURL("");
btnGreenlightOpen.Text = "Thanks for considering voting :)\r\nYou can hide these buttons by pressing hide button on the right side:";
}
}
private void btnGreenlightHide_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
pGreenlight.Visible = false;
Program.Settings.ShowGreenlightButton = false;
}
}
#endregion UploadInfoMenu events
#endregion Form events

View file

@ -274,7 +274,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;scMain.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="chFilename.Text" xml:space="preserve">
<value>Filename</value>
@ -318,54 +318,6 @@
<data name="pGreenlight.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value>
</data>
<data name="&gt;&gt;btnGreenlightHide.Name" xml:space="preserve">
<value>btnGreenlightHide</value>
</data>
<data name="&gt;&gt;btnGreenlightHide.Type" xml:space="preserve">
<value>ShareX.HelpersLib.BlackStyleButton, ShareX.HelpersLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;btnGreenlightHide.Parent" xml:space="preserve">
<value>pGreenlight</value>
</data>
<data name="&gt;&gt;btnGreenlightHide.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="&gt;&gt;btnGreenlightOpen.Name" xml:space="preserve">
<value>btnGreenlightOpen</value>
</data>
<data name="&gt;&gt;btnGreenlightOpen.Type" xml:space="preserve">
<value>ShareX.HelpersLib.BlackStyleButton, ShareX.HelpersLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;btnGreenlightOpen.Parent" xml:space="preserve">
<value>pGreenlight</value>
</data>
<data name="&gt;&gt;btnGreenlightOpen.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="pGreenlight.Location" type="System.Drawing.Point, System.Drawing">
<value>170, 362</value>
</data>
<data name="pGreenlight.Size" type="System.Drawing.Size, System.Drawing">
<value>656, 45</value>
</data>
<data name="pGreenlight.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="pGreenlight.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;pGreenlight.Name" xml:space="preserve">
<value>pGreenlight</value>
</data>
<data name="&gt;&gt;pGreenlight.Type" xml:space="preserve">
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pGreenlight.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;pGreenlight.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="btnGreenlightHide.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Right</value>
</data>
@ -373,13 +325,13 @@
<value>Arial, 12pt</value>
</data>
<data name="btnGreenlightHide.Location" type="System.Drawing.Point, System.Drawing">
<value>553, 0</value>
<value>581, 0</value>
</data>
<data name="btnGreenlightHide.Size" type="System.Drawing.Size, System.Drawing">
<value>103, 45</value>
<value>75, 56</value>
</data>
<data name="btnGreenlightHide.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
<value>3</value>
</data>
<data name="btnGreenlightHide.Text" xml:space="preserve">
<value>Hide</value>
@ -388,7 +340,7 @@
<value>btnGreenlightHide</value>
</data>
<data name="&gt;&gt;btnGreenlightHide.Type" xml:space="preserve">
<value>ShareX.HelpersLib.BlackStyleButton, ShareX.HelpersLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>ShareX.HelpersLib.GreenlightButton, ShareX.HelpersLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;btnGreenlightHide.Parent" xml:space="preserve">
<value>pGreenlight</value>
@ -406,20 +358,20 @@
<value>0, 0</value>
</data>
<data name="btnGreenlightOpen.Size" type="System.Drawing.Size, System.Drawing">
<value>560, 45</value>
<value>576, 56</value>
</data>
<data name="btnGreenlightOpen.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
<value>2</value>
</data>
<data name="btnGreenlightOpen.Text" xml:space="preserve">
<value>We need your help for us to be able to release ShareX in Steam!
<value>We need your help to be able to release ShareX on Steam!
If you would like to vote, click here to open our Steam Greenlight page.</value>
</data>
<data name="&gt;&gt;btnGreenlightOpen.Name" xml:space="preserve">
<value>btnGreenlightOpen</value>
</data>
<data name="&gt;&gt;btnGreenlightOpen.Type" xml:space="preserve">
<value>ShareX.HelpersLib.BlackStyleButton, ShareX.HelpersLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>ShareX.HelpersLib.GreenlightButton, ShareX.HelpersLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;btnGreenlightOpen.Parent" xml:space="preserve">
<value>pGreenlight</value>
@ -427,6 +379,30 @@ If you would like to vote, click here to open our Steam Greenlight page.</value>
<data name="&gt;&gt;btnGreenlightOpen.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="pGreenlight.Location" type="System.Drawing.Point, System.Drawing">
<value>170, 344</value>
</data>
<data name="pGreenlight.Size" type="System.Drawing.Size, System.Drawing">
<value>656, 56</value>
</data>
<data name="pGreenlight.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="pGreenlight.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;pGreenlight.Name" xml:space="preserve">
<value>pGreenlight</value>
</data>
<data name="&gt;&gt;pGreenlight.Type" xml:space="preserve">
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pGreenlight.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;pGreenlight.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<metadata name="tsMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
@ -458,7 +434,7 @@ If you would like to vote, click here to open our Steam Greenlight page.</value>
<value>$this</value>
</data>
<data name="&gt;&gt;tsMain.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="tsddbCapture.ImageAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>