protected override void UpdatePopupMinMaxSize(RadPopupControlBase popup) { if (this.DropDownMinSize != Size.Empty) { popup.MinimumSize = this.DropDownMinSize; } if (this.DropDownMaxSize != Size.Empty) { popup.MaximumSize = this.DropDownMaxSize; } if (!(popup.MinimumSize == Size.Empty)) { return; } RadSizablePopupControl sizablePopupControl = popup as RadSizablePopupControl; RadElement sizingGrip = (RadElement)sizablePopupControl.SizingGrip; Rectangle rectangle = new Rectangle(sizingGrip.BoundingRectangle.Location, Size.Add(sizingGrip.BoundingRectangle.Size, sizingGrip.Margin.Size)); float num = (float)((double)this.listElement.BorderWidth * 2.0 + (this.listElement.VScrollBar.Visibility == ElementVisibility.Visible ? (double)(this.listElement.VScrollBar.FirstButton.Size.Height + this.listElement.VScrollBar.SecondButton.Size.Height) : 0.0) + (sizablePopupControl.SizingGrip.Visibility == ElementVisibility.Collapsed ? 0.0 : (double)rectangle.Height)); if (this.maxDropDownItems != 0) { num = 0.0f; } popup.Size = new Size(0, (int)Math.Ceiling(this.listElement.Items.Count == 1 ? 0.0 : (double)num)); }
protected override void UpdatePopupMinMaxSize(RadPopupControlBase popup) { if (this.DropDownMinSize != Size.Empty) { popup.MinimumSize = this.DropDownMinSize; } if (this.DropDownMaxSize != Size.Empty) { popup.MaximumSize = this.DropDownMaxSize; } if (popup.MinimumSize == Size.Empty) { RadSizablePopupControl sizablePopup = popup as RadSizablePopupControl; Debug.Assert(sizablePopup != null, "Popup is not an RadSizablePopupControl"); float height = (this.listElement.BorderWidth * 2) + (this.listElement.VScrollBar.Visibility == ElementVisibility.Visible ? this.listElement.VScrollBar.FirstButton.Size.Height + this.listElement.VScrollBar.SecondButton.Size.Height : 0) + //this.listElement.HScrollBar.FullBoundingRectangle.Height + (sizablePopup.SizingGrip.Visibility == ElementVisibility.Collapsed ? 0: sizablePopup.SizingGrip.FullBoundingRectangle.Height); //TODO to be refactored - initialy the scroll bar of the list element is visible popup.MinimumSize = new Size(0, (int)Math.Ceiling(this.listElement.Items.Count == 1 ? 0 : height)); } }
public virtual void ShowPopup() { if (!this.CanDisplayPopup()) { return; } RadPopupControlBase popupForm = this.PopupForm; if (popupForm == null) { return; } if (popupForm.ElementTree.RootElement.ElementState != ElementState.Loaded) { this.PopupForm.LoadElementTree(this.GetInitialPopupSize()); } this.UpdatePopupMinMaxSize(popupForm); this.ApplyThemeToPopup(this.PopupForm); Point popupLocation = this.GetPopupLocation(popupForm); popupForm.Size = this.GetPopupSize(popupForm, popupForm.RootElement.MeasureIsDirty || popupForm.RootElement.NeverMeasured); popupForm.HorizontalPopupAlignment = HorizontalPopupAlignment.LeftToLeft; popupForm.VerticalPopupAlignment = VerticalPopupAlignment.TopToBottom; if (this.RightToLeft) { this.popupForm.HorizontalPopupAlignment = HorizontalPopupAlignment.RightToRight; } this.ShowPopupCore(popupForm); popupForm.ShowPopup(new Rectangle(popupLocation, this.ControlBoundingRectangle.Size)); }
/// <summary> /// Gets the screen coordinated where the popup should be displayed. /// </summary> /// <param name="popup"></param> /// <returns></returns> protected virtual Point GetPopupLocation(RadPopupControlBase popup) { Point location = this.ElementTree.Control.PointToScreen(this.ControlBoundingRectangle.Location); return(location); }
//protected override Size GetInitialPopupSize() //{ // if (!this.IsInValidState(true)) // return Size.Empty; // int initialHeight = 0; // int visibleItemsCount = Math.Min(this.maxDropDownItems, this.listElement.Items.Count); // for (int i = 0; i < visibleItemsCount; i++) // { // SizeF desiredSize = this.listElement.Items[i].Height; // initialHeight += (int)desiredSize.Height; // } // return new Size(this.Size.Width, initialHeight); //} protected override Size GetPopupSize(RadPopupControlBase popup, bool measure) { RadSizablePopupControl sizablePopup = popup as RadSizablePopupControl; Debug.Assert(sizablePopup != null, "Popup is not an RadSizablePopupControl"); int itemsCount = this.listElement.Items.Count; if (itemsCount > defaultItemsCountInDropDown || itemsCount == 0) { itemsCount = defaultItemsCountInDropDown; } if (itemsCount > this.maxDropDownItems) { itemsCount = this.maxDropDownItems; } int sizingGripSize = 0; if (sizablePopup.SizingGrip.Visibility == ElementVisibility.Visible) { sizingGripSize = sizablePopup.SizingGrip.FullBoundingRectangle.Height; } int height = itemsCount * (this.ListElement.ItemHeight + this.listElement.Scroller.ItemSpacing) + sizingGripSize + //this.listElement.HScrollBar.FullBoundingRectangle.Height + (int)(this.listElement.BorderWidth * 2); return(new Size(this.Size.Width, height)); }
protected override void UnwirePopupFormEvents(RadPopupControlBase popup) { base.UnwirePopupFormEvents(popup); popup.PopupOpened -= new RadPopupOpenedEventHandler(this.popup_PopupOpened); popup.PopupClosing -= new RadPopupClosingEventHandler(this.popup_PopupClosing); popup.PopupClosed -= new RadPopupClosedEventHandler(this.popup_PopupClosed); popup.PopupOpening -= new RadPopupOpeningEventHandler(this.popup_PopupOpening); }
protected virtual void DisposePopupFormCore(bool dispose) { if (this.popupForm != null) { this.UnwirePopupFormEvents(this.PopupForm); this.popupForm.Dispose(); this.popupForm = null; } }
protected virtual void DisposePopupFormCore(bool dispose) { if (this.popupForm == null) { return; } this.UnwirePopupFormEvents(this.PopupForm); this.popupForm.Dispose(); this.popupForm = (RadPopupControlBase)null; }
protected virtual SizeF ApplySizeConstraints(SizeF desiredSize) { RadPopupControlBase ownerPopup = this.ElementTree.Control as RadPopupControlBase; if (ownerPopup == null) { return(desiredSize); } return(ownerPopup.ApplySizingConstraints(desiredSize.ToSize(), ownerPopup.GetCurrentScreen())); }
protected virtual RadPopupControlBase CreatePopup() { RadPopupControlBase popupControlBase = new RadPopupControlBase((RadElement)this); this.popupStack = this.CreatePopupStack(); popupControlBase.RootElement.Children.Add((RadElement)this.popupStack); popupControlBase.AnimationEnabled = true; popupControlBase.DropDownAnimationDirection = RadDirection.Right; popupControlBase.AnimationType = PopupAnimationTypes.Easing; popupControlBase.PopupClosing += new RadPopupClosingEventHandler(this.Popup_PopupClosing); return(popupControlBase); }
protected override void UpdatePopupMinMaxSize(RadPopupControlBase popup) { if (this.DropDownMinSize != Size.Empty) { popup.MinimumSize = this.DropDownMinSize; } if (!(this.DropDownMaxSize != Size.Empty)) { return; } popup.MaximumSize = this.DropDownMaxSize; }
protected internal virtual RadPopupControlBase GetPopupForm() { if (this.popupForm == null && !this.IsDisposed) { this.popupForm = this.CreatePopupForm(); this.popupForm.PopupOpening += new RadPopupOpeningEventHandler(this.OnPopupForm_Opening); this.popupForm.PopupOpened += new RadPopupOpenedEventHandler(this.OnPopupForm_Opened); this.popupForm.PopupClosing += new RadPopupClosingEventHandler(this.OnPopupForm_Closing); this.popupForm.PopupClosed += new RadPopupClosedEventHandler(this.OnPopupForm_Closed); } return(this.popupForm); }
void comboPopup_PopupClosing(object sender, RadPopupClosingEventArgs args) { if (this.popupShown)// && args.CloseReason == RadPopupCloseReason.Keyboard) { this.popup.Hide(); //selectedItem.OwnerElement.SelectedItem = selectedItem; } RadPopupControlBase comboPopup = sender as RadPopupControlBase; comboPopup.PopupClosing -= comboPopup_PopupClosing; }
/// <summary> /// Displays the popup on the screen. /// </summary> public virtual void ShowPopup() { if (!this.CanDisplayPopup()) { return; } RadPopupControlBase popup = this.PopupForm; if (popup == null) { return; } //explicitly load the element tree as the layout is needed in order to perform size calculations if (popup.ElementTree.RootElement.ElementState != ElementState.Loaded) { Size size = this.GetInitialPopupSize(); this.PopupForm.LoadElementTree(size); } //explicitly syncronize the theme with our RadControl host this.UpdatePopupMinMaxSize(popup); this.ApplyThemeToPopup(this.PopupForm); //update popup's bounds on the screen Point location = this.GetPopupLocation(popup); popup.Size = this.GetPopupSize(popup, popup.RootElement.GetBitState(MeasureDirtyStateKey) || popup.RootElement.GetBitState(NeverMeasuredStateKey)); popup.HorizontalPopupAlignment = HorizontalPopupAlignment.LeftToLeft; popup.VerticalPopupAlignment = VerticalPopupAlignment.TopToBottom; if (this.RightToLeft) { //The right edge of the popup form is aligned to the right //edge of the Combo Box control. popupForm.HorizontalPopupAlignment = HorizontalPopupAlignment.RightToRight; } this.ShowPopupCore(popup); popup.ShowPopup(new Rectangle(location, this.ControlBoundingRectangle.Size)); }
public static void ApplyThemeToPopup(RadElementTree elementTree, RadPopupControlBase popup) { string str = "ControlDefault"; if (elementTree != null && elementTree.ComponentTreeHandler != null && !string.IsNullOrEmpty(elementTree.ComponentTreeHandler.ThemeName)) { str = elementTree.ComponentTreeHandler.ThemeName; } if (!(popup.ThemeName != str)) { return; } popup.ThemeName = str; if (popup.RootElement.ElementState != ElementState.Loaded) { return; } popup.RootElement.UpdateLayout(); }
/// <summary> /// Syncronizes the theme of the editor itself with the popup that is about to be displayed. /// </summary> /// <param name="popup"></param> protected virtual void ApplyThemeToPopup(RadPopupControlBase popup) { string popupThemeName = "ControlDefault"; if (this.ElementTree != null && this.ElementTree.ComponentTreeHandler != null && !string.IsNullOrEmpty(this.ElementTree.ComponentTreeHandler.ThemeName)) { popupThemeName = this.ElementTree.ComponentTreeHandler.ThemeName; } if (popup.ThemeName != popupThemeName) { popup.ThemeName = popupThemeName; //force layout update if the popup's root element is already loaded if (popup.RootElement.ElementState == ElementState.Loaded) { popup.RootElement.UpdateLayout(); } } }
protected override Size GetPopupSize(RadPopupControlBase popup, bool measure) { Size empty = Size.Empty; Size size; if ((SizeF)this.oldPopupSize != SizeF.Empty) { size = this.oldPopupSize; } else { this.PopupContentElement.InvalidateMeasure(); this.PopupContentElement.Measure(new SizeF(float.PositiveInfinity, float.PositiveInfinity)); size = this.PopupContentElement.DesiredSize.ToSize(); if (this.TwoTablesForTime && !this.PopupContentElement.IsAmPmMode()) { size.Height += this.PopupContentElement.RowHeight * this.PopupContentElement.MinutesTable.ContentElement.Rows.Count; } } size.Width = Math.Max(this.PopupMinSize.Width, size.Width); size.Height = Math.Max(this.PopupMinSize.Height, size.Height); return(size); }
protected override Size GetPopupSize(RadPopupControlBase popup, bool measure) { Size size = this.defaultPopupSize; if (this.popup != null && popup.Controls.Count > 0) { if (this.DropDownSizingMode == SizingMode.None) { size = new Size(popup.Controls[0].Size.Width, popup.Controls[0].Size.Height); } else { int height = this.popup.SizingGrip.MinSize.Height; size = new Size(popup.Controls[0].Size.Width, popup.Controls[0].Size.Height + height); } } SizeF scaleFactor = new SizeF(1f, 1f); if (this.popup.LastShowDpiScaleFactor != this.DpiScaleFactor) { scaleFactor = new SizeF(this.DpiScaleFactor.Width / this.popup.LastShowDpiScaleFactor.Width, this.DpiScaleFactor.Height / this.popup.LastShowDpiScaleFactor.Height); } return(TelerikDpiHelper.ScaleSize(size, scaleFactor)); }
protected virtual SizeF ApplySizeConstraints(SizeF desiredSize) { RadPopupControlBase control1 = this.ElementTree.Control as RadPopupControlBase; if (control1 == null) { return(desiredSize); } RadDropDownMenu control2 = this.ElementTree.Control as RadDropDownMenu; if (control2 == null) { return((SizeF)control1.ApplySizingConstraints(desiredSize.ToSize(), control1.GetCurrentScreen())); } RadMenuItem ownerElement = control2.OwnerElement as RadMenuItem; if (ownerElement == null) { return((SizeF)control1.ApplySizingConstraints(desiredSize.ToSize(), control1.GetCurrentScreen())); } Control ownerControl = ownerElement.OwnerControl; return((SizeF)control1.ApplySizingConstraints(desiredSize.ToSize(), Screen.FromControl(ownerControl ?? (Control)control2))); }
protected virtual void ShowPopupCore(RadPopupControlBase popup) { }
protected virtual void UnwirePopupFormEvents(RadPopupControlBase popup) { }
protected virtual void ApplyThemeToPopup(RadPopupControlBase popup) { PopupEditorBaseElement.ApplyThemeToPopup((RadElementTree)this.ElementTree, popup); }
protected virtual void UpdatePopupMinMaxSize(RadPopupControlBase popup) { }
protected virtual Size GetPopupSize(RadPopupControlBase popup, bool measure) { return(Size.Empty); }
protected override Size GetPopupSize(RadPopupControlBase popup, bool measure) { RadSizablePopupControl sizablePopupControl = popup as RadSizablePopupControl; int num1 = this.listElement.Items.Count; CheckedItemTraverser traverser = this.listElement.Scroller.Traverser as CheckedItemTraverser; if (traverser != null && traverser.CheckAll) { ++num1; } if (num1 > this.defaultItemsCountInDropDown || num1 == 0) { num1 = this.defaultItemsCountInDropDown; } if (num1 > this.maxDropDownItems && this.maxDropDownItems > 0) { num1 = this.maxDropDownItems; } int num2 = 0; if (sizablePopupControl.SizingGrip.Visibility == ElementVisibility.Visible) { RadElement sizingGrip = (RadElement)sizablePopupControl.SizingGrip; num2 = new Rectangle(sizingGrip.BoundingRectangle.Location, Size.Add(sizingGrip.BoundingRectangle.Size, sizingGrip.Margin.Size)).Height; } int num3 = 0; if (!this.listElement.AutoSizeItems) { int num4 = this.listElement.ItemHeight; for (int index = 0; index < num1 && index < this.listElement.Items.Count; ++index) { if (this.listElement.Items[index] is DescriptionTextListDataItem || this.listElement.IsDescriptionText) { num4 *= 2; break; } } if (this.ListElement.DpiScaleFactor != this.Popup.OwnerElement.DpiScaleFactor) { num4 = TelerikDpiHelper.ScaleInt(num4, this.Popup.OwnerElement.DpiScaleFactor); } int height = num1 * (num4 + this.listElement.Scroller.ItemSpacing) + num2 + (int)((double)this.listElement.BorderWidth * 2.0); if (this.DropDownHeight != 106) { height = this.DropDownHeight; } return(new Size(this.Size.Width, height)); } int height1; if (this.listElement.Items.Count > 0) { for (int index = 0; index < num1 && index < this.listElement.Items.Count; ++index) { num3 += (int)this.listElement.Items[index].MeasuredSize.Height + this.listElement.Scroller.ItemSpacing; } height1 = num3 + this.listElement.Scroller.ItemSpacing + num2 + this.listElement.HScrollBar.Size.Height + (int)((double)this.listElement.BorderWidth * 2.0); } else { height1 = num1 * (this.listElement.ItemHeight + this.listElement.Scroller.ItemSpacing) + num2 + (int)((double)this.listElement.BorderWidth * 2.0); } if (this.DropDownHeight != 106) { height1 = this.DropDownHeight; } return(new Size(this.Size.Width, height1)); }
protected override Size GetPopupSize(RadPopupControlBase popup, bool measure) { return(this.popupSize); }