private void OnLinePatternChanged(LinePattern selected) { LinePattern oldLinePattern = linePattern; linePattern = selected; FireDidChange("LinePattern", oldLinePattern); }
bool ICommandHandler.OnCommand(string MenuId) { switch (MenuId) { case "MenuId.LinePatternList.New": { LinePattern lw = new LinePattern(); lw.Name = GetNewName(); Add(lw); subEntries = null; propertyTreeView.Refresh(this); propertyTreeView.OpenSubEntries(this, true); propertyTreeView.StartEditLabel(SubEntries[entries.Count - 1] as IPropertyEntry); // der letzte return(true); } case "MenuId.LinePatternList.RemoveUnused": OnRemoveUnused(); return(true); case "MenuId.LinePatternList.UpdateFromProject": OnUpdateFromProject(); return(true); case "MenuId.LinePatternList.AddFromGlobal": OnAddFromGlobal(); return(true); case "MenuId.LinePatternList.MakeGlobal": OnMakeGlobal(); return(true); } return(false); }
/// <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; } }
/// <summary> /// Returns a clone of this LinePattern /// </summary> /// <returns></returns> public LinePattern Clone() { LinePattern res = new LinePattern(); res.name = name; res.pattern = (double[])pattern.Clone(); res.scale = scale; return(res); }
/// <summary> /// Returns the index of the given line pattern or -1 if not in the list /// </summary> /// <param name="lp">line pattern whos index is required</param> /// <returns>the index found or -1 if not found</returns> public int FindIndex(LinePattern lp) { for (int i = 0; i < entries.Count; ++i) { if (entries[i] == lp) { return(i); } } return(-1); }
public LinePattern CreateOrFind(string Name, params double[] pattern) { LinePattern res = Find(Name); if (res != null) { return(res); } res = new LinePattern(Name, pattern); Add(res); return(res); }
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; }
/// <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); }
/// <summary> /// Adds an LinePattern object to the list. Throws a <see cref="NameAlreadyExistsException"/> /// if there is a LinePattern with the given name in the list. This also prevents the same /// object added twice to the list. /// </summary> /// <param name="linePatternToAdd">LinePattern to Add</param> public void Add(LinePattern linePatternToAdd) { for (int i = 0; i < entries.Count; ++i) { if ((entries[i] as LinePattern).Name == linePatternToAdd.Name) { throw new NameAlreadyExistsException(this, linePatternToAdd, linePatternToAdd.Name); } } linePatternToAdd.Parent = this; entries.Add(linePatternToAdd); if (DidModifyEvent != null) { DidModifyEvent(this, null); // ist das ok? der Modelview brauchts } }
bool IAttributeList.MayChangeName(INamedAttribute attribute, string newName) { LinePattern l = attribute as LinePattern; if (l.Name == newName) { return(true); // garkeine Änderung } for (int i = 0; i < entries.Count; ++i) { if ((entries[i] as LinePattern).Name == newName) { return(false); } } return(true); }
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); } } } }
void IAttributeList.Update(IGeoObject Object2Update) { if (Object2Update is ILinePattern) { LinePattern oldLP = (Object2Update as ILinePattern).LinePattern; if (oldLP == null) { return; } LinePattern lp = Find(oldLP.Name); if (lp == null) { Add(oldLP); } else { (Object2Update as ILinePattern).LinePattern = lp; } } }
//Hilfsfunktion für Import internal LinePattern CreateOrFind(double[] pattern, LinePattern.Scaling scale) { int num = pattern.Length / 2; foreach (LinePattern lw in entries) { if (lw.PatternCount != num) { continue; } if (lw.Scale != scale) { continue; } int i = 0; for (; i < num; i++) { if (lw.GetStroke(i) != pattern[i * 2] || lw.GetGap(i) != pattern[i * 2 + 1]) { break; } } if (i == num) { return(lw); //keine Abweichung gefunden } } LinePattern res = new LinePattern(); string prefix = "LP"; for (int i = 0; i < pattern.Length; i++) { prefix = prefix + pattern[i].ToString() + ":"; } res.Name = GetNewName(prefix); res.Pattern = pattern; res.Scale = scale; Add(res); return(res); }
/// <summary> /// Removes an entry from the LinePattern list. Depending on the context and global settings /// there might be a warning if the LinePattern is beeing used by an IGeoObject belonging to the /// Project. If the LinePattern is not in the list, nothing happens. /// </summary> /// <param name="linePatternToRemove">LinePattern to remove</param> public void Remove(LinePattern linePatternToRemove) { int ind = entries.IndexOf(linePatternToRemove); if (ind >= 0) { if (owner != null) { if (!owner.RemovingItem(this, linePatternToRemove, "LinePatternList")) { return; } } entries.RemoveAt(ind); linePatternToRemove.Parent = null; } if (linePatternToRemove == current) { if (entries.Count > 0) { current = entries[0] as LinePattern; } else { current = null; } } if (propertyTreeView != null) { // d.h. es wird gerade angezeigt subEntries = null; propertyTreeView.Refresh(this); } if (DidModifyEvent != null) { DidModifyEvent(this, null); // ist das ok? der Modelview brauchts } }
/// <summary> /// Constructor required by deserialization /// </summary> /// <param name="info">SerializationInfo</param> /// <param name="context">StreamingContext</param> protected LinePatternList(SerializationInfo info, StreamingContext context) { entries = (ArrayList)info.GetValue("Entries", typeof(ArrayList)); current = (LinePattern)(info.GetValue("Current", typeof(LinePattern))); }