Browse Source

small fix

tags/3.0
Gang Zhuo 9 years ago
parent
commit
a070c3c986
4 changed files with 52 additions and 29 deletions
  1. +6
    -0
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  2. +18
    -1
      shadowsocks-csharp/Model/LogViewerConfig.cs
  3. +27
    -27
      shadowsocks-csharp/View/LogForm.cs
  4. +1
    -1
      shadowsocks-csharp/View/MenuViewController.cs

+ 6
- 0
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -286,6 +286,12 @@ namespace Shadowsocks.Controller
Configuration.Save(_config);
}
public void SaveLogViewerConfig(LogViewerConfig newConfig)
{
_config.logViewer = newConfig;
Configuration.Save(_config);
}
protected void Reload()
{
// some logic in configuration updated the config when saving, we need to read it again


+ 18
- 1
shadowsocks-csharp/Model/LogViewerConfig.cs View File

@@ -25,6 +25,24 @@ namespace Shadowsocks.Model
this.toolbarShown = false;
}
public Font GetFont()
{
try
{
return new Font(fontName, fontSize);
}
catch (Exception)
{
return new Font("Console", 8F);
}
}
public void SetFont(Font font)
{
fontName = font.Name;
fontSize = font.Size;
}
public Color GetBackgroundColor()
{
try
@@ -51,7 +69,6 @@ namespace Shadowsocks.Model
catch (Exception)
{
return ColorTranslator.FromHtml("white");
throw;
}
}


+ 27
- 27
shadowsocks-csharp/View/LogForm.cs View File

@@ -1,6 +1,4 @@
using Shadowsocks.Controller;
using Shadowsocks.Properties;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -10,6 +8,10 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using Shadowsocks.Controller;
using Shadowsocks.Properties;
using Shadowsocks.Model;
namespace Shadowsocks.View
{
public partial class LogForm : Form
@@ -18,28 +20,24 @@ namespace Shadowsocks.View
string filename;
Timer timer;
const int BACK_OFFSET = 65536;
Model.Configuration config;
ShadowsocksController controller;
public LogForm(string filename)
public LogForm(ShadowsocksController controller, string filename)
{
this.controller = controller;
this.filename = filename;
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();
}
LogViewerConfig config = controller.GetConfigurationCopy().logViewer;
if (config == null)
config = new LogViewerConfig();
topMostTrigger = config.topMost;
wrapTextTrigger = config.wrapText;
toolbarTrigger = config.toolbarShown;
LogMessageTextBox.BackColor = config.GetBackgroundColor();
LogMessageTextBox.ForeColor = config.GetTextColor();
LogMessageTextBox.Font = config.GetFont();
UpdateTexts();
}
@@ -134,14 +132,16 @@ namespace Shadowsocks.View
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);
LogViewerConfig config = controller.GetConfigurationCopy().logViewer;
if (config == null)
config = new LogViewerConfig();
config.topMost = topMostTrigger;
config.wrapText = wrapTextTrigger;
config.toolbarShown = toolbarTrigger;
config.SetFont(LogMessageTextBox.Font);
config.SetBackgroundColor(LogMessageTextBox.BackColor);
config.SetTextColor(LogMessageTextBox.ForeColor);
controller.SaveLogViewerConfig(config);
}
private void OpenLocationMenuItem_Click(object sender, EventArgs e)


+ 1
- 1
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -439,7 +439,7 @@ namespace Shadowsocks.View
{
string argument = Logging.LogFile;
new LogForm(argument).Show();
new LogForm(controller, argument).Show();
}
private void QRCodeItem_Click(object sender, EventArgs e)


Loading…
Cancel
Save