public void Show(Control pin_to, Point target, string msg, int duration) { lock (m_lock) { Debug.Assert(msg != null && duration >= 0); var issue = ++m_issue; Target = target; Text = msg; Duration = duration; Dispatcher_.BeginInvokeDelayed(() => ShowHintInternal(issue, pin_to), TimeSpan.FromMilliseconds(ShowDelay)); } }
/// <summary>Call to begin or update a time limited feature</summary> public void UseLicensedFeature(string key, ILicensedFeature use) { if (Licence.Valid) { return; } // Wait till the main UI is visible if (!Visible) { return; } // See if the feature is already monitored, if so, just update the interface if (m_licensed_features.ContainsKey(key)) { m_licensed_features[key] = use; return; } // If the feature isn't in use, ignore the request (this method is called recursively) if (!use.FeatureInUse) { return; } // Otherwise, prompt about the feature var dlg = new CrippleUI(use.FeatureDescription); if (dlg.ShowDialog(this) != DialogResult.OK) { // Not interested, close and go home use.CloseFeature(); return; } // Otherwise, the user wants to use the feature m_licensed_features[key] = use; Dispatcher_.BeginInvokeDelayed(() => { ILicensedFeature feat; if (!m_licensed_features.TryGetValue(key, out feat)) { return; } m_licensed_features.Remove(key); UseLicensedFeature(key, feat); }, TimeSpan.FromMinutes(FreeEditionLimits.FeatureEnableTimeInMinutes)); }
/// <summary>Make the hint balloon visible</summary> private void ShowHintInternal(int issue, Control pin_to) { lock (m_lock) { // Only display if the issue number is still valid if (issue != m_issue) { return; } if (PinTo != null) { PinTo.Move -= DoPosition; PinTo.Resize -= DoPosition; } if (Owner != null) { Owner.Move -= DoPosition; Owner.Resize -= DoPosition; Owner.FormClosed -= DetachFromOwner; } Opacity = 1.0; PinTo = pin_to; Owner = pin_to != null ? pin_to.TopLevelControl as Form : null; TopMost = Owner == null; Location = pin_to != null?pin_to.PointToScreen(Target) : Target; Win32.ShowWindow(Handle, Win32.SW_SHOWNOACTIVATE); if (PinTo != null) { PinTo.Move += DoPosition; PinTo.Resize += DoPosition; } if (Owner != null) { Owner.Move += DoPosition; Owner.Resize += DoPosition; Owner.FormClosed += DetachFromOwner; } Dispatcher_.BeginInvokeDelayed(() => HideHintInternal(issue), TimeSpan.FromMilliseconds(Duration)); } }
/// <summary>Hide the hint balloon</summary> private void HideHintInternal(int issue) { lock (m_lock) { // Only hide if the issue number is still valid if (issue != m_issue || !Visible) { return; } // Test if the mouse is over the form, if so, wait another 2000 var pt = PointToClient(Cursor.Position); var rect = ClientRectangle.Inflated(-TipLength, -TipLength); if (rect.Contains(pt)) { Opacity = 1f; Dispatcher_.BeginInvokeDelayed(() => HideHintInternal(issue), TimeSpan.FromMilliseconds(2000)); return; } // Do fading if (FadeDuration > 0) { Opacity -= Math.Min(0.1, Opacity); if (Opacity == 0) { Visible = false; } else { Dispatcher_.BeginInvokeDelayed(() => HideHintInternal(issue), TimeSpan.FromMilliseconds(FadeDuration / 10)); } return; } // Done, hidden DetachFromOwner(); } }
protected override void OnRenderSizeChanged(SizeChangedInfo size_info) { m_resized = true; base.OnRenderSizeChanged(size_info); D3DImage.Invalidate(); // Invalidate after the last resize if (!m_resize_invalidate_pending) { m_resize_invalidate_pending = true; var resize_issue = ++m_resize_issue; Dispatcher_.BeginInvokeDelayed(FinalInvalidate, TimeSpan.FromMilliseconds(1), DispatcherPriority.Background); void FinalInvalidate() { m_resize_invalidate_pending = false; if (resize_issue != m_resize_issue || Window == null) { return; } Invalidate(); } } }
private void ReadSelection() { m_tb_selected_item.Text = (string)m_cb0.SelectedItem ?? "<null>"; m_tb_selected_item.BackColor = Color.LightGreen; Dispatcher_.BeginInvokeDelayed(() => m_tb_selected_item.BackColor = Color.White, TimeSpan.FromMilliseconds(200)); }