protected virtual void OnDragServiceDragOver(object sender, RadDragOverEventArgs e) { if (e.HitTarget is DraggableLayoutControlItem) { e.CanDrop = true; LayoutControlContainerElement ancestor = ((DraggableLayoutControlItem)e.HitTarget).AssociatedItem.FindAncestor <LayoutControlContainerElement>(); LayoutControlDropTargetInfo dropTargetNode = ancestor.LayoutTree.GetDropTargetNode(e.HitTarget as DraggableLayoutControlItem, this.layoutControl.PointToClient(Control.MousePosition), this.GetDragContext(e.DragInstance)); dropTargetNode?.TargetBounds.Offset(ancestor.ControlBoundingRectangle.Location); this.layoutControl.DragOverlay.SetPreviewRectangle(dropTargetNode != null ? dropTargetNode.TargetBounds : Rectangle.Empty); } else if (e.HitTarget is DraggableLayoutControlOverlayElement) { DraggableLayoutControlOverlayElement hitTarget = e.HitTarget as DraggableLayoutControlOverlayElement; if (hitTarget.Parent is RootRadElement && hitTarget.Items.Count == 0) { e.CanDrop = true; this.layoutControl.DragOverlay.SetPreviewRectangle(new Rectangle(Point.Empty, this.layoutControl.Size)); } else { e.CanDrop = false; } } else { e.CanDrop = false; this.layoutControl.DragOverlay.SetPreviewRectangle(Rectangle.Empty); } }
protected virtual void UpdateDragHintLocation(Point mousePosition) { if (!this.CanCommit) { this.overlay.SetPreviewRectangle(Rectangle.Empty); } else { DraggableLayoutControlItem dropTarget = this.DropTarget as DraggableLayoutControlItem; if (dropTarget != null) { LayoutControlContainerElement ancestor = dropTarget.AssociatedItem.FindAncestor <LayoutControlContainerElement>(); Point client = this.overlay.PointToClient(mousePosition); LayoutControlDropTargetInfo dropTargetNode = ancestor.LayoutTree.GetDropTargetNode(dropTarget, client, this.draggedItem.AssociatedItem.GetType()); if (dropTargetNode != null) { this.ValidCursor = (Cursor)null; dropTargetNode.TargetBounds.Offset(ancestor.ControlBoundingRectangle.Location); this.overlay.SetPreviewRectangle(dropTargetNode.TargetBounds); return; } } else if ((this.DropTarget is BaseListViewElement || this.DropTarget is BaseListViewVisualItem) && this.CanDropOnListView(this.DropTarget as RadElement)) { this.overlay.SetPreviewRectangle(Rectangle.Empty); this.ValidCursor = this.deleteCursor; return; } this.ValidCursor = (Cursor)null; this.overlay.SetPreviewRectangle(Rectangle.Empty); } }
protected override void CreateChildElements() { base.CreateChildElements(); this.StretchHorizontally = this.StretchVertically = true; this.Padding = new Padding(4); this.headerElement = new CollapsiblePanelHeaderElement(); int num1 = (int)this.headerElement.HeaderTextElement.BindProperty(RadItem.TextProperty, (RadObject)this, RadItem.TextProperty, PropertyBindingOptions.TwoWay); int num2 = (int)this.headerElement.BindProperty(CollapsiblePanelHeaderElement.IsExpandedProperty, (RadObject)this, LayoutControlGroupItem.IsExpandedProperty, PropertyBindingOptions.TwoWay); int num3 = (int)this.headerElement.HeaderButtonElement.BindProperty(CollapsiblePanelButtonElement.IsExpandedProperty, (RadObject)this, LayoutControlGroupItem.IsExpandedProperty, PropertyBindingOptions.TwoWay); this.containerElement = this.CreateContainerElement(); this.containerElement.Class = "LayoutControlGroupContainer"; this.containerElement.DrawBorder = false; this.Children.Add((RadElement)this.headerElement); this.Children.Add((RadElement)this.containerElement); this.headerElement.HeaderButtonElement.MouseUp += new MouseEventHandler(this.headerElement_MouseUp); }
public LayoutControlResizingBehavior(LayoutControlContainerElement owner) { this.owner = owner; }
public LayoutControlDropTargetInfo GetDropTargetNode( DraggableLayoutControlItem dropTargetElement, Point mousePosition, System.Type dragContext) { LayoutControlContainerElement ancestor = dropTargetElement.AssociatedItem.FindAncestor <LayoutControlContainerElement>(); mousePosition.Offset(-ancestor.ControlBoundingRectangle.X, -ancestor.ControlBoundingRectangle.Y); LayoutControlDropTargetInfo controlDropTargetInfo = new LayoutControlDropTargetInfo(); Rectangle bounds = dropTargetElement.Bounds; Point point = new Point(mousePosition.X - bounds.X, mousePosition.Y - bounds.Y); LayoutTreeNode nodeByItem = this.FindNodeByItem(dropTargetElement.AssociatedItem); if (dropTargetElement.AssociatedItem is LayoutControlGroupItem && ((LayoutControlGroupItem)dropTargetElement.AssociatedItem).Items.Count == 0) { LayoutControlGroupItem associatedItem = dropTargetElement.AssociatedItem as LayoutControlGroupItem; Point location = new Point(dropTargetElement.ControlBoundingRectangle.X - this.owner.ControlBoundingRectangle.X, dropTargetElement.ControlBoundingRectangle.Y - this.owner.ControlBoundingRectangle.Y); location.Offset(associatedItem.ContainerElement.BoundingRectangle.Location); controlDropTargetInfo.TargetBounds = new Rectangle(location, associatedItem.ContainerElement.BoundingRectangle.Size); controlDropTargetInfo.TargetNode = nodeByItem; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Center; return(controlDropTargetInfo); } if (dropTargetElement.AssociatedItem is LayoutControlTabbedGroup) { LayoutControlTabbedGroup associatedItem = dropTargetElement.AssociatedItem as LayoutControlTabbedGroup; if ((object)dragContext != null && typeof(LayoutControlGroupItem).IsAssignableFrom(dragContext) && ((double)point.Y / (double)bounds.Height >= 0.333333343267441 && (double)point.Y / (double)bounds.Height <= 0.666666686534882 && ((double)point.X / (double)bounds.Width > 0.25 && (double)point.X / (double)bounds.Width < 0.75) && associatedItem.ItemGroups.Count == 0 || associatedItem.TabStrip.ItemContainer.BoundingRectangle.Contains(point))) { Point location = new Point((int)nodeByItem.Bounds.Location.X, (int)nodeByItem.Bounds.Location.Y); location.Offset(associatedItem.TabStrip.ContentArea.BoundingRectangle.Location); controlDropTargetInfo.TargetTabIndex = associatedItem.GetTargetDropIndex(point); controlDropTargetInfo.TargetBounds = controlDropTargetInfo.TargetTabIndex >= 0 ? associatedItem.GetTargetBounds(controlDropTargetInfo.TargetTabIndex) : new Rectangle(location, associatedItem.TabStrip.ContentArea.BoundingRectangle.Size); controlDropTargetInfo.TargetNode = nodeByItem; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Center; return(controlDropTargetInfo); } } if ((double)point.Y / (double)bounds.Height <= 0.16666667163372) { float num = Math.Min(0.99f, (float)point.Y / ((float)bounds.Height / 6f)); List <LayoutTreeNode> groupsWithSameEdge = this.GetParentGroupsWithSameEdge(nodeByItem, bounds.Top, RadDirection.Up); if (groupsWithSameEdge.Count == 0) { return((LayoutControlDropTargetInfo)null); } int index = Math.Min(groupsWithSameEdge.Count - 1, (int)((double)groupsWithSameEdge.Count * (double)num)); LayoutTreeNode layoutTreeNode = groupsWithSameEdge[index]; controlDropTargetInfo.TargetBounds = new Rectangle((int)layoutTreeNode.Bounds.X, (int)layoutTreeNode.Bounds.Y, (int)layoutTreeNode.Bounds.Width, 26); controlDropTargetInfo.TargetNode = layoutTreeNode; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Top; } else if ((double)point.Y / (double)bounds.Height > 0.16666667163372 && (double)point.Y / (double)bounds.Height < 0.333333343267441) { controlDropTargetInfo.TargetBounds = new Rectangle(bounds.Location, new Size(bounds.Width, bounds.Height / 2)); controlDropTargetInfo.TargetNode = nodeByItem; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Top; } else if ((double)point.Y / (double)bounds.Height > 0.666666686534882 && (double)point.Y / (double)bounds.Height < 0.833333313465118) { controlDropTargetInfo.TargetBounds = new Rectangle(new Point(bounds.X, bounds.Y + bounds.Height / 2), new Size(bounds.Width, bounds.Height / 2)); controlDropTargetInfo.TargetNode = nodeByItem; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Bottom; } else if ((double)point.Y / (double)bounds.Height >= 0.833333313465118) { float num = Math.Min(0.99f, (float)(bounds.Height - point.Y) / ((float)bounds.Height / 6f)); List <LayoutTreeNode> groupsWithSameEdge = this.GetParentGroupsWithSameEdge(nodeByItem, bounds.Bottom, RadDirection.Down); if (groupsWithSameEdge.Count == 0) { return((LayoutControlDropTargetInfo)null); } int index = Math.Min(groupsWithSameEdge.Count - 1, (int)((double)groupsWithSameEdge.Count * (double)num)); LayoutTreeNode layoutTreeNode = groupsWithSameEdge[index]; controlDropTargetInfo.TargetBounds = new Rectangle((int)layoutTreeNode.Bounds.X, (int)layoutTreeNode.Bounds.Bottom - 26, (int)layoutTreeNode.Bounds.Width, 26); controlDropTargetInfo.TargetNode = layoutTreeNode; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Bottom; } else if ((double)point.Y / (double)bounds.Height >= 0.333333343267441 && (double)point.Y / (double)bounds.Height <= 0.666666686534882) { if ((double)point.X / (double)bounds.Width <= 0.25) { float num = Math.Min(0.99f, (float)point.X / ((float)bounds.Width / 4f)); List <LayoutTreeNode> groupsWithSameEdge = this.GetParentGroupsWithSameEdge(nodeByItem, bounds.Left, RadDirection.Left); if (groupsWithSameEdge.Count == 0) { return((LayoutControlDropTargetInfo)null); } int index = Math.Min(groupsWithSameEdge.Count - 1, (int)((double)groupsWithSameEdge.Count * (double)num)); LayoutTreeNode layoutTreeNode = groupsWithSameEdge[index]; controlDropTargetInfo.TargetBounds = new Rectangle((int)layoutTreeNode.Bounds.X, (int)layoutTreeNode.Bounds.Y, 86, (int)layoutTreeNode.Bounds.Height); controlDropTargetInfo.TargetNode = layoutTreeNode; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Left; } else if ((double)point.X / (double)bounds.Width > 0.25 && (double)point.X / (double)bounds.Width <= 0.5) { controlDropTargetInfo.TargetBounds = new Rectangle(bounds.Location, new Size(bounds.Width / 2, bounds.Height)); controlDropTargetInfo.TargetNode = nodeByItem; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Left; } else if ((double)point.X / (double)bounds.Width > 0.5 && (double)point.X / (double)bounds.Width < 0.75) { controlDropTargetInfo.TargetBounds = new Rectangle(new Point(bounds.X + bounds.Width / 2, bounds.Y), new Size(bounds.Width / 2, bounds.Height)); controlDropTargetInfo.TargetNode = nodeByItem; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Right; } else if ((double)point.X / (double)bounds.Width >= 0.75) { float num = Math.Min(0.99f, (float)(bounds.Width - point.X) / ((float)bounds.Width / 4f)); List <LayoutTreeNode> groupsWithSameEdge = this.GetParentGroupsWithSameEdge(nodeByItem, bounds.Right, RadDirection.Right); if (groupsWithSameEdge.Count == 0) { return((LayoutControlDropTargetInfo)null); } int index = Math.Min(groupsWithSameEdge.Count - 1, (int)((double)groupsWithSameEdge.Count * (double)num)); LayoutTreeNode layoutTreeNode = groupsWithSameEdge[index]; controlDropTargetInfo.TargetBounds = new Rectangle((int)layoutTreeNode.Bounds.Right - 86, (int)layoutTreeNode.Bounds.Y, 86, (int)layoutTreeNode.Bounds.Height); controlDropTargetInfo.TargetNode = layoutTreeNode; controlDropTargetInfo.TargetPosition = LayoutControlDropPosition.Right; } } return(controlDropTargetInfo); }
public LayoutTree(LayoutControlContainerElement owner) { this.owner = owner; }