private void Register() { itemsPresenter = listBox.FindVisualChildOfType <ItemsPresenter>(); if (itemsPresenter == null) { return; } var adornerLayer = AdornerLayer.GetAdornerLayer(itemsPresenter); if (adornerLayer == null) { return; } selectionRect = new SelectionAdorner(itemsPresenter); adornerLayer.Add(selectionRect); selector = new ItemsControlSelector(listBox); autoScroller = new AutoScroller(listBox); autoScroller.OffsetChanged += OnOffsetChanged; // The ListBox intercepts the regular MouseLeftButtonDown event // to do its selection processing, so we need to handle the // PreviewMouseLeftButtonDown. The scroll content won't receive // the message if we click on a blank area so use the ListBox. listBox.PreviewMouseLeftButtonDown += OnPreviewMouseLeftButtonDown; listBox.MouseLeftButtonUp += OnMouseLeftButtonUp; listBox.MouseMove += OnMouseMove; }
/// <summary> /// update autoscrolling with current cursor location /// <P> </summary> /// <param name="dragCursorLocn"> the <code>Point</code> </param> protected internal virtual void UpdateAutoscroll(Point dragCursorLocn) { if (AutoScroller != null) { AutoScroller.UpdateLocation(dragCursorLocn); } }
private bool Register() { this.scrollContent = FindChild <ScrollContentPresenter>(this.listBox); if (this.scrollContent != null) { this.autoScroller = new AutoScroller(this.listBox); this.autoScroller.OffsetChanged += this.OnOffsetChanged; this.selectionRect = new SelectionAdorner(this.scrollContent); this.scrollContent.AdornerLayer.Add(this.selectionRect); this.selector = new ItemsControlSelector(this.listBox); // The ListBox intercepts the regular MouseLeftButtonDown event // to do its selection processing, so we need to handle the // PreviewMouseLeftButtonDown. The scroll content won't receive // the message if we click on a blank area so use the ListBox. this.listBox.PreviewMouseLeftButtonDown += this.OnPreviewMouseLeftButtonDown; this.listBox.MouseLeftButtonUp += this.OnMouseLeftButtonUp; this.listBox.MouseMove += this.OnMouseMove; } // Return success if we found the ScrollContentPresenter return(this.scrollContent != null); }
/// <summary> /// clear autoscrolling /// </summary> protected internal virtual void ClearAutoscroll() { if (AutoScroller != null) { AutoScroller.Stop(); AutoScroller = null; } }
public ChatroomWindow() { InitializeComponent(); flowDocumentLog.Document = new FlowDocument(); UpdateChatFont(); _autoScroller = new AutoScroller(flowDocumentLog); PropertyChangedEventManager.AddListener(UserDataManager.UserData.Settings, this, "PropertyChanged"); WindowTreeManager = new WindowTreeManager(this, HomeWindow.Home.WindowTreeManager); }
// creates an auto scroller object for the tests private AutoScroller CreateAutoScroller(out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller) { scrollView = A.Fake <IScrollView>(); content = A.Fake <IRectangle>(); elementToStartScroller = A.Fake <IActivateable>(); AutoScroller autoScroller = new AutoScroller(scrollView, content, elementToStartScroller); return(autoScroller); }
public void ScrollerActive_SetFalse_ActivatesElementToStartScroller() { AutoScroller autoScroller = CreateAutoScroller( out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller); autoScroller.ScrollerActive = false; Assert.True(elementToStartScroller.ActiveSelf); }
public void NotifyScrollValueChanged_ScrollerInactive_StaysDeactivated() { AutoScroller autoScroller = CreateAutoScroller( out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller); autoScroller.ScrollerActive = false; autoScroller.NotifyScrollValueChanged(); Assert.False(autoScroller.ScrollerActive); }
public void ScrollerActive_SetTrue_ScrollsToBottom() { AutoScroller autoScroller = CreateAutoScroller( out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller); scrollView.NormalizedPosition = new Vector2(1, 1); autoScroller.ScrollerActive = true; Assert.AreEqual(0, scrollView.NormalizedPosition.y); }
public void NotifyScrollValueChanged_UserScrolled_DeactivatesScroller() { AutoScroller autoScroller = CreateAutoScroller( out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller); autoScroller.ScrollerActive = true; // no changes to content size => manual scrolling autoScroller.NotifyScrollValueChanged(); Assert.False(autoScroller.ScrollerActive); }
// ======================================== // constructor // ======================================== public Canvas() : base() { //BackgroundImage = Image.FromFile(@"D:\share\img\WarrenLouw\43a19614516e6315cd8804e3604d84f8.jpg"); DoubleBuffered = true; AutoScroll = true; AllowDrop = true; Size = new Size(10, 10); BackColor = Color.White; ForeColor = Color.Black; _useGdiPlusText = false; //_canvasPadding = new Insets(2); _enableAutoAdjustRootFigureSize = true; _enableAutoScroller = true; _autoScroller = new AutoScroller(this); _autoScroller.AutoScrolling += HandleAutoScrollerAutoScrolling; _autoScroller.AutoScrolled += HandleAutoScrollerAutoScrolled; _dndEventProducer = new MouseDnDEventRaiser(this); _highlightRegistry = new HighlightRegistry(); _rootFigure = new RootFigure(); _rootFigure.Canvas = this; //_rootFigure.Size = ClientSize - _canvasPadding.Size; _rootFigure.Size = ClientSize; //_rootFigure.DescendantChanged += HandleDescendantChanged; _rootFigure.BoundsChanged += HandleRootFigureBoundsChanged; _rootFigure.Layout = new StackLayout(); /// 初期設定.サブクラスでoverrideされることを想定. Configure(); /// DirtManagerやEventDispatcherがConfigureされていなければデフォルト実装を使う. if (_dirtManager == null) { _DirtManager = new DirtManager(this); } if (_dispatcher == null) { _EventDispatcher = new EventDispatcher(this); } InitDndEventProducer(); }
public void NotifyScrollValueChanged_ScrollerInactiveContentSizeChanged_NoScrollToBottom() { AutoScroller autoScroller = CreateAutoScroller( out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller); autoScroller.ScrollerActive = false; content.Size = Vector2.one; scrollView.NormalizedPosition = Vector2.one; autoScroller.NotifyScrollValueChanged(); Assert.AreEqual(1, scrollView.NormalizedPosition.y); }
public void NotifyScrollValueChanged_ContentSizeChanged_KeepsScrollerActive() { AutoScroller autoScroller = CreateAutoScroller( out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller); autoScroller.ScrollerActive = true; content.Size = Vector2.one; // changes to content size => no manual scrolling autoScroller.NotifyScrollValueChanged(); Assert.True(autoScroller.ScrollerActive); }
public void NotifyScrollValueChanged_ContentSizeChanged_ScrollToBottom() { AutoScroller autoScroller = CreateAutoScroller( out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller); autoScroller.ScrollerActive = true; content.Size = Vector2.one; scrollView.NormalizedPosition = Vector2.one; // changes to content size => no manual scrolling autoScroller.NotifyScrollValueChanged(); Assert.AreEqual(0, scrollView.NormalizedPosition.y); }
private bool Register() { UpdateScrollContent(); if (scrollContent != null) { autoScroller = new AutoScroller(listBox); autoScroller.OffsetChanged += OnOffsetChanged; selector = new ItemsControlSelector(listBox); // The ListBox intercepts the regular MouseLeftButtonDown event // to do its selection processing, so we need to handle the // PreviewMouseLeftButtonDown. The scroll content won't receive // the message if we click on a blank area so use the ListBox. listBox.PreviewMouseLeftButtonDown += OnPreviewMouseLeftButtonDown; listBox.MouseLeftButtonUp += OnMouseLeftButtonUp; listBox.MouseMove += OnMouseMove; } // Return success if we found the ScrollContentPresenter return(scrollContent != null); }
public DragNDropController(AutoScroller autoScroller) { this.autoScroller = autoScroller; }
public FileTailerViewModel(ILogger logger, ISchedulerProvider schedulerProvider, FileInfo fileInfo) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (schedulerProvider == null) { throw new ArgumentNullException(nameof(schedulerProvider)); } if (fileInfo == null) { throw new ArgumentNullException(nameof(fileInfo)); } File = fileInfo.FullName; AutoTail = true; var filterRequest = this.WhenValueChanged(vm => vm.SearchText).Throttle(TimeSpan.FromMilliseconds(125)); var autoTail = this.WhenValueChanged(vm => vm.AutoTail) .CombineLatest(_userScrollRequested, (auto, user) => auto ? new ScrollRequest(user.Rows) : new ScrollRequest(user.Rows, user.FirstIndex + 1)) .DistinctUntilChanged(); var tailer = new FileTailer(fileInfo, filterRequest, autoTail); var lineCounter = tailer .TotalLinesCount .CombineLatest(tailer.MatchedLinesCount, (total, matched) => total == matched ? $"File has {total:#,###} lines" : $"Showing {matched:#,###} of {total:#,###} lines") .Subscribe(text => LineCountText = text); // load lines into observable collection var loader = tailer.Lines.Connect() .Buffer(TimeSpan.FromMilliseconds(125)).FlattenBufferResult() .Transform(line => new LineProxy(line)) .Sort(SortExpressionComparer <LineProxy> .Ascending(proxy => proxy.Number)) .ObserveOn(schedulerProvider.MainThread) .Bind(out _data) .Do(_ => AutoScroller.ScrollToEnd()) .Subscribe(a => logger.Info(a.Adds.ToString()), ex => logger.Error(ex, "Opps")); // monitor matching lines and start index // update local values so the virtual scroll panel can bind to them var matchedLinesMonitor = tailer.MatchedLinesCount .Subscribe(matched => MatchedLinesCount = matched); var firstIndexMonitor = tailer.Lines.Connect() .QueryWhenChanged(lines => { // use zero based index rather than line number return(lines.Count == 0 ? 0 : lines.Select(l => l.Number).Min() - 1); }).Subscribe(first => FirstRow = first - 1); _cleanup = new CompositeDisposable( tailer, lineCounter, loader, matchedLinesMonitor, firstIndexMonitor, Disposable.Create(() => _userScrollRequested.OnCompleted())); }