예제 #1
0
            public void Bind()
            {
                if (EFControlProperty == null)
                {
                    if (EFControl.GetType() == typeof(Button))
                    {
                        (EFControl as Button).Text = EFConfigValue;
                    }
                    else if (EFControl.GetType() == typeof(Label))
                    {
                        (EFControl as Label).Text = EFConfigValue;
                    }
                    else if (EFControl.GetType() == typeof(LinkLabel))
                    {
                        (EFControl as LinkLabel).Text = EFConfigValue;
                    }
                    else if (EFControl.GetType() == typeof(MaskedTextBox))
                    {
                        (EFControl as MaskedTextBox).Text = EFConfigValue;
                    }
                    else if (EFControl.GetType() == typeof(RichTextBox))
                    {
                        (EFControl as RichTextBox).Text = EFConfigValue;
                    }
                    else if (EFControl.GetType() == typeof(TextBox))
                    {
                        (EFControl as TextBox).Text = EFConfigValue;
                    }

                    else if (EFControl.GetType() == typeof(CheckBox))
                    {
                        (EFControl as CheckBox).Checked = bool.Parse(EFConfigValue);
                    }
                    else if (EFControl.GetType() == typeof(DateTimePicker))
                    {
                        (EFControl as DateTimePicker).Value = DateTime.Parse(EFConfigValue);
                    }
                    else if (EFControl.GetType() == typeof(NumericUpDown))
                    {
                        (EFControl as NumericUpDown).Value = decimal.Parse(EFConfigValue);
                    }
                    else if (EFControl.GetType() == typeof(ProgressBar))
                    {
                        (EFControl as ProgressBar).Value = int.Parse(EFConfigValue);
                    }
                    else if (EFControl.GetType() == typeof(RadioButton))
                    {
                        (EFControl as RadioButton).Checked = bool.Parse(EFConfigValue);
                    }

                    else if (EFControl.GetType() == typeof(WebBrowser))
                    {
                        (EFControl as WebBrowser).Url = new Uri(EFConfigValue);
                    }

                    //else if (EFControl.GetType() == typeof(MonthCalendar))  (EFControl as MonthCalendar).??? = EFConfigValue;

                    //else if (EFControl.GetType() == typeof(ComboBox))       (EFControl as ComboBox).Text = EFConfigValue;
                    //else if (EFControl.GetType() == typeof(ListBox))        (EFControl as ListBox).Text = EFConfigValue;
                    //else if (EFControl.GetType() == typeof(ListView))       (EFControl as ListView).Text = EFConfigValue;

                    //else if (EFControl.GetType() == typeof(TreeView))       (EFControl as TreeView).Text = EFConfigValue;
                }
                else
                {
                    PropertyInfo prop = EFControl.GetType().GetProperty(EFControlProperty);
                    if (null != prop && prop.CanWrite)
                    {
                        prop.SetValue(EFControl, EFConfigValue, null);
                    }
                }
            }
예제 #2
0
            public void Read()
            {
                if (!EFReadOnly)
                {
                    if (EFControlProperty == null)
                    {
                        if (EFControl.GetType() == typeof(Button))
                        {
                            EFConfigValue = (EFControl as Button).Text;
                        }
                        else if (EFControl.GetType() == typeof(Label))
                        {
                            EFConfigValue = (EFControl as Label).Text;
                        }
                        else if (EFControl.GetType() == typeof(LinkLabel))
                        {
                            EFConfigValue = (EFControl as LinkLabel).Text;
                        }
                        else if (EFControl.GetType() == typeof(MaskedTextBox))
                        {
                            EFConfigValue = (EFControl as MaskedTextBox).Text;
                        }
                        else if (EFControl.GetType() == typeof(RichTextBox))
                        {
                            EFConfigValue = (EFControl as RichTextBox).Text;
                        }
                        else if (EFControl.GetType() == typeof(TextBox))
                        {
                            EFConfigValue = (EFControl as TextBox).Text;
                        }

                        else if (EFControl.GetType() == typeof(CheckBox))
                        {
                            EFConfigValue = (EFControl as CheckBox).Checked.ToString();
                        }
                        else if (EFControl.GetType() == typeof(DateTimePicker))
                        {
                            EFConfigValue = (EFControl as DateTimePicker).Value.ToString();
                        }
                        else if (EFControl.GetType() == typeof(NumericUpDown))
                        {
                            EFConfigValue = (EFControl as NumericUpDown).Value.ToString();
                        }
                        else if (EFControl.GetType() == typeof(ProgressBar))
                        {
                            EFConfigValue = (EFControl as ProgressBar).Value.ToString();
                        }
                        else if (EFControl.GetType() == typeof(RadioButton))
                        {
                            EFConfigValue = (EFControl as RadioButton).Checked.ToString();
                        }

                        else if (EFControl.GetType() == typeof(WebBrowser))
                        {
                            EFConfigValue = (EFControl as WebBrowser).Url.ToString();
                        }

                        //else if (EFControl.GetType() == typeof(MonthCalendar))  (EFControl as MonthCalendar).??? = EFConfigValue;

                        //else if (EFControl.GetType() == typeof(ComboBox))       (EFControl as ComboBox).Text = EFConfigValue;
                        //else if (EFControl.GetType() == typeof(ListBox))        (EFControl as ListBox).Text = EFConfigValue;
                        //else if (EFControl.GetType() == typeof(ListView))       (EFControl as ListView).Text = EFConfigValue;

                        //else if (EFControl.GetType() == typeof(TreeView))       (EFControl as TreeView).Text = EFConfigValue;
                    }
                    else
                    {
                        PropertyInfo prop = EFControl.GetType().GetProperty(EFControlProperty);
                        if (null != prop && prop.CanWrite)
                        {
                            EFConfigValue = prop.GetValue(EFControl, null).ToString();
                        }
                    }
                }
            }