.Net CF Prevents excessive, impatient clicking (during redrawing the screen)

.Net Compact Framework

Scenario: the user is on the screen. The device cannot find the printer and asks the user if they want to try again. If they click No, the current screen will be closed and they will be returned to the parent menu screen. If they click the No button several times, the first click will be used by the No button, and the next click will take effect after the screen is redrawn. (Actually clicking a menu item, which then takes the user to a different screen.)

I don’t see a good place to place the wait cursor ... there isn’t much going on when the user clicks “No” except closing the form. But the CF structure is slowly redrawing the screen.

Any ideas?

+3
source share
2 answers

Random thoughts:

  • Disable some controls in the parent dialog until the modal dialog is up. I do not believe that you can disable the entire form, since it is the parent of a modal dialog.
  • As an alternative, I would suggest using a transparent control to capture clicks, but transparency is not supported on CF.
  • ? CF.Net, . , , -?
  • DialogResult Dispose /remvoing .
+2

, Windows Application.DoEvents();

Event ( ):

using System;
using System.Windows.Forms;

public sealed class Event {

    bool forwarding;

    public event EventHandler Action;

    void Forward (object o, EventArgs a) {
        if ((Action != null) && (!forwarding)) {
            forwarding = true;
            Cursor cursor = Cursor.Current;
            try {
                Cursor.Current = Cursors.WaitCursor;
                Action(o, a);
            } finally {
                Cursor.Current = cursor;
                Application.DoEvents();
                forwarding = false;
            }
        }
    }

    public EventHandler Handler {
        get {
            return new EventHandler(Forward);
        }
    }

}

, ( , HandleClick ):

using System;
using System.Threading;
using System.Windows.Forms;

class Program {

    static void HandleClick (object o, EventArgs a) {
        Console.WriteLine("Click");
        Thread.Sleep(1000);
    }

    static void Main () {
        Form f = new Form();
        Button b = new Button();
        //b.Click += new EventHandler(HandleClick);
        Event e = new Event();
        e.Action += new EventHandler(HandleClick);
        b.Click += e.Handler;
        f.Controls.Add(b);
        Application.Run(f);
    }

}

, ( ):

        b.Click += new EventHandler(HandleClick);
        //Event e = new Event();
        //e.Action += new EventHandler(HandleClick);
        //b.Click += e.Handler;

Event , EventHandler (Button, MenuItem, ListView,...).

, Tamberg

+3

Source: https://habr.com/ru/post/1697724/


All Articles