示例#1
0
 public AdbInfoTreeUnit(MInfoType tp) : base(MInfoTypeHelper.GetInfoTypeWord(tp))
 {
     this.MInfoType = tp;
 }
        public AdbInfoesCheckedViewModel() : base(1)
        {
            var mobileInfoNode = new AdbTreeUnit(LanguageService.FindResourceString("PhoneInfoAquiredItems"));
            var mobileFileNode = new AdbTreeUnit(LanguageService.FindResourceString("PhoneFileAquiredItems"));

            Action <AdbTreeUnit, MInfoType> addInfoAct = (node, tp) => {
                //对于所有文件项,将进行的特殊处理;
                if (tp == MInfoType.AllFiles)
                {
                    var child = new AdbAllFileTreeUnit(MInfoTypeHelper.GetInfoTypeWord(tp))
                    {
                        Level = 1
                    };
                    child.IsChecked = false;
                    node.Children.Add(child);
                    child.CheckStateChanged += (sender, e) => {
                        //若选中所有文件,将其他文件进行选中处理;
                        if (e ?? false)
                        {
                            foreach (var item in node.Children)
                            {
                                if (item != child)
                                {
                                    //item.IsChecked = true;
                                    //item.IsEnabled = false;
                                }
                            }
                        }
                        else
                        {
                            foreach (var item in node.Children)
                            {
                                item.IsEnabled = true;
                            }
                        }
                    };
                }
                else
                {
                    var child = new AdbInfoTreeUnit <IInfo>(tp)
                    {
                        Level = 1
                    };
                    node.Children.Add(child);
                    child.CheckStateChanged += (sender, e) => {
                        if (e != null)
                        {
                            if (e == node.IsChecked)
                            {
                                return;
                            }
                            if (node.Children.FirstOrDefault(p => p.IsChecked != e.Value) != null)
                            {
                                node.IsChecked = null;
                            }
                            else
                            {
                                node.IsChecked = e;
                            }
                        }
                    };
                }
            };

            foreach (var tp in Enum.GetValues(typeof(MInfoType)))
            {
                if ((MInfoType)tp == MInfoType.BackUp)
                {
                    var unit = new AdbBackUpFilesTreeUnit();
                    mobileFileNode.Children.Add(unit);
                }
                else
                {
                    switch (MInfoTypeHelper.GetMInfoTypeBox((MInfoType)tp))
                    {
                    case MInfoTypeBox.AdbFile:
                        addInfoAct(mobileFileNode, (MInfoType)tp);
                        break;

                    case MInfoTypeBox.AdbInfo:
                        addInfoAct(mobileInfoNode, (MInfoType)tp);
                        break;
                    }
                }
            }

            AdbUnits.Add(mobileInfoNode);
            AdbUnits.Add(mobileFileNode);
        }
示例#3
0
 public AdbBackUpFilesTreeUnit(string relPath = null) :
     base(MInfoTypeHelper.GetInfoTypeWord(MInfoType.BackUp))
 {
     this.Direct = relPath;
     this.Level  = 1;
 }