public PerspexEditorMargin(IWpfTextView textView)
        {
            _textView = textView;

            _targetExe = textView.GetContainingProject()?.GetAssemblyPath();
            if (_targetExe == null)
            {
                Height = 0;
                return;
            }
            _designer = new PerspexDesigner() {TargetExe = _targetExe };
            InitializeComponent();
            DesignerContainer.Content = _designer;
            Height = 200;
            _designer.Xaml = textView.TextBuffer.CurrentSnapshot.GetText();
            PerspexBuildEvents.Instance.BuildEnd += Restart;
            PerspexBuildEvents.Instance.ModeChanged += OnModeChanged;
            textView.TextBuffer.PostChanged += delegate
            {
                _designer.Xaml = textView.TextBuffer.CurrentSnapshot.GetText();
            };
            ReloadMetadata();
        }
예제 #2
0
        private void InitializeDesigner()
        {
            _targetExe = GetContainerProject(_fileName).GetAssemblyPath();
            if (_targetExe == null)
            {
                var block = new TextBlock
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Text = $"{Path.GetFileName(_fileName)} cannot be edited in the Design view."
                };
                _designerHost.DesignView.Content = block;
                return;
            }

            _designer = new PerspexDesigner { TargetExe = _targetExe };
            _designerHost.DesignView.Content = _designer;

            _designer.Xaml = _textBuffer.CurrentSnapshot.GetText();
            PerspexBuildEvents.Instance.BuildEnd += Restart;
            PerspexBuildEvents.Instance.ModeChanged += OnModeChanged;
            _textBuffer.PostChanged += OnTextBufferPostChanged;
            ReloadMetadata();
        }