Beispiel #1
0
        public void ChooseBackgroundVideo()
        {
            string videoFilename = BackgroundVideoFilename;
            string initialPath   = string.IsNullOrEmpty(videoFilename) ? null : DosPathHelper.GetDirectory(videoFilename);
            Guid   dialogHandle  = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(RES_HEADER_CHOOSE_VIDEO, true, false,
                                                                                            string.IsNullOrEmpty(initialPath) ? null : LocalFsResourceProviderBase.ToResourcePath(initialPath),
                                                                                            path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                if (string.IsNullOrEmpty(choosenPath))
                {
                    return(false);
                }

                return(MediaItemHelper.IsValidVideo(MediaItemHelper.CreateMediaItem(choosenPath)));
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }

            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                BackgroundVideoFilename = LocalFsResourceProviderBase.ToDosPath(choosenPath);
            },
                                                                   null);
        }
Beispiel #2
0
        public void ChooseImportFile()
        {
            string importFile   = ImportFile;
            string initialPath  = string.IsNullOrEmpty(importFile) ? null : DosPathHelper.GetDirectory(importFile);
            Guid   dialogHandle = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(Consts.RES_CHOOSE_IMPORT_FILE_DIALOG_HEADER, true, false,
                                                                                           string.IsNullOrEmpty(initialPath) ? null : LocalFsResourceProviderBase.ToResourcePath(initialPath),
                                                                                           path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                if (string.IsNullOrEmpty(choosenPath))
                {
                    return(false);
                }
                string extension = StringUtils.TrimToEmpty(DosPathHelper.GetExtension(choosenPath)).ToLowerInvariant();
                return((extension == ".m3u" || extension == ".m3u8") && File.Exists(choosenPath));
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }
            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                ImportFile = LocalFsResourceProviderBase.ToDosPath(choosenPath);
            },
                                                                   null);
        }
Beispiel #3
0
        public void OpenSelectUserImageDialog()
        {
            string imageFilename = _imagePath;
            string initialPath   = string.IsNullOrEmpty(imageFilename) ? null : DosPathHelper.GetDirectory(imageFilename);
            Guid   dialogHandle  = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(Consts.RES_SELECT_USER_IMAGE, true, false,
                                                                                            string.IsNullOrEmpty(initialPath) ? null : LocalFsResourceProviderBase.ToResourcePath(initialPath),
                                                                                            path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                if (string.IsNullOrEmpty(choosenPath))
                {
                    return(false);
                }

                return(IsValidImage(choosenPath));
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }

            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                ImagePath = LocalFsResourceProviderBase.ToDosPath(choosenPath);
            }, null);
        }
        protected string CreateArguments(EmulatorConfiguration emulatorConfiguration, string gamePath)
        {
            if (emulatorConfiguration.IsNative)
            {
                return(emulatorConfiguration.Arguments);
            }

            string format    = emulatorConfiguration.UseQuotes ? "\"{0}\"" : "{0}";
            string arguments = emulatorConfiguration.Arguments ?? "";

            arguments = arguments.Replace(EmulatorConfiguration.WILDCARD_GAME_DIRECTORY, string.Format(format, DosPathHelper.GetDirectory(gamePath)));
            if (!arguments.Contains(EmulatorConfiguration.WILDCARD_GAME_PATH) && !arguments.Contains(EmulatorConfiguration.WILDCARD_GAME_PATH_NO_EXT))
            {
                return(string.Format("{0} {1}", arguments.TrimEnd(), string.Format(format, gamePath)));
            }
            return(arguments.Replace(EmulatorConfiguration.WILDCARD_GAME_PATH, string.Format(format, gamePath))
                   .Replace(EmulatorConfiguration.WILDCARD_GAME_PATH_NO_EXT, string.Format(format, DosPathHelper.GetFileNameWithoutExtension(gamePath))));
        }
 public bool TryStart()
 {
     try
     {
         string path      = CreatePath(_emulatorConfiguration, _gamePath);
         string arguments = CreateArguments(_emulatorConfiguration, _gamePath);
         ServiceRegistration.Get <ILogger>().Debug("EmulatorProcess: Starting '{0} {1}'", path, arguments);
         _process           = new Process();
         _process.StartInfo = new ProcessStartInfo(path, arguments);
         _process.StartInfo.WorkingDirectory = string.IsNullOrEmpty(_emulatorConfiguration.WorkingDirectory) ? DosPathHelper.GetDirectory(_emulatorConfiguration.Path) : _emulatorConfiguration.WorkingDirectory;
         _process.EnableRaisingEvents        = true;
         _process.Exited += OnExited;
         bool result = _process.Start();
         if (result && !_emulatorConfiguration.IsNative && _mappedKey != null && _mappedKey != Key.None)
         {
             _inputHandler = new InputHandler(_process.Id, _mappedKey);
             _inputHandler.MappedKeyPressed += OnMappedKeyPressed;
         }
         return(result);
     }
     catch (Exception ex)
     {
         ServiceRegistration.Get <ILogger>().Error("EmulatorProcess: Error starting process", ex);
         return(false);
     }
 }