コード例 #1
0
        /**
         * @name populateLookup
         *
         * @desc
         *
         * @param xml - IN -
         * @return None
         */
        private void populateLookup(XDocument xml)//XDocument xml
        {
            IEnumerable <XElement> elements = null;


            if (xml.Element("SINGLEPOINTMAPPINGS").HasElements) //"SINGLEPOINTMAPPINGS"
            {
                elements = xml.Elements();

                IEnumerator <XElement> itr = null;// = xml.DescendantNodes().GetEnumerator();
                //XElement unitConstants = XElement.Load(ofd1.FileName, LoadOptions.None);
                itr = elements.GetEnumerator();


                XElement child = null;
                itr.MoveNext();
                child = itr.Current;//SINGLEPOINTMAPPINGS
                if (child.HasElements)
                {
                    elements = child.Elements();
                    itr      = elements.GetEnumerator();//SYMBOLS
                    while (itr.MoveNext())
                    {
                        child = itr.Current;                                                                                      /*SymbolDef .XNodeToSymbolDef*/
                        SinglePointLookupInfo /*SymbolDef*/ temp = SinglePointLookupInfo.XNodeToSinglePointFontLookupInfo(child); // SPSymbolDef temp = SPSymbolDef.XNodeToSPSymbolDef(child);
                        if ((temp != null) && _SPLookup.ContainsKey(temp.getBasicSymbolID()) == false)                            //temp will be null if node is an XCOMMENT
                        {
                            _SPLookup[temp.getBasicSymbolID()] = temp;
                        }
                    } //end while
                }
            }         //end if
        }
コード例 #2
0
        /**
         * @name getCharCodeFromSymbol
         *
         * @desc
         *
         * @param symbolCode - IN -
         * @return
         */
        public int getCharCodeFromSymbol(String symbolCode)
        {
            String basic = SymbolUtilities.getBasicSymbolID(symbolCode);
            SinglePointLookupInfo spli = _SPLookup[basic]; // _dictionary

            if (spli != null)
            {
                if (SymbolUtilities.isWeather(symbolCode) == false)
                {
                    return(spli.getMappingP());
                }
                else
                {
                    if (symbolCode.Substring(3, 1) == "A")
                    {
                        return(spli.getMappingA());
                    }
                    else
                    {
                        return(spli.getMappingP());
                    }
                }
            }
            else
            {
                return(-1);
            }
        }
コード例 #3
0
        /**
         *
         * return The newly cloned SPSymbolDef
         */
        //@Override

        public SinglePointLookupInfo clone()
        {
            SinglePointLookupInfo defReturn;

            defReturn = new SinglePointLookupInfo(_SymbolID, _Description,
                                                  getMappingP().ToString(),
                                                  getMappingA().ToString(),
                                                  getWidth().ToString(),
                                                  getHeight().ToString());
            return(defReturn);
        }
コード例 #4
0
        public int getCharCodeFromFillID(String symbolCode)
        {
            SinglePointLookupInfo spli = _SPLookup[symbolCode]; //_dictionary

            if (spli != null)
            {
                return(spli.getMappingP());
            }
            else
            {
                return(-1);
            }
        }
コード例 #5
0
        public static Rectangle getSymbolBounds(String symbolID, int fontSize)
        {
            //var spsd:SPSymbolDef = SinglePointLookup.instance.getSPSymbolDef(symbolID);
            SinglePointLookupInfo spli = SinglePointLookup.getInstance().getSPLookupInfo(symbolID);

            Rectangle rect = new Rectangle(0, 0, spli.getWidth(), spli.getHeight());

            if (fontSize != 60)           //adjust boundaries ratio if font size is not at the default setting.
            {
                double ratio = fontSize / 60.0;

                rect = new Rectangle(0, 0, (int)((rect.Width * ratio) + 0.5), (int)((rect.Height * ratio) + 0.5));
            }

            return(rect);
        }
コード例 #6
0
        /**
         * @name getSPLookupInfo
         *
         * @desc Method that retrieves a reference to a SinglePointLookupInfo object from the SinglePointLookup Dictionary.
         *
         * @param strSymbolID - IN - The 15 character symbol Id.
         * @return SinglePointLookupInfo, or null if there was an error.
         */
        public SinglePointLookupInfo getSPLookupInfo(String strSymbolID)
        {
            String basic = null;
            SinglePointLookupInfo spli = null;

            try
            {
                basic = SymbolUtilities.getBasicSymbolID(strSymbolID);
                spli  = _SPLookup[basic];
                return(spli);
            }
            catch (Exception err)
            {
                Debug.WriteLine(err);
            }
            return(null);
        }
コード例 #7
0
        public static SinglePointLookupInfo XNodeToSinglePointFontLookupInfo(XNode node)
        {
            SinglePointLookupInfo spli = null;
            XElement element           = null;
            XElement subElement        = null;
            //XAttribute attribute = null;
            XNode nextNode = null;

            try
            {
                if (node is XElement)
                {
                    element = (XElement)node;

                    if (element.HasElements)
                    {
                        spli       = new SinglePointLookupInfo();
                        subElement = null;
                        if (element.FirstNode is XElement)
                        {
                            subElement = (XElement)element.FirstNode;
                        }
                        while (subElement != null)
                        {
                            if (subElement.Name == "DESCRIPTION")
                            {
                                spli._Description = subElement.FirstNode.ToString();//get element value
                                //ufli._strDescription = ufli._strDescription.Replace("&amp;", "&");
                            }
                            else if (subElement.Name.LocalName == "SYMBOLID")
                            {
                                spli._SymbolID = subElement.FirstNode.ToString();
                            }
                            else if (subElement.Name.LocalName == "MAPPINGA")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    spli._mappingA = int.Parse(subElement.FirstNode.ToString());
                                }
                            }
                            else if (subElement.Name.LocalName == "MAPPINGP")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    spli._mappingP = int.Parse(subElement.FirstNode.ToString());
                                }
                            }
                            else if (subElement.Name.LocalName == "HEIGHT")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    spli._height = int.Parse(subElement.FirstNode.ToString());
                                }
                            }
                            else if (subElement.Name.LocalName == "WIDTH")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    spli._width = int.Parse(subElement.FirstNode.ToString());
                                }
                            }

                            nextNode   = subElement.NextNode;
                            subElement = null;
                            while (subElement == null && nextNode != null)
                            {
                                if (nextNode is XElement)
                                {
                                    subElement = (XElement)nextNode;
                                }
                                else
                                {
                                    nextNode = nextNode.NextNode;
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (System.Xml.XmlException xe)
            {
                Console.WriteLine(xe.Message);
                Console.WriteLine(xe.StackTrace);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                Console.WriteLine(exc.StackTrace);
            }
            if (spli.getBasicSymbolID() != null && spli.getBasicSymbolID() != "")
            {
                return(spli);
            }
            else
            {
                return(null);
            }
        }