public abstract void SetSelection(SelectionRange selRange);
public void MouseMove(UIMouseEventArgs e, CssBox startAt) { if (!_isBinded) { return; } if (startAt == null) { return; } //----------------------------------------- int x = e.X; int y = e.Y; if (e.IsDragging && _latestMouseDownChain != null) { //dragging *** , if changed if (this._mousedownX != x || this._mousedownY != y) { //handle mouse drag CssBoxHitChain hitChain = GetFreeHitChain(); hitChain.SetRootGlobalPosition(x, y); BoxHitUtils.HitTest(startAt, x, y, hitChain); SetEventOrigin(e, hitChain); //--------------------------------------------------------- //propagate mouse drag ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseMove(e); return(true); }); //--------------------------------------------------------- if (!e.CancelBubbling) { ClearPreviousSelection(); if (_latestMouseDownChain.Count > 0 && hitChain.Count > 0) { if (this._htmlContainer.LayoutVersion != this.lastDomLayoutVersion) { //the dom has been changed so... //need to evaluate hitchain at mousedown position again int lastRootGlobalX = _latestMouseDownChain.RootGlobalX; int lastRootGlobalY = _latestMouseDownChain.RootGlobalY; _latestMouseDownChain.Clear(); _latestMouseDownChain.SetRootGlobalPosition(lastRootGlobalX, lastRootGlobalY); BoxHitUtils.HitTest(_mouseDownStartAt, lastRootGlobalX, lastRootGlobalY, _latestMouseDownChain); } //create selection range var newSelectionRange = new SelectionRange( _latestMouseDownChain, hitChain, this.ifonts); if (newSelectionRange.IsValid) { this._htmlContainer.SetSelection(newSelectionRange); } else { this._htmlContainer.SetSelection(null); } } else { this._htmlContainer.SetSelection(null); } ForEachEventListenerBubbleUp(e, hitChain, () => { e.CurrentContextElement.ListenMouseMove(e); return(true); }); } //--------------------------------------------------------- ReleaseHitChain(hitChain); } } else { //mouse move //--------------------------------------------------------- CssBoxHitChain hitChain = GetFreeHitChain(); hitChain.SetRootGlobalPosition(x, y); BoxHitUtils.HitTest(startAt, x, y, hitChain); SetEventOrigin(e, hitChain); //--------------------------------------------------------- ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseMove(e); return(true); }); //--------------------------------------------------------- if (!e.CancelBubbling) { ForEachEventListenerBubbleUp(e, hitChain, () => { e.CurrentContextElement.ListenMouseMove(e); return(true); }); } ReleaseHitChain(hitChain); } }
public void MouseMove(UIMouseEventArgs e, CssBox startAt) { if (!_isBinded) { return; } if (startAt == null) { return; } //----------------------------------------- int x = e.X; int y = e.Y; if (e.IsDragging && _latestMouseDownChain != null) { //dragging *** , if changed if (_mousedownX != x || _mousedownY != y) { //handle mouse drag CssBoxHitChain hitChain = GetFreeHitChain(); #if DEBUG hitChain.debugEventPhase = CssBoxHitChain.dbugEventPhase.MouseMove; #endif hitChain.SetRootGlobalPosition(x, y); BoxHitUtils.HitTest(startAt, x, y, hitChain); SetEventOrigin(e, hitChain); //--------------------------------------------------------- //propagate mouse drag ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseMove(e); return(true); }); //--------------------------------------------------------- if (!e.CancelBubbling) { ClearPreviousSelection(); if (_latestMouseDownChain.Count > 0 && hitChain.Count > 0) { if (_htmlVisualRoot.LayoutVersion != _lastDomLayoutVersion) { //the dom has been changed so... //need to evaluate hitchain at mousedown position again int lastRootGlobalX = _latestMouseDownChain.RootGlobalX; int lastRootGlobalY = _latestMouseDownChain.RootGlobalY; _latestMouseDownChain.Clear(); _latestMouseDownChain.SetRootGlobalPosition(lastRootGlobalX, lastRootGlobalY); BoxHitUtils.HitTest(_mouseDownStartAt, lastRootGlobalX, lastRootGlobalY, _latestMouseDownChain); } //create selection range var newSelectionRange = new SelectionRange( _latestMouseDownChain, hitChain, _textService); if (newSelectionRange.IsValid) { _htmlVisualRoot.SetSelection(newSelectionRange); } else { _htmlVisualRoot.SetSelection(null); } } else { _htmlVisualRoot.SetSelection(null); } ForEachEventListenerBubbleUp(e, hitChain, () => { e.CurrentContextElement.ListenMouseMove(e); return(true); }); } //--------------------------------------------------------- ReleaseHitChain(hitChain); } } else { //mouse move //--------------------------------------------------------- CssBoxHitChain hitChain = GetFreeHitChain(); #if DEBUG hitChain.debugEventPhase = CssBoxHitChain.dbugEventPhase.MouseMove; #endif hitChain.SetRootGlobalPosition(x, y); BoxHitUtils.HitTest(startAt, x, y, hitChain); SetEventOrigin(e, hitChain); //--------------------------------------------------------- ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseMove(e); return(true); }); //--------------------------------------------------------- if (!e.CancelBubbling) { ForEachEventListenerBubbleUp(e, hitChain, () => { e.CurrentContextElement.ListenMouseMove(e); return(true); }); } var cssbox = e.ExactHitObject as HtmlBoxes.CssBox; if (cssbox != null) { switch (cssbox.CursorName) { case Css.CssCursorName.IBeam: if (e.MouseCursorStyle != MouseCursorStyle.IBeam) { e.MouseCursorStyle = MouseCursorStyle.IBeam; } break; case Css.CssCursorName.Hand: case Css.CssCursorName.Pointer: if (e.MouseCursorStyle != MouseCursorStyle.Pointer) { e.MouseCursorStyle = MouseCursorStyle.Pointer; } break; case Css.CssCursorName.Default: if (e.MouseCursorStyle != MouseCursorStyle.Default) { e.MouseCursorStyle = MouseCursorStyle.Default; } break; } } else { var cssspan = e.ExactHitObject as HtmlBoxes.CssTextRun; if (cssspan != null) { cssbox = cssspan.OwnerBox; switch (cssbox.CursorName) { default: e.MouseCursorStyle = MouseCursorStyle.IBeam; break; case Css.CssCursorName.Hand: case Css.CssCursorName.Pointer: if (e.MouseCursorStyle != MouseCursorStyle.Pointer) { e.MouseCursorStyle = MouseCursorStyle.Pointer; } break; } } } ReleaseHitChain(hitChain); } }
public override void SetSelection(SelectionRange selRange) { //find gross area of the selection range //then invalidate that area if (selRange != null) { this.currentSelectionArea = (hasSomeSelectedArea) ? Rectangle.Union(this.currentSelectionArea, selRange.SnapSelectionArea) : selRange.SnapSelectionArea; hasSomeSelectedArea = true; } else { hasSomeSelectedArea = false; } this._currentSelectionRange = selRange; this.RootCssBox.InvalidateGraphics(this.currentSelectionArea); }
public override void ClearPreviousSelection() { if (this._currentSelectionRange != null) { _currentSelectionRange.ClearSelection(); _currentSelectionRange = null; this.RootCssBox.InvalidateGraphics(this.currentSelectionArea); this.currentSelectionArea = Rectangle.Empty; } hasSomeSelectedArea = false; }
public void MouseMove(UIMouseEventArgs e, CssBox startAt) { if (!_isBinded) return; if (startAt == null) return; //----------------------------------------- int x = e.X; int y = e.Y; if (e.IsDragging && _latestMouseDownChain != null) { //dragging *** , if changed if (this._mousedownX != x || this._mousedownY != y) { //handle mouse drag CssBoxHitChain hitChain = GetFreeHitChain(); hitChain.SetRootGlobalPosition(x, y); BoxHitUtils.HitTest(startAt, x, y, hitChain); SetEventOrigin(e, hitChain); //--------------------------------------------------------- //propagate mouse drag ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseMove(e); return true; }); //--------------------------------------------------------- if (!e.CancelBubbling) { ClearPreviousSelection(); if (_latestMouseDownChain.Count > 0 && hitChain.Count > 0) { if (this._htmlContainer.LayoutVersion != this.lastDomLayoutVersion) { //the dom has been changed so... //need to evaluate hitchain at mousedown position again int lastRootGlobalX = _latestMouseDownChain.RootGlobalX; int lastRootGlobalY = _latestMouseDownChain.RootGlobalY; _latestMouseDownChain.Clear(); _latestMouseDownChain.SetRootGlobalPosition(lastRootGlobalX, lastRootGlobalY); BoxHitUtils.HitTest(_mouseDownStartAt, lastRootGlobalX, lastRootGlobalY, _latestMouseDownChain); } //create selection range var newSelectionRange = new SelectionRange( _latestMouseDownChain, hitChain, this.ifonts); if (newSelectionRange.IsValid) { this._htmlContainer.SetSelection(newSelectionRange); } else { this._htmlContainer.SetSelection(null); } } else { this._htmlContainer.SetSelection(null); } ForEachEventListenerBubbleUp(e, hitChain, () => { e.CurrentContextElement.ListenMouseMove(e); return true; }); } //--------------------------------------------------------- ReleaseHitChain(hitChain); } } else { //mouse move //--------------------------------------------------------- CssBoxHitChain hitChain = GetFreeHitChain(); hitChain.SetRootGlobalPosition(x, y); BoxHitUtils.HitTest(startAt, x, y, hitChain); SetEventOrigin(e, hitChain); //--------------------------------------------------------- ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseMove(e); return true; }); //--------------------------------------------------------- if (!e.CancelBubbling) { ForEachEventListenerBubbleUp(e, hitChain, () => { e.CurrentContextElement.ListenMouseMove(e); return true; }); } ReleaseHitChain(hitChain); } }