diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-05 19:33:06 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-05 19:33:06 +0200 |
| commit | b9009a814b9c91010e44534b42fa15fe164757a3 (patch) | |
| tree | 007aa60379f5a519ce3c3328887c8aec4951931f /Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/ImageGalleryControl.cs | |
| parent | ee3f1aa159ebb326e7c7053501130afa06bf47d4 (diff) | |
| download | Tango-b9009a814b9c91010e44534b42fa15fe164757a3.tar.gz Tango-b9009a814b9c91010e44534b42fa15fe164757a3.zip | |
Completed ThreadBreak/Loading Wizards !!!
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/ImageGalleryControl.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/ImageGalleryControl.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/ImageGalleryControl.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/ImageGalleryControl.cs new file mode 100644 index 000000000..ba2550e25 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/ImageGalleryControl.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +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.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Threading; +using Tango.SharedUI.Controls; + +namespace Tango.PPC.Common.Controls +{ + [ContentProperty(nameof(Elements))] + public class ImageGalleryControl : Control + { + private NavigationControl _navigationControl; + private DispatcherTimer _timer; + + public int SelectedIndex + { + get { return (int)GetValue(SelectedIndexProperty); } + set { SetValue(SelectedIndexProperty, value); } + } + public static readonly DependencyProperty SelectedIndexProperty = + DependencyProperty.Register("SelectedIndex", typeof(int), typeof(ImageGalleryControl), new PropertyMetadata(0)); + + public ObservableCollection<FrameworkElement> Elements + { + get { return (ObservableCollection<FrameworkElement>)GetValue(ElementsProperty); } + set { SetValue(ElementsProperty, value); } + } + public static readonly DependencyProperty ElementsProperty = + DependencyProperty.Register("Elements", typeof(ObservableCollection<FrameworkElement>), typeof(ImageGalleryControl), new PropertyMetadata(null)); + + public Duration Duration + { + get { return (Duration)GetValue(DurationProperty); } + set { SetValue(DurationProperty, value); } + } + public static readonly DependencyProperty DurationProperty = + DependencyProperty.Register("Duration", typeof(Duration), typeof(ImageGalleryControl), new PropertyMetadata(new Duration(TimeSpan.FromSeconds(2)))); + + + static ImageGalleryControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageGalleryControl), new FrameworkPropertyMetadata(typeof(ImageGalleryControl))); + } + + public ImageGalleryControl() + { + Elements = new ObservableCollection<FrameworkElement>(); + Loaded += ImageGalleryControl_Loaded; + + _timer = new DispatcherTimer(); + _timer.Tick += _timer_Tick; + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _navigationControl = GetTemplateChild("navigationControl") as NavigationControl; + } + + private void ImageGalleryControl_Loaded(object sender, RoutedEventArgs e) + { + if (_navigationControl != null) + { + _navigationControl.Elements = Elements; + + _timer.Interval = Duration.TimeSpan; + + if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())) + { + _timer.Start(); + } + } + } + + private void _timer_Tick(object sender, EventArgs e) + { + if (SelectedIndex < Elements.Count - 1) + { + SelectedIndex++; + } + else + { + SelectedIndex = 0; + } + } + + protected override void OnPreviewMouseDown(MouseButtonEventArgs e) + { + base.OnPreviewMouseDown(e); + _timer.Stop(); + } + + protected override void OnPreviewMouseUp(MouseButtonEventArgs e) + { + base.OnPreviewMouseUp(e); + _timer.Start(); + } + } +} |
