vimage.Config.IsControl C# (CSharp) Method

IsControl() public static method

Returns true if Keyboard.Key is one of Control bindings.
public static IsControl ( Keyboard keyCode, List Control ) : bool
keyCode Keyboard
Control List
return bool
        public static bool IsControl(Keyboard.Key keyCode, List<int> Control)
        {
            // Keyboard key?

            // key-combo?
            if (Control.Count > 2 && Control[0] == -2 && (keyCode == (Keyboard.Key)Control[1] ||
                ((Keyboard.Key)Control[1] == Keyboard.Key.LControl && !CtrlDown) ||
                ((Keyboard.Key)Control[1] == Keyboard.Key.LShift && !ShiftDown) ||
                ((Keyboard.Key)Control[1] == Keyboard.Key.LAlt && !AltDown)))
                return false;

            // not key-combo but Ctrl, Shift or Alt is down?
            if ((CtrlDown && !Control.Contains((int)Keyboard.Key.LControl)) ||
                (ShiftDown && !Control.Contains((int)Keyboard.Key.LShift)) ||
                (AltDown && !Control.Contains((int)Keyboard.Key.LAlt)))
                return false;

            foreach (Keyboard.Key key in Control)
            {
                if (keyCode == key)
                    return true;
            }
            return false;
        }

Same methods

Config::IsControl ( Mouse code, List Control ) : bool
Config::IsControl ( object code, List Control ) : bool

Usage Example

Beispiel #1
0
        private void ControlUp(object code)
        {
            // Close
            if (Config.IsControl(code, Config.Control_Close))
            {
                CloseNextTick = true;
            }

            // Dragging
            if (Config.IsControl(code, Config.Control_Drag))
            {
                Dragging = false;
            }

            // Open Context Menu
            if (Config.IsControl(code, Config.Control_OpenContextMenu))
            {
                ContextMenu.RefreshItems();
                ContextMenu.Show(Window.Position.X + MousePos.X - 1, Window.Position.Y + MousePos.Y - 1);
                ContextMenu.Capture = true;
            }

            // Rotate Image
            if (Config.IsControl(code, Config.Control_RotateClockwise))
            {
                RotateImage((int)Image.Rotation + 90);
            }
            if (Config.IsControl(code, Config.Control_RotateAntiClockwise))
            {
                RotateImage((int)Image.Rotation - 90);
            }

            // Flip Image
            if (Config.IsControl(code, Config.Control_Flip))
            {
                FlipImage();
            }

            // Reset Image
            if (Config.IsControl(code, Config.Control_ResetImage))
            {
                ResetImage();
            }

            // Fit To Monitor Height/Width
            if (Config.IsControl(code, Config.Control_FitToMonitorHeight))
            {
                ToggleFitToMonitor(Config.HEIGHT);
            }
            if (Config.IsControl(code, Config.Control_FitToMonitorWidth))
            {
                ToggleFitToMonitor(Config.WIDTH);
            }
            if (Config.IsControl(code, Config.Control_FitToMonitorAuto))
            {
                ToggleFitToMonitor(Config.AUTO);
            }

            // Animated Image - Pause/Play
            if (Config.IsControl(code, Config.Control_PauseAnimation))
            {
                ToggleAnimation();
            }

            // Next/Prev Image in Folder
            if (!Updated && Config.IsControl(code, Config.Control_PrevImage))
            {
                PrevImage();
            }
            if (!Updated && Config.IsControl(code, Config.Control_NextImage))
            {
                NextImage();
            }

            // Open config.txt
            if (Config.IsControl(code, Config.Control_OpenConfig))
            {
                OpenConfig();
            }
            // Reload Config
            if (Config.IsControl(code, Config.Control_ReloadConfig))
            {
                ReloadConfig();
            }

            // Toggle Settings
            if (Config.IsControl(code, Config.Control_ToggleSmoothing))
            {
                ToggleSmoothing();
            }

            if (Config.IsControl(code, Config.Control_ToggleBackgroundForTransparency))
            {
                ToggleBackground();
            }

            // Toggle Always On Top
            if (Config.IsControl(code, Config.Control_ToggleAlwaysOnTop))
            {
                ToggleAlwaysOnTop();
            }

            // Open File At Location
            if (Config.IsControl(code, Config.Control_OpenAtLocation))
            {
                OpenFileAtLocation();
            }

            // Delete File
            if (Config.IsControl(code, Config.Control_Delete))
            {
                DeleteFile();
            }

            if (Config.IsControl(code, Config.Control_OpenDuplicateImage))
            {
                Process p = new Process();
                p.StartInfo.FileName  = Application.ExecutablePath;
                p.StartInfo.Arguments = "\"" + File + "\"";
                p.Start();
            }

            ZoomFaster      = false;
            ZoomAlt         = false;
            FitToMonitorAlt = false;
        }