Example #1
0
        public SerialisableRect AddSelectionToCurrent(double top, double left, double height, double width)
        {
            SerialisableRect toAdd = new SerialisableRect(top, left, width, height);

            AnnotatedImages[imgIdx].BoundingBoxes.Add(toAdd);
            return(toAdd);
        }
 public void AddRegion(Object sender, ExecutedRoutedEventArgs e)
 {
     if ((selectangle.ActualWidth > 0) &&
         (selectangle.ActualHeight > 0))
     {
         double           scroll        = 1 / (theVM.Zoom / MainWindowVM.ZOOM_MULTIPLE);
         double           top           = Canvas.GetTop(selectangle);
         double           left          = Canvas.GetLeft(selectangle);
         double           width         = selectangle.Width * scroll;
         double           height        = selectangle.Height * scroll;
         SerialisableRect added         = images.ImgFld.AddSelectionToCurrent(top, left, height, width);
         Rectangle        prevSelection = new Rectangle();
         prevSelection.Width      = width * scroll;
         prevSelection.Height     = height * scroll;
         prevSelection.Fill       = Brushes.Blue;
         prevSelection.Opacity    = 0.3;
         prevSelection.Tag        = added;
         prevSelection.MouseDown += PrevSelection_MouseDown;
         showingSelections.Add(prevSelection);
         prevSelection.RenderTransform = theVM.ImageResize;
         cnvSelectanglePos.Children.Add(prevSelection);
         Canvas.SetLeft(prevSelection, left);
         Canvas.SetTop(prevSelection, top);
     }
 }
Example #3
0
 public void RemoveSelectionFromCurrent(SerialisableRect toGo)
 {
     if (AnnotatedImages[imgIdx].BoundingBoxes.Contains(toGo))
     {
         AnnotatedImages[imgIdx].BoundingBoxes.Remove(toGo);
     }
 }
        private void PrevSelection_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Rectangle selection = sender as Rectangle;

            if (selection == null)
            {
                throw new InvalidOperationException("This function should only be attached to rectanges");
            }
            SerialisableRect toRemove = selection.Tag as SerialisableRect;

            if (toRemove == null)
            {
                throw new InvalidOperationException("This function should only be attached to rectanges, linked to a region");
            }
            images.ImgFld.RemoveSelectionFromCurrent(toRemove);
            cnvSelectanglePos.Children.Remove(selection);
            selection = null;
        }