aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Controls/TouchScrollViewer.xaml
blob: eda50f8d6681ffce0b162eb25d13d044ab336fc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Tango.Touch.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="../Resources/Colors.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="TouchScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Height="{TemplateBinding Height}" SnapsToDevicePixels="True" Width="{TemplateBinding Width}" CornerRadius="5" Background="#90000000" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TouchScrollBar" TargetType="{x:Type ScrollBar}">
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
        <Setter Property="Background" Value="#33000000"/>
        <Setter Property="BorderBrush" Value="#33000000"/>
        <Setter Property="Foreground" Value="Gray"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Width" Value="5"/>
        <Setter Property="MinWidth" Value="5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid x:Name="Bg" SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" HorizontalAlignment="Right" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Row="1"/>
                        <Track x:Name="PART_Track" IsDirectionReversed="true" HorizontalAlignment="Right" Width="5" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="1">
                            <Track.Thumb>
                                <Thumb Style="{StaticResource TouchScrollBarThumb}"></Thumb>
                            </Track.Thumb>
                        </Track>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:TouchScrollViewer}">
        <Setter Property="HorizontalScrollBarVisibility" Value="Disabled"></Setter>
        <Setter Property="PanningMode" Value="VerticalOnly"></Setter>
        <Setter Property="VerticalScrollBarVisibility" Value="Visible"></Setter>
        <Setter Property="Focusable" Value="False"></Setter>
        <Setter Property="CanContentScroll" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.Row="1"/>
                        <ScrollBar Opacity="0" Grid.Row="1" x:Name="PART_VerticalScrollBar" Style="{StaticResource TouchScrollBar}" HorizontalAlignment="Right" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="ScrollViewer.ScrollChanged">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_VerticalScrollBar" Storyboard.TargetProperty="Opacity" Duration="00:00:01" FillBehavior="Stop">
                                            <EasingDoubleKeyFrame KeyTime="00:00:0.2" Value="1"></EasingDoubleKeyFrame>
                                            <DiscreteDoubleKeyFrame KeyTime="00:00:0.2" Value="1"></DiscreteDoubleKeyFrame>
                                            <EasingDoubleKeyFrame KeyTime="00:00:01" Value="0"></EasingDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
pan class="p">,&ProcessParametersKeep,sizeof(ProcessParameters)); ProcessParameters ProcessParametersClear; ProcessParametersClear.dryerzone1temp = (ActiveProcessParameters.dryerzone1temp<80)? ActiveProcessParameters.dryerzone1temp:IdleDrierTemperature; ProcessParametersClear.dryerzone2temp = (ActiveProcessParameters.dryerzone2temp<80)? ActiveProcessParameters.dryerzone2temp:IdleDrierTemperature; ProcessParametersClear.dryerzone3temp = (ActiveProcessParameters.dryerzone3temp<80)? ActiveProcessParameters.dryerzone3temp:IdleDrierTemperature; ProcessParametersClear.mixertemp = (ActiveProcessParameters.mixertemp <80)? ActiveProcessParameters.mixertemp :IdleMixerTemperature; ProcessParametersClear.headzone1temp = (ActiveProcessParameters.headzone1temp <80)? ActiveProcessParameters.headzone1temp :IdleHeadTemperature; ProcessParametersClear.headzone2temp = (ActiveProcessParameters.headzone2temp <80)? ActiveProcessParameters.headzone2temp :IdleHeadTemperature; ProcessParametersClear.headzone3temp = (ActiveProcessParameters.headzone3temp <80)? ActiveProcessParameters.headzone3temp :IdleHeadTemperature; ProcessParametersClear.headzone4temp = (ActiveProcessParameters.headzone4temp <80)? ActiveProcessParameters.headzone4temp :IdleHeadTemperature; ProcessParametersClear.headzone5temp = (ActiveProcessParameters.headzone5temp <80)? ActiveProcessParameters.headzone5temp :IdleHeadTemperature; ProcessParametersClear.headzone6temp = (ActiveProcessParameters.headzone6temp <80)? ActiveProcessParameters.headzone6temp :IdleHeadTemperature; ProcessParametersClear.dyeingspeed = (ActiveProcessParameters.dyeingspeed <40)? ActiveProcessParameters.dyeingspeed :IdleHeadTemperature; if (HandleProcessParameters(&ProcessParametersClear)!= OK) { LOG_ERROR (1, "Turn Heaters idle failed"); return; } if (BlowerCfg.enabled == true) { Turn_the_Blower_On();//Turn on with the Default_Voltage if (BlowerCfg.heatingvoltage) Control_Voltage_To_Blower(BlowerCfg.heatingvoltage); else Control_Voltage_To_Blower(BlowerCfg.voltage-500); } SetMachineStatus(MACHINE_STATE__Sleep); } uint32_t PowerIdleCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { if (machineActive == true) return OK; if ((powerIdleSecondsCounter%100 == 0)&&(powerIdleSecondsCounter)) Report("PowerIdle Idle counter ",__FILE__,__LINE__,(int)powerIdleSecondsLimit,RpWarning,(int)powerIdleSecondsCounter,0); if (++powerIdleSecondsCounter>=powerIdleSecondsLimit) { if (powerIdleState == false) { Report("PowerIdle Idle activated ",__FILE__,__LINE__,(int)powerIdleSecondsLimit,RpWarning,(int)powerIdleSecondsCounter,0); powerIdleState = true; SetPowerMachineState(sttIDLE); //move to idle state PowerIdleSetIdle(); if (SafeRemoveControlCallback(IdleControlId, PowerIdleCallBackFunction )==OK) IdleControlId = 0xFF; } } return OK; } void PowerIdleInit(void) { IdleControlId = AddControlCallback( PowerIdleCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); if (IdleControlId == 0xFF) Report("AddControlCallback failed",__FILE__,__LINE__,(int)IdleControlId,RpWarning,(int)0,0); Report("PowerIdleInit ",__FILE__,__LINE__,(int)powerIdleSecondsLimit,RpWarning,(int)0,0); } void PowerIdleSetParameters(uint32_t switchtoidletimeinseconds,uint32_t idledriertemperature,uint32_t idleheadtemperature,uint32_t idlemixertemperature) { powerIdleSecondsLimit = switchtoidletimeinseconds; IdleDrierTemperature = idledriertemperature*100; IdleHeadTemperature = idleheadtemperature*100; IdleMixerTemperature = idlemixertemperature*100; } int getIdleCounter (void) {return powerIdleSecondsCounter;} void setIdleLimit (int Limit) {powerIdleSecondsLimit = Limit;} void setmachineActive(bool Active){machineActive = Active;} void resetIdleCounter (void) {powerIdleSecondsCounter = 0;} bool getIdleState (void) {return powerIdleState;} void PowerIdleOutOfIdleState(void) { Report("PowerIdle Out of Idle ",__FILE__,__LINE__,(int)powerIdleSecondsLimit,RpWarning,(int)powerIdleSecondsCounter,0); powerIdleSecondsCounter = 0; if (powerIdleState == true) { powerIdleState = false; SetPowerMachineState(sttON); if (HandleProcessParameters(&ActiveProcessParameters)!= OK) { LOG_ERROR (1, "Turn Heaters active failed"); return ; } if (IdleControlId == 0xFF) IdleControlId = AddControlCallback( PowerIdleCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); if (IdleControlId == 0xFF) Report("AddControlCallback failed",__FILE__,__LINE__,(int)IdleControlId,RpWarning,(int)0,0); SetMachineStatus(MACHINE_STATE__Ready); } } void PowerIdleActivateIdleState(void) { Report("PowerIdle Activate Idle ",__FILE__,__LINE__,(int)machineActive,RpWarning,(int)powerIdleSecondsCounter,0); if (machineActive == true) { LOG_ERROR(machineActive, "machine is active, cannot switch on idle state"); return; } powerIdleSecondsCounter = 0; if (powerIdleState == false) { powerIdleState = true; PowerIdleSetIdle(); } }