/// <summary> /// イベントルーティング(レンダリング)。 /// </summary> private void RaiseRender(ICanvasContext.IRenderingContext rc) { _lazySharedInfo.Value._IsInvalidating = false; foreach (var target in Tnc.GetAllChildrenAndSelf() .Where(target => target._clipRegion.AsReadOnly().Bounds.IsValid)) { var renderer = new Renderer(_mainOffscreen !, target.AbsoluteRect, target._clipRegion); target.OnPreviewRender(renderer); } foreach (var target in Tnc.GetAllChildrenAndSelfReverse() .Where(target => target._clipRegion.AsReadOnly().Bounds.IsValid)) { var renderer = new Renderer(_mainOffscreen !, target.AbsoluteRect, target._clipRegion); target.OnRender(renderer); } rc.TransferScreen(_mainOffscreen !); // 描画イベント中に「再描画要求」を出すのはNG Verifier.Verify <InvalidOperationException>(!_lazySharedInfo.Value._IsInvalidating); foreach (var target in Tnc.GetAllChildrenAndSelf()) { target._clipRegion.Clear(); } }
/// <summary> /// イベントルーティング(フォーカス取得)。 /// </summary> private void RaiseGotFocus() { _lazySharedInfo.Value.HasFocus = true; foreach (var target in Tnc.GetAllChildrenAndSelf()) { target.OnPreviewGotFocus(); } foreach (var target in Tnc.GetAllChildrenAndSelfReverse()) { target.OnGotFocus(); } }
/// <summary> /// イベントルーティング(フォーカス消失)。 /// </summary> private void RaiseLostFocus() { _lazySharedInfo.Value.HasFocus = false; RaiseMouseLeftButtonUp(); foreach (var target in Tnc.GetAllChildrenAndSelf()) { target.OnPreviewLostFocus(); } foreach (var target in Tnc.GetAllChildrenAndSelfReverse()) { target.OnLostFocus(); } }
// 以下、トンネリングイベント(プレビューイベント)、バブリングイベントのルーティングを処理する。 /// <summary> /// イベントルーティング(初期化)。 /// </summary> private void RaiseCreated(Size2D size) { Verifier.Verify <InvalidOperationException>(size.Width > 0); Verifier.Verify <InvalidOperationException>(size.Height > 0); _lazySharedInfo.Value.Size = size; foreach (var target in Tnc.GetAllChildrenAndSelf()) { target.OnPreviewInitialize(); } foreach (var target in Tnc.GetAllChildrenAndSelfReverse()) { target.OnInitialize(); } #warning このへん、あとで整理 foreach (var target in Tnc.GetAllChildrenAndSelf()) { target._relativeRect = target.ArrangeElement(); } foreach (var target in Tnc.GetAllChildrenAndSelf()) { target.OnPreviewCreated(); } foreach (var target in Tnc.GetAllChildrenAndSelfReverse()) { target.OnCreated(); } _mainOffscreen = CanvasContext.CreateOffscreen(ClientSize); #warning このへん、あとで整理 RaiseResize(size); _lazySharedInfo.Value.CanvasContext.Resize += size => RaiseResize(size); _lazySharedInfo.Value.CanvasContext.RenderFrame += rc => RaiseRender(rc); _lazySharedInfo.Value.CanvasContext.GotFocus += RaiseGotFocus; _lazySharedInfo.Value.CanvasContext.LostFocus += RaiseLostFocus; _lazySharedInfo.Value.CanvasContext.MouseDown += RaiseMouseDown; _lazySharedInfo.Value.CanvasContext.MouseUp += RaiseMouseUp; _lazySharedInfo.Value.CanvasContext.MouseMove += RaiseMouseMove; _lazySharedInfo.Value.CanvasContext.MouseWheel += RaiseMouseWheel; }
/// <summary> /// レイアウトを再調整する。 /// </summary> public void UpdateLayout() { foreach (var target in Tnc.GetAllChildrenAndSelf()) { target._relativeRect = target.ArrangeElement(); target.AbsoluteRect = target.GetAbsoluteRect(); } foreach (var target in Tnc.GetAllChildrenAndSelf()) { target.OnPreviewResize(); } foreach (var target in Tnc.GetAllChildrenAndSelfReverse()) { target.OnResize(); } RequestRender(); }
/// <summary> /// 指定座標のヒットテスト。 /// </summary> private IEnumerable <UIElement> GetHitTestedElementsTunnel(Point2D absLocation) { return(Tnc.GetAllChildrenAndSelf().Where(elem => elem.HitTest(elem.ToLocal(absLocation)))); }