mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
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:
parent
a310fa60cf
commit
2c5373323c
@ -77,7 +77,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
get { return terminated; }
|
get { return terminated; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private CustomCursor RemoteCursor = null;
|
private CustomCursor RemoteCursor;
|
||||||
private CustomCursor LocalCursor = new CustomCursor(Images.StaticImages.vnc_local_cursor, 2, 2);
|
private CustomCursor LocalCursor = new CustomCursor(Images.StaticImages.vnc_local_cursor, 2, 2);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -430,7 +430,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern bool DestroyIcon(IntPtr hIcon);
|
public static extern bool DestroyIcon(IntPtr hIcon);
|
||||||
|
|
||||||
class CustomCursor
|
class CustomCursor : IDisposable
|
||||||
{
|
{
|
||||||
private Cursor cursor = null;
|
private Cursor cursor = null;
|
||||||
private IntPtr handle = IntPtr.Zero;
|
private IntPtr handle = IntPtr.Zero;
|
||||||
|
@ -101,7 +101,7 @@ namespace XenAdmin.Controls
|
|||||||
|
|
||||||
public void ClearRows()
|
public void ClearRows()
|
||||||
{
|
{
|
||||||
foreach (CustomListRow row in Rows)
|
foreach (var row in Rows)
|
||||||
{
|
{
|
||||||
row.Dispose();
|
row.Dispose();
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace XenAdmin.Controls
|
namespace XenAdmin.Controls
|
||||||
{
|
{
|
||||||
public class CustomListRow
|
public class CustomListRow : IDisposable
|
||||||
{
|
{
|
||||||
private Color ForeColor_ = SystemColors.ControlText;
|
private Color ForeColor_ = SystemColors.ControlText;
|
||||||
private Color BackColor_ = SystemColors.Control;
|
private Color BackColor_ = SystemColors.Control;
|
||||||
@ -258,18 +258,14 @@ namespace XenAdmin.Controls
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (ForePen != null)
|
ForePen?.Dispose();
|
||||||
ForePen.Dispose();
|
BorderPen?.Dispose();
|
||||||
if (BorderPen != null)
|
BackBrush?.Dispose();
|
||||||
BorderPen.Dispose();
|
SelectedBackBrush?.Dispose();
|
||||||
if (BackBrush != null)
|
|
||||||
BackBrush.Dispose();
|
|
||||||
if (SelectedBackBrush != null)
|
|
||||||
SelectedBackBrush.Dispose();
|
|
||||||
|
|
||||||
foreach (CustomListRow r in Children)
|
foreach (var row in Children)
|
||||||
{
|
{
|
||||||
r.Dispose();
|
row.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user