/////////////////////////////////////////////////////////////////////////////// // Copyright file = "LocalPaths.cs" // // Copyright (c) 2020 All Rights Reserved // // Authors: Francine Rotzetter / Robin Dittli // // Date: 21/01/2020 // // Summary: Class representing static Paths // /////////////////////////////////////////////////////////////////////////////// /* . . . . . . . . . . . . . . A long time ago in a galaxy far, far away... . . . . . . . . . . . . . . . . . :::::+::::... . . . . . . ..::.:::+++++:::+++++:+::. . . .:. ..:+:..+|||+..::|+|+||++|:. . . . . :::....:::::::::++||||O||O#OO|OOO|+|:. . . . . .:..:..::+||OO#|#|OOO+|O||####OO###O+:+|+ . .:...:+||O####O##||+|OO|||O#####O#O||OO|++||: . . . ..::||+++|+++++|+::|+++++O#O|OO|||+++..:OOOOO|+ . . . . +++||++:.:++:..+#|. ::::++|+++||++O##O+:.++|||#O+ . . . ++++++++...:+:+:.:+: ::..+|OO++O|########|++++||##+ . . . :::+++|O+||+::++++:::+:::+++::+|+O###########OO|:+OO . . . +:+++|OO+|||O:+:::::.. .||O#OOO||O||#@###@######:+|O| . . ::+:++|+|O+|||++|++|:::+O#######O######O@############O . ++++: .+OO###O++++++|OO++|O#@@@####@##################+ . . ::::::::::::::::::::++|O+..+#|O@@@@#@###O|O#O##@#OO#### . . . :. .:.:. .:.:.: +.:::::::: . +#:#@:#@@@#O||O#O@:###:#| . . `. .:.:.:.:. . :.:.:%::%%%:::::%::::%::: . . `.:.:.:.: :.:.:.:. . . */ using System; using System.IO; using System.Windows.Forms; namespace THUMM { // Saves path and path changes // Invoke Eventhandlers in SourcePath and DestinationPath public static class LocalPaths { //BackingFields with default directory private static string _sourcePath = AppDomain.CurrentDomain.BaseDirectory; private static string _destinationPath = AppDomain.CurrentDomain.BaseDirectory; private static string _blenderInstallFolderPath = @"C:\Program Files\Blender Foundation\Blender 2.81"; //SourcePath -> Direcotry public static string SourcePath { get { return _sourcePath; } set { if (!Directory.Exists(value)) { return; } else { _sourcePath = value; //Event Invoke OnSourcePathChanged OnSourcePathChanged?.Invoke(SourcePath); } } } //Get the location where python files should be stored public static string PyFolderPath { get{ return SourcePath; } } //DestinationPath -> Direcotry public static string DestinationPath { get { return _destinationPath; } set { if (!Directory.Exists(value)) { return; } else { _destinationPath = value; //Event Invoke OnDestinationPathChanged OnDestinationPathChanged?.Invoke(DestinationPath); } } } //Set BlenderInstallFolder public static string BlenderInstallFolderPath { get { return _blenderInstallFolderPath; } set { //Directory does NOT exist? if (!Directory.Exists(value)) { //yes return; } //No else { //Get all "blender.exe" Files in Directory string[] dirs = Directory.GetFiles(value, "blender.exe"); //No "blender.exe" Files found (array is empty)? if (dirs.Length == 0) { MessageBox.Show("This Directory does not contain a executable! Please choose another Folder! "); return; } //Success "blender.exe" File was found! //Set blender InstallPath _blenderInstallFolderPath = value; //Event Invoke OnDestinationPathChanged OnBlenderPathChanged?.Invoke(BlenderInstallFolderPath); //Debug foreach (string dir in dirs) { Console.WriteLine(dir); } } } } //Event creation public static event OnPathChangedHandler OnSourcePathChanged; public static event OnPathChangedHandler OnDestinationPathChanged; public static event OnPathChangedHandler OnBlenderPathChanged; //delegate public delegate void OnPathChangedHandler(string path); } }