Exemplo n.º 1
0
        public void ProcessProperty(Property property)
        {
            property.Name  = property.Name.Trim();
            property.Value = property.Value.Trim();

            if (property.Name == "SZ")
            {
                Int32.TryParse(property.Value, out BoardSize);
            }
            else
            {
                if (!ConvertToSGFCoords && !ConvertToGoCoords)
                {
                    return;
                }

                SGFPropertyInfo lSGFPropertyInfo = SGFInfo.GetSGFPropertyInfo(property.Name);

                if (lSGFPropertyInfo == null)
                {
                    return;
                }

                if ((lSGFPropertyInfo.PropertyValueType != SGFPropertyValueType.Stone) &&
                    (lSGFPropertyInfo.PropertyValueType != SGFPropertyValueType.Point) &&
                    (lSGFPropertyInfo.PropertyValueType != SGFPropertyValueType.Move))
                {
                    return;
                }

                string lValue  = property.Value;
                string lValue1 = lValue;
                string lValue2 = string.Empty;

                int lPos = lValue.IndexOf(':');
                if (lPos > 0)
                {
                    lValue1 = lValue.Substring(0, lPos - 1);
                    lValue2 = lValue.Substring(lPos + 1);
                }
                else if (lPos == 0)
                {
                    lValue1 = string.Empty;
                    lValue2 = lValue1.Substring(1);
                }

                Coords lCoord = new Coords(lValue1, BoardSize);

                if (ConvertToSGFCoords)
                {
                    property.Value = lCoord.ToSGFCoords(BoardSize);
                }
                else
                if (ConvertToGoCoords)
                {
                    property.Value = lCoord.ToGoCoords();
                }

                if (lValue2 != string.Empty)
                {
                    property.Value = property.Value + ":" + lValue2;
                }

                if (lSGFPropertyInfo.List)
                {
                    for (int i = 0; i < property.AdditionalValues.Count; i++)
                    {
                        string lAddtValue = property.AdditionalValues[i];

                        lCoord = new Coords(lAddtValue, BoardSize);

                        if (ConvertToSGFCoords)
                        {
                            lAddtValue = lCoord.ToSGFCoords(BoardSize);
                        }
                        else
                        if (ConvertToGoCoords)
                        {
                            lAddtValue = lCoord.ToGoCoords();
                        }

                        property.AdditionalValues[i] = lAddtValue;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void ProcessProperty(Property property)
        {
            property.Name = property.Name.Trim();
            property.Value = property.Value.Trim();

            if (property.Name == "SZ")
            {
                Int32.TryParse(property.Value, out BoardSize);
            }
            else
            {
                if (!ConvertToSGFCoords && !ConvertToGoCoords)
                    return;

                SGFPropertyInfo lSGFPropertyInfo = SGFInfo.GetSGFPropertyInfo(property.Name);

                if (lSGFPropertyInfo == null)
                    return;

                if ((lSGFPropertyInfo.PropertyValueType != SGFPropertyValueType.Stone) &&
                    (lSGFPropertyInfo.PropertyValueType != SGFPropertyValueType.Point) &&
                    (lSGFPropertyInfo.PropertyValueType != SGFPropertyValueType.Move))
                    return;

                string lValue = property.Value;
                string lValue1 = lValue;
                string lValue2 = string.Empty;

                int lPos = lValue.IndexOf(':');
                if (lPos > 0)
                {
                    lValue1 = lValue.Substring(0, lPos - 1);
                    lValue2 = lValue.Substring(lPos + 1);
                }
                else if (lPos == 0)
                {
                    lValue1 = string.Empty;
                    lValue2 = lValue1.Substring(1);
                }

                Coords lCoord = new Coords(lValue1, BoardSize);

                if (ConvertToSGFCoords)
                    property.Value = lCoord.ToSGFCoords(BoardSize);
                else
                    if (ConvertToGoCoords)
                        property.Value = lCoord.ToGoCoords();

                if (lValue2 != string.Empty)
                    property.Value = property.Value + ":" + lValue2;

                if (lSGFPropertyInfo.List)
                {
                    for (int i = 0; i < property.AdditionalValues.Count; i++)
                    {
                        string lAddtValue = property.AdditionalValues[i];

                        lCoord = new Coords(lAddtValue, BoardSize);

                        if (ConvertToSGFCoords)
                            lAddtValue = lCoord.ToSGFCoords(BoardSize);
                        else
                            if (ConvertToGoCoords)
                                lAddtValue = lCoord.ToGoCoords();

                        property.AdditionalValues[i] = lAddtValue;
                    }
                }

            }
        }