private void UpdateProgress() { if (elapsedTime == closeTime) { timer.Dispose(); timer = null; Close(); return; } elapsedTime += 5; if (cancelTimer) { elapsedTime = 0; } double perc = (double)elapsedTime / ((double)closeTime / 100); progressWidth = (int)((double)Width * (perc / 100)); Invalidate(new Rectangle(0, 0, Width, 5)); if (!cancelTimer) { timer.Reset(); } }
protected override void Dispose(bool disposing) { if (hideCursorTimer != null) { hideCursorTimer.Dispose(); } if (!DesignMode) { Application.RemoveMessageFilter(this); // Removing it more than once is okay } base.Dispose(disposing); }
private static void TextBox_LostFocus(object sender, EventArgs args) { TextBox textBox = sender as TextBox; if (textBox != null) { DelayedCall dc = textBox.GetValue(UpdateDelayCallProperty) as DelayedCall; if (dc != null) { dc.Dispose(); } textBox.SetValue(UpdateDelayCallProperty, null); } }
public void TriggerExpandCollapse() { if (_buttonItems.Count == 0) { return; } _expandSize = 2; // corresponds to the padding foreach (PreferencesButtonItem val in _buttonItems) { _expandSize += val.Height; } if (_isExpandable) { if (_isExpanded) { if (_dcExpand != null) { _dcExpand.Cancel(); _dcExpand.Dispose(); _dcExpand = null; } OnCollapsing(); _dcCollapse = DelayedCall.Create(CollapseButton, 1); _dcCollapse.Start(); } else { if (_dcCollapse != null) { _dcCollapse.Cancel(); _dcCollapse.Dispose(); _dcCollapse = null; } OnExpanding(); UpdateItems(true); _isExpanded = true; _dcExpand = DelayedCall.Create(ExpandButton, 1); _dcExpand.Start(); } } }