diff --git a/shadowsocks-csharp/Model/Configuration.cs b/shadowsocks-csharp/Model/Configuration.cs
index 35ee5235..cf506072 100755
--- a/shadowsocks-csharp/Model/Configuration.cs
+++ b/shadowsocks-csharp/Model/Configuration.cs
@@ -24,6 +24,7 @@ namespace Shadowsocks.Model
public bool useOnlinePac;
public bool availabilityStatistics;
public bool autoCheckUpdate;
+ public LogViewerConfig logViewer;
private static string CONFIG_FILE = "gui-config.json";
diff --git a/shadowsocks-csharp/Model/LogViewerConfig.cs b/shadowsocks-csharp/Model/LogViewerConfig.cs
new file mode 100644
index 00000000..28471084
--- /dev/null
+++ b/shadowsocks-csharp/Model/LogViewerConfig.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Drawing;
+
+namespace Shadowsocks.Model
+{
+ [Serializable]
+ public class LogViewerConfig
+ {
+ public string fontName;
+ public float fontSize;
+ public string bgColor;
+ public string textColor;
+ public bool topMost;
+ public bool wrapText;
+ public bool toolbarShown;
+
+ public LogViewerConfig()
+ {
+ this.fontName = "Console";
+ this.fontSize = 8;
+ this.bgColor = "black";
+ this.textColor = "white";
+ this.topMost = false;
+ this.wrapText = false;
+ this.toolbarShown = false;
+ }
+
+ public Color GetBackgroundColor()
+ {
+ try
+ {
+ return ColorTranslator.FromHtml(bgColor);
+ }
+ catch (Exception)
+ {
+ return ColorTranslator.FromHtml("black");
+ }
+ }
+
+ public void SetBackgroundColor(Color color)
+ {
+ bgColor = ColorTranslator.ToHtml(color);
+ }
+
+ public Color GetTextColor()
+ {
+ try
+ {
+ return ColorTranslator.FromHtml(textColor);
+ }
+ catch (Exception)
+ {
+ return ColorTranslator.FromHtml("white");
+ throw;
+ }
+ }
+
+ public void SetTextColor(Color color)
+ {
+ textColor = ColorTranslator.ToHtml(color);
+ }
+ }
+}
diff --git a/shadowsocks-csharp/View/LogForm.cs b/shadowsocks-csharp/View/LogForm.cs
index c906b7d5..ab16faf0 100644
--- a/shadowsocks-csharp/View/LogForm.cs
+++ b/shadowsocks-csharp/View/LogForm.cs
@@ -18,6 +18,7 @@ namespace Shadowsocks.View
string filename;
Timer timer;
const int BACK_OFFSET = 65536;
+ Model.Configuration config;
public LogForm(string filename)
{
@@ -25,6 +26,21 @@ namespace Shadowsocks.View
InitializeComponent();
this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon());
+ config = Model.Configuration.Load();
+ if (config.logViewer == null)
+ {
+ config.logViewer = new Model.LogViewerConfig();
+ }
+ else
+ {
+ topMostTrigger = config.logViewer.topMost;
+ wrapTextTrigger = config.logViewer.wrapText;
+ toolbarTrigger = config.logViewer.toolbarShown;
+ LogMessageTextBox.Font = new Font(config.logViewer.fontName, config.logViewer.fontSize);
+ LogMessageTextBox.BackColor = config.logViewer.GetBackgroundColor();
+ LogMessageTextBox.ForeColor = config.logViewer.GetTextColor();
+ }
+
UpdateTexts();
}
@@ -103,14 +119,29 @@ namespace Shadowsocks.View
timer.Interval = 300;
timer.Tick += Timer_Tick;
timer.Start();
+
+ topMostTriggerLock = true;
this.TopMost = TopMostMenuItem.Checked = TopMostCheckBox.Checked = topMostTrigger;
- LogMessageTextBox.WordWrap = WrapTextCheckBox.Checked = WrapTextMenuItem.Checked = wrapTextTrigger;
- ToolbarFlowLayoutPanel.Visible = toolbarTrigger;
+ topMostTriggerLock = false;
+
+ wrapTextTriggerLock = true;
+ LogMessageTextBox.WordWrap = WrapTextMenuItem.Checked = WrapTextCheckBox.Checked = wrapTextTrigger;
+ wrapTextTriggerLock = false;
+
+ ToolbarFlowLayoutPanel.Visible = ShowToolbarMenuItem.Checked = toolbarTrigger;
}
private void LogForm_FormClosing(object sender, FormClosingEventArgs e)
{
timer.Stop();
+ config.logViewer.topMost = topMostTrigger;
+ config.logViewer.wrapText = wrapTextTrigger;
+ config.logViewer.toolbarShown = toolbarTrigger;
+ config.logViewer.fontName = LogMessageTextBox.Font.Name;
+ config.logViewer.fontSize = LogMessageTextBox.Font.Size;
+ config.logViewer.SetBackgroundColor(LogMessageTextBox.BackColor);
+ config.logViewer.SetTextColor(LogMessageTextBox.ForeColor);
+ Model.Configuration.Save(config);
}
private void OpenLocationMenuItem_Click(object sender, EventArgs e)
@@ -243,6 +274,7 @@ namespace Shadowsocks.View
#endregion
private bool toolbarTrigger = false;
+
private void ShowToolbarMenuItem_Click(object sender, EventArgs e)
{
toolbarTrigger = !toolbarTrigger;
diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj
index 8200aa07..dd957ffb 100644
--- a/shadowsocks-csharp/shadowsocks-csharp.csproj
+++ b/shadowsocks-csharp/shadowsocks-csharp.csproj
@@ -145,6 +145,7 @@
+