private void UserControl_Drop(object sender, DragEventArgs e) { //var parent = UIHelper.GetParentOfType<Grid>(this); // Get Row and Column of the Drop-Target int gridRow = Convert.ToInt32(this.GetValue(Grid.RowProperty)); int gridCol = Convert.ToInt32(this.GetValue(Grid.ColumnProperty)); // Get tile var tile = e.Data.GetData("Tile") as SensorTile; if (tile != null) { int orgGridRow = Convert.ToInt32(tile.GetValue(Grid.RowProperty)); int orgGridCol = Convert.ToInt32(tile.GetValue(Grid.ColumnProperty)); // Set position for tile tile.SetValue(Grid.RowProperty, gridRow); tile.SetValue(Grid.ColumnProperty, gridCol); // Set position for drop target this.SetValue(Grid.RowProperty, orgGridRow); this.SetValue(Grid.ColumnProperty, orgGridCol); // Fire event SensorTilePositionChangedEventArgs args = new SensorTilePositionChangedEventArgs(orgGridRow, orgGridCol, gridRow, gridCol, tile); DependencyFactory.Resolve <IEventAggregator>(GeneralConstants.EventAggregator).GetEvent <SensorTilePositionChangedEvent>().Publish(args); } // Reset-Background-Color this.Background = Brushes.Transparent; }
/// <summary> /// Sensor-Tile position changed /// </summary> /// <param name="args"></param> private void SensorTilePositionChangedEventHandler(SensorTilePositionChangedEventArgs args) { // Update config this.configurationFile.UpdateSensorTileConfig(args.SensorTile.HardwareSensor.Name, args.OldGridRow, args.OldGridColumn, args.NewGridRow, args.NewGridColumn); }