mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Working on desktop app.
This commit is contained in:
parent
83f11d89ca
commit
d6d92834ca
@ -24,6 +24,7 @@
|
||||
<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>
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
<TextBlock VerticalAlignment="Center">
|
||||
Invite Link:
|
||||
</TextBlock>
|
||||
<Button HorizontalAlignment="Right" Style="{StaticResource NormalButton}" Width="50" Height="25" Click="CopyLinkButton_Click">
|
||||
<Button HorizontalAlignment="Right" Style="{StaticResource NormalButton}" Click="CopyLinkButton_Click">
|
||||
Copy
|
||||
</Button>
|
||||
</Grid>
|
||||
@ -46,7 +46,7 @@
|
||||
<TextBlock FontSize="8" Margin="5,0,0,0">Name</TextBlock>
|
||||
<TextBlock FontSize="8" Margin="0,0,5,0" HorizontalAlignment="Right">Has Control</TextBlock>
|
||||
</Grid>
|
||||
<ListBox Height="90" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Viewers}">
|
||||
<ListBox x:Name="ViewerListBox" Height="90" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Viewers}" SelectionMode="Extended">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel>
|
||||
@ -56,6 +56,7 @@
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<Button Style="{StaticResource NormalButton}" HorizontalAlignment="Right" Margin="0,5,0,0" Click="RemoveButton_Click">Remove</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Remotely_Desktop.ViewModels;
|
||||
using Remotely_ScreenCast.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -70,5 +71,10 @@ namespace Remotely_Desktop
|
||||
var animation = new DoubleAnimation(0, TimeSpan.FromMilliseconds(750));
|
||||
tooltip.BeginAnimation(OpacityProperty, animation);
|
||||
}
|
||||
|
||||
private async void RemoveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await MainWindowViewModel.Current.RemoveViewers(ViewerListBox.SelectedItems.Cast<Viewer>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,6 +78,15 @@ namespace Remotely_Desktop.ViewModels
|
||||
});
|
||||
}
|
||||
|
||||
internal async Task RemoveViewers(IEnumerable<Viewer> viewerList)
|
||||
{
|
||||
foreach (Viewer viewer in viewerList)
|
||||
{
|
||||
viewer.DisconnectRequested = true;
|
||||
await Program.OutgoingMessages.SendViewerRemoved(viewer.ViewerConnectionID);
|
||||
}
|
||||
}
|
||||
|
||||
private void ViewerAdded(object sender, Viewer viewer)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
|
||||
@ -66,7 +66,7 @@ namespace Remotely_ScreenCast.Capture
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
public void Init()
|
||||
{
|
||||
CurrentFrame = new Bitmap(CurrentScreenBounds.Width, CurrentScreenBounds.Height, PixelFormat.Format32bppArgb);
|
||||
PreviousFrame = new Bitmap(CurrentScreenBounds.Width, CurrentScreenBounds.Height, PixelFormat.Format32bppArgb);
|
||||
|
||||
@ -162,62 +162,55 @@ namespace Remotely_ScreenCast.Capture
|
||||
CurrentFrame.Dispose();
|
||||
PreviousFrame.Dispose();
|
||||
}
|
||||
private void Init()
|
||||
public void Init()
|
||||
{
|
||||
try
|
||||
lock (ScreenLock)
|
||||
{
|
||||
lock (ScreenLock)
|
||||
factory = new Factory1();
|
||||
|
||||
//Get first adapter
|
||||
adapter = factory.Adapters1.FirstOrDefault(x => x.Outputs.Length > 0);
|
||||
//Get device from adapter
|
||||
device = new SharpDX.Direct3D11.Device(adapter);
|
||||
//Get front buffer of the adapter
|
||||
if (adapter.GetOutputCount() < selectedScreen + 1)
|
||||
{
|
||||
factory = new Factory1();
|
||||
|
||||
//Get first adapter
|
||||
adapter = factory.Adapters1.FirstOrDefault(x => x.Outputs.Length > 0);
|
||||
//Get device from adapter
|
||||
device = new SharpDX.Direct3D11.Device(adapter);
|
||||
//Get front buffer of the adapter
|
||||
if (adapter.GetOutputCount() < selectedScreen + 1)
|
||||
{
|
||||
selectedScreen = 0;
|
||||
}
|
||||
output = adapter.GetOutput(selectedScreen);
|
||||
output1 = output.QueryInterface<Output1>();
|
||||
|
||||
// Width/Height of desktop to capture
|
||||
var bounds = output.Description.DesktopBounds;
|
||||
var newWidth = bounds.Right - bounds.Left;
|
||||
var newHeight = bounds.Bottom - bounds.Top;
|
||||
CurrentScreenBounds = new Rectangle(bounds.Left, bounds.Top, newWidth, newHeight);
|
||||
if (newWidth != width || newHeight != height)
|
||||
{
|
||||
ScreenChanged?.Invoke(this, CurrentScreenBounds);
|
||||
}
|
||||
width = newWidth;
|
||||
height = newHeight;
|
||||
|
||||
CurrentFrame = new Bitmap(width, height);
|
||||
PreviousFrame = new Bitmap(width, height);
|
||||
|
||||
// Create Staging texture CPU-accessible
|
||||
textureDesc = new Texture2DDescription
|
||||
{
|
||||
CpuAccessFlags = CpuAccessFlags.Read,
|
||||
BindFlags = BindFlags.None,
|
||||
Format = Format.B8G8R8A8_UNorm,
|
||||
Width = width,
|
||||
Height = height,
|
||||
OptionFlags = ResourceOptionFlags.None,
|
||||
MipLevels = 1,
|
||||
ArraySize = 1,
|
||||
SampleDescription = { Count = 1, Quality = 0 },
|
||||
Usage = ResourceUsage.Staging
|
||||
};
|
||||
screenTexture = new Texture2D(device, textureDesc);
|
||||
duplicatedOutput = output1.DuplicateOutput(device);
|
||||
selectedScreen = 0;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(ex);
|
||||
output = adapter.GetOutput(selectedScreen);
|
||||
output1 = output.QueryInterface<Output1>();
|
||||
|
||||
// Width/Height of desktop to capture
|
||||
var bounds = output.Description.DesktopBounds;
|
||||
var newWidth = bounds.Right - bounds.Left;
|
||||
var newHeight = bounds.Bottom - bounds.Top;
|
||||
CurrentScreenBounds = new Rectangle(bounds.Left, bounds.Top, newWidth, newHeight);
|
||||
if (newWidth != width || newHeight != height)
|
||||
{
|
||||
ScreenChanged?.Invoke(this, CurrentScreenBounds);
|
||||
}
|
||||
width = newWidth;
|
||||
height = newHeight;
|
||||
|
||||
CurrentFrame = new Bitmap(width, height);
|
||||
PreviousFrame = new Bitmap(width, height);
|
||||
|
||||
// Create Staging texture CPU-accessible
|
||||
textureDesc = new Texture2DDescription
|
||||
{
|
||||
CpuAccessFlags = CpuAccessFlags.Read,
|
||||
BindFlags = BindFlags.None,
|
||||
Format = Format.B8G8R8A8_UNorm,
|
||||
Width = width,
|
||||
Height = height,
|
||||
OptionFlags = ResourceOptionFlags.None,
|
||||
MipLevels = 1,
|
||||
ArraySize = 1,
|
||||
SampleDescription = { Count = 1, Quality = 0 },
|
||||
Usage = ResourceUsage.Staging
|
||||
};
|
||||
screenTexture = new Texture2D(device, textureDesc);
|
||||
duplicatedOutput = output1.DuplicateOutput(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,12 +9,13 @@ namespace Remotely_ScreenCast.Capture
|
||||
{
|
||||
public interface ICapturer : IDisposable
|
||||
{
|
||||
Bitmap CurrentFrame { get; set; }
|
||||
bool CaptureFullscreen { get; set; }
|
||||
Bitmap CurrentFrame { get; set; }
|
||||
Rectangle CurrentScreenBounds { get; }
|
||||
Bitmap PreviousFrame { get; set; }
|
||||
bool CaptureFullscreen { get; set; }
|
||||
void Capture();
|
||||
EventHandler<Rectangle> ScreenChanged { get; set; }
|
||||
int SelectedScreen { get; set; }
|
||||
void Capture();
|
||||
void Init();
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ namespace Remotely_ScreenCast.Capture
|
||||
{
|
||||
capturer = new DXCapture();
|
||||
captureMode = CaptureMode.DirectX;
|
||||
capturer.Init();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -69,9 +69,6 @@
|
||||
<Reference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNetCore.SignalR.Protocols.MessagePack.1.1.0\lib\netstandard2.0\Microsoft.AspNetCore.SignalR.Protocols.MessagePack.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Expression.Encoder, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=x86">
|
||||
<HintPath>..\packages\Microsoft.Expression.Encoder.4.0.4276.3\lib\net45\Microsoft.Expression.Encoder.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Configuration, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
@ -61,5 +61,10 @@ namespace Remotely_ScreenCast.Sockets
|
||||
{
|
||||
await Connection.SendAsync("GetSessionID");
|
||||
}
|
||||
|
||||
public async Task SendViewerRemoved(string viewerID)
|
||||
{
|
||||
await Connection.SendAsync("SendViewerRemoved", viewerID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
<package id="Microsoft.AspNetCore.SignalR.Common" version="1.1.0" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNetCore.SignalR.Protocols.Json" version="1.1.0" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" version="1.1.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Expression.Encoder" version="4.0.4276.3" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.Configuration" version="2.2.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.Configuration.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.Configuration.Binder" version="2.2.0" targetFramework="net472" />
|
||||
|
||||
@ -123,8 +123,8 @@ namespace Remotely_Server.Services
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
await RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("ViewerDisconnected", Context.ConnectionId);
|
||||
}
|
||||
await RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("ViewerDisconnected", Context.ConnectionId);
|
||||
}
|
||||
|
||||
public async Task SelectScreen(int screenIndex)
|
||||
|
||||
@ -134,6 +134,11 @@ namespace Remotely_Server.Services
|
||||
await RCBrowserHub.Clients.Clients(viewerIDs).SendAsync("SwitchingDesktops");
|
||||
}
|
||||
|
||||
public async Task SendViewerRemoved(string viewerID)
|
||||
{
|
||||
await RCBrowserHub.Clients.Clients(viewerID).SendAsync("ViewerRemoved");
|
||||
}
|
||||
|
||||
public async Task GetSessionID()
|
||||
{
|
||||
var random = new Random();
|
||||
|
||||
@ -21,6 +21,7 @@ export class RCBrowserSockets {
|
||||
UI.StatusMessage.innerHTML = "";
|
||||
});
|
||||
this.Connection.closedCallbacks.push((ev) => {
|
||||
UI.Screen2DContext.clearRect(0, 0, UI.ScreenViewer.width, UI.ScreenViewer.height);
|
||||
console.log("Connection closed.");
|
||||
UI.StatusMessage.innerHTML = "Connection closed.";
|
||||
UI.ScreenViewer.setAttribute("hidden", "hidden");
|
||||
@ -121,6 +122,12 @@ export class RCBrowserSockets {
|
||||
UI.ShowMessage("Connection failed. Please reconnect.");
|
||||
this.Connection.stop();
|
||||
});
|
||||
hubConnection.on("ViewerRemoved", () => {
|
||||
UI.ConnectButton.removeAttribute("disabled");
|
||||
UI.StatusMessage.innerHTML = "The session was stopped by your partner.";
|
||||
UI.ShowMessage("Session ended.");
|
||||
this.Connection.stop();
|
||||
});
|
||||
hubConnection.on("SessionIDNotFound", () => {
|
||||
UI.ConnectButton.removeAttribute("disabled");
|
||||
UI.StatusMessage.innerHTML = "Session ID not found.";
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -29,6 +29,7 @@ export class RCBrowserSockets {
|
||||
UI.StatusMessage.innerHTML = "";
|
||||
})
|
||||
this.Connection.closedCallbacks.push((ev) => {
|
||||
UI.Screen2DContext.clearRect(0, 0, UI.ScreenViewer.width, UI.ScreenViewer.height);
|
||||
console.log("Connection closed.");
|
||||
UI.StatusMessage.innerHTML = "Connection closed.";
|
||||
UI.ScreenViewer.setAttribute("hidden", "hidden");
|
||||
@ -130,6 +131,12 @@ export class RCBrowserSockets {
|
||||
UI.ShowMessage("Connection failed. Please reconnect.");
|
||||
this.Connection.stop();
|
||||
});
|
||||
hubConnection.on("ViewerRemoved", () => {
|
||||
UI.ConnectButton.removeAttribute("disabled");
|
||||
UI.StatusMessage.innerHTML = "The session was stopped by your partner.";
|
||||
UI.ShowMessage("Session ended.");
|
||||
this.Connection.stop();
|
||||
});
|
||||
hubConnection.on("SessionIDNotFound", () => {
|
||||
UI.ConnectButton.removeAttribute("disabled");
|
||||
UI.StatusMessage.innerHTML = "Session ID not found.";
|
||||
|
||||
@ -113,6 +113,14 @@ if ($ArgList.Contains("c")) {
|
||||
Pop-Location
|
||||
Move-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\linux-x64\publish\Remotely-Linux.zip" -Destination ".\Remotely_Server\wwwroot\Downloads\Remotely-Linux.zip" -Force
|
||||
|
||||
# Copy desktop app to Downloads folder.
|
||||
if ((Test-Path -Path ".\Remotely_Desktop\bin\Release\Remotely_Desktop.exe") -eq $true) {
|
||||
Copy-Item -Path ".\Remotely_Desktop\bin\Release\Remotely_Desktop.exe" -Destination ".\Remotely_Server\wwwroot\Downloads\Remotely_Desktop.exe" -Force
|
||||
}
|
||||
elseif ((Test-Path -Path ".\Remotely_Desktop\bin\Debug\Remotely_Desktop.exe") -eq $true) {
|
||||
Copy-Item -Path ".\Remotely_Desktop\bin\Debug\Remotely_Desktop.exe" -Destination ".\Remotely_Server\wwwroot\Downloads\Remotely_Desktop.exe" -Force
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($ArgList.Contains("s") -and $OutDir.Length -gt 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user