Skip to content

Commit

Permalink
Added OneClickMode to rectangle region to be able to get handle of se…
Browse files Browse the repository at this point in the history
…lected control
  • Loading branch information
Jaex committed Sep 25, 2015
1 parent 918e254 commit 2e59b2e
Show file tree
Hide file tree
Showing 11 changed files with 348 additions and 25 deletions.
20 changes: 20 additions & 0 deletions Licenses/DirectShow_devices_license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This license governs use of the accompanying software. If you use the software, you
accept this license. If you do not accept the license, do not use the software.

1. Definitions
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the
same meaning here as under U.S. copyright law.
A "contribution" is the original software, or any additions or changes to the software.
A "contributor" is any person that distributes its contribution under this license.
"Licensed patents" are a contributor's patent claims that read directly on its contribution.

2. Grant of Rights
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.

3. Conditions and Limitations
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
13 changes: 11 additions & 2 deletions ShareX.ScreenCaptureLib/Forms/RectangleRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public Color CurrentColor

#endregion Screen ruler

public bool OneClickMode { get; set; }
public SimpleWindowInfo SelectedWindow { get; set; }

private ColorBlinkAnimation colorBlinkAnimation = new ColorBlinkAnimation();

public RectangleRegion()
Expand All @@ -81,9 +84,15 @@ public RectangleRegion()

private void RectangleRegion_MouseDown(object sender, MouseEventArgs e)
{
if (ScreenColorPickerMode && e.Button == MouseButtons.Left)
if ((OneClickMode || ScreenColorPickerMode) && e.Button == MouseButtons.Left)
{
CurrentPosition = InputManager.MousePosition;

if (OneClickMode)
{
SelectedWindow = AreaManager.FindSelectedWindow();
}

Close(SurfaceResult.Region);
}
}
Expand Down Expand Up @@ -162,7 +171,7 @@ public override void Prepare()
AreaManager.WindowCaptureMode |= Config.ForceWindowCapture;
AreaManager.IncludeControls |= Config.IncludeControls;

if (AreaManager.WindowCaptureMode)
if (OneClickMode || AreaManager.WindowCaptureMode)
{
IntPtr handle = Handle;

Expand Down
59 changes: 59 additions & 0 deletions ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#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 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.ScreenCaptureLib
{
public partial class ScrollingCaptureForm : BaseForm
{
public ScrollingCaptureForm()
{
InitializeComponent();
}
}
}
120 changes: 120 additions & 0 deletions ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.resx
Original file line number Diff line number Diff line change
@@ -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>
20 changes: 15 additions & 5 deletions ShareX.ScreenCaptureLib/RegionHelpers/AreaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public bool IsResizing
public bool IsProportionalResizing { get; private set; }
public bool IsSnapResizing { get; private set; }

public List<Rectangle> Windows { get; set; }
public List<SimpleWindowInfo> Windows { get; set; }
public bool WindowCaptureMode { get; set; }
public bool IncludeControls { get; set; }
public int MinimumSize { get; set; }
Expand Down Expand Up @@ -319,19 +319,29 @@ private void CheckHover()
{
CurrentHoverArea = hoverArea;
}
else if (WindowCaptureMode && Windows != null)
else
{
hoverArea = Windows.FirstOrDefault(x => x.Contains(InputManager.MousePosition));
SimpleWindowInfo window = FindSelectedWindow();

if (!hoverArea.IsEmpty)
if (window != null && !window.Rectangle.IsEmpty)
{
hoverArea = CaptureHelpers.ScreenToClient(hoverArea);
hoverArea = CaptureHelpers.ScreenToClient(window.Rectangle);
CurrentHoverArea = Rectangle.Intersect(surface.ScreenRectangle0Based, hoverArea);
}
}
}
}

public SimpleWindowInfo FindSelectedWindow()
{
if (Windows != null)
{
return Windows.FirstOrDefault(x => x.Rectangle.Contains(InputManager.MousePosition));
}

return null;
}

private void surface_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
Expand Down
10 changes: 10 additions & 0 deletions ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
<Compile Include="Forms\RectangleTransparent.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\ScrollingCaptureForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\ScrollingCaptureForm.Designer.cs">
<DependentUpon>ScrollingCaptureForm.cs</DependentUpon>
</Compile>
<Compile Include="MonitorRegion.cs" />
<Compile Include="MonitorRegionDefaultCreator.cs" />
<Compile Include="RectangleAnnotateOptions.cs" />
Expand Down Expand Up @@ -109,6 +115,7 @@
<Compile Include="RegionHelpers\NodeObject.cs" />
<Compile Include="RegionHelpers\ResizeManager.cs" />
<Compile Include="RegionHelpers\ShapeCaptureHelpers.cs" />
<Compile Include="SimpleWindowInfo.cs" />
<Compile Include="SnapSize.cs" />
<Compile Include="SurfaceOptions.cs" />
<Compile Include="Screencast\ScreenRecorder.cs" />
Expand All @@ -131,6 +138,9 @@
<Content Include="Resources\Crosshair.cur" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\ScrollingCaptureForm.resx">
<DependentUpon>ScrollingCaptureForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.de.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
Expand Down
Loading

0 comments on commit 2e59b2e

Please sign in to comment.