Exemplo n.º 1
0
        private void BuildItems(GridTreeViewItem parentItem, GridViewData data)
        {
            GridTreeViewItem item = new GridTreeViewItem(data);

            if (parentItem.children == null)
            {
                parentItem.children = new List <TreeViewItem>();
            }
            parentItem.children.Add(item);

            if (data.IsExpand)
            {
                if (ViewModel.HasChild(data))
                {
                    foreach (var child in data.Children)
                    {
                        BuildItems(item, child);
                    }
                }
            }
            else
            {
                if (ViewModel.HasChild(data))
                {
                    item.children = TreeView.CreateChildListForCollapsedParent();
                }
            }
        }
Exemplo n.º 2
0
 public virtual GridViewData[] GetChilds(GridViewData data)
 {
     if (data.IsExpand)
     {
         return(data.Children.ToArray());
     }
     return(new GridViewData[0]);
 }
Exemplo n.º 3
0
        public GridTreeViewItem(GridViewData data)
        {
            ItemData = data;

            id          = ItemData.ID;
            depth       = ItemData.Depth;
            displayName = ItemData.DisplayName;
        }
Exemplo n.º 4
0
 public GridViewModel()
 {
     RootData = new GridViewData(string.Empty)
     {
         ID       = -1,
         Depth    = -1,
         IsExpand = true,
     };
 }
Exemplo n.º 5
0
        public void RemoveItem(SystemObject data)
        {
            GridViewData viewData = ViewModel.GetDataByUserdata(data);

            if (viewData != null)
            {
                ViewModel.RemoveData(viewData);

                Reload();
            }
        }
Exemplo n.º 6
0
 private void GetDeepChilds(GridViewData data, ref List <GridViewData> dataList, bool isIncludeSelf = false)
 {
     if (isIncludeSelf)
     {
         dataList.Add(data);
     }
     foreach (var child in data.Children)
     {
         GetDeepChilds(child, ref dataList, true);
     }
 }
Exemplo n.º 7
0
        public void AddChildData(GridViewData parentData, GridViewData childData)
        {
            parentData.IsExpand = true;
            parentData.Children.Add(childData);

            childData.Parent = parentData;
            childData.ID     = m_IDCreator.NextID;
            childData.Depth  = parentData.Depth + 1;

            m_IDToDataDic.Add(childData.ID, childData);
        }
Exemplo n.º 8
0
 protected override bool CanMultiSelect(TreeViewItem item)
 {
     if (IsMultiSelect && GetCanMultiSelect != null)
     {
         GridViewData data = ((GridTreeViewItem)item).ItemData;
         return(GetCanMultiSelect(data));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 9
0
        public void RemoveData(GridViewData data)
        {
            GridViewData parentData = data.Parent;

            parentData.Children.Remove(data);
            data.Parent = null;

            List <GridViewData> dataList = new List <GridViewData>();

            GetDeepChilds(data, ref dataList, true);

            foreach (var child in dataList)
            {
                m_IDToDataDic.Remove(child.ID);
            }
        }
Exemplo n.º 10
0
        protected override void OnDrawRowItem(Rect rect, GridViewData itemData)
        {
            Rect drawRect = rect;

            if (ShowSeparator)
            {
                drawRect.height -= SEPARATOR_LINE_HEIGHT;
            }
            EditorGUI.LabelField(drawRect, itemData.DisplayName);

            if (ShowSeparator)
            {
                drawRect.y     += drawRect.height;
                drawRect.height = SEPARATOR_LINE_HEIGHT;
                EGUI.DrawHorizontalLine(drawRect);
            }
        }
Exemplo n.º 11
0
        protected override void SelectionChanged(IList <int> selectedIds)
        {
            if (OnItemSelectedChanged != null)
            {
                GridViewData[] datas = new GridViewData[selectedIds.Count];
                for (int i = 0; i < selectedIds.Count; ++i)
                {
                    datas[i] = ViewModel.GetDataByID(selectedIds[i]);
                }

                OnItemSelectedChanged(datas);
            }
            else
            {
                base.SelectionChanged(selectedIds);
            }
        }
Exemplo n.º 12
0
        protected override float GetCustomRowHeight(int row, TreeViewItem item)
        {
            GridViewData data = ((GridTreeViewItem)item).ItemData;

            return(OnGetRowHeight != null?OnGetRowHeight(data) : base.GetCustomRowHeight(row, item));
        }
Exemplo n.º 13
0
        protected override void ContextClickedItem(int id)
        {
            GridViewData data = ViewModel.GetDataByID(id);

            OnItemContextClicked?.Invoke(data);
        }
Exemplo n.º 14
0
 protected virtual void OnDataExpand(GridViewData data)
 {
 }
Exemplo n.º 15
0
 protected virtual void OnDataCollapse(GridViewData data)
 {
 }
Exemplo n.º 16
0
 public void AddData(GridViewData data)
 {
     AddChildData(RootData, data);
 }
Exemplo n.º 17
0
 public void InsertData(int index, GridViewData data)
 {
     InsertChildData(index, RootData, data);
 }
Exemplo n.º 18
0
 protected virtual void OnItemContextClicked(GridViewData itemData)
 {
 }
Exemplo n.º 19
0
 protected virtual void OnDrawRowItem(Rect rect, GridViewData itemData)
 {
     EditorGUI.LabelField(rect, itemData.DisplayName);
 }
Exemplo n.º 20
0
 protected virtual void DrawCellItem(Rect cellRect, int index, GridViewData itemData)
 {
     EditorGUI.LabelField(cellRect, itemData.DisplayName);
 }
Exemplo n.º 21
0
 protected virtual void OnDrawColumnItem(Rect rect, int columnIndex, GridViewData columnItemData)
 {
     EditorGUI.LabelField(rect, $"{columnItemData.DisplayName}-{columnIndex}");
 }
Exemplo n.º 22
0
 protected virtual float GetRowHeight(GridViewData itemData)
 {
     return(EditorGUIUtility.singleLineHeight);
 }
Exemplo n.º 23
0
 protected override float GetRowHeight(GridViewData itemData)
 {
     return(base.GetRowHeight(itemData) + (ShowSeparator? SEPARATOR_LINE_HEIGHT : 0.0f));
 }
Exemplo n.º 24
0
 protected virtual void OnItemDoubleClicked(GridViewData itemData)
 {
 }
Exemplo n.º 25
0
 public virtual bool HasChild(GridViewData data)
 {
     return(data.Children.Count > 0);
 }