private void ksdfj(object sender, MouseButtonEventArgs e) { AddShipButtonControl Target = sender as AddShipButtonControl; Target.Inventory--; Ship NewShip = new Ship(Target.NewVesselClass); NewShip.ShipOrientation = Orientation.Horizontal; playingField.Children.Add(NewShip); Point Spawn = playingField.GetSpawn(); PlayingField.SetElementPosition(NewShip, new Point((int)NewShip.Vessel, (int)NewShip.Vessel)); }
private void AddShipClick(object sender, MouseButtonEventArgs e) { AddShipButtonControl Target = sender as AddShipButtonControl; Target.Inventory--; Ship NewShip = new Ship(Target.NewVesselClass); NewShip.ShipOrientation = Orientation.Horizontal; Size CellSize = playingField.GetTileSize(); Size ShipSize = new Size(Grid.GetColumnSpan(NewShip), Grid.GetRowSpan(NewShip)); double morphedX = ShipSize.Width * CellSize.Width; double MorphedY = ShipSize.Height * CellSize.Height; NewShip.SetValue(WidthProperty, morphedX); NewShip.SetValue(HeightProperty, MorphedY); this.DragCanvasOverlay.MyDraggableElement = NewShip; }