Skip to content

Commit

Permalink
event
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Feb 22, 2024
1 parent 9d996f9 commit 70bbc6a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ACadSharp/OnNameChangedArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;

namespace ACadSharp
{
public class OnNameChangedArgs : EventArgs
{
/// <summary>
/// Old object name
/// </summary>
public string OldName { get; }

/// <summary>
/// New name to be assign at the object
/// </summary>
public string NewName { get; }

public OnNameChangedArgs(string oldName, string newName)
{
this.OldName = oldName;
this.NewName = newName;
}
}
}
7 changes: 7 additions & 0 deletions ACadSharp/Tables/Collections/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ protected void add(string key, T item)
this._entries.Add(key, item);
item.Owner = this;

item.OnNameChanged += this.onEntryNameChanged;

OnAdd?.Invoke(this, new CollectionChangedEventArgs(item));
}

private void onEntryNameChanged(object sender, OnNameChangedArgs e)
{
throw new NotImplementedException();
}
}
}
3 changes: 3 additions & 0 deletions ACadSharp/Tables/TableEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace ACadSharp.Tables
[DxfSubClass(DxfSubclassMarker.TableRecord, true)]
public abstract class TableEntry : CadObject, INamedCadObject
{
public event EventHandler<OnNameChangedArgs> OnNameChanged;

/// <inheritdoc/>
public override string SubclassMarker => DxfSubclassMarker.TableRecord;

Expand All @@ -23,6 +25,7 @@ public string Name
// throw new System.ArgumentNullException(nameof(value), $"Table entry [{this.GetType().FullName}] must have a name");
}

OnNameChanged?.Invoke(this, new OnNameChangedArgs(this._name, value));
this._name = value;
}
}
Expand Down

0 comments on commit 70bbc6a

Please sign in to comment.