Exemplo n.º 1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
            case Keys.Down:
                Control.ControlCollection buttons = this.flowLayoutPanel1.Controls;
                int index    = buttons.GetChildIndex(GetFocussedButton());
                int newIndex = index + NUMBER_OF_COLUMNS;
                if (newIndex > buttons.Count - 1)
                {
                    newIndex = newIndex % NUMBER_OF_COLUMNS;
                }
                buttons[newIndex].Focus();
                return(true);

            case Keys.Up:
                buttons  = this.flowLayoutPanel1.Controls;
                index    = buttons.GetChildIndex(GetFocussedButton());
                newIndex = index - NUMBER_OF_COLUMNS;
                if (newIndex < 0)
                {
                    if (index < buttons.Count % NUMBER_OF_COLUMNS)
                    {
                        newIndex = (int)(Math.Round((double)buttons.Count / NUMBER_OF_COLUMNS, 0) * 10) + index;
                    }
                    else
                    {
                        newIndex = (int)((Math.Round((double)buttons.Count / NUMBER_OF_COLUMNS, 0) - 1) * 10) + index;
                    }
                }
                buttons[newIndex].Focus();
                return(true);
            }
            return(base.ProcessCmdKey(ref msg, keyData));
        }
Exemplo n.º 2
0
        public static void ZOrderSync(UIElement entity)
        {
            IFormElementEntityDev entityDev = entity as IFormElementEntityDev;

            Debug.Assert(entityDev != null, "实体对象没有实现 IFormElementEntityDev");
            Control control = entityDev.Component as Control;

            Debug.Assert(control != null, "entityDev.Component 不是 Control");
            if (control.Parent == null)
            {
                return;
            }
            Control.ControlCollection controls = control.Parent.Controls;
            IShellControlDev          controlDev;

            foreach (Control c in controls)
            {
                controlDev = c as IShellControlDev;
                Debug.Assert(controlDev != null, "Control 没有实现 IShellControlDev");
                if (controlDev == null)
                {
                    continue;
                }
                ((UIElement)controlDev.Entity).ZOrder = controls.GetChildIndex(c);
            }
        }
Exemplo n.º 3
0
 protected void btnShowControls_Clicked(object sender, EventArgs e)
 {
     Control.ControlCollection coll = this.Controls;
     foreach (Control c in coll)
     {
         if (c != null)
         {
             Console.WriteLine(c.Text, "Index numb: " + coll.GetChildIndex(c, false));
         }
     }
 }