YAPA icon indicating copy to clipboard operation
YAPA copied to clipboard

[Request] Lock option

Open Disar opened this issue 7 years ago • 5 comments

I'd like to have a lock feature disabling clicking (mouse clicks pass trough) and moving the visual timer. Additionally if I hover over when locked it should go fully transparent. Unlocking/Locking can be set by right clicking the icon in the taskbar as additional options.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Disar avatar Aug 13 '17 04:08 Disar

Hey, did some research, doesn't seem to be very difficult to implement this feature.

Will throw snippet here for later: Set on MainWindow WindowStyle="None" AllowsTransparency="True"

` public const int WS_EX_TRANSPARENT = 0x00000020; public const int GWL_EXSTYLE = (-20);

    [DllImport("user32.dll")]
    public static extern int GetWindowLong(IntPtr hwnd, int index);

    [DllImport("user32.dll")]
    public static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);

    [DllImport("user32.dll")]
    public static extern int GetWindowLongPtr(IntPtr hwnd, int index);

    [DllImport("user32.dll")]
    public static extern int SetWindowLongPtr(IntPtr hwnd, int index, int newStyle);

    int extendedStyle;
    private bool is64Bit;
    private IntPtr hwnd;

    protected override void OnSourceInitialized(EventArgs e)
    {
         is64Bit = (Marshal.SizeOf(typeof(IntPtr))) == 8;
        hwnd = new WindowInteropHelper(this).Handle;

        if (is64Bit)
            extendedStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
        else
            extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);

        base.OnSourceInitialized(e);
    }

    private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
    {
        if (is64Bit)
            SetWindowLongPtr(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
        else
            SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
    }`

floatas avatar Aug 14 '17 12:08 floatas

If not absolute necessary I would stay away from importing unsecure win32 code. E.g. if you ever plan to put the app on the store, it will be rejected.

fghber avatar Aug 14 '17 16:08 fghber

I'm not very keen on adding more options to YAPA, it already looks like space ship control panel... For YAPA 2.0, we should add this as plugin, so we can easily remove it if needed.

floatas avatar Aug 18 '17 12:08 floatas

it already looks like space ship control panel...

Love it :) In headline we have "minimalistic", don't we? :)

18.08.2017 14:47 "Šarūnas" [email protected] napisał(a):

I'm not very keen on adding more options to YAPA, it already looks like space ship control panel... For YAPA 2.0, we should add this as plugin, so we can easily remove it if needed.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lukaszbanasiak/YAPA/issues/51#issuecomment-323344300, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYsl3IijJUlRZ_8r2oT1WJqajZpzcyRks5sZYfRgaJpZM4O1lka .

lukaszbanasiak avatar Aug 18 '17 12:08 lukaszbanasiak

I don't see how it looks like a spaceship control panel. It barely offers any options or features.

But whatever works. Plugins sound good too ( although I'd argue a plug-in would detract from being minimalistic).

I just think the timer shouldn't be blocking mouse clicks all the time.

Disar avatar Aug 18 '17 14:08 Disar