Projektdateien hinzufügen.

This commit is contained in:
Kevin Krüger
2023-07-24 12:00:34 +02:00
parent 656751e10b
commit 0d00a90942
210 changed files with 45049 additions and 0 deletions

View File

@@ -0,0 +1,154 @@
namespace VideoBrowser.Common
{
using System;
using System.IO;
using System.Reflection;
/// <summary>
/// Defines the <see cref="AppEnvironment" />.
/// </summary>
public static class AppEnvironment
{
#region Constants
public const string Name = "Cekli Browser";
public const string LongName = "Cekli Video Browser and Downloader";
public const int ProgressUpdateDelay = 250;
public static readonly string ShortName = Assembly.GetExecutingAssembly().GetName().Name;
private const string BinariesDirectory = "Binaries";
private const string JsonDirectory = "Json";
private const string LogsDirectory = "Logs";
#endregion Constants
#region Properties
/// <summary>
/// Gets the AppBinaryDirectory.
/// </summary>
public static string AppBinaryDirectory => Path.Combine(AppDirectory, BinariesDirectory);
/// <summary>
/// Gets the AppDirectory.
/// </summary>
public static string AppDirectory => AppDomain.CurrentDomain.BaseDirectory;
/// <summary>
/// Gets or sets the Arguments.
/// </summary>
public static string[] Arguments { get; internal set; }
/// <summary>
/// Gets the Author.
/// </summary>
public static string Author => "Yohanes Wahyu Nurcahyo";
/// <summary>
/// Gets the HomeUrl.
/// </summary>
public static string HomeUrl => "https://yoyokits.github.io/VideoBrowser/welcome.html";
/// <summary>
/// Gets the ProjectUrl.
/// </summary>
public static string ProjectUrl { get; } = "https://github.com/yoyokits/VideoBrowser";
/// <summary>
/// Gets the UserLocalApplicationData.
/// </summary>
public static string UserLocalApplicationData { get; } = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
/// <summary>
/// Gets the UserProfile.
/// </summary>
public static string UserProfile { get; } = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
/// <summary>
/// Gets the UserVideoFolder.
/// </summary>
public static string UserVideoFolder { get; } = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
/// <summary>
/// Gets the Version.
/// </summary>
public static string Version { get; } = $"{Assembly.GetExecutingAssembly().GetName().Version.ToString()}";
#endregion Properties
#region Methods
/// <summary>
/// Returns the local app data directory for this program. Also makes sure the directory exists.
/// </summary>
/// <returns>The <see cref="string"/>.</returns>
public static string GetAppDataDirectory()
{
var path = Path.Combine(UserLocalApplicationData, AppEnvironment.ShortName);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
return path;
}
/// <summary>
/// The application folder.
/// </summary>
/// <param name="specialFolder">The specialFolder<see cref="Environment.SpecialFolder"/>.</param>
/// <returns>The <see cref="string"/>.</returns>
public static string GetFolder(Environment.SpecialFolder specialFolder) => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
/// <summary>
/// Returns the json directory for this program. Also makes sure the directory exists.
/// </summary>
/// <returns>The <see cref="string"/>.</returns>
public static string GetJsonDirectory()
{
var path = Path.Combine(GetAppDataDirectory(), JsonDirectory);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
return path;
}
/// <summary>
/// Returns the logs directory for this program. Also makes sure the directory exists.
/// </summary>
/// <returns>The <see cref="string"/>.</returns>
public static string GetLogsDirectory()
{
var path = Path.Combine(GetAppDataDirectory(), LogsDirectory);
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
return path;
}
/// <summary>
/// The GetUserLocalApplicationData.
/// </summary>
/// <returns>The <see cref="string"/>.</returns>
public static string GetUserLocalApplicationData()
{
var userFolder = UserLocalApplicationData;
var appFolder = Path.Combine(userFolder, ShortName);
if (!Directory.Exists(appFolder))
{
Directory.CreateDirectory(appFolder);
}
return appFolder;
}
#endregion Methods
}
}

View File

@@ -0,0 +1,135 @@
namespace VideoBrowser.Common
{
using System;
/// <summary>
/// Defines the <see cref="ByteFormatProvider" />
/// </summary>
public class ByteFormatProvider : IFormatProvider, ICustomFormatter
{
#region Constants
private const string FileSizeFormat = "fs";
private const decimal OneGigaByte = OneMegaByte * 1024M;
private const decimal OneKiloByte = 1024M;
private const decimal OneMegaByte = OneKiloByte * 1024M;
private const string SpeedFormat = "s";
#endregion Constants
#region Properties
/// <summary>
/// Gets the Lock
/// </summary>
private object Lock { get; } = new object();
#endregion Properties
#region Methods
/// <summary>
/// The Format
/// </summary>
/// <param name="format">The format<see cref="string"/></param>
/// <param name="arg">The arg<see cref="object"/></param>
/// <param name="formatProvider">The formatProvider<see cref="IFormatProvider"/></param>
/// <returns>The <see cref="string"/></returns>
public string Format(string format, object arg, IFormatProvider formatProvider)
{
lock (this.Lock)
{
if (format == null || (!format.StartsWith(FileSizeFormat) && !format.StartsWith(SpeedFormat)))
{
return DefaultFormat(format, arg, formatProvider);
}
if (arg is string)
{
return DefaultFormat(format, arg, formatProvider);
}
decimal size;
try
{
size = Convert.ToDecimal(arg);
}
catch (InvalidCastException)
{
return DefaultFormat(format, arg, formatProvider);
}
string suffix;
if (size > OneGigaByte)
{
size /= OneGigaByte;
suffix = "GB";
}
else if (size > OneMegaByte)
{
size /= OneMegaByte;
suffix = "MB";
}
else if (size > OneKiloByte)
{
size /= OneKiloByte;
suffix = "KB";
}
else
{
suffix = "Bytes";
}
if (format.StartsWith(SpeedFormat))
{
suffix += "/s";
}
var postion = format.StartsWith(SpeedFormat) ? SpeedFormat.Length : FileSizeFormat.Length;
var precision = format.Substring(postion);
if (string.IsNullOrEmpty(precision))
{
precision = "2";
}
return string.Format("{0:N" + precision + "}{1}", size, " " + suffix);
}
}
/// <summary>
/// The GetFormat
/// </summary>
/// <param name="formatType">The formatType<see cref="Type"/></param>
/// <returns>The <see cref="object"/></returns>
public object GetFormat(Type formatType)
{
return formatType == typeof(ICustomFormatter) ? (this) : null;
}
/// <summary>
/// The DefaultFormat
/// </summary>
/// <param name="format">The format<see cref="string"/></param>
/// <param name="arg">The arg<see cref="object"/></param>
/// <param name="formatProvider">The formatProvider<see cref="IFormatProvider"/></param>
/// <returns>The <see cref="string"/></returns>
private static string DefaultFormat(string format, object arg, IFormatProvider formatProvider)
{
if (arg is IFormattable formattableArg)
{
return formattableArg.ToString(format, formatProvider);
}
return arg.ToString();
}
#endregion Methods
}
}

View File

@@ -0,0 +1,23 @@
namespace VideoBrowser.Common
{
/// <summary>
/// Defines the <see cref="Epsilon" />
/// </summary>
public static class Epsilon
{
/// <summary>
/// The epsilon for angle.
/// </summary>
public const double Angle = 0.01;
/// <summary>
/// The epsilon for default.
/// </summary>
public const double Default = 0.00000000001;
/// <summary>
/// The epsilon for meter.
/// </summary>
public const double Meter = 0.00001;
}
}

169
VideoBrowser/Common/Log.cs Normal file
View File

@@ -0,0 +1,169 @@
namespace VideoBrowser.Common
{
using log4net;
using log4net.Appender;
using log4net.Core;
using log4net.Layout;
using log4net.Repository.Hierarchy;
using System;
using System.IO;
using System.Reflection;
/// <summary>
/// Defines the <see cref="Logging.Logger" />
/// Log the important process to trace the last processes before error occurs.
/// </summary>
public static class Logger
{
#region Constructors
/// <summary>
/// Initializes static members of the <see cref="Logger"/> class.
/// </summary>
static Logger()
{
Setup(nameof(VideoBrowser));
}
#endregion Constructors
#region Properties
/// <summary>
/// Gets the Log.
/// </summary>
public static ILog Log { get; } = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Gets the LogFilePath.
/// </summary>
public static string LogFilePath { get; private set; }
#endregion Properties
#region Methods
/// <summary>
/// The Debug Log.
/// </summary>
/// <param name="message">The message<see cref="object"/>.</param>
public static void Debug(object message)
{
Log.Debug(message);
}
/// <summary>
/// The Error Log.
/// </summary>
/// <param name="message">The message<see cref="object"/>.</param>
public static void Error(object message)
{
Log.Error(message);
}
/// <summary>
/// The Fatal Log.
/// </summary>
/// <param name="message">The message<see cref="object"/>.</param>
public static void Fatal(object message)
{
Log.Fatal(message);
}
/// <summary>
/// The Info.
/// </summary>
/// <param name="message">The message<see cref="object"/>.</param>
public static void Info(object message = null)
{
if (message == null)
{
message = string.Empty;
}
Log.Info(message);
System.Diagnostics.Trace.WriteLine(message);
}
/// <summary>
/// The Info Log.
/// </summary>
/// <param name="source">The source<see cref="object"/>.</param>
/// <param name="message">The message<see cref="object"/>.</param>
public static void Info(this object source, object message)
{
Log.Info(message);
}
/// <summary>
/// The Setup.
/// </summary>
/// <param name="appName">The appName<see cref="string"/>.</param>
public static void Setup(string appName)
{
LogFilePath = GetLogFilePath(appName);
var entryAssembly = Assembly.GetExecutingAssembly();
var hierarchy = (Hierarchy)LogManager.GetRepository(entryAssembly);
var patternLayout = new PatternLayout
{
ConversionPattern = "%date [%thread] %-5level %logger - %message%newline"
};
patternLayout.ActivateOptions();
var roller = new RollingFileAppender
{
AppendToFile = false,
File = LogFilePath,
Layout = patternLayout,
MaxSizeRollBackups = 5,
MaximumFileSize = "1GB",
RollingStyle = RollingFileAppender.RollingMode.Size,
StaticLogFileName = true
};
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
var memory = new MemoryAppender();
memory.ActivateOptions();
hierarchy.Root.AddAppender(memory);
hierarchy.Root.Level = Level.Info;
hierarchy.Configured = true;
}
/// <summary>
/// The Warn.
/// </summary>
/// <param name="source">The source<see cref="object"/>.</param>
/// <param name="message">The message<see cref="object"/>.</param>
public static void Warn(this object source, object message)
{
Log.Warn(message);
}
/// <summary>
/// Saves given Exception's stack trace to a readable file in the local application data folder.
/// </summary>
/// <param name="ex">The Exception to save.</param>
public static void WriteException(Exception ex)
{
Logger.Info(ex.ToString());
}
/// <summary>
/// The GetLogFilePath.
/// </summary>
/// <param name="appName">The appName<see cref="string"/>.</param>
/// <returns>The <see cref="string"/>.</returns>
internal static string GetLogFilePath(string appName)
{
var folder = AppEnvironment.GetUserLocalApplicationData();
var path = Path.Combine(folder, $"{appName}.log");
return path;
}
#endregion Methods
}
}

View File

@@ -0,0 +1,31 @@
namespace VideoBrowser.Common
{
using System.ComponentModel;
using System.Runtime.CompilerServices;
/// <summary>
/// Defines the <see cref="NotifyPropertyChanged" />
/// Standard INotifyPropertyChanged implementation.
/// </summary>
public class NotifyPropertyChanged : INotifyPropertyChanged
{
/// <summary>
/// Defines the PropertyChanged
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// The property changed handler
/// </summary>
protected PropertyChangedEventHandler PropertyChangedHandler => this.PropertyChanged;
/// <summary>
/// The OnPropertyChanged
/// </summary>
/// <param name="propertyName">The <see cref="string"/></param>
public void OnPropertyChanged([CallerMemberName]string propertyName = null)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -0,0 +1,37 @@
namespace VideoBrowser.Common
{
#region Enums
/// <summary>
/// Defines the OutputFormat
/// </summary>
public enum OutputFormat
{
/// <summary>
/// Defines the Webm
/// </summary>
Webm,
/// <summary>
/// Defines the MP4
/// </summary>
MP4,
/// <summary>
/// Defines the MP3
/// </summary>
MP3,
/// <summary>
/// Defines the M4A
/// </summary>
M4A,
/// <summary>
/// Defines the Vorbis
/// </summary>
Vorbis
}
#endregion Enums
}

View File

@@ -0,0 +1,92 @@
namespace VideoBrowser.Common
{
using System;
using VideoBrowser.Extensions;
/// <summary>
/// Defines the <see cref="Percentage" />
/// </summary>
internal struct Percentage : IEquatable<Percentage>
{
/// <summary>
/// Initializes a new instance of the <see cref=""/> class.
/// </summary>
/// <param name="percent">The percent<see cref="double"/></param>
public Percentage(double percent)
{
this.Percent = percent;
}
/// <summary>
/// Gets the Empty
/// </summary>
public static Percentage Empty { get; } = new Percentage(double.NaN);
/// <summary>
/// Gets a value indicating whether IsEmpty
/// </summary>
public bool IsEmpty => double.IsNaN(this.Percent);
/// <summary>
/// Gets the Normalized
/// </summary>
public double Normalized => this.Percent * 0.01;
/// <summary>
/// Gets the Percent
/// </summary>
public double Percent { get; }
/// <summary>
/// The Equals
/// </summary>
/// <param name="obj">The obj<see cref="object"/></param>
/// <returns>The <see cref="bool"/></returns>
public override bool Equals(object obj)
{
return base.Equals(obj);
}
/// <summary>
/// The Equals
/// </summary>
/// <param name="other">The other<see cref="Percentage"/></param>
/// <returns>The <see cref="bool"/></returns>
public bool Equals(Percentage other)
{
var equals = this.Percent.IsEqualTo(other.Percent);
return equals;
}
/// <summary>
/// The GetHashCode
/// </summary>
/// <returns>The <see cref="int"/></returns>
public override int GetHashCode()
{
return this.Percent.GetHashCode();
}
/// <summary>
/// The ToString
/// </summary>
/// <returns>The <see cref="string"/></returns>
public override string ToString()
{
var message = $"{this.Percent.Format()}%";
return message;
}
public static bool operator ==(Percentage left, Percentage right)
{
var equals = left.Percent.IsEqualTo(right.Percent);
return equals;
}
public static bool operator !=(Percentage left, Percentage right)
{
var equals = left.Percent.IsEqualTo(right.Percent);
return !equals;
}
}
}

View File

@@ -0,0 +1,107 @@
namespace VideoBrowser.Common
{
using System;
using VideoBrowser.If;
/// <summary>
/// Defines the <see cref="Range{T}" />
/// </summary>
/// <typeparam name="T"></typeparam>
public struct Range<T> : IRange<T> where T : IComparable<T>
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref=""/> class.
/// </summary>
/// <param name="start">The start.</param>
/// <param name="end">The end.</param>
public Range(T start, T end)
{
this.Start = start;
this.End = end;
}
#endregion Constructors
#region Properties
/// <summary>
/// Gets the End
/// </summary>
public T End { get; }
/// <summary>
/// Gets the Start
/// </summary>
public T Start { get; }
#endregion Properties
#region Methods
/// <summary>
/// The Equals
/// </summary>
/// <param name="other">The other<see cref="IRange{T}"/></param>
/// <returns>The <see cref="bool"/></returns>
public bool Equals(IRange<T> other)
{
return this.Start.Equals(other.Start) && this.End.Equals(other.End);
}
/// <summary>
/// The Equals
/// </summary>
/// <param name="obj">The <see cref="object"/></param>
/// <returns>The <see cref="bool"/></returns>
public override bool Equals(object obj)
{
return this == (Range<T>)obj;
}
/// <summary>
/// The GetHashCode
/// </summary>
/// <returns>The <see cref="int"/></returns>
public override int GetHashCode()
{
var startHash = this.Start.GetHashCode();
var endHash = this.End.GetHashCode();
return startHash ^ (startHash << 8) ^ endHash ^ (endHash << 4);
}
/// <summary>
/// The ToString
/// </summary>
/// <returns>The <see cref="string"/></returns>
public override string ToString()
{
return $"Start:{this.Start};End:{this.End}";
}
#endregion Methods
/// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns> The result of the operator. </returns>
public static bool operator ==(Range<T> left, Range<T> right)
{
return Equals(left.Start, right.Start) && Equals(left.End, right.End);
}
/// <summary>
/// Implements the operator !=.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns> The result of the operator. </returns>
public static bool operator !=(Range<T> left, Range<T> right)
{
return !(left == right);
}
}
}

View File

@@ -0,0 +1,120 @@
namespace VideoBrowser.Common
{
using System;
using VideoBrowser.Extensions;
using VideoBrowser.If;
/// <summary>
/// Defines the <see cref="RangeDouble" />
/// </summary>
public struct RangeDouble : IRange<double>
{
private const double PRECISION = 1E-6;
/// <summary>
/// Initializes a new instance of the <see cref=""/> class.
/// </summary>
/// <param name="start">The start<see cref="double"/></param>
/// <param name="end">The end<see cref="double"/></param>
/// <param name="allowInvert">The allowInvert<see cref="bool"/></param>
public RangeDouble(double start, double end, bool allowInvert = false)
{
if (!allowInvert && start >= end)
{
throw new ArgumentException($"{nameof(start)} is equal or greater than {nameof(end)}");
}
this.Start = start;
this.End = end;
}
/// <summary>
/// Gets the Empty
/// </summary>
public static RangeDouble Empty { get; } = new RangeDouble();
/// <summary>
/// Gets the End
/// </summary>
public double End { get; }
/// <summary>
/// Gets the Start
/// </summary>
public double Start { get; }
/// <summary>
/// The Equals
/// </summary>
/// <param name="other">The other<see cref="IRange{double}"/></param>
/// <returns>The <see cref="bool"/></returns>
public bool Equals(IRange<double> other)
{
return Equals(this.Start, other.Start) && Equals(this.End, other.End);
}
/// <summary>
/// The Equals
/// </summary>
/// <param name="obj">The <see cref="object"/></param>
/// <returns>The <see cref="bool"/></returns>
public override bool Equals(object obj)
{
if (!(obj is RangeDouble))
{
return false;
}
return this == (RangeDouble)obj;
}
/// <summary>Equalses the specified other.</summary>
/// <param name="other">The other.</param>
public bool Equals(RangeDouble other)
{
return this.Start.IsEqualTo(other.Start, PRECISION) && this.End.IsEqualTo(other.End, PRECISION);
}
/// <summary>
/// The GetHashCode
/// </summary>
/// <returns>The <see cref="int"/></returns>
public override int GetHashCode()
{
var startHash = this.Start.GetHashCode();
var endHash = this.End.GetHashCode();
return startHash ^ (startHash << 8) ^ endHash ^ (endHash << 4);
}
/// <summary>
/// The ToString
/// </summary>
/// <returns>The <see cref="string"/></returns>
public override string ToString()
{
return $"Start:{this.Start.Format()};End:{this.End.Format()};Length:{this.Length().Format()}";
}
/// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns> The result of the operator. </returns>
public static bool operator ==(RangeDouble left, RangeDouble right)
{
return left.Start.IsEqualTo(right.Start, PRECISION) && left.End.IsEqualTo(right.End, PRECISION);
}
/// <summary>
/// Implements the operator !=.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns> The result of the operator. </returns>
public static bool operator !=(RangeDouble left, RangeDouble right)
{
return !(left == right);
}
}
}

View File

@@ -0,0 +1,112 @@
namespace VideoBrowser.Common
{
using System;
using VideoBrowser.If;
/// <summary>
/// Defines the <see cref="RangeInt" />
/// </summary>
public struct RangeInt : IRange<int>
{
/// <summary>
/// Initializes a new instance of the <see cref=""/> class.
/// </summary>
/// <param name="start">The start<see cref="int"/></param>
/// <param name="end">The end<see cref="int"/></param>
/// <param name="allowInvert">The allowInvert<see cref="bool"/></param>
public RangeInt(int start, int end, bool allowInvert = false)
{
if (!allowInvert && start > end)
{
throw new ArgumentException($"{nameof(start)} is equal or greater than {nameof(end)}");
}
this.Start = start;
this.End = end;
}
/// <summary>
/// Gets the End
/// </summary>
public int End { get; }
/// <summary>
/// Gets the Start
/// </summary>
public int Start { get; }
/// <summary>
/// The Equals
/// </summary>
/// <param name="other">The other<see cref="IRange{int}"/></param>
/// <returns>The <see cref="bool"/></returns>
public bool Equals(IRange<int> other)
{
return Equals(this.Start, other.Start) && Equals(this.End, other.End);
}
/// <summary>
/// The Equals
/// </summary>
/// <param name="obj">The <see cref="object"/></param>
/// <returns>The <see cref="bool"/></returns>
public override bool Equals(object obj)
{
if (!(obj is RangeInt))
{
return false;
}
return this == (RangeInt)obj;
}
/// <summary>Equalses the specified other.</summary>
/// <param name="other">The other.</param>
public bool Equals(RangeInt other)
{
return this.Start == other.Start && this.End == other.End;
}
/// <summary>
/// The GetHashCode
/// </summary>
/// <returns>The <see cref="int"/></returns>
public override int GetHashCode()
{
var startHash = this.Start.GetHashCode();
var endHash = this.End.GetHashCode();
return startHash ^ (startHash << 8) ^ endHash ^ (endHash << 4);
}
/// <summary>
/// The ToString
/// </summary>
/// <returns>The <see cref="string"/></returns>
public override string ToString()
{
return $"Start:{this.Start};End:{this.End};Length:{this.End - this.Start}";
}
/// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns> The result of the operator. </returns>
public static bool operator ==(RangeInt left, RangeInt right)
{
return left.Start == right.Start && left.End == right.End;
}
/// <summary>
/// Implements the operator !=.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns> The result of the operator. </returns>
public static bool operator !=(RangeInt left, RangeInt right)
{
return !(left == right);
}
}
}

View File

@@ -0,0 +1,61 @@
namespace VideoBrowser.Common
{
using System;
using System.Windows.Input;
/// <summary>
/// The WPF default command.
/// </summary>
/// <seealso cref="System.Windows.Input.ICommand" />
public class RelayCommand : ICommand
{
private readonly Func<object, bool> _canExecute;
private readonly Action<object> _execute;
private readonly string _name;
/// <summary>
/// Initializes a new instance of the <see cref="RelayCommand"/> class.
/// </summary>
/// <param name="execute">The execute.</param>
/// <param name="canExecute">The can execute.</param>
public RelayCommand(Action<object> execute, string name = "", Func<object, bool> canExecute = null)
{
this._execute = execute;
this._name = name;
this._canExecute = canExecute;
}
/// <summary>
/// Occurs when changes occur that affect whether or not the command should execute.
/// </summary>
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
/// <summary>
/// Defines the method that determines whether the command can execute in its current state.
/// </summary>
/// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
/// <returns>
/// <see langword="true" /> if this command can be executed; otherwise, <see langword="false" />.
/// </returns>
public bool CanExecute(object parameter)
{
return this._canExecute == null || this._canExecute(parameter);
}
/// <summary>
/// Defines the method to be called when the command is invoked.
/// </summary>
/// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
public void Execute(object parameter)
{
this._execute(parameter);
Logger.Info($"{nameof(RelayCommand)} {this._name} is executed");
}
}
}

View File

@@ -0,0 +1,32 @@
namespace VideoBrowser.Common
{
#region Enums
/// <summary>
/// Defines the VideoState
/// </summary>
public enum VideoState
{
/// <summary>
/// Defines the None
/// </summary>
None,
/// <summary>
/// Defines the Downloading
/// </summary>
Downloading,
/// <summary>
/// Defines the Downloaded
/// </summary>
Downloaded,
/// <summary>
/// Defines the Error
/// </summary>
Error
}
#endregion Enums
}