Merged PR 4: Branding

This commit is contained in:
Jared Goodwin 2021-02-12 14:03:10 +00:00 committed by Jared Goodwin
parent 463691bfd2
commit 7f3536017f
198 changed files with 19559 additions and 1774 deletions

View File

@ -88,9 +88,14 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression.FileSystem" />
@ -120,15 +125,22 @@
<Compile Include="..\Shared\Models\ConnectionInfo.cs">
<Link>Models\ConnectionInfo.cs</Link>
</Compile>
<Compile Include="..\Shared\Models\DeviceInitParams.cs">
<Link>Models\DeviceInitParams.cs</Link>
</Compile>
<Compile Include="..\Shared\Models\DeviceSetupOptions.cs">
<Link>Models\DeviceSetupOptions.cs</Link>
</Compile>
<Compile Include="Services\CommandLineParser.cs" />
<Compile Include="Services\MessageBoxEx.cs" />
<Compile Include="..\Shared\Utilities\AppConstants.cs">
<Link>Utilities\AppConstants.cs</Link>
</Compile>
<Compile Include="Models\BrandingInfo.cs" />
<Compile Include="Utilities\CommandLineParser.cs" />
<Compile Include="Utilities\MessageBoxEx.cs" />
<Compile Include="Services\Executor.cs" />
<Compile Include="Services\InstallerService.cs" />
<Compile Include="Services\Logger.cs" />
<Compile Include="Services\ProcessEx.cs" />
<Compile Include="Utilities\Logger.cs" />
<Compile Include="Utilities\ProcessEx.cs" />
<Compile Include="ViewModels\MainWindowViewModel.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
<Page Include="MainWindow.xaml">
@ -175,7 +187,7 @@
<Resource Include="Assets\favicon.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Remotely_Icon.png" />
<EmbeddedResource Include="Assets\Remotely_Icon.png" />
</ItemGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">

View File

@ -12,7 +12,7 @@
MouseLeftButtonDown="Window_MouseLeftButtonDown"
Loaded="Window_Loaded"
WindowStartupLocation="CenterScreen"
Title="Remotely Installer" Height="325" Width="500" Icon="Assets/favicon.ico">
Title="Remotely Installer" Height="335" Width="500" Icon="{Binding Icon}">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</Window.Resources>
@ -25,19 +25,24 @@
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Grid.Row="0" Height="50" Background="#FF464646" VerticalAlignment="Top">
<Border Height="50" Background="{Binding TitleBackgroundColor}">
<DockPanel Margin="10,0,0,0">
<Image Height="50" Width="50" Source="Assets/Remotely_Icon.png" Margin="0,0,10,0"></Image>
<TextBlock Foreground="#FF1D90F1" FontWeight="Bold" FontSize="20" VerticalAlignment="Center">Remotely Installer</TextBlock>
<Button Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" />
<Button Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="_"/>
<DockPanel>
<Image Height="50" Width="50" Margin="0,0,10,0" Source="{Binding Icon}"></Image>
<TextBlock Foreground="{Binding TitleForegroundColor}" FontWeight="Bold" FontSize="20" VerticalAlignment="Center">
<Run Text="{Binding ProductName}"></Run>
<Run Text="Installer"></Run>
</TextBlock>
</DockPanel>
<Button Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" />
<Button Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="____" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}"/>
</DockPanel>
</Border>
<Grid Grid.Row="1" Margin="10,15,10,0">
<StackPanel>
<TextBlock Style="{StaticResource SectionHeader}" Text="{Binding HeaderMessage}"></TextBlock>
<TextBlock Style="{StaticResource SectionHeader}" Text="{Binding HeaderMessage}" Margin="0,0,0,10"></TextBlock>
<Grid Margin="25,5,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@ -83,8 +88,8 @@
</Grid>
<TextBlock TextWrapping="Wrap" Margin="0,25,0,0" Text="{Binding StatusMessage}" FontSize="14"></TextBlock>
<ProgressBar Height="25" Margin="0,10,0,0" Value="{Binding Progress}" Visibility="{Binding IsProgressVisible, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>
<TextBlock TextWrapping="Wrap" Margin="40,25,40,0" Text="{Binding StatusMessage}" FontSize="14"></TextBlock>
<ProgressBar Height="25" Margin="40,10,40,0" Value="{Binding Progress}" Visibility="{Binding IsProgressVisible, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>
</StackPanel>
</Grid>

View File

@ -1,4 +1,4 @@
using Remotely.Agent.Installer.Win.Services;
using Remotely.Agent.Installer.Win.Utilities;
using Remotely.Agent.Installer.Win.ViewModels;
using System.Windows;
using System.Windows.Input;

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Remotely.Agent.Installer.Win.Models
{
public class BrandingInfo
{
public string Product { get; set; } = "Remotely";
public string Icon { get; set; }
public byte TitleForegroundRed { get; set; } = 29;
public byte TitleForegroundGreen { get; set; } = 144;
public byte TitleForegroundBlue { get; set; } = 241;
public byte TitleBackgroundRed { get; set; } = 70;
public byte TitleBackgroundGreen { get; set; } = 70;
public byte TitleBackgroundBlue { get; set; } = 70;
public byte ButtonForegroundRed { get; set; } = 255;
public byte ButtonForegroundGreen { get; set; } = 255;
public byte ButtonForegroundBlue { get; set; } = 255;
}
}

View File

@ -1,6 +1,7 @@
using IWshRuntimeLibrary;
using Microsoft.VisualBasic.FileIO;
using Microsoft.Win32;
using Remotely.Agent.Installer.Win.Utilities;
using Remotely.Shared.Models;
using System;
using System.Configuration.Install;

View File

@ -1,12 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
namespace Remotely.Agent.Installer.Win.Services
namespace Remotely.Agent.Installer.Win.Utilities
{
public class CommandLineParser
{
private static Dictionary<string, string> commandLineArgs;
private static bool _invalidArgumentFound;
public static Dictionary<string, string> CommandLineArgs
{
get
@ -14,6 +17,7 @@ namespace Remotely.Agent.Installer.Win.Services
if (commandLineArgs is null)
{
commandLineArgs = new Dictionary<string, string>();
var args = Environment.GetCommandLineArgs();
for (var i = 1; i < args.Length; i += 2)
{
@ -24,8 +28,7 @@ namespace Remotely.Agent.Installer.Win.Services
{
if (!key.Contains("-"))
{
Logger.Write("Command line arguments are invalid.");
MessageBoxEx.Show("Command line arguments are invalid.", "Invalid Arguments", MessageBoxButton.OK, MessageBoxImage.Error);
_invalidArgumentFound = true;
i -= 1;
continue;
}
@ -60,5 +63,14 @@ namespace Remotely.Agent.Installer.Win.Services
return commandLineArgs;
}
}
internal static void VerifyArguments()
{
if (_invalidArgumentFound)
{
Logger.Write("Command line arguments are invalid.");
MessageBoxEx.Show("Command line arguments are invalid.", "Invalid Arguments", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}

View File

@ -2,7 +2,7 @@
using System.IO;
using System.Linq;
namespace Remotely.Agent.Installer.Win.Services
namespace Remotely.Agent.Installer.Win.Utilities
{
public class Logger
{

View File

@ -1,6 +1,6 @@
using System.Windows;
namespace Remotely.Agent.Installer.Win.Services
namespace Remotely.Agent.Installer.Win.Utilities
{
public static class MessageBoxEx
{

View File

@ -1,6 +1,6 @@
using System.Diagnostics;
namespace Remotely.Agent.Installer.Win.Services
namespace Remotely.Agent.Installer.Win.Utilities
{
public static class ProcessEx
{

View File

@ -1,9 +1,13 @@
using Remotely.Agent.Installer.Win.Services;
using Remotely.Agent.Installer.Win.Models;
using Remotely.Agent.Installer.Win.Services;
using Remotely.Agent.Installer.Win.Utilities;
using Remotely.Shared.Utilities;
using Remotely.Shared.Models;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Security.Principal;
using System.ServiceProcess;
@ -11,39 +15,48 @@ using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace Remotely.Agent.Installer.Win.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
private bool createSupportShortcut;
private string headerMessage;
private BrandingInfo _brandingInfo;
private bool _createSupportShortcut;
private string _headerMessage = "Install the service.";
private bool isReadyState = true;
private bool isServiceInstalled;
private bool _isReadyState = true;
private bool _isServiceInstalled;
private string organizationID;
private string _organizationID;
private int progress;
private int _progress;
private string serverUrl;
private string _serverUrl;
private string statusMessage;
private string _statusMessage;
public MainWindowViewModel()
{
Installer = new InstallerService();
CopyCommandLineArgs();
ExtractDeviceInitInfo().Wait();
AddExistingConnectionInfo();
}
public bool CreateSupportShortcut
{
get
{
return createSupportShortcut;
return _createSupportShortcut;
}
set
{
createSupportShortcut = value;
FirePropertyChanged(nameof(CreateSupportShortcut));
_createSupportShortcut = value;
FirePropertyChanged();
}
}
@ -51,15 +64,16 @@ namespace Remotely.Agent.Installer.Win.ViewModels
{
get
{
return headerMessage;
return _headerMessage;
}
set
{
headerMessage = value;
FirePropertyChanged(nameof(HeaderMessage));
_headerMessage = value;
FirePropertyChanged();
}
}
public BitmapImage Icon { get; set; }
public string InstallButtonText => IsServiceMissing ? "Install" : "Reinstall";
public ICommand InstallCommand => new Executor(async (param) => { await Install(); });
@ -70,12 +84,12 @@ namespace Remotely.Agent.Installer.Win.ViewModels
{
get
{
return isReadyState;
return _isReadyState;
}
set
{
isReadyState = value;
FirePropertyChanged(nameof(IsReadyState));
_isReadyState = value;
FirePropertyChanged();
}
}
@ -83,18 +97,18 @@ namespace Remotely.Agent.Installer.Win.ViewModels
{
get
{
return isServiceInstalled;
return _isServiceInstalled;
}
set
{
isServiceInstalled = value;
FirePropertyChanged(nameof(IsServiceInstalled));
_isServiceInstalled = value;
FirePropertyChanged();
FirePropertyChanged(nameof(IsServiceMissing));
FirePropertyChanged(nameof(InstallButtonText));
}
}
public bool IsServiceMissing => !isServiceInstalled;
public bool IsServiceMissing => !_isServiceInstalled;
public ICommand OpenLogsCommand
{
@ -119,25 +133,27 @@ namespace Remotely.Agent.Installer.Win.ViewModels
{
get
{
return organizationID;
return _organizationID;
}
set
{
organizationID = value;
FirePropertyChanged(nameof(OrganizationID));
_organizationID = value;
FirePropertyChanged();
}
}
public string ProductName { get; set; }
public int Progress
{
get
{
return progress;
return _progress;
}
set
{
progress = value;
FirePropertyChanged(nameof(Progress));
_progress = value;
FirePropertyChanged();
FirePropertyChanged(nameof(IsProgressVisible));
}
}
@ -146,12 +162,12 @@ namespace Remotely.Agent.Installer.Win.ViewModels
{
get
{
return serverUrl;
return _serverUrl;
}
set
{
serverUrl = value;
FirePropertyChanged(nameof(ServerUrl));
_serverUrl = value;
FirePropertyChanged();
}
}
@ -159,15 +175,18 @@ namespace Remotely.Agent.Installer.Win.ViewModels
{
get
{
return statusMessage;
return _statusMessage;
}
set
{
statusMessage = value;
FirePropertyChanged(nameof(StatusMessage));
_statusMessage = value;
FirePropertyChanged();
}
}
public SolidColorBrush TitleBackgroundColor { get; set; }
public SolidColorBrush TitleButtonForegroundColor { get; set; }
public SolidColorBrush TitleForegroundColor { get; set; }
public ICommand UninstallCommand => new Executor(async (param) => { await Uninstall(); });
private string DeviceAlias { get; set; }
private string DeviceGroup { get; set; }
@ -175,7 +194,6 @@ namespace Remotely.Agent.Installer.Win.ViewModels
private InstallerService Installer { get; }
public async Task Init()
{
Installer.ProgressMessageChanged += (sender, arg) =>
{
StatusMessage = arg;
@ -187,32 +205,16 @@ namespace Remotely.Agent.Installer.Win.ViewModels
};
IsServiceInstalled = ServiceController.GetServices().Any(x => x.ServiceName == "Remotely_Service");
if (IsServiceMissing)
if (!IsServiceMissing)
{
HeaderMessage = "Install the Remotely service.";
StatusMessage = "Installing the Remotely service will allow remote access by the above service provider.";
HeaderMessage = $"Install the {ProductName} service.";
}
else
{
HeaderMessage = "Modify the Remotely installation.";
StatusMessage = "Uninstalling the Remotely service will remove all remote acess to this device.\r\n\r\n" +
"Reinstalling will retain the current settings and install the service again.";
HeaderMessage = $"Modify the {ProductName} installation.";
}
CopyCommandLineArgs();
var fileName = Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location);
for (var i = 0; i < fileName.Length; i++)
{
var guid = string.Join("", fileName.Skip(i).Take(36));
if (Guid.TryParse(guid, out _))
{
OrganizationID = guid;
}
}
AddExistingConnectionInfo();
CommandLineParser.VerifyArguments();
if (CommandLineParser.CommandLineArgs.ContainsKey("install"))
{
@ -262,6 +264,37 @@ namespace Remotely.Agent.Installer.Win.ViewModels
}
private void ApplyBranding(BrandingInfo brandingInfo)
{
ProductName = "Remotely";
if (!string.IsNullOrWhiteSpace(brandingInfo?.Product))
{
ProductName = brandingInfo.Product;
}
TitleBackgroundColor = new SolidColorBrush(Color.FromRgb(
brandingInfo?.TitleBackgroundRed ?? 70,
brandingInfo?.TitleBackgroundGreen ?? 70,
brandingInfo?.TitleBackgroundBlue ?? 70));
TitleForegroundColor = new SolidColorBrush(Color.FromRgb(
brandingInfo?.TitleForegroundRed ?? 29,
brandingInfo?.TitleForegroundGreen ?? 144,
brandingInfo?.TitleForegroundBlue ?? 241));
TitleButtonForegroundColor = new SolidColorBrush(Color.FromRgb(
brandingInfo?.ButtonForegroundRed ?? 255,
brandingInfo?.ButtonForegroundGreen ?? 255,
brandingInfo?.ButtonForegroundBlue ?? 255));
TitleBackgroundColor.Freeze();
TitleForegroundColor.Freeze();
TitleButtonForegroundColor.Freeze();
Icon = GetBitmapImageIcon(brandingInfo);
}
private bool CheckIsAdministrator()
{
var identity = WindowsIdentity.GetCurrent();
@ -338,6 +371,91 @@ namespace Remotely.Agent.Installer.Win.ViewModels
ServerUrl = ServerUrl.Substring(0, ServerUrl.LastIndexOf("/"));
}
}
private async Task ExtractDeviceInitInfo()
{
try
{
var fileName = Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location);
var codeLength = AppConstants.RelayCodeLength + 2;
for (var i = 0; i < fileName.Length; i++)
{
var guid = string.Join("", fileName.Skip(i).Take(36));
if (Guid.TryParse(guid, out _))
{
OrganizationID = guid;
return;
}
var codeSection = string.Join("", fileName.Skip(i).Take(codeLength));
if (codeSection.StartsWith("[") &&
codeSection.EndsWith("]"))
{
var relayCode = codeSection.Substring(1, 4);
using (var httpClient = new HttpClient())
{
var response = await httpClient.GetAsync($"{AppConstants.DeviceInitUrl}/{relayCode}").ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
var serializer = new JavaScriptSerializer();
var contentString = await response.Content.ReadAsStringAsync();
var deviceInitParams = serializer.Deserialize<DeviceInitParams>(contentString);
OrganizationID = deviceInitParams.OrganizationId;
ServerUrl = deviceInitParams.Host;
break;
}
}
}
}
if (!string.IsNullOrWhiteSpace(OrganizationID) &&
!string.IsNullOrWhiteSpace(ServerUrl))
{
using (var httpClient = new HttpClient())
{
var serializer = new JavaScriptSerializer();
var brandingUrl = $"{ServerUrl.TrimEnd('/')}/api/branding/{OrganizationID}";
using (var response = await httpClient.GetAsync(brandingUrl).ConfigureAwait(false))
{
var responseString = await response.Content.ReadAsStringAsync();
_brandingInfo = serializer.Deserialize<BrandingInfo>(responseString);
}
}
}
ApplyBranding(_brandingInfo);
}
catch (Exception ex)
{
Logger.Write(ex);
}
}
private BitmapImage GetBitmapImageIcon(BrandingInfo bi)
{
Stream imageStream;
if (!string.IsNullOrWhiteSpace(bi?.Icon))
{
imageStream = new MemoryStream(Convert.FromBase64String(bi.Icon));
}
else
{
imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Remotely.Agent.Installer.Win.Assets.Remotely_Icon.png");
}
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = imageStream;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
bitmap.Freeze();
imageStream.Close();
return bitmap;
}
private async Task Install()
{
try

View File

@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Remotely.Agent.Installer.Win.ViewModels
{
@ -6,7 +7,7 @@ namespace Remotely.Agent.Installer.Win.ViewModels
{
public event PropertyChangedEventHandler PropertyChanged;
public void FirePropertyChanged(string propertyName)
public void FirePropertyChanged([CallerMemberName]string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

View File

@ -5,7 +5,7 @@
<TargetFramework>net5.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Copyright>Copyright © 2020 Translucency Software</Copyright>
<Copyright>Copyright © 2021 Translucency Software</Copyright>
<Description>Background service that maintains a connection to the Remotely server. The service is used for remote support and maintenance by this computer's administrators.</Description>
<Authors>Jared Goodwin</Authors>
<Product>Remotely Agent</Product>
@ -18,10 +18,6 @@
<ApplicationIcon>Assets\favicon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<None Remove="Assets\favicon.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\favicon.ico" />
</ItemGroup>
@ -40,7 +36,6 @@
<PackageReference Include="Microsoft.PowerShell.Security" Version="7.1.1" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.1.1" />
<PackageReference Include="Microsoft.WSMan.Runtime" Version="7.1.1" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
<PackageReference Include="System.Management.Automation" Version="7.1.1" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="5.0.0" />
</ItemGroup>
@ -54,10 +49,4 @@
<Compile Update="Services\WindowsService.cs" />
</ItemGroup>
<ItemGroup>
<None Update="Build.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -5,6 +5,6 @@ namespace Remotely.Agent.Models
public class ChatSession
{
public int ProcessID { get; set; }
public NamedPipeServerStream PipeStream { get; set; }
public NamedPipeClientStream PipeStream { get; set; }
}
}

View File

@ -18,15 +18,17 @@ namespace Remotely.Agent
public static IServiceProvider Services { get; set; }
public static void Main(string[] args)
public static async Task Main(string[] args)
{
try
{
BuildServices();
Task.Run(() => { _ = Init(); });
await Init();
Thread.Sleep(Timeout.Infinite);
_ = Task.Run(Services.GetRequiredService<AgentSocket>().HandleConnection);
await Task.Delay(-1);
}
catch (Exception ex)
@ -44,7 +46,7 @@ namespace Remotely.Agent
builder.AddConsole().AddDebug();
});
serviceCollection.AddSingleton<AgentSocket>();
serviceCollection.AddScoped<ChatHostService>();
serviceCollection.AddScoped<ChatClientService>();
serviceCollection.AddTransient<Bash>();
serviceCollection.AddTransient<CMD>();
serviceCollection.AddTransient<PSCore>();
@ -114,10 +116,6 @@ namespace Remotely.Agent
{
Logger.Write(ex);
}
finally
{
await Services.GetRequiredService<AgentSocket>().HandleConnection();
}
}
private static void SetWorkingDirectory()

View File

@ -2,6 +2,7 @@
"profiles": {
"Agent": {
"commandName": "Project",
"commandLineArgs": "",
"nativeDebugging": true
}
}

View File

@ -26,7 +26,7 @@ namespace Remotely.Agent.Services
Uninstaller uninstaller,
CommandExecutor commandExecutor,
ScriptRunner scriptRunner,
ChatHostService chatService,
ChatClientService chatService,
IAppLauncher appLauncher,
IUpdater updater)
{
@ -40,7 +40,7 @@ namespace Remotely.Agent.Services
}
public bool IsConnected => HubConnection?.State == HubConnectionState.Connected;
private IAppLauncher AppLauncher { get; }
private ChatHostService ChatService { get; }
private ChatClientService ChatService { get; }
private CommandExecutor CommandExecutor { get; }
private ConfigService ConfigService { get; }
private ConnectionInfo ConnectionInfo { get; set; }
@ -138,7 +138,7 @@ namespace Remotely.Agent.Services
{
Logger.Write(ex);
}
Thread.Sleep(1000);
await Task.Delay(1000);
}
}

View File

@ -14,6 +14,8 @@ namespace Remotely.Agent.Services
public class AppLauncherLinux : IAppLauncher
{
private readonly string _rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Desktop", EnvironmentHelper.DesktopExecutableFileName);
public AppLauncherLinux(ConfigService configService)
{
ConnectionInfo = configService.GetConnectionInfo();
@ -25,8 +27,7 @@ namespace Remotely.Agent.Services
{
try
{
var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Desktop", EnvironmentHelper.DesktopExecutableFileName);
if (!File.Exists(rcBinaryPath))
if (!File.Exists(_rcBinaryPath))
{
await hubConnection.SendAsync("DisplayMessage", "Chat executable not found on target device.", "Executable not found on device.", requesterID);
}
@ -34,7 +35,12 @@ namespace Remotely.Agent.Services
// Start Desktop app.
await hubConnection.SendAsync("DisplayMessage", $"Starting chat service...", "Starting chat service.", requesterID);
var args = $"{rcBinaryPath} -mode Chat -requester \"{requesterID}\" -organization \"{orgName}\" & disown";
var args = $"{_rcBinaryPath} " +
$"-mode Chat " +
$"-requester \"{requesterID}\" " +
$"-organization \"{orgName}\" " +
$"-host \"{ConnectionInfo.Host}\" " +
$"-orgid \"{ConnectionInfo.OrganizationID}\" & disown";
return StartLinuxDesktopApp(args);
}
catch (Exception ex)
@ -49,8 +55,7 @@ namespace Remotely.Agent.Services
{
try
{
var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Desktop", EnvironmentHelper.DesktopExecutableFileName);
if (!File.Exists(rcBinaryPath))
if (!File.Exists(_rcBinaryPath))
{
await hubConnection.SendAsync("DisplayMessage", "Remote control executable not found on target device.", "Executable not found on device.", requesterID);
return;
@ -59,7 +64,13 @@ namespace Remotely.Agent.Services
// Start Desktop app.
await hubConnection.SendAsync("DisplayMessage", $"Starting remote control...", "Starting remote control.", requesterID);
var args = $"{rcBinaryPath} -mode Unattended -requester \"{requesterID}\" -serviceid \"{serviceID}\" -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host} & disown";
var args = $"{_rcBinaryPath} " +
$"-mode Unattended " +
$"-requester \"{requesterID}\" " +
$"-serviceid \"{serviceID}\" " +
$"-deviceid {ConnectionInfo.DeviceID} " +
$"-host \"{ConnectionInfo.Host}\" " +
$"-orgid \"{ConnectionInfo.OrganizationID}\" & disown";
StartLinuxDesktopApp(args);
}
catch (Exception ex)
@ -72,9 +83,16 @@ namespace Remotely.Agent.Services
{
try
{
var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Desktop", EnvironmentHelper.DesktopExecutableFileName);
// Start Desktop app.
var args = $"{rcBinaryPath} -mode Unattended -requester \"{requesterID}\" -serviceid \"{serviceID}\" -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host} -relaunch true -viewers {string.Join(",", viewerIDs)} & disown";
var args = $"{_rcBinaryPath} " +
$"-mode Unattended " +
$"-requester \"{requesterID}\" " +
$"-serviceid \"{serviceID}\" " +
$"-deviceid {ConnectionInfo.DeviceID} " +
$"-host \"{ConnectionInfo.Host}\" " +
$"-orgid \"{ConnectionInfo.OrganizationID}\" " +
$"-relaunch true " +
$"-viewers {string.Join(",", viewerIDs)} & disown";
StartLinuxDesktopApp(args);
}
catch (Exception ex)

View File

@ -15,6 +15,8 @@ namespace Remotely.Agent.Services
public class AppLauncherWin : IAppLauncher
{
private readonly string _rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Desktop", EnvironmentHelper.DesktopExecutableFileName);
public AppLauncherWin(ConfigService configService)
{
ConnectionInfo = configService.GetConnectionInfo();
@ -26,8 +28,7 @@ namespace Remotely.Agent.Services
{
try
{
var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Desktop", EnvironmentHelper.DesktopExecutableFileName);
if (!File.Exists(rcBinaryPath))
if (!File.Exists(_rcBinaryPath))
{
await hubConnection.SendAsync("DisplayMessage", "Chat executable not found on target device.", "Executable not found on device.", requesterID);
}
@ -37,7 +38,12 @@ namespace Remotely.Agent.Services
await hubConnection.SendAsync("DisplayMessage", $"Starting chat service...", "Starting chat service.", requesterID);
if (WindowsIdentity.GetCurrent().IsSystem)
{
var result = Win32Interop.OpenInteractiveProcess($"{rcBinaryPath} -mode Chat -requester \"{requesterID}\" -organization \"{orgName}\"",
var result = Win32Interop.OpenInteractiveProcess($"{_rcBinaryPath} " +
$"-mode Chat " +
$"-requester \"{requesterID}\" " +
$"-organization \"{orgName}\" " +
$"-host \"{ConnectionInfo.Host}\" " +
$"-orgid \"{ConnectionInfo.OrganizationID}\"",
targetSessionId: -1,
forceConsoleSession: false,
desktopName: "default",
@ -54,7 +60,12 @@ namespace Remotely.Agent.Services
}
else
{
return Process.Start(rcBinaryPath, $"-mode Chat -requester \"{requesterID}\" -organization \"{orgName}\"").Id;
return Process.Start(_rcBinaryPath,
$"-mode Chat " +
$"-requester \"{requesterID}\" " +
$"-organization \"{orgName}\" " +
$"-host \"{ConnectionInfo.Host}\" " +
$"-orgid \"{ConnectionInfo.OrganizationID}\"").Id;
}
}
catch (Exception ex)
@ -69,8 +80,7 @@ namespace Remotely.Agent.Services
{
try
{
var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Desktop", EnvironmentHelper.DesktopExecutableFileName);
if (!File.Exists(rcBinaryPath))
if (!File.Exists(_rcBinaryPath))
{
await hubConnection.SendAsync("DisplayMessage", "Remote control executable not found on target device.", "Executable not found on device.", requesterID);
return;
@ -81,7 +91,13 @@ namespace Remotely.Agent.Services
await hubConnection.SendAsync("DisplayMessage", $"Starting remote control...", "Starting remote control.", requesterID);
if (WindowsIdentity.GetCurrent().IsSystem)
{
var result = Win32Interop.OpenInteractiveProcess(rcBinaryPath + $" -mode Unattended -requester \"{requesterID}\" -serviceid \"{serviceID}\" -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host}",
var result = Win32Interop.OpenInteractiveProcess(_rcBinaryPath +
$" -mode Unattended" +
$" -requester \"{requesterID}\"" +
$" -serviceid \"{serviceID}\"" +
$" -deviceid {ConnectionInfo.DeviceID}" +
$" -host {ConnectionInfo.Host}" +
$" -orgid \"{ConnectionInfo.OrganizationID}\"",
targetSessionId: targetSessionId,
forceConsoleSession: Shlwapi.IsOS(OsType.OS_ANYSERVER) && targetSessionId == -1,
desktopName: "default",
@ -96,7 +112,12 @@ namespace Remotely.Agent.Services
{
// SignalR Connection IDs might start with a hyphen. We surround them
// with quotes so the command line will be parsed correctly.
Process.Start(rcBinaryPath, $"-mode Unattended -requester \"{requesterID}\" -serviceid \"{serviceID}\" -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host}");
Process.Start(_rcBinaryPath, $"-mode Unattended " +
$"-requester \"{requesterID}\" " +
$"-serviceid \"{serviceID}\" " +
$"-deviceid {ConnectionInfo.DeviceID} " +
$"-host {ConnectionInfo.Host} " +
$"-orgid \"{ConnectionInfo.OrganizationID}\"");
}
}
catch (Exception ex)
@ -109,7 +130,6 @@ namespace Remotely.Agent.Services
{
try
{
var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Desktop", EnvironmentHelper.DesktopExecutableFileName);
// Start Desktop app.
Logger.Write("Restarting screen caster.");
if (WindowsIdentity.GetCurrent().IsSystem)
@ -117,7 +137,16 @@ namespace Remotely.Agent.Services
// Give a little time for session changing, etc.
await Task.Delay(1000);
var result = Win32Interop.OpenInteractiveProcess(rcBinaryPath + $" -mode Unattended -requester \"{requesterID}\" -serviceid \"{serviceID}\" -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host} -relaunch true -viewers {String.Join(",", viewerIDs)}",
var result = Win32Interop.OpenInteractiveProcess(_rcBinaryPath +
$" -mode Unattended" +
$" -requester \"{requesterID}\"" +
$" -serviceid \"{serviceID}\"" +
$" -deviceid {ConnectionInfo.DeviceID}" +
$" -host {ConnectionInfo.Host}" +
$" -orgid \"{ConnectionInfo.OrganizationID}\"" +
$" -relaunch true" +
$" -viewers {String.Join(",", viewerIDs)}",
targetSessionId: targetSessionID,
forceConsoleSession: Shlwapi.IsOS(OsType.OS_ANYSERVER) && targetSessionID == -1,
desktopName: "default",
@ -135,7 +164,15 @@ namespace Remotely.Agent.Services
{
// SignalR Connection IDs might start with a hyphen. We surround them
// with quotes so the command line will be parsed correctly.
Process.Start(rcBinaryPath, $"-mode Unattended -requester \"{requesterID}\" -serviceid \"{serviceID}\" -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host} -relaunch true -viewers {String.Join(",", viewerIDs)}");
Process.Start(_rcBinaryPath,
$"-mode Unattended " +
$"-requester \"{requesterID}\" " +
$"-serviceid \"{serviceID}\" " +
$"-deviceid {ConnectionInfo.DeviceID} " +
$"-host {ConnectionInfo.Host} " +
$" -orgid \"{ConnectionInfo.OrganizationID}\"" +
$"-relaunch true " +
$"-viewers {String.Join(",", viewerIDs)}");
}
}
catch (Exception ex)

View File

@ -14,9 +14,9 @@ using System.Threading.Tasks;
namespace Remotely.Agent.Services
{
public class ChatHostService
public class ChatClientService
{
public ChatHostService(IAppLauncher appLauncher)
public ChatClientService(IAppLauncher appLauncher)
{
AppLauncher = appLauncher;
}
@ -71,20 +71,15 @@ namespace Remotely.Agent.Services
Logger.Write($"Chat app did not start successfully.");
return;
}
var serverStream = new NamedPipeServerStream("Remotely_Chat" + senderConnectionID,
PipeDirection.InOut,
NamedPipeServerStream.MaxAllowedServerInstances,
PipeTransmissionMode.Byte,
PipeOptions.Asynchronous);
var cts = new CancellationTokenSource(15000);
await serverStream.WaitForConnectionAsync(cts.Token);
if (!serverStream.IsConnected)
var clientPipe = new NamedPipeClientStream(".", "Remotely_Chat" + senderConnectionID, PipeDirection.InOut, PipeOptions.Asynchronous);
clientPipe.Connect(15000);
if (!clientPipe.IsConnected)
{
Logger.Write("Failed to connect to chat client.");
Logger.Write("Failed to connect to chat host.");
return;
}
chatSession = new ChatSession() { PipeStream = serverStream, ProcessID = procID };
chatSession = new ChatSession() { PipeStream = clientPipe, ProcessID = procID };
_ = Task.Run(async () => { await ReadFromStream(chatSession.PipeStream, senderConnectionID, hubConnection); });
ChatClients.Add(senderConnectionID, chatSession, CacheItemPolicy);
}
@ -113,7 +108,7 @@ namespace Remotely.Agent.Services
}
}
private async Task ReadFromStream(NamedPipeServerStream clientPipe, string senderConnectionID, HubConnection hubConnection)
private async Task ReadFromStream(NamedPipeClientStream clientPipe, string senderConnectionID, HubConnection hubConnection)
{
using var sr = new StreamReader(clientPipe, leaveOpen: true);
while (clientPipe.IsConnected)

View File

@ -10,18 +10,18 @@ namespace Remotely.Agent.Services
{
public class ConfigService
{
private static readonly object fileLock = new object();
private ConnectionInfo connectionInfo;
private readonly string debugGuid = "f2b0a595-5ea8-471b-975f-12e70e0f3497";
private static readonly object _fileLock = new object();
private ConnectionInfo _connectionInfo;
private readonly string _debugGuid = "f2b0a595-5ea8-471b-975f-12e70e0f3497";
private Dictionary<string, string> commandLineArgs;
private Dictionary<string, string> _commandLineArgs;
private Dictionary<string, string> CommandLineArgs
{
get
{
if (commandLineArgs is null)
if (_commandLineArgs is null)
{
commandLineArgs = new Dictionary<string, string>();
_commandLineArgs = new Dictionary<string, string>();
var args = Environment.GetCommandLineArgs();
for (var i = 1; i < args.Length; i += 2)
{
@ -32,32 +32,22 @@ namespace Remotely.Agent.Services
var value = args?[i + 1];
if (value != null)
{
commandLineArgs[key] = args[i + 1].Trim();
_commandLineArgs[key] = args[i + 1].Trim();
}
}
}
}
return commandLineArgs;
return _commandLineArgs;
}
}
public ConnectionInfo GetConnectionInfo()
{
if (EnvironmentHelper.IsDebug && Debugger.IsAttached)
{
return new ConnectionInfo()
{
DeviceID = debugGuid,
Host = "https://localhost:5001"
};
}
// For debugging purposes (i.e. launch of a bunch of instances).
if (CommandLineArgs.TryGetValue("host", out var hostName) &&
CommandLineArgs.TryGetValue("organization", out var orgID) &&
CommandLineArgs.TryGetValue("device", out var deviceID))
if (CommandLineArgs.TryGetValue("organization", out var orgID) &&
CommandLineArgs.TryGetValue("host", out var hostName) &&
CommandLineArgs.TryGetValue("device", out var deviceID))
{
return new ConnectionInfo()
{
@ -67,29 +57,40 @@ namespace Remotely.Agent.Services
};
}
if (connectionInfo == null)
if (EnvironmentHelper.IsDebug && Debugger.IsAttached)
{
lock (fileLock)
return new ConnectionInfo()
{
DeviceID = _debugGuid,
Host = "https://localhost:5001",
OrganizationID = orgID
};
}
if (_connectionInfo == null)
{
lock (_fileLock)
{
if (!File.Exists("ConnectionInfo.json"))
{
Logger.Write(new Exception("No connection info available. Please create ConnectionInfo.json file with appropriate values."));
return null;
}
connectionInfo = JsonSerializer.Deserialize<ConnectionInfo>(File.ReadAllText("ConnectionInfo.json"));
_connectionInfo = JsonSerializer.Deserialize<ConnectionInfo>(File.ReadAllText("ConnectionInfo.json"));
}
}
return connectionInfo;
return _connectionInfo;
}
public void SaveConnectionInfo(ConnectionInfo connectionInfo)
{
lock (fileLock)
lock (_fileLock)
{
this.connectionInfo = connectionInfo;
File.WriteAllText("ConnectionInfo.json", JsonConvert.SerializeObject(connectionInfo));
this._connectionInfo = connectionInfo;
File.WriteAllText("ConnectionInfo.json", JsonSerializer.Serialize(connectionInfo));
}
}
}

View File

@ -123,11 +123,11 @@ namespace Remotely.Agent.Services
if (RuntimeInformation.OSDescription.Contains("Ubuntu", StringComparison.OrdinalIgnoreCase))
{
platform = "Ubuntu-x64";
platform = "UbuntuInstaller-x64";
}
else if (RuntimeInformation.OSDescription.Contains("Manjaro", StringComparison.OrdinalIgnoreCase))
{
platform = "Manjaro-x64";
platform = "ManjaroInstaller-x64";
}
else
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -21,6 +21,7 @@ namespace Remotely.Desktop.Core
public string DeviceID { get; private set; }
public string Host { get; private set; }
public AppMode Mode { get; private set; }
public string OrganizationId { get; private set; }
public string OrganizationName { get; private set; }
public string RequesterID { get; private set; }
public string ServiceID { get; private set; }
@ -104,6 +105,20 @@ namespace Remotely.Desktop.Core
{
OrganizationName = orgName;
}
if (ArgDict.TryGetValue("orgid", out var orgId))
{
OrganizationId = orgId;
}
}
public void UpdateHost(string host)
{
Host = host;
}
public void UpdateOrganizationId(string organizationId)
{
OrganizationId = organizationId;
}
}
}

View File

@ -31,6 +31,14 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<None Remove="Assets\Remotely_Icon.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Assets\Remotely_Icon.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="5.0.2" />
@ -47,4 +55,8 @@
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Remotely_Icon.png" />
</ItemGroup>
</Project>

View File

@ -13,29 +13,29 @@ using System.Threading.Tasks;
namespace Remotely.Desktop.Core.Services
{
public class ChatClientService : IChatClientService
public class ChatHostService : IChatClientService
{
private readonly IChatUiService _chatUiService;
public ChatClientService(IChatUiService chatUiService)
public ChatHostService(IChatUiService chatUiService)
{
_chatUiService = chatUiService;
}
private NamedPipeClientStream NamedPipeStream { get; set; }
private NamedPipeServerStream NamedPipeStream { get; set; }
private StreamReader Reader { get; set; }
private StreamWriter Writer { get; set; }
public async Task StartChat(string requesterID, string organizationName)
{
NamedPipeStream = new NamedPipeClientStream(".", "Remotely_Chat" + requesterID, PipeDirection.InOut, PipeOptions.Asynchronous);
NamedPipeStream = new NamedPipeServerStream("Remotely_Chat" + requesterID, PipeDirection.InOut, 10, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
Writer = new StreamWriter(NamedPipeStream);
Reader = new StreamReader(NamedPipeStream);
var cts = new CancellationTokenSource(10000);
try
{
await NamedPipeStream.ConnectAsync(15_000);
await NamedPipeStream.WaitForConnectionAsync(cts.Token);
}
catch (TaskCanceledException)
{
@ -43,12 +43,6 @@ namespace Remotely.Desktop.Core.Services
Environment.Exit(0);
}
if (!NamedPipeStream.IsConnected)
{
Logger.Write("Failed to connect to chat host.");
return;
}
_chatUiService.ChatWindowClosed += OnChatWindowClosed;
_chatUiService.ShowChatWindow(organizationName, Writer);

View File

@ -0,0 +1,111 @@
using Remotely.Desktop.Core.Interfaces;
using Remotely.Shared.Utilities;
using Remotely.Shared.Models;
using Remotely.Shared.Utilities;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace Remotely.Desktop.Core.Services
{
public interface IDeviceInitService
{
BrandingInfo BrandingInfo { get; }
Task GetInitParams();
void SetBrandingInfo(BrandingInfo branding);
}
public class DeviceInitService : IDeviceInitService
{
private static BrandingInfo _brandingInfo;
private readonly Conductor _conductor;
private readonly IConfigService _configService;
public DeviceInitService(Conductor conductor, IConfigService configService)
{
_conductor = conductor;
_configService = configService;
}
public BrandingInfo BrandingInfo => _brandingInfo;
public async Task GetInitParams()
{
try
{
if (_brandingInfo != null)
{
return;
}
using var httpClient = new HttpClient();
var config = _configService.GetConfig();
if (!string.IsNullOrWhiteSpace(_conductor.Host) &&
!string.IsNullOrWhiteSpace(_conductor.OrganizationId))
{
config.Host = _conductor.Host;
config.OrganizationId = _conductor.Host;
_configService.Save(config);
var brandingUrl = $"{_conductor.Host.TrimEnd('/')}/api/branding/{_conductor.OrganizationId}";
_brandingInfo = await httpClient.GetFromJsonAsync<BrandingInfo>(brandingUrl).ConfigureAwait(false);
return;
}
var fileName = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName);
if (fileName.Contains("[") && fileName.Contains("]"))
{
var codeLength = AppConstants.RelayCodeLength + 2;
for (var i = 0; i < fileName.Length; i++)
{
var codeSection = string.Join("", fileName.Skip(i).Take(codeLength));
if (codeSection.StartsWith("[") && codeSection.EndsWith("]"))
{
var relayCode = codeSection[1..5];
using var response = await httpClient.GetAsync($"{AppConstants.DeviceInitUrl}/{relayCode}").ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
var contentString = await response.Content.ReadAsStringAsync();
var deviceInitParams = JsonSerializer.Deserialize<DeviceInitParams>(contentString, JsonSerializerHelper.CaseInsensitiveOptions);
config.Host = deviceInitParams.Host;
config.OrganizationId = deviceInitParams.OrganizationId;
_configService.Save(config);
var brandingUrl = $"{config.Host.TrimEnd('/')}/api/branding/{config.OrganizationId}";
_brandingInfo = await httpClient.GetFromJsonAsync<BrandingInfo>(brandingUrl).ConfigureAwait(false);
return;
}
}
}
}
}
catch (Exception ex)
{
Logger.Write(ex, "Failed to resolve init params.", Shared.Enums.EventType.Warning);
}
}
public void SetBrandingInfo(BrandingInfo branding)
{
if (branding != null)
{
_brandingInfo = branding;
}
}
}
}

View File

@ -3,7 +3,7 @@ using Remotely.Desktop.Core.Enums;
using Remotely.Desktop.Core.Interfaces;
using Remotely.Desktop.Core.Models;
using Remotely.Desktop.Core.Utilities;
using Remotely.Shared.Helpers;
using Remotely.Shared.Utilities;
using Remotely.Shared.Models;
using Remotely.Shared.Utilities;
using System;

View File

@ -1,7 +1,7 @@
using Remotely.Desktop.Core.Interfaces;
using Remotely.Desktop.Core.Models;
using Remotely.Desktop.Core.ViewModels;
using Remotely.Shared.Helpers;
using Remotely.Shared.Utilities;
using Remotely.Shared.Models;
using Remotely.Shared.Models.RemoteControlDtos;
using Remotely.Shared.Utilities;

View File

@ -1,6 +1,6 @@
using MessagePack;
using Microsoft.MixedReality.WebRTC;
using Remotely.Shared.Helpers;
using Remotely.Shared.Utilities;
using Remotely.Shared.Models;
using Remotely.Shared.Models.RemoteControlDtos;
using Remotely.Shared.Utilities;

View File

@ -12,8 +12,8 @@ namespace Remotely.Desktop.Core.Utilities
{
public class ImageUtils
{
public static ImageCodecInfo JpegEncoder { get; } = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == ImageFormat.Jpeg.Guid);
public static ImageCodecInfo GifEncoder { get; } = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == ImageFormat.Gif.Guid);
public static ImageCodecInfo JpegEncoder { get; } = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == ImageFormat.Jpeg.Guid);
public static byte[] EncodeBitmap(Bitmap bitmap, EncoderParameters encoderParams)
{

View File

@ -18,8 +18,8 @@ namespace Remotely.Desktop.Core.ViewModels
set
{
_filePath = value;
FirePropertyChanged(nameof(FilePath));
FirePropertyChanged(nameof(DisplayName));
FirePropertyChanged();
FirePropertyChanged();
}
}
public double PercentProgress
@ -31,7 +31,7 @@ namespace Remotely.Desktop.Core.ViewModels
set
{
_percentProgress = value;
FirePropertyChanged(nameof(PercentProgress));
FirePropertyChanged();
}
}
}

View File

@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Remotely.Desktop.Core.ViewModels
{
@ -6,7 +7,7 @@ namespace Remotely.Desktop.Core.ViewModels
{
public event PropertyChangedEventHandler PropertyChanged;
public void FirePropertyChanged(string propertyName)
public void FirePropertyChanged([CallerMemberName]string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

View File

@ -5,7 +5,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
xmlns:vm="clr-namespace:Remotely.Desktop.Linux.ViewModels;assembly=Remotely_Desktop"
x:Class="Remotely.Desktop.Linux.Controls.MessageBox"
Icon="/Assets/favicon.ico"
Icon="{Binding Icon}"
Title="{Binding Caption}"
SizeToContent="WidthAndHeight" MinWidth="300" MinHeight="100"
WindowStartupLocation="CenterScreen">

View File

@ -3,7 +3,7 @@ using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Remotely.Desktop.Linux.ViewModels;
using Remotely.Shared.Helpers;
using Remotely.Shared.Utilities;
using System;
using System.Linq;
using System.Threading.Tasks;
@ -54,9 +54,6 @@ namespace Remotely.Desktop.Linux.Controls
// This doesn't appear to work when set in XAML.
WindowStartupLocation = WindowStartupLocation.CenterScreen;
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}

View File

@ -21,6 +21,13 @@
</PropertyGroup>
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageId>Remotely Desktop</PackageId>
<Authors>Jared Goodwin</Authors>
<Company>Translucency Software</Company>
<Product>Remotely Desktop</Product>
<Description>Desktop client for allowing your IT admin to provide remote support.</Description>
<Copyright>Copyright © 2021 Translucency Software</Copyright>
<PackageProjectUrl>https://remotely.one</PackageProjectUrl>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
@ -35,20 +42,26 @@
<EmbeddedResource Remove="Models\**" />
<None Remove="Models\**" />
</ItemGroup>
<ItemGroup>
<AvaloniaResource Remove="Assets\Remotely_Icon.png" />
</ItemGroup>
<ItemGroup>
<None Remove="Assets\Remotely_Icon.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.9.12" />
<PackageReference Include="Avalonia.Desktop" Version="0.9.12" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.9.12" />
<EmbeddedResource Include="Assets\Remotely_Icon.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Desktop.Core\Desktop.Core.csproj" />
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Controls\HostNamePrompt.axaml.cs">
<Compile Update="Views\HostNamePrompt.axaml.cs">
<DependentUpon>HostNamePrompt.axaml</DependentUpon>
</Compile>
<Compile Update="Controls\MessageBox.axaml.cs">

View File

@ -1,6 +1,5 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Logging.Serilog;
using Avalonia.ReactiveUI;
using Avalonia.Threading;
using Microsoft.Extensions.DependencyInjection;
@ -10,6 +9,7 @@ using Remotely.Desktop.Core.Interfaces;
using Remotely.Desktop.Core.Services;
using Remotely.Desktop.Linux.Services;
using Remotely.Desktop.Linux.Views;
using Remotely.Shared.Services;
using Remotely.Shared.Utilities;
using System;
using System.Threading;
@ -24,7 +24,7 @@ namespace Remotely.Desktop.Linux
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToDebug()
.LogToTrace()
.UseReactiveUI();
public static Conductor Conductor { get; private set; }
@ -50,9 +50,11 @@ namespace Remotely.Desktop.Linux
while (App.Current is null)
{
Thread.Sleep(100);
await Task.Delay(100);
}
await Services.GetRequiredService<IDeviceInitService>().GetInitParams();
if (Conductor.Mode == Core.Enums.AppMode.Chat)
{
await Services.GetRequiredService<IChatClientService>().StartChat(Conductor.RequesterID, Conductor.OrganizationName);
@ -107,7 +109,7 @@ namespace Remotely.Desktop.Linux
serviceCollection.AddSingleton<ICasterSocket, CasterSocket>();
serviceCollection.AddSingleton<IdleTimer>();
serviceCollection.AddSingleton<Conductor>();
serviceCollection.AddSingleton<IChatClientService, ChatClientService>();
serviceCollection.AddSingleton<IChatClientService, ChatHostService>();
serviceCollection.AddSingleton<IChatUiService, ChatUiServiceLinux>();
serviceCollection.AddTransient<IScreenCapturer, ScreenCapturerLinux>();
serviceCollection.AddTransient<Viewer>();
@ -119,6 +121,7 @@ namespace Remotely.Desktop.Linux
serviceCollection.AddScoped<IDtoMessageHandler, DtoMessageHandler>();
serviceCollection.AddScoped<IRemoteControlAccessService, RemoteControlAccessServiceLinux>();
serviceCollection.AddScoped<IConfigService, ConfigServiceLinux>();
serviceCollection.AddScoped<IDeviceInitService, DeviceInitService>();
ServiceContainer.Instance = serviceCollection.BuildServiceProvider();
}

View File

@ -1,7 +1,8 @@
{
"profiles": {
"Desktop.Linux": {
"commandName": "Project"
"commandName": "Project",
"commandLineArgs": "-orgid \"e42c65b4-deb2-4dca-b4fb-ec8dcbe8f84c\" -host \"https://localhost:5001\""
}
}
}

View File

@ -2,7 +2,7 @@
using Remotely.Desktop.Core.Interfaces;
using Remotely.Desktop.Linux.ViewModels;
using Remotely.Desktop.Linux.Views;
using Remotely.Shared.Helpers;
using Remotely.Shared.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -0,0 +1,67 @@
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Microsoft.Extensions.DependencyInjection;
using Remotely.Desktop.Core;
using Remotely.Desktop.Core.Services;
using System.IO;
using System.Linq;
using System.Reflection;
namespace Remotely.Desktop.Linux.ViewModels
{
public class BrandedViewModelBase : ReactiveViewModel
{
public BrandedViewModelBase()
{
var deviceInit = ServiceContainer.Instance?.GetRequiredService<IDeviceInitService>();
var brandingInfo = deviceInit?.BrandingInfo ?? new Shared.Models.BrandingInfo();
ProductName = "Remotely";
if (!string.IsNullOrWhiteSpace(brandingInfo?.Product))
{
ProductName = brandingInfo.Product;
}
TitleBackgroundColor = new SolidColorBrush(Color.FromRgb(
brandingInfo?.TitleBackgroundRed ?? 70,
brandingInfo?.TitleBackgroundGreen ?? 70,
brandingInfo?.TitleBackgroundBlue ?? 70));
TitleForegroundColor = new SolidColorBrush(Color.FromRgb(
brandingInfo?.TitleForegroundRed ?? 29,
brandingInfo?.TitleForegroundGreen ?? 144,
brandingInfo?.TitleForegroundBlue ?? 241));
TitleButtonForegroundColor = new SolidColorBrush(Color.FromRgb(
brandingInfo?.ButtonForegroundRed ?? 255,
brandingInfo?.ButtonForegroundGreen ?? 255,
brandingInfo?.ButtonForegroundBlue ?? 255));
if (brandingInfo?.Icon?.Any() == true)
{
using var imageStream = new MemoryStream(brandingInfo.Icon);
Icon = new Bitmap(imageStream);
}
else
{
using var imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Remotely.Desktop.Linux.Assets.Remotely_Icon.png");
Icon = new Bitmap(imageStream);
}
WindowIcon = new WindowIcon(Icon);
}
public Bitmap Icon { get; set; }
public string ProductName { get; set; }
public SolidColorBrush TitleBackgroundColor { get; set; }
public SolidColorBrush TitleButtonForegroundColor { get; set; }
public SolidColorBrush TitleForegroundColor { get; set; }
public WindowIcon WindowIcon { get; set; }
}
}

View File

@ -10,7 +10,7 @@ using System.Windows.Input;
namespace Remotely.Desktop.Linux.ViewModels
{
public class ChatWindowViewModel : ReactiveViewModel
public class ChatWindowViewModel : BrandedViewModelBase
{
private string _inputText;
private string _organizationName = "your IT provider";

View File

@ -15,7 +15,7 @@ using System.Windows.Input;
namespace Remotely.Desktop.Linux.ViewModels
{
public class FileTransferWindowViewModel : ReactiveObject
public class FileTransferWindowViewModel : BrandedViewModelBase
{
private readonly IFileTransferService _fileTransferService;
private readonly Viewer _viewer;

View File

@ -5,9 +5,9 @@ using System.Windows.Input;
namespace Remotely.Desktop.Linux.ViewModels
{
public class HostNamePromptViewModel : ReactiveViewModel
public class HostNamePromptViewModel : BrandedViewModelBase
{
public string _host;
public string _host = "https://";
public string Host
{

View File

@ -11,6 +11,7 @@ using Remotely.Desktop.Linux.Native;
using Remotely.Desktop.Linux.Services;
using Remotely.Desktop.Linux.Views;
using Remotely.Shared.Models;
using Remotely.Shared.Services;
using Remotely.Shared.Utilities;
using System;
using System.Collections.ObjectModel;
@ -21,8 +22,11 @@ using System.Windows.Input;
namespace Remotely.Desktop.Linux.ViewModels
{
public class MainWindowViewModel : ReactiveViewModel
public class MainWindowViewModel : BrandedViewModelBase
{
private readonly ICasterSocket _casterSocket;
private readonly Conductor _conductor;
private readonly IConfigService _configService;
private double _copyMessageOpacity;
private string _host;
private bool _isCopyMessageVisible;
@ -31,6 +35,16 @@ namespace Remotely.Desktop.Linux.ViewModels
public MainWindowViewModel()
{
Current = this;
_configService = Services.GetRequiredService<IConfigService>();
_conductor = Services.GetRequiredService<Conductor>();
_casterSocket = Services.GetRequiredService<ICasterSocket>();
_conductor.SessionIDChanged += SessionIDChanged;
_conductor.ViewerRemoved += ViewerRemoved;
_conductor.ViewerAdded += ViewerAdded;
_conductor.ScreenCastRequested += ScreenCastRequested;
if (!EnvironmentHelper.IsLinux)
{
return;
@ -38,15 +52,6 @@ namespace Remotely.Desktop.Linux.ViewModels
Services.GetRequiredService<IClipboardService>().BeginWatching();
Services.GetRequiredService<IKeyboardMouseInput>().Init();
ConfigService = Services.GetRequiredService<IConfigService>();
Conductor = Services.GetRequiredService<Conductor>();
CasterSocket = Services.GetRequiredService<ICasterSocket>();
Conductor.SessionIDChanged += SessionIDChanged;
Conductor.ViewerRemoved += ViewerRemoved;
Conductor.ViewerAdded += ViewerAdded;
Conductor.ScreenCastRequested += ScreenCastRequested;
}
@ -115,7 +120,7 @@ namespace Remotely.Desktop.Linux.ViewModels
var viewerList = param as AvaloniaList<object> ?? new AvaloniaList<object>();
foreach (Viewer viewer in viewerList)
{
await CasterSocket.DisconnectViewer(viewer, true);
await _casterSocket.DisconnectViewer(viewer, true);
}
});
@ -127,13 +132,10 @@ namespace Remotely.Desktop.Linux.ViewModels
public ObservableCollection<Viewer> Viewers { get; } = new ObservableCollection<Viewer>();
private static IServiceProvider Services => ServiceContainer.Instance;
private ICasterSocket CasterSocket { get; }
private IConfigService ConfigService { get; }
private Conductor Conductor { get; }
public async Task GetSessionID()
{
await CasterSocket.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName, Conductor.DeviceID);
await CasterSocket.GetSessionID();
await _casterSocket.SendDeviceInfo(_conductor.ServiceID, Environment.MachineName, _conductor.DeviceID);
await _casterSocket.GetSessionID();
}
public async Task Init()
@ -152,18 +154,24 @@ namespace Remotely.Desktop.Linux.ViewModels
SessionID = "Retrieving...";
Host = ConfigService.GetConfig().Host;
Host = _configService.GetConfig().Host;
while (string.IsNullOrWhiteSpace(Host))
{
Host = "https://";
await PromptForHostName();
}
Conductor.ProcessArgs(new string[] { "-mode", "Normal", "-host", Host });
await CasterSocket.Connect(Conductor.Host);
_conductor.ProcessArgs(new string[] { "-mode", "Normal", "-host", Host });
CasterSocket.Connection.Closed += async (ex) =>
await _casterSocket.Connect(_conductor.Host);
if (_casterSocket.Connection is null)
{
return;
}
_casterSocket.Connection.Closed += async (ex) =>
{
await Dispatcher.UIThread.InvokeAsync(() =>
{
@ -171,7 +179,7 @@ namespace Remotely.Desktop.Linux.ViewModels
});
};
CasterSocket.Connection.Reconnecting += async (ex) =>
_casterSocket.Connection.Reconnecting += async (ex) =>
{
await Dispatcher.UIThread.InvokeAsync(() =>
{
@ -179,14 +187,14 @@ namespace Remotely.Desktop.Linux.ViewModels
});
};
CasterSocket.Connection.Reconnected += async (arg) =>
_casterSocket.Connection.Reconnected += async (arg) =>
{
await GetSessionID();
};
await CasterSocket.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName, Conductor.DeviceID);
await CasterSocket.GetSessionID();
await _casterSocket.SendDeviceInfo(_conductor.ServiceID, Environment.MachineName, _conductor.DeviceID);
await _casterSocket.GetSessionID();
}
catch (Exception ex)
{
@ -200,13 +208,14 @@ namespace Remotely.Desktop.Linux.ViewModels
public async Task PromptForHostName()
{
var prompt = new HostNamePrompt();
if (!string.IsNullOrWhiteSpace(Host))
{
prompt.ViewModel.Host = Host;
}
prompt.Owner = MainWindow.Current;
await prompt.ShowDialog(MainWindow.Current);
var result = prompt.ViewModel.Host?.TrimEnd('/');
var result = prompt.ViewModel.Host?.Trim();
if (result is null)
{
@ -220,9 +229,9 @@ namespace Remotely.Desktop.Linux.ViewModels
if (result != Host)
{
Host = result;
var config = ConfigService.GetConfig();
var config = _configService.GetConfig();
config.Host = Host;
ConfigService.Save(config);
_configService.Save(config);
}
}

View File

@ -6,7 +6,7 @@ using System.Windows.Input;
namespace Remotely.Desktop.Linux.ViewModels
{
public class MessageBoxViewModel : ReactiveViewModel
public class MessageBoxViewModel : BrandedViewModelBase
{
private bool areYesNoButtonsVisible;
private string caption;

View File

@ -8,7 +8,7 @@ using System.Windows.Input;
namespace Remotely.Desktop.Linux.ViewModels
{
public class PromptForAccessWindowViewModel : ReactiveViewModel
public class PromptForAccessWindowViewModel : BrandedViewModelBase
{
private string _organizationName = "your IT provider";
private string _requesterName = "a technician";

View File

@ -6,14 +6,14 @@
xmlns:Models="clr-namespace:Remotely.Shared.Models;assembly=Remotely_Shared"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Remotely.Desktop.Linux.Views.ChatWindow"
Icon="/Assets/favicon.ico"
Icon="{Binding WindowIcon}"
HasSystemDecorations="False"
BorderBrush="DimGray"
BorderThickness="1"
MinHeight="250"
MinWidth="200"
Topmost="True"
Title="Remotely Chat" Height="450" Width="350">
Title="Chat Session" Height="450" Width="450">
<Window.DataContext>
<vm:ChatWindowViewModel />
@ -25,19 +25,23 @@
<RowDefinition />
</Grid.RowDefinitions>
<Border Name="TitleBanner" Height="50" Background="#FF464646">
<DockPanel Margin="10,4,0,0">
<Border Name="TitleBanner" Height="50" Background="{Binding TitleBackgroundColor}">
<Grid Margin="10,4,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<DockPanel>
<Image Height="50" Width="50" Source="/Assets/Remotely_Icon.png" Margin="0,0,10,0"></Image>
<TextBlock Foreground="#FF1D90F1" FontWeight="Bold" FontSize="20" VerticalAlignment="Center">
Remotely Chat
</TextBlock>
</DockPanel>
<Button Classes="TitlebarButton" Command="{Binding CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="X" />
<Button Classes="TitlebarButton" Command="{Binding MinimizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="_"/>
</DockPanel>
<Image Grid.Column="0" Height="50" Width="50" Source="{Binding Icon}" Margin="0,0,10,0"></Image>
<TextBlock Grid.Column="1" Text="{Binding ProductName}" Foreground="{Binding TitleForegroundColor}" FontWeight="Bold" FontSize="20" VerticalAlignment="Center" />
<TextBlock Grid.Column="2" Text=" Chat" Foreground="{Binding TitleForegroundColor}" FontWeight="Bold" FontSize="20" VerticalAlignment="Center" />
<Button Grid.Column="4" Classes="TitlebarButton" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" Command="{Binding MinimizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="__"/>
<Button Grid.Column="5" Classes="TitlebarButton" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" Command="{Binding CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="X" />
</Grid>
</Border>
<TextBlock Grid.Row="1"

View File

@ -12,9 +12,6 @@ namespace Remotely.Desktop.Linux.Views
public ChatWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private ChatWindowViewModel ViewModel => DataContext as ChatWindowViewModel;

View File

@ -6,10 +6,10 @@
xmlns:local="clr-namespace:Remotely.Desktop.Linux.Views;assembly=Remotely_Desktop"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Remotely.Desktop.Linux.Views.FileTransferWindow"
Title="Remotely File Transfer"
Title="File Transfer"
Height="300" Width="400"
Topmost="True"
Icon="/Assets/favicon.ico">
Icon="{Binding WindowIcon}">
<Window.DataContext>
<vm:FileTransferWindowViewModel />

View File

@ -10,9 +10,6 @@ namespace Remotely.Desktop.Linux.Views
public FileTransferWindow()
{
this.InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()

View File

@ -3,10 +3,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Remotely.Desktop.Linux.Controls.HostNamePrompt"
x:Class="Remotely.Desktop.Linux.Views.HostNamePrompt"
xmlns:ViewModels="clr-namespace:Remotely.Desktop.Linux.ViewModels;assembly=Remotely_Desktop"
Title="Remotely Host Name"
Icon="/Assets/favicon.ico"
Title="Host Name"
Icon="{Binding WindowIcon}"
Height="150" Width="350"
WindowStartupLocation="CenterScreen">
<Window.DataContext>

View File

@ -2,17 +2,16 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Remotely.Desktop.Linux.ViewModels;
using Remotely.Desktop.Linux.Views;
namespace Remotely.Desktop.Linux.Controls
namespace Remotely.Desktop.Linux.Views
{
public class HostNamePrompt : Window
{
public HostNamePrompt()
{
Owner = MainWindow.Current;
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
public HostNamePromptViewModel ViewModel => DataContext as HostNamePromptViewModel;

View File

@ -5,23 +5,28 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Remotely.Desktop.Linux.Views.MainWindow"
Icon="/Assets/favicon.ico"
Title="Remotely" Height="275" Width="350" HasSystemDecorations="False">
Icon="{Binding WindowIcon}"
Title="{Binding ProductName}" Height="275" Width="350" HasSystemDecorations="False">
<Window.DataContext>
<vm:MainWindowViewModel />
</Window.DataContext>
<Grid>
<StackPanel>
<Border Name="TitleBanner" Height="50" Background="#FF464646">
<DockPanel Margin="10,4,0,0">
<StackPanel>
<TextBlock Foreground="DeepSkyBlue" FontWeight="Bold" FontSize="20">Remotely</TextBlock>
<TextBlock Foreground="White" FontSize="10" Text="Do IT Remotely"></TextBlock>
</StackPanel>
<Button Classes="TitlebarButton" Command="{Binding CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="X" />
<Button Classes="TitlebarButton" Command="{Binding MinimizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="_"/>
</DockPanel>
</Border>
<Border Name="TitleBanner" Height="50" Background="{Binding TitleBackgroundColor}">
<Grid Margin="10,4,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Height="50" Width="50" Source="{Binding Icon}" Margin="0,0,10,0"></Image>
<TextBlock Grid.Column="1" Text="{Binding ProductName}" Foreground="{Binding TitleForegroundColor}" FontWeight="Bold" FontSize="20" VerticalAlignment="Center" />
<Button Grid.Column="2" Classes="TitlebarButton" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" Command="{Binding MinimizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="__"/>
<Button Grid.Column="3" Classes="TitlebarButton" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" Command="{Binding CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="X" />
</Grid>
</Border>
<Grid Margin="10,15,10,0">
<Grid.ColumnDefinitions>
<ColumnDefinition />

View File

@ -10,12 +10,8 @@ namespace Remotely.Desktop.Linux.Views
public MainWindow()
{
Current = this;
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
public static MainWindow Current { get; set; }

View File

@ -13,7 +13,7 @@
MinWidth="250"
Height="275"
Width="450"
Icon="/Assets/favicon.ico">
Icon="{Binding WindowIcon}">
<Window.DataContext>
<vm:PromptForAccessWindowViewModel />
@ -26,19 +26,21 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Name="TitleBanner" Height="50" Background="#FF464646">
<DockPanel Margin="10,4,0,0">
<Border Name="TitleBanner" Height="50" Background="{Binding TitleBackgroundColor}">
<Grid Margin="10,4,0,0">
<DockPanel>
<Image Height="50" Width="50" Source="/Assets/Remotely_Icon.png" Margin="0,0,10,0"></Image>
<TextBlock Foreground="#FF1D90F1" FontWeight="Bold" FontSize="20" VerticalAlignment="Center">
Remotely Chat
</TextBlock>
</DockPanel>
<Button Classes="TitlebarButton" Command="{Binding CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="X" />
<Button Classes="TitlebarButton" Command="{Binding MinimizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="_"/>
</DockPanel>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Height="50" Width="50" Source="{Binding Icon}" Margin="0,0,10,0"></Image>
<TextBlock Grid.Column="1" Text="Remote Control Request" Foreground="{Binding TitleForegroundColor}" FontWeight="Bold" FontSize="20" VerticalAlignment="Center" />
<Button Grid.Column="2" Classes="TitlebarButton" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" Command="{Binding MinimizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="__"/>
<Button Grid.Column="3" Classes="TitlebarButton" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" Command="{Binding CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Content="X" />
</Grid>
</Border>
<StackPanel Grid.Row="1">

View File

@ -10,9 +10,6 @@ namespace Remotely.Desktop.Linux.Views
public PromptForAccessWindow()
{
this.InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()

View File

@ -2,16 +2,21 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:Remotely.Desktop.Linux.ViewModels;assembly=Remotely_Desktop"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
Width="300"
Height="100"
x:Class="Remotely.Desktop.Linux.Views.SessionIndicatorWindow"
Background="#2b2726"
Title="Remotely Desktop"
Icon="/Assets/favicon.ico"
Title="{Binding ProductName}p"
Icon="{Binding WindowIcon}"
WindowStartupLocation="Manual"
Topmost="True"
SizeToContent="WidthAndHeight">
<Window.DataContext>
<vm:BrandedViewModelBase />
</Window.DataContext>
<StackPanel Margin="15 10 40 15">
<TextBlock Classes="SectionHeader" Foreground="White">

View File

@ -14,9 +14,6 @@ namespace Remotely.Desktop.Linux.Views
public SessionIndicatorWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()

View File

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

View File

@ -1,31 +0,0 @@
<Application x:Class="Desktop.Win.Wrapper.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Desktop.Win.Wrapper"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style x:Key="TitlebarButton" TargetType="Button">
<Setter Property="Background" Value="#FF464646"></Setter>
<Setter Property="DockPanel.Dock" Value="Right"></Setter>
<Setter Property="HorizontalAlignment" Value="Right"></Setter>
<Setter Property="BorderBrush" Value="{x:Null}"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="FontWeight" Value="Bold"></Setter>
<Setter Property="Height" Value="30"></Setter>
<Setter Property="Width" Value="30"></Setter>
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Margin" Value="5,0,5,0"></Setter>
</Style>
<Style x:Key="SectionHeader" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Bold"></Setter>
<Setter Property="FontSize" Value="18"></Setter>
</Style>
<Style x:Key="NormalButton" TargetType="Button">
<Setter Property="Background" Value="White"></Setter>
<Setter Property="BorderThickness" Value="1"></Setter>
<Setter Property="BorderBrush" Value="Black"></Setter>
<Setter Property="Padding" Value="6,4"></Setter>
</Style>
</Application.Resources>
</Application>

View File

@ -1,11 +0,0 @@
using System.Windows;
namespace Desktop.Win.Wrapper
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@ -1,169 +0,0 @@
<?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>{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Remotely.Desktop.Win.Wrapper</RootNamespace>
<AssemblyName>Remotely_Desktop</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<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>
<ApplicationIcon>favicon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="..\.editorconfig">
<Link>.editorconfig</Link>
</None>
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<EmbeddedResource Include="Remotely_Desktop.zip" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="favicon.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Remotely_Icon.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>if $(ConfigurationName) == Debug (
if not exist "$(ProjectDir)Remotely_Desktop.zip" (
echo &gt; $(ProjectDir)Remotely_Desktop.zip
)
)</PreBuildEvent>
</PropertyGroup>
</Project>

View File

@ -1,42 +0,0 @@
<Window x:Class="Remotely.Desktop.Win.Wrapper.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Remotely.Desktop.Win.Wrapper"
mc:Ignorable="d"
Title="Remotely" Height="250" Width="350"
WindowStyle="None"
ResizeMode="NoResize"
MouseLeftButtonDown="Window_MouseLeftButtonDown"
WindowStartupLocation="CenterScreen"
Loaded="Window_Loaded" Icon="Remotely_Icon.png">
<Grid>
<StackPanel>
<Border Height="50" Background="#FF464646">
<DockPanel Margin="10,0,0,0">
<StackPanel>
<TextBlock Foreground="DeepSkyBlue" FontWeight="Bold" FontSize="20" Margin="0,2,0,0">Remotely</TextBlock>
<TextBlock Foreground="White" FontSize="10"><Run Text="Do IT Remotely"/></TextBlock>
</StackPanel>
<Button Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" />
<Button Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="_"/>
</DockPanel>
</Border>
<TextBlock Margin="0,40,0,0"
Style="{StaticResource SectionHeader}"
Text="Loading resources"
HorizontalAlignment="Center"></TextBlock>
<TextBlock x:Name="StatusText"
Margin="0,20,0,0"
HorizontalAlignment="Center"
Text="Extracting files..."></TextBlock>
<ProgressBar IsIndeterminate="True"
HorizontalAlignment="Center"
Width="150"
Margin="0,10,0,0"
Height="10"></ProgressBar>
</StackPanel>
</Grid>
</Window>

View File

@ -1,154 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace Remotely.Desktop.Win.Wrapper
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private static readonly string baseDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "Remotely_Desktop")).FullName;
private readonly string currentVersionDir = Path.Combine(baseDir, "Current");
private readonly string remotelyDesktopFilename = "Remotely_Desktop.exe";
private readonly string tempDir = Directory.CreateDirectory(Path.Combine(baseDir, Guid.NewGuid().ToString())).FullName;
public MainWindow()
{
InitializeComponent();
}
private void CleanupOldFiles()
{
foreach (var fse in Directory.GetFileSystemEntries(baseDir))
{
try
{
if (Directory.Exists(fse) && fse != currentVersionDir)
{
Directory.Delete(fse, true);
}
else if (File.Exists(fse))
{
File.Delete(fse);
}
}
catch { }
}
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void ExtractRemotely()
{
try
{
var zipPath = Path.Combine(tempDir, "Remotely_Desktop.zip");
var tempExePath = Path.Combine(tempDir, remotelyDesktopFilename);
using (var mrs = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("Remotely.Desktop.Win.Wrapper.Remotely_Desktop.zip"))
{
using (var fs = new FileStream(zipPath, FileMode.Create))
{
mrs.CopyTo(fs);
}
}
using (var zipArchive = ZipFile.OpenRead(zipPath))
{
zipArchive.GetEntry(remotelyDesktopFilename).ExtractToFile(tempExePath);
var fileVersionInfo = FileVersionInfo.GetVersionInfo(tempExePath);
var targetExePath = Path.Combine(currentVersionDir, remotelyDesktopFilename);
if (File.Exists(targetExePath) &&
FileVersionInfo.GetVersionInfo(targetExePath).FileVersion == fileVersionInfo.FileVersion)
{
return;
}
try
{
var currentVersionDir = Path.GetDirectoryName(targetExePath);
if (Directory.Exists(currentVersionDir))
{
Directory.Delete(currentVersionDir, true);
}
Directory.CreateDirectory(currentVersionDir);
ZipFile.ExtractToDirectory(zipPath, currentVersionDir);
}
catch { }
}
}
catch (Exception ex)
{
MessageBox.Show("An error occured while extracting files. Error: " +
Environment.NewLine + Environment.NewLine + ex.Message, "Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
private void MinimizeButton_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private void StartRemotely()
{
try
{
Process.Start(Path.Combine(currentVersionDir, remotelyDesktopFilename));
}
catch (Exception ex)
{
MessageBox.Show("An error occured while starting Remotely. Error: " +
Environment.NewLine + Environment.NewLine + ex.Message, "Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
StatusText.Text = "Extracting files...";
await Task.Run(ExtractRemotely);
await Task.Run(StartRemotely);
await Task.Run(CleanupOldFiles);
await Task.Run(AddFirewallRule);
Close();
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void AddFirewallRule()
{
var psi = new ProcessStartInfo()
{
FileName = "netsh",
Arguments = "advfirewall firewall delete rule name=\"Remotely Desktop\"",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true
};
Process.Start(psi).WaitForExit();
psi.Arguments = $"advfirewall firewall add rule name=\"Remotely Desktop\" program=\"{Path.Combine(currentVersionDir, remotelyDesktopFilename)}\" protocol=any dir=in enable=yes action=allow description=\"The agent that allows screen sharing and remote control for Remotely.\"";
Process.Start(psi).WaitForExit();
}
}
}

View File

@ -1,53 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
// 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("Remotely Desktop")]
[assembly: AssemblyDescription("Desktop client for allowing remote control via the Remotely server.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Translucency Software")]
[assembly: AssemblyProduct("Remotely Desktop")]
[assembly: AssemblyCopyright("Copyright © 2020 Translucency Software")]
[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)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// 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

@ -1,63 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Remotely.Desktop.Win.Wrapper.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Remotely.Desktop.Win.Wrapper.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -1,117 +0,0 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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>

View File

@ -1,26 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Remotely.Desktop.Win.Wrapper.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -1,76 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

View File

@ -9,8 +9,8 @@
<RootNamespace>Remotely.Desktop.Win</RootNamespace>
<ApplicationIcon>Assets\favicon.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Description>Desktop client for allowing remote control via the Remotely server.</Description>
<Copyright>Copyright © 2020 Translucency Software</Copyright>
<Description>Desktop client for allowing your IT admin to provide remote support.</Description>
<Copyright>Copyright © 2021 Translucency Software</Copyright>
<PackageId>Remotely Desktop</PackageId>
<Authors>Jared Goodwin</Authors>
<Company>Translucency Software</Company>
@ -49,7 +49,7 @@
<ItemGroup>
<Resource Include="Assets\favicon.ico" />
<Resource Include="Assets\Remotely_Icon.png" />
<EmbeddedResource Include="Assets\Remotely_Icon.png" />
</ItemGroup>
<ItemGroup>
@ -64,7 +64,7 @@
<SubType>Code</SubType>
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Update="Controls\HostNamePrompt.xaml.cs">
<Compile Update="Views\HostNamePrompt.xaml.cs">
<DependentUpon>HostNamePrompt.xaml</DependentUpon>
</Compile>
<Compile Update="Views\MainWindow.xaml.cs">
@ -74,7 +74,7 @@
</ItemGroup>
<ItemGroup>
<Page Update="Controls\HostNamePrompt.xaml">
<Page Update="Views\HostNamePrompt.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\MainWindow.xaml">

View File

@ -1,4 +1,4 @@
using Remotely.Shared.Helpers;
using Remotely.Shared.Utilities;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using System;

View File

@ -6,13 +6,17 @@ using Remotely.Desktop.Core.Interfaces;
using Remotely.Desktop.Core.Services;
using Remotely.Desktop.Win.Services;
using Remotely.Desktop.Win.Views;
using Remotely.Shared.Helpers;
using Remotely.Shared.Models;
using Remotely.Shared.Utilities;
using Remotely.Shared.Models;
using Remotely.Shared.Services;
using Remotely.Shared.Win32;
using System;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Windows;
using System.Windows.Forms;
@ -36,7 +40,7 @@ namespace Remotely.Desktop.Win
}
}
public static void Main(string[] args)
public static async Task Main(string[] args)
{
try
{
@ -56,6 +60,39 @@ namespace Remotely.Desktop.Win
}
};
var deviceInitService = Services.GetRequiredService<IDeviceInitService>();
var activationUri = Services.GetRequiredService<IClickOnceService>().GetActivationUri();
if (Uri.TryCreate(activationUri, UriKind.Absolute, out var result))
{
var host = $"{result.Scheme}://{result.Authority}";
if (!string.IsNullOrWhiteSpace(host))
{
Conductor.UpdateHost(host);
using var httpClient = new HttpClient();
try
{
var url = $"{host.TrimEnd('/')}/api/branding";
var query = HttpUtility.ParseQueryString(result.Query);
if (query?.AllKeys?.Contains("organizationid") == true)
{
url += $"?organizationId={query["organizationid"]}";
Conductor.UpdateOrganizationId(query["organizationid"]);
}
var branding = await httpClient.GetFromJsonAsync<BrandingInfo>(url).ConfigureAwait(false);
if (branding != null)
{
deviceInitService.SetBrandingInfo(branding);
}
}
catch { }
}
}
await deviceInitService.GetInitParams().ConfigureAwait(false);
if (Conductor.Mode == Core.Enums.AppMode.Chat)
{
StartUiThreads(false);
@ -105,7 +142,7 @@ namespace Remotely.Desktop.Win
serviceCollection.AddSingleton<ICasterSocket, CasterSocket>();
serviceCollection.AddSingleton<IdleTimer>();
serviceCollection.AddSingleton<Conductor>();
serviceCollection.AddSingleton<IChatClientService, ChatClientService>();
serviceCollection.AddSingleton<IChatClientService, ChatHostService>();
serviceCollection.AddSingleton<IChatUiService, ChatUiServiceWin>();
serviceCollection.AddTransient<IScreenCapturer, ScreenCapturerWin>();
serviceCollection.AddTransient<Viewer>();
@ -116,6 +153,8 @@ namespace Remotely.Desktop.Win
serviceCollection.AddScoped<IDtoMessageHandler, DtoMessageHandler>();
serviceCollection.AddScoped<IRemoteControlAccessService, RemoteControlAccessServiceWin>();
serviceCollection.AddScoped<IConfigService, ConfigServiceWin>();
serviceCollection.AddScoped<IDeviceInitService, DeviceInitService>();
serviceCollection.AddScoped<IClickOnceService, ClickOnceService>();
BackgroundForm = new Form()
{

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateDesktopShortcut>True</CreateDesktopShortcut>
<ErrorReportUrl>https://remotely.one/Contact</ErrorReportUrl>
<ExcludeDeploymentUrl>False</ExcludeDeploymentUrl>
<GenerateManifests>True</GenerateManifests>
<Install>true</Install>
<InstallFrom>Web</InstallFrom>
<InstallUrl>http://127.0.0.1:5000/Downloads/Win-x64/ClickOnce/</InstallUrl>
<IsRevisionIncremented>False</IsRevisionIncremented>
<IsWebBootstrapper>True</IsWebBootstrapper>
<MapFileExtensions>True</MapFileExtensions>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<Platform>x64</Platform>
<ProductName>Remotely Desktop</ProductName>
<PublishDir>..\Server\wwwroot\Downloads\Win-x64\ClickOnce\</PublishDir>
<PublishUrl>..\Server\wwwroot\Downloads\Win-x64\ClickOnce\</PublishUrl>
<PublisherName>Translucency Software</PublisherName>
<PublishProtocol>ClickOnce</PublishProtocol>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishSingleFile>False</PublishSingleFile>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<SelfContained>False</SelfContained>
<SignatureAlgorithm>(none)</SignatureAlgorithm>
<SignManifests>False</SignManifests>
<SuiteName>Remotely</SuiteName>
<SupportUrl>https://remotely.one/Contact</SupportUrl>
<TargetFramework>net5.0-windows</TargetFramework>
<TrustUrlParameters>True</TrustUrlParameters>
<UpdateEnabled>True</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
</PropertyGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.NetCore.DesktopRuntime.5.0.x64">
<Install>true</Install>
<ProductName>.NET Desktop Runtime 5.0.1 (x64)</ProductName>
</BootstrapperPackage>
</ItemGroup>
</Project>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateDesktopShortcut>True</CreateDesktopShortcut>
<ErrorReportUrl>https://remotely.one/Contact</ErrorReportUrl>
<ExcludeDeploymentUrl>False</ExcludeDeploymentUrl>
<GenerateManifests>True</GenerateManifests>
<Install>true</Install>
<InstallFrom>Web</InstallFrom>
<InstallUrl>http://127.0.0.1:5000/Downloads/Win-x86/ClickOnce/</InstallUrl>
<IsRevisionIncremented>False</IsRevisionIncremented>
<IsWebBootstrapper>True</IsWebBootstrapper>
<MapFileExtensions>True</MapFileExtensions>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<Platform>x86</Platform>
<ProductName>Remotely Desktop</ProductName>
<PublishDir>..\Server\wwwroot\Downloads\Win-x86\ClickOnce\</PublishDir>
<PublishUrl>..\Server\wwwroot\Downloads\Win-x86\ClickOnce\</PublishUrl>
<PublisherName>Translucency Software</PublisherName>
<PublishProtocol>ClickOnce</PublishProtocol>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishSingleFile>False</PublishSingleFile>
<RuntimeIdentifier>win10-x86</RuntimeIdentifier>
<SelfContained>False</SelfContained>
<SignatureAlgorithm>(none)</SignatureAlgorithm>
<SignManifests>False</SignManifests>
<SuiteName>Remotely</SuiteName>
<SupportUrl>https://remotely.one/Contact</SupportUrl>
<TargetFramework>net5.0-windows</TargetFramework>
<TrustUrlParameters>True</TrustUrlParameters>
<UpdateEnabled>True</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
</PropertyGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.NetCore.DesktopRuntime.5.0.x86">
<Install>true</Install>
<ProductName>.NET Desktop Runtime 5.0.1 (x86)</ProductName>
</BootstrapperPackage>
</ItemGroup>
</Project>

View File

@ -13,7 +13,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>True</PublishTrimmed>
<PublishTrimmed>False</PublishTrimmed>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<TargetFramework>net5.0-windows</TargetFramework>
<PublishDir>bin\Release\win-x64\publish\</PublishDir>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>x86</Platform>
<TargetFramework>net5.0-windows</TargetFramework>
<PublishDir>bin\Release\win-x86\publish\</PublishDir>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win10-x86</RuntimeIdentifier>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,7 @@
{
"profiles": {
"Desktop.Win": {
"commandName": "Project"
}
}
}

View File

@ -0,0 +1,58 @@
using Remotely.Shared.Enums;
using Remotely.Shared.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace Remotely.Desktop.Win.Services
{
public interface IClickOnceService
{
string GetActivationUri();
}
public class ClickOnceService : IClickOnceService
{
private static string _activationUri;
public string GetActivationUri()
{
try
{
if (!string.IsNullOrWhiteSpace(_activationUri))
{
return _activationUri;
}
var appRoot = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent;
if (!Directory.Exists(Path.Combine(appRoot.FullName, "manifests")))
{
Logger.Write($"Manifests folder not found in root folder: {appRoot}", EventType.Warning);
return _activationUri;
}
var manifestFiles = appRoot.GetFiles("manifests\\*tion_*.manifest", SearchOption.AllDirectories);
var manifestFile = manifestFiles.FirstOrDefault();
if (manifestFile is null)
{
Logger.Write($"Manifest file not found.", EventType.Warning);
return _activationUri;
}
var manifest = new XmlDocument();
manifest.Load(manifestFile.FullName);
var node = manifest.GetElementsByTagName("deploymentProvider")[0];
_activationUri = node.Attributes["codebase"].Value;
Logger.Write($"Found ActivationUri: {_activationUri}");
}
catch (Exception ex)
{
Logger.Write(ex);
}
return _activationUri;
}
}
}

View File

@ -2,27 +2,31 @@
using Remotely.Desktop.Core;
using Remotely.Desktop.Core.Interfaces;
using Remotely.Desktop.Core.Services;
using Remotely.Desktop.Core.Utilities;
using Remotely.Shared.Utilities;
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
namespace Remotely.Desktop.Win.Services
{
public class SessionIndicatorWin : ISessionIndicator
{
private readonly Form _backgroundForm;
private readonly IDeviceInitService _deviceInitService;
private Container _container;
private ContextMenuStrip _contextMenuStrip;
private NotifyIcon _notifyIcon;
public SessionIndicatorWin(Form backgroundForm)
public SessionIndicatorWin(Form backgroundForm, IDeviceInitService deviceInitService)
{
BackgroundForm = backgroundForm;
_backgroundForm = backgroundForm;
_deviceInitService = deviceInitService;
}
private Form BackgroundForm { get; }
public void Show()
{
try
@ -37,15 +41,28 @@ namespace Remotely.Desktop.Win.Services
App.Current.Exit += App_Exit;
});
BackgroundForm.Invoke(new Action(() =>
_backgroundForm.Invoke(new Action(() =>
{
_container = new Container();
_contextMenuStrip = new ContextMenuStrip(_container);
_contextMenuStrip.Items.Add("Exit", null, ExitMenuItem_Click);
Icon icon;
if (_deviceInitService.BrandingInfo.Icon?.Any() == true)
{
using var ms = new MemoryStream(_deviceInitService.BrandingInfo.Icon);
using var bitmap = new Bitmap(ms);
icon = Icon.FromHandle(bitmap.GetHicon());
}
else
{
icon = Icon.ExtractAssociatedIcon(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, EnvironmentHelper.DesktopExecutableFileName));
}
_notifyIcon = new NotifyIcon(_container)
{
Icon = Icon.ExtractAssociatedIcon(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, EnvironmentHelper.DesktopExecutableFileName)),
Icon = icon,
Text = "Remote Control Session",
BalloonTipIcon = ToolTipIcon.Info,
BalloonTipText = "A remote control session has started.",

View File

@ -0,0 +1,85 @@
using Microsoft.Extensions.DependencyInjection;
using Remotely.Desktop.Core;
using Remotely.Desktop.Core.Services;
using Remotely.Desktop.Core.ViewModels;
using Remotely.Shared.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace Remotely.Desktop.Win.ViewModels
{
public class BrandedViewModelBase : ViewModelBase
{
public BrandedViewModelBase()
{
var deviceInit = ServiceContainer.Instance?.GetRequiredService<IDeviceInitService>();
var brandingInfo = deviceInit?.BrandingInfo ?? new BrandingInfo();
ProductName = "Remotely";
if (!string.IsNullOrWhiteSpace(brandingInfo?.Product))
{
ProductName = brandingInfo.Product;
}
TitleBackgroundColor = new SolidColorBrush(Color.FromRgb(
brandingInfo?.TitleBackgroundRed ?? 70,
brandingInfo?.TitleBackgroundGreen ?? 70,
brandingInfo?.TitleBackgroundBlue ?? 70));
TitleForegroundColor = new SolidColorBrush(Color.FromRgb(
brandingInfo?.TitleForegroundRed ?? 29,
brandingInfo?.TitleForegroundGreen ?? 144,
brandingInfo?.TitleForegroundBlue ?? 241));
TitleButtonForegroundColor = new SolidColorBrush(Color.FromRgb(
brandingInfo?.ButtonForegroundRed ?? 255,
brandingInfo?.ButtonForegroundGreen ?? 255,
brandingInfo?.ButtonForegroundBlue ?? 255));
Icon = GetBitmapImageIcon(brandingInfo);
}
public BitmapImage Icon { get; set; }
public string ProductName { get; set; }
public SolidColorBrush TitleBackgroundColor { get; set; }
public SolidColorBrush TitleButtonForegroundColor { get; set; }
public SolidColorBrush TitleForegroundColor { get; set; }
private BitmapImage GetBitmapImageIcon(BrandingInfo bi)
{
Stream imageStream;
if (bi.Icon?.Any() == true)
{
imageStream = new MemoryStream(bi.Icon);
}
else
{
imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Remotely.Desktop.Win.Assets.Remotely_Icon.png");
}
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = imageStream;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
bitmap.Freeze();
imageStream.Close();
return bitmap;
}
}
}

View File

@ -1,5 +1,4 @@
using Remotely.Desktop.Core.ViewModels;
using Remotely.Shared.Models;
using Remotely.Shared.Models;
using System.Collections.ObjectModel;
using System.IO;
using System.Text.Json;
@ -7,23 +6,24 @@ using System.Threading.Tasks;
namespace Remotely.Desktop.Win.ViewModels
{
public class ChatWindowViewModel : ViewModelBase
public class ChatWindowViewModel : BrandedViewModelBase
{
private string inputText;
private string organizationName = "your IT provider";
private string senderName = "a technician";
private string _inputText;
private string _organizationName = "your IT provider";
private string _senderName = "a technician";
public ObservableCollection<ChatMessage> ChatMessages { get; } = new ObservableCollection<ChatMessage>();
public string InputText
{
get
{
return inputText;
return _inputText;
}
set
{
inputText = value;
FirePropertyChanged(nameof(InputText));
_inputText = value;
FirePropertyChanged();
}
}
@ -31,19 +31,19 @@ namespace Remotely.Desktop.Win.ViewModels
{
get
{
return organizationName;
return _organizationName;
}
set
{
if (string.IsNullOrWhiteSpace(value) ||
value == organizationName)
value == _organizationName)
{
return;
}
organizationName = value;
FirePropertyChanged(nameof(OrganizationName));
_organizationName = value;
FirePropertyChanged();
}
}
@ -52,17 +52,17 @@ namespace Remotely.Desktop.Win.ViewModels
{
get
{
return senderName;
return _senderName;
}
set
{
if (value == senderName)
if (value == _senderName)
{
return;
}
senderName = value;
FirePropertyChanged(nameof(SenderName));
_senderName = value;
FirePropertyChanged();
}
}

View File

@ -13,7 +13,7 @@ using System.Windows.Input;
namespace Remotely.Desktop.Win.ViewModels
{
public class FileTransferWindowViewModel : ViewModelBase
public class FileTransferWindowViewModel : BrandedViewModelBase
{
private readonly IFileTransferService _fileTransferService;
private readonly Viewer _viewer;
@ -82,7 +82,7 @@ namespace Remotely.Desktop.Win.ViewModels
set
{
_viewerConnectionId = value;
FirePropertyChanged(nameof(ViewerConnectionId));
FirePropertyChanged();
}
}
@ -95,7 +95,7 @@ namespace Remotely.Desktop.Win.ViewModels
set
{
_viewerName = value;
FirePropertyChanged(nameof(ViewerName));
FirePropertyChanged();
}
}

View File

@ -2,17 +2,17 @@
namespace Remotely.Desktop.Win.ViewModels
{
public class HostNamePromptViewModel : ViewModelBase
public class HostNamePromptViewModel : BrandedViewModelBase
{
private string host;
private string _host = "https://";
public string Host
{
get => host;
get => _host;
set
{
host = value;
FirePropertyChanged("Host");
_host = value;
FirePropertyChanged();
}
}
}

View File

@ -2,9 +2,8 @@
using Remotely.Desktop.Core;
using Remotely.Desktop.Core.Interfaces;
using Remotely.Desktop.Core.Services;
using Remotely.Desktop.Core.ViewModels;
using Remotely.Desktop.Win.Controls;
using Remotely.Desktop.Win.Services;
using Remotely.Desktop.Win.Views;
using Remotely.Shared.Models;
using Remotely.Shared.Utilities;
using Remotely.Shared.Win32;
@ -20,8 +19,13 @@ using System.Windows.Input;
namespace Remotely.Desktop.Win.ViewModels
{
public class MainWindowViewModel : ViewModelBase
public class MainWindowViewModel : BrandedViewModelBase
{
private readonly ICasterSocket _casterSocket;
private readonly Conductor _conductor;
private readonly IConfigService _configService;
private readonly ICursorIconWatcher _cursorIconWatcher;
private readonly IDeviceInitService _deviceInitService;
private string _host;
private string _sessionID;
@ -36,20 +40,23 @@ namespace Remotely.Desktop.Win.ViewModels
Application.Current.Exit += Application_Exit;
ConfigService = Services?.GetRequiredService<IConfigService>();
CursorIconWatcher = Services?.GetRequiredService<ICursorIconWatcher>();
CursorIconWatcher.OnChange += CursorIconWatcher_OnChange;
_configService = Services?.GetRequiredService<IConfigService>();
_cursorIconWatcher = Services?.GetRequiredService<ICursorIconWatcher>();
_cursorIconWatcher.OnChange += CursorIconWatcher_OnChange;
_conductor = Services.GetRequiredService<Conductor>();
_casterSocket = Services.GetRequiredService<ICasterSocket>();
_deviceInitService = Services.GetRequiredService<IDeviceInitService>();
Services.GetRequiredService<IClipboardService>().BeginWatching();
Services.GetRequiredService<IKeyboardMouseInput>().Init();
Conductor = Services.GetRequiredService<Conductor>();
CasterSocket = Services.GetRequiredService<ICasterSocket>();
Conductor.SessionIDChanged += SessionIDChanged;
Conductor.ViewerRemoved += ViewerRemoved;
Conductor.ViewerAdded += ViewerAdded;
Conductor.ScreenCastRequested += ScreenCastRequested;
_conductor.SessionIDChanged += SessionIDChanged;
_conductor.ViewerRemoved += ViewerRemoved;
_conductor.ViewerAdded += ViewerAdded;
_conductor.ScreenCastRequested += ScreenCastRequested;
}
public static MainWindowViewModel Current { get; private set; }
public static IServiceProvider Services => ServiceContainer.Instance;
public ICommand ChangeServerCommand
@ -136,7 +143,7 @@ namespace Remotely.Desktop.Win.ViewModels
set
{
_host = value;
FirePropertyChanged(nameof(Host));
FirePropertyChanged();
}
}
@ -151,7 +158,7 @@ namespace Remotely.Desktop.Win.ViewModels
foreach (Viewer viewer in (param as IList<object>).ToArray())
{
ViewerRemoved(this, viewer.ViewerConnectionID);
await CasterSocket.DisconnectViewer(viewer, true);
await _casterSocket.DisconnectViewer(viewer, true);
}
},
(param) =>
@ -168,18 +175,12 @@ namespace Remotely.Desktop.Win.ViewModels
set
{
_sessionID = value;
FirePropertyChanged(nameof(SessionID));
FirePropertyChanged();
}
}
public ObservableCollection<Viewer> Viewers { get; } = new ObservableCollection<Viewer>();
private ICasterSocket CasterSocket { get; set; }
private Conductor Conductor { get; set; }
private IConfigService ConfigService { get; }
private ICursorIconWatcher CursorIconWatcher { get; set; }
public void CopyLink()
{
Clipboard.SetText($"{Host}/RemoteControl?sessionID={SessionID?.Replace(" ", "")}");
@ -187,15 +188,15 @@ namespace Remotely.Desktop.Win.ViewModels
public async Task GetSessionID()
{
await CasterSocket.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName, Conductor.DeviceID);
await CasterSocket.GetSessionID();
await _casterSocket.SendDeviceInfo(_conductor.ServiceID, Environment.MachineName, _conductor.DeviceID);
await _casterSocket.GetSessionID();
}
public async Task Init()
{
SessionID = "Retrieving...";
Host = ConfigService.GetConfig().Host;
Host = _configService.GetConfig().Host;
while (string.IsNullOrWhiteSpace(Host))
{
@ -203,12 +204,18 @@ namespace Remotely.Desktop.Win.ViewModels
PromptForHostName();
}
Conductor.ProcessArgs(new string[] { "-mode", "Normal", "-host", Host });
_conductor.ProcessArgs(new string[] { "-mode", "Normal", "-host", Host });
try
{
await CasterSocket.Connect(Conductor.Host);
await _casterSocket.Connect(_conductor.Host);
CasterSocket.Connection.Closed += async (ex) =>
if (_casterSocket.Connection is null)
{
return;
}
_casterSocket.Connection.Closed += async (ex) =>
{
await App.Current?.Dispatcher?.InvokeAsync(() =>
{
@ -217,7 +224,7 @@ namespace Remotely.Desktop.Win.ViewModels
});
};
CasterSocket.Connection.Reconnecting += async (ex) =>
_casterSocket.Connection.Reconnecting += async (ex) =>
{
await App.Current?.Dispatcher?.InvokeAsync(() =>
{
@ -226,7 +233,7 @@ namespace Remotely.Desktop.Win.ViewModels
});
};
CasterSocket.Connection.Reconnected += async (arg) =>
_casterSocket.Connection.Reconnected += async (arg) =>
{
await GetSessionID();
};
@ -249,9 +256,10 @@ namespace Remotely.Desktop.Win.ViewModels
{
prompt.ViewModel.Host = Host;
}
prompt.Owner = App.Current?.MainWindow;
prompt.ShowDialog();
var result = prompt.ViewModel.Host?.TrimEnd('/');
var result = prompt.ViewModel.Host?.Trim();
if (!result.StartsWith("https://") && !result.StartsWith("http://"))
{
result = $"https://{result}";
@ -259,9 +267,9 @@ namespace Remotely.Desktop.Win.ViewModels
if (result != Host)
{
Host = result;
var config = ConfigService.GetConfig();
var config = _configService.GetConfig();
config.Host = Host;
ConfigService.Save(config);
_configService.Save(config);
}
}
@ -269,6 +277,7 @@ namespace Remotely.Desktop.Win.ViewModels
{
Services.GetRequiredService<IShutdownService>().Shutdown();
}
private void Application_Exit(object sender, ExitEventArgs e)
{
App.Current.Dispatcher.Invoke(() =>
@ -279,9 +288,9 @@ namespace Remotely.Desktop.Win.ViewModels
private async void CursorIconWatcher_OnChange(object sender, CursorInfo cursor)
{
if (Conductor?.Viewers?.Count > 0)
if (_conductor?.Viewers?.Count > 0)
{
foreach (var viewer in Conductor.Viewers.Values)
foreach (var viewer in _conductor.Viewers.Values)
{
await viewer.SendCursorChange(cursor);
}
@ -306,7 +315,7 @@ namespace Remotely.Desktop.Win.ViewModels
// Run on another thread so it doesn't tie up the UI thread.
Task.Run(async () =>
{
await CasterSocket.SendConnectionRequestDenied(screenCastRequest.ViewerID);
await _casterSocket.SendConnectionRequestDenied(screenCastRequest.ViewerID);
});
}
});

View File

@ -8,7 +8,7 @@ using System.Windows.Input;
namespace Remotely.Desktop.Win.ViewModels
{
public class PromptForAccessWindowViewModel : ViewModelBase
public class PromptForAccessWindowViewModel : BrandedViewModelBase
{
private string _organizationName = "your IT provider";
private string _requesterName = "a technician";
@ -18,7 +18,7 @@ namespace Remotely.Desktop.Win.ViewModels
set
{
_organizationName = value;
FirePropertyChanged(nameof(OrganizationName));
FirePropertyChanged();
}
}
@ -30,7 +30,7 @@ namespace Remotely.Desktop.Win.ViewModels
set
{
_requesterName = value;
FirePropertyChanged(nameof(RequesterName));
FirePropertyChanged();
}
}

View File

@ -17,7 +17,8 @@
MinHeight="250"
MinWidth="200"
Topmost="True"
Title="Remotely Chat" Height="450" Width="350" Icon="/Assets/favicon.ico"
Title="Chat Session" Height="450" Width="450"
Icon="{Binding Icon}"
Loaded="Window_Loaded"
ContentRendered="Window_ContentRendered">
@ -31,19 +32,23 @@
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Border Height="50" Background="#FF464646">
<DockPanel Margin="10,0,0,0">
<DockPanel>
<Image Height="50" Width="50" Source="/Assets/Remotely_Icon.png" Margin="0,0,10,0"></Image>
<TextBlock Foreground="#FF1D90F1" FontWeight="Bold" FontSize="20" VerticalAlignment="Center">
Remotely Chat
</TextBlock>
</DockPanel>
<Button Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" />
<Button Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="_"/>
</DockPanel>
<Border Height="50" Background="{Binding TitleBackgroundColor}">
<Grid Margin="10,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Height="50" Width="50" Margin="0,0,10,0" Source="{Binding Icon}"></Image>
<TextBlock Grid.Column="1" Foreground="{Binding TitleForegroundColor}" FontWeight="Bold" FontSize="20" VerticalAlignment="Center">
<Run Text="{Binding ProductName}"></Run>
<Run Text="Chat"></Run>
</TextBlock>
<Button Grid.Column="2" Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="____" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}"/>
<Button Grid.Column="3" Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" />
</Grid>
</Border>
<TextBlock Grid.Row="1" FontWeight="Bold" Foreground="DimGray" Margin="10,10,10,0" TextWrapping="Wrap">

View File

@ -6,11 +6,11 @@
xmlns:local="clr-namespace:Remotely.Desktop.Win.Views"
xmlns:vm="clr-namespace:Remotely.Desktop.Win.ViewModels"
mc:Ignorable="d"
Title="Remotely File Transfer"
Title="File Transfer"
Height="300" Width="400"
Topmost="True"
ContentRendered="Window_ContentRendered"
Icon="/Assets/favicon.ico">
Icon="{Binding Icon}">
<Window.DataContext>
<vm:FileTransferWindowViewModel />

View File

@ -1,13 +1,14 @@
<Window
x:Class="Remotely.Desktop.Win.Controls.HostNamePrompt"
x:Class="Remotely.Desktop.Win.Views.HostNamePrompt"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Remotely.Desktop.Win.Controls"
xmlns:local="clr-namespace:Remotely.Desktop.Win.Views"
xmlns:ViewModels="clr-namespace:Remotely.Desktop.Win.ViewModels" x:Name="PromptWindow"
mc:Ignorable="d"
Title="Remotely Host Name" Height="150" Width="350" WindowStartupLocation="CenterOwner" Icon="/Assets/Remotely_Icon.png">
Title="Host Name" Height="150" Width="350" WindowStartupLocation="CenterOwner"
Icon="{Binding Icon}">
<Window.DataContext>
<ViewModels:HostNamePromptViewModel/>
</Window.DataContext>

View File

@ -1,7 +1,7 @@
using Remotely.Desktop.Win.ViewModels;
using System.Windows;
namespace Remotely.Desktop.Win.Controls
namespace Remotely.Desktop.Win.Views
{
/// <summary>
/// Interaction logic for HostNamePrompt.xaml

View File

@ -6,12 +6,13 @@
xmlns:local="clr-namespace:Remotely.Desktop.Win.Views"
xmlns:ViewModels="clr-namespace:Remotely.Desktop.Win.ViewModels"
mc:Ignorable="d"
Title="Remotely" Height="250" Width="350"
Title="{Binding ProductName}" Height="250" Width="350"
WindowStyle="None"
ResizeMode="NoResize"
MouseLeftButtonDown="Window_MouseLeftButtonDown"
Closing="Window_Closing"
Loaded="Window_Loaded" Icon="/Assets/Remotely_Icon.png">
Loaded="Window_Loaded"
Icon="{Binding Icon}">
<Window.Resources>
<DrawingBrush x:Key="GearBrush">
<DrawingBrush.Drawing>
@ -32,15 +33,19 @@
<Grid>
<StackPanel>
<Border Height="50" Background="#FF464646">
<DockPanel Margin="10,0,0,0">
<StackPanel>
<TextBlock Foreground="DeepSkyBlue" FontWeight="Bold" FontSize="20" Margin="0,2,0,0">Remotely</TextBlock>
<TextBlock Foreground="White" FontSize="10"><Run Text="Do IT Remotely"/></TextBlock>
</StackPanel>
<Button Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" />
<Button Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="_"/>
</DockPanel>
<Border Height="50" Background="{Binding TitleBackgroundColor}">
<Grid Margin="10,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Height="50" Width="50" Margin="0,0,10,0" Source="{Binding Icon}"></Image>
<TextBlock Grid.Column="1" Text="{Binding ProductName}" Foreground="{Binding TitleForegroundColor}" FontWeight="Bold" FontSize="20" VerticalAlignment="Center" />
<Button Grid.Column="2" Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="____" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}"/>
<Button Grid.Column="3" Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" />
</Grid>
</Border>
<Grid Margin="10,15,10,0">
<Grid.ColumnDefinitions>

View File

@ -19,7 +19,7 @@
MinWidth="250"
Height="275"
Width="450"
Icon="/Assets/favicon.ico"
Icon="{Binding Icon}"
ContentRendered="Window_ContentRendered">
<Window.DataContext>
@ -33,18 +33,19 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Height="50" Background="#FF464646">
<DockPanel Margin="10,0,0,0">
<DockPanel>
<Image Height="50" Width="50" Source="/Assets/Remotely_Icon.png" Margin="0,0,10,0"></Image>
<TextBlock Foreground="#FF1D90F1" FontWeight="Bold" FontSize="20" VerticalAlignment="Center">
Remote Control Request
</TextBlock>
</DockPanel>
<Button Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" />
<Button Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="_"/>
</DockPanel>
<Border Height="50" Background="{Binding TitleBackgroundColor}">
<Grid Margin="10,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Height="50" Width="50" Margin="0,0,10,0" Source="{Binding Icon}"></Image>
<TextBlock Grid.Column="1" Text="Remote Control Request" Foreground="{Binding TitleForegroundColor}" FontWeight="Bold" FontSize="20" VerticalAlignment="Center" />
<Button Grid.Column="2" Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="____" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}"/>
<Button Grid.Column="3" Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" />
</Grid>
</Border>
<StackPanel Grid.Row="1">

View File

@ -16,7 +16,7 @@
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
@ -28,7 +28,7 @@
and Windows will automatically select the most compatible environment. -->
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!-- <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" /> -->
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />

View File

@ -9,11 +9,12 @@ If this project has benefited you in some way, or if you just want to show appre
Suggested Charities: https://www.givewell.org/charities/top-charities
If you want to send a few dollars my way as well, you can with the below links. But if you have to choose between one or the other, please pick the charity. Your money will have a much greater impact on their lives than mine.
You can also sponsor the project to unlock additional features on your self-hosted server.
[![GitHub Sponsors](https://img.shields.io/badge/GitHub%20Sponsors-Sponsor-brightgreen)](https://github.com/sponsors/lucent-sea)
[![PayPal Link](https://img.shields.io/badge/PayPal-Donate-brightgreen)](https://www.paypal.me/translucency)
[![GitHub Sponsors](https://img.shields.io/badge/GitHub%20Sponsors-Sponsor-brightgreen)](https://github.com/sponsors/lucent-sea)
## Project Links
@ -26,6 +27,45 @@ Hosting a Remotely server requires building and running an ASP.NET Core web app
It's *highly* encouraged that you get comfortable building and deploying from source. This allows you to hard-code your server's hostname into the desktop client and the installer, which makes for a better experience for the end user. If you don't want to use any of the methods below, you can look at the GitHub Actions workflows to see how the process can be automated, using the `Publish.ps1` script. You can use those as reference for creating an automation process that works for you. You can also use Azure Pipelines for free (which I personally use).
## Hosting a Server (Windows)
* Create a site in IIS that will run Remotely.
* Run Install-RemotelyServer.ps1 (as an administrator), which is on the [Releases page](https://github.com/lucent-sea/Remotely/releases/latest) and in the [Utilities folder in source control](https://raw.githubusercontent.com/lucent-sea/Remotely/master/Utilities/Install-RemotelyServer.ps1).
* Alternatively, you can build from source and copy the server files to the site folder.
* Download and install the .NET Core Runtime (not the SDK) with the Hosting Bundle.
* Link: https://dotnet.microsoft.com/download/dotnet-core/current/runtime
* This includes the Hosting Bundle for Windows, which allows you to run ASP.NET Core in IIS.
* Important: If you installed .NET Core Runtime before installing all the required IIS features, you may need to run a repair on the .NET Core Runtime installation.
* Change values in appsettings.json for your environment. Make a copy named `appsettings.Production.json` (see Configuration section below).
* By default, SQLite is used for the database.
* The "Remotely.db" database file is automatically created in the root folder of your site.
* You can browse and modify the contents using [DB Browser for SQLite](https://sqlitebrowser.org/).
* If the site will be public-facing, configure your bindings in IIS.
* An SSL certificate for HTTPS is recommended. You can install one for free using Let's Encrypt.
* Resources: https://letsencrypt.org/, https://certifytheweb.com/
* Documentation for hosting in IIS can be found here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis
* There is no default account. You must create the first one via the Register page, which will create an account that is both a server and organization admin.
## Hosting a Server (Ubuntu)
* Ubuntu 20.04, 19.04, and 18.04 have been tested.
* Run Ubuntu_Server_Install.sh (with sudo), which is on the [Releases page](https://github.com/lucent-sea/Remotely/releases/latest) and in the [Utilities folder in source control](https://raw.githubusercontent.com/lucent-sea/Remotely/master/Utilities/Remotely_Server_Install.sh).
* The script is designed to install Remotely and Nginx on the same server, running Ubuntu 18.04 or 19.04. You'll need to manually set up other configurations.
* A helpful user supplied an example Apache configuration, which can be found in the Utilities folder.
* The script will prompt for the "App root" location, which is the above directory where the server files are located.
* The script installs the .NET Core runtime, as well as other dependencies.
* Certbot is used in this script and will install an SSL certificate for your site. Your server needs to have a public domain name that is accessible from the internet for this to work.
* More information: https://letsencrypt.org/, https://certbot.eff.org/
* Alternatively, you can build from source (using RuntimeIdentifier "linux-x64" for the server) and copy the server files to the site folder.
* Change values in appsettings.json for your environment. Make a copy named `appsettings.Production.json` (see Configuration section below).
* Documentation for hosting behind Nginx can be found here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx
* There is no default account. You must create the first one via the Register page, which will create an account that is both a server and organization admin.
## Hosting Scenarios
There are countless ways to host an ASP.NET Core app, and I can't document or automate all of them. For hosting scenarios aside from the above two, please refer to Microsoft's documentation.
- https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/
## Build Instructions (GitHub)
GitHub Actions allows you to build and deploy Remotely for free from their cloud servers. The definitions for the build processes are located in `/.github/workflows/` folder.
@ -55,44 +95,6 @@ The following steps will configure your Windows 10 machine for building the Remo
* In development environment, the server will assign all connecting agents to the first organization.
* The above two allow you to debug the agent and server together, and see your device in the list.
## Hosting a Server (Windows)
* Build the Remotely server and clients using the above steps.
* Create a site in IIS that will run Remotely.
* Run Install-RemotelyServer.ps1 (as an administrator), which is in the [Utilities folder in source control](https://raw.githubusercontent.com/lucent-sea/Remotely/master/Utilities/Install-RemotelyServer.ps1) and on the Releases page.
* Alternatively, you can build from source and copy the server files to the site folder.
* Download and install the .NET Core Runtime (not the SDK) with the Hosting Bundle.
* Link: https://dotnet.microsoft.com/download/dotnet-core/current/runtime
* This includes the Hosting Bundle for Windows, which allows you to run ASP.NET Core in IIS.
* Important: If you installed .NET Core Runtime before installing all the required IIS features, you may need to run a repair on the .NET Core Runtime installation.
* Change values in appsettings.json for your environment. Make a copy named `appsettings.Production.json` (see Configuration section below).
* By default, SQLite is used for the database.
* The "Remotely.db" database file is automatically created in the root folder of your site.
* You can browse and modify the contents using [DB Browser for SQLite](https://sqlitebrowser.org/).
* If the site will be public-facing, configure your bindings in IIS.
* An SSL certificate for HTTPS is recommended. You can install one for free using Let's Encrypt.
* Resources: https://letsencrypt.org/, https://certifytheweb.com/
* Documentation for hosting in IIS can be found here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis
* There is no default account. You must create the first one via the Register page, which will create an account that is both a server and organization admin.
## Hosting a Server (Ubuntu)
* Ubuntu 18.04 and 19.04 have been tested.
* Run Ubuntu_Server_Install.sh (with sudo), which is in the [Utilities folder in source control](https://raw.githubusercontent.com/lucent-sea/Remotely/master/Utilities/Remotely_Server_Install.sh).
* The script is designed to install Remotely and Nginx on the same server, running Ubuntu 18.04 or 19.04. You'll need to manually set up other configurations.
* A helpful user supplied an example Apache configuration, which can be found in the Utilities folder.
* The script will prompt for the "App root" location, which is the above directory where the server files are located.
* The script installs the .NET Core runtime, as well as other dependencies.
* Certbot is used in this script and will install an SSL certificate for your site. Your server needs to have a public domain name that is accessible from the internet for this to work.
* More information: https://letsencrypt.org/, https://certbot.eff.org/
* Alternatively, you can build from source (using RuntimeIdentifier "linux-x64" for the server) and copy the server files to the site folder.
* Change values in appsettings.json for your environment. Make a copy named `appsettings.Production.json` (see Configuration section below).
* Documentation for hosting behind Nginx can be found here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx
* There is no default account. You must create the first one via the Register page, which will create an account that is both a server and organization admin.
## Hosting Scenarios
There are countless ways to host an ASP.NET Core app, and I can't document or automate all of them. For hosting scenarios aside from the above two, please refer to Microsoft's documentation.
- https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/
## Admin Accounts
The first account created will be an admin for both the server and the organization that's created for the account.

View File

@ -39,8 +39,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agent.Installer.Win", "Agen
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{48D9D0E6-5781-44A9-84C0-56F56C2A1193}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop.Win.Wrapper", "Desktop.Win.Wrapper\Desktop.Win.Wrapper.csproj", "{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.LoadTester", "Tests.LoadTester\Tests.LoadTester.csproj", "{6C25240C-613D-4A86-A04E-784BA6726094}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2176596E-12DA-4766-96E1-4D23EA7DBEC8}"
@ -156,18 +154,6 @@ Global
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Release|x64.Build.0 = Release|x64
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Release|x86.ActiveCfg = Release|x86
{48D9D0E6-5781-44A9-84C0-56F56C2A1193}.Release|x86.Build.0 = Release|x86
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Debug|x64.ActiveCfg = Debug|Any CPU
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Debug|x64.Build.0 = Debug|Any CPU
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Debug|x86.ActiveCfg = Debug|Any CPU
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Debug|x86.Build.0 = Debug|Any CPU
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Release|Any CPU.Build.0 = Release|Any CPU
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Release|x64.ActiveCfg = Release|x64
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Release|x64.Build.0 = Release|x64
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Release|x86.ActiveCfg = Release|x86
{A9967E61-B1BE-4AA5-A33A-99B0B8B5FC2A}.Release|x86.Build.0 = Release|x86
{6C25240C-613D-4A86-A04E-784BA6726094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C25240C-613D-4A86-A04E-784BA6726094}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C25240C-613D-4A86-A04E-784BA6726094}.Debug|x64.ActiveCfg = Debug|Any CPU

View File

@ -0,0 +1,49 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Remotely.Server.Services;
using Remotely.Shared.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Remotely.Server.API
{
[Route("api/[controller]")]
[ApiController]
public class BrandingController : ControllerBase
{
private readonly IDataService _dataService;
public BrandingController(IDataService dataService)
{
_dataService = dataService;
}
[HttpGet("{organizationId}")]
public async Task<BrandingInfo> Get(string organizationId)
{
var org = _dataService.GetOrganizationById(organizationId);
// Warning: Your GitHub account and server will be permanently banned for abusing this.
if (org.SponsorLevel < Shared.Enums.SponsorLevel.Branding)
{
return null;
}
return await _dataService.GetBrandingInfo(organizationId);
}
[HttpGet]
public async Task<BrandingInfo> GetDefault()
{
var defaultOrg = await _dataService.GetDefaultOrganization();
if (defaultOrg?.SponsorLevel >= Shared.Enums.SponsorLevel.Branding)
{
return await _dataService.GetBrandingInfo(defaultOrg.ID);
}
return null;
}
}
}

View File

@ -3,10 +3,17 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Remotely.Server.Attributes;
using Remotely.Server.Services;
using Remotely.Shared.Utilities;
using Remotely.Shared.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
@ -16,63 +23,175 @@ namespace Remotely.Server.API
[ApiController]
public class ClientDownloadsController : ControllerBase
{
public ClientDownloadsController(IWebHostEnvironment hostEnv,
IApplicationConfig appConfig)
private readonly IApplicationConfig _appConfig;
private readonly IDataService _dataService;
private readonly IHttpClientFactory _httpClientFactory;
private readonly SemaphoreSlim _fileLock = new SemaphoreSlim(1);
private readonly IWebHostEnvironment _hostEnv;
public ClientDownloadsController(
IWebHostEnvironment hostEnv,
IDataService dataService,
IApplicationConfig appConfig,
IHttpClientFactory httpClientFactory)
{
HostEnv = hostEnv;
AppConfig = appConfig;
_hostEnv = hostEnv;
_appConfig = appConfig;
_dataService = dataService;
_httpClientFactory = httpClientFactory;
}
[HttpGet("desktop/{platformID}")]
public async Task<IActionResult> GetDesktop(string platformID)
{
return await GetInstallFile(null, platformID);
}
[HttpGet("clickonce-setup/{architecture}/{organizationId}")]
public async Task<IActionResult> GetClickOnceSetup(string architecture, string organizationId)
{
string setupFilePath;
switch (architecture?.ToLower())
{
case "x64":
setupFilePath = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Win-x64", "ClickOnce", "setup.exe");
break;
case "x86":
setupFilePath = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Win-x86", "ClickOnce", "setup.exe");
break;
default:
return BadRequest();
}
using var client = _httpClientFactory.CreateClient();
var formContent = new MultipartFormDataContent();
var bytes = await System.IO.File.ReadAllBytesAsync(setupFilePath);
using var byteContent = new ByteArrayContent(bytes);
formContent.Add(byteContent, "setup", "setup.exe");
using var response = await client.PostAsync($"{AppConstants.ClickOnceSetupUrl}/?host={Request.Scheme}://{Request.Host}&organizationid={organizationId}&architecture={architecture}", formContent);
var responseBytes = await response.Content.ReadAsByteArrayAsync();
return File(responseBytes, "application/octet-stream", "setup.exe");
}
private IApplicationConfig AppConfig { get; }
private SemaphoreSlim FileLock { get; } = new SemaphoreSlim(1);
private IWebHostEnvironment HostEnv { get; set; }
[ServiceFilter(typeof(ApiAuthorizationFilter))]
[HttpGet("{platformID}")]
public async Task<ActionResult> Get(string platformID)
public async Task<IActionResult> GetInstaller(string platformID)
{
Request.Headers.TryGetValue("OrganizationID", out var orgID);
return await GetInstallFile(orgID, platformID);
}
[HttpGet("{organizationID}/{platformID}")]
public async Task<ActionResult> Get(string organizationID, string platformID)
public async Task<IActionResult> GetInstaller(string organizationID, string platformID)
{
return await GetInstallFile(organizationID, platformID);
}
private async Task<ActionResult> GetInstallFile(string organizationID, string platformID)
private async Task<IActionResult> GetBashInstaller(string fileName, string organizationId)
{
var scheme = _appConfig.RedirectToHttps ? "https" : Request.Scheme;
var fileContents = new List<string>();
fileContents.AddRange(await System.IO.File.ReadAllLinesAsync(Path.Combine(_hostEnv.WebRootPath, "Downloads", fileName)));
var hostIndex = fileContents.IndexOf("HostName=");
var orgIndex = fileContents.IndexOf("Organization=");
fileContents[hostIndex] = $"HostName=\"{scheme}://{Request.Host}\"";
fileContents[orgIndex] = $"Organization=\"{organizationId}\"";
var fileBytes = Encoding.UTF8.GetBytes(string.Join("\n", fileContents));
return File(fileBytes, "application/octet-stream", fileName);
}
private async Task<IActionResult> GetDesktopFile(string filePath)
{
var relayCode = string.Empty;
if (User.Identity.IsAuthenticated)
{
var currentOrg = await _dataService.GetOrganizationByUserName(User.Identity.Name);
if (currentOrg.SponsorLevel >= Shared.Enums.SponsorLevel.Relay)
{
relayCode = currentOrg.RelayCode;
}
}
else
{
relayCode = await _dataService.GetDefaultRelayCode();
}
var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
if (!string.IsNullOrWhiteSpace(relayCode))
{
var downloadFileName = fileNameWithoutExtension + $"-[{relayCode}]" + Path.GetExtension(filePath);
return File(fs, "application/octet-stream", downloadFileName);
}
else
{
return File(fs, "application/octet-stream", fileNameWithoutExtension);
}
}
private async Task<IActionResult> GetInstallFile(string organizationId, string platformID)
{
try
{
if (await FileLock.WaitAsync(TimeSpan.FromSeconds(15)))
if (await _fileLock.WaitAsync(TimeSpan.FromSeconds(15)))
{
var scheme = AppConfig.RedirectToHttps ? "https" : Request.Scheme;
switch (platformID)
{
case "Windows":
case "WindowsDesktop-x64":
{
var filePath = Path.Combine(HostEnv.WebRootPath, "Downloads", $"Remotely_Installer.exe");
var fileName = $"Remotely_Installer-{organizationID}.exe";
var fileStream = System.IO.File.OpenRead(filePath);
return File(fileStream, "application/octet-stream", $"{fileName}");
var filePath = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Win-x64", "Remotely_Desktop.exe");
return await GetDesktopFile(filePath);
}
case "Manjaro-x64":
case "Ubuntu-x64":
case "WindowsDesktop-x86":
{
var fileContents = new List<string>();
var fileName = $"Install-{platformID}.sh";
var filePath = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Win-x86", "Remotely_Desktop.exe");
return await GetDesktopFile(filePath);
}
case "UbuntuDesktop":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Remotely_Desktop");
return await GetDesktopFile(filePath);
}
case "WindowsInstaller":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Remotely_Installer.exe");
var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var organization = _dataService.GetOrganizationById(organizationId);
fileContents.AddRange(await System.IO.File.ReadAllLinesAsync(Path.Combine(HostEnv.WebRootPath, "Downloads", $"{fileName}")));
if (organization.SponsorLevel > Shared.Enums.SponsorLevel.None)
{
var relayCode = organization.RelayCode;
return File(fs, "application/octet-stream", $"Remotely_Install-[{relayCode}].exe");
var hostIndex = fileContents.IndexOf("HostName=");
var orgIndex = fileContents.IndexOf("Organization=");
}
else
{
return File(fs, "application/octet-stream", $"Remotely_Installer-[{organizationId}].exe");
}
}
// TODO: Remove after a few releases.
case "Manjaro-x64":
case "ManjaroInstaller-x64":
{
var fileName = "Install-Manjaro-x64.sh";
fileContents[hostIndex] = $"HostName=\"{scheme}://{Request.Host}\"";
fileContents[orgIndex] = $"Organization=\"{organizationID}\"";
var fileBytes = Encoding.UTF8.GetBytes(string.Join("\n", fileContents));
return File(fileBytes, "application/octet-stream", $"{fileName}");
return await GetBashInstaller(fileName, organizationId);
}
// TODO: Remove after a few releases.
case "Ubuntu-x64":
case "UbuntuInstaller-x64":
{
var fileName = "Install-Ubuntu-x64.sh";
return await GetBashInstaller(fileName, organizationId);
}
default:
@ -86,9 +205,9 @@ namespace Remotely.Server.API
}
finally
{
if (FileLock.CurrentCount == 0)
if (_fileLock.CurrentCount == 0)
{
FileLock.Release();
_fileLock.Release();
}
}
}

View File

@ -5,15 +5,15 @@ using Remotely.Server.Hubs;
using Remotely.Server.Models;
using Remotely.Server.Services;
using Remotely.Shared.Models;
using System;
using System.Linq;
using System.Threading.Tasks;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace Remotely.Server.API
{
[Route("api/[controller]")]
[ApiController]
[Obsolete("This controller is here only for legacy purposes. For new integrations, use API tokens.")]
public class LoginController : ControllerBase
{
public LoginController(SignInManager<RemotelyUser> signInManager,

View File

@ -5,7 +5,7 @@ using Remotely.Server.Attributes;
using Remotely.Server.Hubs;
using Remotely.Server.Models;
using Remotely.Server.Services;
using Remotely.Shared.Helpers;
using Remotely.Shared.Utilities;
using Remotely.Shared.Models;
using System;
using System.Linq;

Some files were not shown because too many files have changed in this diff Show More