Beispiel #1
0
        /// <summary>
        /// Creates a default LineWidthList.
        /// </summary>
        /// <returns></returns>
        public static LineWidthList GetDefault()
        {
            LineWidthList res = new LineWidthList();
            string        defaultLineWidthList = StringTable.GetString("LineWidthList.Default");

            // z.B.: "|Standard (0.7 mm):0.7L|dünn:0.0D|0.3 mm:0.3W"
            string[] split = defaultLineWidthList.Split(new char[] { defaultLineWidthList[0] });
            foreach (string substr in split)
            {
                if (substr.Length > 0)
                {
                    string[] pos = substr.Split(':'); // halt fest am : splitten
                    if (pos.Length == 2)              // es müssen genau zwei sein
                    {
                        LineWidth lw = new LineWidth();
                        lw.Name = pos[0];
                        int    ind = pos[1].LastIndexOfAny("0123456789.".ToCharArray());
                        string widthstr;
                        if (ind > 0)
                        {
                            widthstr = pos[1].Substring(0, ind + 1);
                        }
                        else
                        {
                            widthstr = pos[1];
                        }
                        try
                        {
                            if (ind > 0 && ind < pos[1].Length - 1)
                            {
                                switch (pos[1][ind + 1])
                                {
                                default:     // ist Layout
                                case 'L': lw.Scale = LineWidth.Scaling.Layout; break;

                                case 'W': lw.Scale = LineWidth.Scaling.World; break;

                                case 'D': lw.Scale = LineWidth.Scaling.Device; break;
                                }
                            }
                            lw.Name  = pos[0];
                            lw.Width = double.Parse(widthstr, NumberFormatInfo.InvariantInfo);
                            res.Add(lw);
                        }
                        catch (FormatException) { }            // dann halt nicht zufügen
                        catch (NameAlreadyExistsException) { } // macht auch nix
                    }
                }
            }
            return(res);
        }
Beispiel #2
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 #3
0
        /// <summary>
        /// Returns a copy of this LineWidthList. The entries are cloned so the copy is independant.
        /// </summary>
        /// <returns></returns>
        public LineWidthList Clone()
        {
            LineWidthList res = new LineWidthList();

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