示例#1
0
 public override void Remove(GLControl control)
 {
     if (first == control)
     {
         first = null;
     }
     if (second == control)
     {
         second = null;
     }
     base.Remove(control);
 }
示例#2
0
        protected Rectangle ToViewport(Rectangle r)
        {
            r.X += outer.X;
            r.Y += outer.Y;
            GLControl c = Parent;

            while (c != c.Parent)
            {
                r.X += c.inner.X + c.outer.X;
                r.Y += c.inner.Y + c.outer.Y;
                c    = c.Parent;
            }
            return(r);
        }
示例#3
0
        protected Point ToViewport(Point p)
        {
            p.X += outer.X;
            p.Y += outer.Y;
            GLControl c = Parent;

            while (c != c.Parent)
            {
                p.X += c.inner.X + c.outer.X;
                p.Y += c.inner.Y + c.outer.Y;
                c    = c.Parent;
            }
            return(p);
        }
示例#4
0
        protected Point ToControl(Point p)
        {
            p.X -= outer.X;
            p.Y -= outer.Y;
            GLControl c = Parent;

            while (c != c.Parent)
            {
                p.X -= c.inner.X + c.outer.X;
                p.Y -= c.inner.Y + c.outer.Y;
                c    = c.Parent;
            }
            return(p);
        }
示例#5
0
        internal void DoMouseLeave()
        {
            if (Parent == null)
            {
                return;
            }

            if (hoverChild != null)
            {
                hoverChild.DoMouseLeave();
                hoverChild = null;
            }

            if (MouseLeave != null)
            {
                MouseLeave(this, EventArgs.Empty);
            }
        }
示例#6
0
        public virtual void Remove(GLControl control)
        {
            if (control.Parent == null)
            {
                return;
            }

            if (control.Parent != this)
            {
                string message = string.Format("{0} {1} is a child of {2} {3}.",
                                               control.GetType().Name, control.Name,
                                               control.Parent.GetType().Name, control.Parent.Name);
                throw new ArgumentException(message);
            }

            controls.Remove(control);
            control.Gui    = null;
            control.Parent = null;
        }
示例#7
0
 public override T Add <T>(T control)
 {
     if (first != null && second != null)
     {
         string message = string.Format("{0} {1} already has two children.",
                                        control.GetType().Name, control.Name);
         throw new InvalidOperationException(message);
     }
     base.Add(control);
     if (first == null)
     {
         first = control;
     }
     else
     {
         second = control;
     }
     Invalidate();
     return(control);
 }
示例#8
0
 public override void Remove(GLControl control)
 {
     base.Remove(control);
     (control as GLCheckBox).Changed -= Select;
 }
示例#9
0
        internal bool DoMouseDown(MouseButtonEventArgs e)
        {
            if (Parent == null)
            {
                return(false);
            }

            if (!isDragged)
            {
                Point im = new Point(e.X - inner.X, e.Y - inner.Y);

                if (!HasFocus)
                {
                    HasFocus = true;
                    if (Focus != null)
                    {
                        Focus(this, EventArgs.Empty);
                    }
                }

                if (inner.Contains(e.Position))
                {
                    int i = 0;
                    foreach (GLControl control in controls)
                    {
                        if (control.Outer.Contains(im))
                        {
                            bool handled = control.DoMouseDown(new MouseButtonEventArgs(im.X - control.Outer.X, im.Y - control.Outer.Y, e.Button, e.IsPressed));
                            if (control is GLForm)
                            {
                                GLControl tmp = controls[i];                                 // move to front
                                controls.RemoveAt(i);
                                controls.Insert(0, tmp);
                            }
                            if (handled)
                            {
                                if (control != focusedChild)
                                {
                                    if (focusedChild != null)
                                    {
                                        focusedChild.DoFocusLost();
                                    }
                                    focusedChild = control;
                                }
                                return(true);
                            }
                        }
                        i++;
                    }
                }
            }

            bool handledHere = false;

            if (MouseDown != null)
            {
                MouseDown(this, e);
                handledHere = true;
            }

            if (contextMenu != null && e.Button == MouseButton.Right)
            {
                Gui.OpenContextMenu(contextMenu, ToViewport(e.Position));
                handledHere = true;
            }

            return(handledHere || handleMouseEvents);
        }
示例#10
0
 public override void Remove(GLControl control)
 {
     base.Remove(control);
     control.Resize -= Invalidate;
     Invalidate();
 }