예제 #1
0
        public void RemoveLineAt(int index)
        {
            if (_lines == null || index < 0 || index >= _lines.Length)
            {
                return;
            }

            _lines[index].Parent = null;

            if (_lines.Length == 1)
            {
                _lines = null;
            }
            else
            {
                var tmp = new LineGraphItem[_lines.Length - 1];
                int c   = 0;
                for (int i = 0; i < _lines.Length; i++)
                {
                    if (i != index)
                    {
                        tmp[c++] = _lines[i];
                    }
                }
                _lines = tmp;
            }

            Invalidate();
        }
예제 #2
0
        public void AddLines(LineGraphItem[] lines)
        {
            if (lines == null)
            {
                return;
            }

            for (int i = 0; i < lines.Length; i++)
            {
                lines[i].Parent = this;
            }

            if (_lines == null)
            {
                _lines = lines;
            }
            else
            {
                var tmp = new LineGraphItem[_lines.Length + lines.Length];
                Array.Copy(_lines, tmp, _lines.Length);
                Array.Copy(lines, 0, tmp, _lines.Length, lines.Length);
                _lines = tmp;
            }

            Invalidate();
        }
예제 #3
0
        public void RemoveLine(LineGraphItem line)
        {
            if (_lines == null)
            {
                return;
            }

            for (int i = 0; i < _lines.Length; i++)
            {
                if (_lines[i] == line)
                {
                    RemoveLineAt(i);
                    return;
                }
            }
        }
예제 #4
0
        public void AddLine(LineGraphItem line)
        {
            line.Parent = this;

            if (_lines == null)
            {
                _lines = new[] { line };
            }
            else
            {
                var tmp = new LineGraphItem[_lines.Length + 1];
                Array.Copy(_lines, tmp, _lines.Length);
                tmp[tmp.Length - 1] = line;
                _lines = tmp;
            }

            Invalidate();
        }