public virtual void Synchronize()
 {
     if (this.Data.ChatMessagesViewElement.ShowAvatars)
     {
         if (this.Data.MessageType == ChatMessageType.Single || this.Data.MessageType == ChatMessageType.First)
         {
             this.AvatarPictureElement.Visibility = ElementVisibility.Visible;
         }
         else
         {
             this.AvatarPictureElement.Visibility = ElementVisibility.Hidden;
         }
     }
     else
     {
         this.AvatarPictureElement.Visibility = ElementVisibility.Collapsed;
     }
     if (this.Data.MessageType == ChatMessageType.Single || this.Data.MessageType == ChatMessageType.First)
     {
         this.NameLabelElement.Visibility = ElementVisibility.Visible;
     }
     else
     {
         this.NameLabelElement.Visibility = ElementVisibility.Collapsed;
     }
     this.StatusLabelElement.Visibility = this.Data.MessageType == ChatMessageType.Single || this.Data.MessageType == ChatMessageType.Last ? ElementVisibility.Visible : ElementVisibility.Collapsed;
     this.IsOwnMessage = this.Data.IsOwnMessage;
     this.AvatarPictureElement.Image   = this.Data.Message.Author.Avatar;
     this.AvatarPictureElement.MaxSize = TelerikDpiHelper.ScaleSize(Size.Round(this.Data.ChatMessagesViewElement.AvatarSize), new SizeF(1f / this.DpiScaleFactor.Width, 1f / this.DpiScaleFactor.Height));
     this.NameLabelElement.Text        = this.GetNameLabelText();
     this.StatusLabelElement.Text      = this.Data.Status;
     this.Data.ChatMessagesViewElement.ChatElement.OnItemFormatting(new ChatItemElementEventArgs(this));
 }
Exemple #2
0
        private int GetHorizontalLocation(RadDesktopAlert alert)
        {
            Size size = alert.Popup.NonAnimatedSize;

            if (alert.Popup.LastShowDpiScaleFactor.IsEmpty)
            {
                size = TelerikDpiHelper.ScaleSize(size, alert.DpiScaleElement.DpiScaleFactor);
            }
            switch (alert.ScreenPosition)
            {
            case AlertScreenPosition.BottomRight:
            case AlertScreenPosition.TopRight:
                return(this.activeScreen.WorkingArea.X + this.activeScreen.WorkingArea.Width - size.Width);

            case AlertScreenPosition.BottomCenter:
            case AlertScreenPosition.TopCenter:
                return(this.activeScreen.WorkingArea.X + (this.activeScreen.WorkingArea.Width - size.Width) / 2);

            case AlertScreenPosition.BottomLeft:
            case AlertScreenPosition.TopLeft:
                return(this.activeScreen.WorkingArea.X);

            default:
                return(this.activeScreen.WorkingArea.X);
            }
        }
        private Size GetDropDownSize()
        {
            Size  size         = Size.Empty;
            SizeF scaleFactor1 = this.PopupControl == null || this.PopupControl.OwnerElement == null ? new SizeF(1f, 1f) : this.PopupControl.OwnerElement.DpiScaleFactor;
            int   val1         = TelerikDpiHelper.ScaleInt(185, scaleFactor1);

            size = new Size(Math.Max(val1, this.dateTimePickerElement.ControlBoundingRectangle.Width), Math.Max(val1, TelerikDpiHelper.ScaleInt(this.dropDownHeight, scaleFactor1)));
            if (this.dateTimePickerElement.ElementTree != null)
            {
                if (size.Width == -1)
                {
                    size.Width = this.dateTimePickerElement.ElementTree.Control.Width;
                }
                size.Height = TelerikDpiHelper.ScaleInt(this.dropDownHeight, scaleFactor1) + (this.DropDownSizingMode != SizingMode.None ? 10 : 0);
                if (this.dateTimePickerElement.CalendarSize != new Size(100, 156))
                {
                    size = this.dateTimePickerElement.CalendarSize;
                }
                size = new Size(size.Width, size.Height);
                if (this.cachedSize != Size.Empty)
                {
                    size = this.cachedSize;
                }
                if (this.LastShowDpiScale != scaleFactor1)
                {
                    SizeF scaleFactor2 = new SizeF(this.DateTimePickerElement.DpiScaleFactor.Width / this.LastShowDpiScale.Width, this.DateTimePickerElement.DpiScaleFactor.Height / this.LastShowDpiScale.Height);
                    this.LastShowDpiScale = this.DateTimePickerElement.DpiScaleFactor;
                    size = TelerikDpiHelper.ScaleSize(size, scaleFactor2);
                }
            }
            return(size);
        }
Exemple #4
0
        public virtual void Collapse()
        {
            if (this.IsCollapsed)
            {
                return;
            }
            CancelEventArgs e = new CancelEventArgs();

            this.OnCollapsing(e);
            if (e.Cancel)
            {
                return;
            }
            this.IsCollapsed = true;
            foreach (LightVisualElement lightVisualElement in (IEnumerable <RadPageViewItem>) this.Items)
            {
                lightVisualElement.DrawText = false;
            }
            NavigationViewDisplayModes effectiveDisplayMode = this.GetEffectiveDisplayMode((float)this.Size.Width);

            if (effectiveDisplayMode == NavigationViewDisplayModes.Expanded)
            {
                if (this.AllowAnimation)
                {
                    Size size1 = new Size(TelerikDpiHelper.ScaleInt(this.ExpandedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    Size size2 = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    AnimatedPropertySetting animatedPropertySetting = new AnimatedPropertySetting(RadElement.MinSizeProperty, (object)size1, (object)size2, this.AnimationFrames, this.AnimationInterval);
                    animatedPropertySetting.AnimationFinished += (AnimationFinishedEventHandler)((param0, param1) => this.OnCollapsed(EventArgs.Empty));
                    animatedPropertySetting.ApplyValue((RadObject)this.ItemContainer);
                }
                else
                {
                    this.ItemContainer.MinSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    this.OnCollapsed(EventArgs.Empty);
                }
            }
            else
            {
                this.programmaticallyClosingPopup = true;
                this.Popup.ClosePopup(RadPopupCloseReason.Mouse);
                this.HamburgerButton.StretchHorizontally = false;
                this.programmaticallyClosingPopup        = false;
                if (effectiveDisplayMode == NavigationViewDisplayModes.Compact)
                {
                    this.ItemContainer.MinSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    this.ItemContainer.MaxSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                    if (!this.Children.Contains((RadElement)this.ItemContainer))
                    {
                        int num = (int)this.Popup.RootElement.ResetValue(VisualElement.BackColorProperty, ValueResetFlags.Local);
                        this.Children.Insert(0, (RadElement)this.ItemContainer);
                    }
                }
                if (!this.Children.Contains((RadElement)this.HamburgerButton))
                {
                    int num = (int)this.HamburgerButton.ResetValue(RadElement.AlignmentProperty, ValueResetFlags.Local);
                    this.Children.Add((RadElement)this.HamburgerButton);
                }
                this.OnCollapsed(EventArgs.Empty);
            }
        }
Exemple #5
0
        private void HandleDpiChanged()
        {
            float num = 1f;

            if (this.oldDpi != 0)
            {
                num = (float)this.currentDpi / (float)this.oldDpi;
            }
            else if (this.oldDpi == 0)
            {
                num = (float)this.currentDpi / 96f;
            }
            if ((double)num == 1.0)
            {
                return;
            }
            this.maxSizeState = this.MaximumSize;
            this.minSizeState = this.MinimumSize;
            this.MinimumSize  = Size.Empty;
            this.MaximumSize  = Size.Empty;
            this.SaveAnchorStates();
            this.Scale(new SizeF(num, num));
            this.RestoreAnchorStates();
            this.MinimumSize = TelerikDpiHelper.ScaleSize(this.minSizeState, new SizeF(num, num));
            this.MaximumSize = TelerikDpiHelper.ScaleSize(this.maxSizeState, new SizeF(num, num));
        }
Exemple #6
0
 public override SizeF Measure(SizeF availableSize)
 {
     if (this.Owner.Image != null)
     {
         lock (this.Owner.Image)
         {
             if (this.Owner.ImageLayout == ImageLayout.Zoom)
             {
                 float f    = Math.Min(availableSize.Width / (float)this.Owner.Image.Width, availableSize.Height / (float)this.Owner.Image.Height);
                 int   num1 = (int)Math.Round((double)this.Owner.Image.Width * (double)f);
                 int   num2 = (int)Math.Round((double)this.Owner.Image.Height * (double)f);
                 if (float.IsInfinity(f))
                 {
                     num1 = num2 = 0;
                 }
                 this.DesiredSize = new SizeF((float)num1, (float)num2);
             }
             else
             {
                 this.DesiredSize = TelerikDpiHelper.ScaleSizeF((SizeF)this.Owner.Image.Size, this.Owner.DpiScaleFactor);
             }
         }
     }
     else
     {
         this.DesiredSize = SizeF.Empty;
     }
     this.DesiredSize = new SizeF(Math.Min(availableSize.Width, this.DesiredSize.Width), Math.Min(availableSize.Height, this.DesiredSize.Height));
     return(this.DesiredSize);
 }
        public void Show()
        {
            if (DesktopAlertManager.Instance.ContainsAlert(this))
            {
                return;
            }
            RadPopupOpeningEventArgs args = new RadPopupOpeningEventArgs(this.popup.Location);

            this.OnPopupOpening((object)this, args);
            if (args.Cancel)
            {
                return;
            }
            SizeF monitorDpi = Telerik.WinControls.NativeMethods.GetMonitorDpi(Screen.FromPoint(this.Popup.Location), Telerik.WinControls.NativeMethods.DpiType.Effective);

            this.DpiScaleElement.DpiScaleChanged(monitorDpi);
            Size size = this.GetPopupSize();

            if (this.Popup.LastShowDpiScaleFactor.IsEmpty)
            {
                size = TelerikDpiHelper.ScaleSize(size, new SizeF(1f / monitorDpi.Width, 1f / monitorDpi.Height));
            }
            this.popup.Size = size;
            DesktopAlertManager.Instance.AddAlert(this);
            this.popup.Show(this.popup.Location);
            if (!PopupManager.Default.ContainsPopup((IPopupControl)this.popup) || !this.playSound || this.soundToPlay == null)
            {
                return;
            }
            this.soundToPlay.Play();
        }
Exemple #8
0
        protected override void ShowPopupCore(Size size, Point location)
        {
            SizeF dpiScaleFactor = this.ownerAlert.DpiScaleElement.DpiScaleFactor;
            bool  isEmpty        = this.LastShowDpiScaleFactor.IsEmpty;

            if (this.LastShowDpiScaleFactor != dpiScaleFactor)
            {
                if (isEmpty)
                {
                    this.LastShowDpiScaleFactor = new SizeF(1f, 1f);
                }
                SizeF factor = new SizeF(dpiScaleFactor.Width / this.LastShowDpiScaleFactor.Width, dpiScaleFactor.Height / this.LastShowDpiScaleFactor.Height);
                this.LastShowDpiScaleFactor = dpiScaleFactor;
                this.Scale(factor);
                if (isEmpty)
                {
                    size = TelerikDpiHelper.ScaleSize(size, new SizeF(1f / factor.Width, 1f / factor.Height));
                }
            }
            this.SetBoundsCore(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
            Telerik.WinControls.NativeMethods.ShowWindow(this.Handle, 4);
            if (DWMAPI.IsCompositionEnabled && this.EnableAeroEffects)
            {
                this.UpdateAeroEffectState();
            }
            ControlHelper.BringToFront(this.Handle, false);
        }
Exemple #9
0
 protected override SizeF MeasureOverride(SizeF availableSize)
 {
     if (this.imageEditorElement != null && this.imageEditorElement.CurrentBitmap != null)
     {
         return((SizeF)TelerikDpiHelper.ScaleSize(this.imageEditorElement.CurrentBitmap.Size, this.imageEditorElement.ZoomFactor));
     }
     return(base.MeasureOverride(availableSize));
 }
        protected SizeF ApplyClientOffset(SizeF measured)
        {
            Padding padding1 = this.Padding;
            Padding padding2 = TelerikDpiHelper.ScalePadding(this.GetBorderThickness(true), this.DpiScaleFactor);

            measured.Width  += (float)(padding1.Horizontal + padding2.Horizontal);
            measured.Height += (float)(padding1.Vertical + padding2.Vertical);
            return(measured);
        }
Exemple #11
0
        protected virtual void EnsureDisplayMode(NavigationViewDisplayModes mode)
        {
            switch (mode)
            {
            case NavigationViewDisplayModes.Minimal:
                this.ItemContainer.MaxSize = Size.Empty;
                this.HamburgerButton.StretchHorizontally = false;
                if (!this.PopupStack.Children.Contains((RadElement)this.ItemContainer))
                {
                    this.PopupStack.Children.Add((RadElement)this.ItemContainer);
                }
                if (this.Children.Contains((RadElement)this.HamburgerButton))
                {
                    break;
                }
                this.Children.Add((RadElement)this.HamburgerButton);
                break;

            case NavigationViewDisplayModes.Compact:
                foreach (LightVisualElement lightVisualElement in (IEnumerable <RadPageViewItem>) this.Items)
                {
                    lightVisualElement.DrawText = false;
                }
                this.HamburgerButton.StretchHorizontally = false;
                this.ItemContainer.MinSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                this.ItemContainer.MaxSize = new Size(TelerikDpiHelper.ScaleInt(this.CollapsedPaneWidth, new SizeF(1f / this.DpiScaleFactor.Width, 0.0f)), 0);
                if (!this.Children.Contains((RadElement)this.ItemContainer))
                {
                    this.Children.Insert(0, (RadElement)this.ItemContainer);
                }
                if (this.Children.Contains((RadElement)this.HamburgerButton))
                {
                    break;
                }
                this.Children.Add((RadElement)this.HamburgerButton);
                break;

            case NavigationViewDisplayModes.Expanded:
                foreach (LightVisualElement lightVisualElement in (IEnumerable <RadPageViewItem>) this.Items)
                {
                    lightVisualElement.DrawText = !this.IsCollapsed;
                }
                this.ItemContainer.MaxSize = Size.Empty;
                this.HamburgerButton.StretchHorizontally = true;
                if (!this.Children.Contains((RadElement)this.ItemContainer))
                {
                    this.Children.Insert(0, (RadElement)this.ItemContainer);
                }
                if (this.Children.Contains((RadElement)this.ItemContainer))
                {
                    break;
                }
                this.Children.Add((RadElement)this.HamburgerButton);
                break;
            }
        }
        protected override void AddBlockDesiredSize(SizeF blockDesiredSize, LineInfo line)
        {
            base.AddBlockDesiredSize(blockDesiredSize, line);
            SizeF size = line.Size;
            float num  = Math.Max(size.Height, this.MinLineHeight);

            this.MinLineHeight = TelerikDpiHelper.ScaleFloat(num, new SizeF(1f / this.DpiScaleFactor.Width, 1f / this.DpiScaleFactor.Height));
            size.Height        = num;
            line.Size          = size;
        }
        protected override Size GetBackupSize()
        {
            SizeF scaleFactor = new SizeF(1f, 1f);

            if (this.LastShowDpiScaleFactor.IsEmpty)
            {
                scaleFactor = new SizeF(1f / this.OwnerElement.DpiScaleFactor.Width, 1f / this.OwnerElement.DpiScaleFactor.Height);
            }
            return(TelerikDpiHelper.ScaleSize(this.Size, scaleFactor));
        }
 protected override void HandleDpiChanged()
 {
     if (TelerikHelper.IsWindows8OrLower || TelerikHelper.IsWindows10CreatorsUpdateOrHigher)
     {
         this.Scale(TelerikDpiHelper.ScaleSizeF(Telerik.WinControls.NativeMethods.GetMonitorDpi(Screen.FromControl((Control)this), Telerik.WinControls.NativeMethods.DpiType.Effective), new SizeF(1f / this.RootElement.DpiScaleFactor.Width, 1f / this.RootElement.DpiScaleFactor.Height)));
     }
     else
     {
         base.HandleDpiChanged();
     }
 }
Exemple #15
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (TelerikHelper.IsMaterialTheme(this.ThemeName))
     {
         this.ClientSize = TelerikDpiHelper.ScaleSize(new Size(438, 377), this.RootElement.DpiScaleFactor);
     }
     else
     {
         this.ClientSize = TelerikDpiHelper.ScaleSize(new Size(292, 251), this.RootElement.DpiScaleFactor);
     }
 }
Exemple #16
0
        private int GetBottomTopLocation(RadDesktopAlert alert)
        {
            Size size = alert.Popup.NonAnimatedSize;

            if (alert.Popup.LastShowDpiScaleFactor.IsEmpty)
            {
                size = TelerikDpiHelper.ScaleSize(size, alert.DpiScaleElement.DpiScaleFactor);
            }
            int initialOffset = this.activeScreen.WorkingArea.Height - size.Height + this.activeScreen.WorkingArea.Y;

            this.EvaluateAlertOffset(alert, ref initialOffset, false);
            return(initialOffset);
        }
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            SizeF sizeF1 = base.MeasureOverride(availableSize);

            if (this.Data == null)
            {
                return(sizeF1);
            }
            this.MainMessageElement.Measure((SizeF)TelerikDpiHelper.ScaleSize(((MediaMessageDataItem)this.Data).MediaMessage.Size, this.DpiScaleFactor));
            SizeF sizeF2 = new SizeF(this.AvatarPictureElement.DesiredSize.Width + this.MainMessageElement.DesiredSize.Width + (float)this.Margin.Horizontal, Math.Max(this.AvatarPictureElement.DesiredSize.Height, this.MainMessageElement.DesiredSize.Height) + this.NameLabelElement.DesiredSize.Height + (float)this.Margin.Vertical);

            this.Data.ActualSize = sizeF2;
            return(sizeF2);
        }
Exemple #18
0
        private void SynchronizeWithParentBorderThickness()
        {
            RadElement parent = this.Parent;

            if (parent is BorderPrimitive || parent == null)
            {
                return;
            }
            if (this.Visibility == ElementVisibility.Collapsed)
            {
                parent.BorderThickness = new Padding(0);
            }
            else
            {
                parent.BorderThickness = TelerikDpiHelper.ScalePadding(this.GetBorderThickness(), new SizeF(1f / this.DpiScaleFactor.Width, 1f / this.DpiScaleFactor.Height));
            }
        }
Exemple #19
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (TelerikHelper.IsMaterialTheme(this.ThemeName))
     {
         this.ClientSize = TelerikDpiHelper.ScaleSize(new Size(438, 684), this.RootElement.DpiScaleFactor);
     }
     else
     {
         this.ClientSize = TelerikDpiHelper.ScaleSize(new Size(292, 456), this.RootElement.DpiScaleFactor);
     }
     this.radSpinEditorHorizontalPosition.Maximum          = (Decimal)this.ImageEditorElement.CurrentBitmap.Width;
     this.radSpinEditorVerticalPosition.Maximum            = (Decimal)this.ImageEditorElement.CurrentBitmap.Height;
     this.radTrackBarHorizontalPosition.LargeTickFrequency = this.ImageEditorElement.CurrentBitmap.Width;
     this.radTrackBarVerticalPosition.LargeTickFrequency   = this.ImageEditorElement.CurrentBitmap.Height;
     this.radTrackBarHorizontalPosition.Maximum            = (float)this.ImageEditorElement.CurrentBitmap.Width;
     this.radTrackBarVerticalPosition.Maximum = (float)this.ImageEditorElement.CurrentBitmap.Height;
 }
 private void DoScroll(Point oldValue, Point newValue)
 {
     if (this.viewport == null)
     {
         return;
     }
     this.BitState[274877906944L] = true;
     if (this.UsePhysicalScrolling)
     {
         SizeF scaleFactor = new SizeF(1f / this.DpiScaleFactor.Width, 1f / this.DpiScaleFactor.Height);
         this.viewport.PositionOffset = new SizeF((float)-TelerikDpiHelper.ScaleInt(newValue.X, scaleFactor), (float)-TelerikDpiHelper.ScaleInt(newValue.Y, scaleFactor));
     }
     else
     {
         ((IRadScrollViewport)this.viewport).DoScroll(oldValue, newValue);
     }
     this.BitState[274877906944L] = false;
     this.OnScroll(oldValue, newValue);
 }
 protected virtual void PaintElements(
     IGraphics graphics,
     ISymbology symbology,
     IElementFactory elementFactory)
 {
     if (symbology is PDF417)
     {
         graphics.TranslateTransform((float)(((double)this.Bounds.Width - (double)elementFactory.ElementsBounds.Width) / 2.0), (float)(((double)this.Bounds.Height - (double)elementFactory.ElementsBounds.Height) / 2.0));
     }
     else if (symbology is QRCode)
     {
         TelerikDpiHelper.ScaleInt(4, this.DpiScaleFactor);
     }
     (graphics.UnderlayGraphics as Graphics).Clear(this.BackColor);
     foreach (BarcodeElementBase element in elementFactory.Elements)
     {
         element.PaintElement(graphics.UnderlayGraphics as Graphics);
     }
 }
        private void MeasureWithFillPanel()
        {
            int availableLength = this.layoutInfo.availableLength;
            int num1            = 0;
            int count           = this.layoutInfo.layoutTargets.Count;

            for (int index = 0; index < count; ++index)
            {
                SplitPanel layoutTarget = this.layoutInfo.layoutTargets[index];
                if (layoutTarget != this.layoutInfo.fillPanel)
                {
                    num1 += this.GetLength(layoutTarget.SizeInfo.AbsoluteSize);
                }
            }
            SplitPanelSizeInfo sizeInfo = this.layoutInfo.fillPanel.SizeInfo;
            int num2      = this.layoutInfo.availableLength - this.layoutInfo.totalSplitterLength;
            int num3      = 0;
            int minLength = sizeInfo.minLength;

            if (num1 + minLength > num2)
            {
                num3 = num1 + minLength - num2;
            }
            int num4 = num3;

            for (int index = 0; index < this.layoutInfo.layoutTargets.Count; ++index)
            {
                SplitPanel layoutTarget = this.layoutInfo.layoutTargets[index];
                if (layoutTarget != this.layoutInfo.fillPanel)
                {
                    int length = this.GetLength(TelerikDpiHelper.ScaleSize(layoutTarget.SizeInfo.AbsoluteSize, new SizeF(1f / layoutTarget.SplitPanelElement.DpiScaleFactor.Width, 1f / layoutTarget.SplitPanelElement.DpiScaleFactor.Height)));
                    if (num4 > 0 && layoutTarget.SizeInfo.SizeMode != SplitPanelSizeMode.Absolute)
                    {
                        int num5 = Math.Max(1, (int)((double)((float)length / (float)num1) * (double)num3));
                        num4   -= num5;
                        length -= num5;
                    }
                    layoutTarget.SizeInfo.MeasuredLength = length;
                    availableLength -= layoutTarget.SizeInfo.MeasuredLength + this.layoutInfo.splitterLength;
                }
            }
            this.layoutInfo.fillPanel.SizeInfo.MeasuredLength = availableLength;
        }
Exemple #23
0
        protected override void PaintElement(IGraphics graphics, float angle, SizeF scale)
        {
            if (this.IsCropping)
            {
                Rectangle cropRectangle = this.GetCropRectangle();
                SizeF     scaleFactor   = new SizeF(1f / this.DpiScaleFactor.Width, 1f / this.DpiScaleFactor.Height);
                this.AcceptButton.PositionOffset = TelerikDpiHelper.ScaleSizeF(new SizeF((float)cropRectangle.X + (float)cropRectangle.Width / 2f - (float)this.AcceptButton.Location.X - this.AcceptButton.DesiredSize.Width, (float)(cropRectangle.Y + cropRectangle.Height) + (float)this.CropHandlesSize.Height / 2f - (float)this.AcceptButton.Location.Y), scaleFactor);
                this.CancelButton.PositionOffset = TelerikDpiHelper.ScaleSizeF(new SizeF((float)cropRectangle.X + (float)cropRectangle.Width / 2f - (float)this.CancelButton.Location.X - this.CancelButton.DesiredSize.Width, (float)(cropRectangle.Y + cropRectangle.Height) + (float)this.CropHandlesSize.Height / 2f - (float)this.CancelButton.Location.Y), scaleFactor);
            }
            base.PaintElement(graphics, angle, scale);
            if (this.imageEditorElement.CurrentBitmap == null)
            {
                return;
            }
            Graphics  underlayGraphics   = (Graphics)graphics.UnderlayGraphics;
            Rectangle imageDrawRectangle = this.GetImageDrawRectangle();

            underlayGraphics.DrawImage((Image)this.imageEditorElement.CurrentBitmap, imageDrawRectangle);
            if (!this.IsCropping)
            {
                return;
            }
            RectangleF srcRect        = new RectangleF((float)this.imageEditorElement.CurrentBitmap.Width * this.RelativeCropRect.X, (float)this.imageEditorElement.CurrentBitmap.Height * this.RelativeCropRect.Y, (float)this.imageEditorElement.CurrentBitmap.Width * this.RelativeCropRect.Width, (float)this.imageEditorElement.CurrentBitmap.Height * this.RelativeCropRect.Height);
            Rectangle  cropRectangle1 = this.GetCropRectangle();
            SizeF      sizeF1         = new SizeF((float)this.CropHandlesSize.Width / 2f, (float)this.CropHandlesSize.Height / 2f);

            graphics.FillRectangle(imageDrawRectangle, Color.FromArgb(100, Color.White));
            underlayGraphics.DrawImage((Image)this.imageEditorElement.CurrentBitmap, (RectangleF)cropRectangle1, srcRect, GraphicsUnit.Pixel);
            underlayGraphics.DrawRectangle(Pens.OrangeRed, cropRectangle1);
            underlayGraphics.FillRectangle(Brushes.OrangeRed, new RectangleF((float)cropRectangle1.X - sizeF1.Width, (float)cropRectangle1.Y - sizeF1.Height, (float)this.CropHandlesSize.Width, (float)this.CropHandlesSize.Height));
            underlayGraphics.FillRectangle(Brushes.OrangeRed, new RectangleF((float)cropRectangle1.Right - sizeF1.Width, (float)cropRectangle1.Y - sizeF1.Height, (float)this.CropHandlesSize.Width, (float)this.CropHandlesSize.Height));
            underlayGraphics.FillRectangle(Brushes.OrangeRed, new RectangleF((float)cropRectangle1.X - sizeF1.Width, (float)cropRectangle1.Bottom - sizeF1.Height, (float)this.CropHandlesSize.Width, (float)this.CropHandlesSize.Height));
            underlayGraphics.FillRectangle(Brushes.OrangeRed, new RectangleF((float)cropRectangle1.Right - sizeF1.Width, (float)cropRectangle1.Bottom - sizeF1.Height, (float)this.CropHandlesSize.Width, (float)this.CropHandlesSize.Height));
            string str1   = string.Format("X={0}, Y={1}", (object)(cropRectangle1.X - imageDrawRectangle.X), (object)(cropRectangle1.Y - imageDrawRectangle.Y));
            SizeF  sizeF2 = underlayGraphics.MeasureString(str1, this.GetScaledFont(this.DpiScaleFactor.Height));

            underlayGraphics.DrawString(str1, this.GetScaledFont(this.DpiScaleFactor.Height), Brushes.OrangeRed, (float)cropRectangle1.X - sizeF1.Width, (float)cropRectangle1.Y - sizeF1.Height - sizeF2.Height);
            string str2   = string.Format("{0} x {1} px", (object)cropRectangle1.Width, (object)cropRectangle1.Height);
            SizeF  sizeF3 = underlayGraphics.MeasureString(str2, this.GetScaledFont(this.DpiScaleFactor.Height));

            underlayGraphics.DrawString(str2, this.GetScaledFont(this.DpiScaleFactor.Height), Brushes.OrangeRed, (float)cropRectangle1.Right + sizeF1.Width - sizeF3.Width, (float)cropRectangle1.Bottom + sizeF1.Height);
        }
        protected override void OnThemeChanged()
        {
            base.OnThemeChanged();
            RadDateTimePickerCalendar currentBehavior = this.dateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;

            if (currentBehavior == null)
            {
                return;
            }
            currentBehavior.Calendar.ThemeName     = this.ThemeName;
            currentBehavior.PopupControl.ThemeName = this.ThemeName;
            if (currentBehavior.ShowTimePicker && currentBehavior.TimePicker != null)
            {
                currentBehavior.TimePicker.ThemeName = this.ThemeName;
                if (currentBehavior.ShowFooter)
                {
                    currentBehavior.FooterPanel.ThemeName = this.ThemeName;
                }
            }
            if (!TelerikHelper.IsMaterialTheme(this.ThemeName))
            {
                return;
            }
            Size size = TelerikDpiHelper.ScaleSize(new Size(300, 390), this.RootElement.DpiScaleFactor);

            if (this.dateTimePickerElement.ShowTimePicker)
            {
                currentBehavior.Calendar.MinimumSize = TelerikDpiHelper.ScaleSize(new Size(300, 0), this.RootElement.DpiScaleFactor);
                size.Width = 590;
            }
            currentBehavior.DropDownMinSize = size;
            RadCalendarElement calendarElement = currentBehavior.Calendar.CalendarElement;

            calendarElement.DrawBorder          = true;
            calendarElement.BorderBoxStyle      = BorderBoxStyle.FourBorders;
            calendarElement.BorderGradientStyle = GradientStyles.Solid;
            calendarElement.BorderBottomColor   = calendarElement.BorderBottomShadowColor = calendarElement.BorderRightColor = calendarElement.BorderRightShadowColor = calendarElement.BorderLeftShadowColor = calendarElement.BorderTopShadowColor = Color.Transparent;
            calendarElement.BorderLeftColor     = calendarElement.BorderTopColor = Color.FromArgb(236, 236, 236);
        }
Exemple #25
0
        protected virtual Size GetPopupSize()
        {
            Size  defaultSize = RadDesktopAlert.DefaultSize;
            SizeF scaleFactor = RadControl.EnableDpiScaling ? Telerik.WinControls.NativeMethods.GetMonitorDpi(Screen.FromPoint(this.Popup.Location), Telerik.WinControls.NativeMethods.DpiType.Effective) : new SizeF(1f, 1f);

            if (this.fixedSize != Size.Empty)
            {
                if (this.FixedSize.Width == 0 || (this.FixedSize.Height != 0 || !this.AutoSize))
                {
                    return(TelerikDpiHelper.ScaleSize(this.fixedSize, scaleFactor));
                }
                defaultSize.Width = this.FixedSize.Width;
            }
            Size desiredSize = new Size(defaultSize.Width, defaultSize.Height);

            this.popup.Size = desiredSize;
            this.popup.LoadElementTree(desiredSize);
            SizeF sizeF = new SizeF((float)defaultSize.Width, this.popup.AlertElement.DesiredSize.Height);

            sizeF = TelerikDpiHelper.ScaleSizeF(sizeF, scaleFactor);
            return(sizeF.ToSize());
        }
        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 override SizeF MeasureOverride(SizeF availableSize)
        {
            SizeF sizeF1 = base.MeasureOverride(availableSize);

            if (this.Value == null)
            {
                return(sizeF1);
            }
            SizeF sizeF2 = this.MeasureSymbology(availableSize);

            if (float.IsInfinity(sizeF2.Width))
            {
                sizeF2.Width = TelerikDpiHelper.ScaleFloat((float)this.DefaultSize.Width, this.DpiScaleFactor);
            }
            if (float.IsInfinity(sizeF2.Height))
            {
                sizeF2.Height = TelerikDpiHelper.ScaleFloat((float)this.DefaultSize.Height, this.DpiScaleFactor);
            }
            if (float.IsInfinity(availableSize.Width) || float.IsInfinity(availableSize.Height))
            {
                return(sizeF2);
            }
            return(availableSize);
        }
        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));
        }
Exemple #29
0
        protected virtual Rectangle GetImageDrawRectangle()
        {
            Size size = TelerikDpiHelper.ScaleSize(this.imageEditorElement.CurrentBitmap.Size, this.imageEditorElement.ZoomFactor);

            return(new Rectangle(this.Size.Width > size.Width ? (this.Size.Width - size.Width) / 2 : 0, this.Size.Height > size.Height ? (this.Size.Height - size.Height) / 2 : 0, size.Width, size.Height));
        }
Exemple #30
0
        protected internal override SizeF GetEditorSize(
            SizeF availableSize,
            DataFilterEditorElement editorElement)
        {
            SizeF sizeF     = availableSize;
            bool  isEditing = this.TreeViewElement.IsEditing;

            if (editorElement == this.fieldElement)
            {
                sizeF.Width = !isEditing || (double)this.cachedFieldElementWidth <= 0.0 ? Math.Max((float)TelerikDpiHelper.ScaleInt(DataFilterCriteriaElement.DefaultFieldWidth, this.DpiScaleFactor), availableSize.Width) : this.cachedFieldElementWidth;
                this.cachedFieldElementWidth = sizeF.Width;
            }
            else if (editorElement == this.operatorElement)
            {
                sizeF.Width = !isEditing || (double)this.cachedOperatorElementWidth <= 0.0 ? Math.Max((float)TelerikDpiHelper.ScaleInt(DataFilterCriteriaElement.DefaultOperatorWidth, this.DpiScaleFactor), availableSize.Width) : this.cachedOperatorElementWidth;
                this.cachedOperatorElementWidth = sizeF.Width;
            }
            else if (editorElement == this.valueElement)
            {
                sizeF.Width = !isEditing || (double)this.cachedValueElementWidth <= 0.0 ? Math.Max((float)TelerikDpiHelper.ScaleInt(DataFilterCriteriaElement.DefaultValueWidth, this.DpiScaleFactor), availableSize.Width) : this.cachedValueElementWidth;
                this.cachedValueElementWidth = sizeF.Width;
            }
            return(sizeF);
        }