2using System.Collections.Generic;
4using System.Reflection;
5using System.Diagnostics;
6using System.Runtime.CompilerServices;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Input;
12using Microsoft.Xna.Framework.Graphics;
24 public class Calculator
26 public event Action<float> OnValueChange;
28 private float _value;
public float Value
34 OnValueChange?.Invoke(value);
38 public void SetDigit(
float digit)
44 public Calculator calculator;
48 calculator =
new Calculator();
66 BackgroundColor = Color.Blue,
69 mainframe[
"list"][
"Header"] = Header =
new CUIComponent()
71 BackgroundColor = Color.Green,
72 FitContent =
new CUIBool2(
false,
true),
75 mainframe[
"list"][
"ButtonGrid"] = ButtonGrid =
new CUIGrid()
77 FillEmptySpace =
new CUIBool2(
false,
true),
78 BackgroundColor = Color.Brown,
79 GridTemplateColumns =
"25% 25% 25% 25%",
80 GridTemplateRows =
"25% 25% 25% 25%",
87 calculator.OnValueChange += (value) =>
89 tb.Text = value.ToString();
92 void addNumButton(
int i,
int x,
int y)
96 GridCell =
new Point(x, y),
97 AddOnClick = (e) => calculator.SetDigit(i),
101 addNumButton(1, 0, 0);
102 addNumButton(2, 1, 0);
103 addNumButton(3, 2, 0);
104 addNumButton(4, 0, 1);
105 addNumButton(5, 1, 1);
106 addNumButton(6, 2, 1);
107 addNumButton(7, 0, 2);
108 addNumButton(8, 1, 2);
109 addNumButton(9, 2, 2);
113 GridCell =
new Point(3, 2),
118 GridCell =
new Point(3, 1),
123 GridStartCell =
new Point(2, 3),
124 GridEndCell =
new Point(3, 3),
127 FakeMain.
Append(mainframe);
130 public void Dispose()
Base class for all components.
virtual CUIComponent Append(CUIComponent child, string name=null, [CallerMemberName] string memberName="")
Adds children to the end of the list.
Draggable and resizable container for other components.
A Grid containing children in its cells.
Resizing components to it's Width and placing them sequentially.
I was trying to make a calculator But failed miserably because i have no idea how calculator works.