Beispiel #1
0
        private void OnRowDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            var row     = sender as GridViewRow;
            var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;

            if (details == null || row == null)
            {
                return;
            }

            details.CurrentDraggedOverItem = row.DataContext;

            if (details.CurrentDraggedItem == details.CurrentDraggedOverItem)
            {
                e.Effects = DragDropEffects.None;
                e.Handled = true;
                return;
            }

            details.CurrentDropPosition = GetDropPositionFromPoint(e.GetPosition(row), row);
            int dropIndex       = (this.AssociatedObject.Items as IList).IndexOf(row.DataContext);
            int draggedItemIdex = (this.AssociatedObject.Items as IList).IndexOf(DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedItem"));

            if (dropIndex >= row.GridViewDataControl.Items.Count - 1 && details.CurrentDropPosition == DropPosition.After)
            {
                details.DropIndex = dropIndex;
                return;
            }

            dropIndex         = draggedItemIdex > dropIndex ? dropIndex : dropIndex - 1;
            details.DropIndex = details.CurrentDropPosition == DropPosition.Before ? dropIndex : dropIndex + 1;
        }
        private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            var position = e.GetPosition(sender as Canvas);

            Canvas.SetTop(this.draggedImage, position.Y - this.relativeStartPoint.Y);
            Canvas.SetLeft(this.draggedImage, position.X - this.relativeStartPoint.X);
        }
Beispiel #3
0
        private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            Point mousepos = e.GetPosition(this.syntaxEditor.EditorPresenter);

            dropPos = this.syntaxEditor.EditorPresenter.GetPositionFromViewPoint(mousepos);
            this.syntaxEditor.CaretPosition.MoveToPosition(dropPos);
            this.syntaxEditor.Focus();
        }
        private void OnItemDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            var item = (e.OriginalSource as FrameworkElement).ParentOfType <RadTreeViewItem>();

            if (item == null)
            {
                e.Effects = DragDropEffects.None;
                e.Handled = true;
                return;
            }
            var position = GetPosition(item, e.GetPosition(item));

            if (item.Level == 0 && position != DropPosition.Inside)
            {
                e.Effects = DragDropEffects.None;
                e.Handled = true;
                return;
            }
            RadTreeView tree        = sender as RadTreeView;
            var         draggedData = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData");
            var         dropDetails = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;

            if ((draggedData == null && dropDetails == null))
            {
                return;
            }
            if (position != DropPosition.Inside)
            {
                e.Effects = DragDropEffects.All;
                dropDetails.IsValidDrop = true;
                destinationItems        = item.Level > 0 ? (IList)item.ParentItem.ItemsSource : (IList)tree.ItemsSource;
                int index = destinationItems.IndexOf(item.Item);
                dropDetails.DropIndex = position == DropPosition.Before ? index : index + 1;
            }
            else
            {
                destinationItems = (IList)item.ItemsSource;
                int index = 0;

                if (destinationItems == null)
                {
                    e.Effects = DragDropEffects.None;
                    dropDetails.IsValidDrop = false;
                }
                else
                {
                    e.Effects               = DragDropEffects.All;
                    dropDetails.DropIndex   = index;
                    dropDetails.IsValidDrop = true;
                }
            }

            dropDetails.CurrentDraggedOverItem = item.Item;
            dropDetails.CurrentDropPosition    = position;

            e.Handled = true;
        }
Beispiel #5
0
 private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs args)
 {
     if (this.DraggingCandidate != null && this.MaximizedItem != null)
     {
         this.previousPosition = args.GetPosition(Window.GetWindow(this));
         var currentMousePosition = previousPosition;
         if (this == sender && this.DraggingCandidate != null &&
             this.lastMousePosition != currentMousePosition)
         {
             this.DragTiles(args, currentMousePosition);
             args.Handled = true;
         }
     }
 }
Beispiel #6
0
        private static void OnWindowDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            if (e.AllowedEffects != DragDropEffects.None)
            {
                var position = e.GetPosition(rootVisual) - EndPointOffset;
                arrowVisual.X2 = position.X;
                arrowVisual.Y2 = position.Y;
                arrowVisual.UpdateGeometry();

                if (!arrowContainer.IsOpen &&
                    GetDistance(arrowVisual.X1, arrowVisual.Y1, arrowVisual.X2, arrowVisual.Y2) >= dragStartThreshold)
                {
                    arrowContainer.IsOpen = true;
                }
            }
        }
        private void OnTimelineDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            var position        = e.GetPosition(this.timeline);
            var dataItem        = (ITimelineItem)DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedItem");
            var source          = (IList)this.timeline.ItemsSource;
            var itemIndex       = source.IndexOf(dataItem);
            var groupUnderMouse = GetGroupUnderMouse(position);
            var rowIndex        = GetRowUnderMouse(position, groupUnderMouse);

            source.Remove(dataItem);

            dataItem.GroupKey  = groupUnderMouse.Key;
            dataItem.RowIndex  = rowIndex;
            dataItem.StartDate = this.timeline.ConvertPointToDateTime(position);

            source.Insert(itemIndex, dataItem);
        }
Beispiel #8
0
        private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs args)
        {
            dropPosition.Visibility = Visibility.Collapsed;
            string payloadData = DragDropPayloadManager.GetDataFromObject(args.Data, "DragData") as string;

            if (string.IsNullOrEmpty(payloadData))
            {
                return;
            }

            RadRichTextBox mainEditor  = sender as RadRichTextBox;
            RadRichTextBox richTextBox = mainEditor.ActiveDocumentEditor as RadRichTextBox;

            Point            point = args.GetPosition(richTextBox);
            DocumentPosition pos   = richTextBox.ActiveEditorPresenter.GetDocumentPositionFromViewPoint(point);

            richTextBox.Document.CaretPosition.MoveToPosition(pos);
        }
        private void OnDragOver(object sender, DragEventArgs e)
        {
            if (popup.IsOpen)
            {
                var item = DragDropPayloadManager.GetDataFromObject(e.Data, "DragData") as DragDropParameter;
                if (item != null)
                {
                    var distance = Distance(item.Location, e.GetPosition(this));
                    if (distance > 30)
                    {
                        popup.IsOpen = false;
                    }
                }
            }

            e.Effects = DragDropEffects.None;
            e.Handled = true;
        }
        private void OnTimelineDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            var      position           = e.GetPosition(this.timeline);
            DateTime dateTimeUnderMouse = this.timeline.ConvertPointToDateTime(position);
            var      dataItem           = (ITimelineItem)DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedItem");
            var      dragVisual         = (TimelineItemDragVisualInfo)this.dragVisual.Content;

            var groupUnderMouse = GetGroupUnderMouse(position);

            if (groupUnderMouse != null)
            {
                var rowIndex = GetRowUnderMouse(position, groupUnderMouse);
                dragVisual.GroupKey = groupUnderMouse.Key;
                dragVisual.RowIndex = rowIndex;
            }
            else
            {
                dragVisual.GroupKey = null;
                e.Effects           = DragDropEffects.None;
                e.Handled           = true;
            }
        }
        private static void TrayDropped(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            RadToolBarTray destinationTray = sender as RadToolBarTray;
            DragDropInfo   info            = GetDragDropInfo(e.Data);

            if (destinationTray == null || info == null)
            {
                return;
            }

            var positionInfo = BandsUtilities.CalculateToolBarPositionInfo(info.ToolBar, destinationTray, e.GetPosition(destinationTray));

            if (!destinationTray.Items.Contains(info.ToolBar))
            {
                MoveToolBarToTray(info, destinationTray);
            }

            bool allowNewBandCreation = GetNewBandMode(destinationTray) != NewBandMode.None;

            BandsUtilities.UpdateToolBarPosition(destinationTray, info.ToolBar, positionInfo, allowNewBandCreation);

            ClearHitTesting(destinationTray.Items);
            HideNewBandIndicator(destinationTray);

            e.Handled = true;
        }
        private static void TrayDragEntered(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            RadToolBarTray tray = sender as RadToolBarTray;
            DragDropInfo   info = GetDragDropInfo(e.Data);

            if (tray == null || info == null)
            {
                return;
            }

            lastInitializedInfo = null;

            if (!tray.Items.Contains(info.ToolBar))
            {
                var positionInfo = BandsUtilities.CalculateToolBarPositionInfo(info.ToolBar, tray, e.GetPosition(tray));
                MoveToolBarToTray(info, tray);
                bool allowNewBandCreation = GetNewBandMode(tray) == NewBandMode.Live;
                BandsUtilities.UpdateToolBarPosition(tray, info.ToolBar, positionInfo, allowNewBandCreation);
                UpdateNewBandIndicator(info, positionInfo, tray);
            }

            e.Handled = true;
        }
        private static void TrayDraggedOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            RadToolBarTray tray = sender as RadToolBarTray;
            DragDropInfo   info = GetDragDropInfo(e.Data);

            if (tray == null || info == null)
            {
                return;
            }

            var  positionInfo         = BandsUtilities.CalculateToolBarPositionInfo(info.ToolBar, tray, e.GetPosition(tray));
            bool allowNewBandCreation = GetNewBandMode(tray) == NewBandMode.Live;

            BandsUtilities.UpdateToolBarPosition(tray, info.ToolBar, positionInfo, allowNewBandCreation);
            UpdateNewBandIndicator(info, positionInfo, tray);
        }
        private void OnDrop(object sender, DragEventArgs e)
        {
            const int gadgetSize = 400;
            var sourceElement = e.Source as FrameworkElement;
            if (sourceElement == null)
            {
                e.Effects = DragDropEffects.None;
                return;
            }

            var destination = sourceElement.DataContext as DashboardPageViewModel;

            var item = DragDropPayloadManager.GetDataFromObject(e.Data, "DragData") as DragDropParameter;

            var panel = e.Source as Panel;

            if (destination != null && item != null && panel != null)
            {
                //Get the spatial relation between the destination item and the vis. root:

                var child = (panel.Children)[0];
                var scroll = child as ScrollContentPresenter;
                var location = e.GetPosition(this);

                if (scroll == null)
                    return;

                if (scroll.HorizontalOffset == 0f && (location.X > scroll.ViewportWidth - gadgetSize))
                {
                    scroll.SetHorizontalOffset(gadgetSize);
                }
                else
                {
                    location.X += scroll.HorizontalOffset;

                    if (location.X > (scroll.ViewportWidth + scroll.HorizontalOffset - gadgetSize))
                    {
                        scroll.SetHorizontalOffset(scroll.HorizontalOffset + gadgetSize);
                    }
                }

                if (scroll.VerticalOffset == 0f && (location.Y > scroll.ViewportHeight - gadgetSize))
                {
                    scroll.SetVerticalOffset(gadgetSize);
                }
                else
                {
                    location.Y += scroll.VerticalOffset;

                    if (location.Y > (scroll.ViewportHeight + scroll.VerticalOffset - gadgetSize))
                    {
                        scroll.SetVerticalOffset(scroll.VerticalOffset + gadgetSize);
                    }
                }

                item.Location = location;
                destination.AddGadgetCommand.Execute(item);

                e.Handled = true;
            }
        }
Beispiel #15
0
        private void OnItemDragOver(object sender, DragEventArgs e)
        {
            var item = (e.OriginalSource as FrameworkElement).ParentOfType<RadTreeViewItem>();
            if (item == null)
            {
                e.Effects = DragDropEffects.None;
                e.Handled = true;
                return;
            }
            var position = GetPosition(e.GetPosition(item));
            if (item.Level == 0 && position != DropPosition.Inside)
            {
                e.Effects = DragDropEffects.None;
                e.Handled = true;
                return;
            }
            var tree = sender as RadTreeView;
            var draggedData = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData");
            var dropDetails = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;

            if ((draggedData == null && dropDetails == null))
            {
                return;
            }
            if (position != DropPosition.Inside)
            {
                e.Effects = DragDropEffects.All;

                if (tree != null)
                    _destinationItems = item.Level > 0 ? (IList) item.ParentItem.ItemsSource : (IList) tree.ItemsSource;
                var index = _destinationItems.IndexOf(item.Item);
                if (dropDetails != null) dropDetails.DropIndex = position == DropPosition.Before ? index : index + 1;
            }
            else
            {
                _destinationItems = (IList) item.ItemsSource;
                const int index = 0;

                if (_destinationItems == null)
                {
                    e.Effects = DragDropEffects.None;
                }
                else
                {
                    e.Effects = DragDropEffects.All;
                    if (dropDetails != null) dropDetails.DropIndex = index;
                }
            }

            if (dropDetails != null)
            {
                dropDetails.CurrentDraggedOverItem = item.Item;
                dropDetails.CurrentDropPosition = DropIndicationDetails.ConverDropPositionToString(position);
            }

            e.Handled = true;
        }
		private void OnElementDragDropCompleted(object sender, DragEventArgs e)
		{
			MindmapShapeBase newShape;
			if (this.DraggingCandidate is MindmapRootShape)
				newShape = new MindmapFirstLevelShape();
			else
				newShape = new MindmapOuterShape();

			this.AddShape(newShape, this.GetTransformedPoint(e.GetPosition(this)), true);
			this.AddConnection(new RadDiagramConnection
			{
				Source = this.DraggingCandidate,
				Target = newShape
			}, true);

			this.DraggingCandidate = null;
			e.Handled = true;
		}
Beispiel #17
0
 private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
 {
     lastMousePosition = e.GetPosition(this);
 }
        private void OnDrop(object sender, DragEventArgs e)
        {
            e.Handled = true;
            FadeOut((FrameworkElement)e.Source);

            var mainViewModel = DataContext as MainViewModel;
            if (mainViewModel == null)
            {
                return;
            }

            var sourceElement = e.Source as FrameworkElement;
            if (sourceElement == null)
            {
                return;
            }

            var destination = sourceElement.DataContext as IDashboardPage;
            if (destination == null)
            {
                return;
            }

            var data = DragDropPayloadManager.GetDataFromObject(e.Data, "DragData") as DragDropParameter;

            if (data != null && data.DraggedItem is NavigationItemInfo)
            {
                //proportional
                var grid = Parent as Grid;
                if (grid != null)
                {
                    var parent = grid.Parent as Grid;
                    if (parent != null)
                    {
                        var main = VisualTreeHelper.GetParent(parent) as MainMenuMetroView;
                        if (main != null)
                        {
                            var ph = main.ActualHeight;
                            var pw = main.ActualWidth;

                            var ch = e.GetPosition(sourceElement).Y;
                            var cw = e.GetPosition(sourceElement).X;

                            var cprocentH = ch * 100 / sourceElement.ActualHeight;
                            var cprocentW = cw * 100 / sourceElement.ActualWidth;

                            var parentH = cprocentH * ph / 100;
                            var parentW = cprocentW * pw / 100;

                            var parameter = new DragDropParameter { DraggedItem = data.DraggedItem, Location = new Point(parentW, parentH) };

                            mainViewModel.IsMenuShown = false;
                            mainViewModel.DashboardVM.Value.AddGadgetToExecute(destination, parameter);
                        }
                    }
                }
            }
        }