Exemplo n.º 1
0
        void Attach(SortedList <float, GridLine <T> > lines, GridLineEntry <T> entry, bool vertical)
        {
            var key = vertical ? entry.Location.X : entry.Location.Y;

            if (lines.ContainsKey(key))
            {
                var line = lines[key];
                line.elements.Add(entry);
                line.UpdateSizeConstrains();
                if (vertical)
                {
                    entry.OffsetX = line.Offset;
                }
                else
                {
                    entry.OffsetY = line.Offset;
                }
            }
            else
            {
                var line = new GridLine <T>(vertical);
                line.elements.Add(entry);
                line.Key = key;
                line.UpdateSizeConstrains();
                if (vertical)
                {
                    entry.OffsetX = line.Offset;
                }
                else
                {
                    entry.OffsetY = line.Offset;
                }
                lines.Add(key, line);
            }
        }
Exemplo n.º 2
0
        public void Add(T element, PointF location, SizeF size)
        {
            var entry = new GridLineEntry <T>(element, location, size);

            elements.Add(element, entry);
            Attach(horzLines, entry, false);
            Attach(vertLines, entry, true);
        }
Exemplo n.º 3
0
        void Detach(SortedList <float, GridLine <T> > lines, GridLineEntry <T> entry, bool vertical)
        {
            var key = vertical ? entry.Location.X : entry.Location.Y;

            if (lines.ContainsKey(key))
            {
                var line = lines[key];
                line.elements.Remove(entry);
                line.UpdateSizeConstrains();
                if (line.Count == 0)
                {
                    lines.Remove(key);
                }
            }
        }