示例#1
0
        void validateName(AutoTextBox from, StringBuilder text, ref int caret)
        {
            bool inside(char c, char a, char b)
            => c >= a && c <= b;

            int  len     = text.Length;
            bool changed = false;

            for (int i = 0; i < len; i++)
            {
                char c = text[i];
                if ((i == 0 && inside(c, '0', '9')) || !allowedChars.IsMatch(c + ""))
                {
                    if (nameProblem)
                    {
                        return;
                    }
                    if (nameChecked)
                    {
                        text.Remove(i, 1);
                        i--;
                        len--;
                        caret--;
                        changed = true;
                    }
                    else
                    {
                        nameProblem = true;
                        nameChecked = true;
                        return;
                    }
                }
            }
            if (!changed)
            {
                nameProblem = false;
                showProblem();
            }
            applyFolderIcons();
            btnOK.Enabled        =
                btnApply.Enabled =
                    !nameProblem && len > 0;
        }
示例#2
0
        public static void GetSingleCtrlAutoBindingData(Control ctrl, object obj)
        {
            string ObjectName  = obj.GetType().Name;
            string bindingname = "";

            if (ctrl is AutoTextBox)
            {
                AutoTextBox textbox = ctrl as AutoTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.Text);
                    }
                }
            }
            else
            if (ctrl is TextBoxValidation)
            {
                TextBoxValidation textbox = ctrl as TextBoxValidation;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.Text);
                    }
                }
            }
            else
            if (ctrl is StatusTextbox)
            {
                StatusTextbox textbox = ctrl as StatusTextbox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.Text);
                    }
                }
            }
            else
            if (ctrl is AutoMetroTextBox)
            {
                AutoMetroTextBox textbox = ctrl as AutoMetroTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.Text);
                    }
                }
            }
            else
            if (ctrl is AutoFileTextBox)
            {
                AutoFileTextBox textbox = ctrl as AutoFileTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.FileName);
                    }
                }
            }
            else
            if (ctrl is AutoCombobox)
            {
                AutoCombobox combobox = ctrl as AutoCombobox;
                if (combobox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(combobox.BindingName))
                    {
                        bindingname = combobox.BindingName;
                        SetProperty(bindingname, obj, combobox.SelectedValue);
                    }
                }
            }
            else
            if (ctrl is AutoSearchCombobox)
            {
                AutoSearchCombobox combobox = ctrl as AutoSearchCombobox;
                if (combobox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(combobox.BindingName))
                    {
                        bindingname = combobox.BindingName;
                        if (combobox.GetSelectedText == true)
                        {
                            SetProperty(bindingname, obj, combobox.Text);
                        }
                        else
                        {
                            SetProperty(bindingname, obj, combobox.SelectedValue);
                        }
                    }
                }
            }

            else
            if (ctrl is AutoDatetime)
            {
                AutoDatetime dtp = ctrl as AutoDatetime;
                if (dtp.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        bindingname = dtp.BindingName;
                        SetProperty(bindingname, obj, dtp.Value);
                    }
                }
            }
            else
            if (ctrl is AutoXDatetime)
            {
                AutoXDatetime dtp = ctrl as AutoXDatetime;
                if (dtp.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        bindingname = dtp.BindingName;
                        SetProperty(bindingname, obj, dtp.DateTime);
                    }
                }
            }
            else
            if (ctrl is AutoPictureBox)
            {
                AutoPictureBox ptb = ctrl as AutoPictureBox;
                if (ptb.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(ptb.BindingName))
                    {
                        bindingname = ptb.BindingName;
                        SetProperty(bindingname, obj, ptb.PictureName);
                        if (!string.IsNullOrWhiteSpace(ptb.PictureOriginPath))
                        {
                            PictureUtility.SaveImg(ptb.PictureOriginPath);
                        }
                    }
                }
            }
        }
示例#3
0
        public static void GetAutoBindingData(Control controls, object obj)
        {
            string ObjectName  = obj.GetType().Name;
            string bindingname = "";

            foreach (Control ctrl in controls.Controls)
            {
                if (ctrl is AutoTextBox)
                {
                    AutoTextBox textbox = ctrl as AutoTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    SetProperty(bindingname, obj, textbox.Text);
                }
                else
                if (ctrl is TextBoxValidation)
                {
                    TextBoxValidation textbox = ctrl as TextBoxValidation;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    SetProperty(bindingname, obj, textbox.Text);
                }
                else
                if (ctrl is StatusTextbox)
                {
                    StatusTextbox textbox = ctrl as StatusTextbox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    SetProperty(bindingname, obj, textbox.Text);
                }
                else
                if (ctrl is AutoMetroTextBox)
                {
                    AutoMetroTextBox textbox = ctrl as AutoMetroTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    SetProperty(bindingname, obj, textbox.Text);
                }
                else
                if (ctrl is AutoFileTextBox)
                {
                    AutoFileTextBox textbox = ctrl as AutoFileTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    string text = string.IsNullOrWhiteSpace(textbox.FileName) == true ? textbox.Text : textbox.FileName;
                    SetProperty(bindingname, obj, text);
                }
                else
                if (ctrl is AutoCombobox)
                {
                    AutoCombobox combobox = ctrl as AutoCombobox;
                    if (combobox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(combobox.BindingName))
                    {
                        continue;
                    }
                    bindingname = combobox.BindingName;
                    SetProperty(bindingname, obj, combobox.SelectedValue);
                }
                else
                if (ctrl is AutoSearchCombobox)
                {
                    AutoSearchCombobox combobox = ctrl as AutoSearchCombobox;
                    if (combobox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(combobox.BindingName))
                    {
                        continue;
                    }
                    bindingname = combobox.BindingName;
                    if (combobox.GetSelectedText == true)
                    {
                        SetProperty(bindingname, obj, combobox.Text);
                    }
                    else
                    {
                        SetProperty(bindingname, obj, combobox.SelectedValue);
                    }
                }

                else
                if (ctrl is AutoDatetime)
                {
                    AutoDatetime dtp = ctrl as AutoDatetime;
                    if (dtp.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        continue;
                    }
                    bindingname = dtp.BindingName;
                    SetProperty(bindingname, obj, dtp.Value);
                }
                else
                if (ctrl is AutoXDatetime)
                {
                    AutoXDatetime dtp = ctrl as AutoXDatetime;
                    if (dtp.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        continue;
                    }
                    bindingname = dtp.BindingName;
                    SetProperty(bindingname, obj, dtp.DateTime);
                }
                else
                if (ctrl is AutoPictureBox)
                {
                    AutoPictureBox ptb = ctrl as AutoPictureBox;
                    if (ptb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(ptb.BindingName))
                    {
                        continue;
                    }
                    bindingname = ptb.BindingName;
                    SetProperty(bindingname, obj, ptb.PictureName);
                    if (!string.IsNullOrWhiteSpace(ptb.PictureOriginPath))
                    {
                        PictureUtility.SaveImg(ptb.PictureOriginPath);
                    }
                }
                if (ctrl is AutoMaterialCheckBox)
                {
                    AutoMaterialCheckBox cb = ctrl as AutoMaterialCheckBox;
                    if (cb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(cb.BindingName))
                    {
                        continue;
                    }
                    bindingname = cb.BindingName;
                    SetProperty(bindingname, obj, cb.Checked);
                }
                if (ctrl.Controls.Count > 0)
                {
                    GetAutoBindingData(ctrl, obj);
                }
            }
        }
示例#4
0
        public static void SetSingleCtrlAutoBindingData(Control ctrl, object obj)
        {
            if (obj == null)
            {
                return;
            }
            string ObjectName  = obj.GetType().Name;
            string bindingname = "";
            object val         = null;

            if (ctrl is AutoTextBox)
            {
                AutoTextBox textbox = ctrl as AutoTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";
                    }
                }
            }
            else
            if (ctrl is TextBoxValidation)
            {
                TextBoxValidation textbox = ctrl as TextBoxValidation;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";
                    }
                }
            }
            else
            if (ctrl is StatusTextbox)
            {
                StatusTextbox textbox = ctrl as StatusTextbox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";
                    }
                }
            }
            else
            if (ctrl is AutoMetroTextBox)
            {
                AutoMetroTextBox textbox = ctrl as AutoMetroTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";
                    }
                }
            }
            else
            if (ctrl is AutoFileTextBox)
            {
                AutoFileTextBox textbox = ctrl as AutoFileTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";

                        textbox.FileName = textbox.Text;
                    }
                }
            }
            else
            if (ctrl is AutoDatetime)
            {
                AutoDatetime dtp = ctrl as AutoDatetime;
                if (dtp.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        bindingname = dtp.BindingName;
                        val         = GetPropertyValue(bindingname, obj);
                        dtp.Value   = val != null?Convert.ToDateTime(val) : UtilityFunction.minDate;
                    }
                }
            }
            else
            if (ctrl is AutoXDatetime)
            {
                AutoXDatetime dtp = ctrl as AutoXDatetime;
                if (dtp.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        bindingname  = dtp.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        dtp.DateTime = val != null?Convert.ToDateTime(val) : UtilityFunction.minDate;
                    }
                }
            }
            else
            if (ctrl is AutoPictureBox)
            {
                AutoPictureBox ptb = ctrl as AutoPictureBox;
                if (ptb.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(ptb.BindingName))
                    {
                        bindingname     = ptb.BindingName;
                        val             = GetPropertyValue(bindingname, obj);
                        ptb.PictureName = val != null?val.ToString() : "";

                        ptb.Image = PictureUtility.GetImg(ptb.PictureName);
                        if (ptb.Image == null)
                        {
                            ptb.Image = TmTech_v1.Properties.Resources.unknow;
                        }
                        ptb.SizeMode = PictureBoxSizeMode.StretchImage;
                    }
                }
            }
            else
            if (ctrl is AutoCombobox)
            {
                AutoCombobox cbb = ctrl as AutoCombobox;
                if (cbb.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(cbb.BindingName))
                    {
                        bindingname       = cbb.BindingName;
                        val               = GetPropertyValue(bindingname, obj);
                        cbb.SelectedValue = val != null?Convert.ToInt32(val) : 0;
                    }
                }
            }
            else
            if (ctrl is AutoSearchCombobox)
            {
                AutoSearchCombobox cbb = ctrl as AutoSearchCombobox;
                if (cbb.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(cbb.BindingName))
                    {
                        bindingname = cbb.BindingName;
                        val         = GetPropertyValue(bindingname, obj);
                        if (cbb.GetSelectedText == true)
                        {
                            cbb.Text = val != null?val.ToString() : "";
                        }
                        else
                        {
                            cbb.SelectedValue = val != null?Convert.ToInt32(val) : 0;
                        }
                    }
                }
            }
        }
示例#5
0
        public static void SetAutoBindingData(Control controls, object obj)
        {
            if (obj == null)
            {
                return;
            }
            string ObjectName  = obj.GetType().Name;
            string bindingname = "";
            object val         = null;

            foreach (Control ctrl in controls.Controls)
            {
                if (ctrl is TextBoxValidation)
                {
                    TextBoxValidation textbox = ctrl as TextBoxValidation;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";
                }
                else if (ctrl is StatusTextbox)
                {
                    StatusTextbox textbox = ctrl as StatusTextbox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";

                    if (!string.IsNullOrWhiteSpace(textbox.StatusFieldName))
                    {
                        var statusValue = GetPropertyValue(textbox.StatusFieldName, obj);
                        int status      = statusValue != null?Convert.ToInt32(statusValue) : 0;

                        textbox.Display(status);
                    }
                }
                else if (ctrl is AutoTextBox)
                {
                    AutoTextBox textbox = ctrl as AutoTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";
                }

                else if (ctrl is AutoMetroTextBox)
                {
                    AutoMetroTextBox textbox = ctrl as AutoMetroTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";
                }
                else if (ctrl is AutoFileTextBox)
                {
                    AutoFileTextBox textbox = ctrl as AutoFileTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";

                    if (FileUtility.PathIsImage(textbox.Text))
                    {
                        textbox.FilePath = PictureUtility.getImgLocation(textbox.Text);
                    }
                    textbox.FileName = textbox.Text;
                }
                else if (ctrl is AutoDatetime)
                {
                    AutoDatetime dtp = ctrl as AutoDatetime;
                    if (dtp.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        continue;
                    }
                    bindingname = dtp.BindingName;
                    val         = GetPropertyValue(bindingname, obj);
                    dtp.Value   = val != null?Convert.ToDateTime(val) : UtilityFunction.minDate;
                }
                else if (ctrl is AutoXDatetime)
                {
                    AutoXDatetime dtp = ctrl as AutoXDatetime;
                    if (dtp.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        continue;
                    }
                    bindingname  = dtp.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    dtp.DateTime = val != null?Convert.ToDateTime(val) : UtilityFunction.minDate;
                }
                else if (ctrl is AutoPictureBox)
                {
                    AutoPictureBox ptb = ctrl as AutoPictureBox;
                    if (ptb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(ptb.BindingName))
                    {
                        continue;
                    }
                    bindingname     = ptb.BindingName;
                    val             = GetPropertyValue(bindingname, obj);
                    ptb.PictureName = val != null?val.ToString() : "";

                    ptb.Image = PictureUtility.GetImg(ptb.PictureName);
                    if (ptb.Image == null)
                    {
                        ptb.Image = TmTech_v1.Properties.Resources.unknow;
                    }
                    ptb.SizeMode = PictureBoxSizeMode.StretchImage;
                }
                else if (ctrl is AutoCombobox)
                {
                    AutoCombobox cbb = ctrl as AutoCombobox;
                    if (cbb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(cbb.BindingName))
                    {
                        continue;
                    }
                    bindingname       = cbb.BindingName;
                    val               = GetPropertyValue(bindingname, obj);
                    cbb.SelectedValue = val != null?Convert.ToInt32(val) : 0;
                }
                else if (ctrl is AutoSearchCombobox)
                {
                    AutoSearchCombobox cbb = ctrl as AutoSearchCombobox;
                    if (cbb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(cbb.BindingName))
                    {
                        continue;
                    }
                    bindingname = cbb.BindingName;
                    val         = GetPropertyValue(bindingname, obj);
                    if (cbb.GetSelectedText == true)
                    {
                        cbb.Text = val != null?val.ToString() : "";
                    }
                    else
                    {
                        cbb.SelectedValue = val != null?Convert.ToInt32(val) : 0;
                    }
                }
                else if (ctrl is AutoMaterialCheckBox)
                {
                    AutoMaterialCheckBox cb = ctrl as AutoMaterialCheckBox;
                    if (cb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(cb.BindingName))
                    {
                        continue;
                    }
                    bindingname = cb.BindingName;
                    val         = GetPropertyValue(bindingname, obj);
                    cb.Checked  = val == null ? false : Convert.ToBoolean(val);
                }
                if (ctrl.Controls.Count > 0)
                {
                    SetAutoBindingData(ctrl, obj);
                }
            }
        }
示例#6
0
 public FrmInputBank(AutoTextBox textboxInput)
 {
     m_texbox = textboxInput;
     InitializeComponent();
     lableMessage.Text = "";
 }