Пример #1
0
        private void selectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (isItRectangle)
            {
                formProperties = new FormChange(FormChange.Style.Properties, FormChange.Type.Rectangle);
            }
            else if (isItSquare)
            {
                formProperties = new FormChange(FormChange.Style.Properties, FormChange.Type.Square);
            }
            else if (isItCircle)
            {
                formProperties = new FormChange(FormChange.Style.Properties, FormChange.Type.Circle);
            }

            if (formProperties.ShowDialog() == DialogResult.OK)
            {
                var selectedShapes = _shapes
                                     .AsEnumerable();
                if (formProperties.Width.HasValue)
                {
                    selectedShapes = selectedShapes
                                     .Where(r => r.Width == formProperties.Width.Value);
                }
                if (formProperties.Height.HasValue)
                {
                    selectedShapes = selectedShapes
                                     .Where(r => r.Height == formProperties.Height.Value);
                }
                if (formProperties.Color.HasValue)
                {
                    selectedShapes = selectedShapes
                                     .Where(r => r.Color == formProperties.Color.Value);
                }
                if (formProperties.Height.HasValue || formProperties.Width.HasValue ||
                    formProperties.Color.HasValue)
                {
                    foreach (var shape in selectedShapes)
                    {
                        shape.Selected = true;
                    }
                }
                Invalidate();
            }
            RefreshArea();
        }
Пример #2
0
        private void Properties()
        {
            var shape = _shapes
                        .FirstOrDefault(r => r.Selected);

            if (isItRectangle)
            {
                formProperties = new FormChange(FormChange.Style.Properties, FormChange.Type.Rectangle);
            }
            else if (isItSquare)
            {
                formProperties = new FormChange(FormChange.Style.Properties, FormChange.Type.Square);
            }
            else if (isItCircle)
            {
                formProperties = new FormChange(FormChange.Style.Properties, FormChange.Type.Circle);
            }

            if (shape != null)
            {
                formProperties.Height = shape.Height;
                formProperties.Width  = shape.Width;
                formProperties.Radius = shape.Radius;
                formProperties.Color  = shape.Color;
                if (formProperties.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        shape.Height = formProperties.Height.Value;
                        shape.Width  = formProperties.Width.Value;
                        shape.Radius = formProperties.Radius.Value;
                        shape.Color  = formProperties.Color.Value;
                    }
                    catch (InvalidValueExeption e)
                    {
                        MessageBox.Show(
                            e.Message,
                            "Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                }
            }
        }