This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OfficeNavigationBarHelper.cs
60 lines (59 loc) · 2.08 KB
/
OfficeNavigationBarHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraBars.Navigation;
namespace DxExample {
public class OfficeNavigationBarHelper {
Timer _timer;
FlyoutPanelBeakForm _currentPeekForm;
OfficeNavigationBar _officeNavigationBar;
public OfficeNavigationBarHelper(OfficeNavigationBar _officeNavigationBar) {
this._officeNavigationBar = _officeNavigationBar;
}
Timer Timer {
get {
if (_timer == null)
SetUpTimer();
return _timer;
}
}
void SetUpTimer() {
_timer = new Timer();
_timer.Interval = 200;
_timer.Tick += timer_Tick;
}
void timer_Tick(object sender, EventArgs e) {
Point point = Control.MousePosition;
if (CanHidePeekForm) {
_officeNavigationBar.HidePeekForm();
Timer.Stop();
}
}
bool CanHidePeekForm {
get {
Point screenPoint = Control.MousePosition;
Point clientPoint = _officeNavigationBar.Parent.PointToClient(Control.MousePosition);
return !_currentPeekForm.Bounds.Contains(screenPoint) && !_officeNavigationBar.Bounds.Contains(clientPoint);
}
}
public void SetPeekFormBehavior(bool autoHideOnMouseLeave) {
_officeNavigationBar.PeekFormShown -= OnPeekFormShown;
if (_timer != null) {
_timer.Tick -= timer_Tick;
_timer.Dispose();
_timer = null;
}
if (autoHideOnMouseLeave)
_officeNavigationBar.PeekFormShown += OnPeekFormShown;
}
void OnPeekFormShown(object sender, DevExpress.XtraBars.Navigation.NavigationPeekFormEventArgs e) {
_currentPeekForm = e.Control.FindForm() as FlyoutPanelBeakForm;
Timer.Stop();
Timer.Start();
}
}
}