Skip to content

Commit 8b0fd5f

Browse files
committed
注释翻译结果自动消失
1 parent 05ca994 commit 8b0fd5f

File tree

2 files changed

+65
-68
lines changed

2 files changed

+65
-68
lines changed

TranslateResult.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
MaxWidth="700" MaxHeight="1000" Height="100" Width="200" MinWidth="250" MinHeight="100"
1212
WindowTransitionsEnabled="False"
1313
NonActiveWindowTitleBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
14-
WindowTitleBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" MouseEnter="OnMouseEnter" MouseLeave="OnMouseLeave" Closed="OnClosed">
14+
WindowTitleBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}">
1515
<mah:MetroWindow.IconTemplate>
1616
<DataTemplate>
1717
<Grid Width="{TemplateBinding Width}"

TranslateResult.xaml.cs

Lines changed: 64 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Linq;
3-
using System.Timers;
4-
using System.Windows;
1+
using System.Windows;
52
using System.Windows.Input;
63
using System.Windows.Media;
74

@@ -14,34 +11,34 @@ public partial class TranslateResult
1411
{
1512
public static RoutedCommand EscEvent = new RoutedCommand();
1613

17-
private static Timer _fadeTimer;
18-
private static Timer _stayTimer;
14+
//private static Timer _fadeTimer;
15+
//private static Timer _stayTimer;
1916

20-
//Get MainWindow
21-
private readonly MainWindow _mainWindow = Application.Current.Windows
22-
.Cast<Window>()
23-
.FirstOrDefault(window => window is MainWindow) as MainWindow;
17+
////Get MainWindow
18+
//private readonly MainWindow _mainWindow = Application.Current.Windows
19+
// .Cast<Window>()
20+
// .FirstOrDefault(window => window is MainWindow) as MainWindow;
2421

25-
private double _opacity = 1;
22+
//private double _opacity = 1;
2623

2724
public TranslateResult()
2825
{
2926
InitializeComponent();
3027

3128
EscEvent.InputGestures.Add(new KeyGesture(Key.Escape));
3229

33-
// Create a timer
34-
_stayTimer = new Timer(2000);
35-
// Hook up the Elapsed event for the timer.
36-
_stayTimer.Elapsed += OnStayTimedEvent;
30+
//// Create a timer
31+
//_stayTimer = new Timer(2000);
32+
//// Hook up the Elapsed event for the timer.
33+
//_stayTimer.Elapsed += OnStayTimedEvent;
3734

38-
// Create a timer
39-
_fadeTimer = new Timer(100);
40-
// Hook up the Elapsed event for the timer.
41-
_fadeTimer.Elapsed += OnFadeTimedEvent;
42-
_fadeTimer.AutoReset = true;
35+
//// Create a timer
36+
//_fadeTimer = new Timer(100);
37+
//// Hook up the Elapsed event for the timer.
38+
//_fadeTimer.Elapsed += OnFadeTimedEvent;
39+
//_fadeTimer.AutoReset = true;
4340

44-
Stay();
41+
//Stay();
4542
}
4643

4744
private void EscExecuted(object sender, ExecutedRoutedEventArgs e)
@@ -58,51 +55,51 @@ private void PinSwitch(object sender, RoutedEventArgs e)
5855
: (Brush)converter.ConvertFromString("#FFFFFEFF");
5956
}
6057

61-
private static void Stay()
62-
{
63-
_stayTimer.Start();
64-
}
65-
66-
private static void OnStayTimedEvent(object source, ElapsedEventArgs e)
67-
{
68-
Fade();
69-
_stayTimer.Stop();
70-
}
71-
72-
private static void Fade()
73-
{
74-
_fadeTimer.Start();
75-
}
76-
77-
private void OnFadeTimedEvent(object source, ElapsedEventArgs e)
78-
{
79-
_opacity -= 0.04;
80-
if (_opacity == 0) Close();
81-
82-
Dispatcher.Invoke(delegate { Opacity = _opacity; });
83-
}
84-
85-
private void OnMouseEnter(object sender, MouseEventArgs e)
86-
{
87-
Dispatcher.Invoke(delegate { Opacity = 1; });
88-
89-
_stayTimer.Stop();
90-
_fadeTimer.Stop();
91-
_opacity = 1;
92-
}
93-
94-
private void OnMouseLeave(object sender, MouseEventArgs e)
95-
{
96-
Stay();
97-
}
98-
99-
private void OnClosed(object sender, EventArgs e)
100-
{
101-
_fadeTimer.Stop();
102-
_fadeTimer.Dispose();
103-
104-
_stayTimer.Stop();
105-
_stayTimer.Dispose();
106-
}
58+
//private static void Stay()
59+
//{
60+
// _stayTimer.Start();
61+
//}
62+
63+
//private static void OnStayTimedEvent(object source, ElapsedEventArgs e)
64+
//{
65+
// Fade();
66+
// _stayTimer.Stop();
67+
//}
68+
69+
//private static void Fade()
70+
//{
71+
// _fadeTimer.Start();
72+
//}
73+
74+
//private void OnFadeTimedEvent(object source, ElapsedEventArgs e)
75+
//{
76+
// _opacity -= 0.04;
77+
// if (_opacity == 0) Close();
78+
79+
// Dispatcher.Invoke(delegate { Opacity = _opacity; });
80+
//}
81+
82+
//private void OnMouseEnter(object sender, MouseEventArgs e)
83+
//{
84+
// Dispatcher.Invoke(delegate { Opacity = 1; });
85+
86+
// _stayTimer.Stop();
87+
// _fadeTimer.Stop();
88+
// _opacity = 1;
89+
//}
90+
91+
//private void OnMouseLeave(object sender, MouseEventArgs e)
92+
//{
93+
// Stay();
94+
//}
95+
96+
//private void OnClosed(object sender, EventArgs e)
97+
//{
98+
// _fadeTimer.Stop();
99+
// _fadeTimer.Dispose();
100+
101+
// _stayTimer.Stop();
102+
// _stayTimer.Dispose();
103+
//}
107104
}
108105
}

0 commit comments

Comments
 (0)