コード例 #1
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);
        }