Exemplo n.º 1
0
 public void PrintProject()
 {
     foreach (Connection connection in Model.Connections)
     {
         //ConnectionCreator.AddActor(conne)
         ConnectionUI conn = new ConnectionUI(this.Model, this.target, connection, this.ConnectionCreator);
         this.ConnectionCreator.ConnectionDictionary.Add(connection, conn);
         conn.PrintOnTarget();
     }
     foreach (Shop shopModel in Model.Shops)
     {
         ShopUserControl shopUserControl = new ShopUserControl(shopModel, Model, ConnectionCreator);
         shopUserControl.printOnTarget(this.target);
     }
     foreach (Buyer buyerModel in Model.Buyers)
     {
         BuyerUserControl buyerUserControl = new BuyerUserControl(buyerModel, Model, ConnectionCreator);
         buyerUserControl.printOnTarget(this.target);
     }
     foreach (Supplier supplierModel in Model.Suppliers)
     {
         SupplierUserControl supplierUserControl = new SupplierUserControl(supplierModel, Model, ConnectionCreator);
         supplierUserControl.printOnTarget(this.target);
     }
 }
        public void CreateConnectionIfPossible()
        {
            ConnectionUI connectionUI;
            Connection   conn;

            if (ActorA != null && ActorB != null)
            {
                switch (ActorA.GetUserControlType())
                {
                case EnumTypes.UserControlTypes.ShopUserControl:
                    ShopUserControl ShopA = (ShopUserControl)ActorA;
                    switch (ActorB.GetUserControlType())
                    {
                    case EnumTypes.UserControlTypes.ShopUserControl:
                        ShopUserControl ShopB = (ShopUserControl)ActorB;
                        conn         = new Connection(ShopA.ShopModel, ShopB.ShopModel, EnumTypes.ConnectionTypes.ShopToShop);
                        connectionUI = new ConnectionUI(this.Model, Target, conn, this);
                        ConnectionDictionary.Add(conn, connectionUI);
                        this.Model.Connections.Add(conn);
                        connectionUI.PrintOnTarget();
                        ShopA.Reprint(Target);
                        ShopB.Reprint(Target);
                        break;

                    case EnumTypes.UserControlTypes.BuyerUserControl:
                        BuyerUserControl BuyerB = (BuyerUserControl)ActorB;
                        conn         = new Connection(ShopA.ShopModel, BuyerB.BuyerModel, EnumTypes.ConnectionTypes.ShopToBuyer);
                        connectionUI = new ConnectionUI(this.Model, Target, conn, this);
                        ConnectionDictionary.Add(conn, connectionUI);
                        this.Model.Connections.Add(conn);
                        connectionUI.PrintOnTarget();
                        ShopA.Reprint(Target);
                        BuyerB.Reprint(Target);
                        break;
                    }
                    break;

                case EnumTypes.UserControlTypes.SupplierUserControl:
                    SupplierUserControl SuppA  = (SupplierUserControl)ActorA;
                    ShopUserControl     ShopB2 = (ShopUserControl)ActorB;
                    conn         = new Connection(SuppA.SupplierModel, ShopB2.ShopModel, EnumTypes.ConnectionTypes.SupplierToShop);
                    connectionUI = new ConnectionUI(this.Model, Target, conn, this);
                    ConnectionDictionary.Add(conn, connectionUI);
                    this.Model.Connections.Add(conn);
                    connectionUI.PrintOnTarget();
                    SuppA.Reprint(Target);
                    ShopB2.Reprint(Target);
                    break;
                }
                //RYSUJE - czyli
                this.ActorA = null;
                this.ActorB = null;
            }
        }