Changed project names
This commit is contained in:
parent
b4c4aa4010
commit
a29e57e66d
130 changed files with 501 additions and 504 deletions
82
UI/AmagnoVirtualPrinter.ProgressInfo/ProgressForm.cs
Normal file
82
UI/AmagnoVirtualPrinter.ProgressInfo/ProgressForm.cs
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
using NamedPipeWrapper;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using AmagnoVirtualPrinter.ProgressInfo.Core.Message;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace AmagnoVirtualPrinter.ProgressInfo
|
||||
{
|
||||
public partial class ProgressForm : Form
|
||||
{
|
||||
private const string PipeName = "vdpagent";
|
||||
|
||||
public ProgressForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var client = new NamedPipeClient<Core.Message.Message>(PipeName)
|
||||
{
|
||||
AutoReconnect = true
|
||||
};
|
||||
|
||||
client.ServerMessage += ServerMessage;
|
||||
client.Start(new TimeSpan(TimeSpan.TicksPerMinute));
|
||||
}
|
||||
|
||||
private void ServerMessage(NamedPipeConnection<Core.Message.Message, Core.Message.Message> connection, [NotNull]Core.Message.Message message)
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
|
||||
switch (message.Type) {
|
||||
case MessageType.Finalize:
|
||||
Invoke((Action) Finish);
|
||||
break;
|
||||
case MessageType.Initialize:
|
||||
Invoke((Action) Initialize);
|
||||
break;
|
||||
case MessageType.Step:
|
||||
Invoke((Action) (() => Progress(message.Value)));
|
||||
break;
|
||||
case MessageType.Close:
|
||||
Invoke((Action) Dispose);
|
||||
break;
|
||||
case MessageType.None:
|
||||
throw new ArgumentException("'None' is not a valid MessageType");
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private void Progress(uint val)
|
||||
{
|
||||
lbProgress.Text = $@"{val} pages converted";
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
PlaceToBottomRight();
|
||||
Show();
|
||||
BringToFront();
|
||||
}
|
||||
|
||||
private void Finish()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void PlaceToBottomRight()
|
||||
{
|
||||
var desktopWorkingArea = Screen.PrimaryScreen.WorkingArea;
|
||||
Left = desktopWorkingArea.Right - Width - 12;
|
||||
Top = desktopWorkingArea.Bottom - Height - 12;
|
||||
}
|
||||
|
||||
private void ProgressForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue