summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Controls
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-05-20 02:07:56 +0000
committersr55 <[email protected]>2012-05-20 02:07:56 +0000
commita74a875a44e65737bf1b913d94c806498aac1efe (patch)
treef44711db67fcb8ada728df0d1f64355d0d89ea1d /win/CS/HandBrakeWPF/Controls
parent332f03f3f68dca799a2e50ceb7e34578ac0bcd5f (diff)
WinGui: Status overlay when scanning. Not sure if this is going to stay, just experimenting with ideas.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4690 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/Controls')
-rw-r--r--win/CS/HandBrakeWPF/Controls/Loading.xaml106
-rw-r--r--win/CS/HandBrakeWPF/Controls/Loading.xaml.cs157
-rw-r--r--win/CS/HandBrakeWPF/Controls/StatusPanel.xaml28
-rw-r--r--win/CS/HandBrakeWPF/Controls/StatusPanel.xaml.cs73
4 files changed, 364 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Controls/Loading.xaml b/win/CS/HandBrakeWPF/Controls/Loading.xaml
new file mode 100644
index 000000000..4df223108
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Controls/Loading.xaml
@@ -0,0 +1,106 @@
+<UserControl x:Class="HandBrakeWPF.Controls.Loading"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ Background="Transparent"
+ Height="45"
+ Width="45">
+
+ <Viewbox Width="40" Height="40" HorizontalAlignment="Center" VerticalAlignment="Center">
+ <Grid Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center">
+ <Canvas RenderTransformOrigin="0.5,0.5"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center"
+ Width="120"
+ Height="120"
+ Loaded="CanvasLoaded"
+ Unloaded="CanvasUnloaded">
+
+ <Ellipse x:Name="circle0"
+ Width="20"
+ Height="20"
+ Canvas.Left="0"
+ Canvas.Top="0"
+ Stretch="Fill"
+ Fill="DarkOrange"
+ Opacity="1.0" />
+
+ <Ellipse x:Name="circle1"
+ Width="20"
+ Height="20"
+ Canvas.Left="0"
+ Canvas.Top="0"
+ Stretch="Fill"
+ Fill="DarkOrange"
+ Opacity="0.9" />
+
+ <Ellipse x:Name="circle2"
+ Width="20"
+ Height="20"
+ Canvas.Left="0"
+ Canvas.Top="0"
+ Stretch="Fill"
+ Fill="DarkOrange"
+ Opacity="0.8" />
+
+ <Ellipse x:Name="circle3"
+ Width="20"
+ Height="20"
+ Canvas.Left="0"
+ Canvas.Top="0"
+ Stretch="Fill"
+ Fill="DarkOrange"
+ Opacity="0.7" />
+
+ <Ellipse x:Name="circle4"
+ Width="20"
+ Height="20"
+ Canvas.Left="0"
+ Canvas.Top="0"
+ Stretch="Fill"
+ Fill="DarkOrange"
+ Opacity="0.6" />
+
+ <Ellipse x:Name="circle5"
+ Width="20"
+ Height="20"
+ Canvas.Left="0"
+ Canvas.Top="0"
+ Stretch="Fill"
+ Fill="DarkOrange"
+ Opacity="0.5" />
+
+ <Ellipse x:Name="circle6"
+ Width="20"
+ Height="20"
+ Canvas.Left="0"
+ Canvas.Top="0"
+ Stretch="Fill"
+ Fill="DarkOrange"
+ Opacity="0.4" />
+
+ <Ellipse x:Name="circle7"
+ Width="20"
+ Height="20"
+ Canvas.Left="0"
+ Canvas.Top="0"
+ Stretch="Fill"
+ Fill="DarkOrange"
+ Opacity="0.3" />
+
+ <Ellipse x:Name="circle8"
+ Width="20"
+ Height="20"
+ Canvas.Left="0"
+ Canvas.Top="0"
+ Stretch="Fill"
+ Fill="DarkOrange"
+ Opacity="0.2" />
+
+ <Canvas.RenderTransform>
+ <RotateTransform x:Name="rotate" Angle="0" />
+ </Canvas.RenderTransform>
+ </Canvas>
+ </Grid>
+ </Viewbox>
+</UserControl>
+
diff --git a/win/CS/HandBrakeWPF/Controls/Loading.xaml.cs b/win/CS/HandBrakeWPF/Controls/Loading.xaml.cs
new file mode 100644
index 000000000..102788492
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Controls/Loading.xaml.cs
@@ -0,0 +1,157 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="Loading.xaml.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Interaction logic for Loading.xaml
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Controls
+{
+ using System.Windows.Threading;
+ using System;
+ using System.Windows;
+ using System.Windows.Controls;
+
+ /// <summary>
+ /// Interaction logic for Loading.xaml
+ /// </summary>
+ public partial class Loading : UserControl
+ {
+ #region Fields
+
+ /// <summary>
+ /// Step
+ /// </summary>
+ private const double Step = Math.PI * 2 / 10.0;
+
+ /// <summary>
+ /// Timer for the spinning effect.
+ /// </summary>
+ private readonly DispatcherTimer timer;
+
+ #endregion
+
+ #region Constructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Loading"/> class.
+ /// </summary>
+ public Loading()
+ {
+ InitializeComponent();
+
+ IsVisibleChanged += OnVisibleChanged;
+
+ this.timer = new DispatcherTimer(DispatcherPriority.ContextIdle, Dispatcher)
+ {
+ Interval = new TimeSpan(0, 0, 0, 0, 75)
+ };
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Sets the position.
+ /// </summary>
+ /// <param name="ellipse">The ellipse.</param>
+ /// <param name="offset">The offset.</param>
+ /// <param name="posOffSet">The pos off set.</param>
+ /// <param name="step">The step to change.</param>
+ private static void SetPosition(DependencyObject ellipse, double offset, double posOffSet, double step)
+ {
+ ellipse.SetValue(Canvas.LeftProperty, 50 + (Math.Sin(offset + (posOffSet * step)) * 50));
+ ellipse.SetValue(Canvas.TopProperty, 50 + (Math.Cos(offset + (posOffSet * step)) * 50));
+ }
+
+ /// <summary>
+ /// Starts this instance.
+ /// </summary>
+ private void Start()
+ {
+ this.timer.Tick += this.OnTick;
+ this.timer.Start();
+ }
+
+ /// <summary>
+ /// Stops this instance.
+ /// </summary>
+ private void Stop()
+ {
+ this.timer.Stop();
+ this.timer.Tick -= this.OnTick;
+ }
+
+ /// <summary>
+ /// Run the Animation
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void OnTick(object sender, EventArgs e)
+ {
+ this.rotate.Angle = (this.rotate.Angle + 36) % 360;
+ }
+
+ /// <summary>
+ /// Start and Stop the effect when the visibility changes
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void OnVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ if ((bool)e.NewValue)
+ {
+ Start();
+ }
+ else
+ {
+ Stop();
+ }
+ }
+
+ /// <summary>
+ /// Setup the Canvas
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void CanvasLoaded(object sender, RoutedEventArgs e)
+ {
+ SetPosition(this.circle0, Math.PI, 0.0, Step);
+ SetPosition(this.circle1, Math.PI, 1.0, Step);
+ SetPosition(this.circle2, Math.PI, 2.0, Step);
+ SetPosition(this.circle3, Math.PI, 3.0, Step);
+ SetPosition(this.circle4, Math.PI, 4.0, Step);
+ SetPosition(this.circle5, Math.PI, 5.0, Step);
+ SetPosition(this.circle6, Math.PI, 6.0, Step);
+ SetPosition(this.circle7, Math.PI, 7.0, Step);
+ SetPosition(this.circle8, Math.PI, 8.0, Step);
+ }
+
+ /// <summary>
+ /// Stop when we unload this canvas
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void CanvasUnloaded(object sender, RoutedEventArgs e)
+ {
+ Stop();
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Controls/StatusPanel.xaml b/win/CS/HandBrakeWPF/Controls/StatusPanel.xaml
new file mode 100644
index 000000000..481c2eedb
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Controls/StatusPanel.xaml
@@ -0,0 +1,28 @@
+<UserControl x:Class="HandBrakeWPF.Controls.StatusPanel"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:ctr="clr-namespace:HandBrakeWPF.Controls">
+
+ <UserControl.Resources>
+ <BooleanToVisibilityConverter x:Key="boolTovisibility" />
+ </UserControl.Resources>
+
+ <DockPanel Background="Black" Opacity="0.85"
+ Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}},
+ Path=IsLoading, Mode=OneWay, Converter={StaticResource boolTovisibility}}">
+
+ <ctr:Loading DockPanel.Dock="Left" HorizontalAlignment="Left" VerticalAlignment="Top"
+ Height="45" Margin="18,10" />
+
+ <StackPanel VerticalAlignment="Top">
+ <TextBlock SnapsToDevicePixels="True" VerticalAlignment="Top" FontSize="16" Margin="0,11,0,0" HorizontalAlignment="Left"
+ FontWeight="Bold"
+ Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Message}"
+ Foreground="LightBlue" />
+
+ <TextBlock SnapsToDevicePixels="True" VerticalAlignment="Top" FontSize="12" Margin="0,5" HorizontalAlignment="Left"
+ Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=SubMessage}"
+ Foreground="LightBlue" />
+ </StackPanel>
+ </DockPanel>
+</UserControl>
diff --git a/win/CS/HandBrakeWPF/Controls/StatusPanel.xaml.cs b/win/CS/HandBrakeWPF/Controls/StatusPanel.xaml.cs
new file mode 100644
index 000000000..92ca002d5
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Controls/StatusPanel.xaml.cs
@@ -0,0 +1,73 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="StatusPanel.xaml.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Interaction logic for StatusPanel.xaml
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Controls
+{
+ using System.Windows;
+ using System.Windows.Controls;
+
+ /// <summary>
+ /// Interaction logic for StatusPanel.xaml
+ /// </summary>
+ public partial class StatusPanel : UserControl
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="StatusPanel"/> class.
+ /// </summary>
+ public StatusPanel()
+ {
+ InitializeComponent();
+ }
+
+ /// <summary>
+ /// Dependancy Property for the IsLoading Property
+ /// </summary>
+ public static readonly DependencyProperty IsLoadingProperty =
+ DependencyProperty.Register("IsLoading", typeof(bool), typeof(StatusPanel), new UIPropertyMetadata(false));
+
+ /// <summary>
+ /// Dependancy Property for the Message Property
+ /// </summary>
+ public static readonly DependencyProperty MessageProperty =
+ DependencyProperty.Register("Message", typeof(string), typeof(StatusPanel), new UIPropertyMetadata(string.Empty));
+
+ /// <summary>
+ /// Dependancy Property for the submessage propery
+ /// </summary>
+ public static readonly DependencyProperty SubMessageProperty =
+ DependencyProperty.Register("SubMessage", typeof(string), typeof(StatusPanel), new UIPropertyMetadata(string.Empty));
+
+ /// <summary>
+ /// Gets or sets a value indicating whether IsLoading.
+ /// </summary>
+ public bool IsLoading
+ {
+ get { return (bool)GetValue(IsLoadingProperty); }
+ set { SetValue(IsLoadingProperty, value); }
+ }
+
+ /// <summary>
+ /// Gets or sets Message.
+ /// </summary>
+ public string Message
+ {
+ get { return (string)GetValue(MessageProperty); }
+ set { SetValue(MessageProperty, value); }
+ }
+
+ /// <summary>
+ /// Gets or sets SubMessage.
+ /// </summary>
+ public string SubMessage
+ {
+ get { return (string)GetValue(SubMessageProperty); }
+ set { SetValue(SubMessageProperty, value); }
+ }
+ }
+}