Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
 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();
             }
         }
     }
 }
Ejemplo n.º 4
0
 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();
             }
         }
     }
 }
Ejemplo n.º 5
0
        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"));
            }
        }
Ejemplo n.º 6
0
        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(CultureInfo.InvariantCulture);

                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);
            }
        }