private void map_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     dragItem = SearchPosition(e.GetPosition(map));
     if (dragItem != null)
     {
         mi = new Model.MapItem(dragItem.getID(), dragItem.getName(), dragItem.getPath());
         mi.setPosition(dragItem.getPosition());
         move = true;
     }
     else
     {
         move = false;
     }
 }
 private Model.MapItem SearchPosition(Point point)
 {
     Model.MapItem ret = null;
     foreach (Model.MapItem m in mc.resOnCanvas)
     {
         bool pointIsLefter = false;
         bool pointIsUpper  = false;
         if (point.X < m.getPosition().X)
         {
             pointIsLefter = true;
         }
         if (point.X < m.getPosition().Y)
         {
             pointIsUpper = true;
         }
         if (point.X == m.getPosition().X&& point.Y == m.getPosition().Y&& dragItem.name == m.name)
         {
             continue;
         }
         if (!move)
         {
             if (pointIsLefter || pointIsUpper)
             {
                 continue;
             }
             else
             {
                 if (Math.Abs(point.X - m.position.X) <= 100 && Math.Abs(point.Y - m.position.Y) <= 90)
                 {
                     ret = m;
                 }
             }
         }
         else
         {
             if (Math.Abs(point.X - m.position.X) <= 100 && Math.Abs(point.Y - m.position.Y) <= 100)
             {
                 ret = m;
             }
         }
     }
     return(ret);
 }
        private void itemList_MouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(null);
            Vector diff     = startPoint - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                 Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                ListView     listView     = sender as ListView;
                ListViewItem listViewItem =
                    FindAncestor <ListViewItem>((DependencyObject)e.OriginalSource);

                Model.Resource res = (Model.Resource)listView.ItemContainerGenerator.
                                     ItemFromContainer(listViewItem);

                dragItem = new Model.MapItem(res.getMark(), res.getName(), res.getIco());

                DataObject dragData = new DataObject("myFormat", dragItem);
                DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Move);
            }
        }
 private void map_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
 {
     Model.MapItem m = SearchPosition(e.GetPosition(map));
     mc.resOnCanvas.Remove(m);
 }