Beispiel #1
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            Telemetry.TrackOperation("FileOpened");
            IWpfTextView view = AdaptersFactory.GetWpfTextView(textViewAdapter);

            _buffer = view.TextBuffer;

            _buffer.Properties.GetOrCreateSingletonProperty(() => view);

            ITextBufferUndoManager undoManager = UndoProvider.GetTextBufferUndoManager(view.TextBuffer);

            AddCommandFilter(textViewAdapter, new FormatterCommand(view, undoManager));
            AddCommandFilter(textViewAdapter, new CompletionController(view, CompletionBroker, QuickInfoBroker));
            AddCommandFilter(textViewAdapter, new F1Help());
            AddCommandFilter(textViewAdapter, new NavigateToParent(_buffer));
            AddCommandFilter(textViewAdapter, new SignatureHelpCommand(view, SignatureHelpBroker, QuickInfoBroker));
            AddCommandFilter(textViewAdapter, new HideDefaultCommands());
            AddCommandFilter(textViewAdapter, new EnableSnippetsCommand(textViewAdapter, view, NavigatorService));

            if (textViewAdapter is IVsTextViewEx viewEx)
            {
                ErrorHandler.ThrowOnFailure(viewEx.PersistOutliningState());
            }

            if (DocumentService.TryGetTextDocument(_buffer, out ITextDocument document))
            {
                document.FileActionOccurred += DocumentSavedAsync;
            }

            view.Closed += OnViewClosed;
        }
Beispiel #2
0
        public Comment(Gates.IOGates.Comment cmt) : base(cmt, new TerminalID[0])
        {
            ph = new Path();

            ph.Stroke          = Brushes.Black;
            ph.StrokeThickness = 2;
            ph.Fill            = Brushes.White;
            ph.Margin          = new System.Windows.Thickness(15);
            myCanvas.Children.Add(ph);


            nm      = new TextBox();
            nm.Text = cmt.Value;
            nm.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            nm.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            nm.Margin          = new System.Windows.Thickness(20);
            nm.Width           = this.Width - 40;
            nm.Height          = this.Height - 40;
            nm.BorderThickness = new Thickness(0);

            myCanvas.Children.Add(nm);

            nm.TextChanged += (sender, e) =>
            {
                cmt.Value = nm.Text;
            };
            nm.LostFocus += (sender, e) =>
            {
                // because I don't want to create an undo event
                // for every single keypress!
                if (UndoProvider != null)
                {
                    UndoProvider.Add(new UndoRedo.ChangeUserText(this, prevcmt, nm.Text, txt => { cmt.Value = txt; }));
                }

                prevcmt = nm.Text;
            };
            nm.GotFocus += (sender, e) =>
            {
                if (MyGateCanvas != null)
                {
                    MyGateCanvas.ClearSelection();
                }
            };
            cmt.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "Value")
                {
                    ResizeDueToName();
                }
            };
            ResizeDueToName();
        }
Beispiel #3
0
        void txtName_LostFocus(object sender, System.Windows.RoutedEventArgs e)
        {
            string oldname = _uio.Name;

            _uio.SetName(txtName.Text);

            txtName.Visibility = System.Windows.Visibility.Hidden;
            if (UndoProvider != null)
            {
                UndoProvider.Add(new UndoRedo.ChangeUserText(this, oldname, txtName.Text, _uio.SetName));
            }
        }
Beispiel #4
0
        protected virtual void Delete()
        {
            try
            {
                var deletables = GetSelectedDeleteables().ToArray();

                if (deletables.Any())
                {
                    foreach (var deletable in GetSelectedDeleteables())
                    {
                        deletable.Delete();
                    }

                    SelectionService.SelectNone();

                    UndoProvider?.SaveUndoState();
                }
            }
            catch (Exception ex)
            {
                MessageBoxService.Show(ex);
            }
        }
        protected override void FinishDrag(Point position)
        {
            ApplyToMoveables(m => m.CompleteMove(position - StartPosition));

            UndoProvider?.SaveUndoState();
        }