DataEntry.DataStream.CheckBoxImage added.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.DataEntry.DataStream
|
||||
{
|
||||
public class CheckBoxImage : PictureBox
|
||||
{
|
||||
private bool cbChecked;
|
||||
private readonly Image checkedImg;
|
||||
private readonly Image uncheckedImg;
|
||||
|
||||
public CheckBoxImage()
|
||||
: this(new Bitmap(TBF.Properties.Resources.SwitchOn), new Bitmap(TBF.Properties.Resources.SwitchOff), true)
|
||||
{
|
||||
SizeMode = PictureBoxSizeMode.StretchImage;
|
||||
}
|
||||
|
||||
public CheckBoxImage(Image checkedImg, Image uncheckedImg, bool initState)
|
||||
: base()
|
||||
{
|
||||
this.checkedImg = checkedImg;
|
||||
this.uncheckedImg = uncheckedImg;
|
||||
Click += (sender, e) => { Checked = !Checked; };
|
||||
Checked = initState;
|
||||
}
|
||||
|
||||
public bool Checked
|
||||
{
|
||||
get { return cbChecked; }
|
||||
set
|
||||
{
|
||||
if (Enabled)
|
||||
{
|
||||
Image = value ? checkedImg : uncheckedImg;
|
||||
cbChecked = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user