From 2b3338cc4398ba8682c5b3855af1ab05a01e3072 Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Sun, 6 Aug 2017 23:33:01 +0300 Subject: [PATCH] dark theme; wip videopleyer --- .../QuickLook.Plugin.VideoViewer/Plugin.cs | 2 + .../QuickLook.Plugin.VideoViewer/Styles.xaml | 53 ++++-- .../ViewerPanel.xaml | 166 +++++------------- .../ViewerPanel.xaml.cs | 3 - QuickLook/Actions/ConditionalEventTrigger.cs | 103 ----------- QuickLook/Controls/GlassLayer/GlassLayer.xaml | 4 +- .../Controls/GlassLayer/GlassLayer.xaml.cs | 40 ++++- QuickLook/Helpers/ProcessHelper.cs | 2 +- QuickLook/MainWindowTransparent.xaml | 27 ++- QuickLook/MainWindowTransparent.xaml.cs | 59 +++++-- QuickLook/Plugin/ContextObject.cs | 23 ++- QuickLook/Plugin/InfoPanel/InfoPanel.xaml | 1 - QuickLook/Plugin/InfoPanel/Plugin.cs | 2 +- QuickLook/QuickLook.csproj | 5 +- QuickLook/Styles/MainWindowStyles.Dark.xaml | 15 ++ QuickLook/Styles/MainWindowStyles.xaml | 26 ++- 16 files changed, 227 insertions(+), 304 deletions(-) delete mode 100644 QuickLook/Actions/ConditionalEventTrigger.cs create mode 100644 QuickLook/Styles/MainWindowStyles.Dark.xaml diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs index 0315b41..ad69e23 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs @@ -69,6 +69,8 @@ namespace QuickLook.Plugin.VideoViewer windowSize.Height = Math.Max(def.Height, windowSize.Height); context.SetPreferredSizeFit(windowSize, 0.6); + context.UseDarkTheme = true; + context.TitlebarOverlap = true; } public void View(string path, ContextObject context) diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Styles.xaml b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Styles.xaml index 6cb4b08..7ece212 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Styles.xaml +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Styles.xaml @@ -1,31 +1,51 @@ - - - + + - + @@ -49,12 +69,12 @@ - + - - + @@ -73,10 +93,11 @@ - - - + + + + diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml index 2de3aa4..78bd3eb 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml @@ -6,9 +6,9 @@ xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:vlc="clr-namespace:Meta.Vlc.Wpf;assembly=Meta.Vlc.Wpf" xmlns:local="clr-namespace:QuickLook.Plugin.VideoViewer" + xmlns:glassLayer="clr-namespace:QuickLook.Controls.GlassLayer;assembly=QuickLook" mc:Ignorable="d" x:Name="viewerPanel" - Background="#CC4E4E4E" d:DesignHeight="450" d:DesignWidth="450"> @@ -43,128 +43,48 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs index 251ac66..fe18b5f 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs @@ -60,9 +60,6 @@ namespace QuickLook.Plugin.VideoViewer // buttonMute.Visibility = Visibility.Collapsed; //}; buttonMute.MouseLeftButtonUp += (sender, e) => IsMuted = !IsMuted; - buttonStop.MouseLeftButtonUp += PlayerStop; - buttonBackward.MouseLeftButtonUp += (sender, e) => Seek(TimeSpan.FromSeconds(-10)); - buttonForward.MouseLeftButtonUp += (sender, e) => Seek(TimeSpan.FromSeconds(10)); sliderProgress.PreviewMouseDown += (sender, e) => { diff --git a/QuickLook/Actions/ConditionalEventTrigger.cs b/QuickLook/Actions/ConditionalEventTrigger.cs deleted file mode 100644 index 72aa004..0000000 --- a/QuickLook/Actions/ConditionalEventTrigger.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright © 2017 Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.Windows; -using System.Windows.Markup; - -namespace QuickLook.Actions -{ - [ContentProperty("Actions")] - public class ConditionalEventTrigger : FrameworkContentElement - { - public static readonly DependencyProperty ConditionProperty = - DependencyProperty.Register("Condition", typeof(bool), typeof(ConditionalEventTrigger)); - - public static readonly DependencyProperty TriggersProperty = DependencyProperty.RegisterAttached("Triggers", - typeof(ConditionalEventTriggerCollection), typeof(ConditionalEventTrigger), new PropertyMetadata - { - PropertyChangedCallback = (obj, e) => - { - // When "Triggers" is set, register handlers for each trigger in the list - var element = (FrameworkElement) obj; - var triggers = (List) e.NewValue; - foreach (var trigger in triggers) - element.AddHandler(trigger.RoutedEvent, new RoutedEventHandler((obj2, e2) => - trigger.OnRoutedEvent(element))); - } - }); - - private static readonly RoutedEvent TriggerActionsEvent = EventManager.RegisterRoutedEvent("", - RoutingStrategy.Direct, - typeof(EventHandler), typeof(ConditionalEventTrigger)); - - public ConditionalEventTrigger() - { - Actions = new List(); - } - - public RoutedEvent RoutedEvent { get; set; } - public List Actions { get; set; } - - // Condition - public bool Condition - { - get => (bool) GetValue(ConditionProperty); - set => SetValue(ConditionProperty, value); - } - - // "Triggers" attached property - public static ConditionalEventTriggerCollection GetTriggers(DependencyObject obj) - { - return (ConditionalEventTriggerCollection) obj.GetValue(TriggersProperty); - } - - public static void SetTriggers(DependencyObject obj, ConditionalEventTriggerCollection value) - { - obj.SetValue(TriggersProperty, value); - } - - // When an event fires, check the condition and if it is true fire the actions - private void OnRoutedEvent(FrameworkElement element) - { - DataContext = element.DataContext; // Allow data binding to access element properties - if (Condition) - { - // Construct an EventTrigger containing the actions, then trigger it - var dummyTrigger = new EventTrigger {RoutedEvent = TriggerActionsEvent}; - foreach (var action in Actions) - dummyTrigger.Actions.Add(action); - - element.Triggers.Add(dummyTrigger); - try - { - element.RaiseEvent(new RoutedEventArgs(TriggerActionsEvent)); - } - finally - { - element.Triggers.Remove(dummyTrigger); - } - } - } - } - - // Create collection type visible to XAML - since it is attached we cannot construct it in code - public class ConditionalEventTriggerCollection : List - { - } -} \ No newline at end of file diff --git a/QuickLook/Controls/GlassLayer/GlassLayer.xaml b/QuickLook/Controls/GlassLayer/GlassLayer.xaml index 4cb963e..56e85cd 100644 --- a/QuickLook/Controls/GlassLayer/GlassLayer.xaml +++ b/QuickLook/Controls/GlassLayer/GlassLayer.xaml @@ -15,8 +15,8 @@ Viewport="0,0,100,100" TileMode="FlipY" Stretch="UniformToFill" /> - + . +using System.Drawing; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using QuickLook.Helpers; +using Color = System.Windows.Media.Color; +using Size = System.Windows.Size; namespace QuickLook.Controls.GlassLayer { @@ -56,25 +59,44 @@ namespace QuickLook.Controls.GlassLayer #endregion public Visual BlurredElement - #region public Visibility GrayOverlayVisibility + #region public SolidColorBrush OverlayColor /// - /// Identifies the GrayOverlayVisibility dependency property. + /// Identifies the OverlayColor dependency property. /// - public static DependencyProperty GrayOverlayVisibilityProperty = - DependencyProperty.Register("GrayOverlayVisibility", typeof(Visibility), typeof(GlassLayer), - new UIPropertyMetadata(Visibility.Visible)); + public static DependencyProperty OverlayColorProperty = + DependencyProperty.Register("OverlayColor", typeof(SolidColorBrush), typeof(GlassLayer), + new UIPropertyMetadata(new SolidColorBrush(Color.FromRgb(0xDA, 0xDA, 0xDA)))); /// /// - public Visibility GrayOverlayVisibility + public SolidColorBrush OverlayColor { - get => (Visibility) GetValue(GrayOverlayVisibilityProperty); + + get => (SolidColorBrush) GetValue(OverlayColorProperty); - set => SetValue(GrayOverlayVisibilityProperty, value); + set => SetValue(OverlayColorProperty, value); } - #endregion public Visibility GrayOverlayVisibility + #endregion public SolidColorBrush OverlayColor + + #region public Visibility ColorOverlayVisibility + + /// + /// Identifies the ColorOverlayVisibilityProperty dependency property. + /// + public static DependencyProperty ColorOverlayVisibilityProperty = + DependencyProperty.Register("ColorOverlayVisibility", typeof(Visibility), typeof(GlassLayer), + new UIPropertyMetadata(Visibility.Visible)); + + public Visibility ColorOverlayVisibility + { + get => (Visibility) GetValue(ColorOverlayVisibilityProperty); + + set => SetValue(ColorOverlayVisibilityProperty, value); + } + + #endregion public Visibility ColorOverlayVisibility #region public Visibility NoiseVisibility diff --git a/QuickLook/Helpers/ProcessHelper.cs b/QuickLook/Helpers/ProcessHelper.cs index 726b6a3..f469877 100644 --- a/QuickLook/Helpers/ProcessHelper.cs +++ b/QuickLook/Helpers/ProcessHelper.cs @@ -29,7 +29,7 @@ namespace QuickLook.Helpers public static void PerformAggressiveGC() { // delay some time to make sure that all windows are closed - Task.Delay(1000).ContinueWith(t => GC.Collect(GC.MaxGeneration)); + Task.Delay(2000).ContinueWith(t => GC.Collect(GC.MaxGeneration)); } public static bool IsRunningAsUWP() diff --git a/QuickLook/MainWindowTransparent.xaml b/QuickLook/MainWindowTransparent.xaml index 5943b9d..fc837b7 100644 --- a/QuickLook/MainWindowTransparent.xaml +++ b/QuickLook/MainWindowTransparent.xaml @@ -8,7 +8,6 @@ xmlns:glassLayer="clr-namespace:QuickLook.Controls.GlassLayer" xmlns:converters="clr-namespace:QuickLook.Converters" xmlns:controls="clr-namespace:QuickLook.Controls" - xmlns:actions="clr-namespace:QuickLook.Actions" mc:Ignorable="d" x:Class="QuickLook.MainWindowTransparent" x:Name="mainWindow" UseLayoutRounding="True" d:DesignWidth="624" d:DesignHeight="700" @@ -34,6 +33,9 @@ - - - + Color="{DynamicResource MainWindowShadowColor}" /> - @@ -86,17 +84,17 @@ - +