public void GoToCoordinates() { using (var qf = new QuickForm("Enter Coordinates") { LabelWidth = 50, UseShortcutKeys = true } .TextBox("X", "0") .TextBox("Y", "0") .TextBox("Z", "0") .OkCancel()) { qf.ClientSize = new Size(180, qf.ClientSize.Height); if (qf.ShowDialog() != DialogResult.OK) { return; } decimal x, y, z; if (!Decimal.TryParse(qf.String("X"), out x)) { return; } if (!Decimal.TryParse(qf.String("Y"), out y)) { return; } if (!Decimal.TryParse(qf.String("Z"), out z)) { return; } var coordinate = new Coordinate(x, y, z); ViewportManager.Viewports.ForEach(vp => vp.FocusOn(coordinate)); } }
public void GoToBrushID() { using (var qf = new QuickForm("Enter Brush ID") { LabelWidth = 100, UseShortcutKeys = true } .TextBox("Brush ID") .OkCancel()) { qf.ClientSize = new Size(230, qf.ClientSize.Height); if (qf.ShowDialog() != DialogResult.OK) { return; } long id; if (!long.TryParse(qf.String("Brush ID"), out id)) { return; } var obj = _document.Map.WorldSpawn.FindByID(id); if (obj == null) { return; } // Select and go to the brush _document.PerformAction("Select brush ID " + id, new ChangeSelection(new[] { obj }, _document.Selection.GetSelectedObjects())); ViewportManager.Viewports.ForEach(x => x.FocusOn(obj.BoundingBox)); } }
private void EditHotkey(Hotkey hk) { using (var qf = new QuickForm("Enter New Hotkey") .Item(new HotkeyQuickFormItem("Hotkey", hk.HotkeyString)) .OkCancel()) { if (qf.ShowDialog() != DialogResult.OK) { return; } var key = qf.String("Hotkey"); if (String.IsNullOrWhiteSpace(key)) { return; } var conflict = _hotkeys.FirstOrDefault(x => x.HotkeyString == key && x != hk); if (conflict != null) { if (MessageBox.Show(key + " is already assigned to \"" + Hotkeys.GetHotkeyDefinition(conflict.ID) + "\".\n" + "Continue anyway?", "Conflict Detected", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } hk.HotkeyString = key; UpdateHotkeyList(); } }
private void RenameProfileButtonClicked(object sender, EventArgs e) { if (_profile == null) { return; } using (var qf = new QuickForm("Rename Build Profile").TextBox("Name", _profile.Name).OkCancel()) { if (qf.ShowDialog() == DialogResult.OK) { var name = qf.String("Name"); if (_build.Profiles.Any(x => String.Equals(name, x.Name, StringComparison.InvariantCultureIgnoreCase))) { MessageBox.Show("There is already a profile with that name, please type a unique name.", "Cannot rename profile"); name = null; } if (!String.IsNullOrWhiteSpace(name) && _profile.Name != name) { _profile.Name = name; SettingsManager.Write(); UpdateProfiles(); } } } }
public void VisgroupCreateNew() { using (var qf = new QuickForm("Create New Visgroup") { UseShortcutKeys = true }.TextBox("Name").CheckBox("Add selection to visgroup", true).OkCancel()) { if (qf.ShowDialog() != DialogResult.OK) { return; } var ids = _document.Map.Visgroups.Where(x => !x.IsAutomatic).Select(x => x.ID).ToList(); var id = Math.Max(1, ids.Any() ? ids.Max() + 1 : 1); var name = qf.String("Name"); if (String.IsNullOrWhiteSpace(name)) { name = "Visgroup " + id.ToString(); } var vg = new Visgroup { ID = id, Colour = Colour.GetRandomLightColour(), Name = name, Visible = true }; IAction action = new CreateEditDeleteVisgroups(new[] { vg }, new Visgroup[0], new Visgroup[0]); if (qf.Bool("Add selection to visgroup") && !_document.Selection.IsEmpty()) { action = new ActionCollection(action, new EditObjectVisgroups(_document.Selection.GetSelectedObjects(), new[] { id }, new int[0])); } _document.PerformAction("Create visgroup", action); } }
private void AddPropertyClicked(object sender, EventArgs e) { if (_changingClass) { return; } using (var qf = new QuickForm("Add Property") { UseShortcutKeys = true }.TextBox("Key").TextBox("Value").OkCancel()) { if (qf.ShowDialog(this) != DialogResult.OK) { return; } var name = qf.String("Key"); var newName = name; var num = 1; while (_values.Any(x => String.Equals(x.OriginalKey, newName, StringComparison.InvariantCultureIgnoreCase))) { newName = name + "#" + (num++); } _values.Add(new TableValue { Class = Class.Text, OriginalKey = newName, NewKey = newName, Value = qf.String("Value"), IsAdded = true, IsModified = true, IsRemoved = false }); PropertyValueChanged(this, newName, qf.String("Value")); } }
protected override async Task Invoke(MapDocument document, CommandParameters parameters) { using (var qf = new QuickForm(Title) { UseShortcutKeys = true }.TextBox("X", "X", "0").TextBox("Y", "Y", "0").TextBox("Z", "Z", "0").OkCancel(OK, Cancel)) { qf.ClientSize = new Size(180, qf.ClientSize.Height); if (await qf.ShowDialogAsync() != DialogResult.OK) { return; } if (!Decimal.TryParse(qf.String("X"), out var x)) { return; } if (!Decimal.TryParse(qf.String("Y"), out var y)) { return; } if (!Decimal.TryParse(qf.String("Z"), out var z)) { return; } var coordinate = new Vector3((float)x, (float)y, (float)z); var box = new Box(coordinate - (Vector3.One * 10), coordinate + (Vector3.One * 10)); await Task.WhenAll( Oy.Publish("MapDocument:Viewport:Focus3D", box), Oy.Publish("MapDocument:Viewport:Focus2D", box) ); } }
private string PromptName(string name) { var qf = new QuickForm(ProfileName) { UseShortcutKeys = true }; qf.TextBox("ProfileName", ProfileName, name); qf.OkCancel(OK, Cancel); if (qf.ShowDialog() != DialogResult.OK) { return(null); } var n = qf.String("ProfileName"); return(String.IsNullOrEmpty(n) ? null : n); }
private void SaveProfileAsButtonClicked(object sender, EventArgs e) { using (var qf = new QuickForm("Save Build Profile As...").TextBox("Name").OkCancel()) { if (qf.ShowDialog() == DialogResult.OK) { var name = qf.String("Name"); if (_build.Profiles.Any(x => String.Equals(name, x.Name, StringComparison.InvariantCultureIgnoreCase))) { MessageBox.Show("There is already a profile with that name, please type a unique name.", "Cannot create profile"); name = null; } if (!String.IsNullOrWhiteSpace(name)) { _profile = SaveAsProfile(name); UpdateProfiles(); } } } }
private void AddFavouriteFolderButtonClicked(object sender, EventArgs e) { FavouriteTextureFolder parent = null; var selected = FavouritesTree.SelectedNode; if (selected != null) { parent = selected.Tag as FavouriteTextureFolder; } var siblings = parent != null ? parent.Children : SettingsManager.FavouriteTextureFolders; using (var qf = new QuickForm("Enter Folder Name") { UseShortcutKeys = true }.TextBox("Name").OkCancel()) { if (qf.ShowDialog() != DialogResult.OK) { return; } var name = qf.String("Name"); var uniqName = name; if (String.IsNullOrWhiteSpace(name)) { return; } var counter = 1; while (siblings.Any(x => x.Name == uniqName)) { uniqName = name + "_" + counter; counter++; } siblings.Add(new FavouriteTextureFolder { Name = uniqName }); UpdateFavouritesList(); } }
protected override async Task Invoke(MapDocument document, CommandParameters parameters) { using (var qf = new QuickForm(Title) { UseShortcutKeys = true }.TextBox("ObjectID", ObjectID).OkCancel(OK, Cancel)) { qf.ClientSize = new Size(230, qf.ClientSize.Height); if (await qf.ShowDialogAsync() != DialogResult.OK) { return; } if (!long.TryParse(qf.String("ObjectID"), out var id)) { return; } var obj = document.Map.Root.FindByID(id); if (obj == null) { return; } var tran = new Transaction( new Deselect(document.Selection), new Select(obj) ); await MapDocumentOperation.Perform(document, tran); var box = obj.BoundingBox; await Task.WhenAll( Oy.Publish("MapDocument:Viewport:Focus3D", box), Oy.Publish("MapDocument:Viewport:Focus2D", box) ); } }