public sGraphicImage(sAttribute attr, String image) : base(attr) { //Console.WriteLine("sGraphicImage: "); //pAttr = attr; if (image == null || image.Length == 0) { return; } try { pImage = Image.FromFile(cDataBase.getPath(image)); // Check correct type if (attr.GetType() == typeof(sAttributePixmap)) { //get size of root element (= size of a widget) sAttributePixmap element = (sAttributePixmap)attr; Size elementSize = element.pPixmap; if (elementSize != null) { //Resize image, if imageSize and element size is diffrent if (elementSize.Width != pImage.Size.Width || elementSize.Height != pImage.Height) { if (element.myNode.Attributes["pixmap"] != null || element.myNode.Attributes["pixmaps"] != null) { // ePixmap or widget element with attribute 'pixmap' (= path to image) pImage = ResizeImage(pImage, elementSize.Width, elementSize.Height); } else if (element.myNode.Attributes["render"] != null && element.myNode.Attributes["render"].Value.ToLower().Contains("picon")) { // is picon pImage = ResizeImageKeepAspectRatio(pImage, elementSize.Width, elementSize.Height); } else if (element.myNode.Attributes["render"] != null && element.myNode.Attributes["render"].Value.ToLower().Contains("eventimage")) { // is EventImage pImage = ResizeImageKeepAspectRatio(pImage, elementSize.Width, elementSize.Height); } else if (element.myNode.Attributes["path"] != null) { //widget element with attribute 'path' (= path to image) pImage = ResizeImage(pImage, elementSize.Width, elementSize.Height); } } } } } catch (FileNotFoundException) { Console.WriteLine("File not found! (" + cDataBase.getPath(image) + ")"); return; } }
public sAttributeWidget(sAttribute parent, XmlNode node) : base(parent, node) { if (node.Attributes["source"] != null) { pSource = node.Attributes["source"].Value; } if (node.Attributes["render"] != null) { pRender = node.Attributes["render"].Value; } if (pRender == null) { if (node.Attributes["pixmap"] != null || node.Attributes["pixmaps"] != null) { pRender = "Pixmap"; } else if (pName == "menu" || pName == "list" || pName.EndsWith("list")) //depreceated { pRender = "Listbox"; } else if (pName == "PositionGauge") //depreceated { pRender = "PositionGauge"; } else if (node.Attributes["pointer"] != null) { pRender = "PositionGauge"; } else { pRender = "Label"; } } if (pRender.ToLower() == "label" || pRender.ToLower() == "fixedlabel" || pRender.ToLower() == "vrunningtext" || pRender.ToLower() == "metrixreloadedscreennamelabel") { pLabel = new sAttributeLabel(parent, node); } else if (pRender.ToLower().Contains("pixmap")) { pPixmap = new sAttributePixmap(parent, node); } else if (pRender.ToLower() == "picon") { pPixmap = new sAttributePixmap(parent, node); } else if (pRender.ToLower() == "xpicon") { pPixmap = new sAttributePixmap(parent, node); } else if (pRender.ToLower().Contains("xhdpicon")) { pPixmap = new sAttributePixmap(parent, node); } else if (pRender.ToLower().Contains("eventimage")) { pPixmap = new sAttributePixmap(parent, node); } else if (pRender.ToLower() == "progress") { pProgress = new sAttributeProgress(parent, node); } else if (pRender.ToLower() == "listbox") { pListbox = new sAttributeListbox(parent, node); } else { //Any Render that use path attribute if (node.Attributes["path"] != null) { pPixmap = new sAttributePixmap(parent, node); } } if (pSource != null && pSource.Length > 0) { String text = cPreviewText.getText(parent.Name, pSource); if (text == null || text.Length == 0) { // Show text for elements with render attribute, if they have a font attribute if (myNode.Attributes["font"] != null) { if (myNode.Attributes["name"] != null) { // show name text = myNode.Attributes["name"].Value; } else if (myNode.Attributes["source"] != null) { // show source text = myNode.Attributes["source"].Value; } else { text = "widget"; } } } if (text.Length > 0) { if (pLabel != null && (pLabel.pText == null || pLabel.pText.Length == 0)) { pLabel.pPreviewText = text; } if (pListbox != null) { pListbox.pPreviewEntries = text.Split('|'); } } } if (node.HasChildNodes) { foreach (XmlNode nodeConverter in node.ChildNodes) { if (nodeConverter.Attributes != null) { String type = nodeConverter.Attributes["type"].Value; String parameter = nodeConverter.InnerText; String text = cConverter.getText(pSource, type, parameter); if (text != null) { if (pLabel != null) { if (text.Length > 0 && (pLabel.pText == null || pLabel.pText.Length <= 0)) { pLabel.pPreviewText = text; } if (text == "MAGIC#TRUE" || text == "MAGIC#FALSE") { pLabel.pPreviewText = text; } } else if (pPixmap != null) { if (text == "MAGIC#TRUE") { //pLabel.pText = ""; } else if (text == "MAGIC#FALSE") { pPixmap.pPixmap = new Size(0, 0); pPixmap.pHide = true; } } } } } cConverter.reset(); } else { if (pSource != null) { if (pSource.ToLower() == "title") { if (parent is sAttributeScreen) { if (pLabel != null) { pLabel.pPreviewText = ((sAttributeScreen)parent).pTitle; } } } } } }
//protected sAttributePixmap pAttr; public sGraphicPixmap(sAttributePixmap attr) : base(attr) { pAttr = attr; }