private void Sel_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (VisibilityProperties.Instance.SelectCanvasVisibility == true && Images.Instance.CurrentBitmap != null)
     {
         if (Images.Instance.SelectedBitmap == null)
         {
             rectangle.Stroke          = System.Windows.Media.Brushes.Black;
             rectangle.StrokeThickness = 1;
             VisibilityProperties.Instance.SelectRectangleVisibility = false;
             VisibilityProperties.Instance.NotifyProperties();
             SelectedPoints.PointDown = e.GetPosition(ImageOp);
             Canvas.SetZIndex(rectangle, SelectionCanvas.Children.Count);
             if (!SelectionCanvas.IsMouseCaptured)
             {
                 SelectionCanvas.CaptureMouse();
             }
             index = 1;
         }
         else
         {
             SelectedPoints.PointDown = e.GetPosition(ImageOp);
             Canvas.SetZIndex(rectangle, SelectionCanvas.Children.Count);
             VisibilityProperties.Instance.SelectRectangleVisibility = false;
             VisibilityProperties.Instance.NotifyProperties();
             Images.Instance.SelectedBitmap = null;
             Images.Instance.NotifyImages();
             index = 0;
         }
     }
 }
Exemple #2
0
 public NImageCropper()
 {
     InitializeComponent();
     //this.Unloaded += new RoutedEventHandler(UcImageCropper_Unloaded);
     selectCanvForImg            = new SelectionCanvas();
     selectCanvForImg.CropImage += new RoutedEventHandler(selectCanvForImg_CropImage);
     dragCanvasForImg            = new DragCanvas();
 }
Exemple #3
0
        public SelectionDrawer(SelectionCanvas selectionCanvas)
        {
            _selectionCanvas           = selectionCanvas;
            selectionCanvas.MouseDown += OnMouseDown;
            selectionCanvas.MouseMove += OnMouseMove;
            selectionCanvas.MouseUp   += OnMouseUp;

            PrepareOverlay();
        }
        public SelectionDrawer(SelectionCanvas selectionCanvas, MouseEvents mouseEvents)
        {
            _selectionCanvas = selectionCanvas;
            mouseEvents.MouseDown += OnMouseDown;
            mouseEvents.MouseMove += OnMouseMove;
            mouseEvents.MouseUp += OnMouseUp;

            PrepareOverlay();
        }
        public SelectionDrawer(SelectionCanvas selectionCanvas)
        {
            _selectionCanvas = selectionCanvas;
            selectionCanvas.MouseDown += OnMouseDown;
            selectionCanvas.MouseMove += OnMouseMove;
            selectionCanvas.MouseUp += OnMouseUp;

            PrepareOverlay();
        }
Exemple #6
0
        public void ShowMenu(Project project, Timer timer, Time time,
		                      TimerTimeline timertimeline, SelectionCanvas selectionCanvas)
        {
            this.timer = timer;
            this.time = time;
            this.project = project;
            this.timertimeline = timertimeline;
            this.selectionCanvas = selectionCanvas;
            delitem.Visible = project != null && timer != null;
            Popup ();
        }
 public void ShowMenu(Project project, Timer timer, Time time,
                      SelectionCanvas selectionCanvas)
 {
     this.timer           = timer;
     this.time            = time;
     this.project         = project;
     this.selectionCanvas = selectionCanvas;
     delitem.Visible      = project != null && timer != null;
     delitem.Sensitive    = project.Periods.Count > 1;
     Popup();
 }
Exemple #8
0
        private void SelectionCanvas_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _mouseDown    = true;
            _mouseDownPos = e.GetPosition(SelectionCanvas);
            SelectionCanvas.CaptureMouse();

            // Initial placement of the drag selection box.
            Canvas.SetLeft(SelectionRectangle, _mouseDownPos.X);
            Canvas.SetTop(SelectionRectangle, _mouseDownPos.Y);
            SelectionRectangle.Width  = 0;
            SelectionRectangle.Height = 0;

            // Make the drag selection box visible.
            SelectionRectangle.Visibility = Visibility.Visible;
        }
 public SubstitutionsEditor()
 {
     this.Build();
     tagger              = new LMTeamTaggerView(new WidgetWrapper(drawingarea));
     incanvas            = new SelectionCanvas(new WidgetWrapper(drawingarea2));
     outcanvas           = new SelectionCanvas(new WidgetWrapper(drawingarea3));
     inpo                = new LMPlayerView();
     outpo               = new LMPlayerView();
     inpo.ClickedEvent  += HandleClickedEvent;
     outpo.ClickedEvent += HandleClickedEvent;
     inpo.Size           = PLAYER_SIZE;
     outpo.Size          = PLAYER_SIZE;
     inpo.Center         = new Point(PLAYER_SIZE / 2, PLAYER_SIZE / 2);
     outpo.Center        = new Point(PLAYER_SIZE / 2, PLAYER_SIZE / 2);
     incanvas.AddObject(inpo);
     outcanvas.AddObject(outpo);
     drawingarea2.WidthRequest = drawingarea2.HeightRequest = PLAYER_SIZE;
     drawingarea3.WidthRequest = drawingarea3.HeightRequest = PLAYER_SIZE;
 }
Exemple #10
0
        private void SelectionCanvas_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            _mouseDown = false;
            SelectionCanvas.ReleaseMouseCapture();



            var position = SelectionRectangle.TranslatePoint(new System.Windows.Point(0, 0), SelectionCanvas);
            var top      = position.Y;
            var left     = position.X;
            var bottom   = top + SelectionRectangle.ActualHeight;
            var right    = left + SelectionRectangle.ActualWidth;

            RemoveContoursSelected(top, left, bottom, right);

            DrawContours(_contours);

            SelectionRectangle.Visibility = Visibility.Collapsed;
        }
 public SubstitutionsEditor(Window parent)
 {
     TransientFor = parent;
     this.Build ();
     tagger = new TeamTagger (new WidgetWrapper (drawingarea));
     tagger.PlayersSelectionChangedEvent += HandlePlayersSelectionChangedEvent;
     tagger.PlayersSubstitutionEvent += HandlePlayersSubstitutionEvent;
     incanvas = new SelectionCanvas (new WidgetWrapper (drawingarea2));
     outcanvas = new SelectionCanvas (new WidgetWrapper (drawingarea3));
     inpo = new SportsPlayerObject ();
     outpo = new SportsPlayerObject ();
     inpo.ClickedEvent += HandleClickedEvent;
     outpo.ClickedEvent += HandleClickedEvent;
     inpo.Size = PLAYER_SIZE;
     outpo.Size = PLAYER_SIZE;
     inpo.Center = new Point (PLAYER_SIZE / 2, PLAYER_SIZE / 2);
     outpo.Center = new Point (PLAYER_SIZE / 2, PLAYER_SIZE / 2);
     incanvas.AddObject (inpo);
     outcanvas.AddObject (outpo);
     drawingarea2.WidthRequest = drawingarea2.HeightRequest = PLAYER_SIZE;
     drawingarea3.WidthRequest = drawingarea3.HeightRequest = PLAYER_SIZE;
 }
        public void MouseMove(MouseEventArgs mouseEventArgs, SelectionCanvas foreground)
        {
            if (!_workingMagic)
            {
                return;
            }

            var lineEnd = mouseEventArgs.Location;
            var currentWorkspace = StaticHelper.GetRectangle(_start, lineEnd);

            using (var pen = new Pen(new SolidBrush(Color.Red)))
            using (var canvasGraphics = Graphics.FromImage(foreground.Canvas))
            {
                canvasGraphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                var lastWorkspaceRect = StaticHelper.Inflate(_lastWorkspace, 1);
                StaticHelper.Clear(canvasGraphics, lastWorkspaceRect);
                canvasGraphics.DrawLine(pen, _start, lineEnd);
            }

            foreground.Invalidate(StaticHelper.Inflate(StaticHelper.Contain(_lastWorkspace, currentWorkspace), 1));
            _lastWorkspace = currentWorkspace;
        }
Exemple #13
0
 public SubstitutionsEditor(Window parent)
 {
     TransientFor = parent;
     this.Build();
     tagger = new TeamTagger(new WidgetWrapper(drawingarea));
     tagger.PlayersSelectionChangedEvent += HandlePlayersSelectionChangedEvent;
     tagger.PlayersSubstitutionEvent     += HandlePlayersSubstitutionEvent;
     incanvas            = new SelectionCanvas(new WidgetWrapper(drawingarea2));
     outcanvas           = new SelectionCanvas(new WidgetWrapper(drawingarea3));
     inpo                = new PlayerObject();
     outpo               = new PlayerObject();
     inpo.ClickedEvent  += HandleClickedEvent;
     outpo.ClickedEvent += HandleClickedEvent;
     inpo.Size           = PLAYER_SIZE;
     outpo.Size          = PLAYER_SIZE;
     inpo.Position       = new Point(PLAYER_SIZE / 2, PLAYER_SIZE / 2);
     outpo.Position      = new Point(PLAYER_SIZE / 2, PLAYER_SIZE / 2);
     incanvas.AddObject(inpo);
     outcanvas.AddObject(outpo);
     drawingarea2.WidthRequest = drawingarea2.HeightRequest = PLAYER_SIZE;
     drawingarea3.WidthRequest = drawingarea3.HeightRequest = PLAYER_SIZE;
 }
 private void CanvasMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (VisibilityProperties.Instance.SelectCanvasVisibility == true && Images.Instance.CurrentBitmap != null)
     {
         if (SelectionCanvas.IsMouseCaptured)
         {
             SelectionCanvas.ReleaseMouseCapture();
         }
         double x = 0;
         double y = 0;
         SelectedPoints.PointUp = e.GetPosition(ImageOp);
         if (SelectedPoints.PointUp.X >= 0)
         {
             x = SelectedPoints.PointUp.X;
         }
         else if (SelectedPoints.PointUp.X < 0)
         {
             x = 0;
         }
         if (SelectedPoints.PointUp.Y >= 0)
         {
             y = SelectedPoints.PointUp.Y;
         }
         else if (SelectedPoints.PointUp.Y < 0)
         {
             y = 0;
         }
         SelectedPoints.PointUp    = new System.Windows.Point(x, y);
         rectangle.Stroke          = System.Windows.Media.Brushes.Blue;
         rectangle.StrokeThickness = 2;
         if (index == 1 && rectangle.ActualHeight > 0 && rectangle.ActualWidth > 0)
         {
             ImageFunction.CopySelectedAreaToBitmap((int)rectangle.ActualWidth, (int)rectangle.ActualHeight, SelectedPoints.PointUp, SelectedPoints.PointDown);
         }
         index = 0;
     }
 }
        public void MouseUp(MouseEventArgs mouseEventArgs, SelectionCanvas foreground, SelectionCanvas background)
        {
            if (!_workingMagic)
            {
                return;
            }

            var lineEnd = mouseEventArgs.Location;
            var currentWorkspace = StaticHelper.GetRectangle(_start, lineEnd);

            using (var pen = new Pen(new SolidBrush(Color.Red)))
            using (var backgroundGraphics = Graphics.FromImage(background.Canvas))
            using (var foregroundGraphics = Graphics.FromImage(foreground.Canvas))
            {
                StaticHelper.Clear(foregroundGraphics, _lastWorkspace);
                backgroundGraphics.DrawLine(pen, _start, lineEnd);
            }

            foreground.Invalidate(_lastWorkspace);
            background.Invalidate(StaticHelper.Inflate(currentWorkspace, 1));

            _lastWorkspace = new Rectangle();
            _workingMagic = false;
        }
 public void MouseUp(MouseEventArgs mouseEventArgs, SelectionCanvas foreground, SelectionCanvas background)
 {
     //nothing here, move along
 }