Exemplo n.º 1
0
        /// <summary>
        /// Prepares the Media.
        /// </summary>
        /// <param name="card">The card.</param>
        /// <param name="printstatusreport">The printstatusreport.</param>
        /// <remarks>Documented by Dev03, 2007-08-17</remarks>
        private void PrepareMedia(XmlNode card, PrintStatusReport printstatusreport)
        {
            if (printstatusreport != null)
                printstatusreport.PrepareCount = card.SelectNodes(XPathResourceFilter).Count;

            foreach (XmlNode resource in card.SelectNodes(XPathResourceFilter))
            {
                string path = resource.Value;
                try
                {
                    if (DAL.Helper.GetMediaType(path) == EMedia.Image)
                    {
                        //try to read the image size from the file if it is not given ([ML-128])
                        XmlElement xeMedia = (XmlElement)resource.ParentNode;
                        if (xeMedia.GetAttribute("width") == String.Empty)
                        {
                            using (System.Drawing.Bitmap image = new System.Drawing.Bitmap(path))
                            {
                                System.Drawing.Size size = image.Size;
                                xeMedia.SetAttribute("width", size.Width.ToString());
                                xeMedia.SetAttribute("height", size.Height.ToString());
                            }
                        }
                    }
                }
                catch { }
                if (printstatusreport != null)
                    printstatusreport.SetPrepareStatus();
            }
        }