diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-02-10 17:27:37 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-02-10 17:27:37 +0200 |
| commit | f8e1ff79cc2fa09b52093c6e029392b3456ad8bb (patch) | |
| tree | fc72fecd6564b49a4b7787c0b4161bcb45edc758 /Software/Visual_Studio/Tango.Visuals/AnalogSwitch | |
| parent | 07e686eb253ffd29f36dbe530b3a17633e02b353 (diff) | |
| download | Tango-f8e1ff79cc2fa09b52093c6e029392b3456ad8bb.tar.gz Tango-f8e1ff79cc2fa09b52093c6e029392b3456ad8bb.zip | |
Added dispensers support on technician module.
Diffstat (limited to 'Software/Visual_Studio/Tango.Visuals/AnalogSwitch')
| -rw-r--r-- | Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml | 12 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml.cs | 66 |
2 files changed, 78 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml b/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml new file mode 100644 index 000000000..c7ae4fe57 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml @@ -0,0 +1,12 @@ +<UserControl x:Class="Tango.Visuals.AnalogSwitch" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + mc:Ignorable="d" + d:DesignHeight="120" d:DesignWidth="70"> + <Grid> + <Image x:Name="imgOFF" Source="../Images/off.png" RenderOptions.BitmapScalingMode="Fant"></Image> + <Image x:Name="imgON" Source="../Images/on.png" RenderOptions.BitmapScalingMode="Fant" Visibility="Hidden"></Image> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml.cs b/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml.cs new file mode 100644 index 000000000..2149409a1 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/AnalogSwitch/AnalogSwitch.xaml.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Effects; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.Visuals +{ + /// <summary> + /// Interaction logic for AnalogSwitch.xaml + /// </summary> + public partial class AnalogSwitch : UserControl + { + public event Action<AnalogSwitch> CheckedChanged; + + public AnalogSwitch() + { + InitializeComponent(); + this.PreviewMouseUp += AnalogSwitch_PreviewMouseUp; + } + + void AnalogSwitch_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + IsChecked = !IsChecked; + } + + public bool IsChecked + { + get { return (bool)GetValue(IsCheckedProperty); } + set { SetValue(IsCheckedProperty, value); } + } + + // Using a DependencyProperty as the backing store for IsChecked. This enables animation, styling, binding, etc... + public static readonly DependencyProperty IsCheckedProperty = + DependencyProperty.Register("IsChecked", typeof(bool), typeof(AnalogSwitch), new PropertyMetadata(false,new PropertyChangedCallback(CheckChanged))); + + private static void CheckChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + AnalogSwitch s = d as AnalogSwitch; + if ((bool)e.NewValue) + { + s.imgON.Visibility = Visibility.Visible; + s.imgOFF.Visibility = Visibility.Hidden; + } + else + { + s.imgOFF.Visibility = Visibility.Visible; + s.imgON.Visibility = Visibility.Hidden; + } + + if (s.CheckedChanged != null) s.CheckedChanged(s); + } + + + } +} |
