CP-36392: Inherit IDisposable to avoid confusion

Classes didn't extend IDisposable
Also used null propagation to tidy up method body

Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
Danilo Del Busso 2022-01-24 10:09:06 +00:00 committed by Konstantina Chremmou
parent a310fa60cf
commit 2c5373323c
3 changed files with 11 additions and 15 deletions

View File

@ -77,7 +77,7 @@ namespace XenAdmin.ConsoleView
get { return terminated; }
}
private CustomCursor RemoteCursor = null;
private CustomCursor RemoteCursor;
private CustomCursor LocalCursor = new CustomCursor(Images.StaticImages.vnc_local_cursor, 2, 2);
/// <summary>
@ -430,7 +430,7 @@ namespace XenAdmin.ConsoleView
[DllImport("user32.dll")]
public static extern bool DestroyIcon(IntPtr hIcon);
class CustomCursor
class CustomCursor : IDisposable
{
private Cursor cursor = null;
private IntPtr handle = IntPtr.Zero;

View File

@ -101,7 +101,7 @@ namespace XenAdmin.Controls
public void ClearRows()
{
foreach (CustomListRow row in Rows)
foreach (var row in Rows)
{
row.Dispose();
}

View File

@ -32,12 +32,12 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace XenAdmin.Controls
{
public class CustomListRow
public class CustomListRow : IDisposable
{
private Color ForeColor_ = SystemColors.ControlText;
private Color BackColor_ = SystemColors.Control;
@ -258,18 +258,14 @@ namespace XenAdmin.Controls
public void Dispose()
{
if (ForePen != null)
ForePen.Dispose();
if (BorderPen != null)
BorderPen.Dispose();
if (BackBrush != null)
BackBrush.Dispose();
if (SelectedBackBrush != null)
SelectedBackBrush.Dispose();
ForePen?.Dispose();
BorderPen?.Dispose();
BackBrush?.Dispose();
SelectedBackBrush?.Dispose();
foreach (CustomListRow r in Children)
foreach (var row in Children)
{
r.Dispose();
row.Dispose();
}
}