コード例 #1
0
 private void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.tag == "bad")
     {
         GameObject   refObj = GameObject.Find("CloudFactory");
         CloudFactory cf     = refObj.GetComponent <CloudFactory>();
         cf.DestroyCloud();
         Player.ySpeed = -15.0f;
         Player.isJump = false;
         anim.SetBool("jump", false);
         anim.SetBool("run", false);
         anim.SetBool("down", true);
         audioSource.SoundBad();
     }
     if (collider.tag == "correct")
     {
         if (one)
         {
             GameObject obj = collider.gameObject;
             Destroy(obj);
             GameDirector.next = true;
             one = false;
             audioSource.SoundCorrect();
         }
     }
 }
コード例 #2
0
        public void SupportedProviderTypesShouldNotBeEmpty()
        {
            var factory = new CloudFactory(_state.CloudConfiguration, _authenticator, _blobCache);

            factory.SupportedClouds.Should().NotBeEmpty();
            factory.SupportedClouds.Should().Contain(CloudType.Local);
            factory.SupportedClouds.Should().Contain(CloudType.GitHub);
        }
コード例 #3
0
ファイル: GroundCheck.cs プロジェクト: tatsuyounggg/WebGLGame
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.tag == "cloud")
        {
            if (SceneManager.GetActiveScene().name == "GameScene")
            {
                isGroundEnter = true;
            }
            else if (SceneManager.GetActiveScene().name == "TitleScene")
            {
                isGroundEnter = true;
                GameObject    refObj = GameObject.Find("CloudFactory");
                CloudFactoryT cf     = refObj.GetComponent <CloudFactoryT>();
                cf.MakeGround(collider);
            }
        }
        else if (collider.tag == "ground")
        {
            if (SceneManager.GetActiveScene().name == "GameScene")
            {
                // Physics2D.IgnoreLayerCollision(player_layer, ground_floor_layer, false);
                anim.SetBool("down", false);
                isGroundEnter = true;
                GameObject   refObj = GameObject.Find("CloudFactory");
                CloudFactory cf     = refObj.GetComponent <CloudFactory>();
                cf.DestroyCloud();
                cf.MakeChoice(collider);
            }

            else if (SceneManager.GetActiveScene().name == "TitleScene")
            {
                // Physics2D.IgnoreLayerCollision(player_layer, ground_floor_layer, false);
                isGroundEnter = true;
                GameObject    refObj = GameObject.Find("CloudFactory");
                CloudFactoryT cf     = refObj.GetComponent <CloudFactoryT>();
                cf.DestroyCloud();
                cf.MakeChoice(collider);
            }
        }

        else if (collider.tag == "choice")
        {
            if (SceneManager.GetActiveScene().name == "GameScene")
            {
                isGroundEnter = true;
                GameObject   refObj = GameObject.Find("CloudFactory");
                CloudFactory cf     = refObj.GetComponent <CloudFactory>();
                cf.MakeCloud(collider);
            }
            else if (SceneManager.GetActiveScene().name == "TitleScene")
            {
                isGroundEnter = true;
                GameObject    refObj = GameObject.Find("CloudFactory");
                CloudFactoryT cf     = refObj.GetComponent <CloudFactoryT>();
                cf.MakeCloud(collider);
            }
        }
    }
コード例 #4
0
        /// <summary>
        /// Runs MessageProcessor
        /// </summary>
        /// <returns>Async task</returns>"
        public static async Task Run()
        {
            var                 cloud    = new CloudFactory(MessageProcessor.GetConfiguration());
            var                 provider = cloud.Provider();
            QueueWatcher        watcher  = new QueueWatcher(provider, Constants.SleepTime);
            NotificationHandler handler  = new NotificationHandler(provider);

            await MessageProcessor.Run(watcher, handler);
        }
コード例 #5
0
ファイル: GameScreen.cs プロジェクト: profexorgeek/Shiprekt
        void SpawnCloud(float x, float y)
        {
            var windVelocity = windDirection * WindMagnitude;
            var cloud        = CloudFactory.CreateNew(x, y);

            cloud.Altitude   = FlatRedBallServices.Random.Between(Cloud.CloudAltitudeMin, Cloud.CloudAltitudeMax);
            cloud.Velocity.X = windDirection.X * WindMagnitude;
            cloud.Velocity.Y = windDirection.Y * WindMagnitude;
            cloud.PickRandomSprite();
        }
コード例 #6
0
        public void ShouldInstantiateSupportedProviders()
        {
            var factory  = new CloudFactory(_state.CloudConfiguration, _authenticator, _blobCache);
            var provider = factory.CreateCloud(new CloudParameters {
                Type = CloudType.Local
            });

            provider.Should().NotBeNull();
            provider.Name.Should().Be(CloudType.Local.ToString());
        }
コード例 #7
0
ファイル: YandexUpload.cs プロジェクト: pawlos/ScreenToGif
        public async Task ThrowExceptionWhenUploadFileWithInvalidToken()
        {
            var cloud  = CloudFactory.CreateCloud(UploadDestinations.Yandex);
            var preset = new YandexPreset
            {
                OAuthToken = "Invalid token"
            };

            //Upload.
            await Assert.ThrowsAsync <UploadException>(async() => await cloud.UploadFileAsync(preset, "./Data/Test.txt", CancellationToken.None));
        }
コード例 #8
0
ファイル: MyForm.cs プロジェクト: DarkSanny/di
        public MyForm()
        {
            var cloud = CloudFactory.CreateCloud();

            Size   = cloud.Size;
            Paint += (sender, args) =>
            {
                args.Graphics.DrawImage(cloud, 0, 0);
            };
            cloud.SaveImage(CloudFactory.CreateSaver(), "Image1.png");
        }
コード例 #9
0
 // Start is called before the first frame update
 void Start()
 {
     One           = true;
     Qn            = true;
     next          = false;
     refObj        = GameObject.Find("CloudFactory");
     cf            = refObj.GetComponent <CloudFactory>();
     this.question = GameObject.Find("Question");
     this.choice1  = GameObject.Find("Choice1");
     this.choice2  = GameObject.Find("Choice2");
     this.choice3  = GameObject.Find("Choice3");
     this.player   = GameObject.Find("player");
     audioSource   = GameObject.Find("SoundManage").GetComponent <SoundManage>();
 }
コード例 #10
0
ファイル: YandexUpload.cs プロジェクト: pawlos/ScreenToGif
        public async Task CanUploadFile()
        {
            var cloud  = CloudFactory.CreateCloud(UploadDestinations.Yandex);
            var preset = new YandexPreset
            {
                OAuthToken = "2344534523e45LW2jwerdp-efUwe4rmg" //Put your test token in here.
            };

            //Upload.
            var history = await cloud.UploadFileAsync(preset, "./Data/Test.txt", CancellationToken.None);

            Assert.NotNull(history);
            Assert.False(string.IsNullOrEmpty(history.Link));

            Trace.WriteLine("Link: " + history.Link);

            //Download.
            var data = await HttpHelper.HttpDownloadFileAsync(history.Link);

            Assert.NotNull(data);
        }
コード例 #11
0
        private async void Encode(List <FrameInfo> listFrames, int id, Parameters param, CancellationTokenSource tokenSource)
        {
            var processing = this.DispatcherStringResource("Encoder.Processing");

            try
            {
                switch (param.Type)
                {
                case Export.Gif:

                    #region Gif

                    #region Cut/Paint Unchanged Pixels

                    if (param.EncoderType == GifEncoderType.Legacy || param.EncoderType == GifEncoderType.ScreenToGif)
                    {
                        if (param.DetectUnchangedPixels)
                        {
                            Update(id, 0, FindResource("Encoder.Analyzing").ToString());

                            if (param.DummyColor.HasValue)
                            {
                                var color = Color.FromArgb(param.DummyColor.Value.R, param.DummyColor.Value.G, param.DummyColor.Value.B);

                                listFrames = ImageMethods.PaintTransparentAndCut(listFrames, color, id, tokenSource);
                            }
                            else
                            {
                                listFrames = ImageMethods.CutUnchanged(listFrames, id, tokenSource);
                            }
                        }
                        else
                        {
                            var size = listFrames[0].Path.ScaledSize();
                            listFrames.ForEach(x => x.Rect = new Int32Rect(0, 0, (int)size.Width, (int)size.Height));
                        }
                    }

                    #endregion

                    switch (param.EncoderType)
                    {
                    case GifEncoderType.ScreenToGif:

                        #region Improved encoding

                        using (var stream = new MemoryStream())
                        {
                            using (var encoder = new GifFile(stream, param.RepeatCount))
                            {
                                encoder.UseGlobalColorTable = param.UseGlobalColorTable;
                                encoder.TransparentColor    = param.DummyColor;
                                encoder.MaximumNumberColor  = param.MaximumNumberColors;

                                for (var i = 0; i < listFrames.Count; i++)
                                {
                                    if (!listFrames[i].HasArea && param.DetectUnchangedPixels)
                                    {
                                        continue;
                                    }

                                    if (listFrames[i].Delay == 0)
                                    {
                                        listFrames[i].Delay = 10;
                                    }

                                    encoder.AddFrame(listFrames[i].Path, listFrames[i].Rect, listFrames[i].Delay);

                                    Update(id, i, string.Format(processing, i));

                                    #region Cancellation

                                    if (tokenSource.Token.IsCancellationRequested)
                                    {
                                        SetStatus(Status.Canceled, id);
                                        break;
                                    }

                                    #endregion
                                }
                            }

                            try
                            {
                                using (var fileStream = new FileStream(param.Filename, FileMode.Create, FileAccess.Write, FileShare.None, 4096))
                                    stream.WriteTo(fileStream);
                            }
                            catch (Exception ex)
                            {
                                SetStatus(Status.Error, id);
                                LogWriter.Log(ex, "Improved Encoding");
                            }
                        }

                        #endregion

                        break;

                    case GifEncoderType.Legacy:

                        #region Legacy Encoding

                        using (var encoder = new AnimatedGifEncoder())
                        {
                            if (param.DummyColor.HasValue)
                            {
                                var color = Color.FromArgb(param.DummyColor.Value.R,
                                                           param.DummyColor.Value.G, param.DummyColor.Value.B);

                                encoder.SetTransparent(color);
                                encoder.SetDispose(1);         //Undraw Method, "Leave".
                            }

                            encoder.Start(param.Filename);
                            encoder.SetQuality(param.Quality);
                            encoder.SetRepeat(param.RepeatCount);

                            var numImage = 0;
                            foreach (var frame in listFrames)
                            {
                                #region Cancellation

                                if (tokenSource.Token.IsCancellationRequested)
                                {
                                    SetStatus(Status.Canceled, id);
                                    break;
                                }

                                #endregion

                                if (!frame.HasArea && param.DetectUnchangedPixels)
                                {
                                    continue;
                                }

                                var bitmapAux = new Bitmap(frame.Path);

                                encoder.SetDelay(frame.Delay);
                                encoder.AddFrame(bitmapAux, frame.Rect.X, frame.Rect.Y);

                                bitmapAux.Dispose();

                                Update(id, numImage, string.Format(processing, numImage));
                                numImage++;
                            }
                        }

                        #endregion

                        break;

                    case GifEncoderType.PaintNet:

                        #region paint.NET encoding

                        using (var stream = new MemoryStream())
                        {
                            using (var encoder = new GifEncoder(stream, null, null, param.RepeatCount))
                            {
                                for (var i = 0; i < listFrames.Count; i++)
                                {
                                    var bitmapAux = new Bitmap(listFrames[i].Path);
                                    encoder.AddFrame(bitmapAux, 0, 0, TimeSpan.FromMilliseconds(listFrames[i].Delay));
                                    bitmapAux.Dispose();

                                    Update(id, i, string.Format(processing, i));

                                    #region Cancellation

                                    if (tokenSource.Token.IsCancellationRequested)
                                    {
                                        SetStatus(Status.Canceled, id);

                                        break;
                                    }

                                    #endregion
                                }
                            }

                            stream.Position = 0;

                            try
                            {
                                using (var fileStream = new FileStream(param.Filename, FileMode.Create, FileAccess.Write, FileShare.None, Constants.BufferSize, false))
                                    stream.WriteTo(fileStream);
                            }
                            catch (Exception ex)
                            {
                                SetStatus(Status.Error, id);
                                LogWriter.Log(ex, "Encoding with paint.Net.");
                            }
                        }

                        #endregion

                        break;

                    case GifEncoderType.FFmpeg:

                        #region FFmpeg encoding

                        SetStatus(Status.Processing, id, null, true);

                        if (!Util.Other.IsFfmpegPresent())
                        {
                            throw new ApplicationException("FFmpeg not present.");
                        }

                        if (File.Exists(param.Filename))
                        {
                            File.Delete(param.Filename);
                        }

                        #region Generate concat

                        var concat = new StringBuilder();
                        foreach (var frame in listFrames)
                        {
                            concat.AppendLine("file '" + frame.Path + "'");
                            concat.AppendLine("duration " + (frame.Delay / 1000d).ToString(CultureInfo.InvariantCulture));
                        }

                        var concatPath = Path.GetDirectoryName(listFrames[0].Path) ?? Path.GetTempPath();
                        var concatFile = Path.Combine(concatPath, "concat.txt");

                        if (!Directory.Exists(concatPath))
                        {
                            Directory.CreateDirectory(concatPath);
                        }

                        if (File.Exists(concatFile))
                        {
                            File.Delete(concatFile);
                        }

                        File.WriteAllText(concatFile, concat.ToString());

                        #endregion

                        param.Command = string.Format(param.Command, concatFile, param.ExtraParameters.Replace("{H}", param.Height.ToString()).Replace("{W}", param.Width.ToString()), param.Filename);

                        var process = new ProcessStartInfo(UserSettings.All.FfmpegLocation)
                        {
                            Arguments             = param.Command,
                            CreateNoWindow        = true,
                            ErrorDialog           = false,
                            UseShellExecute       = false,
                            RedirectStandardError = true
                        };

                        var pro = Process.Start(process);

                        var str = pro.StandardError.ReadToEnd();

                        var fileInfo = new FileInfo(param.Filename);

                        if (!fileInfo.Exists || fileInfo.Length == 0)
                        {
                            throw new Exception("Error while encoding the gif with FFmpeg.")
                                  {
                                      HelpLink = $"Command:\n\r{param.Command}\n\rResult:\n\r{str}"
                                  }
                        }
                        ;

                        #endregion

                        break;

                    case GifEncoderType.Gifski:

                        #region Gifski encoding

                        SetStatus(Status.Processing, id, null, true);

                        if (!Util.Other.IsGifskiPresent())
                        {
                            throw new ApplicationException("Gifski not present.");
                        }

                        if (File.Exists(param.Filename))
                        {
                            File.Delete(param.Filename);
                        }

                        var gifski = new GifskiInterop();
                        var handle = gifski.Start(UserSettings.All.GifskiQuality, UserSettings.All.Looped);

                        ThreadPool.QueueUserWorkItem(delegate
                        {
                            Thread.Sleep(500);
                            SetStatus(Status.Processing, id, null, false);

                            for (var i = 0; i < listFrames.Count; i++)
                            {
                                Update(id, i, string.Format(processing, i));
                                gifski.AddFrame(handle, (uint)i, listFrames[i].Path, listFrames[i].Delay);
                            }

                            gifski.EndAdding(handle);
                        }, null);

                        gifski.End(handle, param.Filename);

                        var fileInfo2 = new FileInfo(param.Filename);

                        if (!fileInfo2.Exists || fileInfo2.Length == 0)
                        {
                            throw new Exception("Error while encoding the gif with Gifski.", new Win32Exception())
                                  {
                                      HelpLink = $"Command:\n\r{param.Command}\n\rResult:\n\r{Marshal.GetLastWin32Error()}"
                                  }
                        }
                        ;

                        #endregion

                        break;

                    default:
                        throw new Exception("Undefined Gif encoder type");
                    }

                    #endregion

                    break;

                case Export.Apng:

                    #region Apng

                    #region Cut/Paint Unchanged Pixels

                    if (param.DetectUnchangedPixels)
                    {
                        Update(id, 0, FindResource("Encoder.Analyzing").ToString());

                        if (param.DummyColor.HasValue)
                        {
                            var color = Color.FromArgb(param.DummyColor.Value.A, param.DummyColor.Value.R, param.DummyColor.Value.G, param.DummyColor.Value.B);
                            listFrames = ImageMethods.PaintTransparentAndCut(listFrames, color, id, tokenSource);
                        }
                        else
                        {
                            listFrames = ImageMethods.CutUnchanged(listFrames, id, tokenSource);
                        }
                    }
                    else
                    {
                        var size = listFrames[0].Path.ScaledSize();
                        listFrames.ForEach(x => x.Rect = new Int32Rect(0, 0, (int)size.Width, (int)size.Height));
                    }

                    #endregion

                    #region Encoding

                    using (var stream = new MemoryStream())
                    {
                        var frameCount = listFrames.Count(x => x.HasArea);

                        using (var encoder = new Apng(stream, frameCount, param.RepeatCount))
                        {
                            for (var i = 0; i < listFrames.Count; i++)
                            {
                                if (!listFrames[i].HasArea && param.DetectUnchangedPixels)
                                {
                                    continue;
                                }

                                if (listFrames[i].Delay == 0)
                                {
                                    listFrames[i].Delay = 10;
                                }

                                encoder.AddFrame(listFrames[i].Path, listFrames[i].Rect, listFrames[i].Delay);

                                Update(id, i, string.Format(processing, i));

                                #region Cancellation

                                if (tokenSource.Token.IsCancellationRequested)
                                {
                                    SetStatus(Status.Canceled, id);
                                    break;
                                }

                                #endregion
                            }
                        }

                        try
                        {
                            using (var fileStream = new FileStream(param.Filename, FileMode.Create, FileAccess.Write, FileShare.None, 4096))
                                stream.WriteTo(fileStream);
                        }
                        catch (Exception ex)
                        {
                            SetStatus(Status.Error, id);
                            LogWriter.Log(ex, "Apng Encoding");
                        }
                    }

                    #endregion

                    #endregion

                    break;

                case Export.Video:

                    #region Video

                    switch (param.VideoEncoder)
                    {
                    case VideoEncoderType.AviStandalone:

                        #region Avi Standalone

                        var image = listFrames[0].Path.SourceFrom();

                        if (File.Exists(param.Filename))
                        {
                            File.Delete(param.Filename);
                        }

                        //1000 / listFrames[0].Delay
                        using (var aviWriter = new AviWriter(param.Filename, param.Framerate, image.PixelWidth, image.PixelHeight, param.VideoQuality))
                        {
                            var numImage = 0;
                            foreach (var frame in listFrames)
                            {
                                using (var outStream = new MemoryStream())
                                {
                                    var bitImage = frame.Path.SourceFrom();

                                    var enc = new BmpBitmapEncoder();
                                    enc.Frames.Add(BitmapFrame.Create(bitImage));
                                    enc.Save(outStream);

                                    outStream.Flush();

                                    using (var bitmap = new Bitmap(outStream))
                                        aviWriter.AddFrame(bitmap, param.FlipVideo);
                                }

                                Update(id, numImage, string.Format(processing, numImage));
                                numImage++;

                                #region Cancellation

                                if (tokenSource.Token.IsCancellationRequested)
                                {
                                    SetStatus(Status.Canceled, id);
                                    break;
                                }

                                #endregion
                            }
                        }

                        #endregion

                        break;

                    case VideoEncoderType.Ffmpg:

                        #region Video using FFmpeg

                        SetStatus(Status.Processing, id, null, true);

                        if (!Util.Other.IsFfmpegPresent())
                        {
                            throw new ApplicationException("FFmpeg not present.");
                        }

                        if (File.Exists(param.Filename))
                        {
                            File.Delete(param.Filename);
                        }

                        #region Generate concat

                        var concat = new StringBuilder();
                        foreach (var frame in listFrames)
                        {
                            concat.AppendLine("file '" + frame.Path + "'");
                            concat.AppendLine("duration " + (frame.Delay / 1000d).ToString(CultureInfo.InvariantCulture));
                        }

                        var concatPath = Path.GetDirectoryName(listFrames[0].Path) ?? Path.GetTempPath();
                        var concatFile = Path.Combine(concatPath, "concat.txt");

                        if (!Directory.Exists(concatPath))
                        {
                            Directory.CreateDirectory(concatPath);
                        }

                        if (File.Exists(concatFile))
                        {
                            File.Delete(concatFile);
                        }

                        File.WriteAllText(concatFile, concat.ToString());

                        #endregion

                        param.Command = string.Format(param.Command, concatFile, param.ExtraParameters.Replace("{H}", param.Height.ToString()).Replace("{W}", param.Width.ToString()), param.Filename);

                        var process = new ProcessStartInfo(UserSettings.All.FfmpegLocation)
                        {
                            Arguments             = param.Command,
                            CreateNoWindow        = true,
                            ErrorDialog           = false,
                            UseShellExecute       = false,
                            RedirectStandardError = true
                        };

                        var pro = Process.Start(process);

                        var str = pro.StandardError.ReadToEnd();

                        var fileInfo = new FileInfo(param.Filename);

                        if (!fileInfo.Exists || fileInfo.Length == 0)
                        {
                            throw new Exception("Error while encoding with FFmpeg.")
                                  {
                                      HelpLink = str
                                  }
                        }
                        ;

                        #endregion

                        break;

                    default:
                        throw new Exception("Undefined video encoder");
                    }

                    #endregion

                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(param));
                }

                //If it was canceled, try deleting the file.
                if (tokenSource.Token.IsCancellationRequested)
                {
                    if (File.Exists(param.Filename))
                    {
                        File.Delete(param.Filename);
                    }

                    SetStatus(Status.Canceled, id);
                    return;
                }

                #region Upload

                if (param.Upload && File.Exists(param.Filename))
                {
                    InternalUpdate(id, "Encoder.Uploading", true, true);

                    try
                    {
                        ICloud cloud = CloudFactory.CreateCloud(param.UploadDestinationIndex);

                        var uploadedFile = await cloud.UploadFileAsync(param.Filename, CancellationToken.None);

                        InternalSetUpload(id, true, uploadedFile.Link, uploadedFile.DeleteLink);
                    }
                    catch (Exception e)
                    {
                        LogWriter.Log(e, "It was not possible to run the post encoding command.");
                        InternalSetUpload(id, false, null, null, e);
                    }
                }

                #endregion

                #region Copy to clipboard

                if (param.CopyToClipboard && File.Exists(param.Filename))
                {
                    Dispatcher.Invoke(() =>
                    {
                        try
                        {
                            var data = new DataObject();

                            switch (param.CopyType)
                            {
                            case CopyType.File:
                                if (param.Type != Export.Video)
                                {
                                    data.SetImage(param.Filename.SourceFrom());
                                }

                                data.SetText(param.Filename, TextDataFormat.Text);
                                data.SetFileDropList(new StringCollection {
                                    param.Filename
                                });
                                break;

                            case CopyType.FolderPath:
                                data.SetText(Path.GetDirectoryName(param.Filename) ?? param.Filename, TextDataFormat.Text);
                                break;

                            case CopyType.Link:
                                var link = InternalGetUpload(id);

                                data.SetText(string.IsNullOrEmpty(link) ? param.Filename : link, TextDataFormat.Text);
                                break;

                            default:
                                data.SetText(param.Filename, TextDataFormat.Text);
                                break;
                            }

                            //It tries to set the data to the clipboard 10 times before failing it to do so.
                            //This issue may happen if the clipboard is opened by any clipboard manager.
                            for (var i = 0; i < 10; i++)
                            {
                                try
                                {
                                    Clipboard.SetDataObject(data, true);
                                    break;
                                }
                                catch (COMException ex)
                                {
                                    if ((uint)ex.ErrorCode != 0x800401D0) //CLIPBRD_E_CANT_OPEN
                                    {
                                        throw;
                                    }
                                }

                                Thread.Sleep(100);
                            }

                            InternalSetCopy(id, true);
                        }
                        catch (Exception e)
                        {
                            LogWriter.Log(e, "It was not possible to copy the file.");
                            InternalSetCopy(id, false, e);
                        }
                    });
                }

                #endregion

                #region Execute commands

                if (param.ExecuteCommands && !string.IsNullOrWhiteSpace(param.PostCommands))
                {
                    InternalUpdate(id, "Encoder.Executing", true, true);

                    var command = param.PostCommands.Replace("{p}", "\"" + param.Filename + "\"").Replace("{f}", "\"" + Path.GetDirectoryName(param.Filename) + "\"");
                    var output  = "";

                    try
                    {
                        foreach (var com in command.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            var procStartInfo = new ProcessStartInfo("cmd", "/c " + com)
                            {
                                RedirectStandardOutput = true,
                                RedirectStandardError  = true,
                                UseShellExecute        = false,
                                CreateNoWindow         = true
                            };

                            using (var process = new Process())
                            {
                                process.StartInfo = procStartInfo;
                                process.Start();

                                var message = process.StandardOutput.ReadToEnd();
                                var error   = process.StandardError.ReadToEnd();

                                if (!string.IsNullOrWhiteSpace(message))
                                {
                                    output += message + Environment.NewLine;
                                }

                                if (!string.IsNullOrWhiteSpace(message))
                                {
                                    output += message + Environment.NewLine;
                                }

                                if (!string.IsNullOrWhiteSpace(error))
                                {
                                    throw new Exception(error);
                                }

                                process.WaitForExit(1000);
                            }
                        }

                        InternalSetCommand(id, true, command, output);
                    }
                    catch (Exception e)
                    {
                        LogWriter.Log(e, "It was not possible to run the post encoding command.");
                        InternalSetCommand(id, false, command, output, e);
                    }
                }

                #endregion

                if (!tokenSource.Token.IsCancellationRequested)
                {
                    SetStatus(Status.Completed, id, param.Filename);
                }
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Encode");

                SetStatus(Status.Error, id, null, false, ex);
            }
            finally
            {
                #region Delete Encoder Folder

                try
                {
                    var encoderFolder = Path.GetDirectoryName(listFrames[0].Path);

                    if (!string.IsNullOrEmpty(encoderFolder))
                    {
                        if (Directory.Exists(encoderFolder))
                        {
                            Directory.Delete(encoderFolder, true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogWriter.Log(ex, "Cleaning the Encode folder");
                }

                #endregion

                GC.Collect();
            }
        }
コード例 #12
0
        /// <summary>
        /// Load content.
        /// </summary>
        public void LoadContent()
        {
            // Store graphics device
            this.graphicsDevice = core.GraphicsDevice;

            // Load rendering effects
            clearBufferEffect      = core.ContentManager.Load <Effect>("Effects/ClearGBuffer");
            finalCombineEffect     = core.ContentManager.Load <Effect>("Effects/CombineFinal");
            directionalLightEffect = core.ContentManager.Load <Effect>("Effects/DirectionalLight");
            pointLightEffect       = core.ContentManager.Load <Effect>("Effects/PointLight");
            emissiveLightEffect    = core.ContentManager.Load <Effect>("Effects/EmissiveLight");
            renderBillboards       = core.ContentManager.Load <Effect>("Effects/RenderBillboards");
            fxaaAntialiasing       = core.ContentManager.Load <Effect>("FXAA/fxaa");

            // Get render billboards parameters
            renderBillboards_Texture  = renderBillboards.Parameters["Texture"];
            renderBillboards_Position = renderBillboards.Parameters["Position"];
            renderBillboards_Size     = renderBillboards.Parameters["Size"];

            // Get point light parameters
            pointLight_colorMap             = pointLightEffect.Parameters["ColorMap"];
            pointLight_normalMap            = pointLightEffect.Parameters["NormalMap"];
            pointLight_depthMap             = pointLightEffect.Parameters["DepthMap"];
            pointLight_worldMatrix          = pointLightEffect.Parameters["World"];
            pointLight_viewMatrix           = pointLightEffect.Parameters["View"];
            pointLight_projectionMatrix     = pointLightEffect.Parameters["Projection"];
            pointLight_lightPosition        = pointLightEffect.Parameters["LightPosition"];
            pointLight_lightColor           = pointLightEffect.Parameters["Color"];
            pointLight_lightRadius          = pointLightEffect.Parameters["LightRadius"];
            pointLight_lightIntensity       = pointLightEffect.Parameters["LightIntensity"];
            pointLight_cameraPosition       = pointLightEffect.Parameters["CameraPosition"];
            pointLight_invertViewProjection = pointLightEffect.Parameters["InvertViewProjection"];
            pointLight_halfPixel            = pointLightEffect.Parameters["HalfPixel"];

            // Get directional light paramters
            directionalLight_colorMap             = directionalLightEffect.Parameters["ColorMap"];
            directionalLight_normalMap            = directionalLightEffect.Parameters["NormalMap"];
            directionalLight_depthMap             = directionalLightEffect.Parameters["DepthMap"];
            directionalLight_lightDirection       = directionalLightEffect.Parameters["LightDirection"];
            directionalLight_lightColor           = directionalLightEffect.Parameters["Color"];
            directionalLight_lightIntensity       = directionalLightEffect.Parameters["LightIntensity"];
            directionalLight_cameraPosition       = directionalLightEffect.Parameters["CameraPosition"];
            directionalLight_invertViewProjection = directionalLightEffect.Parameters["InvertViewProjection"];
            directionalLight_gBufferTextureSize   = directionalLightEffect.Parameters["GBufferTextureSize"];

            // Get emissive light parameters
            emissiveLight_ColorMap           = emissiveLightEffect.Parameters["colorMap"];
            emissiveLight_gBufferTextureSize = emissiveLightEffect.Parameters["GBufferTextureSize"];

            // Load light geometry
            pointLightGeometry = core.ContentManager.Load <Model>("Models/PointLightGeometry");
            spotLightGeometry  = core.ContentManager.Load <Model>("Models/SpotLightGeometry");

            // Load light textures
            spotLightCookie = core.ContentManager.Load <Texture2D>("Textures/SpotLightCookie");

            // Create billboard template
            CreateDaggerfallBillboardTemplate();

            // Create rendering classes
            fullScreenQuad = new FullScreenQuad(graphicsDevice);
            gBuffer        = new GBuffer(core);
            bloomProcessor = new BloomProcessor(core);

            // Load content
            skyDomeEffect = core.ContentManager.Load <Effect>("Effects/SkyDomeEffect");
            skyDomeModel  = core.ContentManager.Load <Model>("Models/SkyDomeModel");
            skyDomeModel.Meshes[0].MeshParts[0].Effect = skyDomeEffect.Clone();

            // Create factories
            cloudFactory = new CloudFactory(core);
            starFactory  = new StarFactory(core);

            // Wire up GraphicsDevice events
            graphicsDevice.DeviceReset += new EventHandler <EventArgs>(GraphicsDevice_DeviceReset);
            graphicsDevice.DeviceLost  += new EventHandler <EventArgs>(GraphicsDevice_DeviceLost);
        }