<commit_before>﻿<UserControl x:Class="OpenHab.Wpf.View.Controls.ItemControl"
             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:viewModels="clr-namespace:OpenHab.Wpf.ViewModel.ViewModels;assembly=OpenHab.Wpf.ViewModel"
             xmlns:constants="clr-namespace:OpenHAB.NetRestApi.Constants;assembly=OpenHAB.NetRestApi"
             xmlns:p="clr-namespace:OpenHab.Wpf.View.Properties"
             xmlns:validation="clr-namespace:OpenHab.Wpf.View.Resources.Helpers.Validation"
             xmlns:params="http://schemas.codeplex.com/elysium/params"
             xmlns:extraFixed="clr-namespace:OpenHab.Wpf.View.Resources.Helpers.ElysiumDragFix"
             xmlns:controls="clr-namespace:OpenHab.Wpf.View.Controls"
             xmlns:extra="http://schemas.extra.com/ui"
             mc:Ignorable="d"
             d:DesignHeight="50" d:DesignWidth="500"
             d:DataContext="{d:DesignInstance Type={x:Type viewModels:ItemViewModel}, 
                                              IsDesignTimeCreatable=False}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/BaseResources.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <ControlTemplate x:Key="DimmerControlTemplate">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid Row="0"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0"
                                   Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPadding), Mode=OneWay}"
                                   HorizontalAlignment="Left"
                                   Text="{Binding Label}" />

                        <TextBlock Grid.Column="1"
                                   Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPadding), Mode=OneWay}"
                                   HorizontalAlignment="Right"
                                   Text="{Binding State, StringFormat={}{0}%}" />
                    </Grid>

                    <Grid Row="1"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                        <Slider
                            Value="{Binding State, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,                                                                         
                                        Converter={StaticResource StateToDimmerConverter}}"
                            Minimum="0"
                            Maximum="100"
                            Ticks="1"
                            IsMoveToPointEnabled="True"
                            PreviewMouseUp="DimmerSlider_OnPreviewMouseUp"
                            Thumb.DragDelta="DimmerSlider_OnDragDelta"
                            Thumb.DragCompleted="DimmerSlider_OnDragCompleted" />
                    </Grid>
                </Grid>
            </ControlTemplate>

            <ControlTemplate x:Key="ColorControlTemplate">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Column="0"
                               Grid.Row="0"
                               Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Style="{StaticResource NormalTextStyle}"
                               Text="{x:Static p:Resources.Color}" />

                    <TextBlock Grid.Column="0"
                               Grid.Row="1"
                               Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Style="{StaticResource NormalTextStyle}"
                               Text="{x:Static p:Resources.Saturation}" />

                    <TextBlock Grid.Column="0"
                               Grid.Row="2"
                               Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Style="{StaticResource NormalTextStyle}"
                               Text="{x:Static p:Resources.Brightness}" />

                    <Grid Column="1" Row="0" VerticalAlignment="Center"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                          Background="{StaticResource HorzontalColorHueBrush}">
                        <Slider
                            Value="{Binding State, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,                                                                         
                                        Converter={StaticResource StateToColorConverter}, 
                                        ConverterParameter=0}"
                            Minimum="0"
                            Maximum="360"
                            Ticks="1"
                            IsMoveToPointEnabled="True"
                            PreviewMouseUp="ColorHueSlider_OnPreviewMouseUp"
                            Thumb.DragDelta="ColorHueSlider_OnDragDelta"
                            Thumb.DragCompleted="ColorHueSlider_OnDragCompleted" />
                    </Grid>

                    <Grid Column="1" Row="1" VerticalAlignment="Center"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                        <Slider
                            Value="{Binding State, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,                                                                         
                                        Converter={StaticResource StateToColorConverter}, 
                                        ConverterParameter=1}"
                            Minimum="0"
                            Maximum="100"
                            Ticks="1"
                            IsMoveToPointEnabled="True"
                            PreviewMouseUp="ColorSaturationSlider_OnPreviewMouseUp"
                            Thumb.DragDelta="ColorSaturationSlider_OnDragDelta"
                            Thumb.DragCompleted="ColorSaturationSlider_OnDragCompleted" />
                    </Grid>

                    <Grid Column="1" Row="2" VerticalAlignment="Center"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                        <Slider
                            Value="{Binding State, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,                                                                         
                                        Converter={StaticResource StateToColorConverter}, 
                                        ConverterParameter=2}"
                            Minimum="0"
                            Maximum="100"
                            Ticks="1"
                            IsMoveToPointEnabled="True"
                            PreviewMouseUp="ColorBrightnessSlider_OnPreviewMouseUp"
                            Thumb.DragDelta="ColorBrightnessSlider_OnDragDelta"
                            Thumb.DragCompleted="ColorBrightnessSlider_OnDragCompleted" />
                    </Grid>
                </Grid>
            </ControlTemplate>

            <ControlTemplate x:Key="NumberControlTemplate">
                <Grid Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Column="0"
                               Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Style="{StaticResource NormalTextStyle}"
                               Text="{Binding Label}" />

                    <TextBox Grid.Column="1"
                             Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                             MinWidth="50"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             HorizontalContentAlignment="Right"
                             PreviewKeyDown="NumberTextBox_OnPreviewKeyDown">
                        <TextBox.Text>
                            <Binding Path="State"
                                     UpdateSourceTrigger="PropertyChanged"
                                     ValidatesOnDataErrors="True"
                                     NotifyOnValidationError="True">
                                <Binding.ValidationRules>
                                    <validation:DoubleValueValidationRule />
                                </Binding.ValidationRules>
                            </Binding>
                        </TextBox.Text>
                    </TextBox>
                </Grid>
            </ControlTemplate>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPadding), Mode=OneWay}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <ContentControl x:Name="ItemGrid"
                        MinWidth="250"
                        Grid.Column="0">
            <ContentControl.Style>
                <Style TargetType="{x:Type ContentControl}">
                    <Setter Property="Content" x:Name="Fallback">
                        <Setter.Value>
                            <TextBlock Text="{Binding State}"
                                       Style="{StaticResource NormalTextStyle}" />
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers><commit_msg>minor adjustment<commit_after>﻿<UserControl x:Class="OpenHab.Wpf.View.Controls.ItemControl"
             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:viewModels="clr-namespace:OpenHab.Wpf.ViewModel.ViewModels;assembly=OpenHab.Wpf.ViewModel"
             xmlns:constants="clr-namespace:OpenHAB.NetRestApi.Constants;assembly=OpenHAB.NetRestApi"
             xmlns:p="clr-namespace:OpenHab.Wpf.View.Properties"
             xmlns:validation="clr-namespace:OpenHab.Wpf.View.Resources.Helpers.Validation"
             xmlns:params="http://schemas.codeplex.com/elysium/params"
             xmlns:extraFixed="clr-namespace:OpenHab.Wpf.View.Resources.Helpers.ElysiumDragFix"
             xmlns:controls="clr-namespace:OpenHab.Wpf.View.Controls"
             xmlns:extra="http://schemas.extra.com/ui"
             mc:Ignorable="d"
             d:DesignHeight="50" d:DesignWidth="500"
             d:DataContext="{d:DesignInstance Type={x:Type viewModels:ItemViewModel}, 
                                              IsDesignTimeCreatable=False}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/BaseResources.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <ControlTemplate x:Key="DimmerControlTemplate">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid Row="0"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0"
                                   Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPadding), Mode=OneWay}"
                                   HorizontalAlignment="Left"
                                   Text="{Binding Label}" />

                        <TextBlock Grid.Column="1"
                                   Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPadding), Mode=OneWay}"
                                   HorizontalAlignment="Right"
                                   Text="{Binding State, StringFormat={}{0}%}" />
                    </Grid>

                    <Grid Row="1"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                        <Slider
                            Value="{Binding State, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,                                                                         
                                        Converter={StaticResource StateToDimmerConverter}}"
                            Minimum="0"
                            Maximum="100"
                            Ticks="1"
                            IsMoveToPointEnabled="True"
                            PreviewMouseUp="DimmerSlider_OnPreviewMouseUp"
                            Thumb.DragDelta="DimmerSlider_OnDragDelta"
                            Thumb.DragCompleted="DimmerSlider_OnDragCompleted" />
                    </Grid>
                </Grid>
            </ControlTemplate>

            <ControlTemplate x:Key="ColorControlTemplate">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Column="0"
                               Grid.Row="0"
                               Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Style="{StaticResource NormalTextStyle}"
                               Text="{x:Static p:Resources.Color}" />

                    <TextBlock Grid.Column="0"
                               Grid.Row="1"
                               Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Style="{StaticResource NormalTextStyle}"
                               Text="{x:Static p:Resources.Saturation}" />

                    <TextBlock Grid.Column="0"
                               Grid.Row="2"
                               Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Style="{StaticResource NormalTextStyle}"
                               Text="{x:Static p:Resources.Brightness}" />

                    <Grid Column="1" Row="0" VerticalAlignment="Center"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                          Background="{StaticResource HorzontalColorHueBrush}">
                        <Slider
                            Value="{Binding State, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,                                                                         
                                        Converter={StaticResource StateToColorConverter}, 
                                        ConverterParameter=0}"
                            Minimum="0"
                            Maximum="360"
                            Ticks="1"
                            IsMoveToPointEnabled="True"
                            PreviewMouseUp="ColorHueSlider_OnPreviewMouseUp"
                            Thumb.DragDelta="ColorHueSlider_OnDragDelta"
                            Thumb.DragCompleted="ColorHueSlider_OnDragCompleted" />
                    </Grid>

                    <Grid Column="1" Row="1" VerticalAlignment="Center"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                        <Slider
                            Value="{Binding State, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,                                                                         
                                        Converter={StaticResource StateToColorConverter}, 
                                        ConverterParameter=1}"
                            Minimum="0"
                            Maximum="100"
                            Ticks="1"
                            IsMoveToPointEnabled="True"
                            PreviewMouseUp="ColorSaturationSlider_OnPreviewMouseUp"
                            Thumb.DragDelta="ColorSaturationSlider_OnDragDelta"
                            Thumb.DragCompleted="ColorSaturationSlider_OnDragCompleted" />
                    </Grid>

                    <Grid Column="1" Row="2" VerticalAlignment="Center"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                        <Slider
                            Value="{Binding State, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,                                                                         
                                        Converter={StaticResource StateToColorConverter}, 
                                        ConverterParameter=2}"
                            Minimum="0"
                            Maximum="100"
                            Ticks="1"
                            IsMoveToPointEnabled="True"
                            PreviewMouseUp="ColorBrightnessSlider_OnPreviewMouseUp"
                            Thumb.DragDelta="ColorBrightnessSlider_OnDragDelta"
                            Thumb.DragCompleted="ColorBrightnessSlider_OnDragCompleted" />
                    </Grid>
                </Grid>
            </ControlTemplate>

            <ControlTemplate x:Key="NumberControlTemplate">
                <Grid Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Column="0"
                               Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Style="{StaticResource NormalTextStyle}"
                               Text="{Binding Label}" />

                    <TextBox Grid.Column="1"
                             Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                             MinWidth="50"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Center"
                             HorizontalContentAlignment="Right"
                             PreviewKeyDown="NumberTextBox_OnPreviewKeyDown">
                        <TextBox.Text>
                            <Binding Path="State"
                                     UpdateSourceTrigger="PropertyChanged"
                                     ValidatesOnDataErrors="True"
                                     NotifyOnValidationError="True">
                                <Binding.ValidationRules>
                                    <validation:DoubleValueValidationRule />
                                </Binding.ValidationRules>
                            </Binding>
                        </TextBox.Text>
                    </TextBox>
                </Grid>
            </ControlTemplate>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPadding), Mode=OneWay}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <ContentControl x:Name="ItemGrid"
                        MinWidth="200"
                        Grid.Column="0">
            <ContentControl.Style>
                <Style TargetType="{x:Type ContentControl}">
                    <Setter Property="Content" x:Name="Fallback">
                        <Setter.Value>
                            <TextBlock Text="{Binding State}"
                                       Style="{StaticResource NormalTextStyle}" />
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
{'fraction_non_alphanumeric': 0.09143241312660196, 'fraction_numerical': 0.005798562964830455, 'mean_word_length': 1.2389463781749765, 'pattern_counts': {'":': 0, '<': 171, '<?xml version=': 0, '>': 171, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 26}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 64, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3222589', 'n_tokens_mistral': 5267, 'n_tokens_neox': 4772, 'n_words': 640}