Exemple #1
0
        private int zindexBottom      = BASE_ZINDEX; // Bottom is decremented when a control is moved to back.

        private void AddToCanvas(IHmiControl control, double leftShift = 0, double topShift = 0)
        {
            control.OwnerPage = this;
            SetName(control, control.Name);
            Panel.SetZIndex(control.fe, zindexTop++);
            Location0.Shift(control.fe, leftShift, topShift);
            gridCanvas.Children.Add(control.fe);
        }
Exemple #2
0
        private void ArrowKeyNudge(Key key, bool ctrl)
        {
            IHmiControl control = SelectedControl;
            double      delta = ctrl ? 10 * GridSize : GridSize; // Ctrl+arrows for 10x nudge
            double      left, left0 = GetLeft(control);
            double      top, top0 = GetTop(control);

            switch (key)
            {
            case Key.Left: left = Math.Max(left0 - delta, 0); top = top0; break;

            case Key.Right: left = left0 + delta; top = top0; break;

            case Key.Up: left = left0; top = Math.Max(top0 - delta, 0); break;

            case Key.Down: left = left0; top = top0 + delta; break;

            default: return;
            }
            double dx = left - left0, dy = top - top0;

            if (dx == 0 && dy == 0)  // at the edge
            {
                SystemSounds.Beep.Play();
                return;
            }

            if ((control.Flags & ECtrlFlags.IsGroup) > 0 && !Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
            {
                foreach (object child in gridCanvas.Children)
                {
                    if ((child is IHmiControl control2) && IsInside(control2, control))
                    {
                        Location0.Shift(control2.fe, dx, dy);
                    }
                }
            }

            Location0.Shift(control.fe, dx, dy);

            if (SelectedControl == control)
            {
                marker.Margin = control.fe.Margin;
                designer.UpdateLocation();
            }
        }