Ejemplo n.º 1
0
        void PrintHeader()
        {
            string header = "===================================================\n"
                            + "TouchDesigner Version Detector 1.0.0\n"
                            + "(Copyright : 2018 Kodai Takao All Rights Reserved.)\n"
                            + "===================================================\n";

            MyConsole.ColoredWriteLine(header, ConsoleColor.DarkGreen);
        }
        string SearchInstalledDirectory(string path)
        {
            string file = path + "\\bin\\toeexpand.exe";

            if (File.Exists(file))
            {
                MyConsole.StatusWrite("Detected", true);
                Console.WriteLine("TouchDesigner{0}", Path.GetDirectoryName(path));

                MyConsole.StatusWrite("Expander", true);
                Console.WriteLine(file);

                return(file);
            }

            return(null);
        }
        public bool Expand(string toe_path)
        {
            if (!File.Exists(toe_path))
            {
                Console.WriteLine("No such file : " + toe_path);
                return(false);
            }

            MyConsole.StatusWrite("\nExecuted", true);
            Console.WriteLine("\"{0}\" \"{1}\"", Path.GetFileName(expander_path), Path.GetFileName(toe_path));

            Process p = Process.Start("\"" + expander_path + "\"", "\"" + toe_path + "\"");

            p.WaitForExit();

            MyConsole.StatusWriteLine("Successfully detected.", true);

            return(true);
        }
        public ToeExpander()
        {
            expander_path = SearchDefaultInstalledDirectory();

            // null check
            if (expander_path == null)
            {
                MyConsole.ColoredWriteLine("\nCouldn't find TouchDesigner in default installation folder.", ConsoleColor.Yellow);
                expander_path = AnotherFolderPrompt();

                if (expander_path == null)
                {
                    MyConsole.StatusWriteLine("TouchDesigner is not found.", false);
                    Console.WriteLine("Press any key to close application.");
                    Console.ReadLine();
                    Environment.Exit(0);
                }
            }
        }
        string SearchDefaultInstalledDirectory()
        {
            foreach (string version in versions)
            {
                string file = string.Format(default_td_path, version);
                // Console.WriteLine("Searching... " + dir);

                if (File.Exists(file))
                {
                    MyConsole.StatusWrite("Detected", true);
                    Console.WriteLine("TouchDesigner{0}", version);

                    MyConsole.StatusWrite("Expander", true);
                    Console.WriteLine(file);

                    return(file);
                }
            }

            return(null);
        }
        private string  AnotherFolderPrompt()
        {
            Console.Write("Input your installation directory (TouchDesignerXXX): ");

            string td_path = Console.ReadLine();

            if (td_path == "")
            {
                return(null);
            }

            string tmp_expander_path = SearchInstalledDirectory(td_path);

            if (tmp_expander_path == null)
            {
                MyConsole.StatusWriteLine("\nWrong path", false);
                return(AnotherFolderPrompt());
            }
            else
            {
                return(tmp_expander_path);
            }
        }
Ejemplo n.º 7
0
        void Start()
        {
            ToeExpander expander = new ToeExpander();

            Console.Write("\nInput .toe path : ");
            string toe_path = Console.ReadLine();

            if (expander.Expand(toe_path))
            {
                VersionDetector detector = new VersionDetector(toe_path);

                string version = detector.Detect();
                detector.DeleteGarbageDirectories();

                if (version != null)
                {
                    Console.Write("\n.toe version : ");
                    MyConsole.ColoredWriteLine(version, ConsoleColor.Cyan);

                    Console.Write("\nPress enter to end app.");
                    Console.ReadLine();
                }
            }
        }