コード例 #1
0
        private void EditItem(object sender, MouseButtonEventArgs e)
        {
            var activeListItem = LBItems.SelectedItem as ShapeListItem;

            _activeElement        = activeListItem.Shape;
            _activeMyShapeElement = activeListItem;
            _figureManager        = GetFigureManagerForEdit(activeListItem);
            _currentlyDrawing     = true;
        }
コード例 #2
0
ファイル: mop_profile.cs プロジェクト: robgrz/matmill
        private Sliced_path gen_pocket_toolpath(ShapeListItem shape, Point2F startpoint, Vector2F start_tangent)
        {
            Polyline outline;

            Polyline[] islands;

            if (shape.Shape is Polyline)
            {
                outline = (Polyline)shape.Shape;
                islands = new Polyline[] { };
            }
            else if (shape.Shape is CamBam.CAD.Region)
            {
                CamBam.CAD.Region reg = (CamBam.CAD.Region)shape.Shape;
                outline = reg.OuterCurve;
                islands = reg.HoleCurves;
            }
            else
            {
                return(null);
            }

            Pocket_generator gen = new Pocket_generator(outline, islands);

            gen.General_tolerance = is_inch_units() ? 0.001 / 25.4 : 0.001;
            gen.Tool_d            = base.ToolDiameter.Cached;
            gen.Max_ted           = base.ToolDiameter.Cached * _stepover.Cached;
            gen.Min_ted           = base.ToolDiameter.Cached * _stepover.Cached * _min_stepover_percentage;
            if (startpoint.IsUndefined)
            {
                startpoint = (Point2F)outline.FirstPoint;
            }
            gen.Startpoint           = startpoint;
            gen.Startpoint_is_a_hint = true;
            gen.Margin         = 0;
            gen.Spiral_tangent = start_tangent;

            if (_milling_direction.Cached == MillingDirectionOptions.Mixed || base.SpindleDirection.Cached == SpindleDirectionOptions.Off)
            {
                gen.Mill_direction       = RotationDirection.Unknown; // means 'mixed' here
                gen.Should_smooth_chords = false;
            }
            else
            {
                int dir = (int)(base.SpindleDirection.Cached);
                if (_milling_direction.Cached == MillingDirectionOptions.Climb)
                {
                    dir = -dir;
                }
                gen.Mill_direction       = (RotationDirection)dir;
                gen.Should_smooth_chords = _should_smooth_chords;
            }

            return(gen.run());
        }
コード例 #3
0
        private FigureManager GetFigureManagerForEdit(ShapeListItem shape)
        {
            FigureManager figureManager = null;

            if (shape.Shape is Line)
            {
                figureManager = new LineManager();
            }
            else if (shape.Shape is Ellipse)
            {
                figureManager = new EllipseManager();
            }
            else if (shape.Shape is System.Windows.Shapes.Rectangle)
            {
                figureManager = new RectangleManager();
            }
            figureManager.Set(shape.StartX, shape.StartY);
            return(figureManager);
        }
コード例 #4
0
        private void StartStopDrawing(object sender, MouseButtonEventArgs e)
        {
            if (_currentlyDrawing)
            {
                CurrentlyDrawing = false;
            }
            else
            {
                CurrentlyDrawing = true;

                var mousePosition = e.GetPosition(Canvas);

                _figureManager = GetFigureManager(mousePosition.X, mousePosition.Y);

                _activeElement = GetElement();


                Canvas.Children.Add(_activeElement);
                _activeMyShapeElement        = new ShapeListItem(_activeElement);
                _activeMyShapeElement.StartX = mousePosition.X;
                _activeMyShapeElement.StartY = mousePosition.Y;
                _shapes.Add(_activeMyShapeElement);
            }
        }