Files @ 2040107278aa
Branch filter:

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

jmaltzen
Fixes #8 #9 #6 #3 : Order of ingredients should now match the paint bench. Basic brute-force recipe generation implementation. Fixed rounding error on the simulator. Give feedback when using the simulator if reactions are missing. Also: adds an interface for modifying ingredient settings for recipe generation, adds a help option to view missing recorded reactions
using System;

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

        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;
            }
            // 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", 
                dirname);
            if (!System.IO.Directory.Exists(dirPath))
            {
                // not found
                dirPath = null;
            }
            return dirPath;
        }

        public static string FindApplicationResourceFile(string filename)
        {
            string filePath = System.IO.Path.Combine(
                    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                    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", 
                    filename);
            }
            if (!System.IO.File.Exists(filePath))
            {
                // not found
                filePath = null;
            }
            return filePath;
        }
    }
}