public override bool UpdateItem(ContentItem item, Control editor)
        {
            TextBox tb = (TextBox)editor;

            string[] rows = tb.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            for (int i = item.Children.Count - 1; i >= 0; --i)
            {
                int index = Array.FindIndex(rows, delegate(string row)
                {
                    return(row == item.Children[i].Title);
                }
                                            );
                if (index < 0)
                {
                    Context.Persister.Delete(item.Children[i]);
                }
            }
            for (int i = 0; i < rows.Length; i++)
            {
                ContentItem child = FindChild(item, rows[i]);
                if (child == null)
                {
                    child       = new Option();
                    child.Title = rows[i];
                    child.AddTo(item);
                }
                child.SortOrder = i;
            }

            return(true);
        }
Beispiel #2
0
        public override bool UpdateItem(IEditableObject itemTemp, Control editor)
        {
            ContentItem item = (ContentItem)itemTemp;
            TextBox tb = (TextBox)editor;
            string[] rows = tb.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            for (int i = item.Children.Count - 1; i >= 0; --i)
            {
                int index = Array.FindIndex(rows, row => row == item.Children[i].Title);
                if (index < 0)
                    Context.Persister.Delete(item.Children[i]);
            }
            for (int i = 0; i < rows.Length; i++)
            {
                ContentItem child = FindChild(item, rows[i]);
                if (child == null)
                {
                    child = new Option { Title = rows[i] };
                    child.AddTo(item);
                }
                child.SortOrder = i;
            }

            return true;
        }