diff --git a/Source/LibationWinForms/grid/DescriptionDisplay.cs b/Source/LibationWinForms/grid/DescriptionDisplay.cs index 9f616421..7905e0a5 100644 --- a/Source/LibationWinForms/grid/DescriptionDisplay.cs +++ b/Source/LibationWinForms/grid/DescriptionDisplay.cs @@ -13,15 +13,13 @@ namespace LibationWinForms { public partial class DescriptionDisplay : Form { - public Point SpawnLocation { get; init; } public string DescriptionText { get => textBox1.Text; set => textBox1.Text = value; } + public Point SpawnLocation { get; set; } public DescriptionDisplay() { InitializeComponent(); textBox1.LostFocus += (_, _) => Close(); Shown += DescriptionDisplay_Shown; - - var textHeight = TextRenderer.MeasureText("\n", textBox1.Font).Height; } private void DescriptionDisplay_Shown(object sender, EventArgs e) @@ -34,11 +32,15 @@ namespace LibationWinForms { base.OnLoad(e); int lineCount = textBox1.GetLineFromCharIndex(int.MaxValue) + 2; - Height = Height - textBox1.Height + lineCount * TextRenderer.MeasureText(textBox1.Text, textBox1.Font).Height; + Height = Height - textBox1.Height + lineCount * TextRenderer.MeasureText("X", textBox1.Font).Height; int screenHeight = Screen.PrimaryScreen.WorkingArea.Height; - Location = new Point(SpawnLocation.X + 10, Math.Min(SpawnLocation.Y, screenHeight - Height)); + + var tboxLocation = PointToScreen(textBox1.Location); + var tboxOffset = new Size(tboxLocation.X - Location.X, tboxLocation.Y - Location.Y); + + Location = new Point(SpawnLocation.X - tboxOffset.Width, Math.Min(SpawnLocation.Y - tboxOffset.Height, screenHeight - Height)); } [DllImport("user32.dll")] diff --git a/Source/LibationWinForms/grid/GridEntry.cs b/Source/LibationWinForms/grid/GridEntry.cs index bd6d341d..8b93dd12 100644 --- a/Source/LibationWinForms/grid/GridEntry.cs +++ b/Source/LibationWinForms/grid/GridEntry.cs @@ -265,7 +265,7 @@ namespace LibationWinForms private static string GetDescriptionDisplay(Book book) { var doc = new HtmlAgilityPack.HtmlDocument(); - doc.LoadHtml(book?.Description ?? ""); + doc.LoadHtml(book?.Description?.Replace("

", "\r\n\r\n

") ?? ""); return doc.DocumentNode.InnerText; } diff --git a/Source/LibationWinForms/grid/ProductsGrid.cs b/Source/LibationWinForms/grid/ProductsGrid.cs index 91452ecc..2df9be7f 100644 --- a/Source/LibationWinForms/grid/ProductsGrid.cs +++ b/Source/LibationWinForms/grid/ProductsGrid.cs @@ -69,7 +69,7 @@ namespace LibationWinForms else if (propertyName == tagAndDetailsGVColumn.DataPropertyName) Details_Click(getGridEntry(e.RowIndex)); else if (propertyName == descriptionGVColumn.DataPropertyName) - DescriptionClick(getGridEntry(e.RowIndex), _dataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex,false)); + DescriptionClick(getGridEntry(e.RowIndex), _dataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false)); } private void DescriptionClick(GridEntry liveGridEntry, Rectangle cell) @@ -77,10 +77,12 @@ namespace LibationWinForms var displayWindow = new DescriptionDisplay { Text = $"{liveGridEntry.Title} description", - SpawnLocation = cell.Location + cell.Size, + SpawnLocation = PointToScreen(cell.Location + new Size(cell.Width, 0)), DescriptionText = liveGridEntry.LongDescription }; + displayWindow.RestoreSizeAndLocation(Configuration.Instance); displayWindow.Show(this); + displayWindow.FormClosing += (_, _) => displayWindow.SaveSizeAndLocation(Configuration.Instance); } private static async Task Liberate_Click(GridEntry liveGridEntry)