protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);
            if (e.Property != RadElement.VisibilityProperty)
            {
                return;
            }
            ComponentThemableElementTree elementTree = this.ElementTree;

            if (elementTree == null)
            {
                return;
            }
            Control control = elementTree.Control;

            if (control == null)
            {
                return;
            }
            RadFormControlBase radFormControlBase = control as RadFormControlBase;

            if (radFormControlBase == null || radFormControlBase.FormBorderStyle == FormBorderStyle.None)
            {
                return;
            }
            radFormControlBase.InvalidateIfNotSuspended();
            radFormControlBase.CallSetClientSizeCore(radFormControlBase.ClientSize.Width, radFormControlBase.ClientSize.Height);
        }
        public override void PaintPrimitive(IGraphics g, float angle, SizeF scale)
        {
            RadRibbonBar control = this.ElementTree.Control as RadRibbonBar;

            if (control == null)
            {
                return;
            }
            RadFormControlBase form = control.FindForm() as RadFormControlBase;

            if (form != null && form.FormBehavior is RadRibbonFormBehavior)
            {
                float num1    = (float)form.Width / (float)control.Width;
                int   offsetX = (form.Width - control.Width) / 2;
                g.TranslateTransform(-offsetX, 0);
                if ((double)num1 != 0.0 && !float.IsInfinity(num1))
                {
                    g.ScaleTransform(new SizeF(num1, 1f));
                }
                base.PaintPrimitive(g, angle, scale);
                g.TranslateTransform(offsetX, 0);
                float num2 = (float)control.Width / (float)form.Width;
                if ((double)num2 == 0.0 || float.IsInfinity(num2))
                {
                    return;
                }
                g.ScaleTransform(new SizeF(num2, 1f));
            }
            else
            {
                base.PaintPrimitive(g, angle, scale);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates an instance of the RadFormBehaviorBase class.
        /// </summary>
        /// <param name="targetTreeHandler">
        /// An implementation of the IComponentTreeHandler which
        /// this behavior applies to</param>
        public FormControlBehavior(IComponentTreeHandler targetTreeHandler)
        {
            this.targetHandler = targetTreeHandler;

            if (this.targetHandler != null)
            {
                RadFormControlBase form = this.targetHandler.RootElement.ElementTree.Control as RadFormControlBase;

                if (form == null)
                {
                    throw new ArgumentException("The implementation of IComponentTreeHandler is not of the correct type.");
                }

                this.OnFormAssociated();
            }
        }
Beispiel #4
0
        private void SetFormBorderStyle(Form form, FormBorderStyle style, bool copyOriginal)
        {
            //We need this cast since our Form shadows the base Form's FormBorderStyle property (it is not overriddable)
            RadFormControlBase radForm = form as RadFormControlBase;

            if (radForm != null)
            {
                if (copyOriginal)
                {
                    this.originalBorderStyle = radForm.FormBorderStyle;
                }
                radForm.FormBorderStyle = style;
            }
            else
            {
                if (copyOriginal)
                {
                    this.originalBorderStyle = form.FormBorderStyle;
                }
                form.FormBorderStyle = style;
            }
        }
Beispiel #5
0
        protected virtual bool WmNCHitTest(ref Message msg)
        {
            RadFormControlBase parentForm = this.FindForm() as RadFormControlBase;

            if (parentForm != null && parentForm.FormBehavior is RadRibbonFormBehavior)
            {
                Point mousePos = new Point((int)msg.LParam);


                RadElement element = this.ElementTree.GetElementAtPoint(this.PointToClient(mousePos));

                //Check whether there are any elements that need to handle to mouse input before
                //redirecting it to the parent form.
                if ((element != null &&
                     !(element is RadRibbonBarCaption) &&
                     element.Visibility != ElementVisibility.Hidden) ||
                    (!this.CompositionEnabled))
                {
                    return(false);
                }

                mousePos = this.PointToClient(mousePos);
                int captionAreaHeight = SystemInformation.FrameBorderSize.Height +
                                        SystemInformation.CaptionHeight;
                if (parentForm.WindowState == FormWindowState.Maximized)
                {
                    captionAreaHeight += SystemInformation.FrameBorderSize.Height;
                }

                if (mousePos.Y < captionAreaHeight)
                {
                    msg.Result = new IntPtr(NativeMethods.HTTRANSPARENT);
                    return(true);
                }
            }
            return(false);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        public override void PaintPrimitive(Telerik.WinControls.Paint.IGraphics g, float angle, System.Drawing.SizeF scale)
        {
            RadRibbonBar ribbonBar = this.ElementTree.Control as RadRibbonBar;

            if (ribbonBar != null)
            {
                RadFormControlBase form = ribbonBar.FindForm() as RadFormControlBase;

                if (form != null && form.FormBehavior is RadRibbonFormBehavior)
                {
                    float scaleAmount     = form.Width / (float)ribbonBar.Width;
                    int   translateAmount = (form.Width - ribbonBar.Width) / 2;
                    g.TranslateTransform(-translateAmount, 0);

                    if (scaleAmount != 0f && !float.IsInfinity(scaleAmount))
                    {
                        g.ScaleTransform(new SizeF(scaleAmount, 1));
                    }

                    base.PaintPrimitive(g, angle, scale);

                    g.TranslateTransform(translateAmount, 0);

                    scaleAmount = ribbonBar.Width / (float)form.Width;

                    if (scaleAmount != 0f && !float.IsInfinity(scaleAmount))
                    {
                        g.ScaleTransform(new SizeF(scaleAmount, 1));
                    }
                }
                else
                {
                    base.PaintPrimitive(g, angle, scale);
                }
            }
        }
Beispiel #8
0
 /// <summary>
 /// Creates an instance of the FormRootElement class.
 /// </summary>
 /// <param name="control">The RadFormControlBase which is owner of this root element</param>
 public FormRootElement(RadFormControlBase control)
 {
     this.formControl = control;
 }