170 lines
4.9 KiB
C#
170 lines
4.9 KiB
C#
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using file_finder__test;
|
|
using ShadowStream;
|
|
using ShadowStream.LogHelper;
|
|
using ShadowStream.Obejeckte;
|
|
using System.Threading;
|
|
|
|
namespace ModuleManager;
|
|
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
//Quinn and Reda and Yazan
|
|
public partial class MainWindow : Window
|
|
{
|
|
//adding base components used threw out the code
|
|
private static LogHelper loghelper = new LogHelper();
|
|
LogWindow log = new LogWindow(loghelper.GetEntries());
|
|
|
|
private Catagory Muvie = new Catagory("Muvie");
|
|
private Catagory Serie = new Catagory("Serie");
|
|
private Catagory Music = new Catagory("Music");
|
|
private Catagory Photo = new Catagory("Photos");
|
|
|
|
List<string> suportedVidioFiles = new List<string>();
|
|
List<string> suportedMusicFiles = new List<string>();
|
|
List<string> suportedPhotoFiles = new List<string>();
|
|
|
|
//root directory
|
|
List<string> dirs = new List<string>();
|
|
private int option =0;
|
|
int specificOption = 0;
|
|
string rootPath = "C:/Users/bib/Desktop/";
|
|
|
|
FileScanner fileScanner;
|
|
//code start
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
//Initialise but Hide
|
|
log.Hide();
|
|
this.Hide();
|
|
//Begin Login Process
|
|
var login = new LogIn();
|
|
login.Show();
|
|
//adding all extensions... example values added
|
|
suportedVidioFiles.Add("mp4");
|
|
suportedVidioFiles.Add("mkv");
|
|
suportedMusicFiles.Add("wav");
|
|
suportedMusicFiles.Add("mp3");
|
|
suportedPhotoFiles.Add("jpg");
|
|
Createscan();
|
|
dirs.Add("C:/");
|
|
|
|
//execute and wait for task completion
|
|
var tmp = fileScanner.ScanAllDrivesAsync();
|
|
|
|
//load json parallel to finding drives
|
|
//add code laiter
|
|
|
|
tmp.Wait();
|
|
foreach (var VARIABLE in tmp.Result)
|
|
{
|
|
dirs.Add(VARIABLE);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
void LoadFromJson(string path, object obj)
|
|
{
|
|
//add json logic in here
|
|
}
|
|
void Createscan()
|
|
{
|
|
//adding all string arrays to one temp array to do the initial scan of the designated drive
|
|
int count = 0;
|
|
string[] tmp = new string[suportedMusicFiles.Count + suportedVidioFiles.Count + suportedPhotoFiles.Count];
|
|
foreach (var suportedVidioFile in suportedVidioFiles)
|
|
{
|
|
tmp[count] = suportedVidioFile;
|
|
count++;
|
|
}
|
|
|
|
foreach (var suportedMusicFile in suportedMusicFiles)
|
|
{
|
|
tmp[count] = suportedMusicFile;
|
|
count++;
|
|
}
|
|
|
|
foreach (var suportedPhotoFile in suportedPhotoFiles)
|
|
{
|
|
tmp[count] = suportedPhotoFile;
|
|
count++;
|
|
}
|
|
//initialise the file scanner with all files endings wanted
|
|
fileScanner = new FileScanner(tmp);
|
|
}
|
|
|
|
|
|
//btn logic
|
|
void scanButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
List<string> tmp = new List<string>();
|
|
switch (option)
|
|
{
|
|
case 0:
|
|
foreach (var VARIABLE in dirs)
|
|
{
|
|
foreach (var tmp2 in fileScanner.ScanDriveParallel(VARIABLE).Result)
|
|
{
|
|
tmp.Add(tmp2);
|
|
}
|
|
}
|
|
break;
|
|
case 1:
|
|
foreach (var VARIABLE in fileScanner.ScanDriveParallel(dirs[specificOption]).Result)
|
|
{
|
|
tmp.Add(VARIABLE);
|
|
}
|
|
|
|
break;
|
|
case 2:
|
|
foreach (var VARIABLE in fileScanner.ScanDriveParallel(rootPath).Result)
|
|
{
|
|
tmp.Add(VARIABLE);
|
|
}
|
|
break;
|
|
}
|
|
|
|
var classifier = new FileClassifier();
|
|
var (musicFiles, videoFiles,photoFiles) = classifier.ClassifyFilesAsync(tmp, suportedMusicFiles,suportedVidioFiles,suportedPhotoFiles ).Result;
|
|
|
|
var separator = new VideoSeparator();
|
|
var (series, movies) = separator.SeparateVideosAsync(videoFiles).Result;
|
|
//causes delibrit null refrence exeption. so dont use it!!! :-P
|
|
videoFiles = null;
|
|
//music list,muvie list,photo list,music list
|
|
|
|
|
|
|
|
}
|
|
|
|
List<Item> ItemCreater(List<string> path, string type,bool isFoto)
|
|
{
|
|
List<Item> items = new List<Item>();
|
|
|
|
foreach (var VARIABLE in path)
|
|
{
|
|
Bitmap frame200 = VideoFrameExtractor.GetFrame200(VARIABLE);
|
|
items.Add(new Item(VARIABLE, type,frame200, isFoto));
|
|
}
|
|
|
|
return items;
|
|
}
|
|
|
|
|
|
//scan logic
|
|
|
|
} |