Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
4797c957
Commit
4797c957
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add missing method docstrings.
Refers to
#2
parent
5b858d45
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxTray/AutoTxTray.cs
+53
-0
53 additions, 0 deletions
ATxTray/AutoTxTray.cs
with
53 additions
and
0 deletions
ATxTray/AutoTxTray.cs
+
53
−
0
View file @
4797c957
...
@@ -65,6 +65,10 @@ namespace ATxTray
...
@@ -65,6 +65,10 @@ namespace ATxTray
private
static
TaskDialog
_confirmDialog
;
private
static
TaskDialog
_confirmDialog
;
private
static
DirectoryInfo
_selectedDir
;
private
static
DirectoryInfo
_selectedDir
;
/// <summary>
/// Constructor setting up tray icon, config + status, timer and file system watcher.
/// </summary>
/// <param name="baseDir">The base directory of the AutoTx service installation.</param>
public
AutoTxTray
(
string
baseDir
)
{
public
AutoTxTray
(
string
baseDir
)
{
SetupLogging
();
SetupLogging
();
...
@@ -136,6 +140,9 @@ namespace ATxTray
...
@@ -136,6 +140,9 @@ namespace ATxTray
LogManager
.
Configuration
=
logConfig
;
LogManager
.
Configuration
=
logConfig
;
}
}
/// <summary>
/// Set up the tray icon context menu entries.
/// </summary>
private
void
SetupContextMenu
()
{
private
void
SetupContextMenu
()
{
Log
.
Trace
(
"Building context menu..."
);
Log
.
Trace
(
"Building context menu..."
);
_miExit
.
Text
=
@"Exit"
;
_miExit
.
Text
=
@"Exit"
;
...
@@ -210,6 +217,9 @@ namespace ATxTray
...
@@ -210,6 +217,9 @@ namespace ATxTray
_notifyIcon
.
Text
=
msg
;
_notifyIcon
.
Text
=
msg
;
}
}
/// <summary>
/// Refresh status information and update tray icon and context menu items accordingly.
/// </summary>
private
void
AppTimerElapsed
(
object
sender
,
ElapsedEventArgs
e
)
{
private
void
AppTimerElapsed
(
object
sender
,
ElapsedEventArgs
e
)
{
if
(
_status
==
null
)
{
if
(
_status
==
null
)
{
AutoTxTrayExit
();
AutoTxTrayExit
();
...
@@ -244,16 +254,25 @@ namespace ATxTray
...
@@ -244,16 +254,25 @@ namespace ATxTray
_statusChanged
=
false
;
_statusChanged
=
false
;
}
}
/// <summary>
/// Set global flag indicating the status file has changed and needs to be re-read.
/// </summary>
private
static
void
StatusFileUpdated
(
object
sender
,
FileSystemEventArgs
e
)
{
private
static
void
StatusFileUpdated
(
object
sender
,
FileSystemEventArgs
e
)
{
_statusFileChanged
=
true
;
_statusFileChanged
=
true
;
}
}
/// <summary>
/// Event handler to make the context menu appear on the screen.
/// </summary>
private
void
ShowContextMenu
(
object
sender
,
EventArgs
e
)
{
private
void
ShowContextMenu
(
object
sender
,
EventArgs
e
)
{
// just show the menu again, to avoid that clicking the menu item closes the context
// just show the menu again, to avoid that clicking the menu item closes the context
// menu without having to disable the item (which would grey out the text and icon):
// menu without having to disable the item (which would grey out the text and icon):
_notifyIcon
.
ContextMenuStrip
.
Show
();
_notifyIcon
.
ContextMenuStrip
.
Show
();
}
}
/// <summary>
/// Let the user select a directory for starting a new transfer.
/// </summary>
private
static
void
PickDirectoryForNewTransfer
(
object
sender
,
EventArgs
e
)
{
private
static
void
PickDirectoryForNewTransfer
(
object
sender
,
EventArgs
e
)
{
if
(!
Directory
.
Exists
(
_submitPath
))
{
if
(!
Directory
.
Exists
(
_submitPath
))
{
Log
.
Error
(
"Current user has no incoming directory: [{0}]"
,
_submitPath
);
Log
.
Error
(
"Current user has no incoming directory: [{0}]"
,
_submitPath
);
...
@@ -285,6 +304,9 @@ namespace ATxTray
...
@@ -285,6 +304,9 @@ namespace ATxTray
NewTxConfirmationDialog
();
NewTxConfirmationDialog
();
}
}
/// <summary>
/// Let the user confirm the directory choice by presenting a summary with name, size etc.
/// </summary>
private
static
void
NewTxConfirmationDialog
()
{
private
static
void
NewTxConfirmationDialog
()
{
var
folderName
=
_selectedDir
.
Name
;
var
folderName
=
_selectedDir
.
Name
;
var
locationPath
=
_selectedDir
.
Parent
?.
FullName
;
var
locationPath
=
_selectedDir
.
Parent
?.
FullName
;
...
@@ -332,22 +354,37 @@ namespace ATxTray
...
@@ -332,22 +354,37 @@ namespace ATxTray
}
}
}
}
/// <summary>
/// Dummy handler to set the TaskDialog icon.
/// </summary>
private
static
void
TaskDialogOpened
(
object
sender
,
EventArgs
e
)
{
private
static
void
TaskDialogOpened
(
object
sender
,
EventArgs
e
)
{
var
td
=
sender
as
TaskDialog
;
var
td
=
sender
as
TaskDialog
;
td
.
Icon
=
TaskDialogStandardIcon
.
Shield
;
td
.
Icon
=
TaskDialogStandardIcon
.
Shield
;
}
}
/// <summary>
/// Close the confirmation dialog and submit the selected dir for transfer.
/// </summary>
private
static
void
ConfirmAcceptClick
(
object
sender
,
EventArgs
e
)
{
private
static
void
ConfirmAcceptClick
(
object
sender
,
EventArgs
e
)
{
_confirmDialog
.
Close
();
_confirmDialog
.
Close
();
SubmitDirForNewTx
();
SubmitDirForNewTx
();
}
}
/// <summary>
/// Close the confirmation dialog and re-show the directory picker.
/// </summary>
private
static
void
ConfirmChangeClick
(
object
sender
,
EventArgs
e
)
{
private
static
void
ConfirmChangeClick
(
object
sender
,
EventArgs
e
)
{
_confirmDialog
.
Close
();
_confirmDialog
.
Close
();
Log
.
Debug
(
"User wants to change directory choice."
);
Log
.
Debug
(
"User wants to change directory choice."
);
PickDirectoryForNewTransfer
(
sender
,
e
);
PickDirectoryForNewTransfer
(
sender
,
e
);
}
}
/// <summary>
/// Submit the selected directory as a new transfer.
///
/// The chosen folder will be moved to the AutoTx "incoming" location of the current user
/// where it will be picked up by the service as a new transfer.
/// </summary>
private
static
void
SubmitDirForNewTx
()
{
private
static
void
SubmitDirForNewTx
()
{
Log
.
Debug
(
$"User accepted directory choice [
{
_selectedDir
.
FullName
}
]."
);
Log
.
Debug
(
$"User accepted directory choice [
{
_selectedDir
.
FullName
}
]."
);
var
tgtPath
=
Path
.
Combine
(
_submitPath
,
_selectedDir
.
Name
);
var
tgtPath
=
Path
.
Combine
(
_submitPath
,
_selectedDir
.
Name
);
...
@@ -386,6 +423,9 @@ namespace ATxTray
...
@@ -386,6 +423,9 @@ namespace ATxTray
return
plist
.
Length
>
0
;
return
plist
.
Length
>
0
;
}
}
/// <summary>
/// Check if the service process is alive and update context menu entries accordingly.
/// </summary>
private
void
UpdateServiceProcessState
()
{
private
void
UpdateServiceProcessState
()
{
var
isServiceProcessAlive
=
IsServiceProcessAlive
();
var
isServiceProcessAlive
=
IsServiceProcessAlive
();
if
(
_serviceProcessAlive
==
isServiceProcessAlive
)
if
(
_serviceProcessAlive
==
isServiceProcessAlive
)
...
@@ -413,6 +453,9 @@ namespace ATxTray
...
@@ -413,6 +453,9 @@ namespace ATxTray
}
}
}
}
/// <summary>
/// Update the context menu with the current "suspended" state of the service.
/// </summary>
private
void
UpdateServiceSuspendedState
()
{
private
void
UpdateServiceSuspendedState
()
{
// first update the suspend reason as this can possibly change even if the service
// first update the suspend reason as this can possibly change even if the service
// never leaves the suspended state and we should still display the correct reason:
// never leaves the suspended state and we should still display the correct reason:
...
@@ -439,6 +482,10 @@ namespace ATxTray
...
@@ -439,6 +482,10 @@ namespace ATxTray
}
}
}
}
/// <summary>
/// Update the context menu regarding the current transfer state, show a balloon tooltip
/// if the transfer status has changed.
/// </summary>
private
void
UpdateTxInProgressState
()
{
private
void
UpdateTxInProgressState
()
{
if
(
_txInProgress
==
_status
.
TransferInProgress
&&
if
(
_txInProgress
==
_status
.
TransferInProgress
&&
_txSize
==
_status
.
CurrentTransferSize
)
_txSize
==
_status
.
CurrentTransferSize
)
...
@@ -460,6 +507,9 @@ namespace ATxTray
...
@@ -460,6 +507,9 @@ namespace ATxTray
}
}
}
}
/// <summary>
/// Update the transfer progress bar.
/// </summary>
private
void
UpdateTxProgressBar
()
{
private
void
UpdateTxProgressBar
()
{
if
(
_txInProgress
==
_status
.
TransferInProgress
&&
if
(
_txInProgress
==
_status
.
TransferInProgress
&&
_txProgressPct
==
_status
.
CurrentTransferPercent
)
_txProgressPct
==
_status
.
CurrentTransferPercent
)
...
@@ -478,6 +528,9 @@ namespace ATxTray
...
@@ -478,6 +528,9 @@ namespace ATxTray
}
}
}
}
/// <summary>
/// Update the tray icon reflecting the current service and transfer status.
/// </summary>
private
void
UpdateTrayIcon
()
{
private
void
UpdateTrayIcon
()
{
// if a transfer is running and active show the transfer icon, alternating between its
// if a transfer is running and active show the transfer icon, alternating between its
// two variants every second ("blinking")
// two variants every second ("blinking")
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment