Removing Lines dosn't seem to work.

Aug 25, 2009 at 11:14 AM

James,

Am not too sure if this is an issue or if i am doing something wrong.

If you call DiagramControl.Model.Lines.Remove(KeyValue) and then DiagramControl.Refresh() the line is not removed that you attempted to remove.

The only way i have been able to get lines to remove via code is using DiagramControl.Model.Clear() which then obviously means you have to repaint the entire diagram, which in big diagrams can take a considerable time.

I have also tried setting the line to null by using DiagramControl.Model.Lines[KeyValue] = null but this dosn't seem to have any impact either.

Any help you could give would be very much appreciated.

Cheers

Scott

Mar 5, 2010 at 11:21 AM

I have the same problem, found a solution?

Jul 8, 2010 at 2:50 PM

This can be solved by adjusting the following files (All methods are existing methods)

Elements.cs:

public override bool Remove(string key)
{
    Element elem = base[key];

    if (base.Remove(key))
    {
        OnElementRemoved(elem);
        return true;
    }
    return false;
}

 Model.cs:

public virtual Elements SelectedElements()
{
    GetSelectedElements();
    return _selectedElements;
}

public virtual Shapes SelectedShapes()
{
    GetSelectedElements();
    return _selectedShapes;
}

public virtual Lines SelectedLines()
{
    GetSelectedElements();
    return _selectedLines;
}

//Occurs when an element is removed from the elements collection
private void Element_Remove(object sender, ElementsEventArgs e)
{
    if (e.Value is Shape) ResetLines((Shape)e.Value);

    //Remove from the renderlist
    Elements.SetModifiable(true);
    Elements.Remove(e.Value);
    Elements.SetModifiable(false);

    //Raise the ElementRemovedEvent
    OnElementRemoved(e.Value);
    OnModelInvalid();
}

 

Aug 18, 2013 at 6:40 PM
I adjusted the files listed below but i still have the same problem
with this instruction

DiagramControl.Model.Shapes.Remove(KeyValue);

Thank you for giving a hand

Cheers

Jack