Beispiel #1
0
        private void UpdateErrorMessage(string filename)
        {
            string url;
            var    extension = Path.GetExtension(filename)?.Replace(@".", "").ToLowerInvariant();

            switch (extension)
            {
            case ".ogv":
                url = @"https://xiph.org/dshow/";
                break;

            case ".webm":
                url = @"https://tools.google.com/dlpage/webmmf/";
                break;

            case null:
            case "":
                url = null;
                break;

            default:
                url = $@"https://google.com/search?q={extension}+windows+media+player+codec";
                break;
            }

            ((BbCodeBlock)_switch.False).Text = string.Format(
                "Can’t play file. Make sure Windows Media Player is available and {0}required codec is installed{1}, or enable VLC plugin instead.",
                url == null ? "" : $@"[url={BbCodeBlock.EncodeAttribute(url)}]",
                url == null ? "" : @"[/url]");
        }
Beispiel #2
0
        private string IdToBb(string id, bool car = true)
        {
            const string searchIcon =
                "F1 M 42.5,22C 49.4036,22 55,27.5964 55,34.5C 55,41.4036 49.4036,47 42.5,47C 40.1356,47 37.9245,46.3435 36,45.2426L 26.9749,54.2678C 25.8033,55.4393 23.9038,55.4393 22.7322,54.2678C 21.5607,53.0962 21.5607,51.1967 22.7322,50.0251L 31.7971,40.961C 30.6565,39.0755 30,36.8644 30,34.5C 30,27.5964 35.5964,22 42.5,22 Z M 42.5,26C 37.8056,26 34,29.8056 34,34.5C 34,39.1944 37.8056,43 42.5,43C 47.1944,43 51,39.1944 51,34.5C 51,29.8056 47.1944,26 42.5,26 Z";
            const string linkIcon =
                "F1 M 23.4963,46.1288L 25.0796,48.8712L 29.4053,50.0303L 33.519,47.6553L 34.8902,46.8636L 37.6326,45.2803L 38.4242,46.6515L 37.2652,50.9772L 30.4091,54.9356L 21.7577,52.6174L 18.591,47.1326L 20.9091,38.4811L 27.7652,34.5227L 32.0909,35.6818L 32.8826,37.053L 30.1402,38.6364L 28.769,39.428L 24.6553,41.803L 23.4963,46.1288 Z M 38.7348,28.1895L 45.5908,24.2311L 54.2423,26.5493L 57.409,32.0341L 55.0908,40.6856L 48.2348,44.6439L 43.9091,43.4848L 43.1174,42.1136L 45.8598,40.5303L 47.231,39.7386L 51.3446,37.3636L 52.5037,33.0379L 50.9204,30.2955L 46.5946,29.1364L 42.481,31.5114L 41.1098,32.3031L 38.3674,33.8864L 37.5757,32.5152L 38.7348,28.1895 Z M 33.9006,45.1496L 31.7377,44.5701L 30.5502,42.5133L 31.1298,40.3504L 42.0994,34.0171L 44.2623,34.5966L 45.4498,36.6534L 44.8702,38.8163L 33.9006,45.1496 Z";

            if (!car)
            {
                id = Regex.Replace(id, @"-([^-]+)$", "/$1");
            }

            var name          = $@"“{BbCodeBlock.Encode(id)}”";
            var typeLocalized = car ? ToolsStrings.AdditionalContent_Car : ToolsStrings.AdditionalContent_Track;

            var searchUrl  = $"cmd://findmissing/{(car ? "car" : "track")}?param={id}";
            var searchLink = string.Format(@"[url={0}][ico={1}]Look for missing {2} online[/ico][/url]", BbCodeBlock.EncodeAttribute(searchUrl),
                                           BbCodeBlock.EncodeAttribute(searchIcon), typeLocalized);

            var version = car ? GetRequiredCarVersion(id) : GetRequiredTrackVersion();

            if (OptionIgnoreIndexIfServerProvidesSpecificVersion && version != null ||
                (car ? !IndexDirectDownloader.IsCarAvailable(id) : !IndexDirectDownloader.IsTrackAvailable(id)))
            {
                return($@"{name} \[{searchLink}]");
            }

            var downloadUrl  = $"cmd://downloadmissing/{(car ? "car" : "track")}?param={(string.IsNullOrWhiteSpace(version) ? id : $@"{id}|{version}")}";
Beispiel #3
0
        private static void ManualInstallation([CanBeNull] Exception e, string directory)
        {
            var downloadUrl = @"https://drive.google.com/uc?id=1vPW58x0AsD3XzSSq8MzN9FEuZt6vGTLq";

            NonfatalError.Notify("Can’t download the package",
                                 $"You can try to [url={BbCodeBlock.EncodeAttribute(downloadUrl)}]download[/url] and install it manually. Don’t forget to restart CM after it was installed.",
                                 e, new[] {
                new NonfatalErrorSolution("Open destination folder", null, t => {
                    WindowsHelper.ViewDirectory(directory);
                    return(Task.Delay(0));
                }, "FolderIconData"),
            });
        }
Beispiel #4
0
        public static string GetVersionInfoDisplay([NotNull] this IAcObjectFullAuthorshipInformation obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            if (obj.Version == null && obj.Author == null)
            {
                return(obj.Url != null ? $@"[url={BbCodeBlock.EncodeAttribute(obj.Url)}]{BbCodeBlock.Encode(obj.Url)}[/url]" : null);
            }

            var result = obj.Author == null ? obj.Version
                    : obj.Version == null ? obj.Author : $"{obj.Author} ({obj.Version})";

            return(obj.Url != null ? $@"[url={BbCodeBlock.EncodeAttribute(obj.Url)}]{BbCodeBlock.Encode(result)}[/url]" : result);
        }
Beispiel #5
0
        private static string PrepareLicense(string source)
        {
            return(Regex.Replace(BbCodeBlock.Encode(source), @"https?://\S+", x => {
                var last = x.Value[x.Value.Length - 1];

                string url, postfix;
                if (last == '.' || last == ';' || last == ')' || last == ',')
                {
                    url = x.Value.Substring(0, x.Value.Length - 1);
                    postfix = last.ToString();
                }
                else
                {
                    url = x.Value;
                    postfix = "";
                }

                return $"[url={BbCodeBlock.EncodeAttribute(BbCodeBlock.Decode(url))}]{url}[/url]{postfix}";
            }));
        }
Beispiel #6
0
 private static string BbCodeIcon([Localizable(false)] string icon, [Localizable(false)] string command, string hint)
 {
     return($@"[url={BbCodeBlock.EncodeAttribute(command)}][ico={BbCodeBlock.EncodeAttribute(icon)}]{BbCodeBlock.Encode(hint)}[/ico][/url]");
 }
Beispiel #7
0
        private string GetBrokenSuggestions()
        {
            if (_something is CefSharpWrapper || _something is FormsCefSharpWrapper)
            {
                var directory = @"file://" + PluginsManager.Instance.GetPluginDirectory(KnownPlugins.CefSharp);
                return
                    ($"Try to reinstall CefSharp plugin, its installation could be damaged. To do that, [url={BbCodeBlock.EncodeAttribute(directory)}]remove this directory[/url] (you’ll need to close the app to be able to remove it).");
            }

            return(null);
        }