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 | |
| 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')
| -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 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Visuals/Images/off.png | bin | 0 -> 14366 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Tango.Visuals/Images/on.png | bin | 0 -> 19420 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Tango.Visuals/Led/Led.xaml | 117 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Visuals/Led/Led.xaml.cs | 179 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj | 25 |
7 files changed, 399 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); + } + + + } +} diff --git a/Software/Visual_Studio/Tango.Visuals/Images/off.png b/Software/Visual_Studio/Tango.Visuals/Images/off.png Binary files differnew file mode 100644 index 000000000..67f2f4a6f --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Images/off.png diff --git a/Software/Visual_Studio/Tango.Visuals/Images/on.png b/Software/Visual_Studio/Tango.Visuals/Images/on.png Binary files differnew file mode 100644 index 000000000..9922b1901 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Images/on.png diff --git a/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml b/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml new file mode 100644 index 000000000..b59ed5d15 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml @@ -0,0 +1,117 @@ +<UserControl x:Class="Tango.Visuals.Led" + 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" + xmlns:converters="clr-namespace:Tango.Visuals.Converters" + mc:Ignorable="d" + d:DesignHeight="150" d:DesignWidth="150"> + <UserControl.Resources> + <converters:BooleanToVisibilityConverter x:Key="v"></converters:BooleanToVisibilityConverter> + + <RadialGradientBrush x:Key="outer" + Center="0.5,0.5" GradientOrigin="0.5,0.5" RadiusX="0.5" RadiusY="0.5" + SpreadMethod="Pad" ColorInterpolationMode="SRgbLinearInterpolation" > + <GradientStop Color="Transparent" Offset="0" /> + <GradientStop Color="Transparent" Offset="1" /> + </RadialGradientBrush> + + <RadialGradientBrush x:Key="inner" + Center="0.5,0.5" GradientOrigin="0.5,0.5" RadiusX="0.5" RadiusY="0.5" + SpreadMethod="Pad" ColorInterpolationMode="SRgbLinearInterpolation" > + <GradientStop Color="#FF98FF00" Offset="0" /> + <GradientStop Color="#FF01472B" Offset="1" /> + </RadialGradientBrush> + + <RadialGradientBrush x:Key="innerOff" + Center="0.5,0.5" GradientOrigin="0.5,0.5" RadiusX="0.5" RadiusY="0.5" + SpreadMethod="Pad" ColorInterpolationMode="SRgbLinearInterpolation" > + <GradientStop Color="Red" Offset="0" /> + <GradientStop Color="#FF670000" Offset="1" /> + </RadialGradientBrush> + </UserControl.Resources> + + <Grid> + <Grid x:Name="grid"> + <Grid.RowDefinitions> + <RowDefinition Height="3*"/> + <RowDefinition Height="60*"/> + <RowDefinition Height="3*"/> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="3*"/> + <ColumnDefinition Width="60*"/> + <ColumnDefinition Width="3*"/> + </Grid.ColumnDefinitions> + + <Ellipse Fill="{StaticResource outer}" Grid.RowSpan="3" Grid.ColumnSpan="3" Stroke="Gray" StrokeThickness="1"></Ellipse> + <!--<Ellipse Fill="#FF3E3E3E" Grid.Row="1" Grid.Column="1"> + <Ellipse.Triggers> + <EventTrigger RoutedEvent="MouseEnter"> + <BeginStoryboard> + <Storyboard> + <ColorAnimation Storyboard.TargetProperty="Fill.Color" To="#404040" Duration="00:00:0.2"></ColorAnimation> + </Storyboard> + </BeginStoryboard> + </EventTrigger> + <EventTrigger RoutedEvent="MouseLeave"> + <BeginStoryboard> + <Storyboard> + <ColorAnimation Storyboard.TargetProperty="Fill.Color" To="#FF464646" Duration="00:00:0.2"></ColorAnimation> + </Storyboard> + </BeginStoryboard> + </EventTrigger> + </Ellipse.Triggers> + </Ellipse>--> + + <Ellipse Margin="2" Grid.Row="1" Grid.Column="1" Stroke="#FF7F7F7F" StrokeThickness="2"> + <Ellipse.Style> + <Style> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=IsChecked}" Value="True"> + <Setter Property="Ellipse.Fill" Value="{DynamicResource inner}"></Setter> + <DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="Fill.(GradientBrush.GradientStops)[1].(GradientStop.Offset)" From="0.8" To="1" Duration="0:0:0.5" AutoReverse="True" RepeatBehavior="Forever"/> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + </DataTrigger> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=IsChecked}" Value="False"> + <Setter Property="Ellipse.Fill" Value="{DynamicResource innerOff}"></Setter> + <DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="Fill.(GradientBrush.GradientStops)[1].(GradientStop.Offset)" From="0.5" To="1" Duration="0:0:0.2" AutoReverse="False"/> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + </DataTrigger> + </Style.Triggers> + </Style> + </Ellipse.Style> + </Ellipse> + </Grid> + + <Grid x:Name="gridMask" Visibility="Hidden"> + <Grid.RowDefinitions> + <RowDefinition Height="11*"/> + <RowDefinition Height="30*"/> + <RowDefinition Height="11*"/> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="11*"/> + <ColumnDefinition Width="30*"/> + <ColumnDefinition Width="11*"/> + </Grid.ColumnDefinitions> + + <Ellipse Fill="{StaticResource outer}" Grid.RowSpan="3" Grid.ColumnSpan="3"></Ellipse> + <Ellipse Fill="#FF464646" Grid.Row="1" Grid.Column="1"> + </Ellipse> + + <Ellipse Fill="#707070" Margin="2" Grid.Row="1" Grid.Column="1"> + </Ellipse> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml.cs b/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml.cs new file mode 100644 index 000000000..5a1e67913 --- /dev/null +++ b/Software/Visual_Studio/Tango.Visuals/Led/Led.xaml.cs @@ -0,0 +1,179 @@ +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.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Core.Commands; + +namespace Tango.Visuals +{ + /// <summary> + /// Represents an LED like button that acts like a check box. + /// </summary> + public partial class Led : UserControl + { + #region Constructors + + public Led() + { + InitializeComponent(); + this.PreviewMouseUp += LedControl_PreviewMouseUp; + } + + #endregion + + #region Event Handlers + + void LedControl_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + if (IsPassive) return; + + IsChecked = !IsChecked; + + if (Command != null) + { + Command.Execute(null); + } + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets whether the LED is on or off. + /// </summary> + public bool IsChecked + { + get { return (bool)GetValue(IsCheckedProperty); } + set { SetValue(IsCheckedProperty, value); } + } + public static readonly DependencyProperty IsCheckedProperty = + DependencyProperty.Register("IsChecked", typeof(bool), typeof(Led), new PropertyMetadata(false)); + + + /// <summary> + /// Gets or sets whether the control is enabled. + /// </summary> + public bool Enabled + { + get { return (bool)GetValue(EnabledProperty); } + set { SetValue(EnabledProperty, value); } + } + public static readonly DependencyProperty EnabledProperty = + DependencyProperty.Register("Enabled", typeof(bool), typeof(Led), new PropertyMetadata(true, new PropertyChangedCallback(EnabledChanged))); + private static void EnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + Led l = d as Led; + if ((bool)e.NewValue) + { + l.gridMask.Visibility = Visibility.Hidden; + l.grid.Visibility = Visibility.Visible; + } + else + { + l.gridMask.Visibility = Visibility.Visible; + l.grid.Visibility = Visibility.Hidden; + } + } + + + public Brush FillBrush + { + get { return (Brush)GetValue(FillBrushProperty); } + set { SetValue(FillBrushProperty, value); } + } + public static readonly DependencyProperty FillBrushProperty = + DependencyProperty.Register("FillBrush", typeof(Brush), typeof(Led), new PropertyMetadata(null)); + + + public double InnerOpacity + { + get { return (double)GetValue(InnerOpacityProperty); } + set { SetValue(InnerOpacityProperty, value); } + } + public static readonly DependencyProperty InnerOpacityProperty = + DependencyProperty.Register("InnerOpacity", typeof(double), typeof(Led), new PropertyMetadata(1.0)); + + + public bool IsPassive + { + get { return (bool)GetValue(IsPassiveProperty); } + set { SetValue(IsPassiveProperty, value); } + } + public static readonly DependencyProperty IsPassiveProperty = + DependencyProperty.Register("IsPassive", typeof(bool), typeof(Led), new PropertyMetadata(false)); + + + + public Brush CheckedBrush + { + get { return (Brush)GetValue(CheckedBrushProperty); } + set { SetValue(CheckedBrushProperty, value); } + } + public static readonly DependencyProperty CheckedBrushProperty = + DependencyProperty.Register("CheckedBrush", typeof(Brush), typeof(Led), new PropertyMetadata(null,CheckBrushChanged)); + + private static void CheckBrushChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var control = d as Led; + control.Resources["inner"] = control.CheckedBrush; + } + + + + public Brush UnCheckedBrush + { + get { return (Brush)GetValue(UnCheckedBrushProperty); } + set { SetValue(UnCheckedBrushProperty, value); } + } + public static readonly DependencyProperty UnCheckedBrushProperty = + DependencyProperty.Register("UnCheckedBrush", typeof(Brush), typeof(Led), new PropertyMetadata(null,UnCheckedBrushChanged)); + + private static void UnCheckedBrushChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var control = d as Led; + control.Resources["innerOff"] = control.UnCheckedBrush; + } + + + + #endregion + + #region Commands + + /// <summary> + /// Represents the command to bind for CanExecute event. + /// </summary> + public RelayCommand Command + { + get { return (RelayCommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register("Command", typeof(RelayCommand), typeof(Led), new PropertyMetadata(null, new PropertyChangedCallback(CommandChanged))); + private static void CommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + Led l = d as Led; + + if (l.Command != null) + { + l.Command.CanExecuteChanged += (x, y) => + { + l.IsEnabled = l.Command.CanExecute(null); + }; + } + } + + #endregion + } +}
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj b/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj index 4eaa3376e..53c87d0f5 100644 --- a/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj +++ b/Software/Visual_Studio/Tango.Visuals/Tango.Visuals.csproj @@ -52,6 +52,9 @@ <Compile Include="..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Compile Include="AnalogSwitch\AnalogSwitch.xaml.cs"> + <DependentUpon>AnalogSwitch.xaml</DependentUpon> + </Compile> <Compile Include="Components\Arc.cs" /> <Compile Include="Components\PieAxisTicks.xaml.cs"> <DependentUpon>PieAxisTicks.xaml</DependentUpon> @@ -73,6 +76,9 @@ <Compile Include="Knob\Knob.xaml.cs"> <DependentUpon>Knob.xaml</DependentUpon> </Compile> + <Compile Include="Led\Led.xaml.cs"> + <DependentUpon>Led.xaml</DependentUpon> + </Compile> <Compile Include="YAxisDoubles\YAxisDoubles.xaml.cs"> <DependentUpon>YAxisDoubles.xaml</DependentUpon> </Compile> @@ -90,6 +96,10 @@ <Compile Include="VUMeter\VUMeter.xaml.cs"> <DependentUpon>VUMeter.xaml</DependentUpon> </Compile> + <Page Include="AnalogSwitch\AnalogSwitch.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Components\PieAxisTicks.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -110,6 +120,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Led\Led.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="YAxisDoubles\YAxisDoubles.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -188,6 +202,17 @@ <Resource Include="Knob\volumeKnobMetroDark.png" /> <Resource Include="Knob\volumeKnobMetroLight.png" /> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup /> + <ItemGroup> + <Resource Include="Images\off.png" /> + <Resource Include="Images\on.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. |
