namespace Kuineator.Settings
{
    static class FileControl
    {
        public static string CharacterCode;

        public static string getOpenFilePath()
        {
            System.Windows.Forms.OpenFileDialog f = new System.Windows.Forms.OpenFileDialog();
            f.Title = "開く";
            f.ShowDialog();
            string filename = f.FileName;
            return filename;
        }

        public static string getOpenFilePath(string[] path)
        {
            string filter = path[0];
            for (int i = 1; i < path.Length; i++) filter += "|" + path[i];
            System.Windows.Forms.OpenFileDialog f = new System.Windows.Forms.OpenFileDialog();
            f.Title = "開く";
            f.Filter = filter;
            f.ShowDialog();
            return f.FileName;
        }

        public static string getOpenFilePath(string current, string[] path)
        {
            string filter = path[0];
            for (int i = 1; i < path.Length; i++) filter += "|" + path[i];
            System.Windows.Forms.OpenFileDialog f = new System.Windows.Forms.OpenFileDialog();
            f.Title = "開く";
            f.Filter = filter;
            f.InitialDirectory = @current;
            f.ShowDialog();
            return f.FileName;
        }

        public static System.IO.FileStream getOpenFile()
        {
            System.Windows.Forms.OpenFileDialog f = new System.Windows.Forms.OpenFileDialog();
            f.Title = "開く";
            f.ShowDialog();
            string filename = f.FileName;
            if (filename == "") return null;
            else return new System.IO.FileStream(filename,System.IO.FileMode.OpenOrCreate);
        }

        public static System.IO.FileStream getOpenFile(string current)
        {
            System.Windows.Forms.OpenFileDialog f = new System.Windows.Forms.OpenFileDialog();
            f.Title = "開く";
            f.InitialDirectory = @current;
            f.ShowDialog();
            string filename = f.FileName;
            if (filename == "") return null;
            else return new System.IO.FileStream(filename, System.IO.FileMode.OpenOrCreate);
        }

        public static System.IO.FileStream getOpenFile(string[] path)
        {
            string filter = path[0];
            for (int i = 1; i < path.Length; i++) filter += "|" + path[i]; 
            System.Windows.Forms.OpenFileDialog f = new System.Windows.Forms.OpenFileDialog();
            f.Title = "開く";
            f.Filter = filter;
            f.ShowDialog();
            string filename = f.FileName;
            if (filename == "") return null;
            else return new System.IO.FileStream(filename, System.IO.FileMode.OpenOrCreate);
        }

        public static System.IO.FileStream getOpenFile(string current, string[] path)
        {
            string filter = path[0];
            for (int i = 1; i < path.Length; i++) filter += "|" + path[i];
            System.Windows.Forms.OpenFileDialog f = new System.Windows.Forms.OpenFileDialog();
            f.Title = "開く";
            f.Filter = filter;
            f.InitialDirectory = @current;
            f.ShowDialog();
            string filename = f.FileName;
            if (filename == "") return null;
            else return new System.IO.FileStream(filename, System.IO.FileMode.OpenOrCreate);
        }

        public static string getSaveFilePath()
        {
            System.Windows.Forms.SaveFileDialog f = new System.Windows.Forms.SaveFileDialog();
            f.Title = "保存";
            f.ShowDialog();
            return f.FileName;
        }

        public static System.IO.FileStream getSaveFile()
        {
            System.Windows.Forms.SaveFileDialog f = new System.Windows.Forms.SaveFileDialog();
            f.Title = "保存";
            f.ShowDialog();
            string filename = f.FileName;
            if (filename == "") return null;
            else return new System.IO.FileStream(filename, System.IO.FileMode.Create);
        }

        public static System.IO.FileStream getSaveFile(string current)
        {
            System.Windows.Forms.SaveFileDialog f = new System.Windows.Forms.SaveFileDialog();
            f.Title = "保存";
            f.InitialDirectory = @current;
            f.ShowDialog();
            string filename = f.FileName;
            if (filename == "") return null;
            else return new System.IO.FileStream(filename, System.IO.FileMode.Create);
        }

        public static System.IO.FileStream getSaveFile(string[] path)
        {
            string filter = path[0];
            for (int i = 1; i < path.Length; i++) filter += "|" + path[i];
            System.Windows.Forms.SaveFileDialog f = new System.Windows.Forms.SaveFileDialog();
            f.Title = "保存";
            f.Filter = filter;
            f.ShowDialog();
            string filename = f.FileName;
            if (filename == "") return null;
            else return new System.IO.FileStream(filename, System.IO.FileMode.Create);
        }

        public static System.IO.FileStream getSaveFile(string current, string[] path)
        {
            string filter = path[0];
            for (int i = 1; i < path.Length; i++) filter += "|" + path[i];
            System.Windows.Forms.SaveFileDialog f = new System.Windows.Forms.SaveFileDialog();
            f.Title = "保存";
            f.Filter = filter;
            f.InitialDirectory = @current;
            f.ShowDialog();
            string filename = f.FileName;
            if (filename == "") return null;
            else return new System.IO.FileStream(filename, System.IO.FileMode.Create);
        }

    }
}
