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,42 @@
namespace VideoBrowser.Controls.CefSharpBrowser.Models
{
using System.ComponentModel;
using VideoBrowser.Extensions;
/// <summary>
/// Defines the <see cref="BookmarkModel" />.
/// </summary>
public class BookmarkModel : INotifyPropertyChanged
{
#region Fields
private string _name;
private string _url;
#endregion Fields
#region Events
/// <summary>
/// Defines the PropertyChanged.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
#endregion Events
#region Properties
/// <summary>
/// Gets or sets the Name.
/// </summary>
public string Name { get => _name; set => this.Set(this.PropertyChanged, ref _name, value); }
/// <summary>
/// Gets or sets the Url.
/// </summary>
public string Url { get => _url; set => this.Set(this.PropertyChanged, ref _url, value); }
#endregion Properties
}
}

View File

@@ -0,0 +1,58 @@
namespace VideoBrowser.Controls.CefSharpBrowser.Models
{
using System.Collections.Generic;
/// <summary>
/// Defines the <see cref="BrowserSettings" />.
/// </summary>
public class BrowserSettings
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="BrowserSettings"/> class.
/// </summary>
public BrowserSettings()
{
this.BookmarkModels = new List<BookmarkModel>();
this.DownloadItems = new List<DownloadItemModel>();
this.TabSettingModels = new List<TabSettingsModel>();
}
#endregion Constructors
#region Properties
/// <summary>
/// Gets or sets the BookmarkModels.
/// </summary>
public IList<BookmarkModel> BookmarkModels { get; set; }
/// <summary>
/// Gets or sets the DownloadItems.
/// </summary>
public IList<DownloadItemModel> DownloadItems { get; set; }
/// <summary>
/// Gets or sets the OutputFolder.
/// </summary>
public string OutputFolder { get; set; }
/// <summary>
/// Gets or sets the SelectedTabSettingIndex.
/// </summary>
public int SelectedTabSettingIndex { get; set; }
/// <summary>
/// Gets or sets the TabSettingModels.
/// </summary>
public IList<TabSettingsModel> TabSettingModels { get; set; }
/// <summary>
/// Gets or sets the Version.
/// </summary>
public string Version { get; set; } = "1.0";
#endregion Properties
}
}

View File

@@ -0,0 +1,248 @@
namespace VideoBrowser.Controls.CefSharpBrowser.Models
{
using Newtonsoft.Json;
using System;
using System.Windows.Input;
using VideoBrowser.Common;
using VideoBrowser.Controls.CefSharpBrowser.Helpers;
using VideoBrowser.Extensions;
/// <summary>
/// Defines the <see cref="DownloadItemModel" />.
/// </summary>
public class DownloadItemModel : NotifyPropertyChanged, IEquatable<DownloadItemModel>, IDisposable
{
#region Fields
private string _fileSize;
private bool _isQueuedControlsVisible = true;
private string _outputPath;
private string _pauseText = "Pause";
private int _progress;
private string _status;
private string _thumbnail;
private string _title;
private string _url;
private bool Disposed = false;// To detect redundant calls
#endregion Fields
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="DownloadItemModel"/> class.
/// </summary>
public DownloadItemModel()
{
this.ExecuteDownloadedCommand = new RelayCommand(this.OnExecuteDownloaded, nameof(this.ExecuteDownloadedCommand));
this.ShowDownloadedFolderCommand = new RelayCommand(this.OnShowDownloadedFolderCommand, nameof(this.ShowDownloadedFolderCommand));
}
/// <summary>
/// Initializes a new instance of the <see cref="DownloadItemModel"/> class.
/// </summary>
/// <param name="other">The other<see cref="DownloadItemModel"/>.</param>
internal DownloadItemModel(DownloadItemModel other)
{
this.FileSize = other.FileSize;
this.IsApplicationThumbnail = other.IsApplicationThumbnail;
this.IsQueuedControlsVisible = other.IsQueuedControlsVisible;
this.OutputPath = other.OutputPath;
this.PauseText = other.PauseText;
this.Progress = other.Progress;
this.Status = other.Status;
this.Thumbnail = other.Thumbnail;
this.Title = other.Title;
this.Url = other.Url;
}
#endregion Constructors
#region Properties
/// <summary>
/// Gets or sets the CancelDownloadCommand.
/// </summary>
[JsonIgnore]
public ICommand CancelDownloadCommand { get; protected set; }
/// <summary>
/// Gets or sets the ExecuteDownloadedCommand.
/// </summary>
[JsonIgnore]
public ICommand ExecuteDownloadedCommand { get; protected set; }
/// <summary>
/// Gets or sets the FileSize.
/// </summary>
public string FileSize { get => this._fileSize; set => this.Set(this.PropertyChangedHandler, ref this._fileSize, value); }
/// <summary>
/// Gets or sets a value indicating whether IsApplicationThumbnail.
/// </summary>
public bool IsApplicationThumbnail { get; set; }
/// <summary>
/// Gets a value indicating whether IsCompletedControlsVisible.
/// </summary>
[JsonIgnore]
public bool IsCompletedControlsVisible { get => !this.IsQueuedControlsVisible; }
/// <summary>
/// Gets or sets a value indicating whether IsQueuedControlsVisible.
/// </summary>
public bool IsQueuedControlsVisible
{
get => _isQueuedControlsVisible;
set
{
if (!this.Set(this.PropertyChangedHandler, ref _isQueuedControlsVisible, value))
{
return;
}
this.OnPropertyChanged(nameof(this.IsCompletedControlsVisible));
}
}
/// <summary>
/// Gets or sets the OutputPath.
/// </summary>
public string OutputPath { get => _outputPath; set => this.Set(this.PropertyChangedHandler, ref _outputPath, value); }
/// <summary>
/// Gets or sets the PauseDownloadCommand.
/// </summary>
[JsonIgnore]
public ICommand PauseDownloadCommand { get; protected set; }
/// <summary>
/// Gets or sets the PauseText.
/// </summary>
public string PauseText { get => _pauseText; set => this.Set(this.PropertyChangedHandler, ref _pauseText, value); }
/// <summary>
/// Gets or sets the Progress.
/// </summary>
public int Progress { get => this._progress; set => this.Set(this.PropertyChangedHandler, ref this._progress, value); }
/// <summary>
/// Gets or sets the ShowDownloadedFolderCommand.
/// </summary>
[JsonIgnore]
public ICommand ShowDownloadedFolderCommand { get; protected set; }
/// <summary>
/// Gets or sets the Status.
/// </summary>
public string Status { get => this._status; set => this.Set(this.PropertyChangedHandler, ref this._status, value); }
/// <summary>
/// Gets or sets the Thumbnail.
/// </summary>
public string Thumbnail { get => _thumbnail; set => this.Set(this.PropertyChangedHandler, ref _thumbnail, value); }
/// <summary>
/// Gets or sets the Title.
/// </summary>
public string Title { get => this._title; set => this.Set(this.PropertyChangedHandler, ref this._title, value); }
/// <summary>
/// Gets or sets the Url.
/// </summary>
public string Url { get => this._url; set => this.Set(this.PropertyChangedHandler, ref this._url, value); }
#endregion Properties
#region Methods
/// <summary>
/// The Dispose.
/// </summary>
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
}
/// <summary>
/// The Equals.
/// </summary>
/// <param name="other">The other<see cref="DownloadItemModel"/>.</param>
/// <returns>The <see cref="bool"/>.</returns>
public bool Equals(DownloadItemModel other)
{
var isEqual = other != null && this.OutputPath == other.OutputPath;
return isEqual;
}
/// <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 Equals(obj as DownloadItemModel);
}
/// <summary>
/// The GetHashCode.
/// </summary>
/// <returns>The <see cref="int"/>.</returns>
public override int GetHashCode()
{
var hash = this.OutputPath == null ? string.Empty.GetHashCode() : this.OutputPath.GetHashCode();
return hash;
}
/// <summary>
/// The Dispose.
/// </summary>
/// <param name="disposing">The disposing<see cref="bool"/>.</param>
protected virtual void Dispose(bool disposing)
{
if (!this.Disposed)
{
if (disposing)
{
// TODO: dispose managed state (managed objects).
}
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
// TODO: set large fields to null.
this.Disposed = true;
}
}
/// <summary>
/// The OnPlayMedia.
/// </summary>
/// <param name="obj">The obj<see cref="object"/>.</param>
private void OnExecuteDownloaded(object obj)
{
ProcessHelper.Start(this.OutputPath);
}
/// <summary>
/// The OnShowMediaInFolder.
/// </summary>
/// <param name="obj">The obj<see cref="object"/>.</param>
private void OnShowDownloadedFolderCommand(object obj)
{
ProcessHelper.OpenContainedFolder(this.OutputPath);
}
#endregion Methods
}
}

View File

@@ -0,0 +1,79 @@
namespace VideoBrowser.Controls.CefSharpBrowser.Models
{
using CefSharp;
using VideoBrowser.Common;
using VideoBrowser.Helpers;
/// <summary>
/// Defines the <see cref="DownloadProcessModel" />.
/// </summary>
public class DownloadProcessModel : DownloadItemModel
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="DownloadProcessModel"/> class.
/// </summary>
/// <param name="item">The item<see cref="DownloadItem"/>.</param>
internal DownloadProcessModel(DownloadItem item)
{
this.Initialize(item);
this.IsApplicationThumbnail = true;
this.CancelDownloadCommand = new RelayCommand(this.OnCancelDownload, nameof(this.CancelDownloadCommand));
}
#endregion Constructors
#region Properties
/// <summary>
/// Gets a value indicating whether IsCanceled.
/// </summary>
internal bool IsCanceled { get; private set; }
#endregion Properties
#region Methods
/// <summary>
/// The UpdateInfo.
/// </summary>
internal void UpdateInfo(DownloadItem downloadItem)
{
this.OutputPath = downloadItem.FullPath;
this.Progress = downloadItem.PercentComplete;
var speed = $"{downloadItem.CurrentSpeed.FormatFileSize()}/s";
var percentComplete = $"{downloadItem.PercentComplete}%";
var completeStatus = "Completed";
this.Status = downloadItem.IsComplete ? completeStatus : $"{percentComplete} - {speed}";
if (this.Status == completeStatus)
{
this.IsQueuedControlsVisible = false;
}
this.Thumbnail = this.OutputPath;
}
/// <summary>
/// The Initialize.
/// </summary>
private void Initialize(DownloadItem downloadItem)
{
this.FileSize = FormatString.FormatFileSize(downloadItem.TotalBytes);
this.Title = downloadItem.SuggestedFileName;
this.Url = downloadItem.OriginalUrl;
this.UpdateInfo(downloadItem);
}
/// <summary>
/// The OnCancelDownload.
/// </summary>
/// <param name="obj">The obj<see cref="object"/>.</param>
private void OnCancelDownload(object obj)
{
this.IsCanceled = true;
}
#endregion Methods
}
}

View File

@@ -0,0 +1,42 @@
namespace VideoBrowser.Controls.CefSharpBrowser.Models
{
using System.ComponentModel;
using VideoBrowser.Extensions;
/// <summary>
/// Defines the <see cref="TabSettingsModel" />.
/// </summary>
public class TabSettingsModel : INotifyPropertyChanged
{
#region Fields
private string _title;
private string _url;
#endregion Fields
#region Events
/// <summary>
/// Defines the PropertyChanged.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
#endregion Events
#region Properties
/// <summary>
/// Gets or sets the Title.
/// </summary>
public string Title { get => _title; set => this.Set(this.PropertyChanged, ref _title, value); }
/// <summary>
/// Gets or sets the Url.
/// </summary>
public string Url { get => _url; set => this.Set(this.PropertyChanged, ref _url, value); }
#endregion Properties
}
}