Exemplo n.º 1
0
        private List<DictionaryEntry> GetControlValues(ControlCollection collection)
        {
            List<DictionaryEntry> list = new List<DictionaryEntry>();
            if (this.DesignMode)
            {
                foreach (Control ct in collection)
                {
                    PropertyInfo[] pis = ct.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                    for (int i = 0; i < pis.Length; i++)
                    {
                        if (pis[i].PropertyType == typeof(string))
                        {
                            if (string.Compare(pis[i].Name, "Text", true) == 0 || string.Compare(pis[i].Name, "ToolTip", true) == 0)
                            {
                                list.Add(new DictionaryEntry(string.Format("{0}.{1}", ct.ID, pis[i].Name)
                                    , pis[i].GetValue(ct, null).ToString()));
                            }
                        }
                    }
                    if (ct is JQDataForm)
                    {
                        JQDataForm ctrl = ct as JQDataForm;
                        for (int i = 0; i < ctrl.Columns.Count; i++)
                        {
                            list.Add(new DictionaryEntry(string.Format("{0}.{1}.Caption", ct.ID, ctrl.Columns[i].FieldName), String.IsNullOrEmpty(ctrl.Columns[i].Caption) ? ctrl.Columns[i].FieldName : ctrl.Columns[i].Caption));
                            switch (ctrl.Columns[i].Editor)
                            {
                                case "flipswitch":
                                    JQFlipSwitch jfs = new JQFlipSwitch();
                                    jfs.LoadProperties(ctrl.Columns[i].EditorOptions);
                                    list.Add(new DictionaryEntry(string.Format("{0}.{1}.flipswitch.OnText", ct.ID, ctrl.Columns[i].FieldName), jfs.OnText));
                                    list.Add(new DictionaryEntry(string.Format("{0}.{1}.flipswitch.OffText", ct.ID, ctrl.Columns[i].FieldName), jfs.OffText));
                                    break;
                                case "refval":
                                    JQRefval jr = new JQRefval();
                                    jr.LoadProperties(ctrl.Columns[i].EditorOptions);
                                    list.Add(new DictionaryEntry(string.Format("{0}.{1}.refval.DialogTitle", ct.ID, ctrl.Columns[i].FieldName), jr.DialogTitle));
                                    for (int j = 0; j < jr.Columns.Count; j++)
                                    {
                                        list.Add(new DictionaryEntry(string.Format("{0}.{1}.refval.Caption.{2}", ct.ID, ctrl.Columns[i].FieldName, jr.Columns[j].FieldName), String.IsNullOrEmpty(jr.Columns[j].Caption) ? jr.Columns[j].FieldName : jr.Columns[j].Caption));
                                    }
                                    break;
                            }
                        }
                    }
                    if (ct is JQDataGrid)
                    {
                        JQDataGrid ctrl = ct as JQDataGrid;
                        for (int i = 0; i < ctrl.Columns.Count; i++)
                        {
                            list.Add(new DictionaryEntry(string.Format("{0}.{1}.Caption", ct.ID, ctrl.Columns[i].FieldName), String.IsNullOrEmpty(ctrl.Columns[i].Caption) ? ctrl.Columns[i].FieldName : ctrl.Columns[i].Caption));
                        }
                        for (int i = 0; i < ctrl.QueryColumns.Count; i++)
                        {
                            list.Add(new DictionaryEntry(string.Format("{0}.{1}.QueryColumnCaption{2}", ct.ID, ctrl.QueryColumns[i].FieldName, ctrl.QueryColumns[i].Condition), String.IsNullOrEmpty(ctrl.QueryColumns[i].Caption) ? ctrl.QueryColumns[i].FieldName : ctrl.QueryColumns[i].Caption));
                        }
                        list.Add(new DictionaryEntry(string.Format("{0}.Title", ct.ID), ctrl.Title));
                    }
                    if (ct is JQValidate)
                    {
                        JQValidate ctrl = ct as JQValidate;
                        for (int i = 0; i < ctrl.Columns.Count; i++)
                        {
                            if (!String.IsNullOrEmpty(ctrl.Columns[i].CheckMethod))
                                list.Add(new DictionaryEntry(string.Format("{0}.{1}.ValidateMessage", ct.ID, ctrl.Columns[i].FieldName), ctrl.Columns[i].ValidateMessage));
                        }
                    }

                    if (ct.Controls.Count > 0)
                    {
                        list.AddRange(GetControlValues(ct.Controls));
                    }
                }
            }
            return list;
        }
Exemplo n.º 2
0
        private void ApplyColumnCaption(object value, string objectName)
        {
            if (value == null || objectName == null)
            {
                return;
            }

            XmlNode nodelanguage = GetLanguageNode();

            if (nodelanguage != null && nodelanguage.ChildNodes.Count > 0)
            {
                XmlNode nodefield = nodelanguage.FirstChild;
                while (nodefield != null)
                {
                    string strfield = nodefield.Attributes["field"].Value;
                    string strvalue = nodefield.Attributes["value"].Value;
                    if (string.CompareOrdinal(strfield, 0, objectName, 0, objectName.Length) == 0)
                    {
                        if (strfield.Length >= objectName.Length && strfield[objectName.Length] == '.')
                        {
                            string strfield2 = strfield.Substring(objectName.Length + 1);
                            if (value is JQDataGrid)
                            {
                                foreach (JQGridColumn dc in ((JQDataGrid)value).Columns)
                                {
                                    if (objectName + "." + dc.FieldName + ".Caption" == strfield)
                                    {
                                        dc.Caption = strvalue;
                                        break;
                                    }
                                }
                                foreach (JQQueryColumn dc in ((JQDataGrid)value).QueryColumns)
                                {
                                    if (objectName + "." + dc.FieldName + ".QueryColumnCaption" + dc.Condition == strfield)
                                    {
                                        dc.Caption = strvalue;
                                        break;
                                    }
                                }

                                if (objectName + "." + "Title" == strfield)
                                {
                                    (value as JQDataGrid).Title = strvalue;
                                }
                            }
                            else if (value is JQDataForm)
                            {
                                foreach (JQFormColumn dc in ((JQDataForm)value).Columns)
                                {
                                    if (objectName + "." + dc.FieldName + ".Caption" == strfield)
                                    {
                                        dc.Caption = strvalue;
                                        break;
                                    }
                                    var keys = strfield.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                                    if (strfield.StartsWith(objectName + "." + dc.FieldName) && keys.Length > 3)
                                    {
                                        switch (dc.Editor)
                                        {
                                            case "flipswitch":
                                                JQFlipSwitch jfs = new JQFlipSwitch();
                                                jfs.LoadProperties(dc.EditorOptions);
                                                if (keys[3] == "OnText")
                                                    dc.EditorOptions = dc.EditorOptions.Replace(String.Format("OnText:'{0}'", jfs.OnText), String.Format("OnText:'{0}'", strvalue));
                                                else if (keys[3] == "OffText")
                                                    dc.EditorOptions = dc.EditorOptions.Replace(String.Format("OffText:'{0}'", jfs.OffText), String.Format("OffText:'{0}'", strvalue));
                                                break;
                                            case "refval":
                                                JQRefval jr = new JQRefval();
                                                jr.LoadProperties(dc.EditorOptions);
                                                if (keys[3] == "DialogTitle")
                                                    dc.EditorOptions = dc.EditorOptions.Replace(String.Format("DialogTitle:'{0}'", jr.DialogTitle), String.Format("DialogTitle:'{0}'", strvalue));
                                                else if (keys[3] == "Caption")
                                                {
                                                    for (int j = 0; j < jr.Columns.Count; j++)
                                                    {
                                                        if (jr.Columns[j].FieldName == keys[4])
                                                            dc.EditorOptions = dc.EditorOptions.Replace(String.Format("Caption:'{0}'", jr.Columns[j].Caption), String.Format("Caption:'{0}'", strvalue));
                                                    }
                                                }
                                                break;
                                        }
                                        break;
                                    }
                                }
                            }
                            else if (value is JQValidate)
                            {
                                foreach (JQValidateColumn dc in ((JQValidate)value).Columns)
                                {
                                    if (objectName + "." + dc.FieldName + ".ValidateMessage" == strfield)
                                    {
                                        dc.ValidateMessage = strvalue;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    nodefield = nodefield.NextSibling;
                }
            }
        }