Exemple #1
0
 private void RedoChanges_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     // Seed = Orginator.Restore(Caretaker.GetMemento(Caretaker.CurrentMemento + 1));
     Seed = orginatorGlobal.Restore(careTakerGlobal.GetMemento(careTakerGlobal.CurrentMemento + 1));
     sorteritno.ResetTree(ResTree, ResetHighlight, Seed, drzewo, "MW");
     HideAllPanels();
 }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.Beep();
            IEditableDirWithChildren main = DirManagement.GetDefaultInstance().GetFolderAsNewMainDir(@"C:\Users\Klakier\Desktop\kociFolder\koci");

            DirManagement.GetDefaultInstance().ChangeCreatedDirSystemValue("kotek jest tutaj", main, @"C:\Users\Klakier\Downloads\Hopstarter-Soft-Scraps-Folder-Generic-Green.ico");
        }
Exemple #3
0
        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
        }
        // generuje nazwę wg. prefix_sufix nie sprawdza istnienia folderu w systemie sprawdza istnienie w rodzicu
        public string GeneratetName_Default(IEditableDirWithChildren parentDir, int sufix_minValue = 0, string prefix = const_defaultPrefixForGeneratingNames, params string[] namesToIgnore)
        {
            prefix    = prefix ?? throw new ArgumentNullException("text string is null ");
            parentDir = parentDir ?? throw new ArgumentNullException("parentDir is null ");

            List <string> reservedNames   = new List <string>(namesToIgnore);
            List <int>    reservedNumbers = new List <int>();

            //  inicjalizacja danych
            // dodaje foldery pod ścieżką katalogu rodzica do ignorowanych
            if (dirValidate.IsfolderExisting(parentDir.Description.FullName))
            {
                reservedNames.AddRange(dirRead.GetChildrenNames(parentDir.Description.FullName));
            }


            // sprawdza czy dana nazwa istnieje jako dziecko w dirze nadrzędnym
            foreach (IEditableDirWithChildrenAndParent children in parentDir.Children)
            {
                reservedNames.Add(children.Description.Name);
            }
            // wycina numery z nazwy

            foreach (var name in reservedNames)
            {
                if (name.Contains(prefix + '_'))
                {
                    int    indexOfDash    = name.LastIndexOf('_');
                    string numberAsString = name.Substring(++indexOfDash);
                    reservedNumbers.Add(Convert.ToInt32(numberAsString));
                }
            }
            return($"{prefix}_{GetNextNumber(reservedNumbers, sufix_minValue)}");
        }
Exemple #5
0
        private void DeleteDir_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Button Clicked = (Button)e.Parameter;
            IEditableDirWithChildrenAndParent Target = (IEditableDirWithChildrenAndParent)CurrentlyChosenDir;

            if (Clicked.Name == "DeleteMiddlebtn")
            {
                List<IEditableDirWithChildrenAndParent> TemporaryList = new List<IEditableDirWithChildrenAndParent>();
                for (int i = Target.ParentDir.Children.Count - 1; i > Target.ParentDir.Children.IndexOf(Target); i--)
                {
                    IEditableDirWithChildrenAndParent child = Target.ParentDir.Children[i];
                    if (Target.ParentDir.Children.IndexOf(child) > Target.ParentDir.Children.IndexOf(Target))
                    {
                        TemporaryList.Insert(TemporaryList.Count, child);
                        Target.ParentDir.DeleteChildDirFromList(child);
                    }
                }
                foreach (IEditableDirWithChildrenAndParent child in Target.Children)
                {
                    child.ParentDir = Target.ParentDir;
                    Target.ParentDir.AddChildToChildrenList(child);
                }
                Target.ParentDir.AddChildrenToChildrenList(TemporaryList);
            }
            Target.ParentDir.DeleteChildDirFromList(Target);

            CurrentlyChosen = null;
            CurrentlyChosenDir = null;
            AddMemento();
            sorteritno.ResetTree(ResTree, ResetHighlight, Seed, drzewo, "MW");
        }
Exemple #6
0
        public void SetUp()
        {
            var desc = new DirDescription("kot1\\ kot", "kot");

            parent           = new MainDir(desc);
            defaultGenerator = DirNameGenerator.GetDefaultInstance();
        }
        // generuje nazwę wg. Number_Text_ParentName sprawdza istnienie folderu w systemie i rodzicu
        public string GenerateName_Number_Text_ParentName(IEditableDirWithChildren parentDir, string text, int prefix = 0, char sign = '_', params string[] namesToIgnore)
        {
            if (parentDir == null)
            {
                throw new ArgumentNullException("parentDir is null ");
            }

            foreach (string name in namesToIgnore)
            {
                if (name.Equals($"{prefix}{sign}{text}{sign}{parentDir.Description.Name}"))
                {
                    GenerateName_ParentName_Text_Number(parentDir, text, ++prefix, sign);
                }
            }
            if (dirValidate.IsfolderExisting(parentDir.Description.FullName))
            {
                string[] existingFolders = dirRead.GetChildrenNames(parentDir.Description.FullName);
                foreach (string name in existingFolders)
                {
                    if (name.Equals($"{prefix}{sign}{text}{sign}{parentDir.Description.Name}"))
                    {
                        GenerateName_ParentName_Text_Number(parentDir, text, ++prefix, sign);
                    }
                }
            }
            foreach (var child in parentDir.Children)
            {
                if (child.Description.Name.Equals($"{prefix}{sign}{text}{sign}{parentDir.Description.Name}"))
                {
                    GenerateName_ParentName_Text_Number(parentDir, text, ++prefix, sign);
                }
            }
            dirValidate.IsNameExistingInChildrenDirs(parentDir, $"{prefix}{sign}{text}{sign}{parentDir.Description.Name}");
            return($"{prefix}{sign}{text}{sign}{parentDir.Description.Name}");
        }
Exemple #8
0
        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();
            }
        }
Exemple #9
0
        public Canvas AddReferenceOfFound(IEditableDirWithChildren folderFound)
        {
            Canvas MainLayer = new Canvas();
            MainLayer.Height = 30;

            TextBlock DisplayedName = new TextBlock();
            DisplayedName.Text = folderFound.Description.Name;
            DisplayedName.Foreground = EdycjaDrzewaTextBlock.Foreground;
            DisplayedName.FontSize = 20;
            MainLayer.Children.Add(DisplayedName);

            Button Clicker = new Button();
            //Thickness thickness = new Thickness(0);
            //thickness.Right = -500;
            //Clicker.Margin = thickness;
            Clicker.Opacity = 0.2f;
            Clicker.Width = 280;
            Clicker.Height = 30;
            Clicker.Command = KGPcommands.HighlightFoundAndChosen;
            Clicker.CommandParameter = Clicker;
            MainLayer.Children.Add(Clicker);

            MainLayer.Tag = (object)folderFound;
            return MainLayer;
        }
Exemple #10
0
 public ChildDir(IMutableSystemObjectDescription description, IEditableDirWithChildren mainDir) : base(description)
 {
     if (mainDir == null)
     {
         throw new ArgumentNullException("one or more arguments are null");
     }
     this.ParentDir = mainDir;
 }
Exemple #11
0
        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);
        }
Exemple #12
0
        public ChildDir(string Name, IEditableDirWithChildren mainDir)
        {
            this.ParentDir = mainDir;
            DirDescription dirDescription = new DirDescription(
                name: Name,
                fullName: $"{mainDir.Description.FullName}\\{Name}"
                );

            Description = dirDescription;
        }
Exemple #13
0
 private void ResetHighlight_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (CurrentlyChosenCAW != null)
     {
         CurrentlyChosenCAW.Background = Brushes.LightGray;
         CurrentlyChosenDir            = (IEditableDirWithChildren)CurrentlyChosenCAW.Tag;
         CurrentlyChosenDir.IsMarked   = false;
         CurrentlyChosenCAW            = null;
         CurrentlyChosenDir            = null;
     }
 }
        public IEditableDirWithChildren Restore(Memento memento)
        {
            if (memento == null)
            {
                throw new ArgumentNullException("memento is null ");
            }

            State = SaveAndReadElementInBinaryFile.GetDefaultInstance().ReadFromBinaryFile <IEditableDirWithChildren>(memento.FilePath);

            return(State);
        }
Exemple #15
0
 private void ViewContent_CanExecute(object sender, CanExecuteRoutedEventArgs e)
 {
     Button ViewContentButton = (Button)e.Parameter;
     Canvas MainLayer = (Canvas)ViewContentButton.Parent;
     IEditableDirWithChildren FolderContained = (IEditableDirWithChildren)MainLayer.Tag;
     if (FolderContained.Children.Count == 0)
     {
         e.CanExecute = false;
     }
     else
     {
         e.CanExecute = true;
     }
 }
Exemple #16
0
 private void FindAllFolders(IEditableDirWithChildren CheckedDir, List<IEditableDirWithChildren> FList, string searched)
 {
     if (CheckedDir.Description.Name.ToUpper().Contains(searched.ToUpper()))
     {
         FList.Add(CheckedDir);
     }
     if (CheckedDir.Children.Count != 0)
     {
         foreach (IEditableDirWithChildren child in CheckedDir.Children)
         {
             FindAllFolders(child, FList, searched);
         }
     }
 }
Exemple #17
0
        //sprawdza czy istnieje dany dir jako dziecko
        /// <summary>
        /// checks if the ParrentDir contains dir with the given name
        /// </summary>
        /// <param name="ParentDir"></param>
        /// <param name="name"></param>
        /// <returns>returns true if ParentDir conains given name</returns>
        public bool IsNameExistingInChildrenDirs(IEditableDirWithChildren parent, string name)
        {
            IfNullOrWhitespaceThrowException(name);
            IfNullThrowException(parent);


            foreach (var child in parent.Children)
            {
                if (child.Description.Name.Equals(name))
                {
                    return(true);
                }
            }
            return(false);
        }
        public List <string> GetMainDirChildrenNamesAndAddStringWithNote(IEditableDirWithChildren mainDir)
        {
            if (mainDir == null)
            {
                throw new ArgumentNullException("mainDir is null");
            }
            List <string> childrenNamesWithDateAndString = new List <string>();

            foreach (string fullName in dirRead.GetAllChildrenFullNames(mainDir.Description.FullName))
            {
                childrenNamesWithDateAndString.Add(fullName + " => " + FindDescription(fullName));
            }

            return(childrenNamesWithDateAndString);
        }
Exemple #19
0
 private void ViewContent_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     Button ViewContentButton = (Button)e.Parameter;
     Canvas MainLayer = (Canvas)ViewContentButton.Parent;
     IEditableDirWithChildren FolderContained = (IEditableDirWithChildren)MainLayer.Tag;
     if (FolderContained.ShowContent)
     {
         FolderContained.ShowContent = false;
     }
     else
     {
         FolderContained.ShowContent = true;
     }
     AddMemento();
     sorteritno.ResetTree(ResTree, ResetHighlight, Seed, drzewo, "MW");
 }
Exemple #20
0
        private void ViewContent_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Button ViewContentButton = (Button)e.Parameter;
            Canvas MainLayer         = (Canvas)ViewContentButton.Parent;
            IEditableDirWithChildren FolderContained = (IEditableDirWithChildren)MainLayer.Tag;

            if (FolderContained.ShowContent)
            {
                FolderContained.ShowContent = false;
            }
            else
            {
                FolderContained.ShowContent = true;
            }
            AppMW.sorteritno.ResetTree(DisplayedBranchGrid, ResetHighlight, NewSeed, drzewo, "CAW");
        }
Exemple #21
0
        private void ResetHighlight_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if(CurrentlyChosen != null)
            {
                CurrentlyChosen.Background = Brushes.LightGray;
                CurrentlyChosenDir = (IEditableDirWithChildren)CurrentlyChosen.Tag;
                CurrentlyChosenDir.IsMarked = false;
                CurrentlyChosen = null;
                CurrentlyChosenDir = null;
            }
            if (FolderSearchTB.Text.Length == 0)
            {
                FoundFoldersSV.Visibility = Visibility.Collapsed;
            }
            HideAllPanels();

        }
Exemple #22
0
        private void HighlightChosen_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Button HiddenButton = (Button)e.Parameter;
            Canvas MainLayer    = (Canvas)HiddenButton.Parent;

            if (CurrentlyChosenCAW != null)
            {
                CurrentlyChosenCAW.Background = Brushes.LightGray;
                CurrentlyChosenDir            = (IEditableDirWithChildren)CurrentlyChosenCAW.Tag;
                CurrentlyChosenDir.IsMarked   = false;
            }
            MainLayer.Background = Brushes.Blue;
            CurrentlyChosenCAW   = MainLayer;

            CurrentlyChosenDir          = (IEditableDirWithChildren)CurrentlyChosenCAW.Tag;
            CurrentlyChosenDir.IsMarked = true;
        }
        private List <string> GetMainDirChildrenNamesAndAddDateAndNote(IEditableDirWithChildren mainDir, List <string> childrenNamesWithDateAndString)
        {
            if (mainDir == null)
            {
                throw new ArgumentNullException("mainDir is null");
            }
            foreach (var child in mainDir.Children)
            {
                childrenNamesWithDateAndString.Add(child.Description.FullName + " => " + FindDescription(child.Description.FullName));
                if (child.Children.Count > 0)
                {
                    GetMainDirChildrenNamesAndAddDateAndNote(child, childrenNamesWithDateAndString);
                }
            }

            return(childrenNamesWithDateAndString);
        }
Exemple #24
0
        /// <summary>
        /// Checks if the dir exist in AllCreatedDirs
        /// </summary>
        /// <param name="dir">dir to check</param>
        /// <returns>returns true if the folder exist</returns>
        public bool ReturnTrueIfDirExistInAllCreatedDirs(IEditableDirWithChildren dir)
        {
            if (dir == null)
            {
                throw new ArgumentNullException("dir is null ");
            }
            bool flag = false;

            foreach (IEditableDirWithChildren childDir in AllCreatedDirs)
            {
                if (childDir.Description.FullName.Equals(dir.Description.FullName))
                {
                    flag = true;
                }
            }
            return(flag);
        }
Exemple #25
0
        //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);
        }
Exemple #26
0
        //sprawdza czy istnieje dany dir jako dziecko i folder
        /// <summary>
        /// Checks, if the ParrentDir contains dir with the given name and that the dir exist in file system
        /// </summary>
        /// <param name="ParentDir">Dir Parent</param>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool IsDirExistingAsFolderAndChild(IEditableDirWithChildren ParentDir, string name)
        {
            IfNullOrWhitespaceThrowException(name);
            IfNullThrowException(ParentDir);

            if (IsNameExistingInChildrenDirs(ParentDir, name))
            {
                return(true);
            }
            if (IsfolderExisting($"{ParentDir.Description.FullName}\\{name}"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #27
0
 public void AutoGenerateChildrenFullName(IEditableDirWithChildren dir)
 {
     if (dir == null)
     {
         throw new ArgumentNullException("dir is null");
     }
     foreach (IEditableDirWithChildrenAndParent childDir in dir.Children)
     {
         AutoGenerateDirFullName(childDir);
         if (childDir.Children.Count > 0)
         {
             AutoGenerateChildrenFullName(childDir);
         }
         else
         {
             continue;
         }
     }
 }
Exemple #28
0
        private void HighlightFoundAndChosen_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Button Clicked = (Button)e.Parameter;
            Canvas Layer = (Canvas)Clicked.Parent;
            IEditableDirWithChildren Searched = (IEditableDirWithChildren)Layer.Tag;

            if (CurrentlyChosen != null)
            {

                CurrentlyChosen.Background = Brushes.LightGray;
                CurrentlyChosenDir = (IEditableDirWithChildren)CurrentlyChosen.Tag;
                CurrentlyChosenDir.IsMarked = false;

            }

            CurrentlyChosenDir = (IEditableDirWithChildren)Layer.Tag;
            CurrentlyChosenDir.IsMarked = true;
            sorteritno.ResetTree(ResTree, ResetHighlight, Seed, drzewo, "MW");
            HideAllPanels();
        }
Exemple #29
0
        /// <summary>
        /// Initialize AllCreatedDirs with dir children
        /// </summary>
        /// <param name="dir"></param>
        public void InitializeAllChildren(IEditableDirWithChildren dir)
        {
            if (dir == null)
            {
                throw new ArgumentNullException("dir is null ");
            }

            foreach (IEditableDirWithChildrenAndParent childDir in dir.Children)
            {
                MemoryDirs.AllCreatedDirs.Add(childDir);
                if (childDir.Children.Count > 0)
                {
                    InitializeAllChildren(childDir);
                }
                else
                {
                    continue;
                }
            }
        }
Exemple #30
0
        private void HighlightChosen_Executed(object sender, ExecutedRoutedEventArgs e)
        {

            Button HiddenButton = (Button)e.Parameter;
            Canvas MainLayer = (Canvas)HiddenButton.Parent;
            if(CurrentlyChosen != null )
            {

                CurrentlyChosen.Background = Brushes.LightGray;
                CurrentlyChosenDir = (IEditableDirWithChildren)CurrentlyChosen.Tag;
                CurrentlyChosenDir.IsMarked = false;

            }
            MainLayer.Background = Brushes.Blue;
            CurrentlyChosen = MainLayer;
            CurrentlyChosenDir = (IEditableDirWithChildren)CurrentlyChosen.Tag;
            CurrentlyChosenDir.IsMarked = true;
            HideAllPanels();
            FolderSearchTB.Text = CurrentlyChosenDir.Description.FullName.Length.ToString();
        }