/// <summary> /// box の移動中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Box_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { // box の中心が他のboxに入ったときに入れ替える var box1 = sender as BoxViewEx; double x1 = box1.Bounds.Left + box1.Bounds.Width / 2; double y1 = box1.Bounds.Top + box1.Bounds.Height / 2; // 1.中心が他のboxに入っていないか調べる try { var box2 = boxes .Where(x => x != box1) .SingleOrDefault<BoxViewEx>(x => x.Bounds.Contains(x1, y1)); if (box2 == null) return; if (_flag == true) return; _flag = true; // 2.中心に入っていれば、空位置へ移動する var b = boxBlank; boxBlank = box2.Bounds; box2.LayoutTo(b).ContinueWith((_) => { _flag = false; }); }catch { return; } }
public virtual void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { var rc = this.Bounds; rc.X += e.Delta.Translation.X; rc.Y += e.Delta.Translation.Y; this.Layout(rc); if (ManipulationDelta != null) ManipulationDelta(sender, e); }