private static void TitleFillUp()
        {
            System.IO.StreamReader files = new System.IO.StreamReader(@"../../CodeResources/Files.txt");
            System.IO.StreamReader dependences = new System.IO.StreamReader(@"../../CodeResources/Dependences.txt");

            SortedDictionary<string, Node> independedFolders = new SortedDictionary<string, Node>();
            independedFolders.Add("TASKS_EXPLORER\n", new Node("TASKS_EXPLORER\n"));

            while (!files.EndOfStream) {
                string file = files.ReadLine();
                independedFolders.Add(file, new Node(file));
            }

            while (!dependences.EndOfStream) {
                string inp = dependences.ReadLine();
                inp = Regex.Replace(inp, @"\s+", " ");
                inp = Regex.Replace(inp, @"\\n+", "\n");
                string[] edge = inp.Split(' ');
                independedFolders[edge[0]].children.Add(independedFolders[edge[1]]);
                independedFolders[edge[0]].children[independedFolders[edge[0]].children.Count - 1].number = independedFolders[edge[0]].children.Count - 1;
                independedFolders[edge[0]].children[independedFolders[edge[0]].children.Count - 1].parent = independedFolders[edge[0]];
            }

            folders = independedFolders["TASKS_EXPLORER\n"];

            files.Close();
            dependences.Close();
        }
Beispiel #2
0
        public static void HandleInput(ref Node folders)
        {
            if (Console.KeyAvailable) {
                ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                DFSClearFlags(folders);
                stopDFS = false;

                if (keyInfo.Key == ConsoleKey.UpArrow) {
                    DFSSelectedChange(folders, ArrowMoves.UP);
                }
                else if (keyInfo.Key == ConsoleKey.DownArrow) {
                    DFSSelectedChange(folders, ArrowMoves.DOWN);
                }
                else if (keyInfo.Key == ConsoleKey.RightArrow) {
                    DFSSelectedChange(folders, ArrowMoves.RIGHT);
                }
                else if (keyInfo.Key == ConsoleKey.LeftArrow) {
                    DFSSelectedChange(folders, ArrowMoves.LEFT);
                }
                else if (keyInfo.Key == ConsoleKey.Enter) {
                    DFSSelectedChange(folders, ArrowMoves.ENTER);
                }
                else if (keyInfo.Key == ConsoleKey.Backspace) {
                    DFSSelectedChange(folders, ArrowMoves.BACKSPACE);
                }
                else if (keyInfo.Key == ConsoleKey.Escape) {
                    StopProgram();
                }
            }
        }
Beispiel #3
0
 private static void ArrowLeft(Node current, int selected)
 {
     if (current.value != "TASKS_EXPLORER\n") {
         current.children[selected].isSelected = false;
         current.isSelected = true;
         current.SetExpanded(false);
     }
 }
 private static void DrawNode(Node current, int level)
 {
     if (current.isSelected) {
         Console.BackgroundColor = ConsoleColor.DarkGray;
     }
     Console.WriteLine(current.value.PadRight(Console.WindowWidth - 1));
     Console.ResetColor();
     foreach (var child in current.children) {
         if (child.isVisible)
             DrawNode(child, level + 1);
     }
 }
Beispiel #5
0
 private static void ArrowDown(Node current, int selected)
 {
     if (selected != current.children.Count - 1) {
         current.children [selected + 1].isSelected = true;
         current.children [selected].isSelected = false;
     } else
     if (current.parent.value != null) {
         if (current.number != current.parent.children.Count - 1) {
             current.children[selected].isSelected = false;
             current.SetExpanded(false);
             ArrowDown(current.parent, current.number);
         }
     }
 }
 private static void DrawSubtree(Node current)
 {
     Console.Clear();
     DrawNode(current, 0);
     Thread.Sleep(RENDER_DELAY);
 }
 public Node(string v)
 {
     this.value = v;
     children = new List<Node>();
     parent = new Node ();
     isExpanded = false;
     isVisible = false;
     dfsState = false;
     isSelected = false;
 }
Beispiel #8
0
 private static void ArrowRight(Node current, int selected)
 {
     if (current.children[selected].children.Count > 0) {
         current.children[selected].isSelected = false;
         current.children[selected].SetExpanded(true);
         current.children[selected].children[0].isSelected = true;
     }
 }
Beispiel #9
0
        private static void TaskLauncher(Node current, int selected)
        {
            string choise = current.children[selected].value;
            choise = Regex.Replace(choise, @"-+", "");

            General.Dispose();
            General.Initiate();

            Console.Clear();
            Console.Write("# Launching program {0}\n", choise);
            while (!General.infile.EndOfStream) {
                string cur = General.infile.ReadLine();
                Console.WriteLine(cur);
            }
            Console.Write("# Is input is fine? (Enter/Esc)");
            ConsoleKeyInfo key1 = Console.ReadKey ();
            if (key1.Key == ConsoleKey.Escape) {
                return;
            }

            Console.BackgroundColor = ConsoleColor.DarkGray;
            Console.Write("".PadRight(Console.WindowWidth));
            Console.ResetColor();

            General.Dispose();
            General.Initiate();

            switch (choise) {
                case "Task_VI_19":	Part1.Prac4_VI_19();	break;
                case "Task_VII_4":	Part1.Prac4_VII_4();	break;
                case "Task_II_17":	Part1.Prac5_II_17();	break;
                case "Task_IV_4":	Part1.Prac5_IV_4();		break;
                case "Task_V_2":	Part1.Prac5_V_2();		break;
                case "Task_II_3":	Part2.Prac6_II_3();		break;
                case "Task_IV_15":	Part3.Prac6_IV_15();	break;
                case "Task_V_6":	Part2.Prac6_V_6();		break;
                case "Task_VI_2":	Part3.Prac6_VI_2();		break;
                case "Third_Max":	Lecture.Third_Max();	break;
                default: return;
            }

            General.Dispose();
        }
Beispiel #10
0
 private static void DFSSelectedChange(Node current, ArrowMoves moved)
 {
     current.dfsState = true;
     for (int i = 0; i < current.children.Count && !stopDFS; i++) {
         if (!current.children[i].dfsState) {
             if (current.children[i].isSelected) {
                 switch (moved) {
                     case ArrowMoves.LEFT:		ArrowLeft(current, i);		break;
                     case ArrowMoves.UP:			ArrowUp(current, i);		break;
                     case ArrowMoves.DOWN:		ArrowDown(current, i);		break;
                     case ArrowMoves.RIGHT:		ArrowRight(current, i);		break;
                     case ArrowMoves.ENTER:		ButtonEnter(current, i);	break;
                     case ArrowMoves.BACKSPACE:	ArrowLeft(current, i);		break;
                     default: break;
                 }
                 stopDFS = true;
                 return;
             }
             DFSSelectedChange(current.children[i], moved);
         }
     }
 }
Beispiel #11
0
 private static void DFSClearFlags(Node current)
 {
     current.dfsState = false;
     for (int i = 0; i < current.children.Count; i++) {
         if (current.children[i].dfsState) {
             DFSClearFlags(current.children[i]);
         }
     }
 }
Beispiel #12
0
 private static void ButtonEnter(Node current, int selected)
 {
     if (current.children[selected].children.Count > 0) {
         ArrowRight(current, selected);
     }
     else {
         TaskLauncher(current, selected);
     }
 }