Пример #1
0
 public void AddPathReverse(GraphicsPath path)
 {
     for (int i = path.PathActions.Count - 1; i > 0; i--)
     {
         PathActions.Add(path.PathActions[i]);
     }
 }
Пример #2
0
 public void AddPath(GraphicsPath path)
 {
     foreach (var action in path.PathActions)
     {
         PathActions.Add(action);
     }
 }
Пример #3
0
        public byte[] ToByteArray()
        {
            UpdateInt(Team, 14, ref _bytes);
            UpdateInt(Radius, 12, ref _bytes);

            // clear all actions
            UpdateInt(65535, 16, ref _bytes);
            UpdateInt(65535, 18, ref _bytes);
            UpdateInt(65535, 20, ref _bytes);
            UpdateInt(65535, 22, ref _bytes);
            UpdateInt(65535, 24, ref _bytes);
            UpdateInt(65535, 26, ref _bytes);

            // clear all path actions
            UpdateInt(65535, 28, ref _bytes);
            UpdateInt(65535, 30, ref _bytes);
            UpdateInt(65535, 32, ref _bytes);
            UpdateInt(65535, 34, ref _bytes);
            UpdateInt(65535, 36, ref _bytes);
            UpdateInt(65535, 38, ref _bytes);

            if (Actions.Trim().Length != 0)
            {
                string[] actions = Actions.Split(new char[] { ' ' });

                int pos = 16;

                for (int x = 0; x < actions.Length; x++)
                {
                    try
                    {
                        int action = Convert.ToInt32(actions[x]);
                        UpdateInt(action, pos, ref _bytes);
                        pos += 2;
                    }
                    catch {}
                }
            }

            if (PathActions.Trim().Length != 0)
            {
                string[] actions = PathActions.Split(new char[] { ' ' });

                int pos = 28;

                for (int x = 0; x < actions.Length; x++)
                {
                    try
                    {
                        int action = Convert.ToInt32(actions[x]);
                        UpdateInt(action, pos, ref _bytes);
                        pos += 2;
                    }
                    catch {}
                }
            }

            return(_bytes);
        }
Пример #4
0
        public void Close()
        {
            if (PathActions.Count == 0)
            {
                return;
            }

            PathActions.Add(new PathAction(GetPathStart().PathPoint, VerbType.Close));
        }
Пример #5
0
        public void LineTo(Point point)
        {
            if (PathActions.Count == 0)
            {
                MoveTo(point);
                return;
            }

            PathActions.Add(new PathAction(point, VerbType.Line));
        }
Пример #6
0
        public void LineTo(int x, int y)
        {
            if (PathActions.Count == 0)
            {
                MoveTo(x, y);
                return;
            }

            PathActions.Add(new PathAction(new Point(x, y), VerbType.Line));
        }
Пример #7
0
        public void RelativeLineTo(Point point)
        {
            int count = PathActions.Count;

            if (count > 0)
            {
                PathActions.Add(new PathAction(point + ((PathAction)PathActions[count - 1]).PathPoint, VerbType.Line));
            }
            else
            {
                LineTo(point);
            }
        }
Пример #8
0
        public void RelativeLineTo(int x, int y)
        {
            int count = PathActions.Count;

            if (count > 0)
            {
                PathActions.Add(new PathAction(new Point(x, y) + ((PathAction)PathActions[count - 1]).PathPoint, VerbType.Line));
            }
            else
            {
                LineTo(x, y);
            }
        }
Пример #9
0
        public void RelativeMoveTo(Point point)
        {
            int count = PathActions.Count;

            if (count > 0)
            {
                PathActions.Add(new PathAction(point + PathActions[count - 1].PathPoint, VerbType.Move));
            }
            else
            {
                MoveTo(point);
            }
        }
Пример #10
0
        public void RelativeMoveTo(int x, int y)
        {
            int count = PathActions.Count;

            if (count > 0)
            {
                PathActions.Add(new PathAction(new Point(x, y) + PathActions[count - 1].PathPoint, VerbType.Move));
            }
            else
            {
                MoveTo(x, y);
            }
        }
Пример #11
0
        public void MoveTo(Point point)
        {
            if (PathActions.Count > 0)
            {
                var last = GetLastAction();

                if (last.Verb == VerbType.Move)
                {
                    last.PathPoint = point;
                    return;
                }
            }

            PathActions.Add(new PathAction(point, VerbType.Move));
        }
Пример #12
0
        PathAction GetPathStart()
        {
            var action = PathActions.Where(p => p.Verb == VerbType.Close).LastOrDefault();

            if (action.Verb == VerbType.Close)
            {
                var index = PathActions.IndexOf(action);
                if (index < PathActions.Count - 1 && PathActions[index + 1].Verb == VerbType.Move)
                {
                    index++;
                }
                return(PathActions[index]);
            }
            return(PathActions[0]);
        }
Пример #13
0
        PathAction GetPathStart()
        {
            //var action = PathActions.Where(p => p.Verb == VerbType.Close).LastOrDefault();
            PathAction action = default;

            for (var i = PathActions.Count - 1; i >= 0; i--)
            {
                action = (PathAction)PathActions[i];
                break;
            }
            if (action.Verb == VerbType.Close)
            {
                var index = PathActions.IndexOf(action);
                if (index < PathActions.Count - 1 && ((PathAction)PathActions[index + 1]).Verb == VerbType.Move)
                {
                    index++;
                }
                return((PathAction)PathActions[index]);
            }
            return((PathAction)PathActions[0]);
        }
Пример #14
0
        List <Path> extractSubpaths(List <PAction> inActions)
        {         // not use yet
            Debug.LogError("extractSubpaths not implement");

            List <Path> subPaths = new List <Path> ();
            Path        lastPath = new Path();

            for (int i = 0, il = inActions.Count; i < il; i++)
            {
                PAction item = inActions [i];

                List <float> args       = item.args;
                PathActions  action     = item.action;
                bool         aClockwise = item.aClockwise;

                if (action == PathActions.MOVE_TO)
                {
                    if (lastPath.actions.Count != 0)
                    {
                        subPaths.Add(lastPath);
                        lastPath = new Path();
                    }
                }

                // js 477
                //lastPath[ action ].apply( lastPath, args );
                Debug.LogError("######### TODO: no implement ############");

                if (action == PathActions.MOVE_TO)
                {
                    lastPath.moveTo(args [0], args [1]);
                }
                else if (action == PathActions.LINE_TO)
                {
                    lastPath.lineTo(args [0], args [1]);
                }
                else if (action == PathActions.ARC)
                {
                    //lastPath.arc(args[0], args[1], args[2], args[3], args[4], args[5]);
                }
                else if (action == PathActions.ELLIPSE)
                {
                    lastPath.ellipse(args [0], args [1], args [2], args [3], args [4], args [5], aClockwise);
                }
                else if (action == PathActions.QUADRATIC_CURVE_TO)
                {
                    lastPath.quadraticCurveTo(args [0], args [1], args [2], args [3]);
                }
                else
                {
                }
            }

            if (lastPath.actions.Count != 0)
            {
                subPaths.Add(lastPath);
            }

            // console.log(subPaths);

            return(subPaths);
        }
Пример #15
0
 public PAction(PathActions action, List <float> pos)
 {
     this.action = action;
     this.args   = pos;
 }
Пример #16
0
 PathAction GetLastAction()
 {
     return(PathActions.Last());
 }