-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathLocationEditControl.cs
2425 lines (2007 loc) · 77.4 KB
/
LocationEditControl.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Diagnostics;
using DigitalPlatform.Text;
/*
* TODO:
* 1) 应提供菜单可以增删行,进而触发CountChanged事件和ContentChanged事件
* 2) 可改为平时绘制控件外貌,当点到某行的时候再真正创建这一行的控件
*
* */
namespace DigitalPlatform.CommonControl
{
/// <summary>
/// 馆藏去向 编辑控件
/// </summary>
public partial class LocationEditControl : UserControl
{
// 以前曾用过的地点名。为了实现去掉后又重新要新增时,回到原来的文字
List<string> UsedText = new List<string>();
internal bool m_bFocused = false;
bool m_bHideSelection = true;
/// <summary>
/// 内容发生改变
/// </summary>
public event ContentChangedEventHandler ContentChanged = null;
// 验收已到checkbox状态改变
[Category("New Event")]
public event EventHandler ArrivedChanged = null;
// ReadOnly状态发生改变
[Category("New Event")]
public event EventHandler ReadOnlyChanged = null;
public LocationItem LastClickItem = null; // 最近一次click选择过的LocationItem对象
public string DbName = ""; // 数据库名。用于获得值列表
/// <summary>
/// 获得值列表
/// </summary>
public event GetValueTableEventHandler GetValueTable = null;
int m_nLineHeight = 26;
internal int m_nLabelWidth = 40; // 26
internal int m_nLocationWidth = 160;
internal int m_nArrivedWidth = 40;
internal int m_nLineLeftBlank = 6; // 线条部分左边的空白宽度
internal int m_nLineWidth = 6; // 线条横线部分的宽度
internal int m_nNumberTextWidth = 20; // 线条横线右边的数字文字的宽度
internal int m_nRightBlank = 4; // 30
public List<LocationItem> LocationItems = new List<LocationItem>();
bool m_bChanged = false;
public LocationEditControl()
{
InitializeComponent();
// 2017/1/27
SetDpiXY(DpiUtil.GetDpiXY(this));
}
internal SizeF DpiXY = new SizeF(96, 96);
public void SetDpiXY(SizeF dpi_xy)
{
this.DpiXY = dpi_xy;
m_nLineHeight = DpiUtil.GetScalingY(dpi_xy, 26);
m_nLabelWidth = DpiUtil.GetScalingX(dpi_xy, 40);
m_nLocationWidth = DpiUtil.GetScalingX(dpi_xy, 160);
m_nArrivedWidth = DpiUtil.GetScalingX(dpi_xy, 40);
m_nLineLeftBlank = DpiUtil.GetScalingX(dpi_xy, 6);
m_nLineWidth = DpiUtil.GetScalingX(dpi_xy, 6);
m_nNumberTextWidth = DpiUtil.GetScalingX(dpi_xy, 20);
m_nRightBlank = DpiUtil.GetScalingX(dpi_xy, 4);
}
bool m_bArriveMode = false;
// 是否为验收模式? true表示为验收模式,false表示为订购模式
[Category("Appearance")]
[DescriptionAttribute("ArriveMode")]
[DefaultValue(false)]
public bool ArriveMode
{
get
{
return this.m_bArriveMode;
}
set
{
this.m_bArriveMode = value;
// SetArriveMode(value);
}
}
// 加工id列表,只取得指定数目以内的id构成新列表
static string LimitIDs(string strIDs,
int nCount)
{
if (String.IsNullOrEmpty(strIDs) == true)
return "";
string[] ids = strIDs.Split(new char[] { ',' });
if (ids.Length <= nCount)
return strIDs;
string strResult = "";
for (int i = 0; i < nCount; i++)
{
if (i != 0)
strResult += ",";
strResult += ids[i];
}
return strResult;
}
// 规范馆藏地点字符串,限定其包含的事项个数
// 加工方法是如果有多余的事项就裁减掉,如果缺乏事项就增补上
public static string CanonicalizeDistributeString(
string strDistributeString,
int nAmount)
{
string strResult = "";
int nCurrent = 0;
string[] sections = strDistributeString.Split(new char[] { ';' });
for (int i = 0; i < sections.Length; i++)
{
string strSection = sections[i].Trim();
if (String.IsNullOrEmpty(strSection) == true)
continue;
string strIDs = ""; // 已验收id列表
string strLocationString = "";
int nCount = 0;
int nRet = strSection.IndexOf(":");
if (nRet == -1)
{
strLocationString = strSection;
nCount = 1;
}
else
{
strLocationString = strSection.Substring(0, nRet).Trim();
string strCount = strSection.Substring(nRet + 1);
nRet = strCount.IndexOf("{");
if (nRet != -1)
{
strIDs = strCount.Substring(nRet + 1).Trim();
if (strIDs.Length > 0 && strIDs[strIDs.Length - 1] == '}')
strIDs = strIDs.Substring(0, strIDs.Length - 1);
strCount = strCount.Substring(0, nRet).Trim();
}
try
{
nCount = Convert.ToInt32(strCount);
}
catch
{
throw new Exception("'" + strCount + "' 应为纯数字");
}
if (nCount > 1000)
throw new Exception("数字太大,超过1000");
}
if (nCurrent + nCount > nAmount)
{
if (nAmount - nCurrent > 0)
{
if (strResult != "")
strResult += ";";
strResult += strLocationString + ":" + (nAmount - nCurrent).ToString();
string strPart = LimitIDs(strIDs, nAmount - nCurrent);
if (LocationCollection.IsEmptyIDs(strPart) == false)
strResult += "{" + strPart + "}";
}
nCurrent += nAmount - nCurrent;
break;
}
if (strResult != "")
strResult += ";";
strResult += strLocationString + ":" + nCount.ToString();
{
string strPart = LimitIDs(strIDs, nCount);
if (LocationCollection.IsEmptyIDs(strPart) == false)
strResult += "{" + strPart + "}";
}
nCurrent += nCount;
}
// 如果不足则增补
if (nCurrent < nAmount)
{
if (strResult != "")
strResult += ";";
strResult += "" + ":" + (nAmount - nCurrent).ToString();
// ids不用了
}
return strResult;
}
public bool HideSelection
{
get
{
return this.m_bHideSelection;
}
set
{
if (this.m_bHideSelection != value)
{
this.m_bHideSelection = value;
this.RefreshLineColor(); // 迫使颜色改变
}
}
}
bool m_bReadOnly = false;
// 全体Item的ReadOnly状态
public bool ReadOnly
{
get
{
return this.m_bReadOnly;
}
set
{
bool bOldValue = this.m_bReadOnly;
if (bOldValue != value)
{
this.m_bReadOnly = value;
for (int i = 0; i < this.LocationItems.Count; i++)
{
LocationItem item = this.LocationItems[i];
/*
if (value == true)
item.comboBox_location.Enabled = false;
else
item.comboBox_location.Enabled = true;
* */
item.ReadOnly = value;
}
this.OnReadOnlyChanged();
}
}
}
public LocationItem InsertNewItem(int index)
{
LocationItem item = new LocationItem(this);
this.LocationItems.Insert(index, item);
item.State = ItemState.New;
this.SetSize();
this.LayoutItems();
return item;
}
// 删除一个事项
// 2008/9/16
public void RemoveItem(int index,
bool bUpdateDisplay)
{
LocationItem line = this.LocationItems[index];
line.RemoveFromContainer();
this.LocationItems.Remove(line);
/*
if (this.LastClickItem == line)
this.LastClickItem = null;
* */
this.Changed = true;
if (bUpdateDisplay == true)
{
this.SetSize();
this.LayoutItems();
}
}
// 删除一个事项
// 2008/9/16
public void RemoveItem(LocationItem line,
bool bUpdateDisplay)
{
int index = this.LocationItems.IndexOf(line);
if (index == -1)
return;
line.RemoveFromContainer();
this.LocationItems.Remove(line);
/*
if (this.LastClickItem == line)
this.LastClickItem = null;
* */
this.Changed = true;
if (bUpdateDisplay == true)
{
this.SetSize();
this.LayoutItems();
}
}
// 将已经勾选的、具有ref id的事项设置为ReadOnly状态
// 2008/9/13
// parameters:
// bClearAllReadOnlyBeforeSet 是否在设置前清除已有的readonly状态
public void SetAlreadyCheckedToReadOnly(bool bClearAllReadOnlyBeforeSet)
{
bool bChanged = false;
for (int i = 0; i < this.LocationItems.Count; i++)
{
LocationItem item = this.LocationItems[i];
if (item.checkBox_arrived.Checked == true
&& String.IsNullOrEmpty(item.ArrivedID) == false)
{
if (item.ReadOnly != true && item.ArrivedID != "*") // 2008/12/25 changed
{
item.ReadOnly = true;
bChanged = true;
}
}
else
{
if (bClearAllReadOnlyBeforeSet == true)
{
if (item.ReadOnly != false)
{
item.ReadOnly = false;
bChanged = true;
}
}
}
}
if (this.m_bReadOnly != false)
{
this.m_bReadOnly = false; // 不是全部事项都为ReadOnly
bChanged = true;
}
if (bChanged == true)
this.OnReadOnlyChanged();
// 会出现这样一种情况:全部item都是readonly了,但是container不是readonly状态。
// 这种状态意味着还可以新增加item。而整个container为readonly的时候,是不允许向里面加入任何新item的了
}
/// <summary>
/// 内容是否发生过修改
/// </summary>
public bool Changed
{
get
{
return this.m_bChanged;
}
set
{
bool bOldValue = this.m_bChanged;
if (this.m_bChanged != value)
{
this.m_bChanged = value;
if (value == false)
ResetLineState();
// 触发事件
if (bOldValue != value && this.ContentChanged != null)
{
ContentChangedEventArgs e = new ContentChangedEventArgs();
e.OldChanged = bOldValue;
e.CurrentChanged = value;
ContentChanged(this, e);
}
}
}
}
internal void OnArrivedChanged()
{
if (this.ArrivedChanged != null)
{
this.ArrivedChanged(this, new EventArgs());
}
}
internal void OnReadOnlyChanged()
{
if (this.ReadOnlyChanged != null)
{
this.ReadOnlyChanged(this, new EventArgs());
}
}
// 进行检查
// return:
// -1 函数运行出错
// 0 检查没有发现错误
// 1 检查发现了错误
public int Check(out string strError)
{
strError = "";
bool bStrict = true; // 是否严格检查
if (bStrict == true)
{
for (int i = 0; i < this.LocationItems.Count; i++)
{
LocationItem element = this.LocationItems[i];
if (String.IsNullOrEmpty(element.LocationString) == true)
{
if (this.LocationItems.Count == 1)
strError = "尚未指定确切的馆藏地点"; // 只有一行的情况,避免提示行号。这样可以让本控件嵌入 OrderDesignControl 时的提示清爽一些 2014/8/29
else
strError = "馆藏事项第 " + (i + 1).ToString() + " 行: 尚未指定确切的馆藏地点";
return 1;
}
}
}
return 0;
}
// 把全部事项的状态设置为Normal
void ResetLineState()
{
for (int i = 0; i < this.LocationItems.Count; i++)
{
LocationItem element = this.LocationItems[i];
element.State = ItemState.Normal;
}
}
void RefreshLineColor()
{
for (int i = 0; i < this.LocationItems.Count; i++)
{
LocationItem element = this.LocationItems[i];
element.SetLineColor();
}
}
void ClearItems()
{
if (this.LocationItems != null)
{
List<LocationItem> items = new List<LocationItem>();
foreach (LocationItem item in this.LocationItems)
{
#if NO
if (item != null)
item.Dispose();
#endif
if (item != null)
items.Add(item);
}
this.LocationItems.Clear();
foreach (LocationItem item in items)
{
item.Dispose();
}
}
}
public void Clear()
{
// this.LocationItems.Clear();
this.ClearItems();
List<Control> controls = new List<Control>();
while (this.panel_main.Controls.Count != 0)
{
Control control = this.panel_main.Controls[0];
this.panel_main.Controls.RemoveAt(0);
if (control != null)
controls.Add(control);
}
foreach (Control control in controls)
{
control.Dispose();
}
}
public void SelectAll()
{
for (int i = 0; i < this.LocationItems.Count; i++)
{
LocationItem cur_element = this.LocationItems[i];
if ((cur_element.State & ItemState.Selected) == 0)
cur_element.State |= ItemState.Selected;
}
}
public void SelectItem(LocationItem element,
bool bClearOld)
{
if (bClearOld == true)
{
for (int i = 0; i < this.LocationItems.Count; i++)
{
LocationItem cur_element = this.LocationItems[i];
if (cur_element == element)
continue; // 暂时不处理当前行
if ((cur_element.State & ItemState.Selected) != 0)
cur_element.State -= ItemState.Selected;
}
}
// 选中当前行
if ((element.State & ItemState.Selected) == 0)
element.State |= ItemState.Selected;
this.LastClickItem = element;
}
public void ToggleSelectItem(LocationItem element)
{
// 选中当前行
if ((element.State & ItemState.Selected) == 0)
element.State |= ItemState.Selected;
else
element.State -= ItemState.Selected;
this.LastClickItem = element;
}
public void RangeSelectItem(LocationItem element)
{
LocationItem start = this.LastClickItem;
int nStart = this.LocationItems.IndexOf(start);
if (nStart == -1)
return;
int nEnd = this.LocationItems.IndexOf(element);
if (nStart > nEnd)
{
// 交换
int nTemp = nStart;
nStart = nEnd;
nEnd = nTemp;
}
for (int i = nStart; i <= nEnd; i++)
{
LocationItem cur_element = this.LocationItems[i];
if ((cur_element.State & ItemState.Selected) == 0)
cur_element.State |= ItemState.Selected;
}
// 清除其余位置
for (int i = 0; i < nStart; i++)
{
LocationItem cur_element = this.LocationItems[i];
if ((cur_element.State & ItemState.Selected) != 0)
cur_element.State -= ItemState.Selected;
}
for (int i = nEnd + 1; i < this.LocationItems.Count; i++)
{
LocationItem cur_element = this.LocationItems[i];
if ((cur_element.State & ItemState.Selected) != 0)
cur_element.State -= ItemState.Selected;
}
}
#if NOOOOOOOOOOOOOO
// 将馆藏地点字符串转换为对象列表
static int LocationStringToList(
string value,
LocationEditControl container,
out List<LocationItem> items,
out string strError)
{
strError = "";
items = new List<LocationItem>();
string[] sections = value.Split(new char[] { ';' });
for (int i = 0; i < sections.Length; i++)
{
string strSection = sections[i].Trim();
if (String.IsNullOrEmpty(strSection) == true)
continue;
string strIDs = ""; // 已验收id列表
string strLocationString = "";
int nCount = 0;
int nRet = strSection.IndexOf(":");
if (nRet == -1)
{
strLocationString = strSection;
nCount = 1;
}
else
{
strLocationString = strSection.Substring(0, nRet).Trim();
string strCount = strSection.Substring(nRet + 1);
nRet = strCount.IndexOf("{");
if (nRet != -1)
{
strIDs = strCount.Substring(nRet + 1).Trim();
if (strIDs.Length > 0 && strIDs[strIDs.Length - 1] == '}')
strIDs = strIDs.Substring(0, strIDs.Length - 1);
strCount = strCount.Substring(0, nRet).Trim();
}
try
{
nCount = Convert.ToInt32(strCount);
}
catch
{
strError = "'" + strCount + "' 应为纯数字";
return -1;
}
if (nCount > 1000)
{
strError = "数字太大,超过1000";
return -1;
}
}
for (int j = 0; j < nCount; j++)
{
LocationItem item = new LocationItem(container);
if (container != null)
item.LocationString = strLocationString;
items.Add(item);
}
if (string.IsNullOrEmpty(strIDs) == false)
{
string[] ids = strIDs.Split(new char[] { ',' });
int nStartBase = items.Count - nCount;
for (int k = 0; k < nCount; k++)
{
LocationItem item = items[nStartBase + k];
if (k >= ids.Length)
break;
string strID = ids[k];
if (String.IsNullOrEmpty(strID) == true)
{
// item.Arrived = false;
continue;
}
item.Arrived = true;
item.ArrivedID = strID;
}
}
}
return 0;
}
// 将对象列表转换为馆藏地点字符串
static string ListToLocationString(List<LocationItem> items,
bool bOutputID)
{
string strResult = "";
string strPrevLocationString = null;
int nPartCount = 0;
string strIDs = "";
for (int i = 0; i < items.Count; i++)
{
LocationItem item = items[i];
if (item.LocationString == strPrevLocationString)
{
nPartCount++;
strIDs += item.ArrivedID + ",";
}
else
{
if (strPrevLocationString != null)
{
if (strResult != "")
strResult += ";";
strResult += strPrevLocationString + ":" + nPartCount.ToString();
if (bOutputID == true)
{
if (LocationEditControl.IsEmptyIDs(strIDs) == false)
strResult += "{" + RemoveTailComma(strIDs) + "}";
}
nPartCount = 0;
strIDs = "";
}
nPartCount++;
strIDs += item.ArrivedID + ",";
}
strPrevLocationString = item.LocationString;
}
if (nPartCount != 0)
{
if (strResult != "")
strResult += ";";
strResult += strPrevLocationString + ":" + nPartCount.ToString();
if (bOutputID == true)
{
if (LocationEditControl.IsEmptyIDs(strIDs) == false)
strResult += "{" + RemoveTailComma(strIDs) + "}";
}
}
return strResult;
}
#endif
// 2012/5/18
internal int m_nDontMerge = 0;
// 字符串形态表达的内容
// 分号间隔每个segment。segment的内部结构是: 馆藏地点:份数{已到记录id罗列}
// '已到记录罗列'的格式为:逗号分隔的字符串。如果某个值为空,其后部的逗号不能省略
public string Value
{
get
{
// this.Merge();
string strResult = "";
string strPrevLocationString = null;
int nPartCount = 0;
string strIDs = "";
// int nIDCount = 0;
for (int i = 0; i < this.LocationItems.Count; i++)
{
LocationItem item = this.LocationItems[i];
if (item.LocationString == strPrevLocationString)
{
nPartCount++;
strIDs += (item.Arrived == true ? item.ArrivedID : "")
+ ",";
/*
if (item.Arrived == true)
nIDCount++;
* */
}
else
{
if (strPrevLocationString != null)
{
Debug.Assert(nPartCount >= 0, "");
if (strResult != "")
strResult += ";";
strResult += strPrevLocationString + ":" + nPartCount.ToString();
if (LocationCollection.IsEmptyIDs(strIDs) == false)
strResult += "{" + LocationCollection.RemoveTailComma(strIDs) + "}";
nPartCount = 0;
strIDs = "";
// nIDCount = 0;
}
nPartCount++;
strIDs += (item.Arrived == true ? item.ArrivedID : "")
+ ",";
/*
if (item.Arrived == true)
nIDCount++;
* */
}
strPrevLocationString = item.LocationString;
}
if (nPartCount != 0)
{
Debug.Assert(nPartCount > 0, "");
if (strResult != "")
strResult += ";";
strResult += strPrevLocationString + ":" + nPartCount.ToString();
if (LocationCollection.IsEmptyIDs(strIDs) == false)
strResult += "{" + LocationCollection.RemoveTailComma(strIDs) + "}";
}
return strResult;
}
set
{
this.Clear();
string[] sections = value.Split(new char[] { ';' });
for (int i = 0; i < sections.Length; i++)
{
string strSection = sections[i].Trim();
if (String.IsNullOrEmpty(strSection) == true)
continue;
string strIDs = ""; // 已验收id列表
string strLocationString = "";
int nCount = 0;
int nRet = strSection.IndexOf(":");
if (nRet == -1)
{
strLocationString = strSection;
nCount = 1;
}
else
{
strLocationString = strSection.Substring(0, nRet).Trim();
string strCount = strSection.Substring(nRet + 1);
nRet = strCount.IndexOf("{");
if (nRet != -1)
{
strIDs = strCount.Substring(nRet + 1).Trim();
if (strIDs.Length > 0 && strIDs[strIDs.Length - 1] == '}')
strIDs = strIDs.Substring(0, strIDs.Length - 1);
strCount = strCount.Substring(0, nRet).Trim();
}
try
{
nCount = Convert.ToInt32(strCount);
}
catch
{
throw new Exception(
"馆藏地点字符串局部 '" + strSection + "' 中 "
+ "'" + strCount + "' 应为纯数字");
}
if (nCount > 1000)
throw new Exception(
"馆藏地点字符串局部 '" + strSection + "' 中 "
+ "数字 " + strCount + " 值太大,超过1000");
// 2008/12/5
if (nCount < 0)
throw new Exception(
"馆藏地点字符串局部 '" + strSection + "' 中 "
+ "数字 " + strCount + " 为负数,格式错误");
Debug.Assert(nCount >= 0, "");
}
this.m_nDontMerge++;
try
{
for (int j = 0; j < nCount; j++)
{
LocationItem item = new LocationItem(this);
item.LocationString = strLocationString;
this.LocationItems.Add(item);
}
}
finally
{
this.m_nDontMerge--;
}
if (string.IsNullOrEmpty(strIDs) == false)
{
Debug.Assert(nCount >= 0, "");
string[] ids = strIDs.Split(new char[] { ',' });
int nStartBase = this.LocationItems.Count - nCount;
for (int k = 0; k < nCount; k++)
{
Debug.Assert((nStartBase + k) >= 0
&& (nStartBase + k) < this.LocationItems.Count,
"");
LocationItem item = this.LocationItems[nStartBase + k];
if (k >= ids.Length)
break;
string strID = ids[k];
if (String.IsNullOrEmpty(strID) == true)
{
// item.Arrived = false;
continue;
}
int nCountSave = this.LocationItems.Count;
item.Arrived = true;
item.ArrivedID = strID;
Debug.Assert(nCountSave == this.LocationItems.Count, "调用前后的count不能变化");
}
}
}
this.ResetLineState();
this.SetSize();
this.LayoutItems();
}
}
internal void SetSize()
{
// 调整容器高度
this.Size = new Size(this.TotalWidth,
this.m_nLineHeight * Math.Max(1, this.LocationItems.Count) + 4/*微调*/);
}
public override Size MaximumSize
{
get
{
Size size = base.MaximumSize;
int nLimitHeight = this.m_nLineHeight * Math.Max(1, this.LocationItems.Count) + 4;
if (size.Height > nLimitHeight