bool ICommandHandler.OnCommand(string MenuId) { switch (MenuId) { case "MenuId.LineWidthList.New": { LineWidth lw = new LineWidth(); 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.LineWidthList.RemoveUnused": OnRemoveUnused(); return(true); case "MenuId.LineWidthList.UpdateFromProject": OnUpdateFromProject(); return(true); case "MenuId.LineWidthList.AddFromGlobal": OnAddFromGlobal(); return(true); case "MenuId.LineWidthList.MakeGlobal": OnMakeGlobal(); return(true); } return(false); }
private void OnLineWidthChanged(LineWidth selected) { LineWidth oldLineWidth = lineWidth; lineWidth = selected; FireDidChange("LineWidth", oldLineWidth); }
/// <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 LineWidth /// </summary> /// <returns></returns> public LineWidth Clone() { LineWidth res = new LineWidth(); res.name = name; res.width = width; res.scale = scale; return(res); }
/// <summary> /// Returns the index of the given linewidth in this list /// </summary> /// <param name="lw">linewidth for which the index is requested</param> /// <returns>the index found or -1 if this list does not contain lw</returns> public int FindIndex(LineWidth lw) { for (int i = 0; i < entries.Count; ++i) { if (entries[i] == lw) { return(i); } } return(-1); }
public LineWidth CreateOrFind(string Name, double width) { LineWidth res = Find(Name); if (res != null) { return(res); } res = new LineWidth(Name, width); 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 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); }
/// <summary> /// Adds an LineWidth object to the list. Throws a <see cref="NameAlreadyExistsException"/> /// if there is a LineWidth with the given name in the list. This also prevents the same /// object added twice to the list. /// </summary> /// <param name="lineWidthToAdd">LineWidth to Add</param> public void Add(LineWidth lineWidthToAdd) { for (int i = 0; i < entries.Count; ++i) { if ((entries[i] as LineWidth).Name == lineWidthToAdd.Name) { throw new NameAlreadyExistsException(this, lineWidthToAdd, lineWidthToAdd.Name); } } lineWidthToAdd.Parent = this; entries.Add(lineWidthToAdd); if (DidModifyEvent != null) { DidModifyEvent(this, null); // ist das ok? der Modelview brauchts } }
bool IAttributeList.MayChangeName(INamedAttribute attribute, string newName) { LineWidth l = attribute as LineWidth; if (l.Name == newName) { return(true); // garkeine Änderung } for (int i = 0; i < entries.Count; ++i) { if ((entries[i] as LineWidth).Name == newName) { return(false); } } return(true); }
// Hilfsfunktion für import // liefert die erste LineWidth mit der angegeben Breite/Scaling oder generiert die gefordete LineWidth internal LineWidth CreateOrFind(double width, LineWidth.Scaling scale) { foreach (LineWidth lw in entries) { if (lw.Width == width && lw.Scale == scale) { return(lw); } } LineWidth res = new LineWidth(); res.Width = width; res.Scale = scale; Add(res); res.Name = scale.ToString() + width.ToString(); return(res); }
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 ILineWidth) { LineWidth oldLW = (Object2Update as ILineWidth).LineWidth; if (oldLW == null) { return; } LineWidth lw = Find(oldLW.Name); if (lw == null) { Add(oldLW); } else { (Object2Update as ILineWidth).LineWidth = lw; } } }
/// <summary> /// Removes an entry from the LineWidth list. Depending on the context and global settings /// there might be a warning if the LineWidth is beeing used by an IGeoObject belonging to the /// Project. If the LineWidth is not in the list, nothing happens. /// </summary> /// <param name="lineWidthToRemove">LineWidth to remove</param> public void Remove(LineWidth lineWidthToRemove) { int ind = entries.IndexOf(lineWidthToRemove); if (ind >= 0) { if (owner != null) { if (!owner.RemovingItem(this, lineWidthToRemove, "LineWidthList")) { return; } } entries.RemoveAt(ind); lineWidthToRemove.Parent = null; } if (lineWidthToRemove == current) { if (entries.Count > 0) { current = entries[0] as LineWidth; } 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 LineWidthList(SerializationInfo info, StreamingContext context) { entries = (ArrayList)info.GetValue("Entries", typeof(ArrayList)); current = (LineWidth)(info.GetValue("Current", typeof(LineWidth))); }