Example #1
0
            public static GridSettings Save(FormGenerate form)
            {
                var settings = new GridSettings
                {
                    rndSeed = Int32.Parse(form.tbSeed.Text),
                    records = Int32.Parse(form.tbRecords.Text)
                };

                foreach (Panel panel in form.panelFields.Controls)
                {
                    var control = panel.Controls.OfType <ControlRangeValues>().First();
                    if (control == null)
                    {
                        throw new NoNullAllowedException($"Missing ${nameof(ControlRangeValues)} in panel inside {nameof(form.panelFields)}");
                    }
                    settings.columns.Add(new GridColumn(control.Text1, control.EnabledRandomValue ? control.Text2 : null));
                }

                return(settings);
            }
Example #2
0
            public static void Load(GridSettings gridSettings, FormGenerate form)
            {
                form.tbRecords.Text = gridSettings.records.ToString();
                form.tbSeed.Text    = gridSettings.rndSeed.ToString();
                foreach (GridColumn col in gridSettings.columns)
                {
                    ControlRangeValues.EnumValueType?type = null;

                    if (col.type == typeof(String))
                    {
                        type = ControlRangeValues.EnumValueType.String;
                    }
                    if (col.type == typeof(Double))
                    {
                        type = ControlRangeValues.EnumValueType.Float;
                    }
                    if (col.type == typeof(Int32))
                    {
                        type = ControlRangeValues.EnumValueType.Integer;
                    }

                    if (col.type == typeof(DateTime))
                    {
                        type = ControlRangeValues.EnumValueType.Date;
                        DateTime dt1 = (DateTime)col.Value1;
                        DateTime dt2 = (DateTime)col.Value2;

                        form.createDataPanel(col.Range, type.Value,
                                             dt1.ToString(ControlRangeValues.DateTime_Format, CultureInfo.InvariantCulture),
                                             dt2.ToString(ControlRangeValues.DateTime_Format, CultureInfo.InvariantCulture));
                        continue;
                    }

                    if (!type.HasValue)
                    {
                        throw new UnknownTypeException($"Unknown type: {col.type} for enum {nameof(ControlRangeValues.EnumValueType)}!");
                    }

                    form.createDataPanel(col.Range, type.Value, col.Value1.ToString(), col.Value2?.ToString());
                }
            }