Exemplo n.º 1
0
        private void Image_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (!is_mouse_in)
            {
                return;
            }
            Point mouse_position = e.GetPosition(image);

            mouse_position.X /= image.ActualWidth;
            mouse_position.Y /= image.ActualHeight;
            selected_x        = mouse_position.X * image_width;
            selected_y        = mouse_position.Y * image_height;
            //LogPanel.Log(mouse_position.ToString());
            try
            {
                if (points == null)
                {
                    LogPanel.Log("no points selected.");
                }
                ImagePoint nearest_point = points[0];
                foreach (var p in points)
                {
                    if (Math.Pow(p.x - selected_x, 2) + Math.Pow(p.y - selected_y, 2) < Math.Pow(nearest_point.x - selected_x, 2) + Math.Pow(nearest_point.y - selected_y, 2))
                    {
                        nearest_point = p;
                    }
                }
                selected_x = nearest_point.x;
                selected_y = nearest_point.y;
                LogPanel.Log($"selected: x = {nearest_point.x}, y = {nearest_point.y}, importance = {nearest_point.importance}.");
                PointSelected?.Invoke(nearest_point);
            }
            finally { DrawDashLines(); }
        }
        private void View_MouseDown(object sender, MouseButtonEventArgs e)
        {
            ColumnView view = (ColumnView)sender;
            int        idx  = Grid.GetColumn(view);

            var position = e.GetPosition(ColumnsGrid);

            PointSelected?.Invoke(this, new PointSelectedEventArgs(idx, position.Y));
        }
 private void ColumnHoldTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         int idx = Grid.GetColumn(touchedView);
         PointSelected?.Invoke(this, new PointSelectedEventArgs(idx, touchPoint.Y));
     }));
     if (columnHoldTimer != null)
     {
         columnHoldTimer.Elapsed -= ColumnHoldTimer_Elapsed;
         columnHoldTimer.Stop();
         columnHoldTimer = null;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Invokes the point selected event for the currently selected pixel
        /// </summary>
        private void InvokePointSelected()
        {
            var selection = -1;

            _selection.TryGetValue(CurrentSliceType, out selection);

            switch (CurrentSliceType)
            {
            case SliceType.Transversal:
                OnPointSelected.Invoke(_lastClickX, _lastClickY, selection);
                break;

            case SliceType.Sagittal:
                OnPointSelected.Invoke(selection, _lastClickX, _lastClickY);
                break;

            case SliceType.Frontal:
                OnPointSelected.Invoke(_lastClickX, selection, _lastClickY);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 private void HoldTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         int idx = Grid.GetColumn(touchedView);
         PointSelected?.Invoke(this, new PointSelectedEventArgs(idx, touchPoint.Y));
     }));
     if (holdTimer != null)
     {
         //System.Diagnostics.Debug.WriteLine("touch-hold timer diactivated as it ticked");
         holdTimer.Elapsed -= HoldTimer_Elapsed;
         holdTimer.Stop();
         holdTimer = null;
     }
 }
Exemplo n.º 6
0
 protected virtual void RaisePointSelectedEvent(PointSelectedEventArgs eventArgs)
 {
     PointSelected?.Invoke(this, eventArgs);
 }