private void PasteChildrenDirs_Executed(object sender, ExecutedRoutedEventArgs e) { if (CurrentlyChosenDir.Description.FullName.Length < sorteritno.path_max_length ) { List<IEditableDirWithChildrenAndParent> CopyOfChildren = SaveAndReadElementInBinaryFile.GetDefaultInstance() .ReadFromBinaryFile<IEditableDirWithChildren>(@"C:..\..\..\TemporaryFiles\tempFile~Copy") .Children; int dirCount = 0; foreach (ChildDir childdir in CopyOfChildren) { dirCount += sorteritno.GetDirCount(childdir); } if (dirCount + sorteritno.dir_counter < sorteritno.dir_count_max) { var validate = DirValidate.GetDefaultInstance(); foreach (IEditableDirWithChildrenAndParent child in CopyOfChildren) { if (validate.IsDirExistingAsFolderAndChild(CurrentlyChosenDir, child.Description.Name)) { child.Description.Name = DirNameGenerator.GetDefaultInstance().GeneratetName_Default(CurrentlyChosenDir, 1, child.Description.Name); } child.ParentDir = CurrentlyChosenDir; } CurrentlyChosenDir.AddChildrenToChildrenList(CopyOfChildren); DirManagement.GetDefaultInstance().AutoGenerateChildrenFullName(CurrentlyChosenDir); int result = PasteFullNameControl(CurrentlyChosenDir); if (result > 0) { EMW = new ErrorMessageWindow(); EMW.SetMessage(4); EMW.ShowDialog(); } AddMemento(); sorteritno.ResetTree(ResTree, ResetHighlight, Seed, drzewo, "MW"); } else //wyswietl info o zbyt duzej ilosci dirow { EMW = new ErrorMessageWindow(); EMW.SetMessage(2); EMW.ShowDialog(); } } else { EMW = new ErrorMessageWindow(); EMW.SetMessage(3); EMW.ShowDialog(); } }
// dodaje childDir public void AddChildToChildrenList(IEditableDirWithChildrenAndParent child) { if (DirValidate.IsNameExistingInChildrenDirs(this, child.Description.Name)) { throw new InvalidOperationException($"folder named as {child.Description.Name} exist in structure"); } child.ParentDir = this; DirManagement.AutoGenerateDirFullName(child); if (DirValidate.IsfolderExisting(child.Description.FullName)) { throw new InvalidOperationException("you can't create folder that exist"); } Children.Add(child); }
//warunek sprawdzajacy czy podana sciezka istnieje/ jest poprawna public void CreateCNTW_CanExecute(object sender, CanExecuteRoutedEventArgs e) { bool flag = false; try { flag = DirValidate.GetDefaultInstance().IsfolderExisting(SeedLocation.Text); } catch (Exception) { } if (flag && StructureName.Text.Length > 0) { e.CanExecute = true; } else { e.CanExecute = false; } }
string SetGeneratedName(object check, IEditableDirWithChildren Parent) { List <string> namesInSystem = new List <string>(); // names to ignore string[] namesToIgnore = new string[AppMW.CurrentlyChosenDir.Children.Count + namesInSystem.Count]; //selecting names to ignore for (int j = 0; j < AppMW.CurrentlyChosenDir.Children.Count; j++) { namesToIgnore[j] = AppMW.CurrentlyChosenDir.Children[j].Description.Name; if (j == AppMW.CurrentlyChosenDir.Children.Count - 1 && DirValidate.GetDefaultInstance().IsfolderExisting(AppMW.CurrentlyChosenDir.Description.FullName)) { namesInSystem.CopyTo(namesToIgnore, ++j); } } if (check == Default) { return(DirNameGenerator.GetDefaultInstance().GeneratetName_Default(Parent, namesToIgnore: namesToIgnore)); } else if (check == Numbers) { return(DirNameGenerator.GetDefaultInstance().GenerateName_Number(Parent, 1, namesToIgnore: namesToIgnore)); } else if (check == NumSiPar) { return(DirNameGenerator.GetDefaultInstance().GenerateName_Number_Text_ParentName(Parent, SignTB.Text, namesToIgnore: namesToIgnore)); } else if (check == ParSiNum) { return(DirNameGenerator.GetDefaultInstance().GenerateName_ParentName_Text_Number(Parent, SignTB.Text, namesToIgnore: namesToIgnore)); } return("If you see this message - report us an error"); }
public TxtFileEditor(DirValidate dirValidate, DirRead dirReader, FileRead fileRead) { this.dirValidate = dirValidate; this.dirRead = dirReader; this.fileRead = fileRead; }
public TxtFileWriter() { this.dirValidate = DirValidate.GetDefaultInstance(); TxtFileEditor = new TxtFileEditor(this.dirValidate, DirRead.GetDefaultInstance(), FileRead.GetDefaultInstance()); }
public TxtFileWriter(DirValidate dirValidator, TxtFileEditor editor) { this.TxtFileEditor = editor; this.dirValidate = dirValidator; }
public static TxtFileWriter GetInstance(DirValidate dirValidator, TxtFileEditor editor) { return(new TxtFileWriter(dirValidator, editor));; }