aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/GeneralGuideView.xaml.cs
blob: 10b5337ce379cedf319473aff7095d04145ddaeb (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
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;

namespace Tango.PPC.Maintenance.Views
{
    /// <summary>
    /// Interaction logic for GeneralGuideView.xaml
    /// </summary>
    public partial class GeneralGuideView : UserControl
    {
        public GeneralGuideView()
        {
            InitializeComponent();
        }

        private void TouchCheckBox_Loaded(object sender, RoutedEventArgs e)
        {

        }
    }
}
System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Tango.Core.Commands; using Tango.Core.EventArguments; namespace Tango.Touch.Controls { public class TouchStaticListBox : Control { public IList ItemsSource { get { return (IList)GetValue(ItemsSourceProperty); } set { SetValue(ItemsSourceProperty, value); } } public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(IList), typeof(TouchStaticListBox), new PropertyMetadata(null)); public DataTemplate ItemTemplate { get { return (DataTemplate)GetValue(ItemTemplateProperty); } set { SetValue(ItemTemplateProperty, value); } } public static readonly DependencyProperty ItemTemplateProperty = DependencyProperty.Register("ItemTemplate", typeof(DataTemplate), typeof(TouchStaticListBox), new PropertyMetadata(null)); public Style ItemContainerStyle { get { return (Style)GetValue(ItemContainerStyleProperty); } set { SetValue(ItemContainerStyleProperty, value); } } public static readonly DependencyProperty ItemContainerStyleProperty = DependencyProperty.Register("ItemContainerStyle", typeof(Style), typeof(TouchStaticListBox), new PropertyMetadata(null)); public Object SelectedItem { get { return (Object)GetValue(SelectedItemProperty); } set { SetValue(SelectedItemProperty, value); } } public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem", typeof(Object), typeof(TouchStaticListBox), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, (d, e) => (d as TouchStaticListBox).OnSelectdItemChanged())); public RelayCommand<TouchStaticListBoxItem> ListBoxItemLoadedCommand { get { return (RelayCommand<TouchStaticListBoxItem>)GetValue(ListBoxItemLoadedCommandProperty); } set { SetValue(ListBoxItemLoadedCommandProperty, value); } } public static readonly DependencyProperty ListBoxItemLoadedCommandProperty = DependencyProperty.Register("ListBoxItemLoadedCommand", typeof(RelayCommand<TouchStaticListBoxItem>), typeof(TouchStaticListBox), new PropertyMetadata(null)); public ItemsPanelTemplate ItemsPanel { get { return (ItemsPanelTemplate)GetValue(ItemsPanelProperty); } set { SetValue(ItemsPanelProperty, value); } } public static readonly DependencyProperty ItemsPanelProperty = DependencyProperty.Register("ItemsPanel", typeof(ItemsPanelTemplate), typeof(TouchStaticListBox), new PropertyMetadata(null)); static TouchStaticListBox() { DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchStaticListBox), new FrameworkPropertyMetadata(typeof(TouchStaticListBox))); } public TouchStaticListBox() { ListBoxItemLoadedCommand = new RelayCommand<TouchStaticListBoxItem>(RegisterListBoxItemEvents); } private void RegisterListBoxItemEvents(TouchStaticListBoxItem item) { if (item.Tag == null) { item.Tag = 1; item.RegisterForPreviewMouseOrTouchUp(OnItemMouseUp); } } private void OnItemMouseUp(object sender, MouseOrTouchEventArgs e) { var scrollViewer = this.FindAncestor<LightTouchScrollViewer>(); if (scrollViewer != null && scrollViewer.IsAfterScrolling) return; var item = (e.Source is TouchStaticListBoxItem) ? e.Source as TouchStaticListBoxItem : (e.Source as DependencyObject).FindAncestor<TouchStaticListBoxItem>(); SelectedItem = item.DataContext; } private void OnSelectdItemChanged() { var items = GetItems(); items.ForEach(x => x.IsSelected = false); if (SelectedItem != null) { var selected_item = items.FirstOrDefault(x => x.DataContext == SelectedItem); if (selected_item != null) { selected_item.IsSelected = true; } } } private List<TouchStaticListBoxItem> GetItems() { return this.FindVisualChildren<TouchStaticListBoxItem>().ToList(); } } }