Example #1
0
 public PlanningWindow(DriverMachineInterface dmi) : base(dmi, 246, 300)
 {
     ButtonScaleUp   = new DMIIconButton("NA_03.bmp", "NA_05.bmp", Viewer.Catalog.GetString("Scale Up"), true, ScaleUp, 40, 15, dmi);
     ButtonScaleDown = new DMIIconButton("NA_04.bmp", "NA_06.bmp", Viewer.Catalog.GetString("Scale Down"), true, ScaleDown, 40, 15, dmi)
     {
         ExtendedSensitiveArea = new Rectangle(0, 15, 0, 0)
     };
     ButtonScaleUp.ExtendedSensitiveArea = new Rectangle(0, 0, 0, 15);
     ButtonScaleUp.ShowButtonBorder      = false;
     ButtonScaleDown.ShowButtonBorder    = false;
     ButtonScaleUp.Enabled   = MaxViewingDistanceM > MinZoomDistanceM;
     ButtonScaleDown.Enabled = MaxViewingDistanceM < MaxZoomDistanceM;
     ScaleChanged();
 }
        public void HandleMouseInput(bool pressed, int x, int y)
        {
            DMIButton pressedButton = null;

            if (ActiveButton != null)
            {
                if (!ActiveButton.Enabled)
                {
                    ActiveButton.Pressed = false;
                    ActiveButton         = null;
                }
                else if (ActiveButton.SensitiveArea(ActiveWindow.Position).Contains(x, y))
                {
                    if (ActiveButton.UpType)
                    {
                        if (ActiveButton.DelayType && ActiveButton.FirstPressed + 2 > CurrentTime)
                        {
                            ActiveButton.Pressed = ((int)((CurrentTime - ActiveButton.FirstPressed) * 4)) % 2 == 0;
                        }
                        else
                        {
                            ActiveButton.Pressed = true;
                            if (!pressed)
                            {
                                pressedButton = ActiveButton;
                            }
                        }
                    }
                    else
                    {
                        ActiveButton.Pressed = false;
                        if (ActiveButton.FirstPressed + 1.5 < CurrentTime)
                        {
                            if (ActiveButton.LastPressed + 0.3 < CurrentTime)
                            {
                                pressedButton            = ActiveButton;
                                ActiveButton.Pressed     = true;
                                ActiveButton.LastPressed = CurrentTime;
                            }
                        }
                    }
                }
                else
                {
                    ActiveButton.FirstPressed = CurrentTime;
                    ActiveButton.Pressed      = false;
                }
            }
            else if (pressed)
            {
                foreach (var area in ActiveWindow.SubAreas)
                {
                    if (!(area is DMIButton))
                    {
                        continue;
                    }
                    var b = (DMIButton)area;
                    b.Pressed = false;
                    if (b.SensitiveArea(ActiveWindow.Position).Contains(x, y))
                    {
                        ActiveButton              = b;
                        ActiveButton.Pressed      = true;
                        ActiveButton.FirstPressed = CurrentTime;
                        if (!b.UpType && b.Enabled)
                        {
                            pressedButton = ActiveButton;
                        }
                        break;
                    }
                }
            }
            if (!pressed && ActiveButton != null)
            {
                ActiveButton.Pressed = false;
                ActiveButton         = null;
            }
            pressedButton?.PressedAction();
        }