Toasts – Diff between revs 57 and 58
?pathlinks?
Rev 57 | Rev 58 | |||
---|---|---|---|---|
Line 143... | Line 143... | |||
143 | private readonly int _screenWidth; |
143 | private readonly int _screenWidth; |
|
Line 144... | Line 144... | |||
144 | |
144 | |
|
Line 145... | Line 145... | |||
145 | private readonly int _screenHeight; |
145 | private readonly int _screenHeight; |
|
146 | |
146 | |
|
- | 147 | private byte[] _chime; |
||
- | 148 | |
||
- | 149 | private string _title; |
||
- | 150 | |
||
147 | private byte[] _chime; |
151 | private string _body; |
|
Line 148... | Line 152... | |||
148 | |
152 | |
|
149 | protected override bool ShowWithoutActivation => true; |
153 | protected override bool ShowWithoutActivation => true; |
|
150 | |
154 | |
|
Line 191... | Line 195... | |||
191 | /// </summary> |
195 | /// </summary> |
|
192 | /// <param name="title">the toast title</param> |
196 | /// <param name="title">the toast title</param> |
|
193 | /// <param name="body">the toast body</param> |
197 | /// <param name="body">the toast body</param> |
|
194 | public ToastForm(string title, string body) : this() |
198 | public ToastForm(string title, string body) : this() |
|
195 | { |
199 | { |
|
196 | labelTitle.Text = title; |
200 | _title = title; |
|
197 | htmlPanel1.Text = body; |
201 | _body = body; |
|
Line 198... | Line 202... | |||
198 | |
202 | |
|
199 | var httpClientHandler = new HttpClientHandler |
203 | var httpClientHandler = new HttpClientHandler |
|
200 | { |
204 | { |
|
201 | // mono does not implement this |
205 | // mono does not implement this |
|
Line 339... | Line 343... | |||
339 | |
343 | |
|
Line 340... | Line 344... | |||
340 | } |
344 | } |
|
341 | |
345 | |
|
342 | // compute notification height from body |
- | ||
343 | var maxWidth = tableLayoutPanel4.Width; |
346 | // compute notification height from body |
|
344 | |
347 | var maxWidth = tableLayoutPanel4.Width; |
|
345 | switch (ContentType) |
348 | switch (ContentType) |
|
346 | { |
349 | { |
|
347 | case "text/markdown": |
- | ||
348 | var htmlDocument = new HtmlAgilityPack.HtmlDocument(); |
350 | case "text/markdown": |
|
349 | var panelText = htmlPanel1.Text; |
351 | var htmlDocument = new HtmlAgilityPack.HtmlDocument(); |
|
350 | if (!string.IsNullOrEmpty(panelText)) |
352 | if (!string.IsNullOrEmpty(_body)) |
|
351 | { |
353 | { |
|
352 | htmlDocument.LoadHtml(panelText); |
354 | htmlDocument.LoadHtml(_body); |
|
353 | if (htmlDocument.DocumentNode != null && htmlDocument.DocumentNode.Descendants().Any()) |
355 | if (htmlDocument.DocumentNode != null && htmlDocument.DocumentNode.Descendants().Any()) |
|
354 | { |
356 | { |
|
355 | var imgNodes = htmlDocument.DocumentNode.SelectNodes("//img"); |
357 | var imgNodes = htmlDocument.DocumentNode.SelectNodes("//img"); |
|
Line 360... | Line 362... | |||
360 | node.SetAttributeValue("style", $"max-width: {maxWidth}px"); |
362 | node.SetAttributeValue("style", $"max-width: {maxWidth}px"); |
|
361 | } |
363 | } |
|
362 | } |
364 | } |
|
363 | } |
365 | } |
|
Line 364... | Line 366... | |||
364 | |
366 | |
|
365 | htmlPanel1.Text = htmlDocument.DocumentNode.WriteTo(); |
367 | _body = htmlDocument.DocumentNode.WriteTo(); |
|
366 | } |
368 | } |
|
367 | break; |
369 | break; |
|
368 | default: |
370 | default: |
|
369 | break; |
371 | break; |
|
Line 370... | Line 372... | |||
370 | } |
372 | } |
|
371 | |
373 | |
|
372 | using (var image = HtmlRender.RenderToImage(htmlPanel1.Text, maxWidth, 0, Color.Empty)) |
374 | using (var image = HtmlRender.RenderToImage(_body, maxWidth, 0, Color.Empty)) |
|
373 | { |
375 | { |
|
374 | var height = image.Height + labelTitle.Height; |
376 | var height = image.Height + labelTitle.Height; |
|
375 | if (height > Height) |
377 | if (height > Height) |
|
376 | { |
378 | { |
|
377 | Height = height; |
379 | Height = height; |
|
Line -... | Line 380... | |||
- | 380 | } |
||
- | 381 | } |
||
- | 382 | |
||
- | 383 | // apply the title and the text |
||
378 | } |
384 | labelTitle.Text = _title; |
|
379 | } |
385 | htmlPanel1.Text = _body; |
|
380 | |
386 | |
|
381 | if (EnablePin) |
387 | if (EnablePin) |
|
382 | { |
388 | { |