Beispiel #1
0
 public AlignObjectsEditOperation(Box alignBox, AlignAxis axis, AlignDirection direction, TransformFlags transformFlags)
 {
     _alignBox       = alignBox;
     _axis           = axis;
     _direction      = direction;
     _transformFlags = transformFlags;
 }
 public AlignObjectsEditOperation(Box alignBox, AlignAxis axis, AlignDirection direction, TransformFlags transformFlags)
 {
     _alignBox = alignBox;
     _axis = axis;
     _direction = direction;
     _transformFlags = transformFlags;
 }
 public int AlignIndexToNearestCluster(int index, AlignDirection flow)
 {
     if (flow == AlignDirection.Back)
     {
         return(Math.Max(index - 1, 0));
     }
     if (flow == AlignDirection.Forward)
     {
         return(index + 1);
     }
     throw new ArgumentOutOfRangeException("flowの値がおかしい");
 }
Beispiel #4
0
        public int AlignIndexToNearestCluster(int index, AlignDirection flow)
        {
            float x, y;

            DW.HitTestMetrics metrics;
            metrics = this.layout.HitTestTextPosition(index, false, out x, out y);

            if (flow == AlignDirection.Forward)
            {
                return(Util.RoundUp(metrics.TextPosition + metrics.Length));
            }
            else if (flow == AlignDirection.Back)
            {
                return(Util.RoundUp(metrics.TextPosition));
            }
            throw new ArgumentOutOfRangeException();
        }
        /// <summary>
        /// キャレットを一文字移動させる
        /// </summary>
        /// <param name="caret">キャレット</param>
        /// <param name="isMoveNext">真なら1文字すすめ、そうでなければ戻す</param>
        /// <remarks>このメソッドを呼び出した後でScrollToCaretメソッドとSelectWithMoveCaretメソッドを呼び出す必要があります</remarks>
        TextPoint MoveCaretHorizontical(TextPoint caret, bool isMoveNext)
        {
            if (this.Document.FireUpdateEvent == false)
            {
                throw new InvalidOperationException("");
            }
            int    delta      = isMoveNext ? 0 : -1;
            int    prevcol    = caret.col;
            int    col        = caret.col + delta;
            string lineString = this.View.LayoutLines[caret.row];

            if (col < 0 || caret.row >= this.View.LayoutLines.Count)
            {
                if (caret.row == 0)
                {
                    caret.col = 0;
                    return(caret);
                }
                caret     = this.MoveCaretVertical(caret, false);
                caret.col = this.View.LayoutLines.GetLengthFromLineNumber(caret.row) - 1;  //最終行以外はすべて改行コードが付くはず
            }
            else if (col >= lineString.Length || lineString[col] == Document.NewLine)
            {
                if (caret.row < this.View.LayoutLines.Count - 1)
                {
                    caret     = this.MoveCaretVertical(caret, true);
                    caret.col = 0;
                }
            }
            else
            {
                AlignDirection direction = isMoveNext ? AlignDirection.Forward : AlignDirection.Back;
                caret.col = this.View.LayoutLines.GetLayout(caret.row).AlignIndexToNearestCluster(col, direction);
            }
            return(caret);
        }
Beispiel #6
0
 private void AlignMiddle(Microsoft.Office.Interop.PowerPoint.ShapeRange shapeRange, AlignDirection direction)
 {
     if (shapeRange == null || shapeRange.Count < 2)
     {
         return;
     }
     for (int i = 2; i <= shapeRange.Count; i++)
     {
         if (direction == AlignDirection.Horizontal)
         {
             shapeRange[i].Left = shapeRange[1].Left + (shapeRange[1].Width - shapeRange[i].Width) / 2;
         }
         else if (direction == AlignDirection.Vertical)
         {
             shapeRange[i].Top = shapeRange[1].Top + (shapeRange[1].Height - shapeRange[i].Height) / 2;
         }
         else
         {
             return;
         }
     }
 }
Beispiel #7
0
 public int AlignIndexToNearestCluster(int index, AlignDirection flow)
 {
     return(0);
 }
Beispiel #8
0
        public int AlignIndexToNearestCluster(int index, AlignDirection flow)
        {
            CharacterHit hit = this.Lines[0].GetNextCaretCharacterHit(new CharacterHit(index, 0));

            return(flow == AlignDirection.Back ? hit.FirstCharacterIndex : hit.FirstCharacterIndex + hit.TrailingLength);
        }
        void Align(AlignDirection direction)
        {
            for (int polygonIndex = 0; polygonIndex < selectedSourcePolygons.Count; polygonIndex++)
            {
                Polygon polygon = selectedSourcePolygons[polygonIndex];

                Transform brushTransform = matchedBrushes[polygon].transform;

                UVOrientation worldOrientation = GetNorthEastVectors(polygon, brushTransform);

                Vector3 worldVectorNorth = worldOrientation.NorthVector;
                Vector3 worldVectorEast = worldOrientation.EastVector;

                // These are flipped for some reason
                worldVectorNorth *= -1;
                worldVectorEast *= -1;

                Vector3 polygonCenterLocal = polygon.GetCenterPoint();
                Vector3 polygonCenterWorld = brushTransform.TransformPoint(polygonCenterLocal);

                // World vertices
                Polygon[] builtPolygons = csgModel.BuiltPolygonsByIndex(polygon.UniqueIndex);
                Vertex northernVertex = builtPolygons[0].Vertices[0];
                Vertex southernVertex = builtPolygons[0].Vertices[0];
                Vertex easternVertex = builtPolygons[0].Vertices[0];
                Vertex westernVertex = builtPolygons[0].Vertices[0];

                for (int builtIndex = 0; builtIndex < builtPolygons.Length; builtIndex++)
                {
                    for (int i = 0; i < builtPolygons[builtIndex].Vertices.Length; i++)
                    {
                        Vertex testVertex = builtPolygons[builtIndex].Vertices[i];

                        float dotCurrent = Vector3.Dot(northernVertex.Position-polygonCenterWorld, worldVectorNorth);
                        float dotTest = Vector3.Dot(testVertex.Position-polygonCenterWorld, worldVectorNorth);
                        if(dotTest > dotCurrent)
                        {
                            northernVertex = testVertex;
                        }

                        dotCurrent = Vector3.Dot(southernVertex.Position-polygonCenterWorld, -worldVectorNorth);
                        dotTest = Vector3.Dot(testVertex.Position-polygonCenterWorld, -worldVectorNorth);
                        if(dotTest > dotCurrent)
                        {
                            southernVertex = testVertex;
                        }

                        dotCurrent = Vector3.Dot(easternVertex.Position-polygonCenterWorld, worldVectorEast);
                        dotTest = Vector3.Dot(testVertex.Position-polygonCenterWorld, worldVectorEast);
                        if(dotTest > dotCurrent)
                        {
                            easternVertex = testVertex;
                        }

                        dotCurrent = Vector3.Dot(westernVertex.Position-polygonCenterWorld, -worldVectorEast);
                        dotTest = Vector3.Dot(testVertex.Position-polygonCenterWorld, -worldVectorEast);
                        if(dotTest > dotCurrent)
                        {
                            westernVertex = testVertex;
                        }
                    }
                }

                Vector2 offset = new Vector2(0,0);

                if(direction == AlignDirection.Top)
                {
                    offset.y = 1-northernVertex.UV.y;
                }
                else if(direction == AlignDirection.Bottom)
                {
                    offset.y = 0-southernVertex.UV.y;
                }
                else if(direction == AlignDirection.Left)
                {
                    offset.x = 0-westernVertex.UV.x;
                }
                else if(direction == AlignDirection.Right)
                {
                    offset.x = 1-easternVertex.UV.x;
                }

                TransformUVs(polygon, UVUtility.TranslateUV, new UVUtility.TransformData(offset,0));
            }
        }