Exemple #1
0
        protected override void OnFocusGrabbed()
        {
            base.OnFocusGrabbed();

            if (plots.Count < 1)
            {
                return;
            }

            // don't switch focus if any plot already has focus
            foreach (IPlot plot in plots)
            {
                if (plot.HasFocus)
                {
                    return;
                }
            }

            // find the plot with the smallest x value, and focus it
            int min_plot = -1;
            int min_x    = Int32.MaxValue;
            int min_y    = Int32.MaxValue;

            for (int i = 0; i < plots.Count; i++)
            {
                IPlot plot = (IPlot)plots[i];
                if (!plot.CanFocus)
                {
                    continue;
                }

                int x, y;
                plot.GetGrabFocusRequest(out x, out y);

                if ((min_x > x) || (min_x == x && min_y > y))
                {
                    min_x    = x;
                    min_y    = y;
                    min_plot = i;
                }
            }

            if (min_plot == -1)
            {
                return;
            }

            ((IPlot)plots[min_plot]).GrabFocus();
            focused_plot_index = min_plot;
        }