CrabUI
Loading...
Searching...
No Matches
WeakEvents.cs
1using System;
2using System.Reflection;
3using System.Runtime.CompilerServices;
4using System.Collections.Generic;
5using System.Collections.Immutable;
6using System.Linq;
7
8using Barotrauma;
9using HarmonyLib;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Graphics;
12
13using CrabUI;
14
15namespace CrabUITest
16{
17 public partial class PropTest : FillMethods
18 {
19
20 public class SomeClass
21 {
22 public event Action SomeEvent;
23 }
24
25 /// <summary>
26 /// It just demonstates the problem
27 /// idk how to solve it yet
28 /// no, i'm not gonna use other weak event managers
29 /// </summary>
30 /// <param name="Main"></param>
31 public static void WeakEvents(CUIComponent Main)
32 {
33 CUIFrame frame = new CUIFrame(0.6f, 0.2f, 0.2f, 0.6f);
34
35 bool state = false;
36
38 {
39 Absolute = new CUINullRect(100, 100, 100, 100),
40 BackgroundColor = Color.Blue,
41 };
42
43 Main.OnMouseDown += (e) =>
44 {
45 state = !state;
46 c.BackgroundColor = state ? Color.Blue : Color.Green;
47 };
48
49
50 // And just throw it away
51 //frame.Append(c);
52 Main.Append(frame);
53 }
54
55
56
57
58
59 }
60}
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.
Definition CUIFrame.cs:16
This class contains filling methods An Action<CUIComponent> that creates some GUI and attaches it t...
Testing separate props.
Definition WeakEvents.cs:18
static void WeakEvents(CUIComponent Main)
It just demonstates the problem idk how to solve it yet no, i'm not gonna use other weak event manage...
Definition WeakEvents.cs:31
Rectangle with float?
Definition CUIRect.cs:104