Exemplo n.º 1
0
        public static StartUpConfig CreateConfig(string[] args, string defaultMedia)
        {
            StartUpConfig config = new StartUpConfig()
            {
                ScreenNumber = 0, MediaPath = defaultMedia
            };

            foreach (var arg in args)
            {
                if (string.IsNullOrWhiteSpace(arg))
                {
                    continue;
                }

                var splitArgs = arg.Trim().Split(':');
                if (splitArgs.Length >= 2)
                {
                    if (splitArgs[0] == FullScreenProperty)
                    {
                        bool fullscreen;
                        if (bool.TryParse(splitArgs[1], out fullscreen))
                        {
                            config.FullScreen = fullscreen;
                        }
                    }
                    if (splitArgs[0] == PauseOnStartProperty)
                    {
                        bool pause;
                        if (bool.TryParse(splitArgs[1], out pause))
                        {
                            config.PauseOnStart = pause;
                        }
                    }
                    if (splitArgs[0] == ScreenNumberProperty)
                    {
                        int screen;
                        if (int.TryParse(splitArgs[1], out screen))
                        {
                            config.ScreenNumber = screen;
                        }
                    }
                    if (splitArgs[0] == PresetPathProperty)
                    {
                        if (splitArgs.Length == 3)
                        {
                            config.PresetPath = String.Format("{0}:{1}", splitArgs[1], splitArgs[2]);
                        }
                        else
                        {
                            config.PresetPath = splitArgs[1];
                        }
                    }
                    if (splitArgs[0] == MediaPathProperty)
                    {
                        if (splitArgs.Length == 3)
                        {
                            config.MediaPath = String.Format("{0}:{1}", splitArgs[1], splitArgs[2]);
                        }
                        else
                        {
                            config.MediaPath = splitArgs[1];
                        }
                    }
                }
            }
            return(config);
        }
Exemplo n.º 2
0
        public void App_OnStartup(object sender, StartupEventArgs e)
        {
            try
            {
                // using (FileStream fs = File.Create(@"D:\hh.txt"))
                //   TaskBarHelper.HideTaskBar();
                //Set default culture
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

                //Load settings
                _settingsManager.Load();

                //Load media and preset from command line arguments
                var args = Environment.GetCommandLineArgs();

                var config = StartUpConfig.CreateConfig(args, Path.GetFullPath(DefaultMedia));
                Logger.Instance.Info(string.Format("Loading media '{0}'...", config.MediaPath));

                ((MediaService)_mediaService).StartUpConfig = config;
                _mediaService.Load(config.MediaPath);


                if (string.IsNullOrWhiteSpace(config.PresetPath) == false)
                {
                    Logger.Instance.Info(string.Format("Loading preset '{0}'...", config.PresetPath));
                    _presetsManager.LoadFromUri(config.PresetPath);
                }
                ViewModelFactory.StartUpConfig = config;


                //////////////////////////////////////////////////////////////////////////
                //// loading sequence for vrplayer URI-schemes:
                //////////////////////////////////////////////////////////////////////////
                ////if (args.Length > 1 && args[1].Length > UriScheme.Length)
                //if (args.Length > 1 && args[1].ToLower().StartsWith(UriScheme))
                //{
                //    ////////////////////////////////////////////////////////////////////
                //    // this is a "vrplayer:" command line parameter
                //    ////////////////////////////////////////////////////////////////////
                //    var source = args[1].Remove(0, UriScheme.Length);

                //    Logger.Instance.Info(string.Format("Loading media '{0}'...", source));
                //    _mediaService.Load(source);
                //}
                //else if (args.Length > 1)
                //{
                //    /////////////////////////////////////////////////////////////////////
                //    // a command line parameter was passed, so let's assume the first one
                //    // is a media file to load and play
                //    /////////////////////////////////////////////////////////////////////

                //    var source = args[1];
                //    if (File.Exists(source))
                //    {
                //        Logger.Instance.Info(string.Format("Loading media '{0}'...", source));
                //        _mediaService.Load(source);
                //    }

                //}
                //else
                //{

                //    /////////////////////////////////////////////////////////////////////
                //    // CL: nothing passed, load the default media
                //    /////////////////////////////////////////////////////////////////////
                //    _mediaService.Load(Path.GetFullPath(DefaultMedia));

                //}

                //if (args.Length > 2)
                //{
                //    var preset = args[2];
                //    Logger.Instance.Info(string.Format("Loading preset '{0}'...", preset));
                //    _presetsManager.LoadFromUri(preset);
                //}
            }
            catch (Exception exc)
            {
                Logger.Instance.Error("Error while starting up application.", exc);
            }
        }