public async void Click(Vector2 vector) { vector.Y = WindowHeight - vector.Y; Vector3 position = Models[Selector].Position; bool isHovering = PointInRectangle( new Vector2(position.X, position.Y), new Vector2(position.X + Width, position.Y), new Vector2(position.X + Width, position.Y - Height), new Vector2(position.X, position.Y - Height), vector); if (isHovering && !Models[Selector].IsHidden && State != ControlState.Clicked) { Polymono.Debug($"Button clicked: {Text}[{ID}]"); State = ControlState.Clicked; Selector = "Clicked"; try { await ExecDelegate(); } catch (Exception e) { Polymono.Error(e.Message); Polymono.ErrorF(e.StackTrace); } State = ControlState.Normal; Selector = "Default"; } }
public void LoadFromFile(string filename, Color4 colour) { try { using (StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read))) { LoadFromString(reader.ReadToEnd(), colour); } } catch (FileNotFoundException e) { Polymono.Error($"File not found: {filename + Environment.NewLine + e.ToString()}"); } catch (Exception e) { Console.WriteLine($"Error loading file: {filename + Environment.NewLine + e.ToString()}"); } }