示例#1
0
 protected void InitialiseProperties()
 {
     if (_configuration == null)
     {
         return;
     }
     if (_configuration.IsNative)
     {
         EmulatorType = EmulatorType.Native;
     }
     else if (_configuration.IsLibRetro)
     {
         EmulatorType = EmulatorType.LibRetro;
     }
     else
     {
         EmulatorType = EmulatorType.Emulator;
     }
     Name = _configuration.Name;
     if (!string.IsNullOrEmpty(_configuration.Path))
     {
         PathBrowser.ChoosenResourcePath = LocalFsResourceProviderBase.ToResourcePath(_configuration.Path);
     }
     Arguments              = _configuration.Arguments;
     WorkingDirectory       = _configuration.WorkingDirectory;
     UseQuotes              = _configuration.UseQuotes;
     ExitsOnEscapeKey       = _configuration.ExitsOnEscapeKey;
     FileExtensions         = new HashSet <string>(_configuration.FileExtensions);
     SelectedGameCategories = new List <string>(_configuration.Platforms);
     UpdateIsGameCategoriesSelected();
 }
        public bool IsVirtualResource(ResourcePath rp)
        {
            if (rp == null)
            {
                return(false);
            }
            int numPathSegments = rp.Count();

            if (numPathSegments == 0)
            {
                return(false);
            }
            ResourcePath firstRPSegment = new ResourcePath(new ProviderPathSegment[] { rp[0] });
            String       pathRoot       = Path.GetPathRoot(LocalFsResourceProviderBase.ToDosPath(firstRPSegment));

            if (string.IsNullOrEmpty(pathRoot) || pathRoot.Length < 2)
            {
                return(false);
            }
            string fullPath = LocalFsResourceProviderBase.ToDosPath(rp);

            if (!string.IsNullOrEmpty(fullPath) && fullPath.Equals(_dokanExecutor.MountPoint, StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }
            return(false);
        }
示例#3
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);
        }
示例#4
0
        protected void ImportRecording(string fileName)
        {
            ISystemResolver systemResolver = ServiceRegistration.Get <ISystemResolver>();
            IMediaLibrary   mediaLibrary   = ServiceRegistration.Get <IMediaLibrary>();

            List <Share> possibleShares = new List <Share>(); // Shares can point to different depth, we try to find the deepest one

            foreach (var share in mediaLibrary.GetShares(systemResolver.LocalSystemId).Values)
            {
                var dir = LocalFsResourceProviderBase.ToDosPath(share.BaseResourcePath.LastPathSegment.Path);
                if (dir != null && fileName.StartsWith(dir, StringComparison.InvariantCultureIgnoreCase))
                {
                    possibleShares.Add(share);
                }
            }
            if (possibleShares.Count == 0)
            {
                ServiceRegistration.Get <ILogger>().Warn("SlimTvService: Received notifaction of new recording but could not find a media source. Have you added recordings folder as media source? File: {0}", fileName);
                return;
            }

            Share           usedShare      = possibleShares.OrderByDescending(s => s.BaseResourcePath.LastPathSegment.Path.Length).First();
            IImporterWorker importerWorker = ServiceRegistration.Get <IImporterWorker>();

            importerWorker.ScheduleImport(LocalFsResourceProviderBase.ToResourcePath(fileName), usedShare.MediaCategories, false);
        }
        protected VideoDriveHandler(DriveInfo driveInfo, IEnumerable <Guid> extractedMIATypeIds) : base(driveInfo)
        {
            IMediaAccessor    mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();
            ResourcePath      rp            = LocalFsResourceProviderBase.ToResourcePath(driveInfo.Name);
            IResourceAccessor ra;

            if (!rp.TryCreateLocalResourceAccessor(out ra))
            {
                throw new ArgumentException(string.Format("Unable to access drive '{0}'", driveInfo.Name));
            }
            using (ra)
                _mediaItem = mediaAccessor.CreateLocalMediaItem(ra, mediaAccessor.GetMetadataExtractorsForMIATypes(extractedMIATypeIds));
            if (_mediaItem == null)
            {
                throw new Exception(string.Format("Could not create media item for drive '{0}'", driveInfo.Name));
            }

            MatchWithStubs(driveInfo, new MediaItem[] { _mediaItem });
            IEnumerable <MediaItem> processedItems = CertificationHelper.ProcessMediaItems(new MediaItem[] { _mediaItem });

            if (processedItems.Count() == 0)
            {
                _mediaItem = null;
                return;
            }
            _mediaItem = processedItems.First();
            SingleMediaItemAspect mia = null;

            MediaItemAspect.TryGetAspect(_mediaItem.Aspects, MediaAspect.Metadata, out mia);
            mia.SetAttribute(MediaAspect.ATTR_TITLE, mia.GetAttributeValue(MediaAspect.ATTR_TITLE) +
                             " (" + DriveUtils.GetDriveNameWithoutRootDirectory(driveInfo) + ")");
        }
示例#6
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);
        }
示例#7
0
        public void SearchApp()
        {
            string initialPath  = "C:\\";
            Guid   dialogHandle = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(S_APP, true, false,
                                                                                           string.IsNullOrEmpty(initialPath) ? null : LocalFsResourceProviderBase.ToResourcePath(initialPath),
                                                                                           path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                if (string.IsNullOrEmpty(choosenPath))
                {
                    return(false);
                }

                return(true);
            });

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

            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                AppPath = LocalFsResourceProviderBase.ToDosPath(choosenPath);

                ShortName = choosenPath.FileName.Substring(0, choosenPath.FileName.LastIndexOf(".", System.StringComparison.Ordinal));

                var icon = Icon.ExtractAssociatedIcon(AppPath);

                if (icon != null)
                {
                    IconPath = Help.GetIconPfad(choosenPath.FileName, icon.ToBitmap());
                }
            }, null);
        }
示例#8
0
        public override void ExecuteConfiguration()
        {
            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }

            var pathEntry = Setting as PathEntry;

            if (pathEntry == null)
            {
                return;
            }

            Guid dialogHandle = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(Help.Evaluate(), pathEntry.PathType == PathEntry.PathSelectionType.File, false,
                                                                                         string.IsNullOrEmpty(pathEntry.Path) ? null : LocalFsResourceProviderBase.ToResourcePath(pathEntry.Path),
                                                                                         path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                return(!string.IsNullOrEmpty(choosenPath));
            });

            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                pathEntry.Path = LocalFsResourceProviderBase.ToDosPath(choosenPath);
                Save();
                _pathBrowserCloseWatcher.Dispose();
                _pathBrowserCloseWatcher = null;
            },
                                                                   null);
        }
示例#9
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);
        }
示例#10
0
 public void UpdateLibRetroSettings()
 {
     if (_libRetroProxy == null)
     {
         _libRetroProxy = new LibRetroProxy(LocalFsResourceProviderBase.ToDosPath(PathBrowser.ChoosenResourcePath));
         _libRetroProxy.Init();
     }
 }
        public void UnregisterChangeTracker(PathChangeDelegate changeDelegate)
        {
            string dosPath = LocalFsResourceProviderBase.ToDosPath(_path);

            if (!string.IsNullOrEmpty(dosPath) && (File.Exists(dosPath) || Directory.Exists(dosPath)))
            {
                _provider.UnregisterChangeTracker(changeDelegate, dosPath);
            }
        }
示例#12
0
 protected void SetDefaultLibRetroSettings()
 {
     _libRetroProxy = new LibRetroProxy(LocalFsResourceProviderBase.ToDosPath(PathBrowser.ChoosenResourcePath));
     if (_libRetroProxy.Init())
     {
         Name           = _libRetroProxy.Name;
         FileExtensions = new HashSet <string>(_libRetroProxy.Extensions);
     }
 }
        public void RegisterChangeTracker(PathChangeDelegate changeDelegate, IEnumerable <string> fileNameFilters,
                                          IEnumerable <MediaSourceChangeType> changeTypes)
        {
            string dosPath = LocalFsResourceProviderBase.ToDosPath(_path);

            if (!string.IsNullOrEmpty(dosPath) && (File.Exists(dosPath) || Directory.Exists(dosPath)))
            {
                _provider.RegisterChangeTracker(changeDelegate, dosPath, fileNameFilters, changeTypes);
            }
        }
        public Stream OpenRead()
        {
            string dosPath = LocalFsResourceProviderBase.ToDosPath(_path);

            if (string.IsNullOrEmpty(dosPath) || !File.Exists(dosPath))
            {
                return(null);
            }
            return(new FileStream(dosPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
        }
        public Stream OpenWrite()
        {
            string dosPath = LocalFsResourceProviderBase.ToDosPath(_path);

            if (string.IsNullOrEmpty(dosPath) || !File.Exists(dosPath))
            {
                return(null);
            }
            return(File.OpenWrite(dosPath));
        }
示例#16
0
        /// <summary>
        /// Detects if the given directory contains video, image or audio media files and returns <see cref="MediaItem"/> instances for those files.
        /// </summary>
        /// <param name="directory">The directory to be examined.</param>
        /// <param name="videoMIATypeIds">Ids of the media item aspects to be extracted from video items.</param>
        /// <param name="imageMIATypeIds">Ids of the media item aspects to be extracted from image items.</param>
        /// <param name="audioMIATypeIds">Ids of the media item aspects to be extracted from audio items.</param>
        /// if the return value is <see cref="MultiMediaType.None"/>.</param>
        /// <returns>Type of media items found.</returns>
        public static MultiMediaType DetectMultimedia(string directory,
                                                      IEnumerable <Guid> videoMIATypeIds, IEnumerable <Guid> imageMIATypeIds, IEnumerable <Guid> audioMIATypeIds)
        {
            if (!Directory.Exists(directory))
            {
                return(MultiMediaType.None);
            }

            return(DetectMultimedia(LocalFsResourceProviderBase.ToResourcePath(directory),
                                    videoMIATypeIds, imageMIATypeIds, audioMIATypeIds));
        }
            public IList <Guid> Execute(IList <string> mediaFiles, ShareLocation shareLocation)
            {
                NumFiles = mediaFiles.Count;
                IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>();
                IContentDirectory        cd  = scm.ContentDirectory;
                string systemId = shareLocation == ShareLocation.Local ? ServiceRegistration.Get <ISystemResolver>().LocalSystemId : scm.HomeServerSystemId;

                Guid[] necessaryAudioAspectIds = null;
                Guid[] optionalAudioAspectIds  = null;

                ILogger        logger        = ServiceRegistration.Get <ILogger>();
                IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                Guid?          dialogId      = screenManager.ShowDialog(Consts.DIALOG_IMPORT_PLAYLIST_PROGRESS, (dialogName, dialogInstanceId) => Cancel());

                if (!dialogId.HasValue)
                {
                    logger.Warn("ImportPlaylistOperation: Error showing progress dialog");
                    return(null);
                }

                IList <Guid> result = new List <Guid>();

                NumMatched   = 0;
                NumProcessed = 0;
                NumMatched   = 0;
                UpdateScreenData();
                try
                {
                    foreach (string localMediaFile in mediaFiles)
                    {
                        if (IsCancelled)
                        {
                            return(null);
                        }
                        CheckUpdateScreenData();
                        MediaItem item = cd.LoadItem(systemId, LocalFsResourceProviderBase.ToResourcePath(localMediaFile), necessaryAudioAspectIds, optionalAudioAspectIds);
                        NumProcessed++;
                        if (item == null)
                        {
                            logger.Warn("ImportPlaylistOperation: Media item '{0}' was not found in the media library", localMediaFile);
                            continue;
                        }
                        logger.Debug("ImportPlaylistOperation: Matched media item '{0}' in media library", localMediaFile);
                        NumMatched++;
                        result.Add(item.MediaItemId);
                    }
                }
                catch (Exception e)
                {
                    logger.Warn("ImportPlaylistOperation: Error importing playlist", e);
                }
                screenManager.CloseDialog(dialogId.Value);
                return(result);
            }
示例#18
0
        protected void OnCoreItemSelectionChanged(AbstractProperty property, object oldValue)
        {
            ListItem selected = _localCoreItems.FirstOrDefault(i => i.Selected);

            if (selected == null)
            {
                return;
            }
            ResourcePath path = LocalFsResourceProviderBase.ToResourcePath(selected.Label(Consts.KEY_PATH, null).Evaluate());

            _emulatorProxy.PathBrowser.ChoosenResourcePath = path;
        }
        public Task <Stream> OpenReadAsync()
        {
            string dosPath = LocalFsResourceProviderBase.ToDosPath(_path);

            if (string.IsNullOrEmpty(dosPath) || !File.Exists(dosPath))
            {
                return(null);
            }
            // In this implementation there is no preparational work to do. We therefore return a
            // completed Task; there is no need for any async operation.
            return(Task.FromResult((Stream) new FileStream(dosPath, FileMode.Open, FileAccess.Read, FileShare.Read, ASYNC_STREAM_BUFFER_SIZE, true)));
        }
示例#20
0
        public static MediaItem CreateMediaItem(string filename)
        {
            IMediaAccessor     mediaAccessor   = ServiceRegistration.Get <IMediaAccessor>();
            IEnumerable <Guid> meIds           = mediaAccessor.GetMetadataExtractorsForMIATypes(NECESSARY_VIDEO_MIAS);
            ResourceLocator    resourceLocator = new ResourceLocator(LocalFsResourceProviderBase.ToResourcePath(filename));
            IResourceAccessor  ra = resourceLocator.CreateAccessor();

            if (ra == null)
            {
                return(null);
            }
            using (ra)
                return(mediaAccessor.CreateLocalMediaItem(ra, meIds));
        }
        public ICollection <IFileSystemResourceAccessor> GetFiles()
        {
            if (string.IsNullOrEmpty(_path))
            {
                return(null);
            }
            if (_path == "/")
            {
                // No files at root level - there are only logical drives
                return(new List <IFileSystemResourceAccessor>());
            }
            string dosPath = LocalFsResourceProviderBase.ToDosPath(_path);

            return((!string.IsNullOrEmpty(dosPath) && Directory.Exists(dosPath)) ? CreateChildResourceAccessors(Directory.GetFiles(dosPath), false) : null);
        }
        public ICollection <IFileSystemResourceAccessor> GetChildDirectories()
        {
            if (string.IsNullOrEmpty(_path))
            {
                return(null);
            }
            if (_path == "/")
            {
                return(Directory.GetLogicalDrives().Where(drive => new DriveInfo(drive).IsReady).Select <string, IFileSystemResourceAccessor>(
                           drive => new LocalFsResourceAccessor(_provider, "/" + FileUtils.RemoveTrailingPathDelimiter(drive) + "/")).ToList());
            }
            string dosPath = LocalFsResourceProviderBase.ToDosPath(_path);

            return((!string.IsNullOrEmpty(dosPath) && Directory.Exists(dosPath)) ? CreateChildResourceAccessors(Directory.GetDirectories(dosPath), true) : null);
        }
        protected bool GetSharesForPath(string fileName, string localSystemId, out List <Share> possibleShares)
        {
            IMediaLibrary mediaLibrary = ServiceRegistration.Get <IMediaLibrary>();

            possibleShares = new List <Share>();
            foreach (var share in mediaLibrary.GetShares(localSystemId).Values)
            {
                var dir = LocalFsResourceProviderBase.ToDosPath(share.BaseResourcePath.LastPathSegment.Path);
                if (dir != null && fileName.StartsWith(dir, StringComparison.InvariantCultureIgnoreCase))
                {
                    possibleShares.Add(share);
                }
            }
            return(possibleShares.Count > 0);
        }
        public Stream CreateOpenWrite(string file, bool overwrite)
        {
            string dosPath = LocalFsResourceProviderBase.ToDosPath(_path);

            if (string.IsNullOrEmpty(dosPath) || !Directory.Exists(dosPath))
            {
                return(null);
            }
            string filePath = System.IO.Path.Combine(dosPath, file);

            if (File.Exists(filePath) && !overwrite)
            {
                return(File.OpenWrite(filePath));
            }
            return(File.Create(filePath));
        }
    private string GetRemovableMediaItemPath(MediaItem mediaItem)
    {
      if (mediaItem == null)
        return null;

      foreach (var pra in mediaItem.PrimaryResources)
      {
        var resPath = ResourcePath.Deserialize(pra.GetAttributeValue<string>(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH));
        var dosPath = LocalFsResourceProviderBase.ToDosPath(resPath);
        if (string.IsNullOrEmpty(dosPath))
          continue;
        if (DriveUtils.IsDVD(dosPath))
          return dosPath;
      }
      return null;
    }
示例#26
0
        public void ShowWorkingDirectoryDialog()
        {
            string       workingDirectory = WorkingDirectory;
            ResourcePath initialPath      = string.IsNullOrEmpty(workingDirectory) ? null : LocalFsResourceProviderBase.ToResourcePath(workingDirectory);
            Guid         dialogHandle     = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser("[Emulators.Config.WorkingDirectory.Label]", false, false, initialPath,
                                                                                                     path =>
            {
                string chosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                return(!string.IsNullOrEmpty(chosenPath));
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }
            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, chosenPath => WorkingDirectory = LocalFsResourceProviderBase.ToDosPath(chosenPath), null);
        }
示例#27
0
        public ICollection <Share> CreateDefaultShares()
        {
            List <Share> result = new List <Share>();
            Guid         localFsResourceProviderId = LocalFsResourceProviderBase.LOCAL_FS_RESOURCE_PROVIDER_ID;

            if (LocalResourceProviders.ContainsKey(localFsResourceProviderId))
            {
                string folderPath;
                if (WindowsAPI.GetSpecialFolder(WindowsAPI.SpecialFolder.MyMusic, out folderPath))
                {
                    folderPath = LocalFsResourceProviderBase.ToProviderPath(folderPath);
                    string[] mediaCategories = new[] { DefaultMediaCategories.Audio.ToString() };
                    Share    sd = Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(localFsResourceProviderId, folderPath),
                                                            MY_MUSIC_SHARE_NAME_RESOURE, mediaCategories);
                    result.Add(sd);
                }

                if (WindowsAPI.GetSpecialFolder(WindowsAPI.SpecialFolder.MyVideos, out folderPath))
                {
                    folderPath = LocalFsResourceProviderBase.ToProviderPath(folderPath);
                    string[] mediaCategories = new[] { DefaultMediaCategories.Video.ToString() };
                    Share    sd = Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(localFsResourceProviderId, folderPath),
                                                            MY_VIDEOS_SHARE_NAME_RESOURCE, mediaCategories);
                    result.Add(sd);
                }

                if (WindowsAPI.GetSpecialFolder(WindowsAPI.SpecialFolder.MyPictures, out folderPath))
                {
                    folderPath = LocalFsResourceProviderBase.ToProviderPath(folderPath);
                    string[] mediaCategories = new[] { DefaultMediaCategories.Image.ToString() };
                    Share    sd = Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(localFsResourceProviderId, folderPath),
                                                            MY_PICTURES_SHARE_NAME_RESOURCE, mediaCategories);
                    result.Add(sd);
                }
            }
            if (result.Count > 0)
            {
                return(result);
            }
            // Fallback: If no share was added for the defaults above, use the provider's root folders
            result.AddRange(LocalBaseResourceProviders.Select(resourceProvider => resourceProvider.Metadata).Select(
                                metadata => Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(metadata.ResourceProviderId, "/"), metadata.Name, null)));
            return(result);
        }
示例#28
0
        public void FinishEmulatorConfiguration()
        {
            EmulatorConfiguration configuration;

            if (_emulatorProxy.Configuration != null)
            {
                configuration = _emulatorProxy.Configuration;
            }
            else
            {
                configuration = new EmulatorConfiguration()
                {
                    IsNative      = _emulatorProxy.EmulatorType == EmulatorType.Native,
                    IsLibRetro    = _emulatorProxy.EmulatorType == EmulatorType.LibRetro,
                    Id            = Guid.NewGuid(),
                    LocalSystemId = ServiceRegistration.Get <ISystemResolver>().LocalSystemId,
                    // Libretro configs are platform specific, assume it requires the current platform
                    Is64Bit = _emulatorProxy.EmulatorType == EmulatorType.LibRetro && Utils.IsCurrentPlatform64Bit()
                };
            }

            if (!configuration.IsNative)
            {
                configuration.Path = LocalFsResourceProviderBase.ToDosPath(_emulatorProxy.PathBrowser.ChoosenResourcePath);
            }
            configuration.Arguments        = _emulatorProxy.Arguments;
            configuration.WorkingDirectory = _emulatorProxy.WorkingDirectory;
            configuration.UseQuotes        = _emulatorProxy.UseQuotes;
            configuration.Name             = _emulatorProxy.Name;
            configuration.FileExtensions   = _emulatorProxy.FileExtensions;
            configuration.ExitsOnEscapeKey = _emulatorProxy.ExitsOnEscapeKey;
            configuration.Platforms.Clear();
            foreach (string category in _emulatorProxy.SelectedGameCategories)
            {
                configuration.Platforms.Add(category);
            }
            ServiceRegistration.Get <IEmulatorManager>().AddOrUpdate(configuration);
            if (configuration.IsLibRetro && _emulatorProxy.LibRetroProxy != null)
            {
                UpdateLibRetroCoreSetting(configuration.Path, _emulatorProxy.LibRetroProxy.Variables);
            }
            UpdateConfigurations();
            NavigateBackToOverview();
        }
示例#29
0
        public string GetFileSystemPath()
        {
            if (!string.IsNullOrEmpty(SourcePath))
            {
                var systemPath = LocalFsResourceProviderBase.ToDosPath(SourcePath);
                if (File.Exists(systemPath))
                {
                    return(systemPath);
                }

                var path = ResourcePath.Deserialize(SourcePath);
                if (path.BasePathSegment.ProviderId == LocalFsResourceProviderBase.LOCAL_FS_RESOURCE_PROVIDER_ID)
                {
                    return(LocalFsResourceProviderBase.ToDosPath(path));
                }
            }

            return(null);
        }
        /// <summary>
        /// Helper method to create a valid <see cref="ResourcePath"/> from the given path. This method supports both local and UNC paths and will use the right ResourceProviderId.
        /// </summary>
        /// <param name="path">Path or file name</param>
        /// <returns></returns>
        protected static ResourcePath BuildResourcePath(string path)
        {
            Guid providerId;

            if (path.StartsWith("\\\\"))
            {
                // NetworkNeighborhoodResourceProvider
                providerId = new Guid("{03DD2DA6-4DA8-4D3E-9E55-80E3165729A3}");
                // Cut-off the first \
                path = path.Substring(1);
            }
            else
            {
                providerId = LocalFsResourceProviderBase.LOCAL_FS_RESOURCE_PROVIDER_ID;
            }

            string folderPath   = LocalFsResourceProviderBase.ToProviderPath(path);
            var    resourcePath = ResourcePath.BuildBaseProviderPath(providerId, folderPath);

            return(resourcePath);
        }