Skip to content

Commit

Permalink
Merge pull request #365 from AvaloniaUI/do-not-show-error-on-the-prev…
Browse files Browse the repository at this point in the history
…iewer-side-when-project-is-built

Do not show error on the previewer side when project is built
  • Loading branch information
Takoooooo authored Aug 8, 2023
2 parents 4fde0f2 + 110e8a7 commit b967c4c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
19 changes: 15 additions & 4 deletions AvaloniaVS.Shared/Views/AvaloniaDesigner.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Avalonia.Ide.CompletionEngine.DnlibMetadataProvider;
using AvaloniaVS.Models;
using AvaloniaVS.Services;
using AvaloniaVS.Shared.Views;
using EnvDTE;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Text;
Expand Down Expand Up @@ -100,6 +99,7 @@ internal partial class AvaloniaDesigner : UserControl, IDisposable
private bool _disposed;
private double _scaling = 1;
private AvaloniaDesignerView _unPausedView;
private bool _buidRequired;

/// <summary>
/// Initializes a new instance of the <see cref="AvaloniaDesigner"/> class.
Expand Down Expand Up @@ -340,7 +340,7 @@ private async Task LoadTargetsAsync()

bool IsValidTarget(ProjectInfo project)
{
return project.IsExecutable &&
return project.IsExecutable &&
project.References.Contains("Avalonia.DesignerSupport") &&
(project.Project == _project || project.ProjectReferences.Contains(_project));
}
Expand Down Expand Up @@ -483,6 +483,7 @@ private async Task StartProcessAsync()
}
catch (FileNotFoundException ex)
{
_buidRequired = true;
ShowError("Build Required", ex.Message);
Log.Logger.Debug(ex, "StartAsync could not find executable");
}
Expand All @@ -495,6 +496,7 @@ private async Task StartProcessAsync()
{
_startingProcess.Release();
}
_buidRequired = false;
}
else
{
Expand Down Expand Up @@ -625,9 +627,18 @@ private void ShowError(string heading, string message)
errorIndicator.Visibility = Visibility.Visible;
errorHeading.Text = heading;
errorMessage.Text = message;
if (_buidRequired == true)
{
previewer.buildButton.Visibility = Visibility.Visible;
}
else
{
previewer.buildButton.Visibility = Visibility.Hidden;
}
previewer.error.Visibility = Visibility.Visible;
previewer.errorHeading.Text = heading;
previewer.errorMessage.Text = message;
previewer.previewScroller.Visibility = Visibility.Hidden;
}

private void ShowPreview()
Expand Down Expand Up @@ -677,7 +688,7 @@ void VerticalGrid()
{
HorizontalGrid();
var content = SwapPanesButton.Content as UIElement;
content.RenderTransform = new RotateTransform(90);
content.RenderTransform = new RotateTransform(90);
}
else
{
Expand Down Expand Up @@ -705,7 +716,7 @@ private void SwapPreviewAndXamlPanes(object sender, RoutedEventArgs args)
{
case Orientation.Horizontal:
var editorRow = Grid.GetRow(editorHost);

if (editorRow == 0)
{
Grid.SetRow(editorHost, 2);
Expand Down
1 change: 1 addition & 0 deletions AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
Name="buildButton"
Margin="0,15,0,0"
Padding="7,5,7,5"
Visibility="Hidden"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="Build" />
Expand Down
4 changes: 2 additions & 2 deletions AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ private void Update(BitmapSource bitmap)
{
preview.Width = bitmap.Width / scaling;
preview.Height = bitmap.Height / scaling;
error.Visibility = Visibility.Collapsed;
previewScroller.Visibility = Visibility.Visible;
}
error.Visibility = Visibility.Collapsed;
previewScroller.Visibility = Visibility.Visible;

var fullScaling = scaling * Process.Scaling;
var hScale = preview.Width * 2 / fullScaling;
Expand Down

0 comments on commit b967c4c

Please sign in to comment.