예제 #1
0
        // Handle Fixed logos (Free Style and cijConnect formats later)
        private void LoadLogos(XmlNode c)
        {
            Bitmap bm = null;

            foreach (XmlNode l in c.ChildNodes)
            {
                if (l is XmlWhitespace || l.Name != "Logo")
                {
                    continue;
                }
                string       layout    = GetXmlAttr(l, "Layout");
                IJPDotMatrix dotMatrix = ParseEnum <IJPDotMatrix>(GetXmlAttr(l, "DotMatrix"));
                int          location  = (int)GetXmlAttrN(l, "Location");
                string       rawData   = GetXmlAttr(l, "RawData");
                if (rawData == string.Empty)
                {
                    string folder       = GetXmlAttr(c, "Folder");
                    string fileName     = GetXmlAttr(l, "FileName");
                    string fullFileName = Path.Combine(folder, fileName + ".bmp");
                    if (File.Exists(fullFileName))
                    {
                        bm = new Bitmap(fullFileName);
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    if (!int.TryParse(GetXmlAttr(l, "Width"), out int width) ||
                        !int.TryParse(GetXmlAttr(l, "Height"), out int height))
                    {
                        GetBitmapSize(dotMatrix, out width, out height);
                    }
                    ulong[] stripes = RawDataToStripes(height, rawData);
                    bm = BuildBitMap(stripes, width, height);
                }
                if (layout == "Fixed")
                {
                    IJPFixedUserPattern upFixed = new IJPFixedUserPattern(location + 1, dotMatrix, bm);
                    ijp.SetFixedUserPattern(upFixed);
                }
                else
                {
                    IJPFreeUserPattern upFree = new IJPFreeUserPattern(location + 1, bm);
                    ijp.SetFreeUserPattern(upFree);
                }
            }
        }