コード例 #1
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        /// <summary>
        /// 确保一个事项处在可见范围
        /// </summary>
        /// <param name="item">EasyItem 对象</param>
        public void EnsureVisible(EasyLine item)
        {
            if (item.Visible == true)
                this.ScrollControlIntoView(item.label_caption);
#if NO
            int[] row_heights = this.tableLayoutPanel_content.GetRowHeights();
            int nYOffs = 0; // row_heights[0];
            int i = 0;  // 1
            foreach (EasyLine cur_item in this.Items)
            {
                if (cur_item == item)
                    break;
                nYOffs += row_heights[i++];
            }

            // this.AutoScrollPosition = new Point(this.AutoScrollOffset.X, 1000);
            if (nYOffs < - this.AutoScrollPosition.Y)
            {
                this.AutoScrollPosition = new Point(this.AutoScrollOffset.X, nYOffs);
            }
            else if (nYOffs + row_heights[i] > - (this.AutoScrollPosition.Y - this.ClientSize.Height))
            {
                // 刚好进入下部
                this.AutoScrollPosition = new Point(this.AutoScrollOffset.X, nYOffs - this.ClientSize.Height + row_heights[i]);
            }
#endif
        }
コード例 #2
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        // 得到上一个可以输入内容的字段或子字段对象
        // parameters:
        //      ref_line    参考的对象。从它前面一个开始获取。如果为 null,表示获取最后一个可编辑的对象
        public EasyLine GetPrevEditableLine(EasyLine ref_line)
        {
            EasyLine line = null;
            foreach (EasyLine item in this.Items)
            {
                if (ref_line != null && ref_line == item)
                    break;

                {
                    if (item.Visible == false)
                        continue;
                    if (item.ExpandState == EasyMarc.ExpandState.Collapsed)
                        continue;
                    if (item.textBox_content.Visible == false)
                        continue;
                    // results.Add(item);
                    line = item;
                }
            }

            return line;
        }
コード例 #3
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        // 得到下一个可以输入内容的字段或子字段对象
        // parameters:
        //      ref_line    参考的对象。从它后面一个开始获取。如果为 null,表示获取第一个可编辑的对象
        public EasyLine GetNextEditableLine(EasyLine ref_line)
        {
            bool bOn = false;
            if (ref_line == null)
                bOn = true;
            foreach (EasyLine item in this.Items)
            {
                if (bOn == false && ref_line == item)
                {
                    bOn = true;
                    continue;
                }

                if (bOn)
                {
                    if (item.Visible == false)
                        continue;
                    if (item.ExpandState == EasyMarc.ExpandState.Collapsed)
                        continue;
                    if (item.textBox_content.Visible == false)
                        continue;
                    return item;
                }
            }

            return null;
        }
コード例 #4
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        /// <summary>
        /// 打开当前按位置的定长模板对话框
        /// </summary>
        public void GetValueFromTemplate(EasyLine line)
        {
            string strError;
            int nRet = 0;

            string strFieldName = "";
            string strFieldValue = "";

            string strSubfieldName = "";
            string strSubfieldValue = "";

            if (line is FieldLine)
            {
                strFieldName = line.Name;
                strFieldValue = line.Content;   // TODO: 如果遇到不是控制字段的,是否要合成字段内容?
            }
            else
            {
                FieldLine field = this.GetFieldLine(line as SubfieldLine);
                strFieldName = field.Name;
                strSubfieldName = line.Name;
                strSubfieldValue = line.Content;
            }

            // int nSubfieldDupIndex = 0;

            string strOutputValue;
            if (strSubfieldName == "")
            {
                // 获取字段的定长模板
                nRet = this.GetValueFromTemplate(strFieldName,
                    "",
                    strFieldValue,
                    out strOutputValue,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    return;
                }

                if (nRet == 0)
                    return;

                // 此处应使用Value
                if (strFieldValue != strOutputValue)
                    line.Content = strOutputValue;

                // 不让小edit全选上
                line.textBox_content.SelectionLength = 0;
            }
            else
            {
                int nOldSelectionStart = line.textBox_content.SelectionStart;

                nRet = this.GetValueFromTemplate(strFieldName,
                    strSubfieldName,
                    strSubfieldValue,
                    out strOutputValue,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    return;
                }

                // 不是定长子字段的情况
                if (nRet == 0)
                    return;

                if (strSubfieldValue != strOutputValue)
                {
                    line.Content = strOutputValue;
                }

                // 不让小edit全选上
                if (nOldSelectionStart < line.textBox_content.Text.Length)
                    line.textBox_content.SelectionStart = nOldSelectionStart;
                else
                    line.textBox_content.SelectionLength = 0;
            }
        }
コード例 #5
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        // 探测当前位置是否存在定长模板定义
        // parameters:
        //      strCurName  返回当前所在位置的字段、子字段名
        internal bool HasTemplateOrValueListDef(
            EasyLine line,
            string strDefName,
            out string strCurName)
        {
            strCurName = "";

            string strFieldName = "";
            string strSubfieldName = "";

            if (line is FieldLine)
            {
                strFieldName = line.Name;
                strCurName = strFieldName;
            }
            else
            {
                FieldLine field = this.GetFieldLine(line as SubfieldLine);
                strFieldName = field.Name;
                strSubfieldName = line.Name;

                strCurName = strFieldName + new String(Record.KERNEL_SUBFLD, 1) + strSubfieldName;
            }

            string strError;
            return HasTemplateOrValueListDef(
                strDefName,
                strFieldName,
                strSubfieldName,
                out strError);
        }
コード例 #6
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        /// <summary>
        /// 选择一个范围的事项。本方法是从 上次选定过的事项 一直选定到 element 所指示的事项
        /// </summary>
        /// <param name="element">起点事项</param>
        public void RangeSelectItem(EasyLine element)
        {
            EasyLine start = this.LastClickItem;

            int nStart = this.Items.IndexOf(start);
            if (nStart == -1)
                return;

            int nEnd = this.Items.IndexOf(element);

            if (nStart > nEnd)
            {
                // 交换
                int nTemp = nStart;
                nStart = nEnd;
                nEnd = nTemp;
            }

            bool bSelectionChanged = false;
            for (int i = nStart; i <= nEnd; i++)
            {
                EasyLine cur_element = this.Items[i];

                if ((cur_element.State & ItemState.Selected) == 0)
                {
                    cur_element.State |= ItemState.Selected;
                    bSelectionChanged = true;
                    this.InvalidateLine(cur_element);
                }
            }

            // 清除其余位置
            for (int i = 0; i < nStart; i++)
            {
                EasyLine cur_element = this.Items[i];

                if ((cur_element.State & ItemState.Selected) != 0)
                {
                    cur_element.State -= ItemState.Selected;
                    bSelectionChanged = true;
                    this.InvalidateLine(cur_element);
                }
            }

            for (int i = nEnd + 1; i < this.Items.Count; i++)
            {
                EasyLine cur_element = this.Items[i];

                if ((cur_element.State & ItemState.Selected) != 0)
                {
                    cur_element.State -= ItemState.Selected;
                    bSelectionChanged = true;
                    this.InvalidateLine(cur_element);
                }
            }

            if (bSelectionChanged)
                OnSelectionChanged(new EventArgs());
        }
コード例 #7
0
ファイル: KeyboardForm.cs プロジェクト: paopaofeng/dp2
        void LinkBiblioField(EasyLine line)
        {
            if (line == null)
                return;

            string strCaption = line.Caption;
            if (line is SubfieldLine)
            {
                strCaption = line.Caption + " - " + line.Container.GetFieldLine(line as SubfieldLine).Caption;
            }
            this.label_name.Text = strCaption;
            this.textBox_input.Text = line.Content;

            this.BaseForm.DisableWizardControl();
            line.Container.SelectItem(line, true, false);
            this.BaseForm.EnableWizardControl();

            line.EnsureVisible();
        }
コード例 #8
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        internal void InvalidateLine(EasyLine item)
        {
            return; // 将来有导致行背景颜色改变的操作再使用这个函数

            Point p = this.tableLayoutPanel_content.PointToScreen(new Point(0, 0));

            Rectangle rect = item.label_color.RectangleToScreen(item.label_color.ClientRectangle);
            rect.Width = this.tableLayoutPanel_content.DisplayRectangle.Width;
            rect.Offset(-p.X, -p.Y);
            rect.Height = (int)this.Font.GetHeight() + 8;   // 缩小刷新高度

            this.tableLayoutPanel_content.Invalidate(rect, false);

            // this.tableLayoutPanel_content.Invalidate();
        }
コード例 #9
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        public void RemoveItem(EasyLine line, bool bFireEvent)
        {
            int index = this.Items.IndexOf(line);

            if (index == -1)
                return;

            line.RemoveFromTable(this.tableLayoutPanel_content, index);

            this.Items.Remove(line);

            // this.Changed = true;
            if (bFireEvent == true)
                this.FireTextChanged();
        }
コード例 #10
0
ファイル: KeyboardForm.cs プロジェクト: paopaofeng/dp2
        private void button_scan_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            this.textBox_input.SelectAll();
            this.textBox_input.Focus();

            if (this._step == Step.PrepareSearchBiblio)
            {
                this.BaseForm.QueryWord = this.textBox_input.Text;
                this._lastISBN = this.textBox_input.Text;
                // 显示“正在检索”
                this.SetStep(Step.SearchingBiblio);
                this.BaseForm.DoSearch(this.textBox_input.Text, "ISBN", false);
                this.SetStep(Step.SearchBiblioCompleted);
                // 如果检索命中,要选择后,切换到下一页。选择方面,可以提示输入 1 2 3 4 等用以选择
                // 如果检索没有命中,提示再次扫入相同的 ISBN,可以直接进入创建新记录流程
                if (this.BaseForm.SearchResultErrorCount > 0)
                {
                    this.SetStep(Step.SearchBiblioError);
                }
                else if (this.BaseForm.SearchResultCount > 0)
                {
                    if (this.BaseForm.SearchResultCount == 1)
                    {
                        // 命中唯一的一条
                        this.EditSelectedBrowseLine();
                        // 观察书目记录包含多少册记录。
                        this.SetStep(Step.EditEntity);
                        return;
                    }
                    this.textBox_input.Text = "1";
                    this.SetStep(Step.SelectSearchResult);
                }
                else
                {
                    Debug.Assert(this.BaseForm.SearchResultCount == 0, "");

                    // 没有命中。当再次输入同样的 ISBN, 表示创建新书目记录
                    this.SetStep(Step.SearchBiblioNotFound);
                }
                return;
            }

            if (this._step == Step.SelectSearchResult)
            {
                int index = 0;

                // 如果输入刚才用过的 ISBN ,表示选择第一个记录
                if (this.textBox_input.Text == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    index = 1;
                }
                else
                {
                    // 根据输入的数字挑选命中记录
                    if (StringUtil.IsPureNumber(this.textBox_input.Text) == false)
                    {
                        strError = "请输入一个数字";
                        goto ERROR1;
                    }

                    if (int.TryParse(this.textBox_input.Text, out index) == false)
                    {
                        strError = "输入的应该是一个数字";
                        goto ERROR1;
                    }

                    // TODO: 可以根据检索命中列表中事项的最大个数,探测 input 中输入达到这么多个字符后不需要按回车键就可以开始后续处理

                    if (index - 1 >= this.BaseForm.ResultListCount)
                    {
                        strError = "请输入一个 1-" + (this.BaseForm.ResultListCount + 1).ToString() + " 之间的数字";
                        goto ERROR1;
                    }
                }
                this.BaseForm.SelectBrowseLine(true, index - 1);
                this.EditSelectedBrowseLine();
                // 观察书目记录包含多少册记录。
                this.SetStep(Step.EditEntity);
                return;
            }

            if (this._step == Step.SearchBiblioNotFound)
            {
                // 如果输入刚才用过的 ISBN ,表示创建新书目记录
                if (this.textBox_input.Text == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    nRet = this.BaseForm.NewBiblio(false);
                    if (nRet == -1)
                    {
                        this.DisplayError("操作出错");
                        return;
                    }
                    this.SetStep(Step.EditBiblio);
                    return;
                }
                else
                {
                    string strText = this.textBox_input.Text;
                    this.SetStep(Step.PrepareSearchBiblio);
                    this.textBox_input.Text = strText;
                    this.BeginInvoke(new Action<object, EventArgs>(button_scan_Click), this, new EventArgs());
                    return;
                }
                return;
            }

            if (this._step == Step.EditBiblio)
            {
                // 观察输入的字符串,如果和检索使用过的 ISBN 一致,则增加一个册(册条码号为空);
                // 如果是其他 ISBN,则回到检索画面自动启动检索书目;
                // 如果不是 ISBN,则当作为当前书目字段输入内容

                string strText = this.textBox_input.Text;

                if (strText == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    // 将上一个 EntityEditControl 中的蓝色行标记清除
                    if (this._currentEntityControl != null)
                    {
                        this.BaseForm.DisableWizardControl();
                        this._currentEntityControl.ClearActiveState();
                        this.BaseForm.EnableWizardControl();
                    }
                    this._currentEntityControl = this.BaseForm.AddNewEntity("", false);
                    this._currentEntityLine = null;
#if NO
                    // 越过第一个字段
                    this._currentEntityLine = GetNextEntityLine(this._currentEntityLine);
#endif
                    return;
                }

                if (QuickChargingForm.IsISBN(ref strText) == true)
                {
                    this.SetStep(Step.PrepareSearchBiblio);
                    this.textBox_input.Text = strText;
                    this.BeginInvoke(new Action<object, EventArgs>(button_scan_Click), this, new EventArgs());
                    return;
                }
                else
                {
                    // 为当前子字段添加内容,顺次进入下一子字段。等所有字段都输入完以后,自动进入 EditEntity 状态
                    if (this._currenBiblioLine != null)
                    {
                        if (string.IsNullOrEmpty(this.textBox_input.Text) == true)
                        {
                            List<EasyLine> selected_lines = new List<EasyLine>();
                            selected_lines.Add(this._currenBiblioLine);
                            EasyMarcControl container = this._currenBiblioLine.Container;
                            // 删除前要先找到上一个行。否则删除后查找将无法继续
                            this._currenBiblioLine = GetPrevBiblioLine(this._currenBiblioLine);
                            // 删除
                            container.DeleteElements(selected_lines);
                        }
                        else
                        {
                            this._currenBiblioLine.Content = this.textBox_input.Text;
                            this.textBox_input.Text = "";
                        }
                        SetStep(Step.EditBiblio);
                    }
                    else
                    {
                        this.textBox_input.Text = "";
                        SetStep(Step.EditEntity);
                    }
                    return;
                }
            }

            if (this._step == Step.EditEntity)
            {
                // 观察输入的字符串,如果和检索使用过的 ISBN 一致,则增加一个册(册条码号为空);
                // 如果是其他 ISBN,则回到检索画面自动启动检索书目;
                // 如果不是 ISBN,则当作册条码号增加一个册

                string strText = this.textBox_input.Text;

                if (strText == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    // 将上一个 EntityEditControl 中的蓝色行标记清除
                    if (this._currentEntityControl != null)
                    {
                        this.BaseForm.DisableWizardControl();
                        this._currentEntityControl.ClearActiveState();
                        this.BaseForm.EnableWizardControl();
                    }

                    this._currentEntityControl = this.BaseForm.AddNewEntity("", false);
                    this._currentEntityLine = null;
#if NO
                    // 越过第一个字段
                    this._currentEntityLine = GetNextEntityLine(this._currentEntityLine);
#endif
                    this.BeginInvoke(new Func<Step, string, bool>(SetStep), Step.EditEntity, "");
                    return;
                }

                if (QuickChargingForm.IsISBN(ref strText) == true)
                {
                    // TODO: 连带引起保存书目和册记录可能会失败哟
                    if (this.SetStep(Step.PrepareSearchBiblio) == false)
                        return;
                    this.textBox_input.Text = strText;
                    this.BeginInvoke(new Action<object, EventArgs>(button_scan_Click), this, new EventArgs());
                    return;
                }
                else
                {
                    // 首次输入册条码号。还没有关联的 EntityEditControl
                    if (this._currentEntityControl == null)
                    {
                        this._currentEntityControl = this.BaseForm.AddNewEntity(strText, false);
                        this._currentEntityLine = null;
                        // 越过第一个字段
                        this._currentEntityLine = GetNextEntityLine(this._currentEntityLine);

                        this.BeginInvoke(new Func<Step, string, bool>(SetStep), Step.EditEntity, "");
                        return;
                    }
                    // 为册编辑器当前行输入内容,顺次进入下一行。等所有字段都输入完以后,自动进入 EditEntity 等待输入册条码号的状态
                    if (this._currentEntityLine != null)
                    {
                        this._currentEntityLine.Content = this.textBox_input.Text;
                        this.textBox_input.Text = "";

                        SetStep(Step.EditEntity);
                    }
                    else
                    {
                        // 进入首次等待输入册条码号的状态
                        this._currentEntityControl = null;
                        this._currentEntityLine = null;
                        this.textBox_input.Text = "";
                        SetStep(Step.EditEntity);
                    }
                    return;
                }
            }
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
コード例 #11
0
 public EasyLine GetPrevBiblioLine(EasyLine ref_line)
 {
     return this.easyMarcControl1.GetPrevEditableLine(ref_line);
 }
コード例 #12
0
ファイル: KeyboardForm.cs プロジェクト: paopaofeng/dp2
 EasyLine GetNextBiblioLine(EasyLine start_line, bool bFindEmpty = true)
 {
 REDO:
     EasyLine line = this.BaseForm.GetNextBiblioLine(start_line);
     if (bFindEmpty == true)
     {
         if (line != null && string.IsNullOrEmpty(line.Content) == false && line.Content.IndexOf("?") == -1)
         {
             start_line = line;
             goto REDO;  // 直到找到一个内容为空或者有问号的字段
         }
     }
     return line;
 }
コード例 #13
0
ファイル: KeyboardForm.cs プロジェクト: paopaofeng/dp2
 EasyLine GetPrevBiblioLine(EasyLine start_line)
 {
     return this.BaseForm.GetPrevBiblioLine(start_line);
 }
コード例 #14
0
ファイル: KeyboardForm.cs プロジェクト: paopaofeng/dp2
 public void SetCurrentBiblioLine(EasyLine line)
 {
     this._currenBiblioLine = line;
 }
コード例 #15
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        EasyLine LastClickItem = null;   // 最近一次click选择过的Item对象

        /// <summary>
        /// 选定一个事项
        /// </summary>
        /// <param name="element">事项</param>
        /// <param name="bClearOld">是否清除以前的选择</param>
        public void SelectItem(EasyLine element,
            bool bClearOld,
            bool bSetFocus = true)
        {
            bool bSelectionChanged = false;

            if (bClearOld == true)
            {
                for (int i = 0; i < this.Items.Count; i++)
                {
                    EasyLine cur_element = this.Items[i];

                    if (cur_element == element)
                        continue;   // 暂时不处理当前行

                    if ((cur_element.State & ItemState.Selected) != 0)
                    {
                        cur_element.State -= ItemState.Selected;
                        bSelectionChanged = true;
                        this.InvalidateLine(cur_element);
                    }
                }
            }

            if (element == null)
                return;

            // 选中当前行
            if ((element.State & ItemState.Selected) == 0)
            {
                element.State |= ItemState.Selected;
                bSelectionChanged = true;
                this.InvalidateLine(element);
            }

            if (bSetFocus == true)
            {
                if (element.textBox_content.Visible == true)
                {

                    SetEditFocus(element.textBox_content);
                    element.textBox_content.Select(0, 0);
                }
                else
                {
                    // 2015/5/30
                    // 如果当前 item 是字段名行,需要将 Focus 设置到其后的第一个子字段行的 TextBox 上
                    if (element is FieldLine && element.Visible == true)
                    {
                        List<EasyLine> subfields = GetSubfieldLines(element as FieldLine);
                        if (subfields.Count > 0)
                            SetEditFocus(subfields[0].textBox_content);
                    }
                }
            }

            this.LastClickItem = element;

            if (bSelectionChanged)
                OnSelectionChanged(new EventArgs());
        }
コード例 #16
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        // 清除一个Item对象对应的Control
        internal void ClearOneItemControls(
            TableLayoutPanel table,
            EasyLine line)
        {
            table.Controls.Remove(line.label_color);

            table.Controls.Remove(line.label_caption);

            if (line.splitter != null)
                table.Controls.Remove(line.splitter);

            table.Controls.Remove(line.textBox_content);
        }
コード例 #17
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        /// <summary>
        /// 将一个事项的选定状态来回切换
        /// </summary>
        /// <param name="element"></param>
        public void ToggleSelectItem(EasyLine element)
        {
            // 选中当前行
            if ((element.State & ItemState.Selected) == 0)
                element.State |= ItemState.Selected;
            else
                element.State -= ItemState.Selected;

            this.InvalidateLine(element);

            this.LastClickItem = element;

            OnSelectionChanged(new EventArgs());
        }
コード例 #18
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        public void InsertNewLine(int index,
            EasyLine line,
            bool bFireEnvent)
        {
            this.DisableUpdate();   // 防止闪动

            try
            {
                RowStyle style = new RowStyle();
                //style.Height = 26;
                //style.SizeType = SizeType.Absolute;

                this.tableLayoutPanel_content.RowStyles.Insert(index + RESERVE_LINES, style);
                this.tableLayoutPanel_content.RowCount += 1;

                line.InsertToTable(this.tableLayoutPanel_content, index);

                this.Items.Insert(index, line);

                line.State = ItemState.New;

                if (bFireEnvent == true)
                    this.FireTextChanged();
            }
            finally
            {
                this.EnableUpdate();
            }
        }
コード例 #19
0
ファイル: EasyMarcControl.cs プロジェクト: renyh1013/dp2
        internal void ToggleExpand(EasyLine line)
        {
            if (line.ExpandState == EasyMarc.ExpandState.None)
                return;

            this.DisableUpdate();
            try
            {
                if (line.ExpandState == EasyMarc.ExpandState.Expanded)
                    line.ExpandState = EasyMarc.ExpandState.Collapsed;
                else
                    line.ExpandState = EasyMarc.ExpandState.Expanded;

                int nStart = this.Items.IndexOf(line);
                if (nStart == -1)
                    return;

                // 将下属子字段显示或者隐藏
                for (int i = nStart + 1; i < this.Items.Count; i++)
                {
                    EasyLine current = this.Items[i];
                    if (current is FieldLine)
                        break;
                    if (line.ExpandState == ExpandState.Expanded)
                        current.Visible = true;
                    else
                        current.Visible = false;
                }

            }
            finally
            {
                this.EnableUpdate();
            }
        }
コード例 #20
0
ファイル: KeyboardForm.cs プロジェクト: paopaofeng/dp2
        // return:
        //      false   出错
        //      true    成功
        public bool SetStep(Step step, string strStyle = "")
        {
            int nRet = 0;

            Step save = this._step;

        REDO_SETSTEP:

            this._step = step;

            this.DisplayInfo(Step.None);

            if (step == Step.None)
            {
                SetTarget("None");
                this.EnableInput(false);
                return true;
            }

            // 准备检索书目
            if (step == Step.PrepareSearchBiblio)
            {
                this.label_name.Text = "请输入检索词";

                this._currenBiblioLine = null;
                this._currentEntityControl = null;
                this._currentEntityLine = null;

                this.EnableInput(true);

                if (StringUtil.IsInList("dont_clear", strStyle) == false)
                {
                    this.textBox_input.Text = "";

                    // 操作前要确保各种修改已经自动保存,以免出现提示保存的对话框导致破坏流畅性
                    // return:
                    //      -1      保存过程出错
                    //      0       成功
                    nRet = this.BaseForm.ReStart();
                    if (nRet == -1)
                    {
                        this.DisplayError("操作出错");
                        this._step = save;
                        return false;
                    }
                }

                if (StringUtil.IsInList("dont_hilight", strStyle) == false)
                {
                    this.EnableInput(true);

                    this.textBox_input.SelectAll();
                    this.textBox_input.Focus(); // 将输入焦点切换回来
                }
                SetTarget("QueryWord");
                DisplayInfo(step);
                return true;
            }

            if (step == Step.SearchingBiblio)
            {
                this.SetTarget("ResultList");
                DisplayInfo(step);
                return true;
            }

            if (step == Step.SearchBiblioCompleted)
            {
                this.EnableInput(true);

                this.SetTarget("ResultList");
                DisplayInfo(step);
                return true;
            }

            if (step == Step.SearchBiblioError)
            {
                this.SetTarget("ResultList");
                this.DisplayInfo(Step.SearchBiblioError);
                return true;
            }

            if (step == Step.SearchBiblioNotFound)
            {
                this.EnableInput(true);

                this.SetTarget("ResultList");
                this.DisplayInfo(Step.SearchBiblioNotFound);
                return true;
            }

            // 在书目命中多条结果中选择
            if (step == Step.SelectSearchResult)
            {
                this.label_name.Text = "请输入命中事项的序号";

                this.EnableInput(true);

                this.textBox_input.SelectAll();
                this.SetTarget("ResultList");
                DisplayInfo(step);
                return true;
            }

            // 编辑书目记录
            if (step == Step.EditBiblio)
            {
                this.textBox_input.SelectAll();
                    this.SetTarget("MarcEdit");

                if (StringUtil.IsInList("dont_hilight", strStyle) == false)
                {
#if NO
                EasyLine start_line = _currenBiblioLine;
            REDO:
                EasyLine line = this.BaseForm.GetNextBiblioLine(start_line);
                if (line != null && string.IsNullOrEmpty(line.Content) == false && line.Content.IndexOf("?") == -1)
                {
                    start_line = line;
                    goto REDO;  // 直到找到一个内容为空或者有问号的字段
                }
#endif
                    EasyLine line = GetNextBiblioLine(_currenBiblioLine);
                    if (line != null)
                    {
#if NO
                        string strCaption = line.Caption;
                        if (line is SubfieldLine)
                        {
                            strCaption = line.Caption + " - " + line.Container.GetFieldLine(line as SubfieldLine).Caption;
                        }
                        this.label_name.Text = strCaption;
                        this.textBox_input.Text = line.Content;
                        line.Container.SelectItem(line, true, false);
                        line.EnsureVisible();
#endif
                        LinkBiblioField(line);
                        this.EnableInput(true);
                    }
                    else
                    {
                        // 全部字段都已经有内容了,要转为编辑册记录
                        if (_currenBiblioLine != null)
                        {
                            this.BaseForm.DisableWizardControl();
                            _currenBiblioLine.Container.SelectItem(null, true, false);
                            this.BaseForm.EnableWizardControl();
                        }

                        _currenBiblioLine = null;
                        this.textBox_input.Text = "";
                        // this.BeginInvoke(new Action<Step, string>(SetStep), Step.EditEntity, "");
                        step = Step.EditEntity;
                        goto REDO_SETSTEP;
                    }
                    _currenBiblioLine = line;
                }
                else
                {
                    // 定位到当前字段上
                    if (this._currenBiblioLine != null)
                    {
                        LinkBiblioField(this._currenBiblioLine);
                        this.EnableInput(true);
                    }
                    else
                    {
                        this.textBox_input.Text = "";
                        this.EnableInput(false);
                    }
                }
                
                DisplayInfo(step);
                return true;
            }

            // 增加新的册记录
            if (step == Step.EditEntity)
            {
                this.label_name.Text = "册条码号";
                this._currenBiblioLine = null;

                this.EnableInput(true);

                if (this._currentEntityControl == null)
                {
                    this.textBox_input.Text = "";
                    PlusButton plus = this.BaseForm.GetEntityPlusButton();
                    if (plus != null)
                    {
                        this.BaseForm.EnsurePlusButtonVisible();

                        this.BaseForm.DisableWizardControl();
                        plus.Active = true;
                        this.BaseForm.EnableWizardControl();
                    }
                    else
                    {
                        ////
                        ////Debug.Assert(false, "");
                    }
                    DisplayInfo(step);

                    this.textBox_input.SelectAll();
                    this.SetTarget("Entities");

                    return true;
                }

                this.textBox_input.SelectAll();
                this.SetTarget("Entities");
                if (StringUtil.IsInList("dont_hilight", strStyle) == false)
                {

                    if (this._currentEntityControl != null)
                    {
#if NO
                    EditLine start_line = this._currentEntityLine;
                REDO:
                    EditLine line = this.BaseForm.GetNextEntityLine(this._currentEntityControl, start_line);
#endif
                        EditLine line = GetNextEntityLine(this._currentEntityLine);
                        if (line != null)
                        {
#if NO
                        this.label_name.Text = line.Caption;
                        this.textBox_input.Text = line.Content;

                        this._currentValueList = this._currentEntityControl.GetLineValueList(line);

                        line.ActiveState = true;
                        this.BaseForm.EnsureEntityVisible(line.EditControl);
                        // 把加号按钮修改为一般状态
                        PlusButton plus = this.BaseForm.GetEntityPlusButton();
                        if (plus != null)
                        {
                            plus.Active = false;
                        }
#endif
                            LinkEntityLine(line);
                            this.EnableInput(true);
                        }
                        else
                        {
                            if (this._currentEntityControl != null)
                            {
                                this.BaseForm.DisableWizardControl();
                                this._currentEntityControl.ClearActiveState();
                                this.BaseForm.EnableWizardControl();
                            }
                            this._currentEntityControl = null;
                            this._currentEntityLine = null;
                            this.textBox_input.Text = "";
                            // this.BeginInvoke(new Action<Step, string>(SetStep), Step.EditEntity, "");
                            step = Step.EditEntity;
                            goto REDO_SETSTEP;
                        }
                        _currentEntityLine = line;
                    }
                }
                else
                {
                    // 定位到当前字段上
                    if (this._currentEntityControl != null
                        && this._currentEntityLine != null)
                    {
                        LinkEntityLine(this._currentEntityLine);
                        this.EnableInput(true);
                    }
                    else
                    {
                        this.textBox_input.Text = "";
                        this.EnableInput(true); // 准备新增一条册记录
                    }
                }

                DisplayInfo(step);
                return true;
            }

            return true;
        }