Skip to content

Commit f893f55

Browse files
committed
Upgrade to net core 3.0 stable, bump VncDotnet to 1.1.0, bump version to 1.1.0
1 parent 1dad455 commit f893f55

File tree

5 files changed

+59
-66
lines changed

5 files changed

+59
-66
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# VncDotnet.WPF
2-
[![Build Status](https://dev.azure.com/benediktradtke/VncDotnet/_apis/build/status/VncDotnet.VncDotnet.WPF%20CI?branchName=master)](https://dev.azure.com/benediktradtke/VncDotnet/_build/latest?definitionId=9&branchName=master)
2+
[![Build Status](https://dev.azure.com/benediktradtke/VncDotnet/_apis/build/status/VncDotnet.VncDotnet.WPF%20CI?branchName=master)](https://dev.azure.com/benediktradtke/VncDotnet/_build)
33
![](https://tokei.rs/b1/github/VncDotnet/VncDotnet.WPF)

VncDotnet.WPF/VncDotnet.WPF.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1515
<IncludeSymbols>true</IncludeSymbols>
1616
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
17-
<Version>1.0.8</Version>
17+
<Version>1.1.0</Version>
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="VncDotnet" Version="1.0.8" />
21+
<PackageReference Include="VncDotnet" Version="1.1.0" />
2222
<PackageReference Include="WriteableBitmapEx" Version="1.6.2" />
23-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19351-01" PrivateAssets="All"/>
23+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" PrivateAssets="All" />
2424
</ItemGroup>
2525

2626
</Project>

VncDotnet.WPF/VncDotnetControl.cs

Lines changed: 49 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
namespace VncDotnet.WPF
2323
{
24-
public class VncDotnetControl : Control
24+
public class VncDotnetControl : Control, IVncHandler
2525
{
2626
static VncDotnetControl()
2727
{
@@ -56,12 +56,11 @@ public void Start(string host, int port, string? password, IEnumerable<SecurityT
5656
Task.Run(() => ReconnectLoop(host, port, password, securityTypes, section, token));
5757
}
5858

59-
public void Start(RfbConnection preEstablishedConnection, MonitorSnippet? section)
59+
public async Task Attach(RfbConnection preEstablishedConnection, MonitorSnippet? section)
6060
{
6161
Section = section;
6262
PreEstablishedConnection = preEstablishedConnection;
63-
PreEstablishedConnection.OnVncUpdate += Client_OnVncUpdate;
64-
PreEstablishedConnection.OnResolutionUpdate += Client_OnResolutionUpdate;
63+
await PreEstablishedConnection.Attach(this);
6564
}
6665

6766
private async Task ReconnectLoop(string host, int port, string? password, IEnumerable<SecurityType> securityTypes, MonitorSnippet? section, CancellationToken token)
@@ -72,8 +71,6 @@ private async Task ReconnectLoop(string host, int port, string? password, IEnume
7271
{
7372
Connection = await RfbConnection.ConnectAsync(host, port, password, securityTypes, section, token);
7473
Section = section;
75-
Connection.OnVncUpdate += Client_OnVncUpdate;
76-
Connection.OnResolutionUpdate += Client_OnResolutionUpdate;
7774
await Connection.Start();
7875
}
7976
catch (OperationCanceledException) { }
@@ -85,35 +82,45 @@ private async Task ReconnectLoop(string host, int port, string? password, IEnume
8582
}
8683
}
8784

88-
private void Client_OnResolutionUpdate(int framebufferWidth, int framebufferHeight)
85+
private int BitmapX()
8986
{
90-
Application.Current?.Dispatcher.Invoke(new Action(() =>
87+
if (Section != null)
9188
{
92-
var image = (Image) GetTemplateChild("Scene");
93-
if (Section != null)
94-
{
95-
FramebufferWidth = Section.Width;
96-
FramebufferHeight = Section.Height;
97-
Bitmap = BitmapFactory.New(FramebufferWidth, FramebufferHeight);
98-
}
99-
else
100-
{
101-
FramebufferWidth = framebufferWidth;
102-
FramebufferHeight = framebufferHeight;
103-
Bitmap = BitmapFactory.New(framebufferWidth, framebufferHeight);
104-
}
105-
image.Source = Bitmap;
106-
}));
89+
return Section.X;
90+
}
91+
return 0;
92+
}
93+
94+
private int BitmapY()
95+
{
96+
if (Section != null)
97+
{
98+
return Section.Y;
99+
}
100+
return 0;
101+
}
102+
103+
public async Task Stop()
104+
{
105+
if (Connection != null)
106+
{
107+
Connection.Stop();
108+
}
109+
110+
if (PreEstablishedConnection != null)
111+
{
112+
await PreEstablishedConnection.Detach(this);
113+
}
107114
}
108115

109-
private void Client_OnVncUpdate(IEnumerable<(RfbRectangleHeader header, byte[] data)> rectangles)
116+
public void HandleFramebufferUpdate(IEnumerable<(RfbRectangleHeader, byte[])> rectangles)
110117
{
111118
Application.Current?.Dispatcher.Invoke(new Action(() =>
112119
{
113120
var stopwatch = new Stopwatch();
114121
stopwatch.Start();
115122
if (Bitmap == null)
116-
throw new InvalidOperationException();
123+
throw new InvalidOperationException("Bitmap is null");
117124
using (var ctx = Bitmap.GetBitmapContext())
118125
{
119126
Bitmap.Lock();
@@ -168,51 +175,35 @@ private void Client_OnVncUpdate(IEnumerable<(RfbRectangleHeader header, byte[] d
168175
rowLength * 4);
169176
}
170177
}
171-
ArrayPool<byte>.Shared.Return(data);
172178
}
173179
}
174180

175-
Bitmap.DrawRectangle(0, 0, 64, 64, Colors.GreenYellow);
176181
Bitmap.AddDirtyRect(new Int32Rect(0, 0, Bitmap.PixelWidth, Bitmap.PixelHeight));
177182
Bitmap.Unlock();
178183
}
179184
stopwatch.Stop();
180-
//Debug.WriteLine($"Client_OnVncUpdate invocation took {stopwatch.Elapsed}");
181185
}));
182186
}
183187

184-
private int BitmapX()
185-
{
186-
if (Section != null)
187-
{
188-
return Section.X;
189-
}
190-
return 0;
191-
}
192-
193-
private int BitmapY()
188+
public void HandleResolutionUpdate(int framebufferWidth, int framebufferHeight)
194189
{
195-
if (Section != null)
196-
{
197-
return Section.Y;
198-
}
199-
return 0;
200-
}
201-
202-
public void Stop()
203-
{
204-
if (Connection != null)
205-
{
206-
Connection.OnResolutionUpdate -= Client_OnResolutionUpdate;
207-
Connection.OnVncUpdate -= Client_OnVncUpdate;
208-
Connection.Stop();
209-
}
210-
211-
if (PreEstablishedConnection != null)
190+
Application.Current?.Dispatcher.Invoke(new Action(() =>
212191
{
213-
PreEstablishedConnection.OnResolutionUpdate -= Client_OnResolutionUpdate;
214-
PreEstablishedConnection.OnVncUpdate -= Client_OnVncUpdate;
215-
}
192+
var image = (Image)GetTemplateChild("Scene");
193+
if (Section != null)
194+
{
195+
FramebufferWidth = Section.Width;
196+
FramebufferHeight = Section.Height;
197+
Bitmap = BitmapFactory.New(FramebufferWidth, FramebufferHeight);
198+
}
199+
else
200+
{
201+
FramebufferWidth = framebufferWidth;
202+
FramebufferHeight = framebufferHeight;
203+
Bitmap = BitmapFactory.New(framebufferWidth, framebufferHeight);
204+
}
205+
image.Source = Bitmap;
206+
}));
216207
}
217208
}
218209
}

azure-pipelines-release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ variables:
2020
steps:
2121
- task: NuGetToolInstaller@1
2222

23-
- task: DotNetCoreInstaller@1
23+
- task: UseDotNet@2
2424
inputs:
25-
version: '3.0.100-preview9-014004'
25+
packageType: 'sdk'
26+
version: 3.x
2627

2728
- task: DotNetCoreCLI@2
2829
inputs:

azure-pipelines.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ variables:
1515
buildConfiguration: 'Release'
1616

1717
steps:
18-
- task: DotNetCoreInstaller@1
18+
- task: UseDotNet@2
1919
inputs:
20-
version: '3.0.100-preview9-014004'
20+
packageType: 'sdk'
21+
version: 3.x
2122

2223
- task: DotNetCoreCLI@2
2324
inputs:

0 commit comments

Comments
 (0)