Ejemplo n.º 1
0
        private void RecordGif(int frames, int interval)
        {
            _gifBitmapEncoder = new GifBitmapEncoder();

            for (var i = 0; i < frames; i++)
            {
                _capture.CaptureScreen();
                Thread.Sleep(interval);
            }

            _path = new RelativeFile
            {
                SubDirectory         = "Animations",
                Name                 = "GifRecording",
                Extension            = ".gif",
                TimeStampFile        = true,
                UseDetailedTimeStamp = true
            };

            using (var filestream = new FileStream(_path.GetFullPath(), FileMode.Create))
            {
                _gifBitmapEncoder.Save(filestream);
            }

            _gifBitmapEncoder = null;
        }
Ejemplo n.º 2
0
        private static async Task DoFile(DocumentContext context, RelativeFile file)
        {
            if (file.Source.Extension != "md")
            {
                return;
            }
            Console.Error.WriteLine($"Working on {file.Source.FullPath}");

            var text = await file.Read();

            var doc = MarkdownFactory.Parse(text);

            doc.ApplyD2LTweaks();
            var html = MarkdownFactory.RenderToString(doc, context);

            var renderer  = TemplateRenderer.CreateFromResource("Templates.page.html");
            var formatted = await renderer.RenderAsync(
                title : GetTitle(doc),
                content : html,
                editLink : file.EditSourceLink
                );

            await file.Write(formatted);

            CopyAssociatedFiles(doc, context, file.Source.Path);
        }
Ejemplo n.º 3
0
 public NugetReference(Project project, Package package, RelativeFile file, VersionWithSuffix version)
     : base(project, file, version)
 {
     if (version == null)
     {
         throw new ArgumentNullException();
     }
     Package = package;
 }
Ejemplo n.º 4
0
        private void btnLoadOriginal_Click(object sender, EventArgs e)
        {
            RelativeFile item = listBoxFiles.SelectedItem as RelativeFile;

            if (item == null)
            {
                return;
            }

            SetTextBoxContents(item.File.Contents);
        }
Ejemplo n.º 5
0
        private void btnReprocess_Click(object sender, EventArgs e)
        {
            RelativeFile item = listBoxFiles.SelectedItem as RelativeFile;

            if (item == null)
            {
                return;
            }

            SetTextBoxContents(GetLanguageHandler(item.File).PrepareFileContents(textBoxCode.Text));
        }
Ejemplo n.º 6
0
        private void btnDebug_Click(object sender, EventArgs e)
        {
            RelativeFile item = listBoxFiles.SelectedItem as RelativeFile;

            if (item == null)
            {
                return;
            }

            Variables.Root variables = GenerateVariables(item.File);
            variables.CheckFlag(""); // keep the object alive for debugging

            Debugger.Break();
        }
Ejemplo n.º 7
0
        private void listBoxFiles_SelectedValueChange(object sender, EventArgs e)
        {
            RelativeFile item = listBoxFiles.SelectedItem as RelativeFile;

            if (item == null)
            {
                return;
            }

            AbstractLanguageFileHandler handler = GetLanguageHandler(item.File);

            SetTextBoxContents(handler.PrepareFileContents(item.File.Contents));

            treeViewData.Nodes.Clear();

            foreach (Node node in handler.GenerateTreeViewData(GenerateVariables(item.File), item.File))
            {
                treeViewData.Nodes.Add(ConvertNode(node));
            }
        }
        bool FilesToSnippets(string key, string?relativePath, string?linePath, out IReadOnlyList <Snippet> snippetsForKey)
        {
            var keyWithDirChar = FileEx.PrependSlash(key);

            snippetsForKey = snippetSourceFiles
                             .Where(file => file.EndsWith(keyWithDirChar, StringComparison.OrdinalIgnoreCase))
                             .Select(file => FileToSnippet(key, file, file))
                             .ToList();
            if (snippetsForKey.Any())
            {
                return(true);
            }

            if (RelativeFile.Find(allFiles, rootDirectory, key, relativePath, linePath, out var path))
            {
                snippetsForKey = SnippetsForFile(key, path);
                return(true);
            }

            snippetsForKey = null !;
            return(false);
        }
Ejemplo n.º 9
0
 private static void AssertOperatorNotEquals(RelativeFile left, RelativeFile right)
 {
     Assert.That(left == right, Is.False, string.Format("! '{0}' == '{1}'", left, right));
     Assert.That(left != right, Is.True, string.Format("! '{0}' != '{1}'", left, right));
 }
Ejemplo n.º 10
0
 private static void AssertEqualityNotEquals(RelativeFile left, object right)
 {
     Assert.That(left.Equals(right), Is.False, string.Format("! '{0}'.Equals('{1}')", left, right));
     Assert.That(left.GetHashCode(), Is.Not.EqualTo(right.GetHashCode()), string.Format("'{0}'.GetHashCode() != '{1}'.GetHashCode()", left, right));
 }
Ejemplo n.º 11
0
        /// <summary>Manages the given <see cref="Beatmap"/>, overriding all relevant <see cref="Background"/> event files.</summary>
        /// <param name="Beatmap">The beatmap.</param>
        /// <param name="Location">The location.</param>
        /// <param name="Backgrounds">The backgrounds.</param>
        /// <param name="ManagedMedia">The managed media.</param>
        /// <param name="Resize">If set to <c>true</c> resizes the new backgrounds to match the original resolution, using the <see cref="WPFExtensions.ResizeToFill(Bitmap, int, int, PixelFormat, System.Drawing.Drawing2D.CompositingMode, System.Drawing.Drawing2D.CompositingQuality, System.Drawing.Drawing2D.InterpolationMode, System.Drawing.Drawing2D.SmoothingMode, System.Drawing.Drawing2D.PixelOffsetMode, System.Drawing.Drawing2D.WrapMode)"/> method.</param>
        /// <param name="BackupBackground">If set to <c>true</c>, calls <see cref="FileSystemExtensions.SetAsBackup(FileInfo, bool)"/> on the original background files before overwriting them.</param>
        public static void ManageBeatmap(Beatmap Beatmap, DirectoryInfo Location, Bitmap[] Backgrounds, ref HashSet <string> ManagedMedia, bool Resize, bool BackupBackground)
        {
            foreach (OsuEvent Event in Beatmap.Events)
            {
                LogWindow.Log($"\tChecking Event: {Event}");
                switch (Event)
                {
                case Background BG:
                    LogWindow.Log($"\t\t=> Got BG Event: {BG}");
                    if (BG.FileName.TryGetAbsoluteFile(Location, out FileInfo RelativeFile) && !RelativeFile.Extension.IsNullOrEmpty())
                    {
                        string RelativeFileName = RelativeFile.FullName.ToLowerInvariant();
                        if (!ManagedMedia.Contains(RelativeFileName))
                        {
                            ManagedMedia.Add(RelativeFileName);
                            LogWindow.Log($"\t\t\tFound Media: '{RelativeFile.FullName}'.");

                            ImageFormat Final = GetFormat(RelativeFile, out _);
                            if (Final == null)
                            {
                                return;
                            }

                            Bitmap NewBackground = Backgrounds.GetRandom();

                            if (RelativeFile.Exists)
                            {
                                if (BackupBackground)
                                {
                                    RelativeFile.SetAsBackup();
                                }

                                if (Resize)
                                {
                                    LogWindow.Log("Attempting resize...");
                                    int W = -1;
                                    int H = -1;

                                    try {
                                        using (Bitmap Original = new Bitmap(RelativeFile.FullName)) {
                                            W = Original.Width;
                                            H = Original.Height;
                                        }
                                    } catch { }     //Unable to access / import bitmap; Skipped in next check.

                                    if (W > 0 && H > 0)
                                    {
                                        LogWindow.Log($"\tWill resize to: ({W}, {H}) ;; Chosen BG: ({NewBackground.Width}, {NewBackground.Height})");
                                        NewBackground = NewBackground.ResizeToFill(W, H, PixelFormat.Format24bppRgb, GlobalImageResizerWindow.CompositingMode, GlobalImageResizerWindow.CompositingQuality, GlobalImageResizerWindow.InterpolationMode, GlobalImageResizerWindow.SmoothingMode, GlobalImageResizerWindow.PixelOffsetMode, GlobalImageResizerWindow.WrapMode);
                                    }
                                    else
                                    {
                                        LogWindow.Log("\tFailed retrieving original media size.");
                                    }
                                }

                                RelativeFile.Delete();
                            }

                            Save(NewBackground, RelativeFile, Final);
                        }
                        else
                        {
                            LogWindow.Log($"\t\t\tMedia: '{RelativeFile.FullName}' was already managed.");
                        }
                    }

                    break;
                    //case OsuEvent.OsuEventType.Video: //TODO: Video event support?
                    //    break;
                }
            }
        }