Exemple #1
0
 private void reinitVars() {
     _code = null;
     _title = null;
     _type = null;
     _tooltipType = TooltipManager.TooltipType.BIOBRICK;
     _subtitle = null;
     _illustration = null;
     _customField = null;
     _customValue = null;
     _length = null;
     _reference = null;
     _energyConsumption = null;
     _explanation = null;
     _info = null;
 }
Exemple #2
0
 private void reinitVars()
 {
     _code              = null;
     _title             = null;
     _type              = null;
     _tooltipType       = TooltipManager.TooltipType.BIOBRICK;
     _subtitle          = null;
     _illustration      = null;
     _customField       = null;
     _customValue       = null;
     _length            = null;
     _reference         = null;
     _energyConsumption = null;
     _explanation       = null;
     _info              = null;
 }
Exemple #3
0
    //TODO replace "type" of type string by type enum
    public TooltipInfo(
        string code,
        string title,
        TooltipManager.TooltipType tooltipType,
        string subtitle,
        string illustration,
        string customField,
        string customValue,
        string length,
        string reference,
        string energyConsumption,
        string explanation
        )
    {
        _code              = code;
        _title             = title;
        _tooltipType       = tooltipType;
        _subtitle          = subtitle;
        _illustration      = illustration;
        _customField       = customField;
        _customValue       = customValue;
        _length            = length;
        _reference         = reference;
        _energyConsumption = energyConsumption;
        _explanation       = explanation;

        switch (tooltipType)
        {
        case TooltipManager.TooltipType.BIOBRICK:
            _type       = TooltipLoader.biobrickKey;
            _background = TooltipManager.getBioBrickBackground();
            break;

        case TooltipManager.TooltipType.DEVICE:
            _type       = TooltipLoader.deviceKey;
            _background = TooltipManager.getDeviceBackground();
            break;

        default:
            _type       = TooltipLoader.biobrickKey;
            _background = TooltipManager.getBioBrickBackground();
            break;
        }
    }
Exemple #4
0
  //TODO replace "type" of type string by type enum
  public TooltipInfo(
    string code,
    string title,
    TooltipManager.TooltipType tooltipType,
    string subtitle,
    string illustration,
    string customField,
    string customValue,
    string length,
    string reference,
    string energyConsumption,
    string explanation
    )
  {
    _code              = code;
    _title             = title;
    _tooltipType       = tooltipType;
    _subtitle          = subtitle;
    _illustration      = illustration;
    _customField       = customField;
    _customValue       = customValue;
    _length            = length;
    _reference         = reference;
    _energyConsumption = energyConsumption;
    _explanation       = explanation;

    switch(tooltipType) {
        case TooltipManager.TooltipType.BIOBRICK:
            _type = TooltipLoader.biobrickKey;
            _background = TooltipManager.getBioBrickBackground();            
            break;
        case TooltipManager.TooltipType.DEVICE:
            _type = TooltipLoader.deviceKey;
            _background = TooltipManager.getDeviceBackground();
            break;
        default:
            _type = TooltipLoader.biobrickKey;
            _background = TooltipManager.getBioBrickBackground();
            break;
    }
   }
Exemple #5
0
    public LinkedList <TooltipInfo> loadInfoFromFile(string filePath)
    {
        Logger.Log("TooltipLoader::loadInfoFromFile(" + filePath + ")", Logger.Level.DEBUG);

        LinkedList <TooltipInfo> resultInfo = new LinkedList <TooltipInfo>();

        XmlDocument xmlDoc = Tools.getXmlDocument(filePath);

        XmlNodeList infoList = xmlDoc.GetElementsByTagName(TooltipXMLTags.TOOLTIP);

        foreach (XmlNode infoNode in infoList)
        {
            reinitVars();
            //common info attributes
            try {
                _code = infoNode.Attributes[TooltipXMLTags.CODE].Value;
            }
            catch (NullReferenceException exc) {
                Logger.Log("TooltipLoader::loadInfoFromFile bad xml, missing field\n" + exc, Logger.Level.WARN);
                continue;
            }
            catch (Exception exc) {
                Logger.Log("TooltipLoader::loadInfoFromFile failed, got exc=" + exc, Logger.Level.WARN);
                continue;
            }

            if (!String.IsNullOrEmpty(_code))
            {
                foreach (XmlNode attr in infoNode)
                {
                    switch (attr.Name)
                    {
                    case TooltipXMLTags.TITLE:
                        _title = attr.InnerText;
                        break;

                    case TooltipXMLTags.TYPE:
                        _type = attr.InnerText;
                        break;

                    case TooltipXMLTags.SUBTITLE:
                        _subtitle = attr.InnerText;
                        break;

                    case TooltipXMLTags.ILLUSTRATION:
                        _illustration = attr.InnerText;
                        break;

                    case TooltipXMLTags.CUSTOMFIELD:
                        _customField = attr.InnerText;
                        break;

                    case TooltipXMLTags.CUSTOMVALUE:
                        _customValue = attr.InnerText;
                        break;

                    case TooltipXMLTags.LENGTH:
                        _length = attr.InnerText;
                        break;

                    case TooltipXMLTags.REFERENCE:
                        _reference = attr.InnerText;
                        break;

                    case TooltipXMLTags.ENERGYCONSUMPTION:
                        _energyConsumption = attr.InnerText;
                        break;

                    case TooltipXMLTags.EXPLANATION:
                        _explanation = attr.InnerText;
                        break;

                    default:
                        Logger.Log("TooltipLoader::loadInfoFromFile unknown attr " + attr.Name + " for info node", Logger.Level.WARN);
                        break;
                    }
                }
                if (!String.IsNullOrEmpty(_type))
                {
                    string root = _tooltipPrefix + _code.ToUpper().Replace(' ', '_');
                    _title             = string.IsNullOrEmpty(_title)?root + _titleSuffix:_title;
                    _subtitle          = string.IsNullOrEmpty(_subtitle)?root + _subtitleSuffix:_subtitle;
                    _customField       = string.IsNullOrEmpty(_customField)?getKeyIfExists(root + _customFieldSuffix):_customField;
                    _customValue       = string.IsNullOrEmpty(_customValue)?getKeyIfExists(root + _customValueSuffix):_customValue;
                    _length            = string.IsNullOrEmpty(_length)?root + _lengthSuffix:_length;
                    _reference         = string.IsNullOrEmpty(_reference)?root + _referenceSuffix:_reference;
                    _energyConsumption = string.IsNullOrEmpty(_energyConsumption)?getKeyIfExists(root + _energySuffix):_energyConsumption;
                    _explanation       = string.IsNullOrEmpty(_explanation)?root + _explanationSuffix:_explanation;

                    string lower = _type.ToLowerInvariant();
                    if (lower == TooltipManager.TooltipType.DEVICE.ToString().ToLowerInvariant())
                    {
                        _tooltipType = TooltipManager.TooltipType.DEVICE;
                    }
                    else if (lower == TooltipManager.TooltipType.BIOBRICK.ToString().ToLowerInvariant())
                    {
                        _tooltipType = TooltipManager.TooltipType.BIOBRICK;
                    }
                    else
                    {
                        _tooltipType = TooltipManager.TooltipType.BIOBRICK;
                    }

                    _info = new TooltipInfo(
                        _code,
                        _title,
                        _tooltipType,
                        _subtitle,
                        _illustration,
                        _customField,
                        _customValue,
                        _length,
                        _reference,
                        _energyConsumption,
                        _explanation
                        );
                }
                if (null != _info)
                {
                    resultInfo.AddLast(_info);
                }
            }
            else
            {
                Logger.Log("TooltipLoader::loadInfoFromFile Error : missing attribute code in info node", Logger.Level.WARN);
            }
        }
        return(resultInfo);
    }
Exemple #6
0
    public LinkedList<TooltipInfo> loadInfoFromFile(string filePath)
    {
        Logger.Log("TooltipLoader::loadInfoFromFile("+filePath+")", Logger.Level.DEBUG);

        LinkedList<TooltipInfo> resultInfo = new LinkedList<TooltipInfo>();

        XmlDocument xmlDoc = Tools.getXmlDocument(filePath);

        XmlNodeList infoList = xmlDoc.GetElementsByTagName(TooltipXMLTags.TOOLTIP);

        foreach (XmlNode infoNode in infoList)
        {
            reinitVars();
            //common info attributes
            try {
                _code = infoNode.Attributes[TooltipXMLTags.CODE].Value;
            }
            catch (NullReferenceException exc) {
                Logger.Log("TooltipLoader::loadInfoFromFile bad xml, missing field\n"+exc, Logger.Level.WARN);
                continue;
            }
            catch (Exception exc) {
                Logger.Log("TooltipLoader::loadInfoFromFile failed, got exc="+exc, Logger.Level.WARN);
                continue;
            }

            if (!String.IsNullOrEmpty(_code))
            {
                foreach (XmlNode attr in infoNode)
                {
                    switch (attr.Name)
                    {
                        case TooltipXMLTags.TITLE:
                            _title = attr.InnerText;
                            break;
                        case TooltipXMLTags.TYPE:
                            _type = attr.InnerText;
                            break;
                        case TooltipXMLTags.SUBTITLE:
                            _subtitle = attr.InnerText;
                            break;
                        case TooltipXMLTags.ILLUSTRATION:
                            _illustration = attr.InnerText;
                            break;
                        case TooltipXMLTags.CUSTOMFIELD:
                            _customField = attr.InnerText;
                            break;
                        case TooltipXMLTags.CUSTOMVALUE:
                            _customValue = attr.InnerText;
                            break;
                        case TooltipXMLTags.LENGTH:
                            _length = attr.InnerText;
                            break;
                        case TooltipXMLTags.REFERENCE:
                            _reference = attr.InnerText;
                            break;
                        case TooltipXMLTags.ENERGYCONSUMPTION:
                            _energyConsumption = attr.InnerText;
                            break;
                        case TooltipXMLTags.EXPLANATION:
                            _explanation = attr.InnerText;
                            break;
                        default:
                            Logger.Log("TooltipLoader::loadInfoFromFile unknown attr "+attr.Name+" for info node", Logger.Level.WARN);
                            break;
                    }
                }
                if(!String.IsNullOrEmpty(_type))
                {
            
                    string root = _tooltipPrefix+_code.ToUpper().Replace(' ','_');
                    _title = string.IsNullOrEmpty(_title)?root+_titleSuffix:_title;
                    _subtitle = string.IsNullOrEmpty(_subtitle)?root+_subtitleSuffix:_subtitle;
                    _customField = string.IsNullOrEmpty(_customField)?getKeyIfExists(root+_customFieldSuffix):_customField;
                    _customValue = string.IsNullOrEmpty(_customValue)?getKeyIfExists(root+_customValueSuffix):_customValue;
                    _length = string.IsNullOrEmpty(_length)?root+_lengthSuffix:_length;
                    _reference = string.IsNullOrEmpty(_reference)?root+_referenceSuffix:_reference;
                    _energyConsumption = string.IsNullOrEmpty(_energyConsumption)?getKeyIfExists(root+_energySuffix):_energyConsumption;
                    _explanation = string.IsNullOrEmpty(_explanation)?root+_explanationSuffix:_explanation;
                    
                    string lower = _type.ToLowerInvariant();
                    if(lower == TooltipManager.TooltipType.DEVICE.ToString().ToLowerInvariant())
                    {
                        _tooltipType = TooltipManager.TooltipType.DEVICE;
                    }
                    else if(lower == TooltipManager.TooltipType.BIOBRICK.ToString().ToLowerInvariant())
                    {
                        _tooltipType = TooltipManager.TooltipType.BIOBRICK;
                    }
                    else
                    {
                        _tooltipType = TooltipManager.TooltipType.BIOBRICK;
                    }
                    
                    _info = new TooltipInfo(
                        _code,
                        _title,
                        _tooltipType,
                        _subtitle,
                        _illustration,
                        _customField,
                        _customValue,
                        _length,
                        _reference,
                        _energyConsumption,
                        _explanation
                    );
                }
                if(null != _info)
                {
                        resultInfo.AddLast(_info);
                }
            } else {
                Logger.Log("TooltipLoader::loadInfoFromFile Error : missing attribute code in info node", Logger.Level.WARN);
            }
        }
        return resultInfo;
    }