예제 #1
0
        public bool DeleteSelectedItem()
        {
            bool result = false;

            if (SelectedItem != null)
            {
                int maxIndex = elements.IndexOf(SelectedItem);
                if (maxIndex == 0)//запрет на удаление нулевого элемента
                {
                    return(false);
                }

                for (int i = elements.Count() - 1; i >= maxIndex; i--)
                {
                    if (!elements.Remove(elements[i]))
                    {
                        return(false);
                    }
                    else
                    {
                        result = true;
                    }
                }
                SelectedItem = null;
            }

            if (result == true)
            {
                OnPropertyChanged("DeleteSelectedItem");
            }

            return(result);
        }
 private void CanvasMain_MouseRightButtonDown_SelectLink(object sender, MouseButtonEventArgs e)
 {
     try
     {
         ManipulatorElement selectedElement = (ManipulatorElement)e.OriginalSource;
         if (selectedElement.ElementType != ManipulatorElement.elementTypes.CENTER_OF_MASS)
         {
             if (selectedElement == manipulator.SelectedItem)
             {
                 manipulator.SelectedItem = null;
             }
             else
             {
                 manipulator.SelectedItem = selectedElement;
             }
         }
     }
     catch (Exception)
     {
     }
     finally
     {
         //MessageBox.Show(e.OriginalSource.ToString());
     }
 }
        public bool DeleteLastElement()
        {
            //Нельзя удалить начальный элемент
            if (elements.Count > 1)
            {
                ManipulatorElement lastElement = elements.Last();

                if (elements.Remove(lastElement))
                {
                    OnPropertyChanged("DeleteLink");
                    return(true);
                }
            }
            return(false);
        }