//dejamos en el mapa borramos la asignación y le agregamos la orden private void OnDropToMap(object sender, DragEventArgs e) { Console.WriteLine("Soltar en el mapa"); int routedId = 0; if (e.Effects == DragDropEffects.None) { return; } var order = e.Data.GetData(typeof(Order)) as Order; if (_dragViewOrigin.ListView == null) { routedId = 0; } else { routedId = Convert.ToInt32(_dragViewOrigin.ListView.Uid.ToString()); } //ListView _listView = (ListView)sender; if (order != null) { _viewModel.RemoveAssignedOrderToMap(null, _dragViewOrigin.ListView, _dragViewOrigin.AssignId ?? 0, order, routedId); _viewModel.Refresh(); } _dragViewOrigin = null; }
//cuando dejamos en la lista te borra la assignación private void OnDropToList(object sender, DragEventArgs e) { int routedId = 0; //falla al asignar if (e.Effects == DragDropEffects.None) { return; } Order order = e.Data.GetData(typeof(Order)) as Order; ListView _listView = (ListView)sender; if (string.IsNullOrEmpty(_dragViewOrigin.ListView.Uid)) { routedId = 0; } else { routedId = Convert.ToInt32(_dragViewOrigin.ListView.Uid.ToString()); } //_listView.Background = new SolidColorBrush(Colors.Red); if (order != null) // && _dragViewOrigin.AssignId != null) { _viewModel.RemoveAssignedOrder(_listView, _dragViewOrigin.ListView, _dragViewOrigin.AssignId ?? 0, order, routedId); _viewModel.Refresh(); } _dragViewOrigin = null; }
//lista de pedidos #region DRAG & DROP #region Drag/Drop List private void OnDragEnterToList(object sender, DragEventArgs e) { e.Effects = DragDropEffects.Move; if (_dragViewOrigin is null) { _dragViewOrigin = new DragViewOrigin(sender as ListView, DragViewOrigin.LIST_TYPE); } }
//desde el mapa #endregion #region Drag/Drop Map private void OnDragEnterToMap(object sender, DragEventArgs e) { Console.WriteLine("Entrar en el mapa"); e.Effects = DragDropEffects.Move; if (_dragViewOrigin is null) { _dragViewOrigin = new DragViewOrigin(sender as ListView, DragViewOrigin.MAP_TYPE); } }
private void OnDropToAssignment(object sender, DragEventArgs e) { //Funciona try { DateTime Fechainicio = new DateTime(); Fechainicio = DateTime.Now; if (e.Effects == DragDropEffects.None) { return; } ListView _listView = (ListView)sender; Order order = e.Data.GetData(typeof(Order)) as Order; //e.Data. if (order != null) { /* * if (_dragViewOrigin.AssignId != null) * { * _viewModel.RemoveAssignedOrder(_listView,_dragViewOrigin.AssignId ?? 0, order); * } */ int assignId = Convert.ToInt32(_listView.Tag); int routedId = Convert.ToInt32(_listView.Uid.ToString()); _viewModel.AddAssignOrder(_listView, _dragViewOrigin.ListView, assignId, order, routedId); // Innecesario puesto que la llamada se hace desde la clase custom ListViewDragDropManager //RorderAssigments(_listView); _listViewGlobal = _listView; } _dragViewOrigin = null; //this.Refresh(); _viewModel.Refresh(); } catch (Exception ex) { string a = ex.ToString(); } }