-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppDelegate.cs
79 lines (62 loc) · 2.69 KB
/
AppDelegate.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
using System;
using AppKit;
using SpriteKit;
using Foundation;
namespace DynamicManager {
public partial class AppDelegate : NSApplicationDelegate {
public override void DidFinishLaunching(NSNotification notification) {
var scene = SKNode.FromFile<GameScene>("GameScene");
// Set the scale mode to scale to fit the window
scene.ScaleMode = SKSceneScaleMode.AspectFill;
MyGameView.PresentScene(scene);
// SpriteKit applies additional optimizations to improve rendering performance
MyGameView.IgnoresSiblingOrder = true;
ProcessName.StringValue = "New Process";
}
public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender) {
return true;
}
partial void ConfirmMemoryInput(NSObject sender) {
if (MemorySize.StringValue.Length == 0) {
NSAlert alert = new NSAlert();
alert.MessageText = "请选择内存总容量大小。";
alert.RunModal();
} else {
GameScene.memorySize = GetIntFromString(MemorySize.StringValue);
GameScene.memoryInputConfirmed = true;
}
}
partial void ConfirmProcessInput(NSObject sender) {
GameScene.processSize = ProcessSize.IntValue;
GameScene.processInputConfirmed = true;
GameScene.processName = ProcessName.StringValue;
ProcessName.StringValue = "New Process";
if (Algorithm.StringValue.Length == 0)
Algorithm.StringValue = "最先适配算法";
GameScene.algorithm = Algorithm.StringValue == "最先适配算法" ? 0 : 1;
}
partial void GetMemorySize(Foundation.NSObject sender) {
GameScene.memorySize = GetIntFromString(MemorySize.StringValue);
}
partial void GetProcessName(NSObject sender) {
GameScene.processName = ProcessName.StringValue;
}
partial void GetProcessSize(NSObject sender) {
GameScene.processSize = ProcessSize.IntValue;
}
partial void GetAlgorithm(NSObject sender) {
GameScene.algorithm = Algorithm.StringValue == "最先适配算法" ? 0 : 1;
}
partial void TimeCheck(NSObject sender) {
ProgramStatus.InsertText(new NSString(GameScene.status), new NSRange(0, 10000));
}
// public funtions
public int GetIntFromString(string str) {
for (int i = 0; i < str.Length; i++) {
if (!char.IsNumber(str, i))
str = str.Remove(i--, 1);
}
return int.Parse(str);
}
}
}