Exemplo n.º 1
0
 /// <summary>
 /// Disposes the Bitmap and releases all of its resources.
 /// </summary>
 public void Dispose()
 {
     if (Disposed == false)
     {
         SystemBitmap.Dispose();
         _disposed = true;
     }
 }
Exemplo n.º 2
0

        
Exemplo n.º 3
0

        
Exemplo n.º 4
0
        public override Dictionary <string, FileOutput> ExportProject(
            IList <VariableDeclaration> globals,
            IList <StructDefinition> structDefinitions,
            IList <FunctionDefinition> functionDefinitions,
            IList <LibraryForExport> libraries,
            ResourceDatabase resourceDatabase,
            Options options,
            ILibraryNativeInvocationTranslatorProvider libraryNativeInvocationTranslatorProviderForPlatform)
        {
            if (!options.GetBool(ExportOptionKey.HAS_ICON))
            {
                throw new InvalidOperationException("Cannot generate a Chrome Web App without an icon resource.");
            }

            string iconFilePath = options.GetString(ExportOptionKey.ICON_PATH);

            if (!FileUtil.FileExists(iconFilePath))
            {
                throw new InvalidOperationException("Icon resource path points to non-existent file.");
            }
            SystemBitmap iconFile  = new SystemBitmap(iconFilePath);
            SystemBitmap smallIcon = iconFile.CloneToNewSize(16, 16);
            SystemBitmap largeIcon = iconFile.CloneToNewSize(128, 128);

            JavaScriptApp.PlatformImpl      jsBasicPlatform = (JavaScriptApp.PlatformImpl) this.PlatformProvider.GetPlatform("javascript-app");
            Dictionary <string, FileOutput> files           = jsBasicPlatform.ExportProjectImpl(globals, structDefinitions, functionDefinitions, libraries, resourceDatabase, options, libraryNativeInvocationTranslatorProviderForPlatform, this.Translator);
            Dictionary <string, string>     replacements    = this.GenerateReplacementDictionary(options, resourceDatabase);

            replacements["JS_LIB_INCLUSIONS"] = jsBasicPlatform.GenerateJsLibInclusionHtml(files.Keys);
            this.CopyResourceAsText(files, "background.js", "Resources/BackgroundJs.txt", replacements);
            this.CopyResourceAsText(files, "index.html", "Resources/IndexHtml.txt", replacements); // overwrites GameHostHtml.txt from javascript-app
            this.CopyResourceAsText(files, "chrome_web_app.js", "Resources/ChromeWebAppJs.txt", replacements);
            this.CopyResourceAsText(files, "manifest.json", "Resources/ManifestJson.txt", Util.MakeReplacementStringsJsonSafe(replacements));
            files["icon-16.png"] = new FileOutput()
            {
                Type   = FileOutputType.Image,
                Bitmap = smallIcon,
            };
            files["icon-128.png"] = new FileOutput()
            {
                Type   = FileOutputType.Image,
                Bitmap = largeIcon,
            };

            return(new Dictionary <string, FileOutput>()
            {
                { replacements["PROJECT_ID"] + ".zip", ZipCreator.Create(files, false) }
            });
        }
Exemplo n.º 5
0
        public override void ExportProject(
            Dictionary <string, FileOutput> output,
            TemplateStorage templates,
            IList <LibraryForExport> libraries,
            ResourceDatabase resourceDatabase,
            Options options)
        {
            if (!options.GetBool(ExportOptionKey.HAS_ICON))
            {
                throw new InvalidOperationException("Cannot generate a Chrome Web App without an icon resource.");
            }

            string iconFilePath = options.GetString(ExportOptionKey.ICON_PATH);

            if (!FileUtil.FileExists(iconFilePath))
            {
                throw new InvalidOperationException("Icon resource path points to non-existent file.");
            }
            SystemBitmap iconFile  = new SystemBitmap(iconFilePath);
            SystemBitmap smallIcon = iconFile.CloneToNewSize(16, 16);
            SystemBitmap largeIcon = iconFile.CloneToNewSize(128, 128);

            JavaScriptApp.PlatformImpl      jsBasicPlatform = (JavaScriptApp.PlatformImpl) this.PlatformProvider.GetPlatform("javascript-app");
            Dictionary <string, FileOutput> proxyOutput     = new Dictionary <string, FileOutput>();

            jsBasicPlatform.ExportProjectImpl(proxyOutput, templates, libraries, resourceDatabase, options);
            Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase);

            replacements["JS_LIB_INCLUSIONS"] = JavaScriptApp.PlatformImpl.GenerateJsLibInclusionHtml(proxyOutput.Keys);
            this.CopyResourceAsText(proxyOutput, "background.js", "Resources/BackgroundJs.txt", replacements);
            this.CopyResourceAsText(proxyOutput, "index.html", "Resources/IndexHtml.txt", replacements); // overwrites GameHostHtml.txt from javascript-app
            this.CopyResourceAsText(proxyOutput, "chrome_web_app.js", "Resources/ChromeWebAppJs.txt", replacements);
            this.CopyResourceAsText(proxyOutput, "manifest.json", "Resources/ManifestJson.txt", Util.MakeReplacementStringsJsonSafe(replacements));
            proxyOutput["icon-16.png"] = new FileOutput()
            {
                Type   = FileOutputType.Image,
                Bitmap = smallIcon,
            };
            proxyOutput["icon-128.png"] = new FileOutput()
            {
                Type   = FileOutputType.Image,
                Bitmap = largeIcon,
            };

            output[replacements["PROJECT_ID"] + ".zip"] = ZipCreator.Create(proxyOutput, false);
        }
Exemplo n.º 6
0
        public void HueChange(int hue)
        {
            hue %= 360;
            if (hue == 0)
            {
                return;
            }

            float[][] matrix = HSLColor.HueMatrix(hue);

            System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();
            attr.SetColorMatrix(new System.Drawing.Imaging.ColorMatrix(matrix),
                                System.Drawing.Imaging.ColorMatrixFlag.Default,
                                System.Drawing.Imaging.ColorAdjustType.Bitmap);

            System.Drawing.Bitmap bmp = (System.Drawing.Bitmap)SystemBitmap.Clone();
            Graphics.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, Width, Height),
                               0, 0, Width, Height, System.Drawing.GraphicsUnit.Pixel, attr);
        }
Exemplo n.º 7
0
Arquivo: Basic.cs Projeto: i2ali/RAD
        public void CreateSlicerFactory()
        {
            // This function saves a bitmap source
            Action <String, BitmapSource> saveBitmapSource = (String argFileName, BitmapSource argBitmapSource) =>
            {
                FileStream       stream  = new FileStream(argFileName, FileMode.Create);
                BmpBitmapEncoder encoder = new BmpBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(argBitmapSource));
                encoder.Save(stream);
                stream.Flush();
                stream.Close();
            };

            // This function creates a bitmap source from a system bitmap
            Func <SystemBitmap, BitmapSource> createBitmapSource = (SystemBitmap argSystemBitmap) =>
            {
                // Convert from RGBA to BGRA
                uint currentScanLine = 0;

                for (uint y = 0; y < argSystemBitmap.Height; ++y)
                {
                    uint currentPixel = currentScanLine;

                    for (uint x = 0; x < argSystemBitmap.Width; ++x)
                    {
                        byte tempRed = argSystemBitmap.Data[currentPixel + 0];
                        argSystemBitmap.Data[currentPixel + 0] = argSystemBitmap.Data[currentPixel + 2];
                        argSystemBitmap.Data[currentPixel + 2] = tempRed;

                        currentPixel += 4;
                    }

                    currentScanLine += argSystemBitmap.Stride;
                }


                return(BitmapSource.Create(
                           (int)argSystemBitmap.Width,
                           (int)argSystemBitmap.Height,
                           96,
                           96,
                           PixelFormats.Bgra32,
                           null,
                           argSystemBitmap.Data,
                           (int)argSystemBitmap.Stride));
            };


            SlicerFactory slicerFactory = null;
            IGdiSlicer    gdiSlicer     = null;
            IDwmSlicer    dwmSlicer     = null;


            // Test creating a slicer factory
            int retval = SlicerFactory.Create(out slicerFactory, ComputeShaderModel.None);

            Verify.AreEqual(0, retval, String.Format("SlicerFactory.Create: {0:X08}", retval));
            Verify.IsNotNull(slicerFactory);

            // Put the SlicerFactory object in a "using" block so that we test
            // what happens when the SlicerFactory's resources are freed.
            using (slicerFactory)
            {
                // Test creating a GDI slicer
                retval = slicerFactory.CreateGdiSlicer(out gdiSlicer);

                Verify.AreEqual(0, retval, String.Format("CreateGdiSlicer: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicer);

                // Test creating a DWM slicer
                retval = slicerFactory.CreateDwmSlicer(out dwmSlicer);

                Verify.AreEqual(0, retval, String.Format("CreateDwmSlicer: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicer);
            }


            // Test EndCapture without StartCapture
            {
                SystemBitmap gdiSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmap);
                Verify.AreNotEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
            }

            // Test using DWM and GDI slicer after the slcier factory has been
            // destroyed
            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmap);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmap);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("gdiSlicerTestManaged.1.0.bmp", createBitmapSource(gdiSlicerBitmap));
            }

            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmapLeft  = null;
                SystemBitmap gdiSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmapLeft, out gdiSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmapLeft);
                Verify.IsNull(gdiSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("gdiSlicerTestManaged.2.0.bmp", createBitmapSource(gdiSlicerBitmapLeft));
            }

            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0, Channel.LeftAndRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmapLeft  = null;
                SystemBitmap gdiSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmapLeft, out gdiSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmapLeft);
                Verify.IsNotNull(gdiSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("gdiSlicerTestManaged.3.0.bmp", createBitmapSource(gdiSlicerBitmapLeft));
                saveBitmapSource("gdiSlicerTestManaged.3.1.bmp", createBitmapSource(gdiSlicerBitmapRight));
            }


            // Test EndCapture without StartCapture
            {
                SystemBitmap dwmSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmap);
                Verify.AreNotEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
            }

            // Test using DWM and DWM slicer after the slcier factory has been
            // destroyed
            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmap = null;
                uint         framesCaptured  = 0;
                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmap);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmap);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("dwmSlicerTestManaged.1.0.bmp", createBitmapSource(dwmSlicerBitmap));
            }

            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmapLeft  = null;
                SystemBitmap dwmSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmapLeft, out dwmSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmapLeft);
                Verify.IsNull(dwmSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("dwmSlicerTestManaged.2.0.bmp", createBitmapSource(dwmSlicerBitmapLeft));
            }

            // Note: Windows 8 Bugs #11553 and Windows Blue Bugs #22133
            // Capture left and right channels
            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0, Channel.LeftAndRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmapLeft  = null;
                SystemBitmap dwmSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmapLeft, out dwmSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmapLeft);
                Verify.IsNotNull(dwmSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("dwmSlicerTestManaged.3.0.bmp", createBitmapSource(dwmSlicerBitmapLeft));
                saveBitmapSource("dwmSlicerTestManaged.3.1.bmp", createBitmapSource(dwmSlicerBitmapRight));
            }
        }
Exemplo n.º 8
0
Arquivo: Basic.cs Projeto: i2ali/RAD
        public void CreateSlicerFactory()
        {
            // This function creates a bitmap from a system bitmap
            Func <SystemBitmap, Bitmap> createBitmap = (SystemBitmap argSystemBitmap) =>
            {
                Bitmap bitmap = new Bitmap((int)argSystemBitmap.Width, (int)argSystemBitmap.Height);

                // Convert from RGBA to BGRA
                uint currentScanLine = 0;

                for (uint y = 0; y < argSystemBitmap.Height; ++y)
                {
                    uint currentPixel = currentScanLine;

                    for (uint x = 0; x < argSystemBitmap.Width; ++x)
                    {
                        bitmap.SetPixel(
                            (int)x,
                            (int)y,
                            Color.FromArgb(
                                argSystemBitmap.Data[currentPixel + 3],
                                argSystemBitmap.Data[currentPixel + 0],
                                argSystemBitmap.Data[currentPixel + 1],
                                argSystemBitmap.Data[currentPixel + 2]));

                        currentPixel += 4;
                    }

                    currentScanLine += argSystemBitmap.Stride;
                }

                return(bitmap);
            };


            SlicerFactory slicerFactory = null;
            IGdiSlicer    gdiSlicer     = null;
            IDwmSlicer    dwmSlicer     = null;

            // Test creating a slicer factory
            int retval = SlicerFactory.Create(out slicerFactory, ComputeShaderModel.None);

            Verify.AreEqual(0, retval, String.Format("SlicerFactory.Create: {0:X08}", retval));
            Verify.IsNotNull(slicerFactory);

            // Put the SlicerFactory object in a "using" block so that we test
            // what happens when the SlicerFactory's resources are freed.
            using (slicerFactory)
            {
                // Test creating a GDI slicer
                retval = slicerFactory.CreateGdiSlicer(out gdiSlicer);

                Verify.AreEqual(0, retval, String.Format("CreateGdiSlicer: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicer);

                // Test creating a DWM slicer
                retval = slicerFactory.CreateDwmSlicer(out dwmSlicer);

                Verify.AreEqual(0, retval, String.Format("CreateDwmSlicer: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicer);
            }


            // Test EndCapture without StartCapture
            {
                SystemBitmap gdiSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmap);
                Verify.AreNotEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
            }

            // Test using DWM and GDI slicer after the slcier factory has been
            // destroyed
            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmap);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmap);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(gdiSlicerBitmap).Save("gdiSlicerTestManaged.1.0.bmp", ImageFormat.Bmp);
            }

            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmapLeft  = null;
                SystemBitmap gdiSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmapLeft, out gdiSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmapLeft);
                Verify.IsNull(gdiSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(gdiSlicerBitmapLeft).Save("gdiSlicerTestManaged.2.0.bmp", ImageFormat.Bmp);
            }

            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0, Channel.LeftAndRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmapLeft  = null;
                SystemBitmap gdiSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmapLeft, out gdiSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmapLeft);
                Verify.IsNotNull(gdiSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(gdiSlicerBitmapLeft).Save("gdiSlicerTestManaged.3.0.bmp", ImageFormat.Bmp);
                createBitmap(gdiSlicerBitmapRight).Save("gdiSlicerTestManaged.3.1.bmp", ImageFormat.Bmp);
            }


            // Test EndCapture without StartCapture
            {
                SystemBitmap dwmSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmap);
                Verify.AreNotEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
            }

            // Test using DWM and DWM slicer after the slcier factory has been
            // destroyed
            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmap = null;
                uint         framesCaptured  = 0;
                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmap);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmap);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(dwmSlicerBitmap).Save("dwmSlicerTestManaged.1.0.bmp", ImageFormat.Bmp);
            }

            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmapLeft  = null;
                SystemBitmap dwmSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmapLeft, out dwmSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmapLeft);
                Verify.IsNull(dwmSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(dwmSlicerBitmapLeft).Save("dwmSlicerTestManaged.2.0.bmp", ImageFormat.Bmp);
            }

            // Note: Windows 8 Bugs #11553 and Windows Blue Bugs #22133
            // Capture left and right channels
            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0, Channel.LeftAndRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmapLeft  = null;
                SystemBitmap dwmSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmapLeft, out dwmSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmapLeft);
                Verify.IsNotNull(dwmSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(dwmSlicerBitmapLeft).Save("dwmSlicerTestManaged.3.0.bmp", ImageFormat.Bmp);
                createBitmap(dwmSlicerBitmapRight).Save("dwmSlicerTestManaged.3.1.bmp", ImageFormat.Bmp);
            }
        }
Exemplo n.º 9
0
        public void OutputAndroidBoilerplate(Dictionary <string, FileOutput> output, Dictionary <string, string> replacements, Options options)
        {
            string packagedDir = replacements["JAVA_PACKAGE"].Replace('.', '/');

            output[".gitignore"]        = this.LoadTextFile("Resources/gitignore.txt", replacements);
            output["build.gradle"]      = this.LoadTextFile("Resources/buildGradle.txt", replacements);
            output["android.iml"]       = this.LoadTextFile("Resources/androidIml.txt", replacements);
            output["gradle.properties"] = this.LoadTextFile("Resources/gradleProperties.txt", replacements);
            output["gradlew"]           = this.LoadTextFile("Resources/gradlew.txt", replacements);
            output["gradlew.bat"]       = this.LoadTextFile("Resources/gradlewBat.txt", replacements);
            output["local.properties"]  = this.LoadTextFile("Resources/localProperties.txt", replacements);
            output["settings.gradle"]   = this.LoadTextFile("Resources/settingsGradle.txt", replacements);

            output["gradle/wrapper/gradle-wrapper.jar"]        = this.LoadBinaryFile("Resources/gradle/wrapper/GradleWrapper.jar");
            output["gradle/wrapper/gradle-wrapper.properties"] = this.LoadTextFile("Resources/gradle/wrapper/GradleWrapperProperties.txt", replacements);

            output[".idea/.name"]         = this.LoadTextFile("Resources/idea/name.txt", replacements);
            output[".idea/compiler.xml"]  = this.LoadTextFile("Resources/idea/compilerXml.txt", replacements);
            output[".idea/encodings.xml"] = this.LoadTextFile("Resources/idea/encodingsXml.txt", replacements);
            output[".idea/gradle.xml"]    = this.LoadTextFile("Resources/idea/gradleXml.txt", replacements);
            output[".idea/misc.xml"]      = this.LoadTextFile("Resources/idea/miscXml.txt", replacements);
            output[".idea/modules.xml"]   = this.LoadTextFile("Resources/idea/modulesXml.txt", replacements);
            output[".idea/vcs.xml"]       = this.LoadTextFile("Resources/idea/vcsXml.txt", replacements);
            output[".idea/copyright/profiles_settings.xml"] = this.LoadTextFile("Resources/idea/copyright/profileSettings.txt", replacements);
            output[".idea/scopes/scope_settings.xml"]       = this.LoadTextFile("Resources/idea/scopes/scopeSettings.txt", replacements);

            if (!options.GetBool(ExportOptionKey.ANDROID_SKIP_WORKSPACE_XML))
            {
                output[".idea/workspace.xml"] = this.LoadTextFile("Resources/idea/workspaceXml.txt", replacements);
            }

            output["app/.gitignore"]         = this.LoadTextFile("Resources/app/gitignore.txt", replacements);
            output["app/app.iml"]            = this.LoadTextFile("Resources/app/appIml.txt", replacements);
            output["app/build.gradle"]       = this.LoadTextFile("Resources/app/buildGradle.txt", replacements);
            output["app/proguard-rules.txt"] = this.LoadTextFile("Resources/app/proguardRules.txt", replacements);

            output["app/src/main/java/" + packagedDir + "/app/MainActivity.java"] = this.LoadTextFile("Resources/app/src/main/java/org/crayonlang/sampleapp/app/MainActivityJava.txt", replacements);
            output["app/src/main/res/layout/activity_main.xml"] = this.LoadTextFile("Resources/app/src/main/res/layout/ActivityMainXml.txt", replacements);
            output["app/src/main/res/menu/main.xml"]            = this.LoadTextFile("Resources/app/src/main/res/menu/MainXml.txt", replacements);
            output["app/src/main/res/values/dimens.xml"]        = this.LoadTextFile("Resources/app/src/main/res/values/DimensXml.txt", replacements);
            output["app/src/main/res/values/strings.xml"]       = this.LoadTextFile("Resources/app/src/main/res/values/StringsXml.txt", replacements);
            output["app/src/main/res/values/styles.xml"]        = this.LoadTextFile("Resources/app/src/main/res/values/StylesXml.txt", replacements);
            output["app/src/main/res/values-w820dp/dimens.xml"] = this.LoadTextFile("Resources/app/src/main/res/valuesW820dp/DimensXml.txt", replacements);

            FileOutput androidManifest = this.LoadTextFile("Resources/app/src/main/AndroidManifestXml.txt", replacements);

            output["app/src/main/AndroidManifest.xml"] = androidManifest;
            androidManifest.TextContent = this.AdjustAndroidManifest(androidManifest.TextContent, options);

            IconSetGenerator icons = new IconSetGenerator();

            if (options.GetBool(ExportOptionKey.HAS_ICON))
            {
                string       iconPath = options.GetString(ExportOptionKey.ICON_PATH);
                SystemBitmap icon     = new SystemBitmap(iconPath);
                icons.AddInputImage(icon);
            }
            Dictionary <int, SystemBitmap> iconImagesBySize = icons
                                                              .AddOutputSize(48)
                                                              .AddOutputSize(72)
                                                              .AddOutputSize(96)
                                                              .AddOutputSize(144)
                                                              .AddOutputSize(512)
                                                              .GenerateWithDefaultFallback();

            output["app/src/main/res/drawable-mdpi/ic_launcher.png"] = new FileOutput()
            {
                Type = FileOutputType.Image, Bitmap = iconImagesBySize[48]
            };
            output["app/src/main/res/drawable-hdpi/ic_launcher.png"] = new FileOutput()
            {
                Type = FileOutputType.Image, Bitmap = iconImagesBySize[72]
            };
            output["app/src/main/res/drawable-xhdpi/ic_launcher.png"] = new FileOutput()
            {
                Type = FileOutputType.Image, Bitmap = iconImagesBySize[96]
            };
            output["app/src/main/res/drawable-xxhdpi/ic_launcher.png"] = new FileOutput()
            {
                Type = FileOutputType.Image, Bitmap = iconImagesBySize[144]
            };
            output["app/src/main/ic_launcher-web.png"] = new FileOutput()
            {
                Type = FileOutputType.Image, Bitmap = iconImagesBySize[512]
            };
        }
Exemplo n.º 10
0
        public override void ExportProject(
            Dictionary <string, FileOutput> output,
            TemplateStorage templates,
            IList <LibraryForExport> libraries,
            ResourceDatabase resourceDatabase,
            Options options)
        {
            options.SetOption(ExportOptionKey.JS_FILE_PREFIX, null);
            options.SetOption(ExportOptionKey.JS_FULL_PAGE, false); // iOS export has its own enforced fullscreen logic
            options.SetOption(ExportOptionKey.JS_HEAD_EXTRAS, string.Join(
                                  "\n",
                                  "<script type=\"text/javascript\" src=\"ios.js\"></script>",
                                  "<style type=\"text/css\">",
                                  "  body { margin:0px; background-color:#000; }",
                                  "  #crayon_host {",
                                  "    background-color:#000;",
                                  "    text-align:left;",
                                  "    width:100%;",
                                  "    height:100%;",
                                  "  }",
                                  "</style>"
                                  ));
            Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase);

            Dictionary <string, FileOutput> files        = new Dictionary <string, FileOutput>();
            Dictionary <string, FileOutput> basicProject = new Dictionary <string, FileOutput>();

            this.ParentPlatform.ExportProject(
                basicProject,
                templates,
                libraries,
                resourceDatabase,
                options);

            // TODO: not good. The library inclusions should automatically be populated in LangJavaScript platforms.
            // This is also done identically in the ChromeApp PlatformImpl.
            replacements["JS_LIB_INCLUSIONS"] = JavaScriptApp.PlatformImpl.GenerateJsLibInclusionHtml(basicProject.Keys);

            foreach (string filePath in basicProject.Keys)
            {
                files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/" + filePath] = basicProject[filePath];
            }

            // TODO: use this in the pbxproj file.
            string uuidSeed = options.GetStringOrNull(ExportOptionKey.GUID_SEED);


            OrientationParser orientations         = new OrientationParser(options);
            bool       useLandscapeForLaunchscreen = orientations.SupportsLandscapeLeft || orientations.SupportsLandscapeRight;
            FileOutput launchScreen;

            if (options.GetBool(ExportOptionKey.HAS_LAUNCHSCREEN))
            {
                launchScreen = new FileOutput()
                {
                    Type   = FileOutputType.Image,
                    Bitmap = new SystemBitmap(options.GetString(ExportOptionKey.LAUNCHSCREEN_PATH)),
                };
            }
            else
            {
                launchScreen = new FileOutput()
                {
                    Type   = FileOutputType.Image,
                    Bitmap = new SystemBitmap(typeof(JavaScriptAppIos.PlatformImpl).Assembly, "SwiftResources/" +
                                              (useLandscapeForLaunchscreen ? "launchhorizontal.png" : "launchvertical.png")),
                };
            }
            files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/launchscreen.png"] = launchScreen;
            replacements["LAUNCH_SCREEN_WIDTH"]  = launchScreen.Bitmap.Width.ToString();
            replacements["LAUNCH_SCREEN_HEIGHT"] = launchScreen.Bitmap.Height.ToString();

            IconSetGenerator icons = new IconSetGenerator();

            if (options.GetBool(ExportOptionKey.HAS_ICON))
            {
                string       iconPath = options.GetString(ExportOptionKey.ICON_PATH);
                SystemBitmap icon     = new SystemBitmap(iconPath);
                icons.AddInputImage(icon);
            }

            Dictionary <int, SystemBitmap> iconImagesBySize = icons
                                                              .AddOutputSize(20 * 1)
                                                              .AddOutputSize(20 * 2)
                                                              .AddOutputSize(20 * 3)
                                                              .AddOutputSize(29 * 1)
                                                              .AddOutputSize(29 * 2)
                                                              .AddOutputSize(29 * 3)
                                                              .AddOutputSize(40 * 1)
                                                              .AddOutputSize(40 * 2)
                                                              .AddOutputSize(40 * 3)
                                                              .AddOutputSize(60 * 2)
                                                              .AddOutputSize(60 * 3)
                                                              .AddOutputSize(76 * 1)
                                                              .AddOutputSize(76 * 2)
                                                              .AddOutputSize(167) // 83.5 * 2
                                                              .GenerateWithDefaultFallback();

            foreach (int size in iconImagesBySize.Keys)
            {
                files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/icon" + size + ".png"] = new FileOutput()
                {
                    Type   = FileOutputType.Image,
                    Bitmap = iconImagesBySize[size],
                };
            }

            foreach (string pair in new string[] {
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%.xcodeproj/project.pbxproj|SwiftResources/PbxProj.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/AppDelegate.swift|SwiftResources/AppDelegateSwift.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/Contents.json|SwiftResources/IconSetContentJson.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/Contents.json|SwiftResources/ImageSetContentJson.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/LaunchScreen.storyboard|SwiftResources/LaunchScreenStoryboard.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/Main.storyboard|SwiftResources/MainStoryboard.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Info.plist|SwiftResources/InfoPlist.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/ViewController.swift|SwiftResources/ViewControllerSwift.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/ios.js|SwiftResources/iOSjs.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/index.html|SwiftResources/HostHtml.txt",
            })
            {
                string[] parts = pair.Split('|');
                files[parts[0]] = new FileOutput()
                {
                    TrimBomIfPresent = true,
                    Type             = FileOutputType.Text,
                    TextContent      = this.LoadTextResource(parts[1], replacements),
                };
            }

            foreach (string filename in files.Keys)
            {
                output[this.ApplyReplacements(filename, replacements)] = files[filename];
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Gets or sets the color of a given pixel of the Bitmap.
 /// </summary>
 /// <param name="x">The x-coordinate of the pixel.</param>
 /// <param name="y">The y-coordinate of the pixel.</param>
 /// <returns></returns>
 public Color this[int x, int y]
 {
     get { return(new Color(SystemBitmap.GetPixel(x, y))); }
     set { SystemBitmap.SetPixel(x, y, value.ToSystemColor()); NeedRefresh = true; }
 }
Exemplo n.º 12
0
        public override Dictionary <string, FileOutput> ExportProject(
            IList <VariableDeclaration> globals,
            IList <StructDefinition> structDefinitions,
            IList <FunctionDefinition> functionDefinitions,
            IList <LibraryForExport> libraries,
            ResourceDatabase resourceDatabase,
            Options options,
            ILibraryNativeInvocationTranslatorProvider libraryNativeInvocationTranslatorProviderForPlatform)
        {
            options.SetOption(ExportOptionKey.JS_FILE_PREFIX, null);
            options.SetOption(ExportOptionKey.JS_HEAD_EXTRAS, string.Join(
                                  "\n",
                                  "<script type=\"text/javascript\" src=\"ios.js\"></script>",
                                  "<style type=\"text/css\">",
                                  "  body { margin:0px; background-color:#000; }",
                                  "  #crayon_host {",
                                  "    background-color:#000;",
                                  "    text-align:left;",
                                  "    width:100%;",
                                  "    height:100%;",
                                  "  }",
                                  "</style>"
                                  ));
            Dictionary <string, string>     replacements = this.GenerateReplacementDictionary(options, resourceDatabase);
            Dictionary <string, FileOutput> files        = new Dictionary <string, FileOutput>();
            Dictionary <string, FileOutput> basicProject = this.ParentPlatform.ExportProject(
                globals,
                structDefinitions,
                functionDefinitions,
                libraries,
                resourceDatabase,
                options,
                libraryNativeInvocationTranslatorProviderForPlatform);

            foreach (string filePath in basicProject.Keys)
            {
                files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/" + filePath] = basicProject[filePath];
            }

            // TODO: use this in the pbxproj file.
            string uuidSeed = options.GetStringOrNull(ExportOptionKey.GUID_SEED);


            OrientationParser orientations         = new OrientationParser(options);
            bool       useLandscapeForLaunchscreen = orientations.SupportsLandscapeLeft || orientations.SupportsLandscapeRight;
            FileOutput launchScreen;

            if (options.GetBool(ExportOptionKey.HAS_LAUNCHSCREEN))
            {
                launchScreen = new FileOutput()
                {
                    Type   = FileOutputType.Image,
                    Bitmap = new SystemBitmap(options.GetString(ExportOptionKey.LAUNCHSCREEN_PATH)),
                };
            }
            else
            {
                launchScreen = new FileOutput()
                {
                    Type   = FileOutputType.Image,
                    Bitmap = new SystemBitmap(typeof(JavaScriptAppIosTranslator).Assembly, "SwiftResources/" +
                                              (useLandscapeForLaunchscreen ? "launchhorizontal.png" : "launchvertical.png")),
                };
            }
            files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/launchscreen.png"] = launchScreen;
            replacements["LAUNCH_SCREEN_WIDTH"]  = launchScreen.Bitmap.Width.ToString();
            replacements["LAUNCH_SCREEN_HEIGHT"] = launchScreen.Bitmap.Height.ToString();

            IconSetGenerator icons = new IconSetGenerator();

            if (options.GetBool(ExportOptionKey.HAS_ICON))
            {
                string       iconPath = options.GetString(ExportOptionKey.ICON_PATH);
                SystemBitmap icon     = new SystemBitmap(iconPath);
                icons.AddInputImage(icon);
            }

            Dictionary <int, SystemBitmap> iconImagesBySize = icons
                                                              .AddOutputSize(20 * 1)
                                                              .AddOutputSize(20 * 2)
                                                              .AddOutputSize(20 * 3)
                                                              .AddOutputSize(29 * 1)
                                                              .AddOutputSize(29 * 2)
                                                              .AddOutputSize(29 * 3)
                                                              .AddOutputSize(40 * 1)
                                                              .AddOutputSize(40 * 2)
                                                              .AddOutputSize(40 * 3)
                                                              .AddOutputSize(60 * 2)
                                                              .AddOutputSize(60 * 3)
                                                              .AddOutputSize(76 * 1)
                                                              .AddOutputSize(76 * 2)
                                                              .AddOutputSize(167) // 83.5 * 2
                                                              .GenerateWithDefaultFallback();

            foreach (int size in iconImagesBySize.Keys)
            {
                files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/icon" + size + ".png"] = new FileOutput()
                {
                    Type   = FileOutputType.Image,
                    Bitmap = iconImagesBySize[size],
                };
            }

            foreach (string pair in new string[] {
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%.xcodeproj/project.pbxproj|SwiftResources/PbxProj.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/AppDelegate.swift|SwiftResources/AppDelegateSwift.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/Contents.json|SwiftResources/IconSetContentJson.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/Contents.json|SwiftResources/ImageSetContentJson.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/LaunchScreen.storyboard|SwiftResources/LaunchScreenStoryboard.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/Main.storyboard|SwiftResources/MainStoryboard.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Info.plist|SwiftResources/InfoPlist.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/ViewController.swift|SwiftResources/ViewControllerSwift.txt",
                "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/ios.js|SwiftResources/iOSjs.txt",
            })
            {
                string[] parts = pair.Split('|');
                files[parts[0]] = new FileOutput()
                {
                    TrimBomIfPresent = true,
                    Type             = FileOutputType.Text,
                    TextContent      = this.LoadTextResource(parts[1], replacements),
                };
            }

            Dictionary <string, FileOutput> filesFixed = new Dictionary <string, FileOutput>();

            foreach (string filename in files.Keys)
            {
                filesFixed[this.ApplyReplacements(filename, replacements)] = files[filename];
            }

            return(filesFixed);
        }
Exemplo n.º 13
0
        //
        // mEndCaptureButton Handlers
        //

        private void mEndCaptureButton_Click(object sender, RoutedEventArgs e)
        {
            // This function creates a bitmap source from a system bitmap
            Func <SystemBitmap, BitmapSource> createBitmapSource = (SystemBitmap argSystemBitmap) =>
            {
                // Convert from RGBA to BGRA
                uint currentScanLine = 0;

                for (uint y = 0; y < argSystemBitmap.Height; ++y)
                {
                    uint currentPixel = currentScanLine;

                    for (uint x = 0; x < argSystemBitmap.Width; ++x)
                    {
                        byte tempRed = argSystemBitmap.Data[currentPixel + 0];
                        argSystemBitmap.Data[currentPixel + 0] = argSystemBitmap.Data[currentPixel + 2];
                        argSystemBitmap.Data[currentPixel + 2] = tempRed;

                        currentPixel += 4;
                    }

                    currentScanLine += argSystemBitmap.Stride;
                }


                return(BitmapSource.Create(
                           (int)argSystemBitmap.Width,
                           (int)argSystemBitmap.Height,
                           96,
                           96,
                           PixelFormats.Bgra32,
                           null,
                           argSystemBitmap.Data,
                           (int)argSystemBitmap.Stride));
            };


            // End capturing
            uint         framesCaptured = 0;
            SystemBitmap leftImage      = null;
            SystemBitmap rightImage     = null;

            try
            {
                Marshal.ThrowExceptionForHR(
                    this.mSlicer.EndCapture(
                        ref framesCaptured,
                        out leftImage,
                        out rightImage));

                if (null != leftImage)
                {
                    // Show a save file dialog first
                    Microsoft.Win32.SaveFileDialog s = new Microsoft.Win32.SaveFileDialog();
                    s.Title        = "Left Image";
                    s.Filter       = "Bitmap|*.bmp";
                    s.AddExtension = true;
                    s.DefaultExt   = ".bmp";

                    bool?retval = s.ShowDialog();

                    if (null != retval && true == retval)
                    {
                        FileStream       stream  = new FileStream(s.FileName, FileMode.Create);
                        BmpBitmapEncoder encoder = new BmpBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(createBitmapSource(leftImage)));
                        encoder.Save(stream);
                        stream.Flush();
                        stream.Close();
                    }
                }

                if (null != rightImage)
                {
                    // Show a save file dialog first
                    Microsoft.Win32.SaveFileDialog s = new Microsoft.Win32.SaveFileDialog();
                    s.Title        = "Right Image";
                    s.Filter       = "Bitmap|*.bmp";
                    s.AddExtension = true;
                    s.DefaultExt   = ".bmp";

                    bool?retval = s.ShowDialog();

                    if (null != retval && true == retval)
                    {
                        FileStream       stream  = new FileStream(s.FileName, FileMode.Create);
                        BmpBitmapEncoder encoder = new BmpBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(createBitmapSource(rightImage)));
                        encoder.Save(stream);
                        stream.Flush();
                        stream.Close();
                    }
                }

                // Enable the proper buttons again
                this.mAreaSelect_Button.Dispatcher.Invoke(new Action(() => { this.mAreaSelect_Button.IsEnabled = true; }));
                this.mCancel_Button.Dispatcher.Invoke(new Action(() => { this.mCancel_Button.IsEnabled = false; }));
                this.mEndCapture_Button.Dispatcher.Invoke(new Action(() => { this.mEndCapture_Button.IsEnabled = false; }));
                this.mStartCapture_Button.Dispatcher.Invoke(new Action(() => { this.mStartCapture_Button.IsEnabled = true; }));

                this.mMaxFrames_TextBox.Dispatcher.Invoke(new Action(() => { this.mMaxFrames_TextBox.IsEnabled = true; }));
                this.mSkipFrames_TextBox.Dispatcher.Invoke(new Action(() => { this.mSkipFrames_TextBox.IsEnabled = true; }));
                this.mChannel_ComboBox.Dispatcher.Invoke(new Action(() => { this.mChannel_ComboBox.IsEnabled = true; }));
                this.mStartCaptureDelay_TextBox.Dispatcher.Invoke(new Action(() => { this.mStartCaptureDelay_TextBox.IsEnabled = true; }));

                this.mStatus_TextBlock.Text    = "Capture Complete";
                this.mCountDown_TextBlock.Text = "-";
            }
            catch (Exception exception)
            {
                this.mStatus_TextBlock.Dispatcher.Invoke(new Action(() => { this.mStatus_TextBlock.Text = String.Format("Error 0x{0:X08}", exception.HResult); }));
                this.mCountDown_TextBlock.Dispatcher.Invoke(new Action(() => { this.mCountDown_TextBlock.Text = "-"; }));

                // Enable the proper buttons again
                this.mAreaSelect_Button.Dispatcher.Invoke(new Action(() => { this.mAreaSelect_Button.IsEnabled = true; }));
                this.mCancel_Button.Dispatcher.Invoke(new Action(() => { this.mCancel_Button.IsEnabled = false; }));
                this.mEndCapture_Button.Dispatcher.Invoke(new Action(() => { this.mEndCapture_Button.IsEnabled = false; }));
                this.mStartCapture_Button.Dispatcher.Invoke(new Action(() => { this.mStartCapture_Button.IsEnabled = true; }));

                this.mMaxFrames_TextBox.Dispatcher.Invoke(new Action(() => { this.mMaxFrames_TextBox.IsEnabled = true; }));
                this.mSkipFrames_TextBox.Dispatcher.Invoke(new Action(() => { this.mSkipFrames_TextBox.IsEnabled = true; }));
                this.mChannel_ComboBox.Dispatcher.Invoke(new Action(() => { this.mChannel_ComboBox.IsEnabled = true; }));
                this.mStartCaptureDelay_TextBox.Dispatcher.Invoke(new Action(() => { this.mStartCaptureDelay_TextBox.IsEnabled = true; }));
            }
        }