/** Gibt ein ins Grid passende GridItem zurück, das das BitmapImage bitImg anzeigt **/ public GridItem getGridItem(BitmapImage bitImg) { Image img = new Image(); img.Source = bitImg; GridItem newItem = new GridItem(); newItem.Content = img; if (img.MinHeight != 0 && img.MinWidth != 0) { newItem.Width = img.MinWidth * 2; newItem.Height = img.MinHeight * 2; } else { Size s = GetTileSize(); newItem.Width = s.Width; newItem.Height = s.Height; } return newItem; }
/** Entfernt das item mit der ID itemId vom Grid **/ public void remove(string itemId) { GridItem itemToBeRemoved = getItemForId(itemId); this.Children.Remove(itemToBeRemoved); }
/* ---------------------------- 2D ---------------------------- */ private void initGrid() { machineMap machines = ClientServerUtil.getInstance().getFactory(); if (machines == null || machines.map == null) { return; } foreach (machineMapEntry machine in machines.map) { string instanceID = machine.key; int classID = getClassIdFromItemId(instanceID); position pos = machine.value; GridItem newItem = new GridItem(); Image img = icons.getImage(classID); newItem.Content = img; #if DEBUG Console.WriteLine("MainWindow.initGrid: instanceID = " + instanceID); Console.WriteLine("MainWindow.initGrid: classID = " + classID); #endif Size s = GridC.GetTileSize(); newItem.Width = s.Width; newItem.Height = s.Height; newItem.Angle = getAngleFromDirection(pos.direction); newItem.instanceId = instanceID; GridC.placeItem(newItem, pos.x, pos.y); } }