예제 #1
0
        private void OnGenerateShapeCommand()
        {
            Shape shape = null;

            if (SelectedShapeType == ShapeType.Circle)
            {
                shape = _generateShapeHelper.GenerateCircle();
            }

            if (SelectedShapeType == ShapeType.Rectangle)
            {
                shape = _generateShapeHelper.GenerateRectangle();
            }

            if (SelectedShapeType == ShapeType.Trapezium)
            {
                shape = _generateShapeHelper.GenerateTrapezium();
            }

            if (shape != null)
            {
                ShapesFullList.Add(shape);
                ShapesFullList = new CustomList <Shape>(ShapesFullList);
                ApplyFilter();
            }
        }
예제 #2
0
        private void OnCreateShape()
        {
            BaseWindow window = null;

            if (SelectedShapeType == ShapeType.Circle)
            {
                var viewModel = new CreateCircleViewModel();
                window = new CreateCircleWindow(viewModel);
            }

            if (SelectedShapeType == ShapeType.Rectangle)
            {
                var viewModel = new CreateRectangleViewModel();
                window = new CreateRectangleWindow(viewModel);
            }

            if (SelectedShapeType == ShapeType.Trapezium)
            {
                var viewModel = new CreateTrapeziumViewModel();
                window = new CreateTrapeziumWindow(viewModel);
            }

            window.ShowDialog();

            var shape = (window.DataContext as BaseViewModel).Shape;

            if (shape != null)
            {
                ShapesFullList.Add(shape);
                ShapesFullList = new CustomList <Shape>(ShapesFullList);
                ApplyFilter();
            }
        }
예제 #3
0
 private void OnDeleteShape()
 {
     ShapesFullList.Remove(SelectedShape);
     ShapesFullList = new CustomList <Shape>(ShapesFullList);
     ApplyFilter();
     SelectedShape = ShapesList.LastOrDefault();
 }
예제 #4
0
        private void ApplyFilter()
        {
            if (!IsCircleSelected && !IsTrapeziumSelected && !IsRectangleSelected)
            {
                ShapesList = new CustomList <Shape>(ShapesFullList);
                return;
            }

            var filteredList = ShapesFullList.Where(x =>
                                                    (IsCircleSelected && x is Circle) ||
                                                    (IsTrapeziumSelected && x is Trapezium) ||
                                                    (IsRectangleSelected && x is Rectangle)).ToList();

            ShapesList = new CustomList <Shape>(filteredList);
        }