Exemplo n.º 1
0
 public CheatCollection(IDialogParent dialogParent, ICheatConfig config)
 {
     _dialogParent = dialogParent;
     _config       = config;
 }
Exemplo n.º 2
0
 public static DialogResult ShowDialogAsChild(this IDialogParent dialogParent, Form dialog)
 => dialog.ShowDialog(dialogParent.SelfAsHandle);
Exemplo n.º 3
0
        public bool Load(string path, IDialogParent dialogParent)
        {
            // try to detect binary first
            using var bl = ZipStateLoader.LoadAndDetect(path);
            if (bl is null)
            {
                return(false);
            }
            var succeed = false;

            if (!VersionInfo.DeveloperBuild)
            {
                bl.GetLump(BinaryStateLump.BizVersion, true, tr => succeed = tr.ReadLine() == VersionInfo.GetEmuVersion());
                if (!succeed)
                {
                    var result = dialogParent.ModalMessageBox2(
                        "This savestate was made with a different version, so it's unlikely to work.\nChoose OK to try loading it anyway.",
                        "Savestate version mismatch",
                        EMsgBoxIcon.Question,
                        useOKCancel: true);
                    if (!result)
                    {
                        return(false);
                    }
                }
            }

            // Movie timeline check must happen before the core state is loaded
            if (_movieSession.Movie.IsActive())
            {
                bl.GetLump(BinaryStateLump.Input, true, tr => succeed = _movieSession.CheckSavestateTimeline(tr));
                if (!succeed)
                {
                    return(false);
                }
            }

            using (new SimpleTime("Load Core"))
            {
                bl.GetCoreState(br => _statable.LoadStateBinary(br), tr => _statable.LoadStateText(tr));
            }

            // We must handle movie input AFTER the core is loaded to properly handle mode changes, and input latching
            if (_movieSession.Movie.IsActive())
            {
                bl.GetLump(BinaryStateLump.Input, true, tr => succeed = _movieSession.HandleLoadState(tr));
                if (!succeed)
                {
                    return(false);
                }
            }

            if (_videoProvider != null)
            {
                bl.GetLump(BinaryStateLump.Framebuffer, false, br => PopulateFramebuffer(br, _videoProvider, _quickBmpFile));
            }

            string userData = "";

            bl.GetLump(BinaryStateLump.UserData, false, delegate(TextReader tr)
            {
                string line;
                while ((line = tr.ReadLine()) != null)
                {
                    if (!string.IsNullOrWhiteSpace(line))
                    {
                        userData = line;
                    }
                }
            });

            if (!string.IsNullOrWhiteSpace(userData))
            {
                var bag = (Dictionary <string, object>)ConfigService.LoadWithType(userData);
                _userBag.Clear();
                foreach (var(k, v) in bag)
                {
                    _userBag.Add(k, v);
                }
            }

            if (_movieSession.Movie.IsActive() && _movieSession.Movie is ITasMovie)
            {
                bl.GetLump(BinaryStateLump.LagLog, false, delegate(TextReader tr)
                {
                    ((ITasMovie)_movieSession.Movie).LagLog.Load(tr);
                });
            }

            return(true);
        }
Exemplo n.º 4
0
        private void ProcessFile([NotNull] FileInfo droppedFile, IDialogParent owner)
        {
            if ((droppedFile.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
            {
                Logger.Error($"{droppedFile.FullName} is a directory, ignoring.");
                return;
            }

            if (!droppedFile.IsMovieFile())
            {
                Logger.Info($"{droppedFile.FullName} is not a movie file, ignoring.");
                return;
            }

            // Note that the extension of the file may not be fi.extension as users can put ".mkv.t" for example as an extension
            string otherExtension = TVSettings.Instance.FileHasUsefulExtensionDetails(droppedFile, true);

            ShowConfiguration?bestShow = (string)cbShowList.SelectedItem == "<Auto>"
                ? FinderHelper.FindBestMatchingShow(droppedFile.FullName, mDoc.TvLibrary.Shows)
                : mDoc.TvLibrary.Shows.FirstOrDefault(item => item.ShowName == (string)cbShowList.SelectedItem);

            if (bestShow is null)
            {
                if (TVSettings.Instance.AutoAddAsPartOfQuickRename)
                {
                    List <MediaConfiguration> addedShows = FinderHelper.FindMedia(new List <FileInfo> {
                        droppedFile
                    }, mDoc, owner);
                    bestShow = addedShows.OfType <ShowConfiguration>().FirstOrDefault();

                    if (bestShow != null)
                    {
                        mDoc.Add(bestShow);
                        mDoc.TvAddedOrEdited(true, false, false, parent, bestShow);

                        Logger.Info($"Added new show called: {bestShow.ShowName}");
                    }
                }

                if (bestShow is null)
                {
                    Logger.Info($"Cannot find show for {droppedFile.FullName}, ignoring this file.");
                    return;
                }
            }

            if (!FinderHelper.FindSeasEp(droppedFile, out int seasonNum, out int episodeNum, out int _, bestShow,
                                         out TVSettings.FilenameProcessorRE _))
            {
                Logger.Info($"Cannot find episode for {bestShow.ShowName} for {droppedFile.FullName}, ignoring this file.");
                return;
            }

            try
            {
                ProcessedEpisode episode = bestShow.GetEpisode(seasonNum, episodeNum);

                string filename = TVSettings.Instance.FilenameFriendly(
                    TVSettings.Instance.NamingStyle.NameFor(episode, otherExtension,
                                                            droppedFile.DirectoryName.Length));

                FileInfo targetFile =
                    new FileInfo(droppedFile.DirectoryName.EnsureEndsWithSeparator() + filename);

                if (droppedFile.FullName == targetFile.FullName)
                {
                    Logger.Info(
                        $"Can't rename file for {bestShow.ShowName} for {droppedFile.FullName}, as it already has the appropriate name.");

                    return;
                }

                mDoc.TheActionList.Add(new ActionCopyMoveRename(droppedFile, targetFile, episode, mDoc));

                // if we're copying/moving a file across, we might also want to make a thumbnail or NFO for it
                mDoc.TheActionList.AddNullableRange(new DownloadIdentifiersController().ProcessEpisode(episode, targetFile));

                //If keep together is active then we may want to copy over related files too
                if (TVSettings.Instance.KeepTogether)
                {
                    FileFinder.KeepTogether(mDoc.TheActionList, false, true, mDoc);
                }
            }
            catch (ShowConfiguration.EpisodeNotFoundException)
            {
                Logger.Info(
                    $"Can't rename file for {bestShow.ShowName} for {droppedFile.FullName}, as it does not have Episode {episodeNum} for Season {seasonNum}.");
            }
        }
 public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
 {
     return(new CodecToken());
 }
 public FFmpegWriter(IDialogParent dialogParent) => _dialogParent = dialogParent;
Exemplo n.º 7
0
        public static List <MediaConfiguration> FindMedia([NotNull] IEnumerable <string> possibleShowNames, TVDoc doc, IDialogParent owner)
        {
            List <MediaConfiguration> addedShows = new List <MediaConfiguration>();

            foreach (string hint in possibleShowNames)
            {
                //if hint doesn't match existing added shows
                if (LookForSeries(hint, addedShows))
                {
                    Logger.Info($"Ignoring {hint} as it matches existing shows.");
                    continue;
                }
                if (LookForMovies(hint, addedShows))
                {
                    Logger.Info($"Ignoring {hint} as it matches existing movies.");
                    continue;
                }

                //If the hint contains certain terms then we'll ignore it
                if (TVSettings.Instance.IgnoredAutoAddHints.Contains(hint))
                {
                    Logger.Info(
                        $"Ignoring {hint} as it is in the list of ignored terms the user has selected to ignore from prior Auto Adds.");

                    continue;
                }

                //Remove any (nnnn) in the hint - probably a year
                string refinedHint = Regex.Replace(hint, @"\(\d{4}\)", "");

                //Remove anything we can from hint to make it cleaner and hence more likely to match
                refinedHint = RemoveSeriesEpisodeIndicators(refinedHint, doc.TvLibrary.SeasonWords());

                if (string.IsNullOrWhiteSpace(refinedHint))
                {
                    Logger.Info($"Ignoring {hint} as it refines to nothing.");
                    continue;
                }

                //If there are no LibraryFolders then we cant use the simplified UI
                if (TVSettings.Instance.LibraryFolders.Count + TVSettings.Instance.MovieLibraryFolders.Count == 0)
                {
                    MessageBox.Show(
                        "Please add some monitor (library) folders under 'Bulk Add Shows' to use the 'Auto Add' functionality (Alternatively you can add them or turn it off in settings).",
                        "Can't Auto Add Show", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    continue;
                }

                Logger.Info("****************");
                Logger.Info($"Auto Adding New Show/Movie for '{refinedHint}'");

                //popup dialog
                AutoAddShow askForMatch = new AutoAddShow(refinedHint, hint);

                owner.ShowChildDialog(askForMatch);
                DialogResult dr = askForMatch.DialogResult;
                askForMatch.Dispose();

                if (dr == DialogResult.OK)
                {
                    //If added add show to collection
                    if (askForMatch.ShowConfiguration.Code > 0)
                    {
                        addedShows.Add(askForMatch.ShowConfiguration);
                        doc.Stats().AutoAddedShows++;
                    }
                    else
                    {
                        addedShows.Add(askForMatch.MovieConfiguration);
                        doc.Stats().AutoAddedMovies++;
                    }
                }
                else if (dr == DialogResult.Abort)
                {
                    Logger.Info("Skippng Auto Add Process");
                    break;
                }
                else if (dr == DialogResult.Ignore)
                {
                    Logger.Info($"Permenantly Ignoring 'Auto Add' for: {hint}");
                    TVSettings.Instance.IgnoredAutoAddHints.Add(hint);
                }
                else
                {
                    Logger.Info($"Cancelled Auto adding new show/movie {hint}");
                }
            }

            return(addedShows);
        }
Exemplo n.º 8
0
 public static FileInfo SaveFileDialog(string currentFile, string path, string fileType, string fileExt, IDialogParent parent)
 {
     return(SaveFileDialog(currentFile, path, new FilesystemFilterSet(new FilesystemFilter(fileType, new[] { fileExt })), parent));
 }
 public static DialogResult ShowDialogWithTempMute(this IDialogParent dialogParent, CommonDialog dialog)
 => dialogParent.DialogController.DoWithTempMute(() => dialog.ShowDialog(dialogParent.AsWinFormsHandle()));
        public static void Run(IDialogParent parent)
        {
            var form = new FFmpegDownloaderForm();

            parent.ShowDialogWithTempMute(form);
        }
 public static DialogResult ShowDialogAsChild(this IDialogParent dialogParent, Form dialog)
 => dialog.ShowDialog(dialogParent.AsWinFormsHandle());
 public static IWin32Window AsWinFormsHandle(this IDialogParent dialogParent) => (IWin32Window)dialogParent;
Exemplo n.º 13
0
        public static DialogResult DoSettingsDialog(IDialogParent dialogParent, ISettingsAdapter settable)
        {
            var s  = (BsnesCore.SnesSettings)settable.GetSettings();
            var ss = (BsnesCore.SnesSyncSettings)settable.GetSyncSettings();

            using var dlg = new BSNESOptions
                  {
                      AlwaysDoubleSize = s.AlwaysDoubleSize,
                      CropSGBFrame     = s.CropSGBFrame,
                      Entropy          = ss.Entropy,
                      RegionOverride   = ss.RegionOverride,
                      Hotfixes         = ss.Hotfixes,
                      FastPPU          = ss.FastPPU,
                      FastDSP          = ss.FastDSP,
                      FastCoprocessors = ss.FastCoprocessors,
                      UseSGB2          = ss.UseSGB2,
                      ShowObj1         = s.ShowOBJ_0,
                      ShowObj2         = s.ShowOBJ_1,
                      ShowObj3         = s.ShowOBJ_2,
                      ShowObj4         = s.ShowOBJ_3,
                      ShowBg1_0        = s.ShowBG1_0,
                      ShowBg1_1        = s.ShowBG1_1,
                      ShowBg2_0        = s.ShowBG2_0,
                      ShowBg2_1        = s.ShowBG2_1,
                      ShowBg3_0        = s.ShowBG3_0,
                      ShowBg3_1        = s.ShowBG3_1,
                      ShowBg4_0        = s.ShowBG4_0,
                      ShowBg4_1        = s.ShowBG4_1
                  };

            var result = dialogParent.ShowDialogAsChild(dlg);

            if (result == DialogResult.OK)
            {
                s.AlwaysDoubleSize  = dlg.AlwaysDoubleSize;
                s.CropSGBFrame      = dlg.CropSGBFrame;
                ss.Entropy          = dlg.Entropy;
                ss.RegionOverride   = dlg.RegionOverride;
                ss.Hotfixes         = dlg.Hotfixes;
                ss.FastPPU          = dlg.FastPPU;
                ss.FastDSP          = dlg.FastDSP;
                ss.FastCoprocessors = dlg.FastCoprocessors;
                ss.UseSGB2          = dlg.UseSGB2;
                s.ShowOBJ_0         = dlg.ShowObj1;
                s.ShowOBJ_1         = dlg.ShowObj2;
                s.ShowOBJ_2         = dlg.ShowObj3;
                s.ShowOBJ_3         = dlg.ShowObj4;
                s.ShowBG1_0         = dlg.ShowBg1_0;
                s.ShowBG1_1         = dlg.ShowBg1_1;
                s.ShowBG2_0         = dlg.ShowBg2_0;
                s.ShowBG2_1         = dlg.ShowBg2_1;
                s.ShowBG3_0         = dlg.ShowBg3_0;
                s.ShowBG3_1         = dlg.ShowBg3_1;
                s.ShowBG4_0         = dlg.ShowBg4_0;
                s.ShowBG4_1         = dlg.ShowBg4_1;

                settable.PutCoreSettings(s);
                settable.PutCoreSyncSettings(ss);
            }
            return(result);
        }
Exemplo n.º 14
0
 public static DialogResult ShowDialogWithTempMute(this IDialogParent dialogParent, Form dialog)
 => dialogParent.DialogController.DoWithTempMute(() => dialog.ShowDialog(dialogParent.SelfAsHandle));
Exemplo n.º 15
0
 /// <param name="dialogParent">parent for if the user is shown config dialog</param>
 public IVideoWriter Create(IDialogParent dialogParent) => (IVideoWriter)(
     _type.GetConstructor(CTOR_TYPES_A)
     ?.Invoke(new object[] { dialogParent })
     ?? Activator.CreateInstance(_type));
        private void CreateFolder(MovieConfiguration si, ICollection <string> ignoredLocations, string proposedFolderName, IDialogParent owner)
        {
            string folder = proposedFolderName;

            // generate new filename info
            // ReSharper disable once RedundantAssignment
            bool          goAgain      = false;
            DirectoryInfo di           = null;
            bool          firstAttempt = true;

            do
            {
                goAgain = false;
                if (!string.IsNullOrEmpty(folder))
                {
                    try
                    {
                        di = new DirectoryInfo(folder);
                    }
                    catch (Exception e)
                    {
                        LOGGER.Warn($"Could not create Folder {folder} as {e.Message}.");
                        break;
                    }
                }

                if (ignoredLocations.Contains(folder))
                {
                    break;
                }

                if (di != null && di.Exists)
                {
                    continue;
                }

                string?otherFolder = null;

                FaResult whatToDo = GetDefaultAction();

                if (TVSettings.Instance.AutoCreateFolders && firstAttempt)
                {
                    whatToDo     = FaResult.kfaCreate;
                    firstAttempt = false;
                }

                if (whatToDo == FaResult.kfaNotSet)
                {
                    // no command line guidance, so ask the user
                    MissingFolderAction mfa = new MissingFolderAction(si.ShowName, "", folder);

                    owner.ShowChildDialog(mfa);
                    whatToDo    = mfa.Result;
                    otherFolder = mfa.FolderName;
                    mfa.Dispose();
                }

                switch (whatToDo)
                {
                case FaResult.kfaRetry:
                    goAgain = true;
                    break;

                case FaResult.kfaDifferentFolder:
                    if (otherFolder != null)
                    {
                        folder = otherFolder;
                    }
                    goAgain = UpdateDirectory(si, folder);
                    break;

                case FaResult.kfaNotSet:
                    break;

                case FaResult.kfaCancel:
                    throw new TVRenameOperationInterruptedException();

                case FaResult.kfaCreate:
                    TryCreateDirectory(folder, si.ShowName);
                    goAgain = true;
                    break;

                case FaResult.kfaIgnoreOnce:
                    ignoredLocations.Add(folder);
                    break;

                case FaResult.kfaIgnoreAlways:
                    // si.IgnoreSeasons.Add(snum);  TODO What should we do here? Turn off auto / manual folders?
                    Doc.SetDirty();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            } while (goAgain);
        }
Exemplo n.º 17
0
 /// <summary>
 /// find an IVideoWriter by its short name
 /// </summary>
 /// <param name="dialogParent">parent for if the user is shown config dialog</param>
 public static IVideoWriter GetVideoWriter(string name, IDialogParent dialogParent)
 {
     return(VideoWriters.TryGetValue(name, out var ret)
                         ? ret.Create(dialogParent)
                         : null);
 }
Exemplo n.º 18
0
        public static FileInfo SaveFileDialog(string currentFile, string path, FilesystemFilterSet filterSet, IDialogParent parent)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            using var sfd = new SaveFileDialog
                  {
                      FileName         = Path.GetFileName(currentFile),
                      InitialDirectory = path,
                      Filter           = filterSet.ToString(),
                      RestoreDirectory = true
                  };

            var result = parent.ShowDialogWithTempMute(sfd);

            return(result.IsOk() ? new FileInfo(sfd.FileName) : null);
        }
Exemplo n.º 19
0
        public static List <MediaConfiguration> FindMedia([NotNull] IEnumerable <FileInfo> possibleShows, TVDoc doc, IDialogParent owner)
        {
            List <MediaConfiguration> addedShows = new List <MediaConfiguration>();

            foreach (FileInfo file in possibleShows)
            {
                string hint = file.RemoveExtension(TVSettings.Instance.UseFullPathNameToMatchSearchFolders) + ".";

                //If the hint contains certain terms then we'll ignore it
                if (TVSettings.Instance.IgnoredAutoAddHints.Contains(hint))
                {
                    Logger.Info(
                        $"Ignoring {hint} as it is in the list of ignored terms the user has selected to ignore from prior Auto Adds.");

                    continue;
                }
                //remove any search folders  from the hint. They are probbably useless at helping specify the showname
                foreach (var path in TVSettings.Instance.DownloadFolders)
                {
                    if (hint.StartsWith(path, StringComparison.OrdinalIgnoreCase))
                    {
                        hint = hint.RemoveFirst(path.Length);
                    }
                }

                //Remove any (nnnn) in the hint - probably a year
                string refinedHint = Regex.Replace(hint, @"\(\d{4}\)", "");

                //Remove anything we can from hint to make it cleaner and hence more likely to match
                refinedHint = RemoveSeriesEpisodeIndicators(refinedHint, doc.TvLibrary.SeasonWords());

                if (string.IsNullOrWhiteSpace(refinedHint))
                {
                    Logger.Info($"Ignoring {hint} as it refines to nothing.");
                    continue;
                }

                //if hint doesn't match existing added shows
                if (LookForSeries(refinedHint, addedShows))
                {
                    Logger.Info($"Ignoring {hint} as it matches shows already being added.");
                    continue;
                }
                if (LookForMovies(refinedHint, addedShows))
                {
                    Logger.Info($"Ignoring {hint} as it matches existing movies already being added: {addedShows.Where(si => si.NameMatch(refinedHint)).Select(s => s.ShowName).ToCsv()}");
                    continue;
                }

                //if hint doesn't match existing added shows
                if (LookForSeries(refinedHint, doc.TvLibrary.Shows))
                {
                    Logger.Info($"Ignoring {hint} as it matches shows already in the library.");
                    continue;
                }
                if (LookForMovies(refinedHint, doc.FilmLibrary.Movies))
                {
                    Logger.Info($"Ignoring {hint} as it matches existing movies already in the library: {doc.FilmLibrary.Movies.Where(si => si.NameMatch(refinedHint)).Select(s=>s.ShowName).ToCsv()}");
                    continue;
                }

                //If there are no LibraryFolders then we cant use the simplified UI
                if (TVSettings.Instance.LibraryFolders.Count + TVSettings.Instance.MovieLibraryFolders.Count == 0)
                {
                    MessageBox.Show(
                        "Please add some monitor (library) folders under 'Bulk Add Shows' to use the 'Auto Add' functionality (Alternatively you can add them or turn it off in settings).",
                        "Can't Auto Add Show", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    continue;
                }

                bool assumeMovie = FinderHelper.IgnoreHint(hint) || !file.FileNameNoExt().ContainsAnyCharactersFrom("0123456789");

                if (assumeMovie && TVSettings.Instance.DefMovieDefaultLocation.HasValue() && TVSettings.Instance.DefMovieUseDefaultLocation && true)//todo use  TVSettings.Instance.AutomateAutoAddWhenOneMovieFound
                {
                    var foundMovie = LocalCache.Instance.GetMovie(refinedHint, null, true, true);
                    if (foundMovie != null)
                    {
                        // no need to popup dialog
                        Logger.Info($"Auto Adding New Movie for '{refinedHint}' (directly) : {foundMovie.Name}");

                        MovieConfiguration newMovie = new MovieConfiguration();
                        newMovie.TmdbCode            = foundMovie.TmdbCode;
                        newMovie.UseAutomaticFolders = true;
                        newMovie.AutomaticFolderRoot = TVSettings.Instance.DefMovieDefaultLocation;
                        newMovie.Format = MovieConfiguration.MovieFolderFormat.singleDirectorySingleFile;
                        newMovie.UseCustomFolderNameFormat = false;
                        newMovie.ConfigurationProvider     = TVDoc.ProviderType.TMDB;

                        if (!hint.Contains(foundMovie?.Name ?? string.Empty, StringComparison.OrdinalIgnoreCase))
                        {
                            newMovie.AliasNames.Add(hint);
                        }


                        addedShows.Add(newMovie);
                        doc.Stats().AutoAddedMovies++;
                        continue;
                    }
                }
                //popup dialog
                AutoAddShow askForMatch = new AutoAddShow(refinedHint, file, assumeMovie);

                if (askForMatch.SingleTvShowFound && !askForMatch.SingleMovieFound && true) //todo use  TVSettings.Instance.AutomateAutoAddWhenOneShowFound
                {
                    // no need to popup dialog
                    Logger.Info($"Auto Adding New Show for '{refinedHint}' : {askForMatch.ShowConfiguration.CachedShow.Name}");
                    addedShows.Add(askForMatch.ShowConfiguration);
                    doc.Stats().AutoAddedShows++;
                }
                else if (askForMatch.SingleMovieFound && !askForMatch.SingleTvShowFound && true) //todo use  TVSettings.Instance.AutomateAutoAddWhenOneMovieFound
                {
                    // no need to popup dialog
                    Logger.Info($"Auto Adding New Movie for '{refinedHint}' : {askForMatch.MovieConfiguration.CachedMovie.Name}");
                    addedShows.Add(askForMatch.MovieConfiguration);
                    doc.Stats().AutoAddedMovies++;
                }
                else
                {
                    Logger.Info($"Auto Adding New Show/Movie by asking about for '{refinedHint}'");
                    owner.ShowChildDialog(askForMatch);
                    DialogResult dr = askForMatch.DialogResult;

                    if (dr == DialogResult.OK)
                    {
                        //If added add show ot collection
                        if (askForMatch.ShowConfiguration.Code > 0)
                        {
                            addedShows.Add(askForMatch.ShowConfiguration);
                            doc.Stats().AutoAddedShows++;
                        }
                        else if (askForMatch.MovieConfiguration.Code > 0)
                        {
                            addedShows.Add(askForMatch.MovieConfiguration);
                            doc.Stats().AutoAddedMovies++;
                        }
                    }
                    else if (dr == DialogResult.Abort)
                    {
                        Logger.Info("Skippng Auto Add Process");
                        break;
                    }
                    else if (dr == DialogResult.Ignore)
                    {
                        Logger.Info($"Permenantly Ignoring 'Auto Add' for: {hint}");
                        TVSettings.Instance.IgnoredAutoAddHints.Add(hint);
                    }
                    else
                    {
                        Logger.Info($"Cancelled Auto adding new show/movie {hint}");
                    }
                }

                askForMatch.Dispose();
            }

            return(addedShows);
        }
Exemplo n.º 20
0
        public static void SaveAsFile(this Bitmap bitmap, IGameInfo game, string suffix, string systemId, PathEntryCollection paths, IDialogParent parent)
        {
            using var sfd = new SaveFileDialog
                  {
                      FileName         = $"{game.FilesystemSafeName()}-{suffix}",
                      InitialDirectory = paths.ScreenshotAbsolutePathFor(systemId),
                      Filter           = FilesystemFilterSet.Screenshots.ToString(),
                      RestoreDirectory = true
                  };

            if (parent.ShowDialogWithTempMute(sfd) != DialogResult.OK)
            {
                return;
            }

            var         file      = new FileInfo(sfd.FileName);
            string      extension = file.Extension.ToUpper();
            ImageFormat i         = extension switch
            {
                ".BMP" => ImageFormat.Bmp,
                _ => ImageFormat.Png,
            };

            bitmap.Save(file.FullName, i);
        }
Exemplo n.º 21
0
 public static bool?ModalMessageBox3(
     this IDialogParent dialogParent,
     string text,
     string?caption   = null,
     EMsgBoxIcon?icon = null)
 => dialogParent.DialogController.ShowMessageBox3(owner: dialogParent, text: text, caption: caption, icon: icon);