/// <summary> /// Получает данные о ВО из TFS и формирует список объектов оттуда. /// </summary> public void FillErtList() { ErtList = new List <Ert>(); ItemSet itemset = tools.versionControl.GetItems(String.Format(@"{0}*", SourceFolder), RecursionType.Full); // Получаем все папки кроме PictureGallery List <Item> erts = itemset.Items.Where(item => (item.ItemType == ItemType.Folder) && (!item.ServerItem.ToLower().EndsWith(".ert/picturegallery")) ).OrderBy(x => x.ServerItem).ToList(); foreach (Item item in erts) { string FullPath = item.ServerItem.Replace(SourceFolder, ""); string[] parts = FullPath.Split('/'); Ert NewErt = new Ert(); NewErt.ServerPath = item.ServerItem; NewErt.FullPath = FullPath; NewErt.Name = parts[parts.Length - 1]; NewErt.IsFolder = FullPath.ToLower().EndsWith(".ert") ? false : true; NewErt.IsAdded = false; NewErt.ParentFullPath = FullPath.Remove(FullPath.LastIndexOf(NewErt.Name)).Trim('/'); ErtList.Add(NewErt); } }
/// <summary> /// Добавляет новый каталог на основании выбранного узла /// </summary> private void NewCatalog() { string NewName = "Новый каталог"; int count = ErtList.Count(x => x.Name.Contains(NewName)); if (count >= 1) { NewName += " " + (count + 1).ToString(); } Ert NewErt = new Ert(); NewErt.Name = NewName; NewErt.IsFolder = true; NewErt.IsAdded = true; TreeNode TN = tree.SelectedNode; if (TN != null) { Ert ParentErt = (Ert)TN.Tag; NewErt.ServerPath = ParentErt.ServerPath + "/" + NewName; NewErt.FullPath = ParentErt.FullPath + "/" + NewName; NewErt.ParentFullPath = ParentErt.FullPath; } else { NewErt.FullPath = NewName; NewErt.ParentFullPath = ""; NewErt.ServerPath = SourceFolder + NewName; } ErtList.Add(NewErt); }
/// <summary> /// Возвращает индекс иконки для объекта ВО /// </summary> /// <param name="ert">Объект ВО</param> /// <returns>Индекс иконки</returns> private int GetIco(Ert ert) { int res = 0; if (ert.IsFolder) { res = 0; } else { res = 2; } return(res); }
/// <summary> /// Окончательный выбор узла /// </summary> private void SelectNode() { TreeNode TN = tree.SelectedNode; if (TN != null) { bool CanBeSelected = false; Ert ert = (Ert)TN.Tag; if ((OnlyFolders && ert.IsFolder) || (!OnlyFolders && !ert.IsFolder)) { CanBeSelected = true; } if (CanBeSelected) { SelectedItem = ert; this.DialogResult = DialogResult.OK; Close(); } } }
private void tree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { if (e.Label != null) { if (e.Label.Length > 0) { if (e.Label.IndexOfAny(new char[] { '@', '.', ',', '!' }) == -1) { e.Node.EndEdit(false); Ert ert = (Ert)e.Node.Tag; int index = ErtList.FindLastIndex(x => x.ServerPath == ert.ServerPath); Ert NewErt = ErtList[index]; NewErt.Name = e.Label; ErtList[index] = NewErt; tools.LogAdd(ErtList[index].Name, true); List <Ert> ErtForEdit = ErtList.FindAll(x => x.ServerPath.Contains(ert.ServerPath)); string ertNewServerPath = ert.ServerPath.Remove(ert.ServerPath.LastIndexOf('/')) + '/' + e.Label; for (int i = 0; i < ErtForEdit.Count; i++) { int ind = ErtList.FindLastIndex(x => x.ServerPath == ErtForEdit[i].ServerPath); Ert EditedErt = ErtList[ind]; EditedErt.ServerPath = EditedErt.ServerPath.Replace(ert.ServerPath, ertNewServerPath); ErtList[ind] = EditedErt; } ErtForEdit = ErtList.FindAll(x => x.FullPath.IndexOf(ert.FullPath) == 0); string ertNewFullPath = ert.FullPath.Remove(ert.FullPath.LastIndexOf('/')) + '/' + e.Label; for (int i = 0; i < ErtForEdit.Count; i++) { int ind = ErtList.FindLastIndex(x => x.ServerPath == ErtForEdit[i].ServerPath); Ert EditedErt = ErtList[ind]; EditedErt.FullPath = ertNewFullPath + EditedErt.FullPath.Remove(0, ert.FullPath.Length); ErtList[ind] = EditedErt; } ErtForEdit = ErtList.FindAll(x => x.ParentFullPath.IndexOf(ert.FullPath) == 0); string ertNewParentFullPath = ert.FullPath.Remove(ert.FullPath.LastIndexOf('/')) + '/' + e.Label; for (int i = 0; i < ErtForEdit.Count; i++) { int ind = ErtList.FindLastIndex(x => x.ServerPath == ErtForEdit[i].ServerPath); Ert EditedErt = ErtList[ind]; EditedErt.ParentFullPath = ertNewParentFullPath + EditedErt.ParentFullPath.Remove(0, ert.FullPath.Length); ErtList[ind] = EditedErt; } e.CancelEdit = true; RefreshTree(); TreeNode[] TNS = tree.Nodes.Find(ertNewFullPath, true); if (TNS.Length == 1) { tree.SelectedNode = TNS[0]; tree.SelectedNode.Expand(); } } else { e.CancelEdit = true; e.Node.BeginEdit(); } } else { e.CancelEdit = true; e.Node.BeginEdit(); } } }