コード例 #1
0
        //protected override void OnRender(Gdi graphics, Rectangle rect)
        //{
        //    //base.OnRender(graphics, rect);

        //    //// Draw a back color
        //    //if (this.BackgroundColor != null)
        //    //{
        //    //    //using (Brush brush = new SolidBrush(BackgroundColor))
        //    //    //{
        //    //    //     graphics.FillRectangle(brush, new Rectangle(this.Left, this.Top, this.Height, this.Width));
        //    //    //}
        //    //    graphics.FillRect(Rectangle, BackgroundColor);
        //    //}

        //    // Pass the graphics objects to all UI elements
        //    for (int i = 0; i < _children.Count; i++)
        //    {
        //        UIElementBase element = _children[i];
        //        if (element.Visible)
        //        {
        //            //int y = 0;
        //            //if (!(Host is Form))
        //            //{
        //            //    y += Host.Top;
        //            //}

        //            //Rectangle elementRect = new Rectangle(Host.Left + element.Left,
        //            //            y + element.Top,
        //            //            element.Width,
        //            //            element.Height);

        //            if (IsVisibleOnRect(element.Rectangle, rect))
        //            {
        //                //element.Render(graphics, elementRect);
        //                element.Render(graphics, element.Rectangle);
        //            }
        //        }
        //    }
        //}

        protected override void OnRender(Gdi graphics, Rectangle rect)
        {
            //base.OnRender(graphics, rect);

            //// Draw a back color
            //if (this.BackgroundColor != null)
            //{
            //    //using (Brush brush = new SolidBrush(BackgroundColor))
            //    //{
            //    //     graphics.FillRectangle(brush, new Rectangle(this.Left, this.Top, this.Height, this.Width));
            //    //}
            //    graphics.FillRect(Rectangle, BackgroundColor);
            //}

            // Pass the graphics objects to all UI elements
            if (!_layouted)
            {
                for (int i = 0; i < _children.Count; i++)
                {
                    UIElementBase element = _children[i];
                    if (element.Visible)
                    {
                        if (element.Rectangle.IntersectsWith(rect))
                        {
                            element.Render(graphics, element.Rectangle);
                        }
                    }
                }
            }
        }
コード例 #2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            while (_mouseDownObjects.Count > 0)
            {
                UIElementBase element = _mouseDownObjects[0];
                if (element.HitTest(new Point(e.X, e.Y)))
                {
                    element.OnMouseUp(e);
                }
                else
                {
                    element.Focus(false);
                }

                if (_mouseDownObjects.Contains(element))
                {
                    _mouseDownObjects.Remove(element);
                }
            }

            //foreach (UIElementBase element in _mouseDownObjects)
            //{
            //    if (element.HitTest(new Point(e.X, e.Y)))
            //    {
            //        element.OnMouseUp(e);
            //    }
            //    else
            //        element.Focus(false);
            //}

            //_mouseDownObjects.Clear();
        }
コード例 #3
0
        public void Render(Gdi gMem, Rectangle rClip, int yListOffset)
        {
            // Pass the graphics objects to all UI elements
            for (int i = 0; i < _children.Count; i++)
            {
                UIElementBase element = _children[i];
                if (element.Visible)
                {
                    int y = -yListOffset;
                    if (!(Host is Form))
                    {
                        y += Host.Top;
                    }

                    Rectangle elementRect = new Rectangle(Host.Left + element.Left,
                                                          y + element.Top,
                                                          element.Width,
                                                          element.Height);

                    if (IsVisibleOnRect(elementRect, rClip))
                    {
                        element.Render(gMem, elementRect);
                    }
                }
            }
        }
コード例 #4
0
 internal void InvalidateChild(UIElementBase element)
 {
     if (this._host != null)
     {
         Host.Invalidate(element.Rectangle);
     }
 }
コード例 #5
0
ファイル: UIElementBase.cs プロジェクト: xorkrus/vk_wm
 public void OnInvalidate(UIElementBase element)
 {
     if (this.Invalidate != null)
     {
         this.Invalidate(element, null);
     }
 }
コード例 #6
0
ファイル: UIViewBasePaint.cs プロジェクト: xorkrus/vk_wm
 public static void UIInvalidate(UIElementBase sender)
 {
     //Point origin = Point.Empty;
     //UIElementBase parent = sender;
     //while (!(parent is UIViewBase) && parent != null)
     //{
     //origin.X += parent.Left;
     //origin.Y += parent.Top;
     //parent = parent.Parent;
     //}
     //UIViewBase host = parent as UIViewBase;
     //if (host != null)
     //host.UIInvalidate(new Rectangle(origin.X, origin.Y, sender.Width, sender.Height));
 }
コード例 #7
0
ファイル: UIElementBase.cs プロジェクト: xorkrus/vk_wm
        protected Control FindHost()
        {
            UIElementBase parent = this.Parent;

            while (parent != null)
            {
                if (parent is Canvas)
                {
                    return(((Canvas)parent).Host);
                }
                parent = parent.Parent;
            }
            return(null);
        }
コード例 #8
0
        /// <summary>
        /// Перерасчет Размеров и расположения UI контролов на форме в зависимости от расширения
        /// </summary>
        public void RecalcDPIScaling()
        {
            if (UISettings.ScreenDPI <= 96)
            {
                return;
            }

            for (int i = 0; i < _children.Count; i++)
            {
                UIElementBase element = _children[i];
                Point         loc     = new Point(UISettings.CalcPix(element.Left), UISettings.CalcPix(element.Top));
                Size          size    = new Size(UISettings.CalcPix(element.Width), UISettings.CalcPix(element.Height));
                element.Location = loc;
                element.Size     = size;
            }
        }
コード例 #9
0
 void Host_Resize(object sender, EventArgs e)
 {
     if (!_layouted)
     {
         Size sizeDiff = new Size(_host.Size.Width - _hostSize.Width, _host.Size.Height - _hostSize.Height);
         for (int i = 0; i < _children.Count; i++)
         {
             UIElementBase element = _children[i];
             Rectangle     rec     = new Rectangle(element.Left, element.Top, element.Width, element.Height);
             if (IsAnchored(element.Anchor, AnchorStyles.Right))
             {
                 if (IsAnchored(element.Anchor, AnchorStyles.Left))
                 {
                     rec.Width += sizeDiff.Width;
                 }
                 else
                 {
                     rec.X += sizeDiff.Width;
                 }
             }
             if (IsAnchored(element.Anchor, AnchorStyles.Bottom))
             {
                 if (IsAnchored(element.Anchor, AnchorStyles.Top))
                 {
                     rec.Height += sizeDiff.Height;
                 }
                 else
                 {
                     rec.Y += sizeDiff.Height;
                 }
             }
             if (element.Anchor != 0)
             {
                 if (rec.X != element.Left || rec.Y != element.Top)
                 {
                     element.Location = rec.Location;
                 }
                 if (rec.Width != element.Width || rec.Height != element.Height)
                 {
                     element.Size = rec.Size;
                 }
             }
         }
     }
     _hostSize = _host.Size;
 }
コード例 #10
0
ファイル: UIElementBase.cs プロジェクト: xorkrus/vk_wm
 public void OnInvalidate(UIElementBase element)
 {
     if (this.Invalidate != null)
     {
         this.Invalidate(element, null);
     }
 }
コード例 #11
0
ファイル: UIElementBase.cs プロジェクト: xorkrus/vk_wm
 //public abstract void Dispose();
 public virtual void Dispose()
 {
     _parent = null;
 }
コード例 #12
0
ファイル: UIElementBase.cs プロジェクト: xorkrus/vk_wm
 //public abstract void Dispose();
 public virtual void Dispose()
 {
     _parent = null;
 }