Skip to content

Commit 6fae38a

Browse files
committed
dedupe border code
1 parent fbab8ee commit 6fae38a

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using System.Text;
5+
using System.Windows;
6+
using System.Windows.Media;
7+
8+
namespace JitExplorer.Component
9+
{
10+
public static class ThinBorder
11+
{
12+
public static void SetThinBorder(object sender, EventArgs e)
13+
{
14+
var s = (Window)sender;
15+
Matrix m = PresentationSource.FromVisual(s).CompositionTarget.TransformToDevice;
16+
double dpiFactor = 1 / m.M11;
17+
s.BorderThickness = new Thickness(dpiFactor);
18+
}
19+
}
20+
}

JitExplorer/MainWindow.xaml.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using ICSharpCode.AvalonEdit.Highlighting;
66
using ICSharpCode.AvalonEdit.Highlighting.Xshd;
77
using JitExplorer.Completion;
8+
using JitExplorer.Component;
89
using JitExplorer.Controls;
910
using JitExplorer.Engine;
1011
using JitExplorer.Engine.Compile;
@@ -73,7 +74,7 @@ public static void Execute()
7374

7475
this.AssemblerView.MouseDoubleClick += AssemblerView_MouseDoubleClick;
7576

76-
this.Loaded += a_Loaded;
77+
this.Loaded += ThinBorder.SetThinBorder;
7778

7879
// in the constructor:
7980
this.CodeEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering;
@@ -99,13 +100,7 @@ public static void Execute()
99100
this.AsmTab.CloseButtonEnabled = true;
100101
}
101102

102-
void a_Loaded(object sender, EventArgs e)
103-
{
104-
var s = (Window)sender;
105-
Matrix m = PresentationSource.FromVisual(s).CompositionTarget.TransformToDevice;
106-
double dpiFactor = 1 / m.M11;
107-
this.BorderThickness = new Thickness(dpiFactor);
108-
}
103+
109104

110105
// Scroll to line
111106
private void AssemblerView_MouseDoubleClick(object sender, MouseButtonEventArgs e)

JitExplorer/Splash.xaml.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using MahApps.Metro.Controls;
1+
using JitExplorer.Component;
2+
using MahApps.Metro.Controls;
23
using System;
34
using System.Collections.Generic;
45
using System.Text;
@@ -22,17 +23,7 @@ public partial class Splash : MetroWindow
2223
public Splash()
2324
{
2425
InitializeComponent();
25-
this.Loaded += a_Loaded;
26-
}
27-
28-
void a_Loaded(object sender, EventArgs e)
29-
{
30-
var s = (Window)sender;
31-
32-
Matrix m = PresentationSource.FromVisual(s).CompositionTarget.TransformToDevice;
33-
double dpiFactor = 1 / m.M11;
34-
35-
this.BorderThickness = new Thickness(dpiFactor);
26+
this.Loaded += ThinBorder.SetThinBorder;
3627
}
3728
}
3829
}

0 commit comments

Comments
 (0)