aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Managers/IStatusManager.cs
blob: 691e573ec8e563e9111e9f843edb540c37578cc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.AzureUtils.UI.Managers
{
    public interface IStatusManager
    {
        event EventHandler<AzureUtilsProgressEventArgs> StatusUpdated;

        void UpdateStatus(AzureUtilsStage stage, String message, bool isIndeterminate = false);

        void UpdateStatus(AzureUtilsProgressEventArgs progress);

        void UpdateStatus(Exception ex);
    }
}
ghlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* 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.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
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;

namespace Tango.Touch.Controls
{
    public class TouchToggleSlider : ToggleButton
    {
        private Grid _grid_ellipse;

        static TouchToggleSlider()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchToggleSlider), new FrameworkPropertyMetadata(typeof(TouchToggleSlider)));
        }

        public CornerRadius CornerRadius
        {
            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
            set { SetValue(CornerRadiusProperty, value); }
        }
        public static readonly DependencyProperty CornerRadiusProperty =
            DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(TouchToggleSlider), new PropertyMetadata(default(CornerRadius)));

        public Brush ThumbBrush
        {
            get { return (Brush)GetValue(ThumbBrushProperty); }
            set { SetValue(ThumbBrushProperty, value); }
        }
        public static readonly DependencyProperty ThumbBrushProperty =
            DependencyProperty.Register("ThumbBrush", typeof(Brush), typeof(TouchToggleSlider), new PropertyMetadata(null));

        public Object UncheckedContent
        {
            get { return (Object)GetValue(UncheckedContentProperty); }
            set { SetValue(UncheckedContentProperty, value); }
        }
        public static readonly DependencyProperty UncheckedContentProperty =
            DependencyProperty.Register("UncheckedContent", typeof(Object), typeof(TouchToggleSlider), new PropertyMetadata(null));

        public Object CheckedContent
        {
            get { return (Object)GetValue(CheckedContentProperty); }
            set { SetValue(CheckedContentProperty, value); }
        }
        public static readonly DependencyProperty CheckedContentProperty =
            DependencyProperty.Register("CheckedContent", typeof(Object), typeof(TouchToggleSlider), new PropertyMetadata(null));

        public Object UncheckedThumbContent
        {
            get { return (Object)GetValue(UncheckedThumbContentProperty); }
            set { SetValue(UncheckedThumbContentProperty, value); }
        }
        public static readonly DependencyProperty UncheckedThumbContentProperty =
            DependencyProperty.Register("UncheckedThumbContent", typeof(Object), typeof(TouchToggleSlider), new PropertyMetadata(null));

        public Object CheckedThumbContent
        {
            get { return (Object)GetValue(CheckedThumbContentProperty); }
            set { SetValue(CheckedThumbContentProperty, value); }
        }
        public static readonly DependencyProperty CheckedThumbContentProperty =
            DependencyProperty.Register("CheckedThumbContent", typeof(Object), typeof(TouchToggleSlider), new PropertyMetadata(null));

        public Brush UncheckedBackground
        {
            get { return (Brush)GetValue(UncheckedBackgroundProperty); }
            set { SetValue(UncheckedBackgroundProperty, value); }
        }
        public static readonly DependencyProperty UncheckedBackgroundProperty =
            DependencyProperty.Register("UncheckedBackground", typeof(Brush), typeof(TouchToggleSlider), new PropertyMetadata(null));

        public Brush CheckedBackground
        {
            get { return (Brush)GetValue(CheckedBackgroundProperty); }
            set { SetValue(CheckedBackgroundProperty, value); }
        }
        public static readonly DependencyProperty CheckedBackgroundProperty =
            DependencyProperty.Register("CheckedBackground", typeof(Brush), typeof(TouchToggleSlider), new PropertyMetadata(null));

        public DataTemplate UncheckedThumbContentTemplate
        {
            get { return (DataTemplate)GetValue(UncheckedThumbContentTemplateProperty); }
            set { SetValue(UncheckedThumbContentTemplateProperty, value); }
        }
        public static readonly DependencyProperty UncheckedThumbContentTemplateProperty =
            DependencyProperty.Register("UncheckedThumbContentTemplate", typeof(DataTemplate), typeof(TouchToggleSlider), new PropertyMetadata(null));

        public DataTemplate CheckedThumbContentTemplate
        {
            get { return (DataTemplate)GetValue(CheckedThumbContentTemplateProperty); }
            set { SetValue(CheckedThumbContentTemplateProperty, value); }
        }
        public static readonly DependencyProperty CheckedThumbContentTemplateProperty =
            DependencyProperty.Register("CheckedThumbContentTemplate", typeof(DataTemplate), typeof(TouchToggleSlider), new PropertyMetadata(null));

        public TouchToggleSlider()
        {
            Loaded += TouchToggleSlider_Loaded;
        }

        private void TouchToggleSlider_Loaded(object sender, RoutedEventArgs e)
        {
            SetThumbPosition();
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _grid_ellipse = GetTemplateChild("PART_GridEllipse") as Grid;
        }

        protected override void OnChecked(RoutedEventArgs e)
        {
            base.OnChecked(e);
            SetThumbPosition();
        }

        protected override void OnUnchecked(RoutedEventArgs e)
        {
            base.OnUnchecked(e);
            SetThumbPosition();
        }

        private void SetThumbPosition()
        {
            if (_grid_ellipse != null)
            {
                ThicknessAnimation ani = new ThicknessAnimation();
                ani.Duration = TimeSpan.FromSeconds(0.2);

                if (IsChecked.Value)
                {
                    ani.To = new Thickness(ActualWidth - _grid_ellipse.ActualWidth - 4, 0, 0, 0);
                }
                else
                {
                    ani.To = new Thickness(0, 0, 0, 0);
                }

                _grid_ellipse.BeginAnimation(Grid.MarginProperty, ani);
            }
        }
    }
}