Esempio n. 1
0
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public GistForVS(IWpfTextView view)
        {
            _view = view;

            _control = new InsertGistControl(); //new Image();
            RxApp.DeferredScheduler          = new DispatcherScheduler(_control.Dispatcher);
            view.Selection.SelectionChanged += (o, e) =>
            {
                var sel = (ITextSelection)o;
                _control.ViewModel.SelectionText = String.Join("",
                                                               sel.SelectedSpans.Select(x => x.GetText()));
            };
            //_image.Source = drawingImage;

            //Grab a reference to the adornment layer that this adornment should be added to
            _adornmentLayer = view.GetAdornmentLayer("GistForVS");

            _view.ViewportHeightChanged += delegate { this.onSizeChange(); };
            _view.ViewportWidthChanged  += delegate { this.onSizeChange(); };
        }
Esempio n. 2
0
        public void CreateTestWindow()
        {
            Application.ResourceAssembly = typeof(InsertGistControl).Assembly;

            WpfHelper.RunBlockAsSTA(() => {
                var grid = new Grid();
                var lhs  = new ColumnDefinition()
                {
                    Width = new GridLength(0.5, GridUnitType.Star)
                };
                var rhs = new ColumnDefinition()
                {
                    Width = new GridLength(0.5, GridUnitType.Star)
                };
                grid.ColumnDefinitions.Add(lhs);    grid.ColumnDefinitions.Add(rhs);

                var textBox = new TextBox();
                var control = new InsertGistControl()
                {
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                };

                Grid.SetColumn(textBox, 0);
                Grid.SetColumn(control, 1);
                textBox.TextChanged += (o, e) => control.ViewModel.SelectionText = textBox.Text;
                grid.Children.Add(textBox); grid.Children.Add(control);

                var wnd = new Window()
                {
                    Content = grid,
                };

                wnd.ShowDialog();
            });
        }