-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
167 lines (157 loc) · 5.31 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
using System;
using System.Text;
using System.Collections.Generic;
namespace Matrix_Calculator
{
class Program
{
static int ChoosenOne = 0;
static short MenuPosition = 0;
static int ChoosenOperation = 0;
static string MenuName = "";
static List<string> MenuInfo = new List<string>();
static bool TraceM()
{
return false;
}
static List<string> MainMenu()
{
List<string> MainMenuInfo = new List<string>();
MainMenuInfo.Add("Find trace matrix.");
MainMenuInfo.Add("Find transpose matrix.");
MainMenuInfo.Add("Find sum of two matrices.");
MainMenuInfo.Add("Find difference of two matrices.");
MainMenuInfo.Add("Find product of the two matrices.");
MainMenuInfo.Add("Find product of the matrix on number. ");
MainMenuInfo.Add("Find determinant of the matrix.");
return MainMenuInfo;
}
static List<string> MethodMenu()
{
List<string> MethodMenuInfo = new List<string>();
MethodMenuInfo.Add("Use text file");
MethodMenuInfo.Add("Use console input");
MethodMenuInfo.Add("Randomize");
return MethodMenuInfo;
}
static void InputMethod(int ChoosenOperation)
{
switch (ChoosenOperation)
{
case (0):
InputPath();
break;
case (1):
InputMatrix();
break;
case (2):
RandomMatrix();
break;
default:
break;
}
}
static void InputPath()
{
Console.WriteLine("Plz, input correct path to your file with matrix(ces)");
MenuInfo = new List<string>();
}
static void InputMatrix()
{
Console.WriteLine("Plz, input correct matrix(ces)");
MenuInfo = new List<string>();
}
static void RandomMatrix()
{
Console.WriteLine("Plz, input correct size of matrix");
MenuInfo = new List<string>();
}
static bool CheckMatrix()
{
return false;
}
static short PositionClear(short Position)
{
if (Position < 0)
return 0;
if (Position >= 2)
return 2;
return Position;
}
public static void PrintOutUpAndDown(List<string> InputList, int ChoosenOne)
{
// The loop that goes through all of the menu items.
for (int i = 0; i < InputList.Count; i++)
{
// Print all output;
if (i == ChoosenOne)
{
// HighLight the choosen one.
Console.BackgroundColor = ConsoleColor.Gray;
Console.ForegroundColor = ConsoleColor.Black;
Console.WriteLine($">>{InputList[i]}");
Console.ResetColor();
}
else
{
Console.WriteLine($" {InputList[i]}");
}
}
}
static void Main(string[] args)
{
do
{
MenuPosition = PositionClear(MenuPosition);
Console.Clear();
if (MenuPosition == 0)
{
Console.WriteLine("Main Menu");
MenuInfo = MainMenu();
}
if (MenuPosition == 1)
{
Console.WriteLine(MenuName);
MenuInfo = MethodMenu();
}
if (MenuPosition == 2)
{
InputMethod(ChoosenOperation);
}
PrintOutUpAndDown(MenuInfo, ChoosenOne);
ConsoleKeyInfo key = Console.ReadKey(true);
// Simple switch, if uparrow then decrease, downarrow then increase.
switch (key.Key)
{
case (ConsoleKey.UpArrow):
// Move cursor up.
if (ChoosenOne == 0)
ChoosenOne = MenuInfo.Count - 1;
else
ChoosenOne--;
break;
case (ConsoleKey.DownArrow):
// Move cursor down.
if (ChoosenOne == MenuInfo.Count - 1)
ChoosenOne = 0;
else
ChoosenOne++;
break;
case (ConsoleKey.RightArrow):
if (MenuPosition < 2)
{
MenuPosition += 1;
MenuName = MenuInfo[ChoosenOne];
ChoosenOperation = ChoosenOne;
ChoosenOne = 0;
}
break;
case (ConsoleKey.LeftArrow):
MenuPosition -= 1;
ChoosenOne = 0;
break;
}
} while (true);
}
}
}