示例#1
0
        internal void LoadProperties(string value)
        {
            if (!string.IsNullOrEmpty((string)value))
            {
                var options = ((string)value).Split(',');
                var op = string.Empty;
                foreach (var option in options)
                {
                    if (op.Length > 0)
                    {
                        op += ',';
                    }
                    op += option;
                    if (op.Split('{').Length != op.Split('}').Length)
                    {
                        continue;
                    }
                    if (op.Split('[').Length != op.Split(']').Length)
                    {
                        continue;
                    }
                    var index = op.IndexOf(':');

                    if (index > 0)
                    {
                        var pname = op.Substring(0, index).Trim();
                        var pvalue = op.Substring(index + 1).Trim('\'');
                        if (pname == "title")
                        {
                            this.DialogTitle = pvalue;
                        }
                        else if (pname == "panelWidth")
                        {
                            try
                            {
                                this.DialogWidth = int.Parse(pvalue);
                            }
                            catch
                            { }
                        }
                        else if (pname == "columnCount")
                        {
                            try
                            {
                                this.ColumnCount = int.Parse(pvalue);
                            }
                            catch
                            { }
                        }
                        else if (pname == "multiSelect")
                        {
                            bool b = false;
                            if (Boolean.TryParse(pvalue, out b))
                            {
                                this.MultiSelect = b;
                            }
                        }
                        else if (pname == "openDialog")
                        {
                            bool b = false;
                            if (Boolean.TryParse(pvalue, out b))
                            {
                                this.OpenDialog = b;
                            }
                        }
                        else if (pname == "selectAll")
                        {
                            bool b = false;
                            if (Boolean.TryParse(pvalue, out b))
                            {
                                this.SelectAll = b;
                            }
                        }
                        else if (pname == "remoteName")
                        {
                            this.RemoteName = pvalue;
                        }
                        else if (pname == "valueField")
                        {
                            this.ValueMember = pvalue;
                        }
                        else if (pname == "textField")
                        {
                            this.DisplayMember = pvalue;
                        }
                        else if (pname == "onSelect")
                        {
                            this.OnSelect = pvalue;
                        }
                        else if (pname == "selectOnly")
                        {
                            bool vselectonly = false;
                            Boolean.TryParse(pvalue, out vselectonly);
                            this.SelectOnly = vselectonly;
                        }
                        else if (pname == "onWhere")
                        {
                            this.OnWhere = pvalue;
                        }
                        else if (pname == "items")
                        {
                            var items = pvalue.Trim('[', ']');
                            var matches = Regex.Matches(items, @"(?<=\{).*?(?=\})");
                            if (matches.Count > 0)
                            {
                                foreach (Match match in matches)
                                {
                                    var item = new JQComboItem();
                                    var columnOptions = match.Value.Split(',');
                                    foreach (var cop in columnOptions)
                                    {
                                        var cparts = cop.Split(':');
                                        if (cparts.Length == 2)
                                        {
                                            var cpname = cparts[0].Trim();
                                            var cpvalue = cparts[1].Trim('\'');
                                            if (cpname == "text")
                                            {
                                                item.Text = cpvalue;
                                            }
                                            else if (cpname == "value")
                                            {
                                                item.Value = cpvalue;
                                            }
                                        }
                                    }
                                    this.Items.Add(item);
                                }
                            }
                        }

                    }
                    op = string.Empty;
                }
            }
        }
示例#2
0
        internal void LoadProperties(string value)
        {
            if (!string.IsNullOrEmpty((string)value))
            {
                var options = ((string)value).Split(',');
                var op = string.Empty;
                foreach (var option in options)
                {
                    if (op.Length > 0)
                    {
                        op += ',';
                    }
                    op += option;
                    if (op.Split('{').Length != op.Split('}').Length)
                    {
                        continue;
                    }
                    if (op.Split('[').Length != op.Split(']').Length)
                    {
                        continue;
                    }
                    var index = op.IndexOf(':');

                    if (index > 0)
                    {
                        var pname = op.Substring(0, index).Trim();
                        var pvalue = op.Substring(index + 1).Trim('\'');

                        if (pname == "remoteName")
                        {
                            this.RemoteName = pvalue;
                        }
                        else if (pname == "textField")
                        {
                            this.DisplayMember = pvalue;
                        }
                        else if (pname == "valueField")
                        {
                            this.ValueMember = pvalue;
                        }
                        else if (pname == "onSelect")
                        {
                            this.OnSelect = pvalue;
                        }
                        else if (pname == "onBeforeLoad")
                        {
                            this.OnBeforeLoad = pvalue;
                        }
                        else if (pname == "checkData")
                        {
                            bool b = false;
                            if (Boolean.TryParse(pvalue, out b))
                            {
                                this.CheckData = b;
                            }

                        }
                        else if (pname == "selectOnly")
                        {
                            bool b = false;
                            if (Boolean.TryParse(pvalue, out b))
                            {
                                this.SelectOnly = b;
                            }

                        }
                        else if (pname == "cacheRelationText")
                        {
                            bool vcacheRelationText = true;
                            Boolean.TryParse(pvalue, out vcacheRelationText);
                            this.CacheRelationText = vcacheRelationText;
                        }
                        else if (pname == "items")
                        {
                            var columns = pvalue.Trim('[', ']');
                            var matches = Regex.Matches(columns, @"(?<=\{).*?(?=\})");
                            if (matches.Count > 0)
                            {
                                foreach (Match match in matches)
                                {
                                    var item = new JQComboItem();
                                    var itemOptions = match.Value.Split(',');
                                    foreach (var cop in itemOptions)
                                    {
                                        var cparts = cop.Split(':');
                                        if (cparts.Length >= 2)
                                        {
                                            var cpname = cparts[0].Trim();
                                            var cpvalue = cop.Substring(cpname.Length+1).Trim('\'');
                                            if (cpname == "value")
                                            {
                                                item.Value = cpvalue;
                                            }
                                            else if (cpname == "text")
                                            {
                                                item.Text = cpvalue;
                                            }
                                            else if (cpname == "selected")
                                            {
                                                try
                                                {
                                                    item.Selected = bool.Parse(cpvalue);
                                                }
                                                catch { }
                                            }
                                        }
                                    }
                                    this.Items.Add(item);
                                }
                            }
                        }
                        else if (pname == "pageSize")
                        {
                            int i = 0;
                            if (Int32.TryParse(pvalue, out i))
                                this.PageSize = i;
                        }
                        else if (pname == "panelHeight")
                        {
                            int i = 0;
                            if (Int32.TryParse(pvalue, out i))
                                this.PanelHeight = i;
                        }
                    }
                    op = string.Empty;
                }
            }
        }