public IActionResult OnPost() { if (!ModelState.IsValid) { throw new Exception("Antiforgery check failed."); } InitPage(); if (ErpEntity == null) { return(NotFound()); } if (String.IsNullOrWhiteSpace(ReturnUrl)) { ReturnUrl = $"/sdk/objects/entity/r/{RecordId}/rl/fields/c/select"; } //empty html input is not posted, so we init it with string.empty if (DefaultValue == null) { DefaultValue = string.Empty; } var entMan = new EntityManager(); try { var newFieldId = Guid.NewGuid(); if (Id != null) { newFieldId = Id.Value; } var response = new FieldResponse(); InputField input = null; switch (Type) { case FieldType.AutoNumberField: { decimal defaultDecimal = 1; if (Decimal.TryParse(DefaultValue, out decimal result)) { defaultDecimal = result; } input = new InputAutoNumberField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultDecimal, StartingNumber = StartingNumber, DisplayFormat = DisplayFormat, EnableSecurity = EnableSecurity }; } break; case FieldType.CheckboxField: { bool?defaultValue = null; if (Boolean.TryParse(DefaultValue, out bool result)) { defaultValue = result; } input = new InputCheckboxField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity }; } break; case FieldType.CurrencyField: { decimal?defaultDecimal = null; if (Decimal.TryParse(DefaultValue, out decimal result)) { defaultDecimal = result; } input = new InputCurrencyField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultDecimal, EnableSecurity = EnableSecurity, MinValue = MinValue, MaxValue = MaxValue, Currency = Helpers.GetCurrencyType(CurrencyCode) }; } break; case FieldType.DateField: { DateTime?defaultValue = null; if (DateTime.TryParse(DefaultValue, out DateTime result)) { defaultValue = result; } input = new InputDateField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, Format = Format, UseCurrentTimeAsDefaultValue = UseCurrentTimeAsDefaultValue }; } break; case FieldType.DateTimeField: { DateTime?defaultValue = null; if (DateTime.TryParse(DefaultValue, out DateTime result)) { defaultValue = result; } input = new InputDateTimeField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, Format = Format, UseCurrentTimeAsDefaultValue = UseCurrentTimeAsDefaultValue }; } break; case FieldType.EmailField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputEmailField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; case FieldType.FileField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputFileField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity }; } break; case FieldType.HtmlField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputHtmlField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity }; } break; case FieldType.ImageField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputImageField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity }; } break; case FieldType.MultiLineTextField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputMultiLineTextField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; case FieldType.MultiSelectField: { var selectOptions = (SelectOptions ?? string.Empty).Split(Environment.NewLine); var defaultOptions = (DefaultValue ?? string.Empty).Split(Environment.NewLine); var multiSelectOptions = new List <SelectOption>(); var defaultValues = new List <string>(); foreach (var option in selectOptions) { if (!String.IsNullOrWhiteSpace(option)) { var optionArray = option.Split(','); var key = ""; var value = ""; var iconClass = ""; var color = ""; if (optionArray.Length > 0 && !String.IsNullOrWhiteSpace(optionArray[0])) { key = optionArray[0].Trim().ToLowerInvariant(); } if (optionArray.Length > 1 && !String.IsNullOrWhiteSpace(optionArray[1])) { value = optionArray[1].Trim(); } else if (optionArray.Length > 0 && !String.IsNullOrWhiteSpace(optionArray[0])) { value = key; } if (optionArray.Length > 2 && !String.IsNullOrWhiteSpace(optionArray[2])) { iconClass = optionArray[2].Trim(); } if (optionArray.Length > 3 && !String.IsNullOrWhiteSpace(optionArray[3])) { color = optionArray[3].Trim(); } if (!String.IsNullOrWhiteSpace(key) && !String.IsNullOrWhiteSpace(value)) { multiSelectOptions.Add(new SelectOption() { Value = key, Label = value, IconClass = iconClass, Color = color }); } } } foreach (var option in defaultOptions) { var fixedOption = option.Trim().ToLowerInvariant(); if (!String.IsNullOrWhiteSpace(option) && multiSelectOptions.Any(x => x.Value == fixedOption)) { defaultValues.Add(fixedOption); } else if (!String.IsNullOrWhiteSpace(option) && !multiSelectOptions.Any(x => x.Value == fixedOption)) { Validation.Errors.Add(new ValidationError("DefaultValue", "one or more of the default values are not found as select options")); throw Validation; } } input = new InputMultiSelectField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, EnableSecurity = EnableSecurity, Options = multiSelectOptions, DefaultValue = defaultValues }; } break; case FieldType.NumberField: { decimal?defaultDecimal = null; if (Decimal.TryParse(DefaultValue, out decimal result)) { defaultDecimal = result; } input = new InputNumberField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultDecimal, EnableSecurity = EnableSecurity, MinValue = MinValue, MaxValue = MaxValue, DecimalPlaces = DecimalPlaces }; } break; case FieldType.PasswordField: { input = new InputPasswordField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, MinLength = MinLength, Encrypted = Encrypted, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; case FieldType.PercentField: { decimal?defaultDecimal = null; if (Decimal.TryParse(DefaultValue, out decimal result)) { defaultDecimal = result; } input = new InputNumberField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultDecimal, EnableSecurity = EnableSecurity, MinValue = MinValue, MaxValue = MaxValue, DecimalPlaces = DecimalPlaces }; } break; case FieldType.PhoneField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputPhoneField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; case FieldType.GuidField: { Guid?defaultGuid = null; if (Guid.TryParse(DefaultValue, out Guid result)) { defaultGuid = result; } input = new InputGuidField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultGuid, EnableSecurity = EnableSecurity, GenerateNewId = GenerateNewId }; } break; case FieldType.SelectField: { var selectOptions = SelectOptions.Split(Environment.NewLine); var modelSelectOptions = new List <SelectOption>(); foreach (var option in selectOptions) { if (!String.IsNullOrWhiteSpace(option)) { var optionArray = option.Split(','); var key = ""; var value = ""; var iconClass = ""; var color = ""; if (optionArray.Length > 0 && !String.IsNullOrWhiteSpace(optionArray[0])) { key = optionArray[0].Trim().ToLowerInvariant(); } if (optionArray.Length > 1 && !String.IsNullOrWhiteSpace(optionArray[1])) { value = optionArray[1].Trim(); } else if (optionArray.Length > 0 && !String.IsNullOrWhiteSpace(optionArray[0])) { value = key; } if (optionArray.Length > 2 && !String.IsNullOrWhiteSpace(optionArray[2])) { iconClass = optionArray[2].Trim(); } if (optionArray.Length > 3 && !String.IsNullOrWhiteSpace(optionArray[3])) { color = optionArray[3].Trim(); } if (!String.IsNullOrWhiteSpace(key) && !String.IsNullOrWhiteSpace(value)) { modelSelectOptions.Add(new SelectOption() { Value = key, Label = value, IconClass = iconClass, Color = color }); } } } DefaultValue = DefaultValue.Trim().ToLowerInvariant(); if (!String.IsNullOrWhiteSpace(DefaultValue) && !modelSelectOptions.Any(x => x.Value == DefaultValue)) { Validation.Errors.Add(new ValidationError("DefaultValue", "one or more of the default values are not found as select options")); throw Validation; } input = new InputSelectField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = DefaultValue, EnableSecurity = EnableSecurity, Options = modelSelectOptions }; } break; case FieldType.UrlField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputUrlField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength, OpenTargetInNewWindow = OpenTargetInNewWindow }; } break; case FieldType.TextField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputTextField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; default: throw new Exception("Field Type not recognized"); } var recordPermissionsKeyValues = JsonConvert.DeserializeObject <List <KeyStringList> >(FieldPermissions); input.Permissions = new FieldPermissions(); input.Permissions.CanRead = new List <Guid>(); input.Permissions.CanUpdate = new List <Guid>(); foreach (var role in recordPermissionsKeyValues) { var roleId = Guid.Empty; if (Guid.TryParse(role.Key, out Guid result)) { roleId = result; } if (roleId != Guid.Empty) { if (role.Values.Contains("read")) { input.Permissions.CanRead.Add(roleId); } if (role.Values.Contains("update")) { input.Permissions.CanUpdate.Add(roleId); } } } response = entMan.CreateField(ErpEntity.Id, input); if (!response.Success) { var exception = new ValidationException(response.Message); exception.Errors = response.Errors.MapTo <ValidationError>(); throw exception; } // because of https://github.com/aspnet/Mvc/issues/6711, i added TempDataExtensions int // WebVella.Erp.Web.Utils and using Put and Get<> instead of // TempData["ScreenMessage"] = new ScreenMessage() { Message = "Field created successfully" }; TempData.Put("ScreenMessage", new ScreenMessage() { Message = "Field created successfully" }); return(Redirect($"/sdk/objects/entity/r/{ErpEntity.Id}/rl/fields/l")); } catch (ValidationException ex) { Validation.Message = ex.Message; Validation.Errors = ex.Errors; } catch (Exception ex) { Validation.Message = ex.Message; Validation.Errors.Add(new ValidationError("", ex.Message, isSystem: true)); } HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "fields")); ErpRequestContext.PageContext = PageContext; BeforeRender(); return(Page()); }
public SettingsUI(Game game) : base(game) { orbis = (Orbis)game; SpriteFont font = _contentManager.GetFont("DebugFont"); // Background for UI AddChild(background = new RelativeTexture(this, new SpriteDefinition(_contentManager.GetColorTexture(BACKGROUND_COLOR), new Rectangle(0, 0, 1, 1))) { Size = new Point(_game.Window.ClientBounds.Width, _game.Window.ClientBounds.Height), AnchorPosition = AnchorPosition.TopLeft, RelativePosition = new Point(0, 0), LayerDepth = 1 }); string checkBoxTexture = AudioManager.IsEnabled() ? "UI/Checkbox_Checked" : "UI/Checkbox_Unchecked"; AddChild(audioCheckbox = new Button(this, new SpriteDefinition(_contentManager.GetTexture(checkBoxTexture), new Rectangle(0, 0, 16, 16))) { AnchorPosition = AnchorPosition.Center, Size = new Point(_game.Window.ClientBounds.Width / 50, _game.Window.ClientBounds.Height / 30), RelativePosition = new Point(-_game.Window.ClientBounds.Width / 16, 60), LayerDepth = 0.3f, }); AddChild(audioCheckboxText = new RelativeText(audioCheckbox, font) { AnchorPosition = AnchorPosition.Center, RelativePosition = new Point(40, -9), Text = "Music Enabled", LayerDepth = 0.3f, }); AddChild(backButton = new Button(this, new SpriteDefinition(_contentManager.GetTexture("UI/Button_Back"), new Rectangle(0, 0, 228, 64))) { AnchorPosition = AnchorPosition.Center, Size = new Point(_game.Window.ClientBounds.Width / 8, _game.Window.ClientBounds.Height / 16), RelativePosition = new Point(-_game.Window.ClientBounds.Width / 16, (int)(_game.Window.ClientBounds.Width / 7.5)), LayerDepth = 0.3f, }); // Get the length and height of text int textLength = (int)Math.Ceiling(font.MeasureString("Civilization count: ").X); int textHeight = (int)Math.Ceiling(font.MeasureString("A").Y); // Get the width of the max amount of input int fieldWidth = (int)Math.Ceiling(font.MeasureString("99999999").X); // Add the seed input field AddChild(fog = new InputNumberField(this) { AnchorPosition = AnchorPosition.Center, Size = new Point(fieldWidth + 2, font.LineSpacing + 2), RelativePosition = new Point(-_game.Window.ClientBounds.Width / 16, 0), MaxDigits = 4, Visible = true, LayerDepth = 0.03F }); AddChild(new RelativeText(fog, font) { AnchorPosition = AnchorPosition.TopRight, RelativePosition = new Point(16, 3), Text = "Fog/Render Distance", LayerDepth = 0.3f, }); AddChild(decorationDensity = new InputNumberField(this) { AnchorPosition = AnchorPosition.Center, Size = new Point(fieldWidth + 2, font.LineSpacing + 2), RelativePosition = new Point(-_game.Window.ClientBounds.Width / 16, 30), MaxDigits = 3, Visible = true, LayerDepth = 0.03F }); AddChild(new RelativeText(decorationDensity, font) { AnchorPosition = AnchorPosition.TopRight, RelativePosition = new Point(16, 3), Text = "Vegetation density (%)", LayerDepth = 0.3f, }); // Add button click listeners game.Window.TextInput += fog.Window_TextInput; game.Window.TextInput += decorationDensity.Window_TextInput; audioCheckbox.Click += AudioCheckbox_Click; backButton.Click += BackButton_Click; }
/// <summary> /// Constructor for the menu UI /// </summary> /// <param name="game"></param> public MenuUI(Game game) : base(game) { orbis = (Orbis)game; stateManager = StateManager.GetInstance(); SpriteFont font = _contentManager.GetFont("DebugFont"); // Background for the menu AddChild(menuBackground = new RelativeTexture(this, new SpriteDefinition(_contentManager.GetColorTexture(Color.LightGray), new Rectangle(0, 0, 1, 1))) { Size = new Point(_game.Window.ClientBounds.Width, _game.Window.ClientBounds.Height), AnchorPosition = AnchorPosition.TopLeft, RelativePosition = new Point(0, 0), LayerDepth = 1, }); // The orbis logo AddChild(orbisLogo = new RelativeTexture(this, new SpriteDefinition(_contentManager.GetTexture("UI/Orbis-Icon"), new Rectangle(0, 0, 1520, 1520))) { Size = new Point(_game.Window.ClientBounds.Width / 4, _game.Window.ClientBounds.Width / 4), AnchorPosition = AnchorPosition.Center, RelativePosition = new Point(-_game.Window.ClientBounds.Width / 8, -(_game.Window.ClientBounds.Height / 2) + 50), LayerDepth = 0.5f }); // Button to open the popup menu AddChild(openPopupButton = new Button(this, new SpriteDefinition(_contentManager.GetTexture("UI/Button_Start"), new Rectangle(0, 0, 228, 64))) { AnchorPosition = AnchorPosition.Center, Size = new Point(_game.Window.ClientBounds.Width / 6, _game.Window.ClientBounds.Height / 12), RelativePosition = new Point(-_game.Window.ClientBounds.Width / 12, -_game.Window.ClientBounds.Height / 8 + 100), LayerDepth = 0.5f, Focused = true }); // Button for settings menu AddChild(settingsMenu = new Button(this, new SpriteDefinition(_contentManager.GetTexture("UI/Button_Settings"), new Rectangle(0, 0, 228, 64))) { AnchorPosition = AnchorPosition.Center, Size = new Point(_game.Window.ClientBounds.Width / 6, _game.Window.ClientBounds.Height / 12), RelativePosition = new Point(-_game.Window.ClientBounds.Width / 12, 0 + 100), LayerDepth = 0.5f, Focused = true }); // Button for exiting the game AddChild(quitButton = new Button(this, new SpriteDefinition(_contentManager.GetTexture("UI/Button_Quit"), new Rectangle(0, 0, 228, 64))) { AnchorPosition = AnchorPosition.Center, Size = new Point(_game.Window.ClientBounds.Width / 6, _game.Window.ClientBounds.Height / 12), RelativePosition = new Point(-_game.Window.ClientBounds.Width / 12, _game.Window.ClientBounds.Height / 8 + 100), LayerDepth = 0.5f, Focused = true }); // Background for the popup menu AddChild(popupBackground = new RelativeTexture(this, new SpriteDefinition(_contentManager.GetColorTexture(Color.DarkGray), new Rectangle(0, 0, 1, 1))) { Size = new Point(_game.Window.ClientBounds.Width / 3, _game.Window.ClientBounds.Height / 3 + 20), AnchorPosition = AnchorPosition.Center, RelativePosition = new Point(-_game.Window.ClientBounds.Width / 6, -(_game.Window.ClientBounds.Height / 3 + 20) / 2), LayerDepth = 0.4f, Visible = false }); // Text for the popup window AddChild(text = new RelativeText(popupBackground, font) { AnchorPosition = AnchorPosition.TopLeft, RelativePosition = new Point(10, 10), Text = "Generate a world based on the following settings:\r\n\r\nSeed:\r\n\r\nCivilization count:\r\n\r\nMap radius:\r\n\r\nMonths to simulate:", Visible = false }); // Get the length and height of text int textLength = (int)Math.Ceiling(font.MeasureString("Civilization count: ").X); int textHeight = (int)Math.Ceiling(font.MeasureString("A").Y); // Get the width of the max amount of input int fieldWidth = (int)Math.Ceiling(font.MeasureString("99999999").X); // Add the seed input field AddChild(seed = new InputNumberField(popupBackground) { AnchorPosition = AnchorPosition.TopRight, Size = new Point(fieldWidth + 2, font.LineSpacing + 2), RelativePosition = new Point(-20 - fieldWidth + 2, 43), MaxDigits = 8, Visible = false, LayerDepth = 0.03F }); // Add the civ number input field AddChild(civs = new InputNumberField(popupBackground) { AnchorPosition = AnchorPosition.TopRight, Size = new Point(fieldWidth + 2, font.LineSpacing + 2), RelativePosition = new Point(-20 - fieldWidth + 2, 83), MaxDigits = 8, Visible = false, LayerDepth = 0.03F }); // Add the radius input field AddChild(radius = new InputNumberField(popupBackground) { AnchorPosition = AnchorPosition.TopRight, Size = new Point(fieldWidth + 2, font.LineSpacing + 2), RelativePosition = new Point(-20 - fieldWidth + 2, 123), MaxDigits = 8, Visible = false, LayerDepth = 0.03F }); // Add the ticks input field AddChild(ticks = new InputNumberField(popupBackground) { AnchorPosition = AnchorPosition.TopRight, Size = new Point(fieldWidth + 2, font.LineSpacing + 2), RelativePosition = new Point(-20 - fieldWidth + 2, 163), MaxDigits = 8, Visible = false, LayerDepth = 0.03F }); // Add text input events to the input fields game.Window.TextInput += seed.Window_TextInput; game.Window.TextInput += civs.Window_TextInput; game.Window.TextInput += radius.Window_TextInput; game.Window.TextInput += ticks.Window_TextInput; // Add startbutton to the popup menu AddChild(startButton = new Button(popupBackground, new SpriteDefinition(_contentManager.GetTexture("UI/Button_Start"), new Rectangle(0, 0, 228, 64))) { AnchorPosition = AnchorPosition.BottomRight, Size = new Point(_game.Window.ClientBounds.Width / 8, _game.Window.ClientBounds.Height / 16), RelativePosition = new Point(-_game.Window.ClientBounds.Width / 8 - 10, -_game.Window.ClientBounds.Height / 16 - 10), LayerDepth = 0.3f, Focused = false, Visible = false }); // Add startbutton to the popup menu AddChild(closeButton = new Button(popupBackground, new SpriteDefinition(_contentManager.GetTexture("UI/Button_Back"), new Rectangle(0, 0, 228, 64))) { AnchorPosition = AnchorPosition.BottomLeft, Size = new Point(_game.Window.ClientBounds.Width / 8, _game.Window.ClientBounds.Height / 16), RelativePosition = new Point(10, -_game.Window.ClientBounds.Height / 16 - 10), LayerDepth = 0.3f, Focused = false, Visible = false }); // Add button click listeners startButton.Click += StartButton_Click; settingsMenu.Click += SettingsButton_Click; quitButton.Click += QuitButton_Click; openPopupButton.Click += PopupButton_Click; closeButton.Click += CloseButton_Click; }
private static void Patch20190205(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan) { #region << ***Update field*** Entity: timelog Field Name: minutes >> { var currentEntity = entMan.ReadEntity(new Guid("750153c5-1df9-408f-b856-727078a525bc")).Object; InputNumberField numberField = new InputNumberField(); numberField.Id = currentEntity.Fields.SingleOrDefault(x => x.Name == "minutes").Id; numberField.Name = "minutes"; numberField.Label = "Minutes"; numberField.PlaceholderText = null; numberField.Description = "0 will not create timelog"; numberField.HelpText = null; numberField.Required = true; numberField.Unique = false; numberField.Searchable = false; numberField.Auditable = false; numberField.System = true; numberField.DefaultValue = Decimal.Parse("0.0"); numberField.MinValue = null; numberField.MaxValue = null; numberField.DecimalPlaces = byte.Parse("0"); numberField.EnableSecurity = false; numberField.Permissions = new FieldPermissions(); numberField.Permissions.CanRead = new List <Guid>(); numberField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.UpdateField(new Guid("750153c5-1df9-408f-b856-727078a525bc"), numberField); if (!response.Success) { throw new Exception("System error 10060. Entity: timelog Field: minutes Message:" + response.Message); } } } #endregion #region << ***Create field*** Entity: task Field Name: recurrence_template >> { InputTextField textboxField = new InputTextField(); textboxField.Id = new Guid("9973acd9-86eb-41de-8c93-295b17876adb"); textboxField.Name = "recurrence_template"; textboxField.Label = "Recurrence Template"; textboxField.PlaceholderText = null; textboxField.Description = null; textboxField.HelpText = null; textboxField.Required = false; textboxField.Unique = false; textboxField.Searchable = false; textboxField.Auditable = false; textboxField.System = true; textboxField.DefaultValue = null; textboxField.MaxLength = null; textboxField.EnableSecurity = false; textboxField.Permissions = new FieldPermissions(); textboxField.Permissions.CanRead = new List <Guid>(); textboxField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("9386226e-381e-4522-b27b-fb5514d77902"), textboxField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: task Field: recurrence_template Message:" + response.Message); } } } #endregion }