public async Task <FileDrop.Result> Run(
            IEnumerable <string> filePathes,
            int stepFrameCount      = 0,
            int layer               = 0,
            int timeoutMilliseconds = -1)
        {
            FileDrop.ValidateFilePathes(filePathes, nameof(filePathes));

            // コピーしておく
            var filePathesClone = new List <string>(filePathes);

            return
                (await this.MainWindow.Dispatcher.InvokeAsync(
                     () =>
            {
                // VoiceroidUtilのメインウィンドウハンドル取得
                var mainWinHandle =
                    (HwndSource.FromVisual(this.MainWindow) as HwndSource)?.Handle;
                if (!mainWinHandle.HasValue)
                {
                    return FileDrop.Result.Fail;
                }

                return
                FileDrop.Run(
                    mainWinHandle.Value,
                    filePathesClone,
                    stepFrameCount,
                    layer,
                    timeoutMilliseconds);
            }));
        }
Ejemplo n.º 2
0
        public async Task <FileDrop.Result> Run(
            IEnumerable <string> filePathes,
            int stepFrameCount      = 0,
            int layer               = 0,
            int timeoutMilliseconds = -1)
        {
            FileDrop.ValidateFilePathes(filePathes, nameof(filePathes));

            // コピーしておく
            var filePathesClone = filePathes.ToArray();

            // VoiceroidUtilのメインウィンドウハンドル取得
            var mainWin       = this.MainWindow;
            var mainWinHandle =
                await mainWin.Dispatcher.InvokeAsync(
                    () => new WindowInteropHelper(mainWin).Handle);

            if (mainWinHandle == IntPtr.Zero)
            {
                return(FileDrop.Result.Fail);
            }

            // ファイルドロップ処理実施
            return
                (await Task.Run(
                     () =>
                     FileDrop.Run(
                         mainWinHandle,
                         filePathesClone,
                         stepFrameCount,
                         layer,
                         timeoutMilliseconds)));
        }