Example #1
0
        /// <summary>
        /// エレメント領域を最上位の親における座標系で取得する。
        /// </summary>
        private Rect2D GetAbsoluteRect()
        {
            var offset = Tnc.GetParents().Aggregate(
                Size2D.Empty, (total, parent) => total.Add(parent._relativeRect.Location.ToSize()));

            return(_relativeRect.Offset(offset));
        }
Example #2
0
        /// <summary>
        /// コンストラクタ。
        /// </summary>
        public TextView(ICanvasContext canvasContext, IReadOnlyTextDocument doc, string settingsJson)
            : base(canvasContext, settingsJson)
        {
            var options = new JsonSerializerOptions();

            options.AllowTrailingCommas = true;
            options.Converters.Add(new JsonStringEnumConverter(null, false));
            _settings = JsonSerializer.Deserialize <Settings>(settingsJson, options);

            DrawingMetricsMeasurer = new DrawingMetricsMeasure(this);

            Doc = doc;

            Tnc.AddNode(TextArea);
            Tnc.AddNode(VRuler);
            Tnc.AddNode(VScrollBar);
            Tnc.AddNode(HScrollBar);

            VScrollBar.ValueChanged += value =>
            {
                VRuler.RequestRenderByVScroll();
                TextArea.RequestRenderByVScroll();
            };
            HScrollBar.ValueChanged += value =>
            {
                TextArea.RequestRenderByHScroll();
                TextArea.RequestRenderCurrentLine();
            };
        }
Example #3
0
        /// <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();
            }
        }
Example #4
0
        /// <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();
            }
        }
Example #5
0
        public List <Tnc> Get()
        {
            List <Tnc> list = new List <Tnc>();

            DataProvider.ExecuteCmd("dbo.TnC_SelectAll"
                                    , inputParamMapper : null
                                    , singleRecordMapper : delegate(IDataReader reader, short set)
            {
                Tnc singleItem = Mapper(reader);
                list.Add(singleItem);
            });
            return(list);
        }
Example #6
0
        /// <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();
            }
        }
Example #7
0
        private Tnc Mapper(IDataReader reader)
        {
            Tnc singleItem    = new Tnc();
            int startingIndex = 0;

            singleItem.Id           = reader.GetSafeInt32(startingIndex++);
            singleItem.CreatedDate  = reader.GetSafeDateTime(startingIndex++);
            singleItem.ModifiedDate = reader.GetSafeDateTime(startingIndex++);
            singleItem.ModifiedBy   = reader.GetSafeString(startingIndex++);
            singleItem.ParentId     = reader.GetSafeInt32(startingIndex++);
            singleItem.Title        = reader.GetSafeString(startingIndex++);
            singleItem.Description  = reader.GetSafeString(startingIndex++);
            singleItem.DisplayOrder = reader.GetSafeInt32(startingIndex++);
            return(singleItem);
        }
Example #8
0
        public Tnc Get(int id)
        {
            Tnc singleItem = null;

            DataProvider.ExecuteCmd("dbo.TnC_SelectById"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Id", id);
            }
                                    , singleRecordMapper : delegate(IDataReader reader, short set)
            {
                singleItem = Mapper(reader);
            });
            return(singleItem);
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        protected override void OnPreviewInitialize()
        {
            _textView = Tnc.GetParent <TextView>();

            var oldDisplayDigits = -1;

            _textView.Doc.DocModified += _ =>
            {
                var displayDigits = CalcDisplayDigits();
                if (oldDisplayDigits != displayDigits)
                {
                    oldDisplayDigits = displayDigits;
                    _textView.UpdateLayout();
                }
            };
        }
Example #10
0
        protected override Rect2D ArrangeElement()
        {
            switch (Direction)
            {
            case ScrollDirection.Vertical:
                var height = Tnc.GetParent().ClientSize.Height - ScrollButton.Length * 2;
                return(new Rect2D(0, ScrollButton.Length, ScrollBar.Thickness, height));

            case ScrollDirection.Horizontal:
                var width = Tnc.GetParent().ClientSize.Width - ScrollButton.Length * 2;
                return(new Rect2D(ScrollButton.Length, 0, width, ScrollBar.Thickness));

            default:
                throw new InvalidOperationException();
            }
        }
Example #11
0
        // 以下、トンネリングイベント(プレビューイベント)、バブリングイベントのルーティングを処理する。

        /// <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;
        }
Example #12
0
        /// <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();
        }
Example #13
0
        /// <summary>
        ///
        /// </summary>
        protected override void OnPreviewInitialize()
        {
            _textView          = Tnc.GetParent <TextView>();
            _mouseClickCounter = new MouseClickCounter(4);

            _textView.VScrollBar.SetMarks(new List <IMarker> {
                _marker
            });

            Caret = new Caret(_textView);
            Caret.BlinkChanged += () => RequestRenderCurrentLine();

            _textView.FontChanged += () =>
            {
                var jsFontInfo = _textView._settings.fonts.jpFont;
                _inputMethod.SetFont(jsFontInfo.name, jsFontInfo.height * _textView.ZoomRate, _textView.GetLineHeight());
                Caret.Update();
            };

            Doc.DocModified += OnDocumentModified;
        }
Example #14
0
 protected override void OnPreviewInitialize()
 {
     ScrollBar = Tnc.GetParent <ScrollBar>();
 }
Example #15
0
 /// <summary>
 /// 指定座標のヒットテスト。
 /// </summary>
 private IEnumerable <UIElement> GetHitTestedElementsBubble(Point2D absLocation)
 {
     return(Tnc.GetAllChildrenAndSelfReverse().Where(elem => elem.HitTest(elem.ToLocal(absLocation))));
 }
Example #16
0
        public ScrollBody(ScrollDirection direction)
        {
            Direction = direction;

            Tnc.AddNode(new ScrollThumb(Direction));
        }