예제 #1
0
파일: Shell.cs 프로젝트: davidov541/SAMI
        public static void Main(String[] args)
        {
            bool   isParsingDirectory  = false;
            bool   isParsingConfigFile = false;
            String configurationFile   = "ConsoleConfiguration.xml";

            foreach (String arg in args)
            {
                if (isParsingDirectory)
                {
                    ConfigurationManager.AddPluginDirectory(arg);
                    isParsingDirectory = false;
                }
                else if (isParsingConfigFile)
                {
                    configurationFile = Path.GetFullPath(arg);
                }
                else if (arg.Equals("-PluginDirectory"))
                {
                    isParsingDirectory = true;
                }
                else if (arg.Equals("-ConfigurationFile"))
                {
                    isParsingConfigFile = true;
                }
            }

#if !DEBUG
            Directory.SetCurrentDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SAMI"));
#endif
            _configManager = new ConfigurationManager(configurationFile);
            _sami          = new ShellSAMI(_configManager);
            SetConsoleCtrlHandler(new HandlerRoutine(ConsoleCtrlCheck), true);
            _sami.Run(false);
            Cleanup();
        }
예제 #2
0
        internal static int Main(string[] args)
        {
            bool   isParsingDirectory  = false;
            bool   isParsingConfigFile = false;
            String configurationFile   = "KinectConfiguration.xml";

            foreach (String arg in args)
            {
                if (isParsingDirectory)
                {
                    ConfigurationManager.AddPluginDirectory(arg);
                    isParsingDirectory = false;
                }
                else if (isParsingConfigFile)
                {
                    configurationFile   = Path.GetFullPath(arg);
                    isParsingConfigFile = false;
                }
                else if (arg.Equals("-PluginDirectory"))
                {
                    isParsingDirectory = true;
                }
                else if (arg.Equals("-ConfigurationFile"))
                {
                    isParsingConfigFile = true;
                }
            }

#if !DEBUG
            Directory.SetCurrentDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SAMI"));
#endif

            bool   updating     = false;
            Thread updateThread = null;
            ConfigurationManager configManager = new ConfigurationManager(configurationFile);

            try
            {
                // Create thread.
                updateThread = new Thread(() => UpdateThread(configManager));
                _isStopping  = false;
                updating     = false;

                _sami = new KinectSAMIFacade(configManager);

                // Start the update thread.
                updateThread.Start();

                SetConsoleCtrlHandler(new HandlerRoutine(ConsoleCtrlCheck), true);
                // Run SAMI until either she quits or we need to update.
                _sami.Run(!args.Contains("-NoIntro"));

                // Record whether we are updating or not.
                updating = _sami.CanBeUpdated;
            }
            catch (Exception e)
            {
                Logger.LogException(configManager, e);
                if (e.InnerException != null)
                {
                    Console.WriteLine(e.InnerException.ToString());
                }
                else
                {
                    Console.WriteLine(e.ToString());
                }
            }
            finally
            {
                // Stop everything.
                Cleanup();
                _isStopping = true;
                if (updateThread != null && updateThread.IsAlive)
                {
                    updateThread.Join();
                }
            }
            if (updating)
            {
                return(UpdateReturnValue);
            }
            return(0);
        }