Interaction logic for TaskDragItem.xaml
Пример #1
0
        public void StartDragDrop(object sender, InputDevice device, object src) {
            //if (!layer.Service.Settings.CanEdit) return;

            var mf = sender;

            // Check whether the input device is in the ignore list.
            if (ignoredDeviceList.Contains(device)) return;

            InputDeviceHelper.InitializeDeviceState(device);

            // try to start drag-and-drop,
            // verify that the cursor the contact was placed at is a ListBoxItem
            //                DependencyObject downSource = sender as DependencyObject;
            //                FrameworkElement parrent = mf.Parent as FrameworkElement;
            //                var source = GetVisualAncestor<FrameworkElement>(downSource);

            var findSource = src as FrameworkElement;

            //var parrent = GetVisualAncestor<FrameworkElement>(downSource);

            //                var cursorVisual = new ucDocument(){Document = new Document(){Location = mf.Location}};
            //                var cursorVisual = new ListFeatureView() { CanBeDragged = false };
            var cursorVisual = new TaskDragItem {
                Task = Task,
                IsDragging = true,
                Plugin = Plugin,
                DataContext = mf,
                Width = 75,
                Height = 75
            };


            var devices = new List<InputDevice>(new[] {device});

            SurfaceDragDrop.BeginDragDrop(this, findSource, cursorVisual, mf, devices, DragDropEffects.Copy);

            // Reset the input device's state.
            InputDeviceHelper.ClearDeviceState(device);
            ignoredDeviceList.Remove(device);
        }
Пример #2
0
        public void Drop(object sender, SurfaceDragDropEventArgs e) {
            var border = sender as Border;
            if (border == null) return;
            border.Background = Brushes.Red;
            if (!visitedBorders.Contains(border))
                visitedBorders.Add(border);

            taskDragItem = e.Cursor.Data as TaskDragItem;
            if (taskDragItem == null || taskDragItem.Service == null || taskDragItem.Task == null) return;
            activeTask = taskDragItem.Task;

            Lead = Followers = string.Empty;

            if (visitedBorders.Count > 0) {
                Lead = (string) visitedBorders[0].DataContext;

                if (visitedBorders.Count > 1) {
                    var sb = new StringBuilder();
                    for (var i = 1; i < visitedBorders.Count; i++) {
                        var visitedBorder = visitedBorders[i];
                        sb.Append((string) visitedBorder.DataContext);
                        sb.Append(", ");
                    }
                    Followers = sb.ToString().TrimEnd(new[] {',', ' '});
                }
                else Followers = "-";
            }

            activeTask.Labels[RecipientsKey] = visitedBorders.Count <= 1 
                ? Lead
                : string.Format("{0}, {1}", Lead, Followers);
            ShowConfirmation = true;
            RemoveFloatingElement();
            e.Handled = true;
        }