aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Views/MainView.xaml
blob: e935b22ec6c5bd8cd114ca2f6ed57db9b8f13902 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<UserControl x:Class="Tango.PPC.Synchronization.Views.MainView"
             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:vm="clr-namespace:Tango.PPC.Synchronization.ViewModels"
             xmlns:global="clr-namespace:Tango.PPC.Synchronization"
             xmlns:local="clr-namespace:Tango.PPC.Synchronization.Views"
             mc:Ignorable="d" 
             d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
    <Grid>
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}">TEST MODULE</TextBlock>
    </Grid>
</UserControl>
f } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using Tango.Core.EventArguments;
using Tango.Logging;
using Tango.PPC.Common;
using Tango.PPC.UI.ViewModels;
using Tango.PPC.UI.ViewsContracts;

namespace Tango.PPC.UI.Views
{
    /// <summary>
    /// Interaction logic for LayoutView.xaml
    /// </summary>
    public partial class LayoutView : UserControl, ILayoutView
    {
        public static LayoutView Instance { get; private set; }
        private LayoutViewVM _vm;
        private System.Timers.Timer _timer;

        public LayoutView()
        {
            InitializeComponent();
            Instance = this;
            Loaded += (_, __) => _vm = DataContext as LayoutViewVM;
            techPressElement.RegisterForPreviewMouseOrTouchDown(OnMouseOrTouchDown);
            techPressElement.RegisterForPreviewMouseOrTouchUp(OnMouseOrTouchUp);
            _timer = new System.Timers.Timer();
            _timer.Interval = TimeSpan.FromSeconds(10).TotalMilliseconds;
            _timer.Elapsed += _timer_Elapsed;

            this.PreviewMouseUp += LayoutView_PreviewMouseUp;
        }

        private void LayoutView_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            _vm.ApplicationManager.ResetScreenLockTimer();
        }

        private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            _timer.Stop();

            Dispatcher.BeginInvoke(new Action(() =>
            {
                _vm.ToggleTechnicianMode();
            }));
        }

        private void OnMouseOrTouchDown(object sender, MouseOrTouchEventArgs e)
        {
            //if (e.TouchDevice != null)
            //{
            //    techPressElement.CaptureTouch(e.TouchDevice);
            //}
            //else
            //{
            //    techPressElement.CaptureMouse();
            //}

            _timer.Start();
        }

        private void OnMouseOrTouchUp(object sender, MouseOrTouchEventArgs e)
        {
            //if (e.TouchDevice != null)
            //{
            //    techPressElement.ReleaseTouchCapture(e.TouchDevice);
            //}
            //else
            //{
            //    techPressElement.ReleaseMouseCapture();
            //}

            _timer.Stop();
        }

        private void Grid_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            _vm.ApplicationManager.ReleaseScreenLock();
        }
    }
}