Пример #1
0
        private void OnColorDefChanged(ColorDef selected)
        {
            ColorDef oldColorDef = colorDef;

            colorDef = selected;
            FireDidChange("ColorDef", oldColorDef);
        }
Пример #2
0
 /// <summary>
 /// Constructor required by deserialization
 /// </summary>
 /// <param name="info">SerializationInfo</param>
 /// <param name="context">StreamingContext</param>
 protected HatchStyleLines(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     lineDistance = (double)info.GetValue("LineDistance", typeof(double));
     lineAngle    = (Angle)info.GetValue("LineAngle", typeof(Angle));
     colorDef     = ColorDef.Read("ColorDef", info, context);
     lineWidth    = LineWidth.Read("LineWidth", info, context);
     linePattern  = LinePattern.Read("LinePattern", info, context);
     try
     {
         marginOffset = (double)info.GetValue("MarginOffset", typeof(double));
     }
     catch (SerializationException)
     {
         marginOffset = 0.0;
     }
     try
     {
         number    = (int)info.GetValue("NumberOffset", typeof(int));
         offset    = (double)info.GetValue("Offset", typeof(double)); // warum ist das double?
         alternate = (bool)info.GetValue("Alternate", typeof(bool));
     }
     catch (SerializationException)
     {
         number    = 1;
         offset    = SweepAngle.ToLeft;
         alternate = false;
     }
 }
Пример #3
0
        private void Remove(ColorDef cd)
        {
            int ind = IndexOf(cd.Name);

            if (ind >= 0)
            {
                RemoveAt(ind);
            }
        }
Пример #4
0
        bool IAttributeList.MayChangeName(INamedAttribute attribute, string newName)
        {
            ColorDef cd = attribute as ColorDef;

            if (cd.Name == newName)
            {
                return(true);
            }
            return(Find(newName) == null);
        }
Пример #5
0
 public int FindIndex(ColorDef cd)
 {
     for (int i = 0; i < namedColors.Count; ++i)
     {
         if (namedColors[i] == cd)
         {
             return(i);
         }
     }
     return(-1);
 }
Пример #6
0
 internal override void Init(Project pr)
 {
     lineDistance = 1.0;
     lineAngle    = Angle.A45;
     marginOffset = 0.0;
     number       = 1;
     offset       = SweepAngle.ToLeft;
     alternate    = false;
     lineWidth    = pr.LineWidthList.Current;
     linePattern  = pr.LinePatternList.Current;
     colorDef     = pr.ColorList.Current;
 }
Пример #7
0
        public ColorDef CreateOrModify(string Name, Color Color)
        {
            ColorDef res = Find(Name);

            if (res != null)
            {
                res.Color = Color;
                return(res);
            }
            ColorDef cd = new ColorDef(Name, Color);

            cd.Source = ColorDef.ColorSource.fromName;
            Add(cd);
            return(cd);
        }
Пример #8
0
 public void Add(ColorDef cd)
 {
     if (IndexOf(cd.Name) >= 0)
     {
         throw new NameAlreadyExistsException(this, cd, cd.Name);
     }
     namedColors.Add(cd);
     cd.Parent = this;
     if (current == null)
     {
         current = namedColors[0] as ColorDef;
     }
     if (DidModifyEvent != null)
     {
         DidModifyEvent(null, null);
     }
 }
Пример #9
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);
             }
         }
     }
 }
Пример #10
0
        public ColorDef CreateOrFind(string Name, Color Color)
        {
            if (Name == null)
            {
                Name = GetNewName();
            }
            ColorDef res = Find(Name);

            if (res != null)
            {
                return(res);
            }
            ColorDef cd = new ColorDef(Name, Color);

            cd.Source = ColorDef.ColorSource.fromName;
            Add(cd);
            return(cd);
        }
Пример #11
0
 internal override void Update(bool AddMissingToList)
 {
     if (color != null && Parent != null && Parent.Owner != null)
     {
         ColorList cl = Parent.Owner.ColorList;
         if (cl != null)
         {
             ColorDef cd = cl.Find(color.Name);
             if (cd != null)
             {
                 color = cd;
             }
             else if (AddMissingToList)
             {
                 cl.Add(color);
             }
         }
     }
 }
Пример #12
0
 void IAttributeList.Update(IGeoObject Object2Update)
 {
     if (Object2Update is IColorDef)
     {
         ColorDef oldC = (Object2Update as IColorDef).ColorDef;
         if (oldC == null)
         {
             return;
         }
         ColorDef c = Find(oldC.Name);
         if (c == null)
         {
             Add(oldC);
         }
         else
         {
             (Object2Update as IColorDef).SetTopLevel(c, true);
         }
     }
 }
Пример #13
0
        /// <summary>
        /// Liefert den Index zu dem gegebenen Namen.
        /// </summary>
        /// <param name="Name">Der Name der gesuchten Farbe.</param>
        /// <returns>Index der gesuchten Farbe oder -1, wenn keine Farbe mit diesem Namen in der Tabelle existiert.</returns>
        /// <summary>
        /// Fügt eine Farbe hinzu, oder überschreibt eine bestehende, wenn der Name bereits existiert.
        /// </summary>
        /// <param name="Name">Bezeichnung der Farbe.</param>
        /// <param name="Color">RGB (oder auch ARGB) Wert der Farbe.</param>
        /// <returns>Index des neuen oder veränderten Eintrags.</returns>
        public int AddColor(string Name, Color Color)
        {
            int      ind = IndexOf(Name);
            ColorDef cd  = new ColorDef(Name, Color);

            cd.Source = ColorDef.ColorSource.fromName;
            if (ind >= 0)
            {
                namedColors[ind] = cd;
            }
            else
            {
                namedColors.Add(cd);
                ind = namedColors.Count - 1;
            }
            cd.Parent = this;
            if (DidModifyEvent != null)
            {
                DidModifyEvent(this, null);
            }
            return(ind);
        }
Пример #14
0
 /// <summary>
 /// Constructor required by deserialization
 /// </summary>
 /// <param name="info">SerializationInfo</param>
 /// <param name="context">StreamingContext</param>
 protected HatchStyleSolid(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     color = (ColorDef)info.GetValue("Color", typeof(ColorDef));
 }
Пример #15
0
 /// <summary>
 /// Constructor required by deserialization
 /// </summary>
 /// <param name="info">SerializationInfo</param>
 /// <param name="context">StreamingContext</param>
 protected ColorList(SerializationInfo info, StreamingContext context)
 {
     namedColors = (ArrayList)(info.GetValue("NamedColors", typeof(ArrayList)));
     current     = ColorDef.Read("Current", info, context);
     resourceId  = "ColorList";
 }
Пример #16
0
 public static ColorDef Read(SerializationInfo info, StreamingContext context)
 {
     return(ColorDef.Read("ColorDef", info, context));
 }
Пример #17
0
 private void OnColorDefChanged(ColorDef selected)
 {
     Color = selected;
 }