public MyTreeList()
     : base()
 {
     Bands                  = new MyTreeListBandCollection(this);
     fRootBand              = Bands[0];
     this.PopupMenuShowing += onPopupMenuShowing;
 }
 public static bool IsValid(MyTreeListBand Band)
 {
     if ((Band == null) || (Band.Position < 0) || (Band.Width < 1))
     {
         return(false);
     }
     if (Band.Parent != null)
     {
         foreach (MyTreeListBand Child in Band.Parent.Children)
         {
             if (Child != Band)  //Intersection check
             {
                 if (Child.Position > Band.Position)
                 {
                     if (Band.EndPosition >= Child.Position)
                     {
                         return(false);
                     }
                 }
                 else
                 {
                     if (Child.EndPosition >= Band.Position)
                     {
                         return(false);
                     }
                 }
             }
         }
     }
     return(true);
 }
 public MyTreeListBandInfo(MyTreeListBand band)
     : base(band.BandColumn)
     //: base(new TreeListColumn())
 {
     fBand = band;
     Type  = ColumnInfoType.ColumnButton;
 }
 public virtual bool IsBrother(MyTreeListBand Band)
 {
     if (Band == null)
     {
         return(false);
     }
     return(Band.Parent == Parent);
 }
 public bool Swap(MyTreeListBand BandA, MyTreeListBand BandB)
 {
     if (BandA.Parent != null)
     {
         return(BandA.Parent.TryToSwap(BandA, BandB));
     }
     return(false);
 }
 public bool Swap(MyTreeListBand Band, TreeListColumn Column)
 {
     if (Band.Parent != null)
     {
         return(Band.Parent.TryToSwapBandAndColumn(Band, Column));
     }
     return(false);
 }
Esempio n. 7
0
        public override void CalcColumnInfo(ColumnInfo ci, ref int left, bool customization)
        {
            int offset = 0;

            base.CalcColumnInfo(ci, ref offset, customization);
            if (ci.Type == ColumnInfo.ColumnInfoType.Column)
            {
                MyTreeListBand ParentBand = TreeList.Bands.GetColumnParentBand(ci.Column);
                if (ParentBand == null)
                {
                    ci.Bounds = Rectangle.Empty;
                    return;
                }
                MyTreeListBandInfo bi = new MyTreeListBandInfo(ParentBand);
                bi.CalcBandInfo(this);
                int VisiblePosition = ParentBand.GetColumnIndex(ci.Column);
                if (ParentBand.BandColumn == ci.Column)
                {
                    ci.Bounds      = bi.Bounds;
                    ci.CaptionRect = new Rectangle(left + 4, 0, bi.Bounds.Width, bi.Bounds.Height);
                    if (BandLinks.ContainsKey(ci.Column))
                    {
                        BandLinks[ci.Column] = bi;
                    }
                    else
                    {
                        BandLinks.Add(ci.Column, bi);
                    }
                }
                else
                {
                    int X = bi.Bounds.X;
                    for (int i = 0; i < VisiblePosition; i++)
                    {
                        TreeListColumn Col = ParentBand.GetColumn(i);
                        if ((Col != null) && Col.Visible)
                        {
                            X += Col.Width;
                        }
                    }
                    int Y      = bi.Bounds.Bottom - 1;
                    int Width  = ci.Column.Width;
                    int Height = BandHeight * (BandMaxLevel - ParentBand.Level);
                    ci.Bounds      = new Rectangle(X, Y, Width, Height);
                    ci.CaptionRect = new Rectangle(left + 4, 0, Width, Height);
                    ColCount++;
                    left += Width;
                }
            }
            else
            {
                left += offset;
            }
            UpdateGlyphInfo(ci);
            ObjectPainter.CalcObjectBounds(GInfo.Graphics, TreeList.ElementsLookAndFeel.Painter.Header, ci);
        }
 public MyTreeListBand(MyTreeList TreeList, MyTreeListBand parent, int position, int width, string name)
 {
     fTreeList   = TreeList;
     fChildren   = new MyTreeListBandCollection(this, TreeList.Bands);
     fColumns    = new TreeListColumn[width];
     fParent     = parent;
     fName       = name;
     fPosition   = position;
     fLevel      = (Parent == null) ? 0 : Parent.Level + 1;
     fBandColumn = null;
     fVisible    = true;
 }
Esempio n. 9
0
        public void CalcCellBandMap(MyTreeListBand Band)
        {
            Source = new BandMapCell[Band.Width, Band.GetDepth()];
            for (int i = 0; i < Band.Width; i++)
            {
                if (Band.Columns[i] != null)
                {
                    Source[i, 0] = new BandMapCell(Band.Columns[i], true, true);
                }
            }
            foreach (MyTreeListBand Child in Band.Children)
            {
                FillCellSource(Child, Child.Position, 0);
            }
            int EmptyLevelCount = 0;

            for (int i = LevelCount - 1; i >= 0; i--)
            {
                bool EmptyLevel = true;
                for (int j = 0; j < ColCount; j++)
                {
                    if (Source[j, i] != null)
                    {
                        EmptyLevel = false;
                        break;
                    }
                }
                if (EmptyLevel)
                {
                    EmptyLevelCount++;
                }
                else
                {
                    break;
                }
            }
            if (EmptyLevelCount > 0)
            {
                int NewLevelCount = LevelCount - EmptyLevelCount;
                BandMapCell[,] Temp = new BandMapCell[ColCount, NewLevelCount];
                for (int i = 0; i < ColCount; i++)
                {
                    for (int j = 0; j < NewLevelCount; j++)
                    {
                        Temp[i, j] = Source[i, j];
                    }
                }
                Source = Temp;
            }
        }
Esempio n. 10
0
 public void CalcBandMap(MyTreeListBand Band)
 {
     Source = new BandMapCell[Band.Width, Band.GetDepth()];
     for (int i = 0; i < Band.Width; i++)
     {
         if (Band.Columns[i] != null)
         {
             Source[i, 0] = new BandMapCell(Band.Columns[i], true, true);
         }
     }
     foreach (MyTreeListBand Child in Band.Children)
     {
         FillSource(Child, Child.Position, 0);
     }
 }
Esempio n. 11
0
 public virtual void Remove(MyTreeListBand Band)
 {
     foreach (MyTreeListBand Child in Band.Children)
     {
         Remove(Child);
     }
     Band.Children.Clear();
     if (Band.Parent != null)
     {
         Band.Parent.Children.Remove(Band);
         for (int i = 0; i < Band.Width; i++)
         {
             Band.Parent.SetColumn(i + Band.Position, Band.Columns[i]);
         }
     }
     Remove(Band);
 }
 public TreeListColumn GetColumn(int Index)
 {
     if ((Index >= 0) && (Index < Width))
     {
         int            Handle = IndexToColumnHandle(Index);
         MyTreeListBand Child  = Children.FindAtHandle(Handle);
         if (Child == null)
         {
             return(Columns[Index]);
         }
         else
         {
             return(Child.GetColumn(Child.ColumnHandleToIndex(Handle)));
         }
     }
     return(null);
 }
Esempio n. 13
0
        protected void FillSource(MyTreeListBand Band, int Offset, int Level)
        {
            object CellObj = (Band.BandColumn == null) ? (object)Band : (object)Band.BandColumn;

            for (int i = 0; i < Band.Width; i++)
            {
                Source[Offset + i, Level] = new BandMapCell(CellObj, i == 0, i == (Band.Width - 1));
                if (Band.Columns[i] != null)
                {
                    Source[Offset + i, Level + 1] = new BandMapCell(Band.Columns[i], true, true);
                }
            }
            foreach (MyTreeListBand Child in Band.Children)
            {
                FillSource(Child, Offset + Child.Position, Level + 1);
            }
        }
 public void SetColumn(int Index, TreeListColumn Column)
 {
     if ((Column != null) && (Index >= 0) && (Index < Width))
     {
         int            Handle = IndexToColumnHandle(Index);
         MyTreeListBand Child  = Children.FindAtHandle(Handle);
         if (Child == null)
         {
             Columns[Index]      = Column;
             Column.VisibleIndex = Handle;
         }
         else
         {
             Child.SetColumn(Child.ColumnHandleToIndex(Handle), Column);
             Columns[Index] = null;
         }
     }
 }
Esempio n. 15
0
        private void FillCellSource(MyTreeListBand Band, int Offset, int Level)
        {
            int NewLevel = (Band.BandColumn == null) ? Level : Level + 1;

            for (int i = 0; i < Band.Width; i++)
            {
                if (Band.BandColumn != null)
                {
                    Source[Offset + i, Level] = new BandMapCell(Band.BandColumn, i == 0, i == (Band.Width - 1));
                }
                if (Band.Columns[i] != null)
                {
                    Source[Offset + i, NewLevel] = new BandMapCell(Band.Columns[i], true, true);
                }
            }
            foreach (MyTreeListBand Child in Band.Children)
            {
                FillCellSource(Child, Offset + Child.Position, NewLevel);
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            //myTreeList1.DataSource = null;
            //myTreeList1.Columns.Clear();
            //myTreeList1.Bands.Clear();
            //myTreeList1.RootBand.Children.Clear();
            DT = new DataTable();
            DT.Columns.Add("ID", typeof(int));
            DT.Columns.Add("ParentID", typeof(int));
            DT.Columns.Add("FirstName", typeof(string));
            DT.Columns.Add("LastName", typeof(string));
            DT.Columns.Add("Age", typeof(int));
            DT.Columns.Add("Position", typeof(string));
            DT.Columns.Add("Experience", typeof(int));
            DT.Rows.Add(1, 0, "Andy", "Smith", 45, "Director", 15);
            DT.Rows.Add(2, 1, "Elizabeth", "Woods", 30, "Manager", 9);
            DT.Rows.Add(3, 2, "Henry", "Hill", 28, "Employee", 4);
            DT.Rows.Add(4, 2, "Bobby", "Lopez", 24, "Employee", 2);
            DT.Rows.Add(5, 1, "Joe", "Martinez", 38, "Chief accountant", 13);
            DT.Rows.Add(6, 5, "Nora", "Gates", 22, "Accountant", 1);
            DT.Rows.Add(7, 0, "Derek", "Swanson", 58, "Director", 25);
            DT.Rows.Add(8, 7, "Ben", "Davidson", 22, "Employee", 3);
            myTreeList1.DataSource = DT;
            myTreeList1.ForceInitialize();
            gridControl1.DataSource = DT;
            myTreeList1.SetBandsWidth(3);
            MyTreeListBand BandPersInfo = myTreeList1.Bands.Add(0, 2, "Personal info");
            MyTreeListBand BandLastName = BandPersInfo.CreateChild(0, 2, "Last Name");
            MyTreeListBand BandWorkInfo = myTreeList1.Bands.Add(2, 1, "Work info");
            MyTreeListBand BandPosition = BandWorkInfo.CreateChild(0, 1, "Position");

            BandLastName.SetColumn(0, myTreeList1.Columns[0]);
            BandLastName.BandColumn = myTreeList1.Columns[1];
            BandLastName.SetColumn(1, myTreeList1.Columns[2]);
            BandPosition.BandColumn = myTreeList1.Columns[3];
            BandPosition.SetColumn(0, myTreeList1.Columns[4]);
            myTreeList1.ViewInfo.RC.NeedsRestore = true;
            myTreeList1.LayoutChanged();
            myTreeList1.BestFitColumns();
            myTreeList1.LayoutChanged();
        }
Esempio n. 17
0
 protected internal virtual MyTreeListBand Add(MyTreeListBand Band)
 {
     if (MyTreeListBand.IsValid(Band))
     {
         if (fTreeListBands != null)
         {
             foreach (MyTreeListBand Child in Band.Children)
             {
                 fTreeListBands.Add(Child);
             }
         }
         if (Band.Parent != null)
         {
             for (int i = Band.Position; i <= Band.EndPosition; i++)
             {
                 Band.Parent.SetColumn(i, Band.Parent.Columns[i]);
             }
         }
         return(this[List.Add(Band)]);
     }
     return(null);
 }
        public virtual bool TryToSwap(MyTreeListBand A, MyTreeListBand B)
        {
            if ((this != A.Parent) || (this != B.Parent))
            {
                return(false);
            }
            int Start = Math.Min(B.Position, A.Position);
            int End   = Math.Max(B.Position, A.Position);

            if (A.Position < B.Position)
            {
                B.Position = A.Position;
                A.Position = B.Position + B.Width;
            }
            else
            {
                A.Position = B.Position;
                B.Position = A.Position + A.Width;
            }
            Children.UpdateColumns();
            return(true);
        }
        public bool TryToSwapBandAndColumn(MyTreeListBand Band, TreeListColumn Column)
        {
            if ((Band == null) || (Column == null) || (Band.Parent != this))
            {
                return(false);
            }
            int ColumnPosition = -1;

            for (int i = 0; i < Width; i++)
            {
                if (Columns[i] == Column)
                {
                    ColumnPosition = i;
                }
            }
            if (ColumnPosition < 0)
            {
                return(false);
            }
            int Start = Math.Min(ColumnPosition, Band.Position);
            int End   = Math.Max(ColumnPosition, Band.Position);
            int NewColumnPosition;

            if (Band.Position < ColumnPosition)
            {
                NewColumnPosition = Band.Position;
                Band.Position     = NewColumnPosition + 1;
            }
            else
            {
                Band.Position     = ColumnPosition;
                NewColumnPosition = Band.Position + Band.Width;
            }
            Columns[NewColumnPosition] = Columns[ColumnPosition];
            Columns[ColumnPosition]    = null;
            Children.UpdateColumns();
            return(true);
        }
Esempio n. 20
0
 public virtual bool Contains(MyTreeListBand Band)
 {
     return(List.Contains(Band));
 }
Esempio n. 21
0
        public virtual MyTreeListBand Add(int Index, int Width, string Name)
        {
            MyTreeListBand Res = fRootBand.CreateChild(Index, Width, Name);

            return(Add(Res));
        }
Esempio n. 22
0
 public MyTreeListBandCollection(MyTreeList treeList)
 {
     fRootBand = new MyTreeListBand(treeList, null, 0, treeList.Columns.Count, string.Empty);
     List.Add(fRootBand);
     fTreeListBands = null;
 }
Esempio n. 23
0
 public MyTreeListBandCollection(MyTreeListBand RootBand, MyTreeListBandCollection TreeListBands)
 {
     fRootBand      = RootBand;
     fTreeListBands = TreeListBands;
 }
        public MyTreeListBand CreateChild(int Position, int ChildWidth, string ChildName)
        {
            MyTreeListBand Res = new MyTreeListBand(fTreeList, this, Position, ChildWidth, ChildName);

            return(Children.Add(Res));
        }