import typing
from SIMULTAN.Data import SimNamedObject_1, ISimManagedCollection, SimId, GeometricReference, SimManagedCollection_1, IReferenceLocation
from SIMULTAN.Data.SimMath import SimColor, SimPoint
from System import Guid, MulticastDelegate, IAsyncResult, AsyncCallback, ValueTuple_2, DateTime, IDisposable
from System.Reflection import MethodInfo
from System.Collections.ObjectModel import ObservableCollection_1
from System.ComponentModel import INotifyPropertyChanged
from SIMULTAN.Data.Components import SimComponentInstance, SimComponent
from System.Collections.Generic import Dictionary_2, List_1, IEnumerable_1
from SIMULTAN.Projects import ProjectData

class BaseSimNetworkElement(SimNamedObject_1[ISimManagedCollection], ISimNetworkElement):
    def __init__(self) -> None: ...
    @property
    def Color(self) -> SimColor: ...
    @Color.setter
    def Color(self, value: SimColor) -> SimColor: ...
    @property
    def Description(self) -> str: ...
    @Description.setter
    def Description(self, value: str) -> str: ...
    @property
    def Factory(self) -> ISimManagedCollection: ...
    @Factory.setter
    def Factory(self, value: ISimManagedCollection) -> ISimManagedCollection: ...
    @property
    def GlobalID(self) -> Guid: ...
    @property
    def Height(self) -> float: ...
    @Height.setter
    def Height(self, value: float) -> float: ...
    @property
    def Id(self) -> SimId: ...
    @Id.setter
    def Id(self, value: SimId) -> SimId: ...
    @property
    def IsConnected(self) -> bool: ...
    @property
    def LocalID(self) -> int: ...
    @property
    def Name(self) -> str: ...
    @Name.setter
    def Name(self, value: str) -> str: ...
    @property
    def ParentNetwork(self) -> SimNetwork: ...
    @ParentNetwork.setter
    def ParentNetwork(self, value: SimNetwork) -> SimNetwork: ...
    @property
    def Ports(self) -> SimNetworkPort.SimNetworkPortCollection: ...
    @Ports.setter
    def Ports(self, value: SimNetworkPort.SimNetworkPortCollection) -> SimNetworkPort.SimNetworkPortCollection: ...
    @property
    def Position(self) -> SimPoint: ...
    @Position.setter
    def Position(self, value: SimPoint) -> SimPoint: ...
    @property
    def RepresentationReference(self) -> GeometricReference: ...
    @RepresentationReference.setter
    def RepresentationReference(self, value: GeometricReference) -> GeometricReference: ...
    @property
    def Width(self) -> float: ...
    @Width.setter
    def Width(self, value: float) -> float: ...
    def NotifyIsDeleted(self) -> None: ...
    def OnIsBeingDeleted(self) -> None: ...

    class IsBeingDeletedEventHandler(MulticastDelegate):
        def __init__(self, object: typing.Any, method: int) -> None: ...
        @property
        def Method(self) -> MethodInfo: ...
        @property
        def Target(self) -> typing.Any: ...
        def BeginInvoke(self, sender: typing.Any, callback: AsyncCallback, object: typing.Any) -> IAsyncResult: ...
        def EndInvoke(self, result: IAsyncResult) -> None: ...
        def Invoke(self, sender: typing.Any) -> None: ...


    class IsDeletedEventHandler(MulticastDelegate):
        def __init__(self, object: typing.Any, method: int) -> None: ...
        @property
        def Method(self) -> MethodInfo: ...
        @property
        def Target(self) -> typing.Any: ...
        def BeginInvoke(self, sender: typing.Any, callback: AsyncCallback, object: typing.Any) -> IAsyncResult: ...
        def EndInvoke(self, result: IAsyncResult) -> None: ...
        def Invoke(self, sender: typing.Any) -> None: ...


    class SimNetworkElementCollection(ObservableCollection_1[BaseSimNetworkElement]):
        def __init__(self, parentNetwork: SimNetwork) -> None: ...
        @property
        def Count(self) -> int: ...
        @property
        def Item(self) -> BaseSimNetworkElement: ...
        @Item.setter
        def Item(self, value: BaseSimNetworkElement) -> BaseSimNetworkElement: ...



class IElementWithComponent(INotifyPropertyChanged, typing.Protocol):
    @property
    def ComponentInstance(self) -> SimComponentInstance: ...
    @ComponentInstance.setter
    def ComponentInstance(self, value: SimComponentInstance) -> SimComponentInstance: ...
    @property
    def Id(self) -> SimId: ...
    @property
    def ParentNetwork(self) -> SimNetwork: ...


class INetwork(typing.Protocol):
    @property
    def HasParent(self) -> bool: ...


class ISimNetworkElement(typing.Protocol):
    pass


class PortType(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    Input : PortType # 0
    Output : PortType # 1


class SimNetwork(BaseSimNetworkElement, INetwork):
    @typing.overload
    def __init__(self, name: str) -> None: ...
    @typing.overload
    def __init__(self, name: str, position: SimPoint) -> None: ...
    @property
    def Color(self) -> SimColor: ...
    @Color.setter
    def Color(self, value: SimColor) -> SimColor: ...
    @property
    def ContainedConnectors(self) -> SimNetworkConnector.SimNetworkConnectorCollection: ...
    @property
    def ContainedElements(self) -> BaseSimNetworkElement.SimNetworkElementCollection: ...
    @property
    def Description(self) -> str: ...
    @Description.setter
    def Description(self, value: str) -> str: ...
    @property
    def Factory(self) -> ISimManagedCollection: ...
    @Factory.setter
    def Factory(self, value: ISimManagedCollection) -> ISimManagedCollection: ...
    @property
    def GlobalID(self) -> Guid: ...
    @property
    def HasParent(self) -> bool: ...
    @property
    def Height(self) -> float: ...
    @Height.setter
    def Height(self, value: float) -> float: ...
    @property
    def Id(self) -> SimId: ...
    @Id.setter
    def Id(self, value: SimId) -> SimId: ...
    @property
    def IndexOfGeometricRepFile(self) -> int: ...
    @IndexOfGeometricRepFile.setter
    def IndexOfGeometricRepFile(self, value: int) -> int: ...
    @property
    def IsConnected(self) -> bool: ...
    @property
    def LocalID(self) -> int: ...
    @property
    def Name(self) -> str: ...
    @Name.setter
    def Name(self, value: str) -> str: ...
    @property
    def ParentNetwork(self) -> SimNetwork: ...
    @ParentNetwork.setter
    def ParentNetwork(self, value: SimNetwork) -> SimNetwork: ...
    @property
    def Ports(self) -> SimNetworkPort.SimNetworkPortCollection: ...
    @Ports.setter
    def Ports(self, value: SimNetworkPort.SimNetworkPortCollection) -> SimNetworkPort.SimNetworkPortCollection: ...
    @property
    def Position(self) -> SimPoint: ...
    @Position.setter
    def Position(self, value: SimPoint) -> SimPoint: ...
    @property
    def RepresentationReference(self) -> GeometricReference: ...
    @RepresentationReference.setter
    def RepresentationReference(self, value: GeometricReference) -> GeometricReference: ...
    @property
    def Size(self) -> float: ...
    @Size.setter
    def Size(self, value: float) -> float: ...
    @property
    def Width(self) -> float: ...
    @Width.setter
    def Width(self, value: float) -> float: ...
    def Clone(self, name: str, factory: SimNetwork.SimNetworkCollection, parentNetwork: SimNetwork, portPairs: Dictionary_2[SimId, SimId]) -> ValueTuple_2[SimNetwork, Dictionary_2[SimId, SimId]]: ...
    def ConvertBlockToSubnetwork(self, block: SimNetworkBlock) -> SimNetwork: ...
    def GetAllBlocks(self) -> List_1[SimNetworkBlock]: ...
    def GetAllPorts(self) -> List_1[SimNetworkPort]: ...

    class AssociationChangedEventHandler(MulticastDelegate):
        def __init__(self, object: typing.Any, method: int) -> None: ...
        @property
        def Method(self) -> MethodInfo: ...
        @property
        def Target(self) -> typing.Any: ...
        def BeginInvoke(self, sender: typing.Any, elements: IEnumerable_1[BaseSimNetworkElement], callback: AsyncCallback, object: typing.Any) -> IAsyncResult: ...
        def EndInvoke(self, result: IAsyncResult) -> None: ...
        def Invoke(self, sender: typing.Any, elements: IEnumerable_1[BaseSimNetworkElement]) -> None: ...


    class SimNetworkCollection(SimManagedCollection_1[SimNetwork]):
        def __init__(self, owner: ProjectData) -> None: ...
        @property
        def CalledFromLocation(self) -> IReferenceLocation: ...
        @property
        def Count(self) -> int: ...
        @property
        def HasChanges(self) -> bool: ...
        @property
        def IsLoading(self) -> bool: ...
        @IsLoading.setter
        def IsLoading(self, value: bool) -> bool: ...
        @property
        def Item(self) -> SimNetwork: ...
        @Item.setter
        def Item(self, value: SimNetwork) -> SimNetwork: ...
        @property
        def LastChange(self) -> DateTime: ...
        @property
        def ProjectData(self) -> ProjectData: ...
        def DisconnectAllInstances(self, resource_id: int) -> None: ...
        def EndLoading(self) -> None: ...
        def GetElementsWithComponents(self) -> List_1[IElementWithComponent]: ...
        def RemoveItemSoft(self, item: SimNetwork) -> None: ...
        def StartLoading(self) -> None: ...



class SimNetworkBlock(BaseSimNetworkElement, IElementWithComponent):
    @typing.overload
    def __init__(self, name: str, position: SimPoint) -> None: ...
    @typing.overload
    def __init__(self, name: str, position: SimPoint, id: SimId, ports: IEnumerable_1[SimNetworkPort], color: SimColor) -> None: ...
    @property
    def Color(self) -> SimColor: ...
    @Color.setter
    def Color(self, value: SimColor) -> SimColor: ...
    @property
    def ComponentInstance(self) -> SimComponentInstance: ...
    @ComponentInstance.setter
    def ComponentInstance(self, value: SimComponentInstance) -> SimComponentInstance: ...
    @property
    def Description(self) -> str: ...
    @Description.setter
    def Description(self, value: str) -> str: ...
    @property
    def Factory(self) -> ISimManagedCollection: ...
    @Factory.setter
    def Factory(self, value: ISimManagedCollection) -> ISimManagedCollection: ...
    @property
    def GlobalID(self) -> Guid: ...
    @property
    def Height(self) -> float: ...
    @Height.setter
    def Height(self, value: float) -> float: ...
    @property
    def Id(self) -> SimId: ...
    @Id.setter
    def Id(self, value: SimId) -> SimId: ...
    @property
    def IsConnected(self) -> bool: ...
    @property
    def IsStatic(self) -> bool: ...
    @property
    def LocalID(self) -> int: ...
    @property
    def Name(self) -> str: ...
    @Name.setter
    def Name(self, value: str) -> str: ...
    @property
    def ParentNetwork(self) -> SimNetwork: ...
    @ParentNetwork.setter
    def ParentNetwork(self, value: SimNetwork) -> SimNetwork: ...
    @property
    def Ports(self) -> SimNetworkPort.SimNetworkPortCollection: ...
    @Ports.setter
    def Ports(self, value: SimNetworkPort.SimNetworkPortCollection) -> SimNetworkPort.SimNetworkPortCollection: ...
    @property
    def Position(self) -> SimPoint: ...
    @Position.setter
    def Position(self, value: SimPoint) -> SimPoint: ...
    @property
    def RepresentationReference(self) -> GeometricReference: ...
    @RepresentationReference.setter
    def RepresentationReference(self, value: GeometricReference) -> GeometricReference: ...
    @property
    def Width(self) -> float: ...
    @Width.setter
    def Width(self, value: float) -> float: ...
    def AddRelativPositionToPortComp(self, portComponent: SimComponent, port: SimNetworkPort) -> None: ...
    def AssignComponent(self, component: SimComponent, syncBlockToComp: bool) -> None: ...
    def AttachEvents(self) -> None: ...
    def Clone(self, parent: SimNetwork) -> ValueTuple_2[SimNetworkBlock, Dictionary_2[SimId, SimId]]: ...
    def ConvertToStatic(self) -> None: ...
    def RemoveComponentInstance(self, sendAssociatedEvent: bool = ...) -> None: ...


class SimNetworkConnector(SimNamedObject_1[ISimManagedCollection], ISimNetworkElement):
    def __init__(self, port1: SimNetworkPort, port2: SimNetworkPort) -> None: ...
    @property
    def Color(self) -> SimColor: ...
    @Color.setter
    def Color(self, value: SimColor) -> SimColor: ...
    @property
    def Description(self) -> str: ...
    @Description.setter
    def Description(self, value: str) -> str: ...
    @property
    def Factory(self) -> ISimManagedCollection: ...
    @Factory.setter
    def Factory(self, value: ISimManagedCollection) -> ISimManagedCollection: ...
    @property
    def GlobalID(self) -> Guid: ...
    @property
    def Id(self) -> SimId: ...
    @Id.setter
    def Id(self, value: SimId) -> SimId: ...
    @property
    def LocalID(self) -> int: ...
    @property
    def Name(self) -> str: ...
    @Name.setter
    def Name(self, value: str) -> str: ...
    @property
    def ParentNetwork(self) -> SimNetwork: ...
    @ParentNetwork.setter
    def ParentNetwork(self, value: SimNetwork) -> SimNetwork: ...
    @property
    def Points(self) -> ObservableCollection_1[SimPoint]: ...
    @Points.setter
    def Points(self, value: ObservableCollection_1[SimPoint]) -> ObservableCollection_1[SimPoint]: ...
    @property
    def RepresentationReference(self) -> GeometricReference: ...
    @RepresentationReference.setter
    def RepresentationReference(self, value: GeometricReference) -> GeometricReference: ...
    @property
    def Source(self) -> SimNetworkPort: ...
    @Source.setter
    def Source(self, value: SimNetworkPort) -> SimNetworkPort: ...
    @property
    def Target(self) -> SimNetworkPort: ...
    @Target.setter
    def Target(self, value: SimNetworkPort) -> SimNetworkPort: ...

    class SimNetworkConnectorCollection(ObservableCollection_1[SimNetworkConnector]):
        def __init__(self, parentNetwork: SimNetwork) -> None: ...
        @property
        def Count(self) -> int: ...
        @property
        def Item(self) -> SimNetworkConnector: ...
        @Item.setter
        def Item(self, value: SimNetworkConnector) -> SimNetworkConnector: ...



class SimNetworkPort(SimNamedObject_1[ISimManagedCollection], IElementWithComponent, IDisposable, ISimNetworkElement):
    @typing.overload
    def __init__(self, basePort: SimNetworkPort) -> None: ...
    @typing.overload
    def __init__(self, portType: PortType, name: str = ..., position: SimPoint = ...) -> None: ...
    @property
    def Color(self) -> SimColor: ...
    @Color.setter
    def Color(self, value: SimColor) -> SimColor: ...
    @property
    def ComponentInstance(self) -> SimComponentInstance: ...
    @ComponentInstance.setter
    def ComponentInstance(self, value: SimComponentInstance) -> SimComponentInstance: ...
    @property
    def ConnectedPorts(self) -> List_1[SimNetworkPort]: ...
    @property
    def Connectors(self) -> List_1[SimNetworkConnector]: ...
    @property
    def Description(self) -> str: ...
    @Description.setter
    def Description(self, value: str) -> str: ...
    @property
    def Factory(self) -> ISimManagedCollection: ...
    @Factory.setter
    def Factory(self, value: ISimManagedCollection) -> ISimManagedCollection: ...
    @property
    def GlobalID(self) -> Guid: ...
    @property
    def Id(self) -> SimId: ...
    @Id.setter
    def Id(self, value: SimId) -> SimId: ...
    @property
    def IsConnected(self) -> bool: ...
    @property
    def LocalID(self) -> int: ...
    @property
    def Name(self) -> str: ...
    @Name.setter
    def Name(self, value: str) -> str: ...
    @property
    def ParentNetwork(self) -> SimNetwork: ...
    @property
    def ParentNetworkElement(self) -> BaseSimNetworkElement: ...
    @ParentNetworkElement.setter
    def ParentNetworkElement(self, value: BaseSimNetworkElement) -> BaseSimNetworkElement: ...
    @property
    def PortType(self) -> PortType: ...
    @PortType.setter
    def PortType(self, value: PortType) -> PortType: ...
    @property
    def Position(self) -> SimPoint: ...
    @Position.setter
    def Position(self, value: SimPoint) -> SimPoint: ...
    @property
    def RepresentationReference(self) -> GeometricReference: ...
    @RepresentationReference.setter
    def RepresentationReference(self, value: GeometricReference) -> GeometricReference: ...
    def ConnectTo(self, port: SimNetworkPort) -> None: ...
    def Dispose(self) -> None: ...
    def RemoveConnections(self) -> None: ...

    class SimNetworkPortCollection(ObservableCollection_1[SimNetworkPort]):
        def __init__(self, parentElement: BaseSimNetworkElement) -> None: ...
        @property
        def Count(self) -> int: ...
        @property
        def Item(self) -> SimNetworkPort: ...
        @Item.setter
        def Item(self, value: SimNetworkPort) -> SimNetworkPort: ...


