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;
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        //protected sAttributeLabel pAttr;

        public sGraphicLabel(sAttributeLabel attr)
            : base(attr)
        {
            pAttr = attr;
        }