private void DragFinished(bool cancelled) { System.Windows.Input.Mouse.Capture(null); if (_isDragging) { AdornerLayer.GetAdornerLayer(_overlayElement.AdornedElement).Remove(_overlayElement); if (cancelled == false) { // Canvas.SetTop(_originalElement, _originalTop + _overlayElement.TopOffset); // Canvas.SetLeft(_originalElement, _originalLeft + _overlayElement.LeftOffset); // MessageBox.Show(_overlayElement.PointFromScreen.TopOffset.ToString()); // MessageBox.Show(_overlayElement.LeftOffset.ToString()); System.Data.DataRowView rowView = btnCurrentTable.DataContext as DataRowView; double new_row_no = Math.Floor(int.Parse(rowView["display_row_no"].ToString()) + ((_overlayElement.TopOffset) / 50)); double new_column_no = Math.Floor(int.Parse(rowView["display_column_no"].ToString()) + ((_overlayElement.LeftOffset) / 50)); rowView["display_row_no"] = new_row_no; rowView["display_column_no"] = new_column_no; _presenter.SetTablePosition(rowView); } _overlayElement = null; } _isDragging = false; _isDown = false; }
private void DragStarted() { _isDragging = true; _originalLeft = Canvas.GetLeft(_originalElement); _originalTop = Canvas.GetTop(_originalElement); _overlayElement = new SimpleCircleAdorner(_originalElement); AdornerLayer layer = AdornerLayer.GetAdornerLayer(_originalElement); layer.Add(_overlayElement); }