Skip to content

Commit

Permalink
Removed unused usings and added viewonly mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MCPC10 committed May 29, 2024
1 parent 494a018 commit 16b4719
Show file tree
Hide file tree
Showing 39 changed files with 42 additions and 70 deletions.
3 changes: 1 addition & 2 deletions benchmarks/Benchmarks/ImmutableDictionaryLookup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Immutable;
using System.Collections.Immutable;
using System.Linq;
using BenchmarkDotNet.Attributes;

Expand Down
1 change: 0 additions & 1 deletion benchmarks/Benchmarks/MemoryCopy.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Attributes;
Expand Down
1 change: 0 additions & 1 deletion samples/AvaloniaVncClient/Services/ConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Threading.Tasks;
using MarcusW.VncClient;
using MarcusW.VncClient.Avalonia.Adapters.Logging;
using MarcusW.VncClient.Rendering;
using Microsoft.Extensions.Logging;
using Splat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
Expand Down
15 changes: 7 additions & 8 deletions samples/AvaloniaVncClient/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
Expand Down Expand Up @@ -54,13 +53,13 @@ private void InitializeComponent()

private void OnEnableFullscreenButtonClicked(object? sender, RoutedEventArgs e) => SetFullscreenMode(true);

private void SetFullscreenMode(bool fullscreen)
{
WindowState = fullscreen ? WindowState.FullScreen : WindowState.Normal;
private void SetFullscreenMode(bool fullscreen)
{
WindowState = fullscreen ? WindowState.FullScreen : WindowState.Normal;

TopDockPanel.IsVisible = !fullscreen;
BottomDockPanel.IsVisible = !fullscreen;
RightDockPanel.IsVisible = !fullscreen;
}
TopDockPanel.IsVisible = !fullscreen;
BottomDockPanel.IsVisible = !fullscreen;
RightDockPanel.IsVisible = !fullscreen;
}
}
}
1 change: 0 additions & 1 deletion src/MarcusW.VncClient.Avalonia/Conversions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel;
using Avalonia;

namespace MarcusW.VncClient.Avalonia
Expand Down
2 changes: 0 additions & 2 deletions src/MarcusW.VncClient.Avalonia/RfbRenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using Avalonia.Threading;
using MarcusW.VncClient.Avalonia.Adapters;
using MarcusW.VncClient.Avalonia.Adapters.Rendering;
using MarcusW.VncClient.Rendering;
using IRenderTarget = MarcusW.VncClient.Rendering.IRenderTarget;
using PixelFormat = Avalonia.Platform.PixelFormat;

namespace MarcusW.VncClient.Avalonia
{
Expand Down
9 changes: 6 additions & 3 deletions src/MarcusW.VncClient.Avalonia/VncView.KeyInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class VncView
protected override void OnTextInput(TextInputEventArgs e)
{
base.OnTextInput(e);
if (e.Handled)
if (ViewOnly || e.Handled)
return;

// Get connection
Expand All @@ -39,7 +39,7 @@ protected override void OnTextInput(TextInputEventArgs e)
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.Handled || e.Key == Key.None)
if (ViewOnly || e.Handled || e.Key == Key.None)
return;

// Send key press
Expand All @@ -53,7 +53,7 @@ protected override void OnKeyDown(KeyEventArgs e)
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
if (e.Handled || e.Key == Key.None)
if (ViewOnly|| e.Handled || e.Key == Key.None)
return;

// Send key release
Expand All @@ -69,6 +69,9 @@ protected override void OnKeyUp(KeyEventArgs e)
protected override void OnLostFocus(RoutedEventArgs e)
{
base.OnLostFocus(e);
if (ViewOnly)
return;

ResetKeyPresses();
}

Expand Down
8 changes: 4 additions & 4 deletions src/MarcusW.VncClient.Avalonia/VncView.MouseInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class VncView
protected override void OnPointerMoved(PointerEventArgs e)
{
base.OnPointerMoved(e);
if (e.Handled)
if (ViewOnly || e.Handled)
return;

PointerPoint point = e.GetCurrentPoint(this);
Expand All @@ -22,7 +22,7 @@ protected override void OnPointerMoved(PointerEventArgs e)
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
base.OnPointerPressed(e);
if (e.Handled)
if (ViewOnly || e.Handled)
return;

PointerPoint point = e.GetCurrentPoint(this);
Expand All @@ -34,7 +34,7 @@ protected override void OnPointerPressed(PointerPressedEventArgs e)
protected override void OnPointerReleased(PointerReleasedEventArgs e)
{
base.OnPointerReleased(e);
if (e.Handled)
if (ViewOnly || e.Handled)
return;

PointerPoint point = e.GetCurrentPoint(this);
Expand All @@ -46,7 +46,7 @@ protected override void OnPointerReleased(PointerReleasedEventArgs e)
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
{
base.OnPointerWheelChanged(e);
if (e.Handled)
if (ViewOnly || e.Handled)
return;

PointerPoint point = e.GetCurrentPoint(this);
Expand Down
1 change: 0 additions & 1 deletion src/MarcusW.VncClient.Avalonia/VncView.Sizing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using Avalonia;
using Avalonia.Controls;
using MarcusW.VncClient.Protocol.Implementation.MessageTypes.Outgoing;
Expand Down
28 changes: 24 additions & 4 deletions src/MarcusW.VncClient.Avalonia/VncView.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Reactive.Disposables;
using Avalonia;
using Avalonia.Input;
using Avalonia.Threading;
using MarcusW.VncClient.Output;
using MarcusW.VncClient.Protocol.Implementation.MessageTypes.Outgoing;

namespace MarcusW.VncClient.Avalonia
{
Expand All @@ -16,10 +14,15 @@ public partial class VncView : RfbRenderTarget, IOutputHandler
/// <summary>
/// Defines the <see cref="Connection"/> property.
/// </summary>
public static readonly DirectProperty<VncView, RfbConnection?> ConnectionProperty =
AvaloniaProperty.RegisterDirect<VncView, RfbConnection?>(nameof(Connection), o => o.Connection, (o, v) => o.Connection = v);
public static readonly DirectProperty<VncView, RfbConnection?> ConnectionProperty = AvaloniaProperty.RegisterDirect<VncView, RfbConnection?>(nameof(Connection), o => o.Connection, (o, v) => o.Connection = v);

/// <summary>
/// Defines the <see cref="ViewOnly"/> property.
/// </summary>
public static readonly DirectProperty<VncView, bool> ViewOnlyProperty = AvaloniaProperty.RegisterDirect<VncView, bool>(nameof(ViewOnly), o => o.ViewOnly, (o, v) => o.ViewOnly = v);

private RfbConnection? _connection;
private bool _viewOnly;

// Disposable for cleaning up after connection detaches
private CompositeDisposable _connectionDetachDisposable = new CompositeDisposable();
Expand Down Expand Up @@ -76,6 +79,20 @@ public RfbConnection? Connection
}
}

/// <summary>
/// Gets or sets the view only mode
/// </summary>
public bool ViewOnly
{
get => _viewOnly;
set
{
_viewOnly = value;
if (_viewOnly)
ResetKeyPresses();
}
}

public VncView()
{
InitSizing();
Expand All @@ -91,6 +108,9 @@ public virtual void RingBell()
/// <inheritdoc />
public virtual void HandleServerClipboardUpdate(string text)
{
if (ViewOnly)
return;

Dispatcher.UIThread.Post(async () => {
// Copy the text to the local clipboard
await Clipboard.Get().SetTextAsync(text).ConfigureAwait(true);
Expand Down
1 change: 0 additions & 1 deletion src/MarcusW.VncClient/ConnectParameters.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Net;
using MarcusW.VncClient.Output;
using MarcusW.VncClient.Rendering;
using MarcusW.VncClient.Security;
Expand Down
4 changes: 0 additions & 4 deletions src/MarcusW.VncClient/PixelFormat.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Buffers.Binary;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using MarcusW.VncClient.Protocol;
using MarcusW.VncClient.Rendering;

namespace MarcusW.VncClient
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Buffers.Binary;
using System.IO;
using MarcusW.VncClient.Protocol.EncodingTypes;
using MarcusW.VncClient.Rendering;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using MarcusW.VncClient.Protocol.EncodingTypes;
using MarcusW.VncClient.Rendering;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Buffers.Binary;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using MarcusW.VncClient.Protocol.EncodingTypes;
using MarcusW.VncClient.Rendering;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using MarcusW.VncClient.Protocol.EncodingTypes;
using MarcusW.VncClient.Rendering;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Diagnostics;
using System.IO;
using MarcusW.VncClient.Protocol.EncodingTypes;
using MarcusW.VncClient.Protocol.Implementation.MessageTypes.Incoming;
using MarcusW.VncClient.Protocol.Implementation.MessageTypes.Outgoing;
using Microsoft.Extensions.Logging;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Threading;
using MarcusW.VncClient.Output;
using MarcusW.VncClient.Protocol.MessageTypes;
using Microsoft.Extensions.Logging;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Threading;
using MarcusW.VncClient.Protocol.EncodingTypes;
using MarcusW.VncClient.Protocol.Implementation.MessageTypes.Outgoing;
using MarcusW.VncClient.Protocol.MessageTypes;
using Microsoft.Extensions.Logging;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Buffers.Binary;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using MarcusW.VncClient.Protocol.EncodingTypes;
using MarcusW.VncClient.Protocol.Implementation.EncodingTypes.Pseudo;
using MarcusW.VncClient.Protocol.Implementation.MessageTypes.Outgoing;
using MarcusW.VncClient.Protocol.MessageTypes;
using MarcusW.VncClient.Protocol.Services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Buffers.Binary;
using System.Diagnostics;
using System.Threading;
using MarcusW.VncClient.Protocol.Implementation.MessageTypes.Incoming;
using MarcusW.VncClient.Protocol.MessageTypes;

namespace MarcusW.VncClient.Protocol.Implementation.MessageTypes.Outgoing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Buffers.Binary;
using System.Diagnostics;
using System.Threading;
using MarcusW.VncClient.Protocol.MessageTypes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading;
using MarcusW.VncClient.Protocol.EncodingTypes;
using MarcusW.VncClient.Protocol.MessageTypes;

namespace MarcusW.VncClient.Protocol.Implementation.MessageTypes.Outgoing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Buffers.Binary;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics.X86;

namespace MarcusW.VncClient.Protocol.Implementation
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using MarcusW.VncClient.Protocol.SecurityTypes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MarcusW.VncClient.Protocol.SecurityTypes;
using MarcusW.VncClient.Security;
using MarcusW.VncClient.Utils;

namespace MarcusW.VncClient.Protocol.Implementation.SecurityTypes
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Threading;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MarcusW.VncClient.Protocol.Implementation.MessageTypes.Outgoing;
using MarcusW.VncClient.Protocol.MessageTypes;
using MarcusW.VncClient.Protocol.Services;
using MarcusW.VncClient.Rendering;
using MarcusW.VncClient.Utils;
using Microsoft.Extensions.Logging;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Threading.Tasks;
using MarcusW.VncClient.Protocol.SecurityTypes;
using MarcusW.VncClient.Protocol.Services;
using MarcusW.VncClient.Utils;
using Microsoft.Extensions.Logging;

namespace MarcusW.VncClient.Protocol.Implementation.Services.Handshaking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using MarcusW.VncClient.Protocol.Services;
using MarcusW.VncClient.Utils;
using Microsoft.Extensions.Logging;

namespace MarcusW.VncClient.Protocol.Implementation.Services.Initialization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
Expand Down
Loading

0 comments on commit 16b4719

Please sign in to comment.