private static bool GetCorrectingDirection( Rectangle popupRect, Rectangle screenRect, ref RadDirection correction) { bool flag = true; if (popupRect.Left < screenRect.Left && correction == RadDirection.Left) { correction = RadDirection.Right; } else if (popupRect.Top < screenRect.Top && correction == RadDirection.Up) { correction = RadDirection.Down; } else if (popupRect.Right > screenRect.Right && correction == RadDirection.Right) { correction = RadDirection.Left; } else if (popupRect.Bottom > screenRect.Bottom && correction == RadDirection.Down) { correction = RadDirection.Up; } else { flag = false; } return(flag); }
/// <summary>Gets the valid location for a drop-down (for menus, combo boxes, etc.).</summary> /// <remarks> /// The popup is not allowed to be outside the screen rectangle and to be shown over /// the <strong>ownerRect</strong>. /// </remarks> /// <param name="popupDirection"></param> /// <param name="screenRect"></param> /// <param name="popupSize"></param> /// <param name="ownerRect"></param> /// <param name="ownerOffset"> /// Offset in pixels from the owner element. When this is zero there is no space /// between the owner and the drop-down. /// </param> /// <param name="corected"></param> public static Point GetValidLocationForDropDown(RadDirection popupDirection, Rectangle screenRect, Size popupSize, Rectangle ownerRect, int ownerOffset, ref bool corected) { Point firstLocation = CalcLocation(popupDirection, popupSize, ownerRect, ownerOffset); Point location = firstLocation; RadDirection correction = popupDirection; // Correct the location if necessary (only opposite directions are corrected) Rectangle popupRect = new Rectangle(location, popupSize); if (GetCorrectingDirection(popupRect, screenRect, ref correction)) { location = CalcLocation(correction, popupSize, ownerRect, ownerOffset); // Prevent from recursive corrections popupRect = new Rectangle(location, popupSize); if (GetCorrectingDirection(popupRect, screenRect, ref correction)) { location = firstLocation; } corected = true; } // Ensure that the whole popup rectangle is visible popupRect.Location = location; popupRect = EnsureBoundsInScreen(popupRect, screenRect); return(popupRect.Location); }
protected virtual void AdjustDropDownAlignmentForPopupDirection(RadDirection popupDirection) { switch (popupDirection) { case RadDirection.Left: this.HorizontalPopupAlignment = HorizontalPopupAlignment.RightToLeft; this.VerticalPopupAlignment = VerticalPopupAlignment.TopToTop; break; case RadDirection.Right: this.HorizontalPopupAlignment = HorizontalPopupAlignment.LeftToRight; this.VerticalPopupAlignment = VerticalPopupAlignment.TopToTop; break; case RadDirection.Up: this.HorizontalPopupAlignment = this.OwnerElement == null || !this.OwnerElement.RightToLeft ? HorizontalPopupAlignment.LeftToLeft : HorizontalPopupAlignment.RightToRight; this.VerticalPopupAlignment = VerticalPopupAlignment.BottomToTop; break; case RadDirection.Down: this.HorizontalPopupAlignment = this.OwnerElement == null || !this.OwnerElement.RightToLeft ? HorizontalPopupAlignment.LeftToLeft : HorizontalPopupAlignment.RightToRight; this.VerticalPopupAlignment = VerticalPopupAlignment.TopToBottom; break; } }
public static Point GetValidLocationForDropDown( RadDirection popupDirection, Rectangle screenRect, Size popupSize, Rectangle ownerRect, int ownerOffset, ref bool corected) { Point point = RadPopupHelper.CalcLocation(popupDirection, popupSize, ownerRect, ownerOffset); Point location = point; RadDirection correction = popupDirection; Rectangle rectangle = new Rectangle(location, popupSize); if (RadPopupHelper.GetCorrectingDirection(rectangle, screenRect, ref correction)) { location = RadPopupHelper.CalcLocation(correction, popupSize, ownerRect, ownerOffset); rectangle = new Rectangle(location, popupSize); if (RadPopupHelper.GetCorrectingDirection(rectangle, screenRect, ref correction)) { location = point; } corected = true; } rectangle.Location = location; return(RadPopupHelper.EnsureBoundsInScreen(rectangle, screenRect).Location); }
public void ShowControl(RadDirection popupDirection, int ownerOffset) { if (this.Visible) return; bool corected = false; Point location = RadPopupHelper.GetValidLocationForDropDown(popupDirection, this.Size, this.OwnerElement, ownerOffset, ref corected); if (this.grip != null) { if (corected) DockLayoutPanel.SetDock(grip, Telerik.WinControls.Layouts.Dock.Top); else DockLayoutPanel.SetDock(grip, Telerik.WinControls.Layouts.Dock.Bottom); } this.Location = location; this.AutoUpdateBounds(); if (this.AnimationEnabled) { this.AnimateDropDown(true); } else { this.Show(); } }
public Point ShowControl(RadDirection popupDirection, int ownerOffset) { bool flag = false; this.DropDownAnimationDirection = popupDirection; if (this.OwnerElement is RadDateTimePickerElement) { this.SizingGrip.MinSize = new Size(10, 10); this.SizingGrip.Visibility = ElementVisibility.Visible; this.SizingGrip.GripItemNSEW.Alignment = ContentAlignment.BottomRight; } if (this.SizingGrip != null) { if (flag) { DockLayoutPanel.SetDock((RadElement)this.SizingGrip, Dock.Top); } else { DockLayoutPanel.SetDock((RadElement)this.SizingGrip, Dock.Bottom); } } if (!(this.OwnerElement as RadDateTimePickerElement).RightToLeft) { this.SizingGrip.RightToLeft = false; } else { this.SizingGrip.RightToLeft = true; } this.AutoUpdateBounds(); this.ShowPopup(this.OwnerControl.RectangleToScreen(this.OwnerElement.ControlBoundingRectangle)); return(this.Location); }
protected virtual void AdjustDropDownAlignmentForPopupDirection(RadDirection popupDirection) { switch (popupDirection) { case RadDirection.Down: { bool isRTL = this.OwnerElement != null ? this.OwnerElement.RightToLeft : false; this.HorizontalPopupAlignment = !isRTL ? HorizontalPopupAlignment.LeftToLeft : HorizontalPopupAlignment.RightToRight; this.VerticalPopupAlignment = VerticalPopupAlignment.TopToBottom; break; } case RadDirection.Left: { this.HorizontalPopupAlignment = HorizontalPopupAlignment.RightToLeft; this.VerticalPopupAlignment = VerticalPopupAlignment.TopToTop; break; } case RadDirection.Right: { this.HorizontalPopupAlignment = HorizontalPopupAlignment.LeftToRight; this.VerticalPopupAlignment = VerticalPopupAlignment.TopToTop; break; } case RadDirection.Up: { bool isRTL = this.OwnerElement != null ? this.OwnerElement.RightToLeft : false; this.HorizontalPopupAlignment = !isRTL ? HorizontalPopupAlignment.LeftToLeft : HorizontalPopupAlignment.RightToRight; this.VerticalPopupAlignment = VerticalPopupAlignment.BottomToTop; break; } } }
private static Point CalcLocation( RadDirection popupDirection, Size popupSize, Rectangle ownerRect, int ownerOffset) { Point point = new Point(0, 0); switch (popupDirection) { case RadDirection.Left: point = new Point(ownerRect.Left - ownerOffset - popupSize.Width, ownerRect.Top); break; case RadDirection.Right: point = new Point(ownerRect.Right + ownerOffset, ownerRect.Top); break; case RadDirection.Up: point = new Point(ownerRect.Left, ownerRect.Top - ownerOffset - popupSize.Height); break; case RadDirection.Down: point = new Point(ownerRect.Left, ownerRect.Bottom + ownerOffset); break; } return(point); }
/// <summary> /// Gets the valid location for a context menu /// </summary> /// <param name="popupDirection"></param> /// <param name="location"></param> /// <param name="popupSize"></param> /// <param name="corected"></param> /// <returns></returns> public static Point GetValidLocationForContextMenu(RadDirection popupDirection, Point location, Size popupSize, ref bool corected) { Rectangle screenRect = GetScreenRect(location); Rectangle popupRect = new Rectangle(location, popupSize); Point firstLocation = location; switch (popupDirection) { case RadDirection.Left: location = new Point(popupRect.Left - popupSize.Width, popupRect.Top); break; case RadDirection.Up: location = new Point(popupRect.Left, popupRect.Top - popupSize.Height); break; } if (GetCorrectingDirection(popupRect, screenRect, ref popupDirection)) { switch (popupDirection) { case RadDirection.Left: location = new Point(popupRect.Left - popupSize.Width, popupRect.Top); break; case RadDirection.Right: location = new Point(popupRect.Right, popupRect.Top); break; case RadDirection.Up: location = new Point(popupRect.Left, popupRect.Top - popupSize.Height); break; case RadDirection.Down: location = new Point(popupRect.Left, popupRect.Bottom); break; } // Prevent from recursive corrections popupRect = new Rectangle(location, popupSize); if (GetCorrectingDirection(popupRect, screenRect, ref popupDirection)) { location = firstLocation; } corected = true; } popupRect.Location = location; popupRect = EnsureBoundsInScreen(popupRect, screenRect); return(popupRect.Location); }
public static Point GetValidLocationForContextMenu( RadDirection popupDirection, Point location, Size popupSize, ref bool corected) { Rectangle screenRect = RadPopupHelper.GetScreenRect(location); Rectangle rectangle = new Rectangle(location, popupSize); Point point = location; switch (popupDirection) { case RadDirection.Left: location = new Point(rectangle.Left - popupSize.Width, rectangle.Top); break; case RadDirection.Up: location = new Point(rectangle.Left, rectangle.Top - popupSize.Height); break; } if (RadPopupHelper.GetCorrectingDirection(rectangle, screenRect, ref popupDirection)) { switch (popupDirection) { case RadDirection.Left: location = new Point(rectangle.Left - popupSize.Width, rectangle.Top); break; case RadDirection.Right: location = new Point(rectangle.Right, rectangle.Top); break; case RadDirection.Up: location = new Point(rectangle.Left, rectangle.Top - popupSize.Height); break; case RadDirection.Down: location = new Point(rectangle.Left, rectangle.Bottom); break; } rectangle = new Rectangle(location, popupSize); if (RadPopupHelper.GetCorrectingDirection(rectangle, screenRect, ref popupDirection)) { location = point; } corected = true; } rectangle.Location = location; rectangle = RadPopupHelper.EnsureBoundsInScreen(rectangle, screenRect); return(rectangle.Location); }
/// <summary> /// <para>Gets the valid location for a drop-down (for menus, combo boxes, /// etc.).</para> /// </summary> /// <remarks> /// This method calculates: /// <para>1. The rectangle of the screen where the drop down should be shown</para> /// <para>2. The rectangle (in screen coordinates) of the owner element. Owner element /// is the element that shows the drop-down and is connected to it - like a menu item /// that shows its sub menus or a combobox element that shows its drop-down.</para> /// <para>After calculating the screen and the element rectangles this method calls the /// basic method. /// </para> /// </remarks> /// <param name="popupDirection"></param> /// <param name="popupSize"></param> /// <param name="owner"></param> /// <param name="ownerOffset"> /// Offset in pixels from the owner element. When this is zero there is no space /// between the owner and the drop-down. /// </param> /// <param name="corected"></param> public static Point GetValidLocationForDropDown(RadDirection popupDirection, Size popupSize, RadElement owner, int ownerOffset, ref bool corected) { Rectangle screenRect = GetScreenRect(owner); Rectangle ownerRect = owner.ControlBoundingRectangle; if (owner.ElementTree != null) { ownerRect = owner.ElementTree.Control.RectangleToScreen(ownerRect); } Point location = GetValidLocationForDropDown(popupDirection, screenRect, popupSize, ownerRect, ownerOffset, ref corected); return(location); }
public static Point GetValidLocationForDropDown( RadDirection popupDirection, Size popupSize, RadElement owner, int ownerOffset, ref bool corected) { Rectangle screenRect = RadPopupHelper.GetScreenRect(owner); Rectangle rectangle = owner.ControlBoundingRectangle; if (owner.ElementTree != null) { rectangle = owner.ElementTree.Control.RectangleToScreen(rectangle); } return(RadPopupHelper.GetValidLocationForDropDown(popupDirection, screenRect, popupSize, rectangle, ownerOffset, ref corected)); }
protected override void ShowCore(Point point, int ownerOffset, RadDirection popupDirection) { RadApplicationMenuDropDownElement popupElement = ((RadDropDownMenu)this.ElementTree.Control).PopupElement as RadApplicationMenuDropDownElement; if (popupElement != null && !this.IsDesignMode) { popupElement.InvalidateMeasure(true); popupElement.UpdateLayout(); Size size = popupElement.TopRightContentElement.Layout.Size; size.Width -= 3; size.Height -= 3; this.PopupElement.MinSize = size; int num = (int)this.PopupElement.SetValue(RadDropDownMenuElement.DropDownPositionProperty, (object)DropDownPosition.RightPopupContent); } base.ShowCore(point, ownerOffset, popupDirection); }
protected virtual ArrowDirection TranslateArrowDirection(RadDirection dropdownDirection) { switch (dropdownDirection) { case RadDirection.Left: case RadDirection.Right: return(ArrowDirection.Left); case RadDirection.Up: case RadDirection.Down: return(ArrowDirection.Down); default: return(ArrowDirection.Left); } }
protected override void ShowCore(Point point, int ownerOffset, RadDirection popupDirection) { RadApplicationMenuDropDown dropDown = (RadApplicationMenuDropDown)this.ElementTree.Control; RadApplicationMenuDropDownElement menuElement = dropDown.PopupElement as RadApplicationMenuDropDownElement; if (menuElement != null && !this.IsDesignMode) { Size size = menuElement.TopRightContentElement.Layout.Size; size.Width -= 3; size.Height -= 3; this.PopupElement.MinSize = size; this.PopupElement.SetValue(RadDropDownMenuElement.DropDownPositionProperty, DropDownPosition.RightPopupContent); } base.ShowCore(point, ownerOffset, popupDirection); }
protected override SizeF ArrangeOverride(SizeF arrangeSize) { SizeF sizeF = base.ArrangeOverride(arrangeSize); RadCollapsiblePanelElement parent = this.Parent as RadCollapsiblePanelElement; RadDirection expandDirection = parent != null ? parent.ExpandDirection : RadDirection.Down; if (this.Orientation == Orientation.Horizontal) { this.ArrangeAccordingToHorizontalHeaderAlignment(arrangeSize); } else { this.ArrangeAccordingToVerticalHeaderAlignment(arrangeSize); } this.ArrangeLineInMiddle(expandDirection, arrangeSize); return(sizeF); }
private List <LayoutTreeNode> GetParentGroupsWithSameEdge( LayoutTreeNode itemNode, int edgeLocation, RadDirection edgeSpecified) { List <LayoutTreeNode> layoutTreeNodeList = new List <LayoutTreeNode>(); for (LayoutTreeNode layoutTreeNode = itemNode; layoutTreeNode != null; layoutTreeNode = layoutTreeNode.Parent) { if (edgeSpecified == RadDirection.Up && (double)edgeLocation == (double)layoutTreeNode.Bounds.Top || edgeSpecified == RadDirection.Left && (double)edgeLocation == (double)layoutTreeNode.Bounds.Left || (edgeSpecified == RadDirection.Right && (double)edgeLocation == (double)layoutTreeNode.Bounds.Right || edgeSpecified == RadDirection.Down && (double)edgeLocation == (double)layoutTreeNode.Bounds.Bottom)) { layoutTreeNodeList.Add(layoutTreeNode); } } layoutTreeNodeList.Reverse(); return(layoutTreeNodeList); }
private void ArrangeLineInMiddle(RadDirection expandDirection, SizeF arrangeSize) { if (!this.ShowHeaderLine) { return; } PointF location = PointF.Empty; switch (expandDirection) { case RadDirection.Left: case RadDirection.Right: location = new PointF(arrangeSize.Width / 2f - (float)this.HeaderLineElement.LineWidth, this.HeaderLineElement.PreviousArrangeRect.Location.Y); break; case RadDirection.Up: case RadDirection.Down: location = new PointF(this.HeaderLineElement.PreviousArrangeRect.Location.X, arrangeSize.Height / 2f - (float)(this.HeaderLineElement.LineWidth / 2)); break; } base.ArrangeElement((RadElement)this.HeaderLineElement, this.GetClientRectangle(arrangeSize), new RectangleF(location, this.HeaderLineElement.PreviousArrangeRect.Size), arrangeSize); }
protected override SizeF MeasureOverride(SizeF availableSize) { float num1 = (float)this.ownerControl.Height; float num2 = (float)this.ownerControl.Width; RadDirection expandDirection = this.ExpandDirection; foreach (RadElement child in this.Children) { child.Measure(availableSize); switch (expandDirection) { case RadDirection.Left: case RadDirection.Right: num2 = Math.Max(child.DesiredSize.Width, num2); if ((double)availableSize.Height != double.PositiveInfinity) { num1 = availableSize.Height; continue; } continue; case RadDirection.Up: case RadDirection.Down: num1 = Math.Max(child.DesiredSize.Height, num1); if ((double)availableSize.Width != double.PositiveInfinity) { num2 = availableSize.Width; continue; } continue; default: continue; } } return(new SizeF(num2, num1)); }
public void Show(Control control, Point point, RadDirection popupDirection) { RadControl radControl = control as RadControl; Point screen = control.PointToScreen(point); if (radControl == null) { radControl = TelerikHelper.FindRadControlParent(control); } if (radControl != null) { if (radControl.RootElement != null && this.dpiScaleFactor != radControl.RootElement.DpiScaleFactor) { this.dpiScaleFactor = radControl.RootElement.DpiScaleFactor; } } else { RadFormControlBase form = control.FindForm() as RadFormControlBase; SizeF sizeF; if (form != null) { sizeF = form.RootElement.DpiScaleFactor; } else { Point systemDpi = Telerik.WinControls.NativeMethods.GetSystemDpi(); sizeF = new SizeF((float)systemDpi.X / 96f, (float)systemDpi.Y / 96f); } if (this.dpiScaleFactor != sizeF) { this.dpiScaleFactor = sizeF; } } this.ShowCore(screen, 0, popupDirection); }
protected override void ShowCore(Point point, int ownerOffset, RadDirection popupDirection) { this.AdjustDropDownAlignmentForPopupDirection(popupDirection); base.ShowCore(point, ownerOffset, popupDirection); }
/// <summary> /// Positions the RadDropDownMenu relative to the specified RadItem location and /// with specified direction and offset according to the owner. /// </summary> /// <param name="item">The RadItem that is the reference point for the RadDropDownMenu position.</param> /// <param name="ownerOffset">Specifies the offset from the owner in pixels.</param> /// <param name="popupDirection">One of the RadDirection values.</param> public void Show(RadItem item, int ownerOffset, RadDirection popupDirection) { ShowCore(Point.Empty, ownerOffset, popupDirection); }
public void Show(RadItem item, int ownerOffset, RadDirection popupDirection) { this.dpiScaleFactor = item.DpiScaleFactor; this.ShowCore(Point.Empty, ownerOffset, popupDirection); }
public void Show(RadItem item, int ownerOffset, RadDirection popupDirection) { this.control = item == null || item.ElementTree == null ? (Control)null : item.ElementTree.Control; this.item = item; this.DropDown.Show(item, ownerOffset, popupDirection); }
public void Show(Control control, Point point, RadDirection popupDirection) { this.GetClickedControl(control, point.X, point.Y); this.DropDown.Show(control, point, popupDirection); }
public void Show(Point point, RadDirection popupDirection) { this.DropDown.Show(point, popupDirection); }
public void Show(RadItem item, Point point, RadDirection popupDirection) { this.dpiScaleFactor = item.DpiScaleFactor; this.ShowCore(item.PointToScreen(point), 0, popupDirection); }
protected virtual void ShowCore(Point point, int ownerOffset, RadDirection popupDirection) { if (this.Visible || this.IsDisposed) { return; } if (this.LastShowDpiScaleFactor.IsEmpty) { this.LastShowDpiScaleFactor = new SizeF(1f, 1f); } if (this.LastShowDpiScaleFactor != this.dpiScaleFactor) { this.Scale(new SizeF(this.dpiScaleFactor.Width / this.LastShowDpiScaleFactor.Width, this.dpiScaleFactor.Height / this.LastShowDpiScaleFactor.Height)); this.LastShowDpiScaleFactor = this.dpiScaleFactor; } this.showing = true; bool isLoaded = this.IsLoaded; this.SetTheme(); if (!isLoaded) { this.LoadElementTree(); isLoaded = this.IsLoaded; } this.SetTheme(); Point empty = Point.Empty; Point location; if (this.ownerElement != null && this.ownerElement.IsDesignMode) { IntPtr activeWindow = Telerik.WinControls.NativeMethods.GetActiveWindow(); Telerik.WinControls.NativeMethods.POINT pt = new Telerik.WinControls.NativeMethods.POINT(0, 0); Telerik.WinControls.NativeMethods.ClientToScreen(new HandleRef((object)this, activeWindow), pt); point.X -= pt.x; point.Y -= pt.y; location = !this.ownerElement.IsInValidState(true) ? this.OnDropDownLocationNeeded(point) : this.ownerElement.ElementTree.Control.PointToScreen(this.ownerElement.ControlBoundingRectangle.Location); } else { location = this.ownerElement == null?this.OnDropDownLocationNeeded(point) : (!this.ownerElement.IsInValidState(true) ? this.OnDropDownLocationNeeded(point) : this.ownerElement.ElementTree.Control.PointToScreen(this.ownerElement.ControlBoundingRectangle.Location)); } location.Offset(ownerOffset, ownerOffset); Size size = this.ownerElement != null ? this.ownerElement.ControlBoundingRectangle.Size : Size.Empty; Rectangle alignmentRectangle = new Rectangle(location, size); this.showing = false; if (isLoaded) { this.RootElement.InvalidateMeasure(true); this.RootElement.UpdateLayout(); this.Size = this.RootElement.DesiredSize.ToSize(); } this.ShowPopup(alignmentRectangle); if (!isLoaded) { return; } this.RootElement.InvalidateMeasure(true); this.RootElement.UpdateLayout(); this.Size = this.RootElement.DesiredSize.ToSize(); }
protected virtual void ShowCore(Point point, int ownerOffset, RadDirection popupDirection) { if (this.Visible || this.IsDisposed) { return; } showing = true; bool loaded = this.IsLoaded; this.SetTheme(); if (!loaded) { this.LoadElementTree(); loaded = this.IsLoaded; } SetTheme(); Point screenLocation = Point.Empty; if (this.ownerElement != null && this.ownerElement.IsDesignMode) { IntPtr activeHwnd = NativeMethods.GetActiveWindow(); NativeMethods.POINT pt = new NativeMethods.POINT(0, 0); NativeMethods.ClientToScreen(new HandleRef(this, activeHwnd), pt); point.X -= pt.x; point.Y -= pt.y; if (ownerElement.IsInValidState(true)) { screenLocation = ownerElement.ElementTree.Control.PointToScreen(ownerElement.ControlBoundingRectangle.Location); } else { screenLocation = this.OnDropDownLocationNeeded(point); } } else { if (this.ownerElement != null) { if (ownerElement.IsInValidState(true)) { screenLocation = ownerElement.ElementTree.Control.PointToScreen(ownerElement.ControlBoundingRectangle.Location); } else { screenLocation = this.OnDropDownLocationNeeded(point); } } else { screenLocation = this.OnDropDownLocationNeeded(point); } } screenLocation.Offset(ownerOffset, ownerOffset); Size alignmentRectSize = this.ownerElement != null ? this.ownerElement.ControlBoundingRectangle.Size : Size.Empty; Rectangle alignmentRectangle = new Rectangle(screenLocation, alignmentRectSize); showing = false; // FIX: the drop down animation does not work correctly when the popupDirection is set to left or up. //this.DropDownAnimationDirection = popupDirection; base.ShowPopup(alignmentRectangle); if (loaded) { this.RootElement.InvalidateMeasure(true); this.RootElement.UpdateLayout(); this.Size = this.RootElement.DesiredSize.ToSize(); } }
public void Show(Point point, RadDirection popupDirection) { this.ShowCore(point, 0, popupDirection); }