Example #1
0
        private void LoadLavel(List <LavelModel> list)
        {
            var rootElement = list.Where(c => c.ParemtId == -1);

            foreach (var rootCategory in rootElement)
            {
                LavelViewModel tmp = new LavelViewModel(rootCategory);
                tmp.PropertyChanged += ItemsOnCollectionChanged1;
                LavelList.Add(tmp);
                SetChild(tmp, list);
            }
        }
Example #2
0
 public void SetChild(LavelViewModel root, IList <LavelModel> source)
 {
     for (var i = 0; i < source.Count; i++)
     {
         if (root.ID != source[i].Id && root.ID == source[i].ParemtId)
         {
             if (source[i].ParemtId != -1)
             {
                 LavelViewModel tmp = new LavelViewModel(source[i]);
                 tmp.PropertyChanged += ItemsOnCollectionChanged1;
                 root.Children.Add(tmp);
                 SetChild(tmp, source);
             }
         }
     }
 }
Example #3
0
        private int Find(int id, ObservableCollection <LavelViewModel> tmp)
        {
            if (tmp == null)
            {
                return(-1);
            }

            foreach (var tmp1 in tmp)
            {
                if (tmp1.ID == id)
                {
                    LavelModel _tmp = new LavelModel
                    {
                        Name     = "new",
                        Id       = _paramDataService.NewIndexLavel,
                        ParemtId = id
                    };

                    LavelViewModel _tmp_ = new LavelViewModel(_tmp);
                    _tmp_.PropertyChanged += ItemsOnCollectionChanged1;
                    _tmp_.IsEditMode       = true;
                    _tmp_.IsSelected       = true;
                    _tmp_.IsExpanded       = true;
                    _tmp_.IsNew            = true;
                    tmp1.Children.Add(_tmp_);
                    return(tmp1.ID);
                }
                else
                {
                    int i = Find(id, tmp1.Children);
                    if (i != -1)
                    {
                        return(i);
                    }
                }
            }

            return(-1);
        }
Example #4
0
        public Tab1Vm()
            : base("Параметры")
        {
            LavelList = new ObservableCollection <LavelViewModel>();
            ParamList = new ObservableCollection <ParamViewModel>();
            Type      = new ObservableCollection <string>();

            _paramDataService = new ParamDataService();
            _paramDataService.GetDataLevel((item, error) => { if (error != null)
                                                              {
                                                                  return;
                                                              }
                                                              LoadLavel(item); });

            Edit = new DelegateCommand <object>(arg =>
            {
                LavelViewModel tmp = LavelList.FirstOrDefault(i => i.IsSelected);
                if (tmp != null)
                {
                    tmp.IsEditMode = true;
                }
            });
        }