-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListView.cs
168 lines (126 loc) · 2.88 KB
/
ListView.cs
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* Created by SharpDevelop.
* User: anton
* Date: 19.11.2010
* Time: 3:01
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace LinkedListLab
{
/// <summary>
/// Description of ListView.
/// </summary>
public partial class ListView : UserControl
{
SingleLinkedList list;
public bool Editable = true;
public ListView()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
public ListView(int[] d)
{
InitializeComponent();
}
void AddBtnClick(object sender, EventArgs e)
{
itemsTlp.RowCount++;
TextBox tb = new TextBox();
tb.Width = 30;
itemsTlp.Controls.Add(tb);
}
void Button1Click(object sender, EventArgs e)
{
if (itemsTlp.Controls.Count>0){
itemsTlp.Controls.RemoveAt(itemsTlp.Controls.Count-1);
}
}
public SingleLinkedList GetList(){
SingleLinkedList list = new SingleLinkedList();
try {
foreach(TextBox c in itemsTlp.Controls) {
list.InsertAfterLast(int.Parse(c.Text));
}
}
catch {}
// TODO: обновление поля list при добавлении нового элемента в список, а не при вызове GetList
this.list = list;
return list;
}
public void SetList(SingleLinkedList list){
SuspendLayout();
this.list = list;
Node p = list.First;
while(p!=null){
TextBox tb = new TextBox();
tb.Text = p.Info.ToString();
tb.Width = 30;
this.itemsTlp.Controls.Add(tb);
p = p.Link;
}
ResumeLayout();
}
void ListViewClick(object sender, EventArgs e)
{
MessageBox.Show(this.GetList().ToString());
}
void Button2Click(object sender, EventArgs e)
{
MessageBox.Show(this.GetList().ToString());
}
void ListViewLoad(object sender, EventArgs e)
{
}
void TlpPaint(object sender, PaintEventArgs e)
{
}
void GbEnter(object sender, EventArgs e)
{
if (Editable)
controlsTlp.Show();
}
void TmTick(object sender, EventArgs e)
{
controlsTlp.Height+=20;
}
void GbLeave(object sender, EventArgs e)
{
controlsTlp.Hide();
}
void TlpEnter(object sender, EventArgs e)
{
}
void GbMouseHover(object sender, EventArgs e)
{
if (Editable)
controlsTlp.Show();
}
void ItemsTlpMouseHover(object sender, EventArgs e)
{
if (Editable)
controlsTlp.Show();
}
void ItemsTlpMouseLeave(object sender, EventArgs e)
{
}
void TlpMouseHover(object sender, EventArgs e)
{
if (Editable)
controlsTlp.Show();
}
void TlpMouseLeave(object sender, EventArgs e)
{
}
}
}