Ejemplo n.º 1
0
        public ClipboardClear()
        {
            InitializeComponent();

            // Set the state of the save button
            validateSaveButton();

            // Hide the window in the system tray to start
            this.ShowInTaskbar = false;
            notifyIcon.Visible = true;
            hideWindow();

            // Prepare the main timer
            clearClipboardTimer           = new System.Timers.Timer();
            clearClipboardTimer.Interval  = Properties.Settings.Default.TimeToClearClipboard * 1000;
            clearClipboardTimer.AutoReset = false;
            clearClipboardTimer.Elapsed  += new System.Timers.ElapsedEventHandler(clearClipboardTimerElapsed);

            // Prepare the retry timer
            retryClearClipboardTimer           = new System.Timers.Timer();
            retryClearClipboardTimer.AutoReset = false;
            retryClearClipboardTimer.Interval  = 5000;
            retryClearClipboardTimer.Elapsed  += new System.Timers.ElapsedEventHandler(clearClipboardTimerElapsed);

            // Setup the delegate
            timerElapsedDelegate = new TimerElapsedDelegate(clearClipboard);

            // Add in the clipboard listener
            AddClipboardFormatListener(this.Handle);
        }
Ejemplo n.º 2
0
    static void Main()
    {
        int ticksCount = 10;
        int interval = 2000; // milliseconds
        TimerElapsedDelegate timerElapsedDelegate = new TimerElapsedDelegate(PrintTicksLeft);

        Timer timer = new Timer(ticksCount, interval, timerElapsedDelegate);

        Console.WriteLine("Timer started for {0} ticks, a tick occurring once every {1} second(s).", ticksCount, interval / 1000);

        Thread timerThread = new Thread(new ThreadStart(timer.Run));
        timerThread.Start();
    }
Ejemplo n.º 3
0
    static void Main()
    {
        int ticksCount = 10;
        int interval   = 2000; // milliseconds
        TimerElapsedDelegate timerElapsedDelegate = new TimerElapsedDelegate(PrintTicksLeft);

        Timer timer = new Timer(ticksCount, interval, timerElapsedDelegate);

        Console.WriteLine("Timer started for {0} ticks, a tick occurring once every {1} second(s).", ticksCount, interval / 1000);

        Thread timerThread = new Thread(new ThreadStart(timer.Run));

        timerThread.Start();
    }
Ejemplo n.º 4
0
 private void _Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     try
     {
         if (!Dispatcher.CheckAccess())
         {
             TimerElapsedDelegate d = _Timer_Elapsed;
             Dispatcher.Invoke(d, sender, e);
         }
         else
         {
             _Timer.Stop();
             if (!hidePanel())
             {
                 _Timer.Start();
             }
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Ejemplo n.º 5
0
 private void _DelayTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     try
     {
         if (!Dispatcher.CheckAccess())
         {
             TimerElapsedDelegate d = _DelayTimer_Elapsed;
             Dispatcher.Invoke(d, sender, e);
         }
         else
         {
             _DelayTimer.Stop();
             var pt = PointToScreen(Mouse.GetPosition(this));
             if (new Rect(Left, Top, ActualWidth, ActualHeight).Contains(pt))
             {
                 mouseEntered();
             }
         }
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Ejemplo n.º 6
0
 public Timer(int ticksCount, int interval, TimerElapsedDelegate callback)
 {
     this.ticksCount = ticksCount;
     this.interval   = interval;
     this.callback   = callback;
 }
Ejemplo n.º 7
0
 public Timer(int ticksCount, int interval, TimerElapsedDelegate callback)
 {
     this.ticksCount = ticksCount;
     this.interval = interval;
     this.callback = callback;
 }