示例#1
0
        public void DeleteElement(Entity entity)
        {
            if (entity == null)
            {
                return;
            }

            if (entity is ShapeBase)
            {
                DeletingEventArgs deletingEventArgs = new DeletingEventArgs();
                OnDeleting(entity, deletingEventArgs);

                if (!deletingEventArgs.Cancel)
                {
                    this.shapes.Remove(entity as ShapeBase);
                    this.Invalidate(true);
                    OnDeleted(entity, EventArgs.Empty);
                }
            }
            else if (entity is Connection)
            {
                DeletingEventArgs deletingEventArgs = new DeletingEventArgs();
                OnDeleting(entity, deletingEventArgs);

                if (!deletingEventArgs.Cancel)
                {
                    this.connections.Remove(entity as Connection);
                    this.Invalidate(true);
                    OnDeleted(entity, EventArgs.Empty);
                }
            }
        }
示例#2
0
 private void OnDeleting(object sender, DeletingEventArgs e)
 {
     OnElementDeleting?.Invoke(sender, e);
 }