public GroupEditor(EditPurpose purpose, LocalData localData, Group group = null) { InitializeComponent(); ImagePreview.Clicked += ImagePreview_Clicked; CompleteBt.Clicked += CompleteBt_Clicked; Update(purpose, localData, group); }
public UserEditor(EditPurpose purpose, LocalData localData, User user) { InitializeComponent(); ImagePreview.Clicked += Image_Clicked; CompleteBt.Clicked += UserCompleted; Update(purpose, localData, user); }
public static bool ModifyTag(IconSource source, NbtTag existing, EditPurpose purpose) { if (purpose == EditPurpose.Create) { throw new ArgumentException("Use CreateTag to create tags"); } var parent = existing.Parent; bool has_name = parent is NbtCompound; var window = new EditHexWindow(source, existing, parent, has_name, purpose); return(window.ShowDialog() == DialogResult.OK); // window modifies the tag by itself }
public void Update(EditPurpose purpose, LocalData localData, Group group = null) { _purpose = purpose; _localData = localData; if (group != null) { _oldGroup = group; TrySetImage(_oldGroup.AvatarLink); TitleEntry.Text = _oldGroup.Title; DescriptionEntry.Text = _oldGroup.Description; } }
public void Update(EditPurpose purpose, LocalData localData, User user) { _purpose = purpose; _localData = localData; if (user != null) { oldUser = user; TrySetImage(oldUser.AvatarLink); NameEntry.Text = oldUser.Name; BioEntry.Text = oldUser.Bio; } }
private EditTagWindow(IconSource source, NbtTag tag, NbtContainerTag parent, bool set_name, bool set_value, EditPurpose purpose) { InitializeComponent(); NameBox.SetTags(tag, parent); ValueBox.SetTags(tag, parent, fill_current_value: purpose != EditPurpose.Create); SettingName = set_name; if (!SettingName) { this.MinimumSize = new Size(MinimumSize.Width, MinimumSize.Height - MainTable.GetRowHeights()[0]); this.Height -= MainTable.GetRowHeights()[0]; MainTable.RowStyles[0].Height = 0; NameLabel.Visible = false; NameBox.Visible = false; } SettingValue = set_value; if (!SettingValue) { this.MinimumSize = new Size(MinimumSize.Width, MinimumSize.Height - MainTable.GetRowHeights()[1]); this.Height -= MainTable.GetRowHeights()[1]; ValueLabel.Visible = false; ValueBox.Visible = false; } if (tag.TagType == NbtTagType.String) { ValueBox.Multiline = true; ValueBox.AcceptsReturn = true; ValueBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; this.AutoSize = false; this.Width = (int)(this.Width * 1.5); this.Height = (int)(this.Height * 1.5); this.FormBorderStyle = FormBorderStyle.Sizable; WordWrapCheck.Visible = true; WordWrapCheck_CheckedChanged(this, EventArgs.Empty); } else if (NbtUtil.IsNumericType(tag.TagType)) { ValueBox.PlaceholderText = "0"; } this.Icon = NbtUtil.TagTypeImage(source, tag.TagType).Icon; if (purpose == EditPurpose.Create) { this.Text = $"Create {NbtUtil.TagTypeName(tag.TagType)} Tag"; } else if (purpose == EditPurpose.EditValue || purpose == EditPurpose.Rename) { this.Text = $"Edit {NbtUtil.TagTypeName(tag.TagType)} Tag"; } if (SettingName && (!SettingValue || purpose != EditPurpose.EditValue)) { NameBox.Select(); NameBox.SelectAll(); } else if (SettingValue) { ValueBox.Select(); ValueBox.SelectAll(); } }
private EditSnbtWindow(IconSource source, NbtTag tag, NbtContainerTag parent, bool set_name, EditPurpose purpose) { InitializeComponent(); InputBox.Size = new Size(0, 0); WorkingTag = tag; TagParent = parent; var required = RequiredType(); NameBox.SetTags(tag, parent); InputBox.RequiredType = required; SettingName = set_name; if (required is null || required.Value == NbtTagType.Compound || required.Value == NbtTagType.List) { // change multiline before height, otherwise box doesn't shrink properly when resizing down InputBox.Multiline = true; this.Width = 750; this.Height = 500; MinifyCheck.Visible = true; WordWrapCheck.Visible = true; }
private EditHexWindow(IconSource source, NbtTag tag, NbtContainerTag parent, bool set_name, EditPurpose purpose) { InitializeComponent(); TabView.Size = new Size(0, 0); WorkingTag = tag; TagParent = parent; NameBox.SetTags(tag, parent); SettingName = set_name; NameLabel.Visible = SettingName; NameBox.Visible = SettingName; Provider = ByteProviders.GetByteProvider(tag); HexBox.ByteProvider = Provider; HexBox.GroupSize = Provider.BytesPerValue; HexBox.GroupSeparatorVisible = Provider.BytesPerValue > 1; HexBox.SelectionBackColor = Constants.SelectionColor; HexBox.SelectionForeColor = HexBox.ForeColor; string tagname; if (tag is NbtList list) { tagname = NbtUtil.TagTypeName(list.ListType) + " List"; this.Icon = NbtUtil.TagTypeImage(source, list.ListType).Icon; } else { tagname = NbtUtil.TagTypeName(tag.TagType); this.Icon = NbtUtil.TagTypeImage(source, tag.TagType).Icon; } if (purpose == EditPurpose.Create) { this.Text = $"Create {tagname} Tag"; } else if (purpose == EditPurpose.EditValue || purpose == EditPurpose.Rename) { this.Text = $"Edit {tagname} Tag"; } if (SettingName && purpose != EditPurpose.EditValue) { NameBox.Select(); NameBox.SelectAll(); } else { HexBox.Select(); } }