Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
d762af99
Commit
d762af99
authored
May 30, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
状态栏 图标 释放
parent
aa7d0d93
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
87 deletions
+33
-87
AppJustOne.cs
Project.FLY.AppHelper/FLY.AppHelper/AppJustOne.cs
+16
-7
FLY.AppHelper.csproj
Project.FLY.AppHelper/FLY.AppHelper/FLY.AppHelper.csproj
+0
-1
TaskBarUtil.cs
Project.FLY.AppHelper/FLY.AppHelper/TaskBarUtil.cs
+0
-70
WindowNotifyIconHelper.cs
...ect.FLY.AppHelper/FLY.AppHelper/WindowNotifyIconHelper.cs
+17
-9
No files found.
Project.FLY.AppHelper/FLY.AppHelper/AppJustOne.cs
View file @
d762af99
...
@@ -8,6 +8,18 @@ namespace FLY.AppHelper
...
@@ -8,6 +8,18 @@ namespace FLY.AppHelper
{
{
public
class
AppJustOne
public
class
AppJustOne
{
{
static
bool
IsReboot
=
false
;
public
static
void
Restart
()
{
//通知AppJustOne不要限制
IsReboot
=
true
;
//重启软件
System
.
Windows
.
Forms
.
Application
.
Restart
();
Application
.
Current
.
Shutdown
();
}
public
AppJustOne
(
Application
app
)
public
AppJustOne
(
Application
app
)
{
{
app
.
Startup
+=
new
StartupEventHandler
(
app_Startup
);
app
.
Startup
+=
new
StartupEventHandler
(
app_Startup
);
...
@@ -16,14 +28,11 @@ namespace FLY.AppHelper
...
@@ -16,14 +28,11 @@ namespace FLY.AppHelper
void
app_Startup
(
object
sender
,
StartupEventArgs
e
)
void
app_Startup
(
object
sender
,
StartupEventArgs
e
)
{
{
if
(
Application
.
Current
.
Properties
.
Contains
(
"reboot"
))
{
if
(
IsReboot
)
bool
isReboot
=
(
bool
)
Application
.
Current
.
Properties
[
"reboot"
];
{
Application
.
Current
.
Properties
[
"reboot"
]
=
false
;
IsReboot
=
false
;
if
(
isReboot
)
{
return
;
return
;
}
}
}
Process
process
=
Process
.
GetCurrentProcess
();
Process
process
=
Process
.
GetCurrentProcess
();
...
...
Project.FLY.AppHelper/FLY.AppHelper/FLY.AppHelper.csproj
View file @
d762af99
...
@@ -52,7 +52,6 @@
...
@@ -52,7 +52,6 @@
<ItemGroup>
<ItemGroup>
<Compile
Include=
"AppJustOne.cs"
/>
<Compile
Include=
"AppJustOne.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"TaskBarUtil.cs"
/>
<Compile
Include=
"WindowNotifyIconHelper.cs"
/>
<Compile
Include=
"WindowNotifyIconHelper.cs"
/>
</ItemGroup>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
...
...
Project.FLY.AppHelper/FLY.AppHelper/TaskBarUtil.cs
deleted
100644 → 0
View file @
aa7d0d93
using
System
;
using
System.Runtime.InteropServices
;
namespace
FLY.AppHelper
{
public
class
TaskBarUtil
{
struct
RECT
{
public
int
left
,
top
,
right
,
bottom
;
}
public
static
void
RefreshNotificationArea
()
{
var
notificationAreaHandle
=
GetNotificationAreaHandle
();
if
(
notificationAreaHandle
==
IntPtr
.
Zero
)
return
;
RefreshWindow
(
notificationAreaHandle
);
}
private
static
void
RefreshWindow
(
IntPtr
windowHandle
)
{
const
uint
wmMousemove
=
0x0200
;
RECT
rect
;
GetClientRect
(
windowHandle
,
out
rect
);
for
(
var
x
=
0
;
x
<
rect
.
right
;
x
+=
5
)
for
(
var
y
=
0
;
y
<
rect
.
bottom
;
y
+=
5
)
SendMessage
(
windowHandle
,
wmMousemove
,
0
,
(
y
<<
16
)
+
x
);
}
private
static
IntPtr
GetNotificationAreaHandle
()
{
const
string
notificationAreaTitle
=
"Notification Area"
;
//const string notificationAreaTitleInWindows7 = "User Promoted Notification Area";
const
string
notificationAreaTitleInWindows7
=
"用户显示的通知区域"
;
//for chinese version
var
systemTrayContainerHandle
=
FindWindowEx
(
IntPtr
.
Zero
,
IntPtr
.
Zero
,
"Shell_TrayWnd"
,
string
.
Empty
);
var
systemTrayHandle
=
FindWindowEx
(
systemTrayContainerHandle
,
IntPtr
.
Zero
,
"TrayNotifyWnd"
,
string
.
Empty
);
var
sysPagerHandle
=
FindWindowEx
(
systemTrayHandle
,
IntPtr
.
Zero
,
"SysPager"
,
string
.
Empty
);
var
notificationAreaHandle
=
FindWindowEx
(
sysPagerHandle
,
IntPtr
.
Zero
,
"ToolbarWindow32"
,
notificationAreaTitle
);
if
(
notificationAreaHandle
==
IntPtr
.
Zero
)
notificationAreaHandle
=
FindWindowEx
(
sysPagerHandle
,
IntPtr
.
Zero
,
"ToolbarWindow32"
,
notificationAreaTitleInWindows7
);
return
notificationAreaHandle
;
}
[
DllImport
(
"user32.dll"
,
SetLastError
=
true
)]
static
extern
IntPtr
FindWindowEx
(
IntPtr
parentHandle
,
IntPtr
childAfter
,
string
className
,
string
windowTitle
);
[
DllImport
(
"user32.dll"
)]
static
extern
bool
GetClientRect
(
IntPtr
handle
,
out
RECT
rect
);
[
DllImport
(
"user32.dll"
,
CharSet
=
CharSet
.
Auto
)]
static
extern
IntPtr
SendMessage
(
IntPtr
handle
,
UInt32
message
,
Int32
wParam
,
Int32
lParam
);
}
}
Project.FLY.AppHelper/FLY.AppHelper/WindowNotifyIconHelper.cs
View file @
d762af99
...
@@ -24,8 +24,6 @@ namespace FLY.AppHelper
...
@@ -24,8 +24,6 @@ namespace FLY.AppHelper
/// <param name="text">当鼠标指针停留在通知区域图标上时显示的工具提示文本</param>
/// <param name="text">当鼠标指针停留在通知区域图标上时显示的工具提示文本</param>
public
WindowNotifyIconHelper
(
System
.
Windows
.
Window
window
,
string
text
)
public
WindowNotifyIconHelper
(
System
.
Windows
.
Window
window
,
string
text
)
{
{
TaskBarUtil
.
RefreshNotificationArea
();
notifyIcon
=
new
System
.
Windows
.
Forms
.
NotifyIcon
();
notifyIcon
=
new
System
.
Windows
.
Forms
.
NotifyIcon
();
//this.notifyIcon.BalloonTipText = "Hello, NotifyIcon!";
//this.notifyIcon.BalloonTipText = "Hello, NotifyIcon!";
notifyIcon
.
Text
=
text
;
notifyIcon
.
Text
=
text
;
...
@@ -49,6 +47,14 @@ namespace FLY.AppHelper
...
@@ -49,6 +47,14 @@ namespace FLY.AppHelper
wsl
=
this
.
window
.
WindowState
;
wsl
=
this
.
window
.
WindowState
;
this
.
window
.
StateChanged
+=
new
EventHandler
(
window_StateChanged
);
this
.
window
.
StateChanged
+=
new
EventHandler
(
window_StateChanged
);
this
.
window
.
Closing
+=
new
System
.
ComponentModel
.
CancelEventHandler
(
window_Closing
);
this
.
window
.
Closing
+=
new
System
.
ComponentModel
.
CancelEventHandler
(
window_Closing
);
Application
.
ApplicationExit
+=
Application_ApplicationExit
;
}
private
void
Application_ApplicationExit
(
object
sender
,
EventArgs
e
)
{
notifyIcon
.
Dispose
();
//System.Environment.Exit(0); //这个是不会触发 ApplicationExit, 但可以把全部线程清除掉
}
}
...
@@ -63,9 +69,11 @@ namespace FLY.AppHelper
...
@@ -63,9 +69,11 @@ namespace FLY.AppHelper
if
(
r
==
System
.
Windows
.
MessageBoxResult
.
Yes
)
if
(
r
==
System
.
Windows
.
MessageBoxResult
.
Yes
)
{
{
//notifyIcon.Visible = false;
//notifyIcon.Visible = false;
notifyIcon
.
Dispose
();
//
notifyIcon.Dispose();
//System.Windows.Application.Current.Shutdown();
//System.Windows.Application.Current.Shutdown();
System
.
Environment
.
Exit
(
0
);
//Application.Exit();
notifyIcon
.
Dispose
();
System
.
Environment
.
Exit
(
0
);
//这个是不会触发 ApplicationExit, 但可以把全部线程清除掉
}
}
}
}
void
window_Closing
(
object
sender
,
System
.
ComponentModel
.
CancelEventArgs
e
)
void
window_Closing
(
object
sender
,
System
.
ComponentModel
.
CancelEventArgs
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment