Exemple #1
0
 /// <summary>
 /// Raises event 'ChangeSelection'
 /// </summary>
 protected virtual void OnChangeSelection()
 {
     if (ChangeSelection != null)
     {
         ChangeSelection.Invoke(this, System.EventArgs.Empty);
     }
 }
Exemple #2
0
        private void SelectEntity(Entity sel)
        {
            var currentSelection = DocumentManager.CurrentDocument.Selection.GetSelectedObjects();
            var change           = new ChangeSelection(sel.FindAll(), currentSelection);

            DocumentManager.CurrentDocument.PerformAction("Select entity", change);
        }
Exemple #3
0
 public void UpdateSelectedItem(Items item)
 {
     if (SelectedItem != item)
     {
         SelectedItem = item;
         ChangeSelection?.Invoke(item, EventArgs.Empty);
     }
 }
Exemple #4
0
 public void ValidateSelection()
 {
     if (selectionDirty)
     {
         SelectionRange selectionRange = GetSelectionRange();
         selectionDirty = false;
         ChangeSelection?.Invoke(this, selectionRange);
     }
 }
Exemple #5
0
        /// <summary>
        /// Runs the transform on all the currently selected objects
        /// </summary>
        /// <param name="transformationName">The name of the transformation</param>
        /// <param name="transform">The transformation to apply</param>
        /// <param name="clone">True to create a clone before transforming the original.</param>
        private void ExecuteTransform(string transformationName, IUnitTransformation transform, bool clone)
        {
            if (clone)
            {
                transformationName += "-clone";
            }
            var objects = Document.Selection.GetSelectedParents().ToList();
            var name    = String.Format("{0} {1} object{2}", transformationName, objects.Count, (objects.Count == 1 ? "" : "s"));

            var cad    = new CreateEditDelete();
            var action = new ActionCollection(cad);

            if (clone)
            {
                // Copy the selection, transform it, and reselect
                var copies = ClipboardManager.CloneFlatHeirarchy(Document, Document.Selection.GetSelectedObjects()).ToList();
                foreach (var mo in copies)
                {
                    mo.Transform(transform, Document.Map.GetTransformFlags());
                    if (Chisel.Settings.Select.KeepVisgroupsWhenCloning)
                    {
                        continue;
                    }
                    foreach (var o in mo.FindAll())
                    {
                        o.Visgroups.Clear();
                    }
                }
                cad.Create(Document.Map.WorldSpawn.ID, copies);
                var sel = new ChangeSelection(copies.SelectMany(x => x.FindAll()), Document.Selection.GetSelectedObjects());
                action.Add(sel);
            }
            else //NOTE(SVK): This is Move????
            {
                // Transform the selection
                TransformFlags Flags = Document.Map.GetTransformFlags();

                cad.Edit(objects, new TransformEditOperation(transform, Flags));
            }

            // Execute the action
            Document.PerformAction(name, action);
        }
Exemple #6
0
 public void setEvent(ChangeSelection method)
 {
     Change += method;
 }