-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (51 loc) · 2.24 KB
/
Copy pathProgram.cs
File metadata and controls
55 lines (51 loc) · 2.24 KB
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
using System;
using System.Drawing;
using static SplashKitSDK.SplashKit;
using SplashKitSDK;
namespace StockApp
{
public class Program
{
private static SplashKitSDK.Color Background = RGBColor(64, 64, 64);
public static void Main(){
LoadFont("Arial","arial.ttf");
Page home = PageFactory.CreatePage("home");
Page follow = PageFactory.CreatePage("follow");
Page detail = PageFactory.CreatePage("detail");
Page wallet = PageFactory.CreatePage("wallet");
AppContext context = new AppContext();
context.SetState(new HomeState((HomePage)home,(FollowPage) follow,(DetailPage)detail));
OpenWindow("Stock App", 800, 600);
do{
ClearScreen(Background);
ProcessEvents();
// Handle input and draw the current state
context.HandleInput();
context.Update();
context.Draw();
// Check if a state transition is needed
Page_type nextState = context.GetNextState();
StockItem item = context.GetItem();
if (nextState != Page_type.home) // Transition to a new state
{
switch (nextState)
{
case Page_type.following:
context.SetState(new FollowState((FollowPage) follow,(HomePage) home,(DetailPage) detail));
break;
case Page_type.detail:
context.SetState(new DetailState((DetailPage)detail,new StockItem(item.Name, item.X, item.Y, item.High, item.Low, item.Open, item.Current,item.Quantity),(FollowPage)follow,(WalletPage)wallet));
break;
case Page_type.wallet:
context.SetState(new WalletState((WalletPage)wallet, (DetailPage)detail));
break;
}
}
else{
context.SetState(new HomeState((HomePage)home,(FollowPage) follow,(DetailPage)detail));
}
RefreshScreen();
} while (!QuitRequested());
}
}
}