private void InitializeDesigner()
        {
            var basePath =
                Path.GetDirectoryName(typeof(AvaloniaDesignerPane).Assembly.GetModules()[0].FullyQualifiedName);

            basePath  = Path.Combine(basePath, "lib");
            _designer = new AvaloniaDesigner(new DesignerConfiguration
            {
                NetFxAppHostPath   = Path.Combine(basePath, "Avalonia.Designer.HostApp.exe"),
                NetCoreAppHostPath = Path.Combine(basePath, "Avalonia.Designer.HostApp.dll")
            })
            {
                SourceAssembly = Utils.GetContainerProject(_fileName)?.GetAssemblyPath()
            };
            _designer.SpawnedProcess            += DesignerKiller.Register;
            _designerHost.SourceAssemblyChanged += sa =>
            {
                if (_designer != null)
                {
                    _designer.SourceAssembly = sa;
                }
            };
            UpdateTargetExe(_designerHost.TargetExe);
            _designerHost.RestartDesigner = new RelayCommand(() =>
            {
                Restart();
            });
            SetDesignerXaml(_textBuffer.CurrentSnapshot.GetText());
            AvaloniaBuildEvents.Instance.BuildEnd    += Restart;
            AvaloniaBuildEvents.Instance.ModeChanged += OnModeChanged;
            _textBuffer.PostChanged += OnTextBufferPostChanged;

            _designerHostView.IsDesingerVisibleChanged = () => SetDesignerXaml();
        }
Example #2
0
 private void InitializeDesigner()
 {
     _designer = new AvaloniaDesigner()
     {
         SourceAssembly = Utils.GetContainerProject(_fileName)?.GetAssemblyPath()
     };
     UpdateTargetExe(_designerHost.TargetExe);
     _designer.Xaml = _textBuffer.CurrentSnapshot.GetText();
     AvaloniaBuildEvents.Instance.BuildEnd    += Restart;
     AvaloniaBuildEvents.Instance.ModeChanged += OnModeChanged;
     _textBuffer.PostChanged += OnTextBufferPostChanged;
     ReloadMetadata();
 }