mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Removed AsyncBridge library, FFmpeg error window for be able see all output, Replaced ThreadPool with Task.Run
This commit is contained in:
parent
c2f2d48342
commit
e1e29f7b6b
32 changed files with 520 additions and 254 deletions
|
@ -38,9 +38,6 @@ public abstract class ExternalCLIManager : IDisposable
|
|||
public event DataReceivedEventHandler OutputDataReceived;
|
||||
public event DataReceivedEventHandler ErrorDataReceived;
|
||||
|
||||
public StringBuilder Output { get; private set; }
|
||||
public StringBuilder Errors { get; private set; }
|
||||
|
||||
private Process process = new Process();
|
||||
|
||||
public virtual int Open(string path, string args = null)
|
||||
|
@ -49,9 +46,6 @@ public virtual int Open(string path, string args = null)
|
|||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Output = new StringBuilder();
|
||||
Errors = new StringBuilder();
|
||||
|
||||
ProcessStartInfo psi = new ProcessStartInfo(path);
|
||||
psi.UseShellExecute = false;
|
||||
psi.CreateNoWindow = true;
|
||||
|
@ -78,8 +72,6 @@ private void cli_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
|||
{
|
||||
if (e.Data != null)
|
||||
{
|
||||
Output.AppendLine(e.Data);
|
||||
|
||||
if (OutputDataReceived != null)
|
||||
{
|
||||
OutputDataReceived(sender, e);
|
||||
|
@ -91,8 +83,6 @@ private void cli_ErrorDataReceived(object sender, DataReceivedEventArgs e)
|
|||
{
|
||||
if (e.Data != null)
|
||||
{
|
||||
Errors.AppendLine(e.Data);
|
||||
|
||||
if (ErrorDataReceived != null)
|
||||
{
|
||||
ErrorDataReceived(sender, e);
|
||||
|
|
68
HelpersLib/Forms/OutputBox.Designer.cs
generated
Normal file
68
HelpersLib/Forms/OutputBox.Designer.cs
generated
Normal file
|
@ -0,0 +1,68 @@
|
|||
namespace HelpersLib
|
||||
{
|
||||
partial class OutputBox
|
||||
{
|
||||
/// <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.txtText = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtText
|
||||
//
|
||||
this.txtText.BackColor = System.Drawing.Color.Black;
|
||||
this.txtText.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txtText.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtText.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
||||
this.txtText.ForeColor = System.Drawing.Color.White;
|
||||
this.txtText.Location = new System.Drawing.Point(0, 0);
|
||||
this.txtText.Multiline = true;
|
||||
this.txtText.Name = "txtText";
|
||||
this.txtText.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.txtText.Size = new System.Drawing.Size(684, 562);
|
||||
this.txtText.TabIndex = 0;
|
||||
//
|
||||
// OutputBox
|
||||
//
|
||||
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(684, 562);
|
||||
this.Controls.Add(this.txtText);
|
||||
this.Name = "OutputBox";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "OutputBox";
|
||||
this.TopMost = true;
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox txtText;
|
||||
}
|
||||
}
|
48
HelpersLib/Forms/OutputBox.cs
Normal file
48
HelpersLib/Forms/OutputBox.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (C) 2007-2014 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.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HelpersLib
|
||||
{
|
||||
public partial class OutputBox : Form
|
||||
{
|
||||
public OutputBox(string text, string title)
|
||||
{
|
||||
InitializeComponent();
|
||||
Icon = ShareXResources.Icon;
|
||||
Text = "ShareX - " + title;
|
||||
txtText.Text = text;
|
||||
txtText.SelectionStart = txtText.TextLength;
|
||||
}
|
||||
}
|
||||
}
|
120
HelpersLib/Forms/OutputBox.resx
Normal file
120
HelpersLib/Forms/OutputBox.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=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>
|
|
@ -471,7 +471,7 @@ public static void OpenURL(string url)
|
|||
{
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -606,7 +606,7 @@ public static object Clone(object obj)
|
|||
|
||||
public static void PlaySoundAsync(Stream stream)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
Task.Run(() =>
|
||||
{
|
||||
using (stream)
|
||||
using (SoundPlayer soundPlayer = new SoundPlayer(stream))
|
||||
|
|
|
@ -64,7 +64,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HelpersLib
|
||||
|
|
|
@ -51,10 +51,6 @@
|
|||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AsyncBridge.Net35, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b3b1c0202c0d6a87, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\AsyncBridge.Net35.0.2.0\lib\net35-Client\AsyncBridge.Net35.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Gma.QrCodeNet.Encoding">
|
||||
<HintPath>..\packages\QrCode.Net.0.4.0.0\lib\net35\Gma.QrCodeNet.Encoding.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -70,10 +66,6 @@
|
|||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing.Design" />
|
||||
<Reference Include="System.Runtime.Remoting" />
|
||||
<Reference Include="System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\TaskParallelLibrary.1.0.2856.0\lib\Net35\System.Threading.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
|
@ -95,6 +87,12 @@
|
|||
<Compile Include="EncoderProgram.cs" />
|
||||
<Compile Include="CLI\ExternalCLIManager.cs" />
|
||||
<Compile Include="FontSafe.cs" />
|
||||
<Compile Include="Forms\OutputBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\OutputBox.Designer.cs">
|
||||
<DependentUpon>OutputBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\QRCodeForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -117,6 +115,7 @@
|
|||
<Compile Include="PingHelper.cs" />
|
||||
<Compile Include="PingResult.cs" />
|
||||
<Compile Include="ProxyInfo.cs" />
|
||||
<Compile Include="Task.cs" />
|
||||
<Compile Include="UITypeEditors\EnumDescriptionConverter.cs" />
|
||||
<Compile Include="UITypeEditors\DirectoryNameEditor.cs" />
|
||||
<Compile Include="UITypeEditors\MyColorConverter.cs" />
|
||||
|
@ -335,6 +334,9 @@
|
|||
<EmbeddedResource Include="Forms\MonitorTestForm.resx">
|
||||
<DependentUpon>MonitorTestForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\OutputBox.resx">
|
||||
<DependentUpon>OutputBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\QRCodeForm.resx">
|
||||
<DependentUpon>QRCodeForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
|
@ -66,7 +66,7 @@ private void Save()
|
|||
|
||||
public void SaveAsync(string filePath)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state => Save(filePath));
|
||||
Task.Run(() => Save(filePath));
|
||||
}
|
||||
|
||||
private void SaveAsync()
|
||||
|
|
41
HelpersLib/Task.cs
Normal file
41
HelpersLib/Task.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (C) 2007-2014 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace HelpersLib
|
||||
{
|
||||
public static class Task
|
||||
{
|
||||
public static void Run(Action action)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state => action());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AsyncBridge.Net35" version="0.2.0" targetFramework="net35" />
|
||||
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net35" />
|
||||
<package id="QrCode.Net" version="0.4.0.0" targetFramework="net35" />
|
||||
<package id="TaskParallelLibrary" version="1.0.2856.0" targetFramework="net35" />
|
||||
</packages>
|
|
@ -45,20 +45,12 @@
|
|||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AsyncBridge.Net35, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b3b1c0202c0d6a87, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\AsyncBridge.Net35.0.2.0\lib\net35-Client\AsyncBridge.Net35.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ImageListView, Version=11.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\ImageListView.11.0.1\lib\net35\ImageListView.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\TaskParallelLibrary.1.0.2856.0\lib\Net35\System.Threading.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
|
|
@ -73,13 +73,11 @@ public List<HistoryItem> GetHistoryItems()
|
|||
|
||||
public static void AddHistoryItemAsync(string historyPath, HistoryItem historyItem)
|
||||
{
|
||||
WaitCallback thread = state =>
|
||||
Task.Run(() =>
|
||||
{
|
||||
HistoryManager history = new HistoryManager(historyPath);
|
||||
history.AppendHistoryItem(historyItem);
|
||||
};
|
||||
|
||||
ThreadPool.QueueUserWorkItem(thread);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AsyncBridge.Net35" version="0.2.0" targetFramework="net35" />
|
||||
<package id="ImageListView" version="11.0.1" targetFramework="net35" />
|
||||
<package id="TaskParallelLibrary" version="1.0.2856.0" targetFramework="net35" />
|
||||
</packages>
|
|
@ -41,10 +41,6 @@
|
|||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AsyncBridge.Net35, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b3b1c0202c0d6a87, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\AsyncBridge.Net35.0.2.0\lib\net35-Client\AsyncBridge.Net35.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SevenZipSharp">
|
||||
<HintPath>..\packages\SevenZipSharp.0.64\lib\SevenZipSharp.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
@ -42,22 +42,36 @@ public class FFmpegHelper : ExternalCLIManager
|
|||
public static readonly int libmp3lame_qscale_end = 9;
|
||||
public static readonly string GDIgrab = "GDI grab";
|
||||
|
||||
public StringBuilder Output { get; private set; }
|
||||
public ScreencastOptions Options { get; private set; }
|
||||
|
||||
public FFmpegHelper(ScreencastOptions options)
|
||||
{
|
||||
Output = new StringBuilder();
|
||||
OutputDataReceived += FFmpegHelper_DataReceived;
|
||||
ErrorDataReceived += FFmpegHelper_DataReceived;
|
||||
Options = options;
|
||||
Helpers.CreateDirectoryIfNotExist(Options.OutputPath);
|
||||
}
|
||||
|
||||
private void FFmpegHelper_DataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e.Data))
|
||||
{
|
||||
Output.AppendLine(e.Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Record()
|
||||
{
|
||||
int errorCode = Open(Options.FFmpeg.CLIPath, Options.GetFFmpegArgs());
|
||||
bool result = errorCode == 0;
|
||||
if (Options.FFmpeg.ShowError && !result)
|
||||
{
|
||||
string text = string.Join("\r\n", Errors.ToString().Lines().Where(x => !string.IsNullOrEmpty(x)).TakeLast(10).ToArray());
|
||||
MessageBox.Show(text, "ShareX - FFmpeg error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
new OutputBox(Output.ToString(), "FFmpeg error").ShowDialog();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -133,7 +147,7 @@ public DirectShowDevices GetDirectShowDevices()
|
|||
{
|
||||
string arg = "-list_devices true -f dshow -i dummy";
|
||||
Open(Options.FFmpeg.CLIPath, arg);
|
||||
string output = Errors.ToString();
|
||||
string output = Output.ToString();
|
||||
string[] lines = output.Lines();
|
||||
bool isVideo = true;
|
||||
Regex regex = new Regex("\\[dshow @ \\w+\\] \"(.+)\"", RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
|
|
|
@ -30,6 +30,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ScreenCaptureLib
|
||||
|
@ -39,7 +40,7 @@ public abstract class ImageCache : IDisposable
|
|||
public bool IsWorking { get; protected set; }
|
||||
public ScreencastOptions Options { get; set; }
|
||||
|
||||
protected Task task;
|
||||
protected Thread task;
|
||||
protected BlockingCollection<Image> imageQueue;
|
||||
|
||||
public ImageCache()
|
||||
|
@ -63,7 +64,7 @@ protected virtual void StartConsumerThread()
|
|||
{
|
||||
IsWorking = true;
|
||||
|
||||
task = TaskEx.Run(() =>
|
||||
task = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -95,6 +96,8 @@ protected virtual void StartConsumerThread()
|
|||
IsWorking = false;
|
||||
}
|
||||
});
|
||||
|
||||
task.Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +108,7 @@ public void Finish()
|
|||
if (IsWorking)
|
||||
{
|
||||
imageQueue.CompleteAdding();
|
||||
task.Wait();
|
||||
task.Join();
|
||||
}
|
||||
|
||||
Dispose();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AsyncBridge.Net35" version="0.2.0" targetFramework="net35" />
|
||||
<package id="SevenZipSharp" version="0.64" targetFramework="net35" />
|
||||
<package id="TaskParallelLibrary" version="1.0.2856.0" targetFramework="net35" />
|
||||
</packages>
|
|
@ -32,7 +32,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX
|
||||
|
@ -43,7 +42,7 @@ public partial class MainForm
|
|||
|
||||
private void InitHotkeys()
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
Task.Run(() =>
|
||||
{
|
||||
if (Program.HotkeysConfig == null)
|
||||
{
|
||||
|
@ -467,13 +466,19 @@ private void CaptureLastRegion(TaskSettings taskSettings, bool autoHideForm = tr
|
|||
}
|
||||
}
|
||||
|
||||
private async void PrepareCaptureMenuAsync(ToolStripMenuItem tsmiWindow, EventHandler handlerWindow, ToolStripMenuItem tsmiMonitor, EventHandler handlerMonitor)
|
||||
private void PrepareCaptureMenuAsync(ToolStripMenuItem tsmiWindow, EventHandler handlerWindow, ToolStripMenuItem tsmiMonitor, EventHandler handlerMonitor)
|
||||
{
|
||||
tsmiWindow.DropDownItems.Clear();
|
||||
|
||||
WindowsList windowsList = new WindowsList();
|
||||
List<WindowInfo> windows = await TaskEx.Run(() => windowsList.GetVisibleWindowsList());
|
||||
List<WindowInfo> windows = null;
|
||||
|
||||
Helpers.AsyncJob(() =>
|
||||
{
|
||||
windows = windowsList.GetVisibleWindowsList();
|
||||
},
|
||||
() =>
|
||||
{
|
||||
if (windows != null)
|
||||
{
|
||||
foreach (WindowInfo window in windows)
|
||||
|
@ -515,6 +520,7 @@ private async void PrepareCaptureMenuAsync(ToolStripMenuItem tsmiWindow, EventHa
|
|||
|
||||
tsmiWindow.Invalidate();
|
||||
tsmiMonitor.Invalidate();
|
||||
});
|
||||
}
|
||||
|
||||
#region Menu events
|
||||
|
|
|
@ -30,7 +30,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using UploadersLib;
|
||||
|
||||
|
@ -81,7 +80,7 @@ private void SelectRegion()
|
|||
}
|
||||
}
|
||||
|
||||
public async void StartRecording(TaskSettings TaskSettings)
|
||||
public void StartRecording(TaskSettings TaskSettings)
|
||||
{
|
||||
if (TaskSettings.CaptureSettings.RunScreencastCLI)
|
||||
{
|
||||
|
@ -132,13 +131,10 @@ public async void StartRecording(TaskSettings TaskSettings)
|
|||
|
||||
string path = "";
|
||||
|
||||
try
|
||||
{
|
||||
using (ScreenRegionManager screenRegionManager = new ScreenRegionManager())
|
||||
{
|
||||
ScreenRegionManager screenRegionManager = new ScreenRegionManager();
|
||||
screenRegionManager.Start(captureRectangle);
|
||||
|
||||
await TaskEx.Run(() =>
|
||||
Helpers.AsyncJob(() =>
|
||||
{
|
||||
if (TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVI)
|
||||
{
|
||||
|
@ -174,20 +170,23 @@ await TaskEx.Run(() =>
|
|||
Thread.Sleep(delay);
|
||||
}
|
||||
|
||||
screenRegionManager.ChangeColor();
|
||||
|
||||
this.InvokeSafe(() => TrayIcon.Icon = Resources.control_record.ToIcon());
|
||||
this.InvokeSafe(() =>
|
||||
{
|
||||
screenRegionManager.ChangeColor(Color.FromArgb(0, 255, 0));
|
||||
TrayIcon.Icon = Resources.control_record.ToIcon();
|
||||
});
|
||||
|
||||
screenRecorder.StartRecording();
|
||||
});
|
||||
|
||||
if (screenRegionManager != null)
|
||||
{
|
||||
this.InvokeSafe(() => screenRegionManager.Dispose());
|
||||
}
|
||||
|
||||
if (screenRecorder != null)
|
||||
{
|
||||
TrayIcon.Icon = Resources.camcorder__pencil.ToIcon();
|
||||
TrayIcon.Icon = Resources.camcorder_pencil.ToIcon();
|
||||
|
||||
await TaskEx.Run(() =>
|
||||
{
|
||||
string sourceFilePath = path;
|
||||
|
||||
if (TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.GIF)
|
||||
|
@ -209,15 +208,13 @@ await TaskEx.Run(() =>
|
|||
path = Path.Combine(TaskSettings.CaptureFolder, TaskHelpers.GetFilename(TaskSettings, encoder.OutputExtension));
|
||||
screenRecorder.EncodeUsingCommandLine(encoder, sourceFilePath, path);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
finally
|
||||
},
|
||||
() =>
|
||||
{
|
||||
if (screenRecorder != null)
|
||||
{
|
||||
if (TaskSettings.CaptureSettings.RunScreencastCLI &&
|
||||
!string.IsNullOrEmpty(screenRecorder.CachePath) && File.Exists(screenRecorder.CachePath))
|
||||
if (TaskSettings.CaptureSettings.RunScreencastCLI && !string.IsNullOrEmpty(screenRecorder.CachePath) && File.Exists(screenRecorder.CachePath))
|
||||
{
|
||||
File.Delete(screenRecorder.CachePath);
|
||||
}
|
||||
|
@ -230,7 +227,6 @@ await TaskEx.Run(() =>
|
|||
{
|
||||
TrayIcon.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(path) && File.Exists(path))
|
||||
{
|
||||
|
@ -250,6 +246,7 @@ await TaskEx.Run(() =>
|
|||
}
|
||||
|
||||
IsRecording = false;
|
||||
});
|
||||
}
|
||||
|
||||
private void DownloaderForm_InstallRequested(string filePath)
|
||||
|
|
|
@ -313,7 +313,7 @@ private void openURLToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
||||
if (task != null && task.Info != null && task.Info.Result != null && !string.IsNullOrEmpty(task.Info.Result.ToString()))
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(x => Process.Start(task.Info.Result.ToString()));
|
||||
Task.Run(() => Process.Start(task.Info.Result.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using UploadersLib;
|
||||
|
||||
|
@ -317,7 +316,7 @@ private static void Run(string[] args)
|
|||
SettingsResetEvent = new ManualResetEvent(false);
|
||||
UploaderSettingsResetEvent = new ManualResetEvent(false);
|
||||
HotkeySettingsResetEvent = new ManualResetEvent(false);
|
||||
ThreadPool.QueueUserWorkItem(state => LoadSettings());
|
||||
Task.Run(() => LoadSettings());
|
||||
|
||||
DebugHelper.WriteLine("MainForm init started");
|
||||
MainForm = new MainForm();
|
||||
|
@ -532,11 +531,18 @@ private static void ReloadUploadersConfig(string filePath)
|
|||
UploadersConfig = UploadersLib.UploadersConfig.Load(filePath);
|
||||
}
|
||||
|
||||
public async static void UploadersConfigSaveAsync()
|
||||
public static void UploadersConfigSaveAsync()
|
||||
{
|
||||
if (uploaderConfigWatcher != null) uploaderConfigWatcher.EnableRaisingEvents = false;
|
||||
await TaskEx.Run(() => UploadersConfig.Save(Program.UploadersConfigFilePath));
|
||||
|
||||
Helpers.AsyncJob(() =>
|
||||
{
|
||||
UploadersConfig.Save(Program.UploadersConfigFilePath);
|
||||
},
|
||||
() =>
|
||||
{
|
||||
if (uploaderConfigWatcher != null) uploaderConfigWatcher.EnableRaisingEvents = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
8
ShareX/Properties/Resources.Designer.cs
generated
8
ShareX/Properties/Resources.Designer.cs
generated
|
@ -213,9 +213,9 @@ public static System.Drawing.Bitmap bug {
|
|||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
public static System.Drawing.Bitmap camcorder__pencil {
|
||||
public static System.Drawing.Bitmap camcorder_image {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("camcorder__pencil", resourceCulture);
|
||||
object obj = ResourceManager.GetObject("camcorder_image", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
@ -223,9 +223,9 @@ public static System.Drawing.Bitmap camcorder__pencil {
|
|||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
public static System.Drawing.Bitmap camcorder_image {
|
||||
public static System.Drawing.Bitmap camcorder_pencil {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("camcorder_image", resourceCulture);
|
||||
object obj = ResourceManager.GetObject("camcorder_pencil", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
<data name="hammer_pencil" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\hammer--pencil.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="camcorder__pencil" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<data name="camcorder_pencil" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\camcorder--pencil.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ru" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
|
|
|
@ -42,11 +42,11 @@ public void Start(Rectangle captureRectangle)
|
|||
}
|
||||
}
|
||||
|
||||
public void ChangeColor()
|
||||
public void ChangeColor(Color color)
|
||||
{
|
||||
if (regionForm != null)
|
||||
{
|
||||
regionForm.InvokeSafe(() => regionForm.ChangeColor(Color.FromArgb(0, 255, 0)));
|
||||
regionForm.ChangeColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,9 +66,6 @@
|
|||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AsyncBridge.Net35">
|
||||
<HintPath>..\packages\AsyncBridge.Net35.0.2.0\lib\net35-Client\AsyncBridge.Net35.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MegaApiClient, Version=1.0.4.0, Culture=neutral, PublicKeyToken=0480d311efbeb4e2, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MegaApiClient.1.0.4\lib\MegaApiClient.dll</HintPath>
|
||||
|
@ -83,9 +80,6 @@
|
|||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Threading">
|
||||
<HintPath>..\packages\TaskParallelLibrary.1.0.2856.0\lib\Net35\System.Threading.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AsyncBridge.Net35" version="0.2.0" targetFramework="net35" />
|
||||
<package id="MegaApiClient" version="1.0.4" targetFramework="net35" />
|
||||
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net35" />
|
||||
<package id="TaskParallelLibrary" version="1.0.2856.0" targetFramework="net35" />
|
||||
</packages>
|
|
@ -554,7 +554,7 @@ private void openURLToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
FtpItem file = lvFTPList.SelectedItems[0].Tag as FtpItem;
|
||||
if (file != null && file.ItemType == FtpItemType.File)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(x => Process.Start(Account.GetUriPath("@" + file.FullPath)));
|
||||
Task.Run(() => Process.Start(Account.GetUriPath("@" + file.FullPath)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public override void StopUpload()
|
|||
{
|
||||
stopUpload = true;
|
||||
|
||||
ThreadPool.QueueUserWorkItem(state => ftpClient.StopUpload());
|
||||
Task.Run(() => ftpClient.StopUpload());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using UploadersLib.FileUploaders;
|
||||
using UploadersLib.HelperClasses;
|
||||
|
@ -60,12 +59,18 @@ public DropboxFilesForm(OAuthInfo oauth, string path, DropboxAccountInfo account
|
|||
}
|
||||
}
|
||||
|
||||
public async void OpenDirectory(string path)
|
||||
public void OpenDirectory(string path)
|
||||
{
|
||||
lvDropboxFiles.Items.Clear();
|
||||
|
||||
DropboxContentInfo contentInfo = await TaskEx.Run(() => dropbox.GetMetadata(path, true));
|
||||
DropboxContentInfo contentInfo = null;
|
||||
|
||||
Helpers.AsyncJob(() =>
|
||||
{
|
||||
contentInfo = dropbox.GetMetadata(path, true);
|
||||
},
|
||||
() =>
|
||||
{
|
||||
if (contentInfo != null)
|
||||
{
|
||||
lvDropboxFiles.Tag = contentInfo;
|
||||
|
@ -99,6 +104,7 @@ public async void OpenDirectory(string path)
|
|||
{
|
||||
MessageBox.Show("Path not exist: " + path, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void RefreshDirectory()
|
||||
|
|
|
@ -33,7 +33,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using UploadersLib.FileUploaders;
|
||||
using UploadersLib.Forms;
|
||||
|
@ -1500,13 +1499,13 @@ private CustomUploaderItem GetCustomUploaderFromFields()
|
|||
return item;
|
||||
}
|
||||
|
||||
private async void TestCustomUploader(CustomUploaderType type, CustomUploaderItem item)
|
||||
private void TestCustomUploader(CustomUploaderType type, CustomUploaderItem item)
|
||||
{
|
||||
UploadResult result = null;
|
||||
|
||||
txtCustomUploaderLog.ResetText();
|
||||
|
||||
await TaskEx.Run(() =>
|
||||
Helpers.AsyncJob(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1545,8 +1544,9 @@ await TaskEx.Run(() =>
|
|||
result = new UploadResult();
|
||||
result.Errors.Add(e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
() =>
|
||||
{
|
||||
if (result != null)
|
||||
{
|
||||
if ((type != CustomUploaderType.URL && !string.IsNullOrEmpty(result.URL)) || (type == CustomUploaderType.URL && !string.IsNullOrEmpty(result.ShortenedURL)))
|
||||
|
@ -1570,6 +1570,7 @@ await TaskEx.Run(() =>
|
|||
|
||||
btnCustomUploaderImageUploaderTest.Enabled = btnCustomUploaderTextUploaderTest.Enabled =
|
||||
btnCustomUploaderFileUploaderTest.Enabled = btnCustomUploaderURLShortenerTest.Enabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
#endregion Custom uploader
|
||||
|
|
|
@ -99,12 +99,6 @@
|
|||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="AsyncBridge.Net35">
|
||||
<HintPath>..\packages\AsyncBridge.Net35.0.2.0\lib\net35-Client\AsyncBridge.Net35.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading">
|
||||
<HintPath>..\packages\TaskParallelLibrary.1.0.2856.0\lib\Net35\System.Threading.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="APIKeys\APIKeys.cs" />
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AsyncBridge.Net35" version="0.2.0" targetFramework="net35" />
|
||||
<package id="MegaApiClient" version="1.0.4" targetFramework="net35" />
|
||||
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net35" />
|
||||
<package id="SSH.NET" version="2014.4.6-beta1" targetFramework="net35" />
|
||||
<package id="TaskParallelLibrary" version="1.0.2856.0" targetFramework="net35" />
|
||||
</packages>
|
Loading…
Reference in a new issue