Esempio n. 1
0
        private object GetValueFrom(Control control, IUserOption option)
        {
            if (VirtualPropertyHelper.IsEnumType(option))
            {
                ComboBoxItemEx <object> item = ((ComboBox)control).SelectedItem as ComboBoxItemEx <object>;
                if (item == null)
                {
                    return(null);
                }

                return(item.Object);
            }
            if (VirtualPropertyHelper.IsStringType(option))
            {
                return(control.Text);
            }

            if (VirtualPropertyHelper.IsIntegerNumericType(option))
            {
                return(control.Text.As <int>());
            }

            if (VirtualPropertyHelper.IsCharType(option))
            {
                return(control.Text[0]);
            }

            if (VirtualPropertyHelper.IsDecimalNumericType(option))
            {
                return(control.Text.As <decimal>());
            }

            if (VirtualPropertyHelper.IsBoolType(option))
            {
                return(((CheckBox)control).Checked);
            }

            return(null);
        }
Esempio n. 2
0
        private int AddVirtualProperty(IUserOption option, int top, int labelWidth)
        {
            virtualProperties.Add(option);

            Label labelPropertyName = new Label();

            labelPropertyName.Name      = string.Format("label{0}", option.Name);
            labelPropertyName.Font      = this.Font;
            labelPropertyName.Text      = option.Text.Replace("End1:", "").Replace("End2:", "").Trim();
            labelPropertyName.BackColor = BackColor;
            labelPropertyName.ForeColor = ForeColor;

            Control inputControl;

            if (VirtualPropertyHelper.IsEntityPropertyType(option))
            {
                inputControl = AddPropertySelectorInputControl(option);
            }
            else if (VirtualPropertyHelper.IsEnumType(option))
            {
                inputControl = AddEnumInputControl(option);
            }
            else if (VirtualPropertyHelper.IsStringType(option))
            {
                inputControl = AddStringInputControl(option);
            }
            else if (VirtualPropertyHelper.IsIntegerNumericType(option))
            {
                inputControl = AddIntegerInputControl(option);
            }
            else if (VirtualPropertyHelper.IsCharType(option))
            {
                inputControl = AddCharInputControl(option);
            }
            else if (VirtualPropertyHelper.IsDecimalNumericType(option))
            {
                inputControl = AddDecimalInputControl(option);
            }
            else if (VirtualPropertyHelper.IsBoolType(option))
            {
                inputControl = AddBoolInputControl(option);
            }
            else
            {
                throw new NotImplementedException("Not handled yet");
            }
            //return;
            inputControl.Font = this.Font;

            labelPropertyName.Left      = 5;
            labelPropertyName.AutoSize  = false;
            labelPropertyName.Width     = labelWidth;
            labelPropertyName.TextAlign = ContentAlignment.MiddleRight;
            inputControl.Left           = labelPropertyName.Right + 5;
            inputControl.Top            = labelPropertyName.Top = top;
            inputControl.Width          = Width - inputControl.Left - 5;

            bool propertyEnabled = option.DisplayToUser;

            inputControl.Visible      = propertyEnabled;
            labelPropertyName.Visible = propertyEnabled;
            labelPropertyName.Anchor  = AnchorStyles.Left | AnchorStyles.Top;
            inputControl.Anchor       = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            inputControl.Name         = option.Name;

            if (inputControl is ComboBox)
            {
                inputControl.Width  = Math.Min(inputControl.Width, 200);
                inputControl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            }
            else if (inputControl is IntegerInput || inputControl is DoubleInput)
            {
                inputControl.Width  = 50;
                inputControl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            }
            this.Controls.Add(labelPropertyName);
            this.Controls.Add(inputControl);

            if (propertyEnabled)
            {
                SetTooltip(labelPropertyName, "", option.Description);
                SetTooltip(inputControl, "", option.Description);
            }
            else
            {
                SetTooltip(labelPropertyName, "Disabled", option.Description);
                SetTooltip(inputControl, "Disabled", option.Description);
            }
            //CurrentRowHeight += 40;

            //Height = CurrentRowHeight + 50;
            UserOptionLookups.Add(option, inputControl);
            ControlLookups.Add(inputControl, option);
            this.Height = labelPropertyName.Bottom + 10;
            labelPropertyName.Refresh();
            inputControl.Refresh();

            if (propertyEnabled)
            {
                return(Math.Max(labelPropertyName.Bottom, inputControl.Bottom));
            }
            else
            {
                return(top);
            }
        }
Esempio n. 3
0
        private int GetVirtualPropertyControl(ArchAngel.Interfaces.ITemplate.IUserOption option, int CurrentRowHeight)
        {
            Label labelPropertyName = new Label();

            labelPropertyName.Text = option.Text;

            Control inputControl;

            if (VirtualPropertyHelper.IsEnumType(option))
            {
                inputControl = AddEnumInputControl(option);
            }
            else if (VirtualPropertyHelper.IsStringType(option))
            {
                inputControl = AddStringInputControl(option);
            }
            else if (VirtualPropertyHelper.IsIntegerNumericType(option))
            {
                inputControl = AddIntegerInputControl(option);
            }
            else if (VirtualPropertyHelper.IsCharType(option))
            {
                inputControl = AddCharInputControl(option);
            }
            else if (VirtualPropertyHelper.IsDecimalNumericType(option))
            {
                inputControl = AddDecimalInputControl(option);
            }
            else if (VirtualPropertyHelper.IsBoolType(option))
            {
                inputControl = AddBoolInputControl(option);
            }
            else
            {
                throw new NotImplementedException("Not handled yet");
            }
            //return;

            labelPropertyName.Left     = 5;
            labelPropertyName.AutoSize = true;
            inputControl.Left          = labelPropertyName.PreferredWidth + 15;
            inputControl.Top           = labelPropertyName.Top = CurrentRowHeight;
            inputControl.Width         = Control.Width - inputControl.Left - 5;

            bool propertyEnabled = option.DisplayToUser;

            inputControl.Enabled = propertyEnabled;

            labelPropertyName.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            inputControl.Anchor      = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

            Control.Controls.Add(labelPropertyName);
            Control.Controls.Add(inputControl);

            if (propertyEnabled)
            {
                SetTooltip(labelPropertyName, "", option.Description);
            }
            else
            {
                SetTooltip(labelPropertyName, "Disabled", option.Description);
            }

            //CurrentRowHeight += 40;

            //Height = CurrentRowHeight + 50;
            return(Math.Max(labelPropertyName.Bottom, inputControl.Bottom));
        }
Esempio n. 4
0
        private int AddVirtualProperty(IUserOption option, int top, int labelWidth)
        {
            virtualProperties.Add(option);

            Label labelPropertyName = new Label();

            labelPropertyName.Text      = option.Text;
            labelPropertyName.BackColor = BackColor;
            labelPropertyName.ForeColor = ForeColor;

            Control inputControl;

            if (VirtualPropertyHelper.IsEnumType(option))
            {
                inputControl = AddEnumInputControl(option);
            }
            else if (VirtualPropertyHelper.IsStringType(option))
            {
                inputControl = AddStringInputControl(option);
            }
            else if (VirtualPropertyHelper.IsIntegerNumericType(option))
            {
                inputControl = AddIntegerInputControl(option);
            }
            else if (VirtualPropertyHelper.IsCharType(option))
            {
                inputControl = AddCharInputControl(option);
            }
            else if (VirtualPropertyHelper.IsDecimalNumericType(option))
            {
                inputControl = AddDecimalInputControl(option);
            }
            else if (VirtualPropertyHelper.IsBoolType(option))
            {
                inputControl = AddBoolInputControl(option);
            }
            else
            {
                throw new NotImplementedException("Not handled yet");
            }
            //return;

            labelPropertyName.Left      = 5;
            labelPropertyName.AutoSize  = false;
            labelPropertyName.Width     = labelWidth;
            labelPropertyName.TextAlign = ContentAlignment.MiddleRight;
            inputControl.Left           = labelPropertyName.Right + 5;
            inputControl.Top            = labelPropertyName.Top = top;
            inputControl.Width          = Control.Width - inputControl.Left - 5;

            bool propertyEnabled = option.DisplayToUser;

            inputControl.Enabled = propertyEnabled;

            labelPropertyName.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            inputControl.Anchor      = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

            Control.Controls.Add(labelPropertyName);
            Control.Controls.Add(inputControl);

            if (propertyEnabled)
            {
                SetTooltip(labelPropertyName, "", option.Description);
                SetTooltip(inputControl, "", option.Description);
            }
            else
            {
                SetTooltip(labelPropertyName, "Disabled", option.Description);
                SetTooltip(inputControl, "Disabled", option.Description);
            }
            //CurrentRowHeight += 40;

            //Height = CurrentRowHeight + 50;
            UserOptionLookups.Add(option, inputControl);
            ControlLookups.Add(inputControl, option);
            return(Math.Max(labelPropertyName.Bottom, inputControl.Bottom));
        }