private static void Open() { while (true) { Console.Clear(); DrawingConsole.DrawMenu.DrawMenuInstruction(MenuInstruction); DrawingConsole.DrawMenu.TryDrawMenu(DrawingConsole.DrawMenu.PresentMenu); Console.SetCursorPosition(DrawingConsole.DrawMenu.LeftPicture, DrawingConsole.DrawMenu.TopPicture); Console.Write("Enter name open file(A-Z,a-z,_): "); string intput = Console.ReadLine(); Regex regex = new Regex(@"[A-Z||a-z||_]+"); if (regex.IsMatch(intput)) { Console.CursorLeft = DrawingConsole.DrawMenu.LeftPicture; try { picture = FileWork.Read(intput); Console.Write("File open"); } catch (FileNotFoundException) { Console.Write("File Not Found"); } break; } else { Console.CursorLeft = DrawingConsole.DrawMenu.LeftPicture; Console.Write("Error input"); } } DrawPicture.DrawShapes(picture.shapes); }
private static void CreateShape() { while (true) { ClearPicture(); Console.SetCursorPosition(DrawingConsole.DrawMenu.LeftPicture, DrawingConsole.DrawMenu.TopPicture); Console.Write("How draw Shape(fill/empty): "); Console.CursorVisible = true; string input = Console.ReadLine(); if (input == "fill") { picture = DrawPicture.CreateShape <ShapeWithManySide>(picture, true, "ShapeWithManySide"); Console.CursorVisible = false; break; } else if (input == "empty") { picture = DrawPicture.CreateShape <ShapeWithManySide>(picture, false, "ShapeWithManySide"); Console.CursorVisible = false; break; } else { Console.CursorLeft = DrawingConsole.DrawMenu.LeftPicture; Console.Write("Error input"); Console.ReadKey(); } } DrawingConsole.DrawMenu.PresentInstruction = MenuInstruction; DrawPicture.DrawShapes(picture.shapes); }
private static void Save() { FileWork.Save(picture); ClearPicture(); Console.SetCursorPosition(DrawingConsole.DrawMenu.LeftPicture, DrawingConsole.DrawMenu.TopPicture); Console.Write("File save as " + picture.Name + ".json"); Console.ReadKey(); DrawPicture.DrawShapes(picture.shapes); }
public static void DrawChoose(List <Shape> shapes, int position) { Drawing.ClearPicture(); DrawPicture.DrawShapes(shapes); ConsoleColor consoleColor = Console.ForegroundColor; Console.ForegroundColor = Console.BackgroundColor; Console.BackgroundColor = consoleColor; shapes[shapes.Count - 1 - position].Draw(position); Console.ResetColor(); }
public static void DrawMenuItemSelect(Picture picture) { Console.CursorVisible = false; Drawing.ClearPicture(); DrawPicture.DrawShapes(picture.shapes); ConsoleColor consoleColor = Console.BackgroundColor; Console.BackgroundColor = Console.ForegroundColor; Console.ForegroundColor = consoleColor; Console.SetCursorPosition(2, TopPicture + PositionMenu); Console.Write(PresentMenu[PositionMenu]); Console.ResetColor(); }
private static void BackSpaceMenu() { Console.Clear(); DrawingConsole.DrawMenu.PresentInstruction = MenuInstruction; if (StackMenu.Count != 0) { DrawingConsole.DrawMenu.PresentMenu = StackMenu.Pop(); } else { DrawingConsole.DrawMenu.PresentMenu = headMenu; } DrawPicture.DrawShapes(picture.shapes); }
private static void Sort() { while (true) { ClearPicture(); Console.SetCursorPosition(DrawingConsole.DrawMenu.LeftPicture, DrawingConsole.DrawMenu.TopPicture); Console.Write("Sort by(Square/Perimeter): "); Console.CursorVisible = true; string input = Console.ReadLine(); if (input == "Square") { while (true) { Console.CursorLeft = DrawingConsole.DrawMenu.LeftPicture; Console.Write("Sort by(up/down): "); input = Console.ReadLine(); if (input == "up") { picture.shapes = picture.shapes.OrderBy(p => p.Square).ToList(); break; } else if (input == "down") { picture.shapes = picture.shapes.OrderByDescending(p => p.Square).ToList(); break; } else { Console.CursorLeft = DrawingConsole.DrawMenu.LeftPicture; Console.Write("Error input"); Console.ReadKey(); } } break; } else if (input == "Perimeter") { while (true) { Console.CursorLeft = DrawingConsole.DrawMenu.LeftPicture; Console.Write("Sort by(up/down): "); input = Console.ReadLine(); if (input == "up") { picture.shapes = picture.shapes.OrderBy(p => p.Perimeter).ToList(); break; } else if (input == "down") { picture.shapes = picture.shapes.OrderByDescending(p => p.Perimeter).ToList(); break; } else { Console.CursorLeft = DrawingConsole.DrawMenu.LeftPicture; Console.Write("Error input"); Console.ReadKey(); } } break; } else { Console.CursorLeft = DrawingConsole.DrawMenu.LeftPicture; Console.Write("Error input"); Console.ReadKey(); } } DrawingConsole.DrawMenu.PresentInstruction = MenuInstruction; DrawPicture.DrawShapes(picture.shapes); }
static void DrawMenu() { StackMenu.Push(DrawingConsole.DrawMenu.PresentMenu); DrawingConsole.DrawMenu.PresentMenu = drawMenu; DrawPicture.DrawShapes(picture.shapes); }
private static void CreateLine() { picture = DrawPicture.CreateShape <Line>(picture, false, "Line"); DrawingConsole.DrawMenu.PresentInstruction = MenuInstruction; DrawPicture.DrawShapes(picture.shapes); }
private static void DeleteDraw() { picture = ChooseDraw.ChooseDelete(picture); DrawingConsole.DrawMenu.PresentInstruction = MenuInstruction; DrawPicture.DrawShapes(picture.shapes); }