void AssociateConnectionPoints(ConnectionViewModel vm)
        {
            var assoc = pointConnectionAssoc;

            if (!assoc.ContainsKey(vm.StartID))
            {
                assoc[vm.StartID] = new List <ConnectionViewModel>();
            }
            if (!assoc.ContainsKey(vm.EndID))
            {
                assoc[vm.EndID] = new List <ConnectionViewModel>();
            }
            assoc[vm.StartID].Add(vm);
            assoc[vm.EndID].Add(vm);
        }
        void CreateConnectionExecute(Tuple <int, int> connectorIds)
        {
            ConnectionData result = null;

            if (!model.TryCreateConnection(connectorIds.Item1, connectorIds.Item2, out result))
            {
                return;
            }

            var rModel = Connection.Of(result);
            var vm     = new ConnectionViewModel(rModel);

            AssociateConnectionPoints(vm);
            Connections.Add(vm);
        }
        public SheetViewModel(Sheet model)
        {
            SwitchTo                = new RelayCommand(SwitchToExecute);
            CreateConnection        = new RelayCommand <Tuple <int, int> >(CreateConnectionExecute);
            UpdateConnectorPosition = new RelayCommand <Tuple <int, Point> >(UpdateConnectorPositionExecute);

            this.model = model;
            if (model != null)
            {
                foreach (var symbolData in model.Data.Symbols)
                {
                    var symbol = new SymbolViewModel(Symbol.Of(symbolData));
                    Symbols.Add(symbol);
                }

                foreach (var connectionData in model.Data.Connections)
                {
                    var conn = new ConnectionViewModel(Connection.Of(connectionData));
                    AssociateConnectionPoints(conn);
                    Connections.Add(conn);
                }
            }
            ;
        }