项目 5 补齐:旧版线程 API(Suspend / Resume / Abort)与 ListBox
- 编译时把 Thread 的 Suspend / Resume / Abort、ThreadState、Sleep、new Thread 改写成平台的 协作式实现:被挂起或终止的线程在 Sleep、后台改控件、调设备类库、弹提示框时停下或结束; ThreadStateException 等行为与 .NET Framework 一致;编辑器不再提示"已过时" - ListBox:列表项、单选、SelectedIndexChanged 先于 Click、删除选中项后取消选中; ComboBox 与 ListBox 共用 ListControl 和列表项集合;设计器工具箱加"列表框" - 评分规则的"包含"对列表框检查所有列表项 - 示例:项目 5 任务 2(烟雾,线程)、任务 3(推送灾情,二维数组、两个窗体、ListBox), 参考答案修正书上直接 Abort 挂起线程、烟雾记成"发现火情"的问题 - 一直不换行的 Console 输出攒满 4096 字符先发出,避免占满内存 - 测试:旧版线程 API、ListBox 事件顺序、两个示例的端到端和评分测试 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a92354fe4
commit
91b39603a2
36 files changed
+1653
-105
No files matched your search
@@ -159,6 +159,26 @@ export const CONTROLS: ControlDef[] = [
|
||||
events: [...COMMON_EVENTS, { name: 'SelectedIndexChanged', label: '选中项改变', ...EVENT }, { name: 'DropDown', label: '展开列表', ...EVENT }],
|
||||
initial: () => [['FormattingEnabled', bool(true)], ['Size', size(121, 20)]],
|
||||
},
|
||||
{
|
||||
type: `${FORMS}.ListBox`,
|
||||
label: '列表框',
|
||||
group: '常用控件',
|
||||
namePrefix: 'listBox',
|
||||
defaultEvent: 'SelectedIndexChanged',
|
||||
props: [
|
||||
...COMMON_PROPS.filter((p) => p.name !== 'Text'),
|
||||
{ name: 'Items', label: '列表项', description: '列表里的项,每行一项', type: 'items', category: '数据' },
|
||||
{
|
||||
name: 'BorderStyle', label: '边框', description: '边框', type: 'enum', enumType: `${FORMS}.BorderStyle`,
|
||||
options: ['None', 'FixedSingle', 'Fixed3D'], optionLabels: { None: '无', FixedSingle: '单线', Fixed3D: '立体' }, default: enumValue(`${FORMS}.BorderStyle`, 'Fixed3D'), category: '外观',
|
||||
},
|
||||
],
|
||||
events: [
|
||||
...COMMON_EVENTS.filter((e) => e.name !== 'TextChanged'),
|
||||
{ name: 'SelectedIndexChanged', label: '选中项改变', ...EVENT },
|
||||
],
|
||||
initial: () => [['FormattingEnabled', bool(true)], ['ItemHeight', int(12)], ['Size', size(120, 88)]],
|
||||
},
|
||||
{
|
||||
type: `${FORMS}.CheckBox`,
|
||||
label: '复选框',
|
||||
|
||||
@@ -63,7 +63,7 @@ export function previewTree(doc: DesignerDocument): ControlNode {
|
||||
const props: Record<string, unknown> = { ...DEVICE_DEFAULTS[type], ...propsOf(doc, name) }
|
||||
// 设计时即使 Visible = false 也显示出来(和 VS 一样),方便选中和编辑
|
||||
props.Visible = true
|
||||
if (type === 'System.Windows.Forms.ComboBox') props.Items = getItems(doc, name).map((item) => {
|
||||
if (type === 'System.Windows.Forms.ComboBox' || type === 'System.Windows.Forms.ListBox') props.Items = getItems(doc, name).map((item) => {
|
||||
const v = parseValue(item)
|
||||
return v.kind === 'string' ? v.value : item
|
||||
})
|
||||
|
||||
@@ -48,6 +48,9 @@ function selectItem(index: number) {
|
||||
dropDownOpen.value = false
|
||||
act({ action: 'select', index })
|
||||
}
|
||||
|
||||
// ListBox
|
||||
const itemHeight = computed(() => `${(p.value.ItemHeight as number | undefined) ?? 12}px`)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -108,6 +111,27 @@ function selectItem(index: number) {
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- ListBox:点空白处只触发 Click,点某一项先选中再触发 Click -->
|
||||
<div
|
||||
v-else-if="node.type === 'ListBox'"
|
||||
class="wf-control wf-listbox"
|
||||
:class="[`wf-listbox-border-${p.BorderStyle ?? 'Fixed3D'}`, { 'wf-disabled': !enabled }]"
|
||||
:style="style"
|
||||
@click.self="act({ action: 'click' })"
|
||||
>
|
||||
<div
|
||||
v-for="(item, index) in items"
|
||||
:key="index"
|
||||
class="wf-listbox-item"
|
||||
:class="{ 'wf-listbox-selected': index === p.SelectedIndex }"
|
||||
:style="{ height: itemHeight, lineHeight: itemHeight }"
|
||||
@click="act({ action: 'select', index })"
|
||||
@dblclick="act({ action: 'doubleClick' })"
|
||||
>
|
||||
{{ item }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CheckBox / RadioButton:自绘勾选框,状态完全由运行器决定(点击只上报,不在浏览器里自行切换) -->
|
||||
<div
|
||||
v-else-if="node.type === 'CheckBox' || node.type === 'RadioButton'"
|
||||
|
||||
@@ -151,6 +151,36 @@
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.wf-listbox {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
background: #fff;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.wf-listbox-border-Fixed3D {
|
||||
border: 1px solid #828790;
|
||||
}
|
||||
|
||||
.wf-listbox-border-FixedSingle {
|
||||
border: 1px solid #646464;
|
||||
}
|
||||
|
||||
.wf-listbox-item {
|
||||
padding: 0 2px;
|
||||
white-space: pre;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wf-listbox-selected {
|
||||
background: #0078d7;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.wf-disabled .wf-listbox-selected {
|
||||
background: #bfbfbf;
|
||||
}
|
||||
|
||||
.wf-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in new issue
Block a user