예제 #1
0
        public override bool Execute()
        {
            LogHeaderMessage();

            if (!File.Exists(fileName))
            {
                Log.LogError("TRX File not found {0}", fileName);
                return(false);
            }

            try
            {
                Log.LogMessage("Creating HTML Report from TRX file: {0}", fileName);

                VersionFinder    v = new VersionFinder();
                SupportedFormats f = v.GetFileVersion(fileName);
                if (f == SupportedFormats.unknown)
                {
                    Log.LogMessage("File {0} is not a recognized trx", fileName);
                }
                {
                    Log.LogMessage("Processing {0} trx file", f.ToString());
                    Transform(fileName, PrepareXsl(f.ToString()));
                    Log.LogMessage("Tranformation Succeed. OutputFile: " + fileName + ".htm\n");
                }

                Log.LogMessage("Report generation Succeed. OutputFile: {0}.htm\n", fileName);
                return(true);
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex);
                throw;
            }
        }
예제 #2
0
        /// <summary>
        /// Process image looking for corners.
        /// </summary>
        ///
        /// <param name="image">Source image to process.</param>
        ///
        /// <returns>Returns list of found corners (X-Y coordinates).</returns>
        ///
        /// <exception cref="UnsupportedImageFormatException">The source image has incorrect pixel format.</exception>
        ///
        public new List <IntPoint> ProcessImage(Bitmap image)
        {
            // check image format
            if (!SupportedFormats.Contains(image.PixelFormat))
            {
                throw new UnsupportedImageFormatException("Unsupported pixel format of the source image.");
            }

            // lock source image
            BitmapData imageData = image.LockBits(ImageLockMode.ReadOnly);

            List <IntPoint> corners;

            try
            {
                // process the image
                corners = ProcessImage(new UnmanagedImage(imageData));
            }
            finally
            {
                // unlock image
                image.UnlockBits(imageData);
            }

            return(corners);
        }
예제 #3
0
 /* ----------------------------------------------------------------- */
 ///
 /// ImageConverter
 ///
 /// <summary>
 /// オブジェクトを初期化します。
 /// </summary>
 ///
 /// <param name="format">変換後のフォーマット</param>
 /// <param name="io">I/O オブジェクト</param>
 ///
 /* ----------------------------------------------------------------- */
 public ImageConverter(Format format, IO io) : base(format, io)
 {
     if (!SupportedFormats.Contains(format))
     {
         throw new NotSupportedException();
     }
 }
예제 #4
0
        internal static void GenerateReport(string fileName)
        {
            VersionFinder    v = new VersionFinder();
            SupportedFormats f = v.GetFileVersion(fileName);

            if (f != SupportedFormats.vs2010)
            {
                Console.WriteLine("File {0} is not a recognized as a valid trx. Only VS2010 are supported", fileName);
            }
            else
            {
                Console.WriteLine("Processing {0} trx file", f.ToString());

                TrxParser     parser = new TrxParser();
                TestRunResult r      = parser.Parse(fileName);
                string        html   = new HtmlConverter(r).GetHtml();

                using (TextWriter file = File.CreateText(fileName + ".htm"))
                {
                    file.Write(html);
                }

                Console.WriteLine("Tranformation Succeed. OutputFile: " + fileName + ".htm\n");
            }
        }
예제 #5
0
        public bool FileFormatSupported(string fileExtension)
        {
            if (string.IsNullOrEmpty(fileExtension))
            {
                return(false);
            }

            return(SupportedFormats.Any(f => f.Equals(fileExtension, StringComparison.OrdinalIgnoreCase)));
        }
        /// <summary>
        ///   Applies the transformation to an input, producing an associated output.
        /// </summary>
        ///
        /// <param name="input">The input data to which the transformation should be applied.</param>
        ///
        /// <returns>The output generated by applying this transformation to the given input.</returns>
        ///
        public IEnumerable <TFeature> Transform(Signal input)
        {
            // check image format
            if (!SupportedFormats.Contains(input.SampleFormat))
            {
                throw new UnsupportedSampleFormatException("Unsupported pixel format of the source image.");
            }

            return(InnerTransform(input));
        }
예제 #7
0
        /// <summary>
        /// Process image looking for corners.
        /// </summary>
        ///
        /// <param name="input">Source image data to process.</param>
        ///
        /// <returns>Returns list of found corners (X-Y coordinates).</returns>
        ///
        /// <exception cref="UnsupportedImageFormatException">The source image has incorrect pixel format.</exception>
        ///
        public new List <IntPoint> ProcessImage(UnmanagedImage input)
        {
            // check image format
            if (!SupportedFormats.Contains(input.PixelFormat))
            {
                throw new UnsupportedImageFormatException("Unsupported pixel format of the source image.");
            }

            return(InnerProcess(input));
        }
예제 #8
0
        /// <summary>
        /// Decode TGA Header.
        /// </summary>
        /// <param name="reader">Image stream.</param>
        /// <param name="description">Image description.</param>
        public unsafe void DecodeHeader(BinaryReader reader, out ImageDescription description)
        {
            KTXHeader header = ImageHelpers.ReadStruct <KTXHeader>(reader);

            description = new ImageDescription()
            {
                imageFormat = ImageFormat.KTX,
                Width       = Math.Max(1, header.pixelWidth),
                Height      = Math.Max(1, header.pixelHeight),
                Depth       = Math.Max(1, header.pixelDepth),
                MipLevels   = Math.Max(1, header.numberOfMipmapLevels),
                ArraySize   = Math.Max(1, header.numberOfArrayElements),
                Faces       = Math.Max(1, header.numberOfFaces),
                pixelFormat = SupportedFormats.FromOpenGLFormat(ref header),
            };
        }
예제 #9
0
        public DiscordImage Download(DiscordCDNImageFormat format = DiscordCDNImageFormat.Any)
        {
            if (format != DiscordCDNImageFormat.Any && SupportedFormats != null && !SupportedFormats.Contains(format))
            {
                throw new NotSupportedException("Image format not supported. Supported formats for this endpoint: " + string.Join(", ", SupportedFormats));
            }

            string extension = format == DiscordCDNImageFormat.Any ? "" : $".{format.ToString().ToLower()}";

            try
            {
                return(new DiscordImage((Bitmap) new ImageConverter().ConvertFrom(new HttpClient().GetByteArrayAsync(Url + extension).Result)));
            }
            catch
            {
                return(null);
            }
        }
예제 #10
0
        /// <summary>
        /// Decode TGA data.
        /// </summary>
        /// <param name="reader">Binary reader.</param>
        /// <param name="databoxes">Databoxes array.</param>
        /// <param name="description">Image Description.</param>
        public void DecodeData(BinaryReader reader, out DataBox[] databoxes, out ImageDescription description)
        {
            KTXTexture texture = KTXTexture.Load(reader, true);
            var        header  = texture.Header;

            description = new ImageDescription()
            {
                imageFormat = ImageFormat.KTX,
                Width       = Math.Max(1, texture.Header.pixelWidth),
                Height      = Math.Max(1, texture.Header.pixelHeight),
                Depth       = Math.Max(1, texture.Header.pixelDepth),
                MipLevels   = Math.Max(1, texture.Header.numberOfMipmapLevels),
                ArraySize   = Math.Max(1, texture.Header.numberOfArrayElements),
                Faces       = Math.Max(1, header.numberOfFaces),
                pixelFormat = SupportedFormats.FromOpenGLFormat(ref header),
            };

            databoxes = new DataBox[description.ArraySize * description.Faces * description.MipLevels];

            for (int mipmapIndex = 0; mipmapIndex < texture.Mipmaps.Length; mipmapIndex++)
            {
                var level = texture.Mipmaps[mipmapIndex];
                for (int sliceIndex = 0; sliceIndex < level.ArrayElements.Length; sliceIndex++)
                {
                    var slice = level.ArrayElements[sliceIndex];

                    for (int faceIndex = 0; faceIndex < slice.Faces.Length; faceIndex++)
                    {
                        var face = slice.Faces[faceIndex];

                        uint formatSize           = description.pixelFormat.GetSizeInBits() / 8;
                        uint rowPitch             = (uint)level.Width * formatSize;
                        uint slicePitch           = (uint)face.Data.Length;
                        int  sliceIndexCalculated = (sliceIndex * slice.Faces.Length) + faceIndex;
                        int  index = (sliceIndexCalculated * (int)description.MipLevels) + mipmapIndex;


                        databoxes[index] = new DataBox(face.Data, rowPitch, slicePitch);
                    }
                }
            }
        }
        public bool CheckImage(FilePath path)
        {
            int    width, height;
            string errorTitle   = null;
            string errorMessage = null;

            using (var type = Pixbuf.GetFileInfo(path, out width, out height))
            {
                if (type == null)
                {
                    errorTitle   = GettextCatalog.GetString("Invalid file selected");
                    errorMessage = GettextCatalog.GetString("Selected file was not a valid image.");
                }
                else if (type.IsDisabled)
                {
                    errorTitle   = GettextCatalog.GetString("Unsupported image selected");
                    errorMessage = GettextCatalog.GetString("Support for loading images of type '{0}' has not been enabled.", type.Name);
                }
                else if (AcceptedSize != Size.Empty && AcceptedSize != new Size(width, height))
                {
                    errorTitle   = GettextCatalog.GetString("Incorrect image dimensions");
                    errorMessage = GettextCatalog.GetString(
                        "Only images with size {0}x{1} are allowed. Picture was {2}x{3}.",
                        AcceptedSize.Width, AcceptedSize.Height, width, height);
                }
                else if (!SupportedFormats.Contains(type.Name))
                {
                    var formats = string.Join(", ", SupportedFormats.Select(f => "'" + f + "'"));
                    errorTitle   = GettextCatalog.GetString("Invalid image selected");
                    errorMessage = GettextCatalog.GetString("An image of type '{0}' has been selected but you must select an image of type '{1}'.", type.Name, formats);
                }
                else
                {
                    return(true);
                }

                LoggingService.LogError("{0}: {1}", errorTitle, errorMessage);
                MessageService.ShowError(errorTitle, errorMessage);
                return(false);
            }
        }
        protected override void OnClicked()
        {
            base.OnClicked();
            if (project == null)
            {
                return;
            }

            var formats = string.Join("|", SupportedFormats.Select(f => "*." + f));
            var dialog  = new ProjectFileSelectorDialog(project, "All Images", formats);

            try
            {
                if (AcceptedSize.IsEmpty)
                {
                    dialog.Title = GettextCatalog.GetString("Select image...");
                }
                else
                {
                    dialog.Title = GettextCatalog.GetString("Select image ({0}x{1})...", RecommendedSize.Width, RecommendedSize.Height);
                }
                while (MessageService.RunCustomDialog(dialog) == (int)Gtk.ResponseType.Ok && dialog.SelectedFile != null)
                {
                    var path = dialog.SelectedFile.FilePath;
                    if (!CheckImage(path))
                    {
                        continue;
                    }

                    SelectedProjectFile = dialog.SelectedFile.ProjectVirtualPath;
                    OnChanged(EventArgs.Empty);
                    break;
                }
            }
            finally
            {
                dialog.Destroy();
            }
        }
예제 #13
0
        internal SupportedFormats GetFileVersion(string file)
        {
            SupportedFormats result = SupportedFormats.unknown;

            using (XmlReader r = XmlReader.Create(file))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(r);

                if (CheckVersion(doc.DocumentElement))
                {
                    result = SupportedFormats.vs2005;
                }
                if (IsVS2008(doc.DocumentElement))
                {
                    result = SupportedFormats.vs2008;
                }
                if (IsVS2010(doc.DocumentElement))
                {
                    result = SupportedFormats.vs2010;
                }
            }
            return(result);
        }
예제 #14
0
        static void Main(string[] args)
        {
            Console.WriteLine("trx2html.exe \n  Create HTML reports of VSTS TestRuns. (c)rido'08");
            Console.WriteLine("version:" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\n");
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: trx2html <TestResult>.trx");
                return;
            }

            string           fileName = args[0];
            VersionFinder    v        = new VersionFinder();
            SupportedFormats f        = v.GetFileVersion(fileName);

            if (f == SupportedFormats.unknown)
            {
                Console.WriteLine("File {0} is not a recognized trx", fileName);
            }
            {
                Console.WriteLine("Processing {0} trx file", f.ToString());
                Transform(fileName, PrepareXsl(f.ToString()));
                Console.WriteLine("Tranformation Succeed. OutputFile: " + fileName + ".htm\n");
            }
        }
 /// <summary>
 /// Indicates if a file with the specifies file extension is of this type
 /// </summary>
 /// <param name="fileExtension">The file extension to check</param>
 /// <returns>True if it is of this type, otherwise false</returns>
 public virtual bool IsOfType(FileExtension fileExtension) => SupportedFormats.Any(x => GetFormat(x) == fileExtension);
예제 #16
0
 public AudioPlayerAttribute(string name, string supportedFormats)
 {
     Name = name;
     SupportedFormats.AddRange(supportedFormats.Replace(" ", string.Empty).Split(';'));
 }
예제 #17
0
 public AudioPlayerAttribute(string name, string[] supportedFormats)
 {
     Name = name;
     SupportedFormats.AddRange(supportedFormats);
 }
예제 #18
0
 public static bool CanApply(BitmapSource bitmap, EffectType effectType)
 {
     return(SupportedFormats.ContainsKey(effectType) &&
            SupportedFormats[effectType].ToList().Contains(bitmap.Format) &&
            EffectByType.ContainsKey(effectType));
 }