Ejemplo n.º 1
0
            public int Parse(char[] format, int index)
            {
                int    colon = SplitFormat.FindChar(format, index, ':');
                string ratio = new string(format, index, colon - index);

                if (ratio == "L")
                {
                    _ratio = ALL_OF_REST;
                }
                else
                {
                    int r = Int32.Parse(ratio);
                    if (r <= 0 || r >= 100)
                    {
                        throw new FormatException("ratio range error");
                    }
                    _ratio = r / 100.0;
                }

                if (format[colon + 1] == 'L')   //label
                {
                    int l = SplitFormat.FindChar2(format, colon + 2, ',', ')');
                    _label = new string(format, colon + 2, l - (colon + 2));
                    return(l);
                }
                else   //split
                {
                    _content = new SplitFormat();
                    return(_content.Parse(format, colon + 1));
                }
            }
Ejemplo n.º 2
0
        private DivisionList CreateDivisionList(SplitFormat info, PaneCreationDelegate creation, DockStyle host_dock)
        {
            DivisionList list = new DivisionList(this, info.Direction, host_dock);

            list.FirstNode = CreateDivisionNodeList(list, info, creation);
            return(list);
        }
Ejemplo n.º 3
0
 public Node(double ratio, SplitFormat content, string label, Node next)
 {
     _ratio   = ratio;
     _content = content;
     _label   = label;
     _next    = next;
 }
Ejemplo n.º 4
0
        public static SplitFormat Parse(string format)
        {
            char[]      content = format.ToCharArray();
            SplitFormat info    = new SplitFormat();
            int         len     = info.Parse(content, 0);

            if (len != content.Length)
            {
                throw new FormatException();
            }
            return(info);
        }
Ejemplo n.º 5
0
        public void ApplySplitInfo(Control parent, Control prev_content, string format, PaneCreationDelegate creation)
        {
            bool        was_empty = this.IsEmpty;
            SplitFormat info      = SplitFormat.Parse(format);

            _rootList = CreateDivisionList(info, creation, DockStyle.Fill);
            _count    = _rootList.GetDivisionCount();
            Rebuild();

            if (prev_content == null)
            {
                parent.Controls.Add(_rootList.HostingControl);
            }
            else
            {
                Debug.Assert(prev_content.Parent == parent);
                UIUtil.ReplaceControl(parent, prev_content, _rootList.HostingControl);
            }

            DoLayout();
        }
Ejemplo n.º 6
0
        private DivisionNode CreateDivisionNodeList(DivisionList list, SplitFormat info, PaneCreationDelegate creation)
        {
            SplitFormat.Node tag       = info.FirstTag;
            DivisionNode     firstnode = null;
            DivisionNode     prev      = null;
            double           remain    = 1.0;

            while (tag != null)
            {
                DivisionNode node = null;

                if (tag.Content != null)
                {
                    DockStyle dock = tag.Next == null ? (info.Direction == Direction.TB ? DockStyle.Bottom : DockStyle.Right) : DockStyle.Fill;
                    node = new DivisionNode(list, CreateDivisionList(tag.Content, creation, dock), tag.GetActualRatio(remain));
                }
                else
                {
                    node = new DivisionNode(list, creation(tag.Label), tag.GetActualRatio(remain));
                }
                remain -= tag.Ratio;

                if (firstnode == null)
                {
                    firstnode = node;
                }
                else
                {
                    prev.Next = node;
                }

                Debug.Assert(node.ParentList == list);
                prev = node;
                tag  = tag.Next;
            }

            return(firstnode);
        }
Ejemplo n.º 7
0
        private DivisionNode CreateDivisionNodeList(DivisionList list, SplitFormat info, PaneCreationDelegate creation)
        {
            SplitFormat.Node tag = info.FirstTag;
            DivisionNode firstnode = null;
            DivisionNode prev = null;
            double remain = 1.0;
            while (tag != null) {
                DivisionNode node = null;

                if (tag.Content != null) {
                    DockStyle dock = tag.Next == null ? (info.Direction == Direction.TB ? DockStyle.Bottom : DockStyle.Right) : DockStyle.Fill;
                    node = new DivisionNode(list, CreateDivisionList(tag.Content, creation, dock), tag.GetActualRatio(remain));
                }
                else {
                    node = new DivisionNode(list, creation(tag.Label), tag.GetActualRatio(remain));
                }
                remain -= tag.Ratio;

                if (firstnode == null)
                    firstnode = node;
                else
                    prev.Next = node;

                Debug.Assert(node.ParentList == list);
                prev = node;
                tag = tag.Next;
            }

            return firstnode;
        }
Ejemplo n.º 8
0
 private DivisionList CreateDivisionList(SplitFormat info, PaneCreationDelegate creation, DockStyle host_dock)
 {
     DivisionList list = new DivisionList(this, info.Direction, host_dock);
     list.FirstNode = CreateDivisionNodeList(list, info, creation);
     return list;
 }
Ejemplo n.º 9
0
            public int Parse(char[] format, int index)
            {
                int colon = SplitFormat.FindChar(format, index, ':');
                string ratio = new string(format, index, colon - index);
                if (ratio == "L")
                    _ratio = ALL_OF_REST;
                else {
                    int r = Int32.Parse(ratio);
                    if (r <= 0 || r >= 100)
                        throw new FormatException("ratio range error");
                    _ratio = r / 100.0;
                }

                if (format[colon + 1] == 'L') { //label
                    int l = SplitFormat.FindChar2(format, colon + 2, ',', ')');
                    _label = new string(format, colon + 2, l - (colon + 2));
                    return l;
                }
                else { //split
                    _content = new SplitFormat();
                    return _content.Parse(format, colon + 1);
                }
            }
Ejemplo n.º 10
0
 public Node(double ratio, SplitFormat content, string label, Node next)
 {
     _ratio = ratio;
     _content = content;
     _label = label;
     _next = next;
 }
Ejemplo n.º 11
0
 public static SplitFormat Parse(string format)
 {
     char[] content = format.ToCharArray();
     SplitFormat info = new SplitFormat();
     int len = info.Parse(content, 0);
     if (len != content.Length)
         throw new FormatException();
     return info;
 }