Added DesktopBridgeHelper project

This commit is contained in:
Jaex 2017-04-27 03:00:21 +03:00
parent 5c9284dad4
commit a819b2cdd9
9 changed files with 239 additions and 8 deletions

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>

View file

@ -0,0 +1,109 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (c) 2007-2017 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 System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using Windows.ApplicationModel;
namespace DesktopBridgeHelper
{
internal class Program
{
private const string TaskID = "ShareX";
private static int Main(string[] args)
{
return MainAsync(args).GetAwaiter().GetResult();
}
private async static Task<int> MainAsync(string[] args)
{
try
{
if (args.Length > 0)
{
string argument = args[0];
if (argument.Equals("-StartupState", StringComparison.InvariantCultureIgnoreCase))
{
return (int)await GetStartupState();
}
else if (argument.Equals("-StartupEnable", StringComparison.InvariantCultureIgnoreCase))
{
return (int)await SetStartupState(true);
}
else if (argument.Equals("-StartupDisable", StringComparison.InvariantCultureIgnoreCase))
{
return (int)await SetStartupState(false);
}
}
else
{
string path = GetAbsolutePath("ShareX.exe");
Process.Start(path, "-silent");
return 0;
}
}
catch
{
}
return -1;
}
private async static Task<StartupTaskState> GetStartupState()
{
StartupTask startupTask = await StartupTask.GetAsync(TaskID);
return startupTask.State;
}
private async static Task<StartupTaskState> SetStartupState(bool enable)
{
StartupTask startupTask = await StartupTask.GetAsync(TaskID);
if (enable)
{
return await startupTask.RequestEnableAsync();
}
else
{
startupTask.Disable();
return StartupTaskState.Disabled;
}
}
private static string GetAbsolutePath(string path)
{
if (!Path.IsPathRooted(path)) // Is relative path?
{
path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);
}
return Path.GetFullPath(path);
}
}
}

View file

@ -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("ShareX DesktopBridgeHelper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ShareX Team")]
[assembly: AssemblyProduct("ShareX")]
[assembly: AssemblyCopyright("Copyright (c) 2007-2017 ShareX Team")]
[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("2bf9aebb-b104-4b72-8298-04ca6d23b0e0")]
// 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.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ShareX.DesktopBridgeHelper</RootNamespace>
<AssemblyName>ShareX_DesktopBridgeHelper</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll</HintPath>
</Reference>
<Reference Include="Windows, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD</HintPath>
</Reference>
<Reference Include="Windows.ApplicationModel.StartupTaskContract">
<HintPath>C:\Program Files (x86)\Windows Kits\10\References\10.0.15063.0\Windows.ApplicationModel.StartupTaskContract\1.0.0.0\Windows.ApplicationModel.StartupTaskContract.winmd</HintPath>
</Reference>
<Reference Include="Windows.Foundation.FoundationContract">
<HintPath>C:\Program Files (x86)\Windows Kits\10\References\10.0.15063.0\Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -49,8 +49,8 @@ private enum SetupJobs
Setup = CreateSetup | OpenOutputDirectory, Setup = CreateSetup | OpenOutputDirectory,
Portable = CreatePortable | OpenOutputDirectory, Portable = CreatePortable | OpenOutputDirectory,
Steam = CreateSteamFolder | OpenOutputDirectory, Steam = CreateSteamFolder | OpenOutputDirectory,
WindowsStore = CreateWindowsStoreFolder | OpenOutputDirectory, WindowsStore = CreateWindowsStoreFolder,
WindowsStoreDebug = CreateWindowsStoreDebugFolder | OpenOutputDirectory, WindowsStoreDebug = CreateWindowsStoreDebugFolder,
PortableApps = CreatePortableAppsFolder | OpenOutputDirectory, PortableApps = CreatePortableAppsFolder | OpenOutputDirectory,
Beta = CreateSetup | UploadOutputFile, Beta = CreateSetup | UploadOutputFile,
AppVeyorRelease = CreateSetup | CreatePortable, AppVeyorRelease = CreateSetup | CreatePortable,
@ -82,6 +82,7 @@ private enum SetupJobs
private static string SteamLauncherDir => Path.Combine(ParentDir, @"ShareX.Steam\bin\Release"); private static string SteamLauncherDir => Path.Combine(ParentDir, @"ShareX.Steam\bin\Release");
private static string SteamUpdatesDir => Path.Combine(SteamOutputDir, "Updates"); private static string SteamUpdatesDir => Path.Combine(SteamOutputDir, "Updates");
private static string NativeMessagingHostDir => Path.Combine(ParentDir, @"ShareX.NativeMessagingHost\bin\Release"); private static string NativeMessagingHostDir => Path.Combine(ParentDir, @"ShareX.NativeMessagingHost\bin\Release");
private static string DesktopBridgeHelperDir => Path.Combine(ParentDir, @"ShareX.DesktopBridgeHelper\bin\Release");
private static string RecorderDevicesSetupPath => Path.Combine(OutputDir, "Recorder-devices-setup.exe"); private static string RecorderDevicesSetupPath => Path.Combine(OutputDir, "Recorder-devices-setup.exe");
public static string InnoSetupCompilerPath = @"C:\Program Files (x86)\Inno Setup 5\ISCC.exe"; public static string InnoSetupCompilerPath = @"C:\Program Files (x86)\Inno Setup 5\ISCC.exe";
@ -264,6 +265,7 @@ private static void CreateFolder(string source, string destination, SetupJobs jo
} }
else if (job == SetupJobs.CreateWindowsStoreFolder || job == SetupJobs.CreateWindowsStoreDebugFolder) else if (job == SetupJobs.CreateWindowsStoreFolder || job == SetupJobs.CreateWindowsStoreDebugFolder)
{ {
Helpers.CopyFile(Path.Combine(DesktopBridgeHelperDir, "ShareX_DesktopBridgeHelper.exe"), destination);
Helpers.CopyAll(WindowsStorePackageFilesDir, destination); Helpers.CopyAll(WindowsStorePackageFilesDir, destination);
} }
else if (job == SetupJobs.CreatePortable) else if (job == SetupJobs.CreatePortable)

View file

@ -75,6 +75,9 @@
<None Include="InnoSetup\Recorder-devices-setup.iss" /> <None Include="InnoSetup\Recorder-devices-setup.iss" />
<None Include="InnoSetup\ShareX-setup.iss" /> <None Include="InnoSetup\ShareX-setup.iss" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="WindowsStore\AppxManifest.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -32,7 +32,7 @@
</uap:DefaultTile> </uap:DefaultTile>
</uap:VisualElements> </uap:VisualElements>
<Extensions> <Extensions>
<desktop:Extension Category="windows.startupTask" Executable="ShareX.exe" EntryPoint="Windows.FullTrustApplication"> <desktop:Extension Category="windows.startupTask" Executable="ShareX_DesktopBridgeHelper.exe" EntryPoint="Windows.FullTrustApplication">
<desktop:StartupTask TaskId="ShareX" Enabled="true" DisplayName="ShareX" /> <desktop:StartupTask TaskId="ShareX" Enabled="true" DisplayName="ShareX" />
</desktop:Extension> </desktop:Extension>
</Extensions> </Extensions>

View file

@ -37,6 +37,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShareX.Steam", "ShareX.Stea
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShareX.NativeMessagingHost", "ShareX.NativeMessagingHost\ShareX.NativeMessagingHost.csproj", "{254E398D-F7F5-4B2A-9024-5C121EA6C564}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShareX.NativeMessagingHost", "ShareX.NativeMessagingHost\ShareX.NativeMessagingHost.csproj", "{254E398D-F7F5-4B2A-9024-5C121EA6C564}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShareX.DesktopBridgeHelper", "ShareX.DesktopBridgeHelper\ShareX.DesktopBridgeHelper.csproj", "{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -154,8 +156,8 @@ Global
{7F6ADFC5-2563-4A5F-B202-93B553578719}.Steam|Any CPU.Build.0 = Release|Any CPU {7F6ADFC5-2563-4A5F-B202-93B553578719}.Steam|Any CPU.Build.0 = Release|Any CPU
{7F6ADFC5-2563-4A5F-B202-93B553578719}.WindowsStore|Any CPU.ActiveCfg = Release|Any CPU {7F6ADFC5-2563-4A5F-B202-93B553578719}.WindowsStore|Any CPU.ActiveCfg = Release|Any CPU
{7F6ADFC5-2563-4A5F-B202-93B553578719}.WindowsStore|Any CPU.Build.0 = Release|Any CPU {7F6ADFC5-2563-4A5F-B202-93B553578719}.WindowsStore|Any CPU.Build.0 = Release|Any CPU
{7F6ADFC5-2563-4A5F-B202-93B553578719}.WindowsStoreDebug|Any CPU.ActiveCfg = WindowsStoreDebug|Any CPU {7F6ADFC5-2563-4A5F-B202-93B553578719}.WindowsStoreDebug|Any CPU.ActiveCfg = Release|Any CPU
{7F6ADFC5-2563-4A5F-B202-93B553578719}.WindowsStoreDebug|Any CPU.Build.0 = WindowsStoreDebug|Any CPU {7F6ADFC5-2563-4A5F-B202-93B553578719}.WindowsStoreDebug|Any CPU.Build.0 = Release|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {254E398D-F7F5-4B2A-9024-5C121EA6C564}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.Debug|Any CPU.Build.0 = Debug|Any CPU {254E398D-F7F5-4B2A-9024-5C121EA6C564}.Debug|Any CPU.Build.0 = Debug|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.Release|Any CPU.ActiveCfg = Release|Any CPU {254E398D-F7F5-4B2A-9024-5C121EA6C564}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -164,8 +166,18 @@ Global
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.Steam|Any CPU.Build.0 = Release|Any CPU {254E398D-F7F5-4B2A-9024-5C121EA6C564}.Steam|Any CPU.Build.0 = Release|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.WindowsStore|Any CPU.ActiveCfg = Release|Any CPU {254E398D-F7F5-4B2A-9024-5C121EA6C564}.WindowsStore|Any CPU.ActiveCfg = Release|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.WindowsStore|Any CPU.Build.0 = Release|Any CPU {254E398D-F7F5-4B2A-9024-5C121EA6C564}.WindowsStore|Any CPU.Build.0 = Release|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.WindowsStoreDebug|Any CPU.ActiveCfg = WindowsStoreDebug|Any CPU {254E398D-F7F5-4B2A-9024-5C121EA6C564}.WindowsStoreDebug|Any CPU.ActiveCfg = Release|Any CPU
{254E398D-F7F5-4B2A-9024-5C121EA6C564}.WindowsStoreDebug|Any CPU.Build.0 = WindowsStoreDebug|Any CPU {254E398D-F7F5-4B2A-9024-5C121EA6C564}.WindowsStoreDebug|Any CPU.Build.0 = Release|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.Release|Any CPU.Build.0 = Release|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.Steam|Any CPU.ActiveCfg = Release|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.Steam|Any CPU.Build.0 = Release|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.WindowsStore|Any CPU.ActiveCfg = Release|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.WindowsStore|Any CPU.Build.0 = Release|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.WindowsStoreDebug|Any CPU.ActiveCfg = Release|Any CPU
{2BF9AEBB-B104-4B72-8298-04CA6D23B0E0}.WindowsStoreDebug|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View file

@ -91,7 +91,7 @@ public static bool CreateStartupShortcut(bool create)
private static bool CreateStartupShortcutWindowsStore(bool create) private static bool CreateStartupShortcutWindowsStore(bool create)
{ {
string filepath = Helpers.GetAbsolutePath("DesktopBridgeHelper.exe"); string filepath = Helpers.GetAbsolutePath("ShareX_DesktopBridgeHelper.exe");
if (!string.IsNullOrEmpty(filepath) && File.Exists(filepath)) if (!string.IsNullOrEmpty(filepath) && File.Exists(filepath))
{ {