Skip to content

Commit

Permalink
Basic HDPI support
Browse files Browse the repository at this point in the history
  • Loading branch information
sepich committed Jan 10, 2016
1 parent 7e6f1db commit af570aa
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 165 deletions.
8 changes: 6 additions & 2 deletions SynNotes/DrawRtf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ private class RichTextBoxDrawer : RichTextBox {

//Convert the unit used by the .NET framework (1/100 inch)
//and the unit used by Win32 API calls (twips 1/1440 inch)
private const double anInch = 14.4;
private double anInch;
public RichTextBoxDrawer() {
using(var g = this.CreateGraphics() ){
anInch = 1440 / g.DpiX;
}
}

protected override CreateParams CreateParams {
get {
Expand All @@ -43,7 +48,6 @@ public void Draw(Graphics graphics, Rectangle layoutArea) {
rectLayoutArea.Bottom = (int)(layoutArea.Bottom * anInch);
rectLayoutArea.Left = (int)(layoutArea.Left * anInch);
rectLayoutArea.Right = (int)(layoutArea.Right * anInch);

IntPtr hdc = graphics.GetHdc();

SafeNativeMethods.FORMATRANGE fmtRange;
Expand Down
67 changes: 35 additions & 32 deletions SynNotes/Form.Designer.cs

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

14 changes: 9 additions & 5 deletions SynNotes/Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void Form1_Move(object sender, EventArgs e) {
}
// inits
initTree();
initScintilla();
initScintilla();
}
}

Expand Down Expand Up @@ -329,8 +329,8 @@ private void Form1_KeyDown(object sender, KeyEventArgs e) {
// Ctrl-F
else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.F) {
panelFind.Left = (scEdit.LinesOnScreen >= scEdit.Lines.Count) ?
scEdit.Width - 200 :
scEdit.Width - 199 - SystemInformation.VerticalScrollBarWidth;
scEdit.Width - panelFind.Width :
scEdit.Width - panelFind.Width - SystemInformation.VerticalScrollBarWidth + 1;
panelFind.Visible = true;
panelFind.BringToFront();
tbFind.Focus();
Expand Down Expand Up @@ -454,7 +454,9 @@ private void treeAsList(string query) {
//view
if (tree.RowHeight < 0) {
tree.Roots = null;
tree.RowHeight = 64;
using (Graphics g = this.CreateGraphics()) {
tree.RowHeight = (int)g.MeasureString("O", tree.Font).Height * 4; //title and 3 lines of preview
}
tree.CanExpandGetter = null;
tree.ChildrenGetter = null;
tree.EmptyListMsg = "";
Expand Down Expand Up @@ -1886,7 +1888,7 @@ private void drawFound(Graphics g, Rectangle r, NoteItem note) {

var stringSize = g.MeasureString(note.DateShort, this.Font);
var offset = (int)stringSize.Height + 1;
var r2 = new Rectangle(r.X + 3, offset + 5, r.Width, r.Height - offset); //rect search result
var r2 = new Rectangle(r.X + 3, offset + 2, r.Width, r.Height - offset); //rect search result
using (StringFormat fmt = new StringFormat(StringFormatFlags.NoWrap)) {
fmt.LineAlignment = StringAlignment.Near;
fmt.Trimming = StringTrimming.EllipsisCharacter;
Expand Down Expand Up @@ -1977,6 +1979,8 @@ private void drawTag(Graphics g, Rectangle r, TagItem tag) {
}
using (SolidBrush b = new SolidBrush(Color.White)) {
fmt.Alignment = StringAlignment.Center;
fmt.LineAlignment = StringAlignment.Center;
badgerect.Y = badgerect.Y + 1;
g.DrawString(tag.Count.ToString(), f, b, badgerect, fmt); //count
}
}
Expand Down
2 changes: 1 addition & 1 deletion SynNotes/Form.resx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACM
CwAAAk1TRnQBSQFMAgEBCgEAAbABAQGwAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CwAAAk1TRnQBSQFMAgEBCgEAAYgBAgGIAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down
Loading

0 comments on commit af570aa

Please sign in to comment.