mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-11 17:59:17 +00:00
Code Cleanup
This commit is contained in:
@@ -29,7 +29,7 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage;
|
||||
public class AnimatedImage : Image, IDisposable
|
||||
{
|
||||
// List<Pair<formats, type>>
|
||||
public static List<KeyValuePair<string[], Type>> Providers = new List<KeyValuePair<string[], Type>>();
|
||||
public static List<KeyValuePair<string[], Type>> Providers = [];
|
||||
|
||||
private AnimationProvider _animation;
|
||||
private bool _disposing;
|
||||
@@ -101,7 +101,7 @@ public class AnimatedImage : Image, IDisposable
|
||||
|
||||
private static void AnimationUriChanged(DependencyObject obj, DependencyPropertyChangedEventArgs ev)
|
||||
{
|
||||
if (!(obj is AnimatedImage instance))
|
||||
if (obj is not AnimatedImage instance)
|
||||
return;
|
||||
|
||||
//var thumbnail = instance.Meta?.GetThumbnail(true);
|
||||
@@ -125,8 +125,8 @@ public class AnimatedImage : Image, IDisposable
|
||||
|
||||
if (_.Result != null)
|
||||
{
|
||||
instance.DoZoomToFit?.Invoke(instance, new EventArgs());
|
||||
instance.ImageLoaded?.Invoke(instance, new EventArgs());
|
||||
instance.DoZoomToFit?.Invoke(instance, EventArgs.Empty);
|
||||
instance.ImageLoaded?.Invoke(instance, EventArgs.Empty);
|
||||
}
|
||||
|
||||
instance.BeginAnimation(AnimationFrameIndexProperty, instance._animation?.Animator);
|
||||
@@ -136,7 +136,7 @@ public class AnimatedImage : Image, IDisposable
|
||||
|
||||
private static void AnimationFrameIndexChanged(DependencyObject obj, DependencyPropertyChangedEventArgs ev)
|
||||
{
|
||||
if (!(obj is AnimatedImage instance))
|
||||
if (obj is not AnimatedImage instance)
|
||||
return;
|
||||
|
||||
if (instance._disposing)
|
||||
@@ -155,8 +155,8 @@ public class AnimatedImage : Image, IDisposable
|
||||
|
||||
if (firstLoad)
|
||||
{
|
||||
instance.DoZoomToFit?.Invoke(instance, new EventArgs());
|
||||
instance.ImageLoaded?.Invoke(instance, new EventArgs());
|
||||
instance.DoZoomToFit?.Invoke(instance, EventArgs.Empty);
|
||||
instance.ImageLoaded?.Invoke(instance, EventArgs.Empty);
|
||||
}
|
||||
}));
|
||||
task.Start();
|
||||
|
@@ -45,12 +45,12 @@ public class Plugin : IViewer
|
||||
".nef", ".nrw",
|
||||
".obm", ".orf",
|
||||
".pbm", ".pef", ".pgm", ".png", ".pnm", ".ppm", ".psd", ".ptx", ".pxn",
|
||||
".qoi",
|
||||
".r3d", ".raf", ".raw", ".rw2", ".rwl", ".rwz",
|
||||
".sr2", ".srf", ".srw", ".svg",
|
||||
".tga", ".tif", ".tiff",
|
||||
".wdp", ".webp", ".wmf",
|
||||
".x3f", ".xcf",
|
||||
".qoi"
|
||||
]);
|
||||
|
||||
private ImagePanel _ip;
|
||||
|
@@ -67,7 +67,7 @@ public partial class PdfViewerControl : UserControl, INotifyPropertyChanged, IDi
|
||||
listThumbnails.SelectedIndex = value;
|
||||
listThumbnails.ScrollIntoView(listThumbnails.SelectedItem);
|
||||
|
||||
CurrentPageChanged?.Invoke(this, new EventArgs());
|
||||
CurrentPageChanged?.Invoke(this, EventArgs.Empty);
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public partial class PdfViewerControl : UserControl, INotifyPropertyChanged, IDi
|
||||
if (CurrentPage == -1)
|
||||
return;
|
||||
|
||||
CurrentPageChanged?.Invoke(this, new EventArgs());
|
||||
CurrentPageChanged?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
ReRenderCurrentPage();
|
||||
|
||||
|
@@ -18,7 +18,7 @@ public class OverDvdButtonEventArgs : EventArgs
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flag that defines if the cursor is over a Dvd butotn
|
||||
/// Flag that defines if the cursor is over a Dvd button
|
||||
/// </summary>
|
||||
public bool IsOverDvdButton { get; private set; }
|
||||
}
|
||||
@@ -242,7 +242,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
/// </summary>
|
||||
public string DvdDirectory
|
||||
{
|
||||
get { return m_dvdDirectory; }
|
||||
get => m_dvdDirectory;
|
||||
set
|
||||
{
|
||||
m_dvdDirectory = value;
|
||||
@@ -255,35 +255,28 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
private void InvokeDvdError(DvdError error)
|
||||
{
|
||||
var e = new DvdErrorArgs { Error = error };
|
||||
var dvdErrorHandler = OnDvdError;
|
||||
if (dvdErrorHandler != null) dvdErrorHandler(this, e);
|
||||
OnDvdError?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void InvokeOnDvdTime(DvdTimeEventArgs e)
|
||||
{
|
||||
var onDvdTimeHandler = OnDvdTime;
|
||||
if (onDvdTimeHandler != null) onDvdTimeHandler(this, e);
|
||||
OnDvdTime?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void InvokeOnOverDvdButton(bool isOverDvdButton)
|
||||
{
|
||||
var e = new OverDvdButtonEventArgs(isOverDvdButton);
|
||||
var onOverDvdButtonHandler = OnOverDvdButton;
|
||||
if (onOverDvdButtonHandler != null) onOverDvdButtonHandler(this, e);
|
||||
OnOverDvdButton?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void InvokeOnDvdInserted()
|
||||
{
|
||||
var e = new EventArgs();
|
||||
var onDvdInsertedHandler = OnDvdInserted;
|
||||
if (onDvdInsertedHandler != null) onDvdInsertedHandler(this, e);
|
||||
OnDvdInserted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void InvokeOnDvdEjected()
|
||||
{
|
||||
var e = new EventArgs();
|
||||
var onDvdEjectedHandler = OnDvdEjected;
|
||||
if (onDvdEjectedHandler != null) onDvdEjectedHandler(this, e);
|
||||
OnDvdEjected?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion Event Invokers
|
||||
@@ -296,10 +289,9 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdControl == null)
|
||||
return;
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.ShowMenu(DvdMenuId.Root,
|
||||
DvdCmdFlags.Block | DvdCmdFlags.Flush,
|
||||
out cmd);
|
||||
out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -317,13 +309,10 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdInfo == null)
|
||||
return 0;
|
||||
|
||||
int volumeCount, currentVolume, titleCount;
|
||||
DvdDiscSide side;
|
||||
|
||||
m_dvdInfo.GetDVDVolumeInfo(out volumeCount,
|
||||
out currentVolume,
|
||||
out side,
|
||||
out titleCount);
|
||||
m_dvdInfo.GetDVDVolumeInfo(out _,
|
||||
out _,
|
||||
out _,
|
||||
out int titleCount);
|
||||
|
||||
return titleCount;
|
||||
}
|
||||
@@ -339,10 +328,9 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdControl == null)
|
||||
return;
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.ShowMenu(DvdMenuId.Title,
|
||||
DvdCmdFlags.Block | DvdCmdFlags.Flush,
|
||||
out cmd);
|
||||
out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -358,8 +346,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdControl == null)
|
||||
return;
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.ReturnFromSubmenu(DvdCmdFlags.None, out cmd);
|
||||
m_dvdControl.ReturnFromSubmenu(DvdCmdFlags.None, out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -376,8 +363,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdControl == null)
|
||||
return;
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.SelectAngle(angle, DvdCmdFlags.None, out cmd);
|
||||
m_dvdControl.SelectAngle(angle, DvdCmdFlags.None, out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -393,8 +379,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdControl == null)
|
||||
return;
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.Resume(DvdCmdFlags.None, out cmd);
|
||||
m_dvdControl.Resume(DvdCmdFlags.None, out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -511,8 +496,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
{
|
||||
VerifyAccess();
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.PlayTitle(titleIndex, DvdCmdFlags.Flush, out cmd);
|
||||
m_dvdControl.PlayTitle(titleIndex, DvdCmdFlags.Flush, out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -528,8 +512,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdControl == null)
|
||||
return;
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.PlayNextChapter(DvdCmdFlags.Flush, out cmd);
|
||||
m_dvdControl.PlayNextChapter(DvdCmdFlags.Flush, out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -546,8 +529,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdControl == null)
|
||||
return;
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.PlayForwards(speed, DvdCmdFlags.None, out cmd);
|
||||
m_dvdControl.PlayForwards(speed, DvdCmdFlags.None, out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -564,8 +546,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdControl == null)
|
||||
return;
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.PlayBackwards(speed, DvdCmdFlags.None, out cmd);
|
||||
m_dvdControl.PlayBackwards(speed, DvdCmdFlags.None, out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -581,8 +562,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
if (m_dvdControl == null)
|
||||
return;
|
||||
|
||||
IDvdCmd cmd;
|
||||
m_dvdControl.PlayPrevChapter(DvdCmdFlags.Flush, out cmd);
|
||||
m_dvdControl.PlayPrevChapter(DvdCmdFlags.Flush, out IDvdCmd cmd);
|
||||
|
||||
if (cmd != null)
|
||||
Marshal.ReleaseComObject(cmd);
|
||||
@@ -616,12 +596,9 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
/* Do some VMR9 specific stuff */
|
||||
if (rendererType == VideoRendererType.VideoMixingRenderer9)
|
||||
{
|
||||
var mixer = m_renderer as IVMRMixerControl9;
|
||||
|
||||
if (mixer != null)
|
||||
if (m_renderer is IVMRMixerControl9 mixer)
|
||||
{
|
||||
VMR9MixerPrefs dwPrefs;
|
||||
mixer.GetMixingPrefs(out dwPrefs);
|
||||
mixer.GetMixingPrefs(out VMR9MixerPrefs dwPrefs);
|
||||
dwPrefs &= ~VMR9MixerPrefs.RenderTargetMask;
|
||||
dwPrefs |= VMR9MixerPrefs.RenderTargetYUV;
|
||||
|
||||
@@ -866,10 +843,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
/// </summary>
|
||||
public override long MediaPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return (long)m_currentDvdTime.TotalMilliseconds * MEDIA_TIME_TO_MILLISECONDS;
|
||||
}
|
||||
get => (long)m_currentDvdTime.TotalMilliseconds * MEDIA_TIME_TO_MILLISECONDS;
|
||||
set
|
||||
{
|
||||
var timeCode = new DvdHMSFTimeCode();
|
||||
@@ -897,8 +871,7 @@ public class DvdPlayer : MediaSeekingPlayer
|
||||
private void SetTitleDuration()
|
||||
{
|
||||
var totalTime = new DvdHMSFTimeCode();
|
||||
DvdTimeCodeFlags flags;
|
||||
int hr = m_dvdInfo.GetTotalTitleTime(totalTime, out flags);
|
||||
int hr = m_dvdInfo.GetTotalTitleTime(totalTime, out DvdTimeCodeFlags flags);
|
||||
|
||||
if (hr != 0)
|
||||
return;
|
||||
|
@@ -737,7 +737,7 @@ public class MediaUriPlayer : MediaSeekingPlayer
|
||||
|
||||
/* Only run the media closed if we have an
|
||||
* initialized filter graph */
|
||||
InvokeMediaClosed(new EventArgs());
|
||||
InvokeMediaClosed(EventArgs.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -608,7 +608,7 @@ public class VideoCapturePlayer : MediaPlayerBase, ISampleGrabberCB
|
||||
Marshal.FinalReleaseComObject(m_graph);
|
||||
m_graph = null;
|
||||
|
||||
InvokeMediaClosed(new EventArgs());
|
||||
InvokeMediaClosed(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -60,9 +60,7 @@ public class WorkDispatcher
|
||||
|
||||
private void InvokeShutdownStarted()
|
||||
{
|
||||
var e = new EventArgs();
|
||||
EventHandler started = ShutdownStarted;
|
||||
if (started != null) started(this, e);
|
||||
ShutdownStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
~WorkDispatcher()
|
||||
@@ -73,8 +71,7 @@ public class WorkDispatcher
|
||||
private ShutdownFinishedEventArgs InvokeShutdownFinished()
|
||||
{
|
||||
var e = new ShutdownFinishedEventArgs();
|
||||
var finished = ShutdownFinished;
|
||||
if (finished != null) finished(this, e);
|
||||
ShutdownFinished?.Invoke(this, e);
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -84,7 +81,7 @@ public class WorkDispatcher
|
||||
/// </summary>
|
||||
public Thread DispatcherThread
|
||||
{
|
||||
get { return m_dispatcherThread; }
|
||||
get => m_dispatcherThread;
|
||||
private set
|
||||
{
|
||||
m_dispatcherThread = value;
|
||||
@@ -96,8 +93,8 @@ public class WorkDispatcher
|
||||
/// </summary>
|
||||
public bool ShuttingDown
|
||||
{
|
||||
get { return m_shuttingDown; }
|
||||
private set { m_shuttingDown = value; }
|
||||
get => m_shuttingDown;
|
||||
private set => m_shuttingDown = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -105,8 +102,8 @@ public class WorkDispatcher
|
||||
/// </summary>
|
||||
public bool Shutdown
|
||||
{
|
||||
get { return m_shutdown; }
|
||||
private set { m_shutdown = value; }
|
||||
get => m_shutdown;
|
||||
private set => m_shutdown = value;
|
||||
}
|
||||
|
||||
public bool ShuttingOrShutDown
|
||||
@@ -186,8 +183,7 @@ public class WorkDispatcher
|
||||
m_threadId = GetCurrentThreadId();
|
||||
|
||||
// Call PeekMessage to create the message queue before the event is set
|
||||
Msg msg;
|
||||
PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
|
||||
PeekMessage(out Msg msg, IntPtr.Zero, 0, 0, 0);
|
||||
resetEvent.Set();
|
||||
|
||||
/* Begins the pump */
|
||||
|
Reference in New Issue
Block a user