/// <summary>
        /// Deletes an element and its connections
        /// </summary>
        private void Delete()
        {
            if (SelectedObject is Connector)
            {
                RemoveConnectionByConnector(SelectedObject as Connector);
            }
            if (SelectedObject is Node)
            {
                var node = SelectedObject as Node;
                Connectors.Where(x => x.Start == node || x.End == node).ToList().ForEach(x => RemoveConnectionByConnector(x));
                Nodes.Remove(node);
            }
            if (SelectedObject is Transition)
            {
                var transition = SelectedObject as Transition;
                Connectors.Where(x => x.Start == transition || x.End == transition).ToList().ForEach(x => RemoveConnectionByConnector(x));
                Transitions.Remove(transition);
            }
            if (SelectedObject is InputLadder)
            {
                var input = SelectedObject as InputLadder;
                Connectors.Where(x => x.Start == input || x.End == input).ToList().ForEach(x => RemoveConnectionByConnector(x));
                Inputs.Remove(input);
            }
            if (SelectedObject is OutputLadder)
            {
                var output = SelectedObject as OutputLadder;
                Connectors.Where(x => x.Start == output || x.End == output).ToList().ForEach(x => RemoveConnectionByConnector(x));
                Outputs.Remove(output);
            }

            if (SelectedObject is NotInputLadder)
            {
                var notInput = SelectedObject as NotInputLadder;
                Connectors.Where(x => x.Start == notInput || x.End == notInput).ToList().ForEach(x => RemoveConnectionByConnector(x));
                NotInputs.Remove(notInput);
            }

            if (SelectedObject is NotOutputLadder)
            {
                var notOutput = SelectedObject as NotOutputLadder;
                Connectors.Where(x => x.Start == notOutput || x.End == notOutput).ToList().ForEach(x => RemoveConnectionByConnector(x));
                NotOutputs.Remove(notOutput);
            }


            if (SelectedObject is InterNode)
            {
                var interNode = SelectedObject as InterNode;
                if (Connections.First(x => InterNodes.Contains(interNode)) != null)
                {
                    RemoveConnectionByConnector(Connectors.First(x => x.Start == interNode || x.End == interNode));
                }
                else
                {
                    Connectors.Where(x => x.Start == interNode || x.End == interNode).ToList().ForEach(x => Connectors.Remove(x));
                    InterNodes.Remove(interNode);
                }
            }
        }
 /// <summary>
 /// Removes the Objects that are still in preview mode
 /// </summary>
 public void RemoveNewObjects()
 {
     Connectors.Where(x => (x.Start != null && x.Start.IsNew) || (x.End != null && x.End.IsNew)).ToList().ForEach(x => Connectors.Remove(x));
     Nodes.Where(x => x.IsNew).ToList().ForEach(x => Nodes.Remove(x));
     Transitions.Where(x => x.IsNew).ToList().ForEach(x => Transitions.Remove(x));
     InterNodes.Where(x => x.IsNew).ToList().ForEach(x => InterNodes.Remove(x));
     Connectors.Where(x => x.IsNew).ToList().ForEach(x => Connectors.Remove(x));
     Inputs.Where(x => x.IsNew).ToList().ForEach(x => Inputs.Remove(x));
     NotInputs.Where(x => x.IsNew).ToList().ForEach(x => NotInputs.Remove(x));
     Outputs.Where(x => x.IsNew).ToList().ForEach(x => Outputs.Remove(x));
     NotOutputs.Where(x => x.IsNew).ToList().ForEach(x => NotOutputs.Remove(x));
 }
 /// <summary>
 /// Clear all observable collections
 /// </summary>
 private void ClearData()
 {
     InterNodes.Clear();
     Connections.Clear();
     Connectors.Clear();
     Nodes.Clear();
     Transitions.Clear();
     Inputs.Clear();
     Outputs.Clear();
     NotInputs.Clear();
     NotOutputs.Clear();
 }
        public void CreateNewNotInput()
        {
            var newNotInput = new NotInputLadder()
            {
                Name  = "I" + notInputNumber,
                IsNew = true
            };

            NotInputs.Add(newNotInput);
            notInputNumber++;
            SelectedObject = newNotInput;
        }
        /// <summary>
        /// Searches for a DiagramObject in the observable collections of the DiagramData with the sames coordinates as the DiagramObject parameter
        /// This only makes sense if the user doesn't places two DiagramObject on the same coordinates of the Grid
        /// </summary>
        /// <param name="diagramObject">Diagram object parameter</param>
        /// <returns>Null or the DiagramObject</returns>
        internal DiagramObject GetDiagramObject(DiagramObject diagramObject)
        {
            if (diagramObject == null)
            {
                return(null);
            }
            DiagramObject diag;

            diag = Nodes.ToList().Find(e => e != null && !e.IsNew && e.X == diagramObject.X && e.Y == diagramObject.Y);
            if (diag != null)
            {
                return(diag);
            }
            diag = InterNodes.ToList().Find(e => e != null && !e.IsNew && e.X == diagramObject.X && e.Y == diagramObject.Y);
            if (diag != null)
            {
                return(diag);
            }
            diag = Transitions.ToList().Find(e => e != null && !e.IsNew && e.X == diagramObject.X && e.Y == diagramObject.Y);
            if (diag != null)
            {
                return(diag);
            }
            diag = Inputs.ToList().Find(e => e != null && !e.IsNew && e.X == diagramObject.X && e.Y == diagramObject.Y);
            if (diag != null)
            {
                return(diag);
            }
            diag = Outputs.ToList().Find(e => e != null && !e.IsNew && e.X == diagramObject.X && e.Y == diagramObject.Y);
            if (diag != null)
            {
                return(diag);
            }
            diag = NotInputs.ToList().Find(e => e != null && !e.IsNew && e.X == diagramObject.X && e.Y == diagramObject.Y);
            if (diag != null)
            {
                return(diag);
            }
            diag = NotOutputs.ToList().Find(e => e != null && !e.IsNew && e.X == diagramObject.X && e.Y == diagramObject.Y);


            return(diag);
        }