private void SetCurrentSizeSpecification(RectangularSizeSpecification specification)
 {
     if (specification.Equals(RectangularSizeSpecification.WidthAndHeight))
     {
         SettingsManager.Instance.LocationSelection = RectangularLocationSelection.Create(UnitExtenstions.FullSize);
     }
     else if (specification.Equals(RectangularSizeSpecification.WidthAndHeightAspect))
     {
         SettingsManager.Instance.LocationSelection = RectangularLocationSelection.CreateWithWidthAndAspectRatio(FloatWithUnit.Zero, 1);
     }
     else if (specification.Equals(RectangularSizeSpecification.HeightAndWidthAspect))
     {
         SettingsManager.Instance.LocationSelection = RectangularLocationSelection.CreateWithHeightAndAspectRatio(FloatWithUnit.Zero, 1);
     }
 }
        public override ILocationSelection BuildLocationSelection()
        {
            switch (this.SizeSpecification)
            {
            case SizeSpecification.WidthAndHeight:
                return(RectangularLocationSelection.Create(new SizeWithUnit(this.Width, this.Height)));

            case SizeSpecification.WidthAndHeightAspect:
                return(RectangularLocationSelection.CreateWithWidthAndAspectRatio(this.Width, this.HeightAspectRatio));

            case SizeSpecification.HeightAndWidthAspect:
                return(RectangularLocationSelection.CreateWithHeightAndAspectRatio(this.Height, this.WidthAspectRatio));

            default:
                return(null);
            }
        }
        private Section[] CreateSections()
        {
            var sections = new List <Section>()
            {
                new Section(new []
                {
                    OptionRow <bool> .Create("None",
                                             () => SettingsManager.Instance.LocationSelection == null,
                                             tuple => SettingsManager.Instance.LocationSelection = null,
                                             this.DataSourceListener
                                             ),
                    OptionRow <bool> .Create("Radius",
                                             () => SettingsManager.Instance.LocationSelection is RadiusLocationSelection,
                                             _ => SettingsManager.Instance.LocationSelection = RadiusLocationSelection.Create(FloatWithUnit.Zero),
                                             this.DataSourceListener
                                             ),
                    OptionRow <bool> .Create("Rectangular",
                                             () => SettingsManager.Instance.LocationSelection is RectangularLocationSelection,
                                             _ => SettingsManager.Instance.LocationSelection = RectangularLocationSelection.Create(SizeWithUnit.Zero),
                                             this.DataSourceListener
                                             )
                }, "Type")
            };

            switch (SettingsManager.Instance.LocationSelection)
            {
            case RadiusLocationSelection radiusLocationSelection:
            {
                var radiusSettings = new Section(new[]
                    {
                        FloatWithUnitRow.Create(
                            "Size",
                            () => radiusLocationSelection.Radius,
                            value => SettingsManager.Instance.LocationSelection = RadiusLocationSelection.Create(value),
                            this.DataSourceListener
                            )
                    }, "Radius");
                sections.Add(radiusSettings);
                break;
            }

            case RectangularLocationSelection rectangularLocationSelection:
            {
                var rectangularSettings = new Section(new []
                    {
                        ChoiceRow <RectangularSizeSpecification> .Create(
                            "Size Specification",
                            Enumeration.GetAll <RectangularSizeSpecification>().ToArray(),
                            () => this.GetCurrentSizeSpecification(),
                            specification => this.SetCurrentSizeSpecification(specification),
                            this.DataSourceListener
                            ),
                    }, "Rectangular");
                sections.Add(rectangularSettings);
                switch (rectangularLocationSelection.SizeWithUnitAndAspect.SizingMode)
                {
                case SizingMode.WidthAndHeight:
                {
                    sections.Add(new Section(new[]
                            {
                                this.CreateRectangularWidthRow(),
                                this.CreateRectangularHeightRow()
                            }));
                    break;
                }

                case SizingMode.WidthAndAspectRatio:
                {
                    sections.Add(new Section(new Row[]
                            {
                                this.CreateRectangularWidthRow(),
                                this.CreateHeightAspectRow()
                            }));
                    break;
                }

                case SizingMode.HeightAndAspectRatio:
                {
                    sections.Add(new Section(new Row[]
                            {
                                this.CreateRectangularHeightRow(),
                                this.CreateWidthAspectRow()
                            }));
                    break;
                }
                }
                break;
            }
            }

            return(sections.ToArray());
        }