private void Saving_Executed(object sender, ExecutedRoutedEventArgs e) { Button Clicked = (Button)e.Parameter; if (Clicked == SaveAsNewBtn) { string temporary = thisStructureName; NEW = new NameEditionWindow(); NEW.IsItBeingSaved = true; NEW.ShowDialog(); if (thisStructureName != temporary) { if (CurrentlyChosenDir != null) { CurrentlyChosenDir.IsMarked = false; } string filePath = @"..\..\saved\" + thisStructureName; SaveAndReadElementInBinaryFile.GetDefaultInstance().WriteToBinaryFile<IEditableDirWithChildren>(filePath, Seed); } } else if (Clicked == SaveBtn) { if (CurrentlyChosenDir != null) { CurrentlyChosenDir.IsMarked = false; } string filePath = @"..\..\saved\" + thisStructureName; SaveAndReadElementInBinaryFile.GetDefaultInstance().WriteToBinaryFile<IEditableDirWithChildren>(filePath, Seed); } if (CurrentlyChosenDir != null) { CurrentlyChosenDir.IsMarked = true; } HideAllPanels(); }
private void CopyChildrenDirs_Executed(object sender, ExecutedRoutedEventArgs e) { SaveAndReadElementInBinaryFile.GetDefaultInstance() .WriteToBinaryFile<IEditableDirWithChildren>(@"..\..\..\TemporaryFiles\tempFile~Copy", CurrentlyChosenDir); Pastebtn.Command = KGPcommands.PasteChildrenDirs; }
private void LoadLTW_Executed(object sender, ExecutedRoutedEventArgs e) { if (wayChosed == "old") { AppMW.Seed = SaveAndReadElementInBinaryFile.GetDefaultInstance().ReadFromBinaryFile <MainDir>((string)ChosenCanvas.Tag); } else if (wayChosed == "new") { for (int i = AppMW.Seed.Children.Count - 1; i >= 0; i--) { AppMW.Seed.Children.RemoveAt(i); } IEditableDirWithChildren temporary = SaveAndReadElementInBinaryFile.GetDefaultInstance().ReadFromBinaryFile <MainDir>((string)ChosenCanvas.Tag); foreach (ChildDir child in temporary.Children) { child.ParentDir = AppMW.Seed; AppMW.Seed.Children.Add(child); } } AppMW.sorteritno.ResetTree(AppMW.ResTree, AppMW.ResetHighlight, AppMW.Seed, AppMW.drzewo, "MW"); AppMW.thisStructureName = (string)ChosenCanvas.Tag.ToString().Substring(saved_path.Length); AppMW.CurrentlyChosenDir = null; this.Close(); //ostatnia linijka, zamyka okno }
private void ApplyChangesCAW_Executed(object sender, ExecutedRoutedEventArgs e) { if (AppMW.sorteritno.GetDirCount(NewSeed) + AppMW.sorteritno.dir_counter < AppMW.sorteritno.dir_count_max) { CurrentlyChosenCAW.Background = Brushes.LightGray; CurrentlyChosenDir = (IEditableDirWithChildren)CurrentlyChosenCAW.Tag; CurrentlyChosenDir.IsMarked = false; CurrentlyChosenCAW = null; CurrentlyChosenDir = null; Button ThisButton = (Button)e.Parameter; SaveAndReadElementInBinaryFile.GetDefaultInstance() .WriteToBinaryFile <IEditableDirWithChildren>(@"..\..\..\TemporaryFiles\tempFile~CopyCAW", NewSeed); List <IEditableDirWithChildrenAndParent> children = SaveAndReadElementInBinaryFile.GetDefaultInstance() .ReadFromBinaryFile <IEditableDirWithChildren>(@"C:..\..\..\TemporaryFiles\tempFile~CopyCAW") .Children; AppMW.CurrentlyChosenDir.AddChildrenToChildrenList(children); DirManagement.GetDefaultInstance().AutoGenerateChildrenFullName(AppMW.CurrentlyChosenDir); AppMW.sorteritno.scale = (float)AppMW.ZoomSlider.Value; AppMW.sorteritno.ResetTree(AppMW.ResTree, AppMW.ResetHighlight, AppMW.Seed, AppMW.drzewo, "MW"); if (ThisButton.Name == "OkBtn") { this.Close(); } AddMemento(); } }
public Memento(IEditableDirWithChildren state, Caretaker caretaker) { this.caretaker = caretaker ?? throw new ArgumentNullException("caretaker is null"); State = state ?? throw new ArgumentNullException("state is null "); FilePath = $"..\\..\\..\\TemporaryFiles\\Mementos\\{caretaker.GenerateMementoName()}"; SaveAndReadElementInBinaryFile.GetDefaultInstance().WriteToBinaryFile(FilePath, state); }
private void CopyDir_Executed(object sender, ExecutedRoutedEventArgs e) { IEditableDirWithChildrenAndParent child = new ChildDir(CurrentlyChosenDir.Description, CurrentlyChosenDir.Children); SaveAndReadElementInBinaryFile.GetDefaultInstance() .WriteToBinaryFile<IEditableDirWithChildrenAndParent>(@"..\..\..\TemporaryFiles\tempFile~Copy", child); Pastebtn.Command = KGPcommands.PasteDir; }
public IEditableDirWithChildren Restore(Memento memento) { if (memento == null) { throw new ArgumentNullException("memento is null "); } State = SaveAndReadElementInBinaryFile.GetDefaultInstance().ReadFromBinaryFile <IEditableDirWithChildren>(memento.FilePath); return(State); }
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(); } }
//funkcja podpieta do przycisku Utworz public void CreateCNTW_Executed(object sender, ExecutedRoutedEventArgs e) { AppMW.Seed = DirManagement.GetDefaultInstance().GetFolderAsNewMainDir(SeedLocation.Text); if (AppMW.Seed != null) //warunek zbey nie wypierdalalo bledu, ponizej rysowanie { AppMW.sorteritno.ResetTree(AppMW.ResTree, AppMW.ResetHighlight, AppMW.Seed, AppMW.drzewo, "MW"); } string filePath = @"..\..\saved\" + StructureName.Text; SaveAndReadElementInBinaryFile.GetDefaultInstance().WriteToBinaryFile <IEditableDirWithChildren>(filePath, AppMW.Seed); AppMW.thisStructureName = StructureName.Text; this.Close(); //ostatnia linijka - zamyka okno }
//AppMW.Seed = SaveAndReadElementInBinaryFile.GetDefaultInstance().ReadFromBinaryFile<MainDir>((string)ChosenCanvas.Tag); private void SetChosenLTW_Executed(object sender, ExecutedRoutedEventArgs e) { Button Clicked = (Button)e.Parameter; Canvas MainLayer = (Canvas)Clicked.Parent; string path = (string)MainLayer.Tag; IEditableDirWithChildren temporary = SaveAndReadElementInBinaryFile.GetDefaultInstance().ReadFromBinaryFile <MainDir>(path); foreach (ChildDir child in temporary.Children) { child.ParentDir = CurrentlyChosenDir; CurrentlyChosenDir.Children.Add(child); } AppMW.sorteritno.ResetTree(DisplayedBranchGrid, ResetHighlight, NewSeed, drzewo, "CAW"); //temporary.DeleteChildrenDirsFromList(temporary.Children); }