// ***********************************************************************
// Assembly : Construction
// Author : flythink
// Created : 07-02-2020
//
// Last Modified By : flythink
// Last Modified On : 09-01-2020
// ***********************************************************************
//
// Copyright (c) jindongfang. All rights reserved.
//
//
// ***********************************************************************
namespace WellWorkDataUI
{
using DevExpress.Utils.Drawing;
using DevExpress.Utils.Paint;
using System;
///
/// using自动切换XPaint
///
public class XPaintHelper : IDisposable
{
private static ObjectPool pool = new ObjectPool(() => new XPaintHelper());
private GraphicsCache cache;
private XPaint newItem;
private XPaint oldItem;
private XPaintHelper()
{
}
///
/// Switches the specified cache.
///
/// The cache.
/// The paint.
/// XPaintHelper.
public static XPaintHelper Switch(GraphicsCache cache, XPaint paint)
{
XPaintHelper item = pool.Get();
item.cache = cache;
item.oldItem = cache.Paint;
item.newItem = paint;
cache.Paint = paint;
return item;
}
///
/// Provides objects that represent the root keys in the Windows registry, and methods to access key/value pairs.
///
public void Dispose()
{
this.cache.Paint = this.oldItem;
pool.Return(this);
}
}
}