Exemplo n.º 1
0
        /******************************************************************************************************
         * Body Chart
         *****************************************************************************************************/

        private void BodyChartClick(object sender, MouseButtonEventArgs e)
        {
            if (_withinMarkPopup)
            {
                return;
            }

            var bc         = BodyChartCanvas;
            var lb         = AnnotationsList;
            var ms         = (ModalState)EvaluationModal.DataContext;
            var activeView = ms.ActiveView;
            var point      = new Point(e.GetPosition(BodyChart).X - BodyChartMark.DrawRadius, e.GetPosition(BodyChart).Y - BodyChartMark.DrawRadius);

            var mark = ms.Marks.FirstOrDefault(m => Point.Subtract(point, new Point(m.X, m.Y)).Length < 4 * BodyChartMark.DrawRadius);

            if (mark == null)
            {
                if (ms.CanBeEdited == false)
                {
                    return;
                }

                mark = new BodyChartMark {
                    ViewId = activeView.Id, X = point.X, Y = point.Y, PainLevel = 2
                };

                ms.Marks.Add(mark);
                BodyChartMark.DrawMark(bc, mark, BodyChartClick);
            }

            BodyChartMarkPopup.IsPopupOpen = false;  // close the popup
            BodyChartMarkPopup.DataContext = null;

            lb.SelectedItems.Clear();
            foreach (var annotation in mark.Annotations)
            {
                lb.SelectedItems.Add(annotation);
            }

            BodyChartMarkPopup.DataContext = mark;
            BodyChartMarkPopup.IsPopupOpen = true;  // open the popup
        }
Exemplo n.º 2
0
        private void UpdateBodyView(ModalState ms, int newIdx)
        {
            var bc = BodyChartCanvas;

            ms.ActiveViewIdx = newIdx;
            var newActiveView = ms.ActiveView;

            BodyChartMarkPopup.IsPopupOpen = false;

            // Clear the canvas
            bc.Children.RemoveRange(1, int.MaxValue);
            // Add values (if they exist)
            foreach (var m in ms.Marks)
            {
                if (m.ViewId == newActiveView.Id)
                {
                    BodyChartMark.DrawMark(bc, m, BodyChartClick);
                }
            }

            // Make it visible now
            BodyChart.DataContext = newActiveView;
        }