/// <summary>
        /// Constructor of the MainViewModel, initializes all needed properties
        /// </summary>
        /// <param name="mw">The MainWindow</param>
        public MainViewModel(MainWindow mw)
        {
            nodeNumber                   = 0;
            transitionNumber             = 0;
            inputNumber                  = 0;
            outputNumber                 = 0;
            notInputNumber               = 0;
            notOutputNumber              = 0;
            MainWindowReference          = mw;
            NewProjectCommand.IsEnabled  = true;
            SaveProjectCommand.IsEnabled = true;
            OpenProjectCommand.IsEnabled = true;
            AboutCommand.IsEnabled       = true;

            dd = new DiagramData();


            ShowAllCoordinates = false;
            ShowNames          = true;
        }
        private void FillData(DiagramData auxDD)
        {
            ClearData();
            // Logic Elements
            foreach (Node n in auxDD.Nodes)
            {
                dd.Nodes.Add(n);
            }
            foreach (Transition n in auxDD.Transitions)
            {
                dd.Transitions.Add(n);
            }
            foreach (InputLadder n in auxDD.Inputs)
            {
                dd.Inputs.Add(n);
            }
            foreach (NotInputLadder n in auxDD.NotInputs)
            {
                dd.NotInputs.Add(n);
            }
            foreach (OutputLadder n in auxDD.Outputs)
            {
                dd.Outputs.Add(n);
            }
            foreach (NotOutputLadder n in auxDD.NotOutputs)
            {
                dd.NotOutputs.Add(n);
            }
            foreach (InterNode n in auxDD.InterNodes)
            {
                dd.InterNodes.Add(n);
            }

            // Rebuilding connections
            foreach (Connection n in auxDD.Connections)
            {
                dd.Connections.Add(n);
                n.Start = GetDiagramObject(n.Start);
                n.End   = GetDiagramObject(n.End);
                Collection <InterNode> auxCollection = new Collection <InterNode>();
                // For each internode, we need to make sure
                // it is one of those already initiliazed and present in dd.InterNodes
                foreach (InterNode inter in n.InterNodes)
                {
                    auxCollection.Add(GetDiagramObject(inter) as InterNode);
                }
                foreach (InterNode inter in auxCollection)
                {
                    n.InterNodes.Add(inter);
                }
                foreach (Connector c in n.Connectors)
                {
                    dd.Connectors.Add(c);
                    c.Start = GetDiagramObject(c.Start);
                    c.End   = GetDiagramObject(c.End);
                }
            }

            LogicElement auxLogicElement;

            foreach (Connection n in dd.Connections)
            {
                // We need to fill the Next and Previous lists of each logicElement
                // that is connected to a valid connection
                if (n.Start != null && n.End != null)
                {
                    auxLogicElement = n.Start as LogicElement;
                    auxLogicElement.Next.Add(n.End as LogicElement);
                    auxLogicElement = n.End as LogicElement;
                    auxLogicElement.Previous.Add(n.Start as LogicElement);
                }
            }
        }
        /// <summary>
        /// Constructor of the MainViewModel, initializes all needed properties
        /// </summary>
        /// <param name="mw">The MainWindow</param>
        public MainViewModel(MainWindow mw)
        {
            nodeNumber = 0;
            transitionNumber = 0;
            inputNumber = 0;
            outputNumber = 0;
            notInputNumber = 0;
            notOutputNumber = 0;
            MainWindowReference = mw;
            NewProjectCommand.IsEnabled = true;
            SaveProjectCommand.IsEnabled = true;
            OpenProjectCommand.IsEnabled = true;
            AboutCommand.IsEnabled = true;

            dd = new DiagramData();

            ShowAllCoordinates = false;
            ShowNames = true;
        }
        private void FillData(DiagramData auxDD)
        {
            ClearData();
            // Logic Elements
            foreach (Node n in auxDD.Nodes) { dd.Nodes.Add(n); }
            foreach (Transition n in auxDD.Transitions) { dd.Transitions.Add(n); }
            foreach (InputLadder n in auxDD.Inputs) { dd.Inputs.Add(n); }
            foreach (NotInputLadder n in auxDD.NotInputs) { dd.NotInputs.Add(n); }
            foreach (OutputLadder n in auxDD.Outputs) { dd.Outputs.Add(n); }
            foreach (NotOutputLadder n in auxDD.NotOutputs) { dd.NotOutputs.Add(n); }
            foreach (InterNode n in auxDD.InterNodes) { dd.InterNodes.Add(n); }

            // Rebuilding connections
            foreach (Connection n in auxDD.Connections)
            {
                dd.Connections.Add(n);
                n.Start = GetDiagramObject(n.Start);
                n.End = GetDiagramObject(n.End);
                Collection<InterNode> auxCollection = new Collection<InterNode>();
                // For each internode, we need to make sure
                // it is one of those already initiliazed and present in dd.InterNodes
                foreach (InterNode inter in n.InterNodes){ auxCollection.Add(GetDiagramObject(inter) as InterNode); }
                foreach (InterNode inter in auxCollection){ n.InterNodes.Add(inter); }
                foreach (Connector c in n.Connectors)
                {
                    dd.Connectors.Add(c);
                    c.Start = GetDiagramObject(c.Start);
                    c.End = GetDiagramObject(c.End);
                }
            }

            LogicElement auxLogicElement;
            foreach (Connection n in dd.Connections)
            {
                // We need to fill the Next and Previous lists of each logicElement
                // that is connected to a valid connection
                if (n.Start != null && n.End != null)
                {
                    auxLogicElement = n.Start as LogicElement;
                    auxLogicElement.Next.Add(n.End as LogicElement);
                    auxLogicElement = n.End as LogicElement;
                    auxLogicElement.Previous.Add(n.Start as LogicElement);
                }
            }
        }