Esempio n. 1
0
        private void BtnLayer_MouseEnter(object sender, ScMouseEventArgs e)
        {
            RectangleF oldrc = DrawBox;

            Anchor = new PointF(Width / 2, Height / 2);

            ScaleX = maxZoom;
            ScaleY = maxZoom;

            RectangleF r = new RectangleF(btnLayer.Width - 30, btnLayer.Height - 30, 30, 30);

            gouPath = CreateGouPath(r);

            InvalidateGlobalRect(GDIDataD2DUtils.UnionRectF(oldrc, DrawBox));
        }
Esempio n. 2
0
        private void GridViewContainer_ContentSizeChangedEvent()
        {
            if (Width == 0)
            {
                return;
            }

            SuspendLayout();

            PointF screenLoctain = gridViewCore.GetScreenLoaction();
            float  viewportWidth = gridViewCore.GetViewportWidth();
            float  screenEndPos  = screenLoctain.X + gridViewCore.GetContentSize().Width;

            if (gridViewCore.GetContentSize().Width < viewportWidth && screenLoctain.X < 0)
            {
                gridViewCore.MoveHeaderLoaction(0);
                gridViewCore.SetScreenLoactionX(0);
            }
            else if (screenEndPos <= viewportWidth)
            {
                float x = screenLoctain.X + viewportWidth - screenEndPos;

                if (x <= 0)
                {
                    gridViewCore.MoveHeaderLoaction(x);
                    gridViewCore.SetScreenLoactionX(x);
                }
            }


            if (shadow != null)
            {
                RectangleF oldShadowDrawBox = shadow.DrawBox;
                SetContentShowPos(gridViewCore.GetContentShowPos());
                ResumeLayout(true);
                InvalidateGlobalRect(GDIDataD2DUtils.UnionRectF(oldShadowDrawBox, DrawBox));
                Update();
            }
            else
            {
                SetContentShowPos(gridViewCore.GetContentShowPos());
                ResumeLayout(true);
                Refresh();
                Update();
            }
        }
Esempio n. 3
0
        public void FixSize()
        {
            RectangleF totalRect = Rectangle.Empty;

            foreach (ScLayer control in controls)
            {
                if (totalRect == RectangleF.Empty)
                {
                    totalRect = new RectangleF(
                        control.Location.X, control.Location.Y,
                        control.Width, control.Height);
                    continue;
                }

                totalRect = GDIDataD2DUtils.UnionRectF(totalRect, control.DirectionRect);
            }

            Width  = totalRect.Right;
            Height = totalRect.Bottom;
        }
Esempio n. 4
0
        private void BtnLayer_MouseLeave(object sender)
        {
            RectangleF oldrc = DrawBox;

            Anchor = new PointF(Width / 2, Height / 2);

            ScaleX = minZoom;
            ScaleY = minZoom;
            zoom   = minZoom;

            RectangleF r = new RectangleF(btnLayer.Width - 30, btnLayer.Height - 30, 30, 30);

            gouPath = CreateGouPath(r);

            if (effectBitmap != null)
            {
                effectBitmap.Dispose();
                effectBitmap = null;
            }

            //     StartZoomAnim();
            InvalidateGlobalRect(GDIDataD2DUtils.UnionRectF(oldrc, DrawBox));
        }
Esempio n. 5
0
        void AddNewText(string newText)
        {
            GDIHitTestMetrics start, end;
            bool startTrailingHit, endTrailingHit;
            int  startTextPosition, endTextPosition;

            if (hitTestMetrics[1].TextPosition == hitTestMetrics[0].TextPosition &&
                (isTrailingHit[1] == false && isTrailingHit[0] == true) ||
                hitTestMetrics[1].TextPosition < hitTestMetrics[0].TextPosition)
            {
                start             = hitTestMetrics[1];
                startTextPosition = start.TextPosition;
                startTrailingHit  = isTrailingHit[1];

                end             = hitTestMetrics[0];
                endTextPosition = end.TextPosition;
                endTrailingHit  = isTrailingHit[0];
            }
            else
            {
                start             = hitTestMetrics[0];
                startTextPosition = start.TextPosition;
                startTrailingHit  = isTrailingHit[0];

                end             = hitTestMetrics[1];
                endTextPosition = end.TextPosition;
                endTrailingHit  = isTrailingHit[1];
            }


            if (startTrailingHit == true)
            {
                startTextPosition += 1;
            }

            if (endTrailingHit == false)
            {
                endTextPosition -= 1;
            }


            if (string.IsNullOrWhiteSpace(txt))
            {
                txt = newText;
                startTextPosition = -1;
            }
            else
            {
                string a = txt.Substring(0, startTextPosition);
                string b = txt.Substring(endTextPosition + 1, txt.Length - endTextPosition - 1);
                txt = a + newText + b;
            }


            RectangleF oldrc = DrawBox;


            CreateHitInfo(txt);

            int n = 0;

            if (newText != null)
            {
                n = newText.Count();
            }

            if (startTextPosition == -1 ||
                startTextPosition + n >= txtHitRect.Count())
            {
                isTrailingHit[1] = isTrailingHit[0] = true;
            }
            else
            {
                isTrailingHit[1] = isTrailingHit[0] = false;
            }

            metricsList       = HitTestTextRange(startTextPosition + n, 1);
            hitTestMetrics[1] = hitTestMetrics[0] = metricsList[0];
            cursorIdx         = 0;
            metricsList       = null;

            int x = (int)Math.Round(hitTestMetrics[cursorIdx].Left);
            int y = (int)Math.Round(hitTestMetrics[cursorIdx].Top);

            SetImeWindowsPos(x, y);


            if (CursorPositionEvent != null)
            {
                RectangleF rect =
                    new RectangleF(
                        hitTestMetrics[cursorIdx].Left,
                        hitTestMetrics[cursorIdx].Top,
                        hitTestMetrics[cursorIdx].Width,
                        hitTestMetrics[cursorIdx].Height);

                CursorPositionEvent(rect);
            }

            InvalidateGlobalRect(GDIDataD2DUtils.UnionRectF(oldrc, DrawBox));
        }
Esempio n. 6
0
        void AddNewText(string newText)
        {
            HitTestMetrics start, end;
            RawBool        startTrailingHit, endTrailingHit;
            int            startTextPosition, endTextPosition;
            string         a = "", b = "";
            int            newHitIdx = 0;

            if (hitTestMetrics[1].TextPosition == hitTestMetrics[0].TextPosition &&
                (isTrailingHit[1] == false && isTrailingHit[0] == true) ||
                hitTestMetrics[1].TextPosition < hitTestMetrics[0].TextPosition)
            {
                start             = hitTestMetrics[1];
                startTextPosition = start.TextPosition;
                startTrailingHit  = isTrailingHit[1];

                end             = hitTestMetrics[0];
                endTextPosition = end.TextPosition;
                endTrailingHit  = isTrailingHit[0];
            }
            else
            {
                start             = hitTestMetrics[0];
                startTextPosition = start.TextPosition;
                startTrailingHit  = isTrailingHit[0];

                end             = hitTestMetrics[1];
                endTextPosition = end.TextPosition;
                endTrailingHit  = isTrailingHit[1];
            }

            if (string.IsNullOrWhiteSpace(txt))
            {
                a = "";
                b = "";
            }
            else if (startTextPosition == endTextPosition && startTrailingHit == false && endTrailingHit == false)   //点击前端
            {
                int pos = startTextPosition;
                a = txt.Substring(0, pos);
                b = txt.Substring(pos, txt.Length - pos);
            }
            else if (startTextPosition == endTextPosition && startTrailingHit == true && endTrailingHit == false) //点击后端
            {
                int pos = startTextPosition + 1;
                a = txt.Substring(0, pos);
                b = txt.Substring(pos, txt.Length - pos);
            }
            else if (startTrailingHit == true && endTrailingHit == true) //开始位置"后端", 结束位置"后端"
            {
                a = txt.Substring(0, startTextPosition + 1);
                b = txt.Substring(endTextPosition + 1, txt.Length - endTextPosition - 1);
            }
            else if (startTrailingHit == true && endTrailingHit == false) //开始位置"后端", 结束位置"前端"
            {
                a = txt.Substring(0, startTextPosition + 1);
                b = txt.Substring(endTextPosition, txt.Length - endTextPosition);
            }
            else if (startTrailingHit == false && endTrailingHit == true) //开始位置"前端", 结束位置"后端"
            {
                a = txt.Substring(0, startTextPosition);
                b = txt.Substring(endTextPosition + 1, txt.Length - endTextPosition - 1);
            }
            else if (startTrailingHit == false && endTrailingHit == false) //开始位置"前端", 结束位置"前端"
            {
                a = txt.Substring(0, startTextPosition);
                b = txt.Substring(endTextPosition, txt.Length - endTextPosition);
            }

            RectangleF oldrc = DrawBox;

            txt = a + newText + b;

            CreateD2D();
            InitTextFormatLayout();

            newHitIdx = a.Count() + newText.Count();

            if (newHitIdx < 0)
            {
                newHitIdx = 0;
            }

            metricsList = CurrentTextLayout.HitTestTextRange(newHitIdx, 1, 0.0f, 0.0f);

            hitTestMetrics[1] = hitTestMetrics[0] = metricsList[0];
            isInside[1]       = isInside[0];
            isTrailingHit[1]  = isTrailingHit[0] = false;
            cursorIdx         = 0;

            metricsList = null;

            int x = (int)Math.Round(hitTestMetrics[cursorIdx].Left);
            int y = (int)Math.Round(hitTestMetrics[cursorIdx].Top);

            SetImeWindowsPos(x, y);


            if (CursorPositionEvent != null)
            {
                RectangleF rect =
                    new RectangleF(
                        hitTestMetrics[cursorIdx].Left,
                        hitTestMetrics[cursorIdx].Top,
                        hitTestMetrics[cursorIdx].Width,
                        hitTestMetrics[cursorIdx].Height);

                CursorPositionEvent(rect);
            }

            if (TextViewValueChangedEvent != null)
            {
                TextViewValueChangedEvent(this);
            }


            InvalidateGlobalRect(GDIDataD2DUtils.UnionRectF(oldrc, DrawBox));
        }