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); } }
private void supplierButton_Click(object sender, EventArgs e) { sideBarPanel.Height = supplierButton.Height; sideBarPanel.Top = supplierButton.Top; SupplierUserControl supplierUserControl = new SupplierUserControl(); ShowControl(supplierUserControl); }
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; } }
private void panel_Drop(object sender, DragEventArgs e) { // If an element in the panel has already handled the drop, // the panel should not also handle it. if (e.Handled == false) { Canvas _canvas = (Canvas)sender; UIElement _element = (UIElement)e.Data.GetData("Object"); if (_canvas != null && _element != null) { // Get the panel that the element currently belongs to, // then remove it from that panel and add it the Children of // the panel that its been dropped on. Panel _parent = (Panel)VisualTreeHelper.GetParent(_element); if (_parent != null) { //Mouse position System.Windows.Point position = e.GetPosition(_canvas); //Type DataModel.EnumTypes.UserControlTypes _type = (DataModel.EnumTypes.UserControlTypes)e.Data.GetData("UserControlType"); if ((e.KeyStates == DragDropKeyStates.ControlKey || _parent.Name == "ToolPanel") && e.AllowedEffects.HasFlag(DragDropEffects.Copy)) { switch (_type) { case EnumTypes.UserControlTypes.ShopUserControl: ShopUserControl _shopUserControl = new ShopUserControl((ShopUserControl)_element, Model, ConnectionCreator); Model.Shops.Add(_shopUserControl.ShopModel); _shopUserControl.printOnTarget(_canvas, position); // set the value to return to the DoDragDrop call e.Effects = DragDropEffects.Copy; break; case EnumTypes.UserControlTypes.BuyerUserControl: BuyerUserControl _buyerUserControl = new BuyerUserControl((BuyerUserControl)_element, Model, ConnectionCreator); Model.Buyers.Add(_buyerUserControl.BuyerModel); _buyerUserControl.printOnTarget(_canvas, position); // set the value to return to the DoDragDrop call e.Effects = DragDropEffects.Copy; break; case EnumTypes.UserControlTypes.SupplierUserControl: SupplierUserControl _supplierUserControl = new SupplierUserControl((SupplierUserControl)_element, Model, ConnectionCreator); Model.Suppliers.Add(_supplierUserControl.SupplierModel); _supplierUserControl.printOnTarget(_canvas, position); // set the value to return to the DoDragDrop call e.Effects = DragDropEffects.Copy; break; default: MessageBox.Show("Not habndled yet"); break; } } else if (e.AllowedEffects.HasFlag(DragDropEffects.Move)) { IActorUserControl _actorUserControl = (IActorUserControl)_element; List <Connection> connections; switch (_actorUserControl.GetUserControlType()) { case EnumTypes.UserControlTypes.ShopUserControl: ShopUserControl _shopUserControl = (ShopUserControl)_element; _parent.Children.Remove(_element); _shopUserControl.printOnTarget(_canvas, position); connections = this.Model.Connections.Where(c => c.ActorA == _shopUserControl.ShopModel || c.ActorB == _shopUserControl.ShopModel).ToList(); foreach (Connection conn in connections) { this.ConnectionCreator.ConnectionDictionary[conn].Reprint(); } //TODO: //potem gorzej bo dla kazdej linii musimy nzlaezc aktorow zeby ich przerysowac... nie mam do nich odwolan, po liscie wszystkich narysowanych musze leciec //odowlania nie moge zrobic bo przy odtwarzaniu z bazki nie mam jeszcze aktorow ui i nie ma ich w connections ui //zmiana tego bedzie dluzsza niz warto // set the value to return to the DoDragDrop call e.Effects = DragDropEffects.Move; break; case EnumTypes.UserControlTypes.BuyerUserControl: BuyerUserControl _buyerUserControl = (BuyerUserControl)_element; _parent.Children.Remove(_element); _buyerUserControl.printOnTarget(_canvas, position); connections = this.Model.Connections.Where(c => c.ActorA == _buyerUserControl.BuyerModel || c.ActorB == _buyerUserControl.BuyerModel).ToList(); foreach (Connection conn in connections) { this.ConnectionCreator.ConnectionDictionary[conn].Reprint(); } // set the value to return to the DoDragDrop call e.Effects = DragDropEffects.Move; break; case EnumTypes.UserControlTypes.SupplierUserControl: SupplierUserControl _supplierUserControl = (SupplierUserControl)_element; _parent.Children.Remove(_element); _supplierUserControl.printOnTarget(_canvas, position); connections = this.Model.Connections.Where(c => c.ActorA == _supplierUserControl.SupplierModel || c.ActorB == _supplierUserControl.SupplierModel).ToList(); foreach (Connection conn in connections) { this.ConnectionCreator.ConnectionDictionary[conn].Reprint(); } // set the value to return to the DoDragDrop call e.Effects = DragDropEffects.Move; break; } this.ReprintActors(); } } } } }