Skip to content

Commit

Permalink
Merge pull request #238 from Hirogen/issues/issue-182-high-dpi
Browse files Browse the repository at this point in the history
Issues/issue 182 high dpi
  • Loading branch information
Hirogen authored Jul 21, 2022
2 parents 6390095 + 9258183 commit 46f017b
Show file tree
Hide file tree
Showing 76 changed files with 2,123 additions and 2,029 deletions.
3 changes: 1 addition & 2 deletions src/LogExpert/Classes/Bookmark/BookmarkExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public static void ExportBookmarkList(SortedList<int, Entities.Bookmark> bookmar
foreach (Entities.Bookmark bookmark in bookmarkList.Values)
{
string line = logfileName + ";" + bookmark.LineNum + ";" +
bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine).Replace("\r\n",
replacementForNewLine);
bookmark.Text.Replace(replacementForNewLine, @"\" + replacementForNewLine).Replace("\r\n", replacementForNewLine);
writer.WriteLine(line);
}
writer.Close();
Expand Down
3 changes: 3 additions & 0 deletions src/LogExpert/Classes/Win32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public static Icon LoadIconFromExe(string fileName, int index)
}
return result;
}

[DllImport("user32.dll")]
public static extern long GetSystemMetricsForDpi(long index);


[DllImport("user32.dll")]
Expand Down
77 changes: 39 additions & 38 deletions src/LogExpert/Classes/xml/XmlBlockSplitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,29 @@ internal class XmlBlockSplitter : LogStreamReaderBase
{
#region Fields

private static readonly string[] splitStrings = new string[] { "\r\n", "\n", "\r" };
private static readonly char[] newLineChar = new char[] { '\n' };
private static readonly string[] _splitStrings = { "\r\n", "\n", "\r" };

private readonly XmlLogReader reader;
private static readonly char[] _newLineChar = { '\n' };

private readonly XmlParserContext context;
private readonly XmlReaderSettings settings;
private readonly XmlLogReader _reader;

private readonly Queue<string> lineList = new Queue<string>();
private readonly XmlParserContext _context;
private readonly XmlReaderSettings _settings;

private readonly Queue<string> _lineList = new Queue<string>();

private string stylesheet;
private XslCompiledTransform xslt;
private string _stylesheet;
private XslCompiledTransform _xslt;

#endregion

#region cTor

public XmlBlockSplitter(XmlLogReader reader, IXmlLogConfiguration xmlLogConfig)
{
this.reader = reader;
this.reader.StartTag = xmlLogConfig.XmlStartTag;
this.reader.EndTag = xmlLogConfig.XmlEndTag;
_reader = reader;
_reader.StartTag = xmlLogConfig.XmlStartTag;
_reader.EndTag = xmlLogConfig.XmlEndTag;

Stylesheet = xmlLogConfig.Stylesheet;

Expand All @@ -45,9 +46,9 @@ public XmlBlockSplitter(XmlLogReader reader, IXmlLogConfiguration xmlLogConfig)
nsmgr.AddNamespace(xmlLogConfig.Namespace[0], xmlLogConfig.Namespace[1]);
}
// Create the XmlParserContext.
context = new XmlParserContext(nt, nsmgr, null, XmlSpace.None);
settings = new XmlReaderSettings();
settings.ConformanceLevel = ConformanceLevel.Fragment;
_context = new XmlParserContext(nt, nsmgr, null, XmlSpace.None);
_settings = new XmlReaderSettings();
_settings.ConformanceLevel = ConformanceLevel.Fragment;
}

#endregion
Expand All @@ -56,30 +57,30 @@ public XmlBlockSplitter(XmlLogReader reader, IXmlLogConfiguration xmlLogConfig)

public override long Position
{
get => reader.Position;
set => reader.Position = value;
get => _reader.Position;
set => _reader.Position = value;
}

public override Encoding Encoding => reader.Encoding;
public override Encoding Encoding => _reader.Encoding;

public override bool IsBufferComplete => lineList.Count == 0;
public override bool IsBufferComplete => _lineList.Count == 0;

public string Stylesheet
{
get => stylesheet;
get => _stylesheet;
set
{
stylesheet = value;
if (stylesheet != null)
_stylesheet = value;
if (_stylesheet != null)
{
XmlReader stylesheetReader = XmlReader.Create(new StringReader(stylesheet));
XmlReader stylesheetReader = XmlReader.Create(new StringReader(_stylesheet));

xslt = new XslCompiledTransform();
xslt.Load(stylesheetReader);
_xslt = new XslCompiledTransform();
_xslt.Load(stylesheetReader);
}
else
{
xslt = null;
_xslt = null;
}
}
}
Expand All @@ -90,16 +91,16 @@ public string Stylesheet

private void ParseXmlBlock(string block)
{
if (stylesheet != null)
if (_stylesheet != null)
{
XmlReader xmlReader = XmlReader.Create(new StringReader(block), settings, context);
XmlReader xmlReader = XmlReader.Create(new StringReader(block), _settings, _context);

xmlReader.Read();
xmlReader.MoveToContent();
//xmlReader.MoveToContent();
StringWriter textWriter = new StringWriter();

xslt.Transform(xmlReader, null, textWriter);
_xslt.Transform(xmlReader, null, textWriter);
string message = textWriter.ToString();
SplitToLinesList(message);
}
Expand All @@ -113,17 +114,17 @@ private void ParseXmlBlock(string block)
private void SplitToLinesList(string message)
{
const int MAX_LEN = 3000;
string[] lines = message.Split(splitStrings, StringSplitOptions.None);
string[] lines = message.Split(_splitStrings, StringSplitOptions.None);
foreach (string theLine in lines)
{
string line = theLine.Trim(newLineChar);
string line = theLine.Trim(_newLineChar);
while (line.Length > MAX_LEN)
{
string part = line.Substring(0, MAX_LEN);
line = line.Substring(MAX_LEN);
lineList.Enqueue(part);
_lineList.Enqueue(part);
}
lineList.Enqueue(line);
_lineList.Enqueue(line);
}
}

Expand All @@ -135,20 +136,20 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
reader.Dispose();
_reader.Dispose();
}
}

public override int ReadChar()
{
return reader.ReadChar();
return _reader.ReadChar();
}

public override string ReadLine()
{
if (lineList.Count == 0)
if (_lineList.Count == 0)
{
string block = reader.ReadLine();
string block = _reader.ReadLine();
if (block == null)
{
return null;
Expand All @@ -160,10 +161,10 @@ public override string ReadLine()
}
catch (XmlException)
{
lineList.Enqueue("[XML Parser error] " + block);
_lineList.Enqueue("[XML Parser error] " + block);
}
}
return lineList.Dequeue();
return _lineList.Dequeue();
}

#endregion
Expand Down
10 changes: 7 additions & 3 deletions src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,17 @@ public partial class LogTabWindow : Form
public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNumbers)
{
InitializeComponent();

AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Dpi;

_startupFileNames = fileNames;
this._instanceNumber = instanceNumber;
this._showInstanceNumbers = showInstanceNumbers;
_instanceNumber = instanceNumber;
_showInstanceNumbers = showInstanceNumbers;

Load += OnLogTabWindowLoad;

ConfigManager.Instance.ConfigChanged += ConfigChanged;
ConfigManager.Instance.ConfigChanged += OnConfigChanged;
HilightGroupList = ConfigManager.Settings.hilightGroupList;

Rectangle led = new Rectangle(0, 0, 8, 2);
Expand Down
11 changes: 9 additions & 2 deletions src/LogExpert/Controls/LogTabWindow/LogTabWindowEventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void OnLogTabWindowClosing(object sender, CancelEventArgs e)

DestroyBookmarkWindow();

ConfigManager.Instance.ConfigChanged -= ConfigChanged;
ConfigManager.Instance.ConfigChanged -= OnConfigChanged;

SaveWindowPosition();
ConfigManager.Save(SettingsFlags.WindowPosition | SettingsFlags.FileHistory);
Expand Down Expand Up @@ -707,6 +707,7 @@ private void OnTabColorToolStripMenuItemClick(object sender, EventArgs e)
LogWindow.LogWindow logWindow = dockPanel.ActiveContent as LogWindow.LogWindow;

LogWindowData data = logWindow.Tag as LogWindowData;

if (data == null)
{
return;
Expand All @@ -720,18 +721,21 @@ private void OnTabColorToolStripMenuItemClick(object sender, EventArgs e)
SetTabColor(logWindow, data.color);
}
List<ColorEntry> delList = new List<ColorEntry>();

foreach (ColorEntry entry in ConfigManager.Settings.fileColors)
{
if (entry.FileName.ToLower().Equals(logWindow.FileName.ToLower()))
{
delList.Add(entry);
}
}

foreach (ColorEntry entry in delList)
{
ConfigManager.Settings.fileColors.Remove(entry);
}
ConfigManager.Settings.fileColors.Add(new ColorEntry(logWindow.FileName, dlg.Color));

while (ConfigManager.Settings.fileColors.Count > MAX_COLOR_HISTORY)
{
ConfigManager.Settings.fileColors.RemoveAt(0);
Expand All @@ -751,6 +755,7 @@ private void OnSaveProjectToolStripMenuItemClick(object sender, EventArgs e)
SaveFileDialog dlg = new SaveFileDialog();
dlg.DefaultExt = "lxj";
dlg.Filter = @"LogExpert session (*.lxj)|*.lxj";

if (dlg.ShowDialog() == DialogResult.OK)
{
string fileName = dlg.FileName;
Expand All @@ -768,6 +773,7 @@ private void OnSaveProjectToolStripMenuItemClick(object sender, EventArgs e)
}
}
}

ProjectData projectData = new ProjectData();
projectData.memberList = fileNames;
projectData.tabLayoutXml = SaveLayout();
Expand Down Expand Up @@ -836,7 +842,8 @@ private void OnHighlightGroupsComboBoxMouseUp(object sender, MouseEventArgs e)
}
}

private void ConfigChanged(object sender, ConfigChangedEventArgs e)

private void OnConfigChanged(object sender, ConfigChangedEventArgs e)
{
if (LogExpertProxy != null)
{
Expand Down
32 changes: 19 additions & 13 deletions src/LogExpert/Controls/LogTabWindow/LogTabWindowPrivate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,17 +1114,20 @@ private void StartTool(string cmd, string args, bool sysoutPipe, string columniz
}

SysoutPipe pipe = new SysoutPipe(process.StandardOutput);

LogWindow.LogWindow logWin = AddTempFileTab(pipe.FileName,
CurrentLogWindow.IsTempFile
? CurrentLogWindow.TempTitleName
: Util.GetNameFromPath(CurrentLogWindow.FileName) + "->E");
logWin.ForceColumnizer(columnizer);

process.Exited += pipe.ProcessExitedEventHandler;
//process.BeginOutputReadLine();
}
else
{
_logger.Info("Starting external tool: {0} {1}", cmd, args);

try
{
startInfo.UseShellExecute = false;
Expand Down Expand Up @@ -1187,7 +1190,7 @@ private void LoadProject(string projectFileName, bool restoreLayout)
CloseAllTabs();
break;
case ProjectLoadDlgResult.NewWindow:
LogExpertProxy.NewWindow(new string[] {projectFileName});
LogExpertProxy.NewWindow(new[] {projectFileName});
return;
}
}
Expand Down Expand Up @@ -1288,32 +1291,35 @@ private void ThrowExceptionThreadFx()

private string SaveLayout()
{
;
using (MemoryStream memStream = new MemoryStream(2000))
using (StreamReader r = new StreamReader(memStream))
{
dockPanel.SaveAsXml(memStream, Encoding.UTF8, true);
using (StreamReader r = new StreamReader(memStream))
{
dockPanel.SaveAsXml(memStream, Encoding.UTF8, true);

memStream.Seek(0, SeekOrigin.Begin);
string resultXml = r.ReadToEnd();
memStream.Seek(0, SeekOrigin.Begin);
string resultXml = r.ReadToEnd();

r.Close();
r.Close();

return resultXml;
return resultXml;
}
}
}

private void RestoreLayout(string layoutXml)
{
using (MemoryStream memStream = new MemoryStream(2000))
using (StreamWriter w = new StreamWriter(memStream))
{
w.Write(layoutXml);
w.Flush();
using (StreamWriter w = new StreamWriter(memStream))
{
w.Write(layoutXml);
w.Flush();

memStream.Seek(0, SeekOrigin.Begin);
memStream.Seek(0, SeekOrigin.Begin);

dockPanel.LoadFromXml(memStream, DeserializeDockContent, true);
dockPanel.LoadFromXml(memStream, DeserializeDockContent, true);
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/LogExpert/Controls/LogWindow/LogWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public LogWindow(LogTabWindow.LogTabWindow parent, string fileName, bool isTempF

InitializeComponent();

AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Dpi;

columnNamesLabel.Text = ""; // no filtering on columns by default

_parentLogTabWin = parent;
Expand Down Expand Up @@ -502,9 +505,7 @@ protected override string GetPersistString()

private delegate void SelectLineFx(int line, bool triggerSyncCall);

private delegate void FilterFx(
FilterParams filterParams, List<int> filterResultLines, List<int> lastFilterResultLines,
List<int> filterHitList);
private delegate void FilterFx(FilterParams filterParams, List<int> filterResultLines, List<int> lastFilterResultLines, List<int> filterHitList);

private delegate void UpdateProgressBarFx(int lineNum);

Expand Down
2 changes: 0 additions & 2 deletions src/LogExpert/Controls/LogWindow/LogWindow.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 46f017b

Please sign in to comment.