diff --git a/AvaloniaVS.Shared/Views/AvaloniaDesigner.xaml.cs b/AvaloniaVS.Shared/Views/AvaloniaDesigner.xaml.cs index 2457a602..783a08ca 100644 --- a/AvaloniaVS.Shared/Views/AvaloniaDesigner.xaml.cs +++ b/AvaloniaVS.Shared/Views/AvaloniaDesigner.xaml.cs @@ -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; @@ -100,6 +99,7 @@ internal partial class AvaloniaDesigner : UserControl, IDisposable private bool _disposed; private double _scaling = 1; private AvaloniaDesignerView _unPausedView; + private bool _buidRequired; /// /// Initializes a new instance of the class. @@ -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)); } @@ -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"); } @@ -495,6 +496,7 @@ private async Task StartProcessAsync() { _startingProcess.Release(); } + _buidRequired = false; } else { @@ -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() @@ -677,7 +688,7 @@ void VerticalGrid() { HorizontalGrid(); var content = SwapPanesButton.Content as UIElement; - content.RenderTransform = new RotateTransform(90); + content.RenderTransform = new RotateTransform(90); } else { @@ -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); diff --git a/AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml b/AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml index b4169aed..c044e764 100644 --- a/AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml +++ b/AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml @@ -69,6 +69,7 @@ Name="buildButton" Margin="0,15,0,0" Padding="7,5,7,5" + Visibility="Hidden" HorizontalAlignment="Center" VerticalAlignment="Center" Content="Build" /> diff --git a/AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml.cs b/AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml.cs index eb38eb50..35ca0f39 100644 --- a/AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml.cs +++ b/AvaloniaVS.Shared/Views/AvaloniaPreviewer.xaml.cs @@ -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;