private void PolygonDestination_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(Mosaic))) { Mosaic theItem = (Mosaic)e.Data.GetData(typeof(Mosaic)); Grid grid = sender as Grid; MosaicColors tmpColor = new MosaicColors(((Mosaic)grid.DataContext).Color); bool tmpIsCircle = ((Mosaic)grid.DataContext).IsCircle; bool tmpIsPolygon = ((Mosaic)grid.DataContext).IsPolygon; int tmpSize = ((Mosaic)grid.DataContext).Size; if (grid.Name == "PolygonSource") { model.selectedMosaic.Color = model.Colors.Find(x => x.Color == theItem.Color.Color); //model.selectedMosaic.Color.ColorName = theItem.Color.ColorName; model.selectedMosaic.IsCircle = theItem.IsCircle; model.selectedMosaic.IsPolygon = theItem.IsPolygon; model.selectedMosaic.Size = theItem.Size; } else { ((Mosaic)grid.DataContext).Color.Color = theItem.Color.Color; ((Mosaic)grid.DataContext).Color.ColorName = theItem.Color.ColorName; ((Mosaic)grid.DataContext).IsCircle = theItem.IsCircle; ((Mosaic)grid.DataContext).IsPolygon = theItem.IsPolygon; ((Mosaic)grid.DataContext).Size = theItem.Size; if (theItem.Index != int.MaxValue) { if (model.gridSettingSwap) { theItem.Color.Color = tmpColor.Color; theItem.Color.ColorName = tmpColor.ColorName; theItem.IsCircle = tmpIsCircle; theItem.IsPolygon = tmpIsPolygon; theItem.Size = tmpSize; } else if (model.gridSettingMove) { theItem.Color.Color = Brushes.Transparent.ToString(); theItem.Color.ColorName = "None"; } } } dragSelected = false; } }
public NewBoardModel() { Colors = new List <MosaicColors>(); foreach (MosaicColors color in MainViewModel.usedColors) { Colors.Add(new MosaicColors(color)); } mosaicSize = 20; width = 25; height = 25; generate = false; randomColor = true; randomShape = true; randomSize = true; selectedColor = new MosaicColors(MainViewModel.usedColors[0]); }