コード例 #1
0
 // we are in control display, and if control change the cursor is the current control mouse over, set it
 protected void Gc_CursorTo(GLBaseControl c, GLWindowControl.GLCursorType ct)
 {
     if (currentmouseover == c)
     {
         ((GLControlDisplay)this).SetCursor(ct);
     }
 }
コード例 #2
0
        protected void Gc_MouseUp(object sender, GLMouseEventArgs e)
        {
            SetViewScreenCoord(ref e);

            if (currentmouseover != null)
            {
                currentmouseover.MouseButtonsDown = GLMouseEventArgs.MouseButtons.None;

                SetControlLocation(ref e, currentmouseover);    // reset location etc

                if (currentmouseover.Enabled)
                {
                    currentmouseover.OnMouseUp(e);
                }
            }
            else
            {
                if (this.Enabled)               // not over any control (due to screen coord clip space), so send thru the displaycontrol
                {
                    this.OnMouseUp(e);
                }
            }

            mousedowninitialcontrol = null;
        }
コード例 #3
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnControlAdd(GLBaseControl, GLBaseControl)"/>
        protected override void OnControlAdd(GLBaseControl parent, GLBaseControl child)
        {
            //System.Diagnostics.Debug.WriteLine("On control add {0}:{1} {2}:{3}", parent.GetType().Name, parent.Name, child.GetType().Name, child.Name);

            if (parent is GLMenuStrip)      // note we get called when the GLMenuStrip is added to the display, we don't want that call
            {
                child.SuspendLayout();

                var mi = child as GLMenuItem;
                if (mi != null)                     // MenuItems get coloured and hooked
                {
                    mi.Click      += MenuItemClicked;
                    mi.MouseEnter += MenuItemEnter;
                    mi.MouseLeave += MenuItemLeave;

                    if (FlowDirection == ControlFlowDirection.Down)
                    {
                        mi.IconAreaEnable = true;
                    }
                }
                else
                {
                    if (FlowDirection == ControlFlowDirection.Down)
                    {
                        child.FlowOffsetPosition = new Point(IconAreaWidth, 0);
                    }

                    child.KeyDown += NonMIKeyDown;
                }

                child.ResumeLayout();
            }

            base.OnControlAdd(parent, child);
        }
コード例 #4
0
 /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.Add(GLBaseControl, bool)"/>
 public override void Add(GLBaseControl other, bool atback = false)
 {
     System.Diagnostics.Debug.Assert(other is GLTabPage);
     other.Dock    = DockingType.Fill;
     other.Visible = false;
     base.Add(other, atback);
 }
コード例 #5
0
        protected void Gc_MouseDown(object sender, GLMouseEventArgs e)
        {
            // System.Diagnostics.Debug.WriteLine("GC Mouse down");
            if (currentmouseover != null)
            {
                currentmouseover.FindControlUnderDisplay()?.BringToFront();     // this brings to the front of the z-order the top level element holding this element and makes it visible.

                SetViewScreenCoord(ref e);
                SetControlLocation(ref e, currentmouseover);

                OnGlobalMouseDown(currentmouseover, e);

                if (currentmouseover.Enabled)
                {
                    currentmouseover.MouseButtonsDown = e.Button;
                    currentmouseover.OnMouseDown(e);
                }

                mousedowninitialcontrol = currentmouseover;
            }
            else
            {
                OnGlobalMouseDown(null, e);

                if (this.Enabled)               // not over any control (due to screen coord clip space), so send thru the displaycontrol
                {
                    this.OnMouseDown(e);
                }
            }
        }
コード例 #6
0
 private void dropdownotherkey(GLBaseControl c, GLKeyEventArgs e)
 {
     if (e.KeyCode == System.Windows.Forms.Keys.Escape)
     {
         Deactivate();
     }
 }
コード例 #7
0
 /// <summary> Add an entry with a pre-made control </summary>
 /// <param name="name">Name of control</param>
 /// <param name="control">Control, pre-made</param>
 /// <param name="tooltiptext">Tool tip text, may be null</param>
 /// <param name="tag">User tag, may be null</param>
 public void Add(string name, GLBaseControl control, string tooltiptext = null, Object tag = null)   // add a previously made ctrl
 {
     Add(new Entry(name, control, tooltiptext, tag)
     {
         TabOrder = tabnumber++
     });
 }
コード例 #8
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.AnimateTimeBase.Middle(GLBaseControl, double)"/>
        protected override void Middle(GLBaseControl cs, double delta)
        {
            var s = Begin.Value + (Target - Begin.Value) * (float)delta;

            cs.Opacity = s;
//            System.Diagnostics.Debug.WriteLine("Animate {0} to opacity {1}", cs.Name, cs.Opacity);
        }
コード例 #9
0
 /// <inheritdoc cref="GLOFC.GL4.Controls.AnimateTimeBase.Start(GLBaseControl)"/>
 protected override void Start(GLBaseControl cs)
 {
     if (Begin == null)
     {
         Begin = cs.Location;
     }
 }
コード例 #10
0
 /// <inheritdoc cref="GLOFC.GL4.Controls.AnimateTimeBase.Start(GLBaseControl)"/>
 protected override void Start(GLBaseControl cs)
 {
     if (Begin == null)
     {
         Begin = cs.ScaleWindow ?? new SizeF(1, 1);
     }
 }
コード例 #11
0
        // recursively go thru children, bottom child first, and remove everything
        protected virtual void RemoveControl(GLBaseControl child, bool dispose, bool removechildren)
        {
            if (removechildren)
            {
                foreach (var cc in child.childrenz)     // do children of child first
                {
                    RemoveControl(cc, dispose, removechildren);
                }
            }

            //System.Diagnostics.Debug.WriteLine($"Remove control {child.Name} in {Name}");

            child.OnControlRemove(this, child);
            OnControlRemove(this, child);
            //System.Diagnostics.Debug.WriteLine("Remove {0} {1}", child.GetType().Name, child.Name);
            FindDisplay()?.ControlRemoved(child);   // display may be pointing to it

            if (dispose)
            {
                child.Dispose();
            }

            child.parent = null;

            childrenz.Remove(child);
            childreniz.Remove(child);
            CheckZOrder();
        }
コード例 #12
0
        /// <summary>
        /// Show to pop up a new context menu. Parent is normally displaycontrol.
        /// You can double call and the previous one is closed.
        /// It always makes sure right/bottom is within parent.
        /// </summary>
        /// <param name="parent">Parent of menu to attach to. Normally its the control display top level control</param>
        /// <param name="location">Location to place the menu at</param>
        /// <param name="changewidthifrequired">If set, it will reflow the menu to not exceed parent, making the window wider if required, </param>
        /// <param name="opentag">Tag to pass to Opening callback</param>
        public void Show(GLBaseControl parent, Point location, bool changewidthifrequired = false, Object opentag = null)
        {
            //System.Diagnostics.Debug.WriteLine("Open as context menu " + Name);
            Detach(this);
            openedascontextmenu = true;
            Visible             = true;
            Location            = location;
            AutoSize            = true;
            TopMost             = true;
            KeepWithinParent    = changewidthifrequired;
            parent.Add(this);
            int overflowy = this.Bottom - parent.Bottom;

            if (overflowy > 0)
            {
                Top -= overflowy;
            }
            int overflowx = this.Right - parent.Right;

            if (overflowx > 0)
            {
                Left -= overflowx;
            }
            SetFocus();
            Opening?.Invoke(this, opentag);
        }
コード例 #13
0
        /// <summary> Bring child to the front of its parent Z order. True if already at front. </summary>
        public virtual bool BringToFront(GLBaseControl child)
        {
            //System.Diagnostics.Debug.WriteLine("Bring to front" + child.Name);
            int curpos = childrenz.IndexOf(child);

            if (curpos >= 0)
            {
                int ipos = 0;

                if (!child.TopMost)
                {
                    while (ipos < childrenz.Count && childrenz[ipos].TopMost)     // find first place we can move to
                    {
                        ipos++;
                    }
                }

                if (curpos != ipos)         // if not in first position possible
                {
                    childrenz.Remove(child);
                    childreniz.Remove(child);
                    // list now has child removed, now insert back into position
                    childrenz.Insert(ipos, child);                     // in z order.  First is top of z
                    childreniz.Insert(childreniz.Count - ipos, child); // in inv z order. Last is top of z

                    CheckZOrder();

                    InvalidateLayout(child);
                    return(false);
                }
            }

            return(true);
        }
コード例 #14
0
        /// <summary> Find next tab, either forward or backwards, from this tab number</summary>
        public GLBaseControl FindNextTabChild(int tabno, bool forward = true)
        {
            GLBaseControl found   = null;
            int           mindist = int.MaxValue;

            foreach (var c in childrenz)
            {
                if (c.Focusable && c.Visible && c.Enabled)
                {
                    int dist = c.TabOrder - tabno;

                    if (forward ? dist > 0 : dist < 0)
                    {
                        dist = Math.Abs(dist);
                        if (dist < mindist)
                        {
                            mindist = dist;
                            found   = c;
                        }
                    }
                }
            }

            return(found);
        }
コード例 #15
0
 /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnControlRemove(GLBaseControl, GLBaseControl)"/>
 protected override void OnControlRemove(GLBaseControl parent, GLBaseControl child)
 {
     if (child == this && InDropDown)        // if its dropped, it need removing
     {
         Remove(dropdownbox);
     }
     base.OnControlRemove(parent, child);
 }
コード例 #16
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.AnimateTimeBase.Middle(GLBaseControl, double)"/>
        protected override void Middle(GLBaseControl cs, double delta)
        {
            var s = new SizeF(Begin.Value.Width + (Target.Width - Begin.Value.Width) * (float)delta,
                              Begin.Value.Height + (Target.Height - Begin.Value.Height) * (float)delta);

            //System.Diagnostics.Debug.WriteLine("Animate {0} to scale {1}", cs.Name, s);
            cs.ScaleWindow = s;
        }
コード例 #17
0
 /// <inheritdoc cref="GLOFC.GL4.Controls.AnimateTimeBase.Start(GLBaseControl)"/>
 protected override void Start(GLBaseControl cs)
 {
     if (Begin == null)
     {
         Begin = cs.Opacity;
     }
     cs.Opacity = Begin.Value;
     //System.Diagnostics.Debug.WriteLine("Animate {0} begin {1}", cs.Name, cs.Opacity);
 }
コード例 #18
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnGlobalMouseClick(GLBaseControl, GLMouseEventArgs)"/>
        protected override void OnGlobalMouseClick(GLBaseControl ctrl, GLMouseEventArgs e)
        {
            base.OnGlobalMouseClick(ctrl, e);                           // do heirarchy before we mess with it

            if (InDropDown && (ctrl == null || !IsThisOrChildOf(ctrl))) // if its not part of us, close
            {
                Deactivate();
            }
        }
コード例 #19
0
 protected virtual void OnFocusChanged(FocusEvent focused, GLBaseControl ctrl)   // focused elements or parents up to GLForm gets this as well
 {
     this.focused = focused == FocusEvent.Focused;
     if (InvalidateOnFocusChange)
     {
         Invalidate();
     }
     FocusChanged?.Invoke(this, focused, ctrl);
 }
コード例 #20
0
        protected virtual void OnGlobalFocusChanged(GLBaseControl from, GLBaseControl to)  // everyone gets this
        {
            GlobalFocusChanged?.Invoke(from, to);
            List <GLBaseControl> list = new List <GLBaseControl>(childrenz); // copy of, in case the caller closes something

            foreach (var c in list)
            {
                c.OnGlobalFocusChanged(from, to);
            }
        }
コード例 #21
0
 /// <summary> Remove child control from parent, but do not dispose of it or its children, and maintain all child relationship to it. Control can be reattached</summary>
 public static void Detach(GLBaseControl child)
 {
     if (child.Parent != null) // if attached
     {
         GLBaseControl parent = child.Parent;
         parent.RemoveControl(child, false, false);
         parent.InvalidateLayout(null);
         child.NeedRedraw = true;        // next time, it will need to be drawn
     }
 }
コード例 #22
0
 /// <summary> Remove child control from parent, and disposes of it and all its children. Control is now not reattachable.</summary>
 public static void Remove(GLBaseControl child)
 {
     if (child.Parent != null) // if attached
     {
         GLBaseControl parent = child.Parent;
         parent.RemoveControl(child, true, true);
         parent.InvalidateLayout(null);          // invalidate parent, and indicate null so it knows the child has been removed
         child.NeedRedraw = true;                // next time, it will need to be drawn if reused
     }
 }
コード例 #23
0
 protected void ControlRemoved(GLBaseControl other)     // called on ControlDisplay, to inform it that a control has been removed
 {
     if (currentfocus == other)
     {
         currentfocus = null;
     }
     if (currentmouseover == other)
     {
         currentmouseover = null;
     }
 }
コード例 #24
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnControlRemove(GLBaseControl, GLBaseControl)"/>
        protected override void OnControlRemove(GLBaseControl parent, GLBaseControl child)
        {
            var p = parent as GLControlDisplay; // if attached to control display, its an automatic tool tip

            if (p != null)                      // unsubscribe, and we can do this even if we did not subsribe in the first place
            {
                p.GlobalMouseMove -= MouseMoved;
            }

            base.OnControlRemove(parent, child);
        }
コード例 #25
0
 private void PropergateFontChanged(GLBaseControl p)
 {
     p.OnFontChanged();
     foreach (var c in p.childrenz)
     {
         if (c.font == null)     // if child does not override font..
         {
             PropergateFontChanged(c);
         }
     }
 }
コード例 #26
0
        protected virtual void OnGlobalMouseDown(GLBaseControl ctrl, GLMouseEventArgs e) // everyone gets this
        {
            //System.Diagnostics.Debug.WriteLine("In " + Name + " Global click in " + ctrl.Name);
            GlobalMouseDown?.Invoke(ctrl, e);
            List <GLBaseControl> list = new List <GLBaseControl>(childrenz); // copy of, in case the caller closes something

            foreach (var c in list)
            {
                c.OnGlobalMouseDown(ctrl, e);
            }
        }
コード例 #27
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.AnimateTimeBase.Middle(GLBaseControl, double)"/>
        protected override void Middle(GLBaseControl cs, double delta)
        {
            var s = new Size((int)(Begin.Value.Width + (double)(Target.Width - Begin.Value.Width) * delta), (int)(Begin.Value.Width + (double)(Target.Width - Begin.Value.Width) * delta));

            //System.Diagnostics.Debug.WriteLine("Animate {0} to size {1}", cs.Name, s);
            if (cs.Dock != GLBaseControl.DockingType.None)
            {
                cs.Dock = GLBaseControl.DockingType.None;
            }
            cs.Size = s;
        }
コード例 #28
0
 /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnFocusChanged(FocusEvent, GLBaseControl)"/>
 protected override void OnFocusChanged(FocusEvent evt, GLBaseControl fromto)
 {
     if (evt == FocusEvent.Deactive) // if lost focus
     {
         if (!IsValid)               // if text box is not valid, go back to the original colour with no change event
         {
             Value = number;
         }
     }
     base.OnFocusChanged(evt, fromto);
 }
コード例 #29
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.AnimateTimeBase.Middle(GLBaseControl, double)"/>
        protected override void Middle(GLBaseControl cs, double delta)
        {
            var p = new Point((int)(Begin.Value.X + (double)(Target.X - Begin.Value.X) * delta), (int)(Begin.Value.Y + (double)(Target.Y - Begin.Value.Y) * delta));

            //System.Diagnostics.Debug.WriteLine("Animate {0} to pos {1}", cs.Name, p);
            if (cs.Dock != GLBaseControl.DockingType.None)
            {
                cs.Dock = GLBaseControl.DockingType.None;
            }
            cs.Location = p;
        }
コード例 #30
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnControlAdd(GLBaseControl, GLBaseControl)"/>
        protected override void OnControlAdd(GLBaseControl parent, GLBaseControl child)
        {
            base.OnControlAdd(parent, child);

            var p = parent as GLControlDisplay;     // if attached to control display, its an automatic tool tip

            if (p != null && AutomaticDelay > 0)    // only if auto delay is on
            {
                p.GlobalMouseMove += MouseMoved;
            }
        }