diff --git a/ui-win32/AboutBox.Designer.cs b/ui-win32/AboutBox.Designer.cs
index 0c6390183..88db3d6fe 100644
--- a/ui-win32/AboutBox.Designer.cs
+++ b/ui-win32/AboutBox.Designer.cs
@@ -163,7 +163,7 @@
this.Padding = new System.Windows.Forms.Padding(9);
this.ShowIcon = false;
this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AboutBox1";
this.tableLayoutPanel.ResumeLayout(false);
this.tableLayoutPanel.PerformLayout();
diff --git a/ui-win32/UIMain.Designer.cs b/ui-win32/UIMain.Designer.cs
index 15fe3d556..5e880ce56 100644
--- a/ui-win32/UIMain.Designer.cs
+++ b/ui-win32/UIMain.Designer.cs
@@ -39,6 +39,14 @@
this.btnDrop = new System.Windows.Forms.Button();
this.btnConfigProfile = new System.Windows.Forms.Button();
this.btnAbout = new System.Windows.Forms.Button();
+ this.TrayMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.TrayConnect = new System.Windows.Forms.ToolStripMenuItem();
+ this.TrayDisconnect = new System.Windows.Forms.ToolStripMenuItem();
+ this.saveLogToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.showToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.TrayMenu.SuspendLayout();
this.SuspendLayout();
//
// StatusLabel
@@ -72,6 +80,7 @@
//
// NotificationTrayIcon
//
+ this.NotificationTrayIcon.ContextMenuStrip = this.TrayMenu;
this.NotificationTrayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("NotificationTrayIcon.Icon")));
this.NotificationTrayIcon.Text = "LokiNET - disconnected";
this.NotificationTrayIcon.Visible = true;
@@ -143,6 +152,60 @@
this.btnAbout.UseVisualStyleBackColor = true;
this.btnAbout.Click += new System.EventHandler(this.btnAbout_Click);
//
+ // TrayMenu
+ //
+ this.TrayMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.showToolStripMenuItem,
+ this.TrayConnect,
+ this.TrayDisconnect,
+ this.saveLogToFileToolStripMenuItem,
+ this.aboutToolStripMenuItem,
+ this.exitToolStripMenuItem});
+ this.TrayMenu.Name = "TrayMenu";
+ this.TrayMenu.Size = new System.Drawing.Size(181, 158);
+ //
+ // TrayConnect
+ //
+ this.TrayConnect.Name = "TrayConnect";
+ this.TrayConnect.Size = new System.Drawing.Size(180, 22);
+ this.TrayConnect.Text = "Connect";
+ this.TrayConnect.Click += new System.EventHandler(this.TrayConnect_Click);
+ //
+ // TrayDisconnect
+ //
+ this.TrayDisconnect.Name = "TrayDisconnect";
+ this.TrayDisconnect.Size = new System.Drawing.Size(180, 22);
+ this.TrayDisconnect.Text = "Disconnect";
+ this.TrayDisconnect.Click += new System.EventHandler(this.TrayDisconnect_Click);
+ //
+ // saveLogToFileToolStripMenuItem
+ //
+ this.saveLogToFileToolStripMenuItem.Name = "saveLogToFileToolStripMenuItem";
+ this.saveLogToFileToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.saveLogToFileToolStripMenuItem.Text = "Save Log to File...";
+ this.saveLogToFileToolStripMenuItem.Click += new System.EventHandler(this.saveLogToFileToolStripMenuItem_Click);
+ //
+ // aboutToolStripMenuItem
+ //
+ this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
+ this.aboutToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.aboutToolStripMenuItem.Text = "About...";
+ this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
+ //
+ // exitToolStripMenuItem
+ //
+ this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
+ this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.exitToolStripMenuItem.Text = "Exit";
+ this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
+ //
+ // showToolStripMenuItem
+ //
+ this.showToolStripMenuItem.Name = "showToolStripMenuItem";
+ this.showToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.showToolStripMenuItem.Text = "Show";
+ this.showToolStripMenuItem.Click += new System.EventHandler(this.showToolStripMenuItem_Click);
+ //
// main_frame
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -161,6 +224,7 @@
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "LokiNET Launcher";
+ this.TrayMenu.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -177,6 +241,13 @@
private System.Windows.Forms.Button btnConfigProfile;
public System.Windows.Forms.TextBox lokinetd_fd1;
private System.Windows.Forms.Button btnAbout;
+ private System.Windows.Forms.ContextMenuStrip TrayMenu;
+ private System.Windows.Forms.ToolStripMenuItem TrayConnect;
+ private System.Windows.Forms.ToolStripMenuItem TrayDisconnect;
+ private System.Windows.Forms.ToolStripMenuItem saveLogToFileToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem showToolStripMenuItem;
}
}
diff --git a/ui-win32/UIMain.cs b/ui-win32/UIMain.cs
index 8856fa0c8..3b22271bf 100644
--- a/ui-win32/UIMain.cs
+++ b/ui-win32/UIMain.cs
@@ -12,6 +12,8 @@ namespace network.loki.lokinet.win32.ui
public static Process lokiNetDaemon = new Process();
public static bool isConnected;
public static string logText;
+ private string config_path;
+ private LogDumper ld;
void UpdateUI(string text)
{
@@ -21,6 +23,10 @@ namespace network.loki.lokinet.win32.ui
public main_frame()
{
InitializeComponent();
+ if (Program.platform == PlatformID.Win32NT)
+ config_path = Environment.ExpandEnvironmentVariables("%APPDATA%\\.lokinet");
+ else
+ config_path = Environment.ExpandEnvironmentVariables("%HOME%/.lokinet");
StatusLabel.Text = "Disconnected";
var build = ((AssemblyInformationalVersionAttribute)Assembly
.GetAssembly(typeof(main_frame))
@@ -63,10 +69,13 @@ namespace network.loki.lokinet.win32.ui
lokiNetDaemon.Start();
lokiNetDaemon.BeginOutputReadLine();
btnConnect.Enabled = false;
+ TrayConnect.Enabled = false;
StatusLabel.Text = "Connected";
isConnected = true;
NotificationTrayIcon.Text = "LokiNET - connected";
btnDrop.Enabled = true;
+ TrayDisconnect.Enabled = true;
+ NotificationTrayIcon.ShowBalloonTip(5, "LokiNET", "Connected to network.", ToolTipIcon.Info);
}
private void btnDrop_Click(object sender, EventArgs e)
@@ -74,12 +83,16 @@ namespace network.loki.lokinet.win32.ui
lokiNetDaemon.CancelOutputRead();
lokiNetDaemon.Kill();
btnConnect.Enabled = true;
+ TrayConnect.Enabled = true;
btnDrop.Enabled = false;
+ TrayDisconnect.Enabled = false;
StatusLabel.Text = "Disconnected";
NotificationTrayIcon.Text = "LokiNET - disconnected";
isConnected = false;
logText = lokinetd_fd1.Text;
lokinetd_fd1.Text = string.Empty;
+ NotificationTrayIcon.ShowBalloonTip(5, "LokiNET", "Disconnected from network.", ToolTipIcon.Info);
+
}
private void lokinetd_fd1_TextChanged(object sender, EventArgs e)
@@ -98,14 +111,66 @@ namespace network.loki.lokinet.win32.ui
private void NotificationTrayIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
- Show();
+ if (!Visible)
+ {
+ Show();
+ }
}
private void btnAbout_Click(object sender, EventArgs e)
+ {
+ AboutBox a = new AboutBox();
+ a.ShowDialog(this);
+ a.Dispose();
+ }
+
+ private void saveLogToFileToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (isConnected)
+ MessageBox.Show("Cannot dump log when client is running.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+ else
+ {
+ if (logText == string.Empty)
+ {
+ MessageBox.Show("Log is empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+ return;
+ }
+ if (ld == null)
+ ld = new LogDumper(logText);
+ else
+ ld.setText(logText);
+
+ ld.CreateLog(config_path);
+ MessageBox.Show(string.Format("Wrote log to {0}, previous log rotated", ld.getLogPath()), "LokiNET", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ logText = string.Empty;
+ }
+ }
+
+ private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
AboutBox a = new AboutBox();
a.ShowDialog();
a.Dispose();
}
+
+ private void exitToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Application.Exit();
+ }
+
+ private void TrayDisconnect_Click(object sender, EventArgs e)
+ {
+ btnDrop_Click(sender, e);
+ }
+
+ private void TrayConnect_Click(object sender, EventArgs e)
+ {
+ btnConnect_Click(sender, e);
+ }
+
+ private void showToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Show();
+ }
}
}
diff --git a/ui-win32/UIMain.resx b/ui-win32/UIMain.resx
index 755412cfc..cdb00677c 100644
--- a/ui-win32/UIMain.resx
+++ b/ui-win32/UIMain.resx
@@ -120,6 +120,9 @@
17, 17
+
+ 179, 17
+