internal static void LoadSkin(string skinPath, PNSkinDetails skd) { try { //open skin file as regular zip archive using (Package package = Package.Open(skinPath, FileMode.Open, FileAccess.Read)) { //build parameters file URI Uri uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("data.xml", UriKind.Relative)); //get parameters file PackagePart documentPart = package.GetPart(uriTarget); //read parameters file with XmlReader var xrs = new XmlReaderSettings { IgnoreWhitespace = true }; using (XmlReader xr = XmlReader.Create(documentPart.GetStream(), xrs)) { var arr = new string[] { }; //load parameters file into XDocument var xdoc = XDocument.Load(xr); //get mask color var xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("mask_color"); if (element != null) { arr = element.Value.Split((',')); } } skd.MaskColor = Color.FromArgb(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant)); //get delete/hide position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("delete_hide"); if (element1 != null) { arr = element1.Value.Split((',')); } } } skd.PositionDelHide = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); //get marks position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("marks"); if (element1 != null) { arr = element1.Value.Split((',')); skd.PositionMarks = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); } } } //get toolbar position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("toolbar"); if (element1 != null) { arr = element1.Value.Split((',')); skd.PositionToolbar = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); } } } //get edit box position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("edit_box"); if (element1 != null) { arr = element1.Value.Split((',')); skd.PositionEdit = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); } } } //get tooltip position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("tooltip"); if (element1 != null) { arr = element1.Value.Split((',')); skd.PositionTooltip = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); } } } //get skin info xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("skin_info"); if (element != null) { skd.SkinInfo = element.Value; } } //get possible vertical toolbar xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("vertical_toolbar"); if (element != null) { skd.VerticalToolbar = bool.Parse(element.Value); } } //get marks count xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("marks_count"); if (element1 != null) { skd.MarksCount = int.Parse(element1.Value, PNStatic.CultureInvariant); } } } } //build body image URI uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("body.png", UriKind.Relative)); //extract body image PackagePart resourcePart = package.GetPart(uriTarget); //save body image skd.BitmapSkin = PNStatic.MakeTransparentBitmap( Image.FromStream(resourcePart.GetStream()), skd.MaskColor); //build pattern image uri uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("pattern.png", UriKind.Relative)); //extract pattern image resourcePart = package.GetPart(uriTarget); //save pattern image skd.BitmapPattern = PNStatic.MakeTransparentBitmap(Image.FromStream(resourcePart.GetStream()), skd.MaskColor); //build inactive pattern image uri uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("inactivepattern.png", UriKind.Relative)); if (package.PartExists(uriTarget)) { //extract inactive pattern image resourcePart = package.GetPart(uriTarget); //save inactive pattern image skd.BitmapInactivePattern = PNStatic.MakeTransparentBitmap(Image.FromStream(resourcePart.GetStream()), skd.MaskColor); } else { skd.BitmapInactivePattern = null; } //build delete/hide image URI uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("dh.png", UriKind.Relative)); //extract delete/hide image resourcePart = package.GetPart(uriTarget); //save delete/hide image skd.BitmapDelHide = PNStatic.MakeTransparentBitmap(Image.FromStream(resourcePart.GetStream()), skd.MaskColor); //build marks image URI uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("marks.png", UriKind.Relative)); //extract marks image resourcePart = package.GetPart(uriTarget); //save marks image skd.BitmapMarks = PNStatic.MakeTransparentBitmap( Image.FromStream(resourcePart.GetStream()), skd.MaskColor); //build toolbar image URI uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("tbr.png", UriKind.Relative)); //extract toolbar image resourcePart = package.GetPart(uriTarget); //save toolbar image skd.BitmapCommands = PNStatic.MakeTransparentBitmap(Image.FromStream(resourcePart.GetStream()), skd.MaskColor); } } catch (Exception ex) { PNStatic.LogException(ex); } }