Exemplo n.º 1
0
        public string GetLabel(Layer _Layer, ref Shape _Shape, ref Theme _Theme, CustomLabel _CustomLabel, ref Legend _Legend)
        {
            int i;
            int j;
            string Label = "";
            //*** BugFix 06 Feb 2006 No label field selected
            string Delimiter = " ";
            int IndentSpace = 3;
            char[] Fields;
            bool Indented;

            if ((_Theme == null))
            {
                //*** Custom and Feature Layers
                if (_CustomLabel == null)
                {
                    if (_Layer.LabelMultirow == true)
                        Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                    Fields = _Layer.LabelField.Replace(",", "").ToCharArray();
                }
                else
                {
                    if (_CustomLabel.MultiRow == true)
                        Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                    Fields = _CustomLabel.LabelField.Replace(",", "").ToCharArray();
                }

                if (Array.IndexOf(Fields, "0"[0]) > -1)
                    Label = _Shape.AreaId + Delimiter;
                if (Array.IndexOf(Fields, char.Parse("1")) > -1)
                {
                    if (_Layer.LabelMultirow == true)
                    {
                        if (Label == "")
                        {
                            Label += _Shape.AreaName;
                        }
                        else
                        {
                            if (_Layer.LabelIndented == true)
                                Label += new string(' ', IndentSpace);
                            Label += _Shape.AreaName;
                        }
                    }
                    else
                    {
                        Label += _Shape.AreaName;
                    }
                }
            }
            else
            {
                //*** Base Layers
                if (_CustomLabel == null)
                {
                    if (_Legend == null)
                    {
                        if (_Layer.LabelMultirow == true)
                            Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                        Fields = _Layer.LabelField.Replace(",", "").ToCharArray();
                        Indented = _Layer.LabelIndented;
                    }
                    else
                    {
                        if (_Legend.LabelMultiRow == true)
                            Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                        Fields = _Legend.LabelField.Replace(",", "").ToCharArray();
                        Indented = _Legend.LabelIndented;
                    }
                }
                else
                {
                    if (_CustomLabel.MultiRow == true)
                        Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                    Fields = _CustomLabel.LabelField.Replace(",", "").ToCharArray();
                    Indented = _CustomLabel.Indent;
                }
                if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
                {
                    j = 0;
                    for (i = 0; i <= Fields.Length - 1; i++)
                    {
                        switch (Fields[i])
                        {
                            case '0':
                                Label += _Shape.AreaId + Delimiter;
                                j = j + 1;
                                break;
                            case '1':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).AreaName + Delimiter;
                                j = j + 1;
                                break;
                            case '2':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                //Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).DataValue + Delimiter;
                                //Textual dataValue is also displayed on Map Label, so property AreaInfo.DisplayInfo is used.
                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).DisplayInfo + Delimiter;
                                j = j + 1;
                                break;
                            case '3':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                Label += _Theme.UnitName + Delimiter;
                                j = j + 1;
                                break;
                            case '4':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                //Label += _Theme.SubgroupName(0) & Delimiter
                                //*** BugFix 21 Sep 2006 Subgroup label error
                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Subgroup + Delimiter;
                                j = j + 1;
                                break;
                            case '5':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Time + Delimiter;
                                break;
                        }
                    }
                    Label = Label.Trim(Delimiter.ToCharArray());
                }
                else
                {
                    if (this._ShowLabelWhereDataExists)
                    {
                        //- If label is not required for Areas NOT having Data,
                        // then set blank label.
                        Label = string.Empty;
                    }
                    else
                    {
                        Hashtable AreaNames = _Layer.AreaNames;
                        string AreaName;
                        if (Array.IndexOf(Fields, "0"[0]) > -1)
                            Label = _Shape.AreaId + Delimiter;
                        if (Array.IndexOf(Fields, char.Parse("1")) > -1)
                        {
                            if (AreaNames.ContainsKey(_Shape.AreaId))
                            {
                                //Get language specific AreaName from Database if it exists
                                AreaName = (string)AreaNames[_Shape.AreaId];
                            }
                            else
                            {
                                //Get Shapefile Area Name
                                AreaName = _Shape.AreaName;
                            }
                            if (_Layer.LabelMultirow == true)
                            {
                                if (Label == "")
                                {
                                    Label += AreaName;
                                }
                                else
                                {
                                    if (_Layer.LabelIndented == true)
                                        Label += new string(' ', IndentSpace);
                                    Label += AreaName;
                                }
                            }
                            else
                            {
                                Label += AreaName;
                            }
                        }
                    }
                }
            }
            return Label;
        }
Exemplo n.º 2
0
 public string GetLabel(Layer _Layer, ref Shape _Shape, ref Theme _Theme, CustomLabel _CustomLabel)
 {
     Legend _Legend = null;
     return GetLabel(_Layer, ref _Shape, ref _Theme, _CustomLabel, ref _Legend);
 }