Files @ 41381c24d35a
Branch filter:

Location: ATITD-Tools/Desert-Paint-Lab/FileUtils.cs - annotation

Jason Maltzen
Now supports all the interface sizes with a setting to select the current interface size. The initial screen size check now displays the detected resolution as a hint. The screen size check / interface size settings can now be updated after launch through File->Preferences. Capturing a reaction now includes a progress bar, and runs in a separate thread instead of silently blocking. The reaction status window under 'Help' now has options to disable ingredients to remove them from the list. NOTE: this also disables/enables those ingredients in the recipe generator as well. The list also updates as new reactions are recorded instead of requiring that it be closed and re-opened to update.
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
234ae2144a25
234ae2144a25
234ae2144a25
234ae2144a25
234ae2144a25
234ae2144a25
234ae2144a25
234ae2144a25
234ae2144a25
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
8c3f6ec929d6
501aa95c46d7
8c3f6ec929d6
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
501aa95c46d7
501aa95c46d7
8c3f6ec929d6
501aa95c46d7
501aa95c46d7
8c3f6ec929d6
501aa95c46d7
501aa95c46d7
501aa95c46d7
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
501aa95c46d7
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
501aa95c46d7
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
f28757bb21cb
991c95f4da74
991c95f4da74
991c95f4da74
991c95f4da74
991c95f4da74
991c95f4da74
991c95f4da74
991c95f4da74
991c95f4da74
991c95f4da74
991c95f4da74
991c95f4da74
f28757bb21cb
f28757bb21cb
f28757bb21cb
using System;

namespace DesertPaintLab
{
    public class FileUtils
    {
        public FileUtils()
        {
        }

        public static string AppDataPath
        {
            get {
                return System.IO.Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                    "DesertPaintLab");
            }
        }

        public static string FindApplicationResourceDirectory(string dirname)
        {
            string dirPath = System.IO.Path.Combine(
                    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                    dirname);
            if (System.IO.Directory.Exists(dirPath))
            {
                return dirPath;
            }
            dirPath = System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                "data", 
                dirname);
            if (System.IO.Directory.Exists(dirPath))
            {
                return dirPath;
            }
            // try "Resources" in case this is a Mac app bundle
            dirPath = System.IO.Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.Resources), "data", dirname);
            if (System.IO.Directory.Exists(dirPath))
            {
                return dirPath;
            }
            // try "Resources" in case this is a Mac app bundle
            dirPath = System.IO.Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.Resources), dirname);
            if (System.IO.Directory.Exists(dirPath))
            {
                return dirPath;
            }
            dirPath = System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                "Resources", "data",
                dirname);
            if (System.IO.Directory.Exists(dirPath))
            {
                // not found
                return dirPath;
            }
            dirPath = System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                "Resources", 
                dirname);
            if (!System.IO.Directory.Exists(dirPath))
            {
                // not found
                dirPath = null;
            }
            return dirPath;
        }

        public static string FindApplicationResourceFile(string filename)
        {
            // start with the location of the executable
            string filePath = System.IO.Path.Combine(
                    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                    filename);
            if (!System.IO.File.Exists(filePath))
            {
                filePath = System.IO.Path.Combine(
                    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                    "data", 
                    filename);
            }
            if (!System.IO.File.Exists(filePath))
            {
                // try "Resources/data" in case this is a Mac app bundle
                filePath = System.IO.Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.Resources), "data", filename);
            }
            if (!System.IO.File.Exists(filePath))
            {
                // try "Resources" in case this is a Mac app bundle
                filePath = System.IO.Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.Resources), filename);
            }
            if (!System.IO.File.Exists(filePath))
            {
                filePath = System.IO.Path.Combine(
                    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                    "Resources", "data",
                    filename);
            }
            if (!System.IO.File.Exists(filePath))
            {
                filePath = System.IO.Path.Combine(
                    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                    "Resources", 
                    filename);
            }
            if (!System.IO.File.Exists(filePath))
            {
                // not found
                filePath = null;
            }
            return filePath;
        }

        public static string FindNumberedFile(string baseName, string extension, string folder)
        {
            string filename = "";
            int i = 0;
            do
            {
                ++i;
                filename = System.IO.Path.Combine(folder, String.Format("{0}_{1}.{2}", baseName, i, extension));
            } while (System.IO.File.Exists(filename));
            return filename;
        }
    }
}