コード例 #1
0
        /// <summary>
        /// Saves loaded image using GUI set format and save path.
        /// </summary>
        public void Save()
        {
            Status = "Saving...";

            string tempformat = SelectedFormat;

            if (tempformat.Contains("\\"))
            {
                tempformat = tempformat.Split('\\')[0];
            }

            if (tempformat.Contains('/'))
            {
                tempformat = tempformat.Split('/')[0];
            }

            // KFreon: DDS's
            if (SelectedFormat.Contains("DXT") || SelectedFormat.Contains("V8U8") || SelectedFormat.Contains("ATI"))
            {
                ResIL.Unmanaged.CompressedDataFormat surface = (ResIL.Unmanaged.CompressedDataFormat)Enum.Parse(typeof(ResIL.Unmanaged.CompressedDataFormat), tempformat);

                img.ConvertAndSave(ResIL.Unmanaged.ImageType.Dds, SavePath, GenerateMips ? ResILImage.MipMapMode.BuildAll : ResILImage.MipMapMode.None, surface);
            }
            else  // KFreon: Everything else
            {
                ResIL.Unmanaged.ImageType type = (ResIL.Unmanaged.ImageType)Enum.Parse(typeof(ResIL.Unmanaged.ImageType), tempformat);
                img.ConvertAndSave(type, SavePath);
            }
            Status = "Saved!";
        }
コード例 #2
0
        public void Confirm()
        {
            // Persist preferences
            _settingsService.LastExportFormat        = SelectedFormat;
            _settingsService.LastPartitionLimitValue = PartitionLimitValue;
            _settingsService.LastMessageFilterValue  = MessageFilterValue;
            _settingsService.LastShouldDownloadMedia = ShouldDownloadMedia;

            // If single channel - prompt file path
            if (Channels is not null && IsSingleChannel)
            {
                var channel         = Channels.Single();
                var defaultFileName = ExportRequest.GetDefaultOutputFileName(
                    Guild !,
                    channel,
                    SelectedFormat,
                    After?.Pipe(Snowflake.FromDate),
                    Before?.Pipe(Snowflake.FromDate)
                    );

                // Filter
                var ext    = SelectedFormat.GetFileExtension();
                var filter = $"{ext.ToUpperInvariant()} files|*.{ext}";

                OutputPath = _dialogManager.PromptSaveFilePath(filter, defaultFileName);
            }
コード例 #3
0
        public void Confirm()
        {
            // Persist preferences
            _settingsService.LastExportFormat   = SelectedFormat;
            _settingsService.LastPartitionLimit = PartitionLimit;

            // Clamp 'from' and 'to' values
            if (From > To)
            {
                From = To;
            }
            if (To < From)
            {
                To = From;
            }

            // Generate default file name
            var defaultFileName = ExportHelper.GetDefaultExportFileName(SelectedFormat, Guild, Channel, From, To);

            // Prompt for output file path
            var ext    = SelectedFormat.GetFileExtension();
            var filter = $"{ext.ToUpperInvariant()} files|*.{ext}";

            FilePath = _dialogManager.PromptSaveFilePath(filter, defaultFileName);

            // If canceled - return
            if (FilePath.IsBlank())
            {
                return;
            }

            // Close dialog
            Close(true);
        }
コード例 #4
0
        public void Confirm()
        {
            // Persist preferences
            _settingsService.LastExportFormat        = SelectedFormat;
            _settingsService.LastPartitionLimit      = PartitionLimit;
            _settingsService.LastShouldDownloadMedia = ShouldDownloadMedia;

            // If single channel - prompt file path
            if (IsSingleChannel)
            {
                var channel         = Channels.Single();
                var defaultFileName = ExportRequest.GetDefaultOutputFileName(Guild !, channel, SelectedFormat, After, Before);

                // Filter
                var ext    = SelectedFormat.GetFileExtension();
                var filter = $"{ext.ToUpperInvariant()} files|*.{ext}";

                OutputPath = _dialogManager.PromptSaveFilePath(filter, defaultFileName);
            }
            // If multiple channels - prompt dir path
            else
            {
                OutputPath = _dialogManager.PromptDirectoryPath();
            }

            // If canceled - return
            if (string.IsNullOrWhiteSpace(OutputPath))
            {
                return;
            }

            Close(true);
        }
コード例 #5
0
        public void writeConfiguration()
        {
            try {
                TextWriter Writer = new StreamWriter(CONFIG_FILE);
                XElement   root   = new XElement("AVSyncer");

                XElement xSelectPaths = new XElement("SelectPaths");
                foreach (string s in selectpaths)
                {
                    XElement xPath = new XElement("Path");
                    xPath.SetValue(s);
                    xSelectPaths.Add(xPath);
                }
                root.Add(xSelectPaths);
                XElement xSelectedPath = new XElement("SelectedPath");
                xSelectedPath.Value = SelectedPath.ToString();
                root.Add(xSelectedPath);

                XElement xFormattings = new XElement("Formattings");
                foreach (string s in formattings)
                {
                    string vs = "";
                    foreach (char ic in System.IO.Path.GetInvalidFileNameChars())
                    {
                        vs = s.Replace(ic.ToString(), "");
                    }
                    XElement xFormat = new XElement("Format");
                    xFormat.SetAttributeValue("text", vs);
                    xFormattings.Add(xFormat);
                }
                root.Add(xFormattings);
                XElement xSelectedFormat = new XElement("SelectedFormat");
                xSelectedFormat.Value = SelectedFormat.ToString();
                root.Add(xSelectedFormat);

                XElement xStructs = new XElement("Structs");
                foreach (string s in structs)
                {
                    string vs = "";
                    foreach (char ic in System.IO.Path.GetInvalidPathChars())
                    {
                        vs = s.Replace(ic.ToString(), "");
                    }
                    vs = vs.Replace("..", "");
                    XElement xStruct = new XElement("Struct");
                    xStruct.SetAttributeValue("text", vs);
                    xStructs.Add(xStruct);
                }
                root.Add(xStructs);
                XElement xSelectedStruct = new XElement("SelectedStruct");
                xSelectedStruct.Value = SelectedStruct.ToString();
                root.Add(xSelectedStruct);

                Writer.Write(root);
                Writer.Close();
            } catch (Exception ex) {
                Console.WriteLine(ex);
            }
        }
コード例 #6
0
        public void Confirm()
        {
            // Persist preferences
            _settingsService.LastExportFormat   = SelectedFormat;
            _settingsService.LastPartitionLimit = PartitionLimit;

            // Clamp 'after' and 'before' values
            if (After > Before)
            {
                After = Before;
            }
            if (Before < After)
            {
                Before = After;
            }

            // If single channel - prompt file path
            if (IsSingleChannel)
            {
                // Get single channel
                var channel = Channels.Single();

                // Generate default file name
                var defaultFileName = ExportHelper.GetDefaultExportFileName(SelectedFormat, Guild, channel, After, Before);

                // Generate filter
                var ext    = SelectedFormat.GetFileExtension();
                var filter = $"{ext.ToUpperInvariant()} files|*.{ext}";

                // Prompt user
                OutputPath = _dialogManager.PromptSaveFilePath(filter, defaultFileName);
            }
            // If multiple channels - prompt dir path
            else
            {
                // Prompt user
                OutputPath = _dialogManager.PromptDirectoryPath();
            }

            // If canceled - return
            if (OutputPath.IsNullOrWhiteSpace())
            {
                return;
            }

            // Close dialog
            Close(true);
        }
コード例 #7
0
        public void EnqueueDownload()
        {
            // Prompt user for output file path
            var filter          = $"{SelectedFormat.ToUpperInvariant()} file|*.{SelectedFormat}";
            var defaultFileName = GetDefaultFileName(Video, SelectedFormat);
            var filePath        = _dialogManager.PromptSaveFilePath(filter, defaultFileName);

            // If canceled - return
            if (filePath.IsBlank())
            {
                return;
            }

            // Enqueue download
            var download = EnqueueDownload(Video, filePath);

            // Close dialog with result
            Close(download);
        }
コード例 #8
0
ファイル: Video.cs プロジェクト: Codenrox/Youtube-DL-GUI
        public void DownloadVideo()
        {
            string arguments         = "";
            string output            = "";
            bool   completedDownload = false;
            string progress          = "";

            if (!Directory.Exists(Path))
            {
                MessageBox.Show(Localization.Strings.InvalidPath, Localization.Strings.Error);
            }
            else
            {
                if (SelectedFormat != "default")
                {
                    switch (SelectedFormat)
                    {
                    case string s when(s == "mp3" || s == "flac"):
                        arguments += "--prefer-ffmpeg --extract-audio --audio-format " + SelectedFormat;

                        break;

                    default:
                        arguments += "-f ";

                        if (SelectedFormat.Contains(" "))
                        {
                            arguments += SelectedFormat.Substring(0, SelectedFormat.IndexOf(" "));
                            if (SelectedFormat.Substring(SelectedFormat.Length - 1) == "y")
                            {
                                int spaceIndex = SelectedFormat.IndexOf(" ");
                                arguments += SelectedFormat.Contains("mp4") ? "+bestaudio[ext!=webm]" : "+bestaudio[ext=webm]‌";
                                arguments += " --merge-output-format" + SelectedFormat.Substring(spaceIndex, SelectedFormat.Length - spaceIndex - 2);
                            }
                        }
                        else
                        {
                            arguments += SelectedFormat.Substring(0, SelectedFormat.Length - 2);
                        }

                        break;
                    }
                }
                arguments += SelectedFormat == "default" ? "-o \"" + Path + Name + "\"" : " -o \"" + Path + Name + "\"";
                arguments += " -i " + ID;

                ytbDLInfo.Arguments = arguments;
                ytbDL = Process.Start(ytbDLInfo);

                ytbDL.OutputDataReceived += new DataReceivedEventHandler(
                    (s, f) =>
                {
                    output = f.Data ?? "null";

                    if (output.Contains("[download]") && output.Contains("of"))
                    {
                        if (output.Contains("at") && output.Contains("MiB") && !output.Contains("Destination"))
                        {
                            string downloadSpeed = output.Substring(output.IndexOf("at") + 3, output.IndexOf("ETA") - output.IndexOf("at") - 3);
                            mw.BeginInvoke((Action)(() =>
                            {
                                mw.DownloadSpeed.Text = downloadSpeed;
                            }));
                            progress = output.Substring(output.LastIndexOf("[download]") + 11, output.LastIndexOf("%") - 11);
                            progress = progress.Contains(".") ? progress.Substring(0, progress.IndexOf(".")) : progress;
                        }

                        mw.BeginInvoke((Action)(() =>
                        {
                            mw.DownloadStatus.Text = Localization.Strings.Downloading;
                            mw.DownloadPercentage.Text = progress + "%";
                            mw.DownloadProgressBar.Value = progress != "" ? Int16.Parse(progress) : 0;
                        }));
                        completedDownload = true;
                    }
                    else
                    {
                        mw.BeginInvoke((Action)(() =>
                        {
                            mw.DownloadStatus.Text = output.Contains("[ffmpeg]") ? Localization.Strings.FFMpeg : Localization.Strings.StartingUp;
                        }));
                    }

                    if (output != "null" && Properties.Settings.Default.VerboseStatus)
                    {
                        mw.BeginInvoke((Action)(() =>
                        {
                            mw.VerboseStatus.Text = output;
                        }));
                    }
                }
                    );

                ytbDL.Start();
                ytbDL.BeginOutputReadLine();
                ytbDL.WaitForExit();
                ytbDL.CancelOutputRead();

                if (!completedDownload)
                {
                    MessageBox.Show(Localization.Strings.InvalidFiletype, Localization.Strings.Error);
                }

                mw.BeginInvoke((Action)(() =>
                {
                    mw.DownloadSpeed.Text = "0.0 MiB/s";
                    mw.VerboseStatus.Text = "";
                    mw.DownloadPercentage.Text = "0%";
                    mw.ClearCard();
                    mw.DownloadProgressBar.Value = 0;
                    mw.DownloadStatus.Text = Localization.Strings.NoDownload;
                }));

                arguments = "";
            }
        }