[a235fd]: SQLite.Designer / Design / Check.cs  Maximize  Restore  History

Download this file

99 lines (89 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/********************************************************
* ADO.NET 2.0 Data Provider for SQLite Version 3.X
* Written by Robert Simpson (robert@blackcastlesoft.com)
*
* Released to the public domain, use at your own risk!
********************************************************/
namespace SQLite.Designer.Design
{
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Windows.Forms;
internal class CheckEditor : CollectionEditor
{
Table _table;
CollectionEditor.CollectionForm _form;
object[] _items;
object[] _orig;
int _count;
internal CheckEditor(Table parent)
: base(typeof(List<string>))
{
_table = parent;
}
protected override CollectionEditor.CollectionForm CreateCollectionForm()
{
_form = base.CreateCollectionForm();
_form.Text = "CHECK Constraint Editor";
_form.Width = (int)(_form.Width * 1.25);
_form.Height = (int)(_form.Height * 1.25);
return _form;
}
protected override object CreateInstance(Type itemType)
{
if (itemType == typeof(string)) return String.Empty;
return base.CreateInstance(itemType);
}
protected override object[] GetItems(object editValue)
{
if (_items == null)
{
List<string> items = editValue as List<string>;
_items = new object[items.Count];
_orig = new object[items.Count];
for (int n = 0; n < _items.Length; n++)
{
_items[n] = items[n];
_orig[n] = items[n];
}
_count = _items.Length;
}
return _items;
}
protected override object SetItems(object editValue, object[] value)
{
bool dirty = false;
if (editValue != null)
{
if (!(editValue is IList))
{
return editValue;
}
IList list = (IList)editValue;
list.Clear();
for (int i = 0; i < value.Length; i++)
{
string val = value[i] as string;
if (String.IsNullOrEmpty(val) == false)
{
list.Add(val);
if (i < _orig.Length && val != (string)_orig[i])
dirty = true;
}
}
if (list.Count != _count)
dirty = true;
if (dirty == true && _form.DialogResult == DialogResult.OK)
_table._owner.MakeDirty();
}
return editValue;
}
}
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks