Example #1
0
        public async void FileDropped(IEnumerable <string> list, bool isText)
        {
            var targets = list.SelectMany(path =>
            {
                if (Directory.Exists(path))
                {
                    return(Directory.EnumerateFiles(path).Where(s => s.EndsWith("ts")));
                }
                else
                {
                    return(new string[] { path });
                }
            }).Select(s => new AddQueueItem()
            {
                Path = s
            }).ToList();

            if (targets.Count == 0)
            {
                return;
            }

            var req = new AddQueueRequest()
            {
                DirPath = Path.GetDirectoryName(targets[0].Path),
                Targets = targets,
                Outputs = new List <OutputInfo>()
                {
                    new OutputInfo()
                    {
                        DstPath = Model.UIState.Model?.LastOutputPath,
                        Profile = Model.UIState.Model?.LastUsedProfile,
                        // デフォルト優先順は3
                        Priority = 3
                    }
                },
                AddQueueBat = Model.UIState.Model?.LastAddQueueBat
            };

            // 出力先フォルダ選択
            var selectPathVM = new SelectOutPathViewModel()
            {
                Model = Model,
                Item  = req
            };
            await Messenger.RaiseAsync(new TransitionMessage(
                                           typeof(Views.SelectOutPath), selectPathVM, TransitionMode.Modal, "FromMain"));

            if (selectPathVM.Succeeded)
            {
                if (selectPathVM.PauseStart)
                {
                    await Model.Server?.PauseEncode(true);
                }
                Model.Server?.AddQueue(req).AttachHandler();
            }
        }
Example #2
0
        public async void FileDropped(IEnumerable <string> list)
        {
            Dictionary <string, AddQueueDirectory> dirList = new Dictionary <string, AddQueueDirectory>();

            foreach (var path in list)
            {
                if (Directory.Exists(path))
                {
                    dirList.Add(path, new AddQueueDirectory()
                    {
                        DirPath = path
                    });
                }
                else if (File.Exists(path))
                {
                    var dirPath = System.IO.Path.GetDirectoryName(path);
                    AddQueueDirectory item;
                    if (dirList.TryGetValue(dirPath, out item))
                    {
                        if (item.Targets != null)
                        {
                            item.Targets.Add(path);
                        }
                    }
                    else
                    {
                        dirList.Add(dirPath, new AddQueueDirectory()
                        {
                            DirPath = dirPath,
                            Targets = new List <string>()
                            {
                                path
                            }
                        });
                    }
                }
            }

            foreach (var item in dirList.Values)
            {
                // 出力先フォルダ選択
                var selectPathVM = new SelectOutPathViewModel()
                {
                    Item = item
                };
                await Messenger.RaiseAsync(new TransitionMessage(
                                               typeof(Views.SelectOutPath), selectPathVM, TransitionMode.Modal, "FromMain"));

                if (selectPathVM.Succeeded)
                {
                    Model.Server.AddQueue(item).AttachHandler();
                }
            }
        }