コード例 #1
0
        private void canvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            canvas.ContextMenu = null;

            Point p = Mouse.GetPosition(canvas);
            var   copiedCollection = new List <GraphPoint>(graphPoints);

            foreach (var gp in copiedCollection)
            {
                if (gp.CanRemove && p.X <= gp.PositionX + GraphConsts.PointPadding && p.X >= gp.PositionX - GraphConsts.PointPadding &&
                    p.Y <= gp.PositionY + GraphConsts.PointPadding && p.Y >= gp.PositionY - GraphConsts.PointPadding)
                {
                    var removePointMenuItem = new MenuItem();
                    removePointMenuItem.Header = "Remove point";
                    var removeContextMenu = new ContextMenu();
                    removeContextMenu.Closed += (s, ee) =>
                    {
                        canvas.ContextMenu = null;
                    };

                    removePointMenuItem.Click += (s, ee) =>
                    {
                        canvas.Children.Remove(gp.UIElement);
                        graphPoints.Remove(gp);
                        UpdateGraph();
                        RecalculateColorOutputFunction();
                    };
                    removeContextMenu.Items.Add(removePointMenuItem);
                    canvas.ContextMenu = removeContextMenu;

                    return;
                }
            }

            var addPointMenuItem = new MenuItem();

            addPointMenuItem.Header = "Add point";
            var addContextMenu = new ContextMenu();

            addContextMenu.Closed += (s, ee) =>
            {
                canvas.ContextMenu = null;
            };

            addPointMenuItem.Click += (s, ee) =>
            {
                var graphPoint = GraphPoint.Create(p.X, p.Y);
                graphPoints.Add(graphPoint);

                dragger.EnableDraggingOnElement(graphPoint, graphPoints);
                placeEllipseElement(graphPoint.UIElement, p.X, p.Y);
                canvas.Children.Add(graphPoint.UIElement);

                UpdateGraph();
                RecalculateColorOutputFunction();
            };
            addContextMenu.Items.Add(addPointMenuItem);
            canvas.ContextMenu = addContextMenu;
        }
コード例 #2
0
        private void drawInversionGraphPoints()
        {
            ClearGraph();

            var graphPoint1 = GraphPoint.Create(0, 255, false);
            var graphPoint2 = GraphPoint.Create(255, 0, false);

            placeEllipseElement(graphPoint1.UIElement, 0, 255);
            placeEllipseElement(graphPoint2.UIElement, 255, 0);

            canvas.Children.Add(graphPoint1.UIElement);
            canvas.Children.Add(graphPoint2.UIElement);

            graphPoints.Add(graphPoint1);
            graphPoints.Add(graphPoint2);
        }
コード例 #3
0
        private void drawBrightnessCorrectionAdditionalGraphPoints(int c)
        {
            drawInitialGraphPoints();

            var graphPoint1 = GraphPoint.Create(0, c);
            var graphPoint2 = GraphPoint.Create(255 - c, 255);

            placeEllipseElement(graphPoint1.UIElement, 0, c);
            placeEllipseElement(graphPoint2.UIElement, 255 - c, 255);

            canvas.Children.Add(graphPoint1.UIElement);
            canvas.Children.Add(graphPoint2.UIElement);

            graphPoints.Add(graphPoint1);
            graphPoints.Add(graphPoint2);

            dragger.EnableDraggingOnElement(graphPoint1, graphPoints);
            dragger.EnableDraggingOnElement(graphPoint2, graphPoints);
        }
コード例 #4
0
        private void drawConstrastEnhancementAdditionalGraphPoints(int c)
        {
            drawInitialGraphPoints();

            int cx1 = ((255 / 2) * (c - 1)) / c;
            int cx2 = ((255 / 2) * (c + 1)) / c;

            var graphPoint1 = GraphPoint.Create(cx1, 0);
            var graphPoint2 = GraphPoint.Create(cx2, 255);

            placeEllipseElement(graphPoint1.UIElement, cx1, 0);
            placeEllipseElement(graphPoint2.UIElement, cx2, 255);

            canvas.Children.Add(graphPoint1.UIElement);
            canvas.Children.Add(graphPoint2.UIElement);

            graphPoints.Add(graphPoint1);
            graphPoints.Add(graphPoint2);

            dragger.EnableDraggingOnElement(graphPoint1, graphPoints);
            dragger.EnableDraggingOnElement(graphPoint2, graphPoints);
        }