CrabUI
Loading...
Searching...
No Matches
CrabUI.CUINullRect Struct Reference

Rectangle with float? More...

Public Member Functions

 CUINullRect (Vector2 position, Vector2 size)
 
 CUINullRect (float? x=null, float? y=null, float? w=null, float? h=null)
 
override string ToString ()
 

Static Public Member Functions

static CUINullRect Parse (string s)
 

Public Attributes

float? Left
 
float? Top
 
float? Width
 
float? Height
 

Properties

Vector2 Size [get, set]
 
Vector2 Position [get, set]
 
Vector2 Center [get]
 

Detailed Description

Rectangle with float?

Definition at line 103 of file CUIRect.cs.

Constructor & Destructor Documentation

◆ CUINullRect() [1/2]

CrabUI.CUINullRect.CUINullRect ( Vector2 position,
Vector2 size )

Definition at line 161 of file CUIRect.cs.

161: this(position.X, position.Y, size.X, size.Y) { }

◆ CUINullRect() [2/2]

CrabUI.CUINullRect.CUINullRect ( float? x = null,
float? y = null,
float? w = null,
float? h = null )

Definition at line 163 of file CUIRect.cs.

164 {
165 Left = x;
166 Top = y;
167 Width = w;
168 Height = h;
169 }

Member Function Documentation

◆ Parse()

static CUINullRect CrabUI.CUINullRect.Parse ( string s)
static

Definition at line 106 of file CUIRect.cs.

107 {
108 string content = s.Substring(
109 s.IndexOf('[') + 1,
110 s.IndexOf(']') - s.IndexOf('[') - 1
111 );
112
113 var components = content.Split(',').Select(a => a.Trim());
114
115 string sx = components.ElementAtOrDefault(0);
116 string sy = components.ElementAtOrDefault(1);
117 string sw = components.ElementAtOrDefault(2);
118 string sh = components.ElementAtOrDefault(3);
119
120 float? x = null;
121 float? y = null;
122 float? w = null;
123 float? h = null;
124
125 if (sx == null || sx == "") x = null;
126 else x = float.Parse(sx);
127
128 if (sy == null || sy == "") y = null;
129 else y = float.Parse(sy);
130
131 if (sw == null || sw == "") w = null;
132 else w = float.Parse(sw);
133
134 if (sh == null || sh == "") h = null;
135 else h = float.Parse(sh);
136
137 return new CUINullRect(x, y, w, h);
138 }

Member Data Documentation

◆ Height

float? CrabUI.CUINullRect.Height

Definition at line 143 of file CUIRect.cs.

◆ Left

float? CrabUI.CUINullRect.Left

Definition at line 140 of file CUIRect.cs.

◆ Top

float? CrabUI.CUINullRect.Top

Definition at line 141 of file CUIRect.cs.

◆ Width

float? CrabUI.CUINullRect.Width

Definition at line 142 of file CUIRect.cs.

Property Documentation

◆ Center

Vector2 CrabUI.CUINullRect.Center
get

Definition at line 156 of file CUIRect.cs.

◆ Position

Vector2 CrabUI.CUINullRect.Position
getset

Definition at line 150 of file CUIRect.cs.

151 {
152 get => new Vector2(Left ?? 0, Top ?? 0);
153 set { Left = value.X; Top = value.Y; }
154 }

◆ Size

Vector2 CrabUI.CUINullRect.Size
getset

Definition at line 145 of file CUIRect.cs.

146 {
147 get => new Vector2(Width ?? 0, Height ?? 0);
148 set { Width = value.X; Height = value.Y; }
149 }

The documentation for this struct was generated from the following file: