Beispiel #1
0
        static public bool CloneAttributeList(IAttributeListContainer From, IAttributeListContainer To, string ListName, bool Initialize)
        {
            IAttributeList toAdd = null;

            if (From != null)
            {
                toAdd = From.GetList(ListName);
                if (toAdd != null)
                {
                    toAdd = toAdd.Clone();
                }
            }
            if (toAdd == null)
            {
                switch (ListName)
                {
                case "ColorList":
                    toAdd = new ColorList();
                    break;

                case "LayerList":
                    toAdd = new LayerList();
                    break;

                case "HatchStyleList":
                    toAdd = new HatchStyleList();
                    break;

                case "DimensionStyleList":
                    toAdd = new DimensionStyleList();
                    break;

                case "LineWidthList":
                    toAdd = new LineWidthList();
                    break;

                case "LinePatternList":
                    toAdd = new LinePatternList();
                    break;

                case "StyleList":
                    toAdd = new StyleList();
                    break;

                default:
                    return(false);
                }
                if (Initialize)
                {
                    toAdd.Initialize();
                }
            }
            To.Add(ListName, toAdd);
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a default LinePatternList.
        /// </summary>
        /// <returns></returns>
        public static LinePatternList GetDefault()
        {
            LinePatternList res = new LinePatternList();
            string          defaultLinePatternList = StringTable.GetString("LinePatternList.Default");

            // z.B.: "|durchgezogen|gestrichelt: 2.0 2.0|strichpunktiert: 4.0 2.0 0.0 2.0|gepunktet: 0.0 2.0"
            string[] split = defaultLinePatternList.Split(new char[] { defaultLinePatternList[0] });
            foreach (string substr in split)
            {
                if (substr.Length > 0)
                {
                    string[] pos = substr.Split(':'); // halt fest am : splitten
                    if (pos.Length == 1)              // das ist durchgezogen
                    {
                        LinePattern lw = new LinePattern();
                        lw.Name = pos[0];
                        try
                        {
                            res.Add(lw);
                        }
                        catch (NameAlreadyExistsException) { } // macht auch nix
                    }
                    else if (pos.Length == 2) // es müssen genau zwei sein
                    {
                        LinePattern lw = new LinePattern();
                        lw.Name = pos[0];
                        string[]  dbls = pos[1].Split(null); // Whitespace
                        ArrayList a    = new ArrayList();
                        for (int i = 0; i < dbls.Length; ++i)
                        {
                            try
                            {
                                double d = double.Parse(dbls[i], NumberFormatInfo.InvariantInfo);
                                a.Add(d);
                            }
                            catch (FormatException) { } // dann halt nicht zufügen
                        }
                        if (a.Count % 2 != 0)
                        {
                            a.RemoveAt(a.Count - 1);                   // ggf letztes wegmachen
                        }
                        lw.Pattern = (double[])a.ToArray(typeof(double));
                        try
                        {
                            res.Add(lw);
                        }
                        catch (NameAlreadyExistsException) { } // macht auch nix
                    }
                }
            }
            return(res);
        }
Beispiel #3
0
 internal override void Update(bool AddMissingToList)
 {
     if (Parent != null && Parent.Owner != null)
     {
         ColorList cl = Parent.Owner.ColorList;
         if (cl != null && colorDef != null)
         {
             ColorDef cd = cl.Find(colorDef.Name);
             if (cd != null)
             {
                 colorDef = cd;
             }
             else if (AddMissingToList)
             {
                 cl.Add(colorDef);
             }
         }
         LineWidthList ll = Parent.Owner.LineWidthList;
         if (ll != null && lineWidth != null)
         {
             LineWidth lw = ll.Find(lineWidth.Name);
             if (lw != null)
             {
                 lineWidth = lw;
             }
             else if (AddMissingToList)
             {
                 ll.Add(lineWidth);
             }
         }
         LinePatternList pl = Parent.Owner.LinePatternList;
         if (pl != null && linePattern != null)
         {
             LinePattern lw = pl.Find(linePattern.Name);
             if (lw != null)
             {
                 linePattern = lw;
             }
             else if (AddMissingToList)
             {
                 pl.Add(linePattern);
             }
         }
     }
 }
Beispiel #4
0
        /// <summary>
        /// Returns a copy of this LinePatternList. The entries are cloned so the copy is independant.
        /// </summary>
        /// <returns></returns>
        public LinePatternList Clone()
        {
            LinePatternList res = new LinePatternList();

            for (int i = 0; i < entries.Count; ++i)
            {
                res.Add((entries[i] as LinePattern).Clone());
            }
            if (current != null)
            {
                res.current = res.Find(current.Name);
            }
            else
            {
                res.current = null;
            }
            return(res);
        }