Skip to content

Commit

Permalink
fix(dui): preview issues #1961 #1960
Browse files Browse the repository at this point in the history
  • Loading branch information
teocomi committed Dec 1, 2022
1 parent f48458c commit 04a75fc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs
Expand Up @@ -472,6 +472,13 @@ public Avalonia.Media.Imaging.Bitmap PreviewImage360
set => this.RaiseAndSetIfChanged(ref _previewImage360, value);
}

private bool _previewImage360Loaded;
public bool PreviewImage360Loaded
{
get => _previewImage360Loaded;
set => this.RaiseAndSetIfChanged(ref _previewImage360Loaded, value);
}

public bool CanOpenCommentsIn3DView { get; set; } = false;
private bool _isAddingBranches = false;

Expand Down Expand Up @@ -1017,6 +1024,10 @@ public async Task DownloadImage360(string url)

_previewImage360 = new Bitmap(stream);
this.RaisePropertyChanged(nameof(PreviewImage360));
//the default 360 image width is 34300
//this is a quick hack to see if the returned image is not an error image like "you do not have access" etc
if (_previewImage360.Size.Width > 30000)
PreviewImage360Loaded = true;

}
catch (Exception ex)
Expand Down
Expand Up @@ -211,6 +211,7 @@
<Image
x:Name="Image360"
Height="200"
Opacity="0"
Source="{Binding PreviewImage360}" />
</Viewbox>
</Grid>
Expand Down
@@ -1,6 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using DesktopUI2.ViewModels;
using System;

namespace DesktopUI2.Views.Controls.StreamEditControls
Expand All @@ -18,14 +19,20 @@ public Receive()
Image360 = this.FindControl<Image>("Image360");
ImageBasic = this.FindControl<Image>("ImageBasic");



PreviewBox360.PointerMoved += PreviewBox360_PointerMoved;

}



private void PreviewBox360_PointerMoved(object sender, Avalonia.Input.PointerEventArgs e)
{
var svm = PreviewBox360.DataContext as StreamViewModel;
if (!svm.PreviewImage360Loaded)
return;
Image360.Opacity = 1;
ImageBasic.IsVisible = false;

var mouseX = e.GetPosition(PreviewBox360).X + PreviewBox360.Margin.Left;
SetMargin(mouseX);
}
Expand Down

0 comments on commit 04a75fc

Please sign in to comment.