void drag_Completed(DragListener drag)
 {
     if (operation != null)
     {
         if (drag.IsCanceled)
         {
             operation.Abort();
         }
         else
         {
             operation.Commit();
         }
         operation = null;
     }
     else
     {
         if (drag.IsCanceled)
         {
             changeGroup.Abort();
         }
         else
         {
             changeGroup.Commit();
         }
         changeGroup = null;
     }
     _isResizing = false;
     HideSizeAndShowHandles();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes the specified components from their parent containers.
        /// If the deleted components are currently selected, they are deselected before they are deleted.
        /// </summary>
        public static void DeleteComponents(ICollection <DesignItem> items)
        {
            DesignItem         parent    = items.First().Parent;
            PlacementOperation operation = PlacementOperation.Start(items, PlacementType.Delete);

            try {
                ISelectionService selectionService = items.First().Services.Selection;
                selectionService.SetSelectedComponents(items, SelectionTypes.Remove);
                // if the selection is empty after deleting some components, select the parent of the deleted component
                if (selectionService.SelectionCount == 0 && !items.Contains(parent))
                {
                    selectionService.SetSelectedComponents(new DesignItem[] { parent });
                }
                foreach (var designItem in items)
                {
                    designItem.Name = null;
                }

                var service = parent.Services.Component as XamlComponentService;
                foreach (var item in items)
                {
                    service.RaiseComponentRemoved(item);
                }

                operation.DeleteItemsAndCommit();
            } catch {
                operation.Abort();
                throw;
            }
        }
Ejemplo n.º 3
0
 public void Cancel()
 {
     if (operation != null)
     {
         operation.Abort();
         operation = null;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Deletes the specified components from their parent containers.
        /// If the deleted components are currently selected, they are deselected before they are deleted.
        /// </summary>
        public static void DeleteComponents(ICollection <DesignItem> deleteItems)
        {
            if (deleteItems.Count > 0)
            {
                var changeGroup = deleteItems.First().OpenGroup("Delete Items");
                try
                {
                    var itemsGrpParent = deleteItems.GroupBy(x => x.Parent);
                    foreach (var itemsList in itemsGrpParent)
                    {
                        var                items     = itemsList.ToList();
                        DesignItem         parent    = items.First().Parent;
                        PlacementOperation operation = PlacementOperation.Start(items, PlacementType.Delete);
                        try
                        {
                            ISelectionService selectionService = items.First().Services.Selection;
                            selectionService.SetSelectedComponents(items, SelectionTypes.Remove);
                            // if the selection is empty after deleting some components, select the parent of the deleted component
                            if (selectionService.SelectionCount == 0 && !items.Contains(parent))
                            {
                                selectionService.SetSelectedComponents(new[] { parent });
                            }
                            foreach (var designItem in items)
                            {
                                designItem.Name = null;
                            }

                            var service = parent.Services.Component as XamlComponentService;
                            foreach (var item in items)
                            {
                                service.RaiseComponentRemoved(item);
                            }

                            operation.DeleteItemsAndCommit();
                        }
                        catch
                        {
                            operation.Abort();
                            throw;
                        }
                    }
                    changeGroup.Commit();
                }
                catch
                {
                    changeGroup.Abort();
                    throw;
                }
            }
        }
Ejemplo n.º 5
0
 protected override void OnStopped()
 {
     if (operation != null)
     {
         operation.Abort();
         operation = null;
     }
     if (changeGroup != null)
     {
         changeGroup.Abort();
         changeGroup = null;
     }
     if (services.Tool.CurrentTool is CreateComponentTool)
     {
         services.Tool.CurrentTool = services.Tool.PointerTool;
     }
     base.OnStopped();
 }