Skip to content

Commit

Permalink
Merge pull request #6 from haefele/patch-2
Browse files Browse the repository at this point in the history
Fix README, add RdpControl.OnClientAreaClicked event and fix InvalidActiveXStateException in RdpControl.Disconnect
  • Loading branch information
StefanKoell authored Apr 11, 2024
2 parents cb52b3f + b902cd9 commit db0d8b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# FreeRDP Control
# RDP Control

[![NuGet Version](https://img.shields.io/nuget/v/RoyalApps.Community.Rdp.WinForms.svg?style=flat)](https://www.nuget.org/packages/RoyalApps.Community.FreeRdp.WinForms)
[![NuGet Downloads](https://img.shields.io/nuget/dt/RoyalApps.Community.Rdp.WinForms.svg?color=green)](https://www.nuget.org/packages/RoyalApps.Community.FreeRdp.WinForms)
[![.NET](https://img.shields.io/badge/.NET-%3E%3D%20%207.0-blueviolet)](https://dotnet.microsoft.com/download)
[![NuGet Version](https://img.shields.io/nuget/v/RoyalApps.Community.Rdp.WinForms.svg?style=flat)](https://www.nuget.org/packages/RoyalApps.Community.Rdp.WinForms)
[![NuGet Downloads](https://img.shields.io/nuget/dt/RoyalApps.Community.Rdp.WinForms.svg?color=green)](https://www.nuget.org/packages/RoyalApps.Community.Rdp.WinForms)
[![.NET](https://img.shields.io/badge/.NET-%3E%3D%20%208.0-blueviolet)](https://dotnet.microsoft.com/download)

RoyalApps.Community.RDP contains projects/packages to easily embed/use Microsoft RDP ActiveX wrapped in [MsRdpEx](https://github.com/Devolutions/MsRdpEx) in a Windows (WinForms) application.
![Screenshot](https://raw.githubusercontent.com/royalapplications/royalapps-community-rdp/main/docs/assets/Screenshot.png)

## Getting Started
### Installation
You should install the RoyalApps.Community.FreeRDP.WinForms with NuGet:
You should install the RoyalApps.Community.RDP.WinForms with NuGet:
```
Install-Package RoyalApps.Community.RDP.WinForms
```
Expand All @@ -18,7 +18,7 @@ or via the command line interface:
dotnet add package RoyalApps.Community.RDP.WinForms
```

### Using the FreeRdpControl
### Using the RdpControl
#### Add Control
Place the `RdpControl` on a form or in a container control (user control, tab control, etc.) and set the `Dock` property to `DockStyle.Fill`

Expand Down
16 changes: 14 additions & 2 deletions src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ public class RdpControl : UserControl
/// <summary>
/// Raised when the client calls the RequestClose method.
/// </summary>
public event EventHandler<IMsTscAxEvents_OnConfirmCloseEvent>? OnConfirmClose;
public event EventHandler<IMsTscAxEvents_OnConfirmCloseEvent>? OnConfirmClose;

/// <summary>
/// This event is raised when a user clicks into a remote desktop session and DisableClickDetection is not set.
/// </summary>
public event EventHandler? OnClientAreaClicked;

/// <summary>
/// Raised before the remote desktop size is going to change.
Expand Down Expand Up @@ -171,6 +176,7 @@ public void UnregisterEvents()
RdpClient.OnRequestContainerMinimize -= RdpClient_OnRequestContainerMinimize;
RdpClient.OnRequestLeaveFullScreen -= RdpClient_OnRequestLeaveFullScreen;
RdpClient.OnConfirmClose -= RdpClient_OnConfirmClose;
RdpClient.OnClientAreaClicked -= RdpClient_OnClientAreaClicked;
}

/// <summary>
Expand All @@ -193,7 +199,7 @@ public void Connect()
/// </summary>
public void Disconnect()
{
if (RdpClient == null || RdpClient.ConnectionState == ConnectionState.Disconnected)
if (RdpClient == null || RdpClient.GetOcx() == null || RdpClient.ConnectionState == ConnectionState.Disconnected)
return;

try
Expand Down Expand Up @@ -496,6 +502,11 @@ private void RdpClient_OnConfirmClose(object sender, IMsTscAxEvents_OnConfirmClo
OnConfirmClose?.Invoke(sender, e);
}

private void RdpClient_OnClientAreaClicked(object? sender, EventArgs e)
{
OnClientAreaClicked?.Invoke(sender, e);
}

private void ApplyInitialScaling()
{
_currentZoomLevel = RdpConfiguration.Display.AutoScaling
Expand Down Expand Up @@ -624,6 +635,7 @@ private void RegisterEvents()
RdpClient.OnRequestContainerMinimize += RdpClient_OnRequestContainerMinimize;
RdpClient.OnRequestLeaveFullScreen += RdpClient_OnRequestLeaveFullScreen;
RdpClient.OnConfirmClose += RdpClient_OnConfirmClose;
RdpClient.OnClientAreaClicked += RdpClient_OnClientAreaClicked;
}

private bool SetZoomLevel(int desiredZoomLevel)
Expand Down

0 comments on commit db0d8b3

Please sign in to comment.