-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActivity.cs
executable file
·114 lines (94 loc) · 3.03 KB
/
Activity.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MonoGuiFramework
{
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Base;
using Controls;
using System;
public enum TypeNavigationActivity
{
None = 0,
Left = 1,
Right = 2,
Down = 3,
Up = 4,
Back = 5,
Last = 6
}
public class Activity : Container
{
static int countActivity = 0;
public Activity[] Navigation { get; set; } = new Activity[(int)TypeNavigationActivity.Last];
public Activity Parent { get; set; }
public int Offset { get; private set; }
public override int Width { get => GraphicsSingleton.GetInstance().GetGraphics().PreferredBackBufferWidth; }
public override int Height { get => GraphicsSingleton.GetInstance().GetGraphics().PreferredBackBufferHeight; }
public Texture2D BackgroundImage { get; set; } = null;
public Color Background { get; set; }
public virtual void ChangeActivity(bool active)
{
}
public Activity(Activity parent = null) : base(parent)
{
this.Parent = parent;
this.Name = $"Activity{countActivity}";
countActivity++;
this.Designer();
}
public override void Designer()
{
base.Designer();
}
public virtual void Update(GameTime gameTime)
{
this.UpdateBounds();
}
public override void Draw(GameTime gameTime)
{
SpriteBatch sb = GraphicsSingleton.GetInstance().GetSpriteBatch();
if (this.BackgroundImage != null)
{
sb.Begin();
sb.Draw(this.BackgroundImage, new Rectangle(0, 0, this.Width, this.Height), Color.White);
sb.End();
}
else
{
GraphicsSingleton.GetInstance().GraphicsDevice.Clear(this.Background);
}
sb.Begin();
base.Draw(gameTime);
sb.End();
}
public Region GetChild(string childName)
{
Region Find(IEnumerable<Region> src, string name)
{
foreach(Region item in src)
{
if (item == null)
continue;
if (item is Container)
{
var r = Find((item as Container).Items, name);
if (r != null)
return r;
}
else if (item.Name.Equals(name))
return item;
}
return null;
}
return Find(this.Items, childName);
}
public void Scroll(int pixel)
{
this.SetBounds((int)this.Position.Absolute.X, (int)this.Position.Absolute.Y + pixel, this.Width, this.Height);
}
}
}