Skip to content

Commit

Permalink
Merge pull request #83 from boelew/develop/FixDispatcherProblems
Browse files Browse the repository at this point in the history
Fix dispatcher problems
  • Loading branch information
whistyun authored Jan 22, 2024
2 parents d58819c + 4110f36 commit 0b190df
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MdXaml/ImageLoaderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static async Task<Result<Stream>> OpenStreamAsync(Uri resourceUrl)
{
case "http":
case "https":
var httpResult = await s_client.GetAsync(resourceUrl);
var httpResult = await s_client.GetAsync(resourceUrl).ConfigureAwait(false);
if (httpResult.StatusCode == HttpStatusCode.OK)
{
var webstream = await httpResult.Content.ReadAsStreamAsync();
Expand Down
33 changes: 29 additions & 4 deletions MdXaml/MarkdownScrollViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public class MarkdownScrollViewer : FlowDocumentScrollViewer, IUriContext

public static readonly DependencyProperty MarkdownStyleNameProperty =
DependencyProperty.Register(
nameof(MarkdownStyleName),
typeof(string),
typeof(MarkdownScrollViewer),
new PropertyMetadata(nameof(MdStyle.Standard), UpdateStyleName));
nameof(MarkdownStyleName),
typeof(string),
typeof(MarkdownScrollViewer),
new PropertyMetadata(nameof(MdStyle.Standard), UpdateStyleName));

public static readonly DependencyProperty AssetPathRootProperty =
DependencyProperty.Register(
Expand All @@ -71,6 +71,13 @@ public class MarkdownScrollViewer : FlowDocumentScrollViewer, IUriContext
typeof(MarkdownScrollViewer),
new PropertyMetadata(null, UpdateAssetPathRoot));

public static readonly DependencyProperty DisabledLazyLoadProperty =
DependencyProperty.Register(
nameof(DisabledLazyLoad),
typeof(bool),
typeof(MarkdownScrollViewer),
new PropertyMetadata(false, UpdateDisabledLazyLoad));


private static void UpdateSource(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Expand Down Expand Up @@ -163,6 +170,18 @@ private static void UpdateAssetPathRoot(DependencyObject d, DependencyPropertyCh
}
}

private static void UpdateDisabledLazyLoad(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if(d is MarkdownScrollViewer owner)
{
var disabledLazyLoad = (bool)e.NewValue;
if (disabledLazyLoad != owner.Engine.DisabledLazyLoad)
{
owner.Engine.DisabledLazyLoad = (bool)e.NewValue;
}
}
}

private string _fragment;
private Uri _source;

Expand Down Expand Up @@ -305,6 +324,12 @@ public string MarkdownStyleName
set { SetValue(MarkdownStyleNameProperty, value); }
}

public bool DisabledLazyLoad
{
get { return (bool)GetValue(DisabledLazyLoadProperty); }
set { SetValue(DisabledLazyLoadProperty, value); }
}

public Uri? Source
{
get { return (Uri)GetValue(SourceProperty); }
Expand Down

0 comments on commit 0b190df

Please sign in to comment.