예제 #1
0
파일: KeyboardForm.cs 프로젝트: zszqwe/dp2
        void LinkEntityLine(EditLine line)
        {
            if (line == null)
            {
                return;
            }

            this.BaseForm.DisableWizardControl();
            {
                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;
                }
            }
            this.BaseForm.EnableWizardControl();
        }
예제 #2
0
        // 设置一行的状态
        public void SetLineState(EditLine line, EditLineState new_state)
        {
            bool bNotified = false;

            // 需要把其他事项的 Active 状态全部设置为 false
            if (new_state.Active == true)
            {
                bNotified = ClearActiveState(line);
            }
            SetLineState(line.EditControl, new_state);
            if (bNotified == false)
            {
                OnSelectionChanged(new EventArgs());
            }
        }
예제 #3
0
        // 得到下一个可以输入内容的行对象
        // parameters:
        //      ref_line    参考的对象。从它后面一个开始获取。如果为 null,表示获取第一个可编辑的对象
        public virtual EditLine GetNextEditableLine(EditLine ref_line)
        {
            bool bOn = false;

            if (ref_line == null)
            {
                bOn = true;
            }
            for (int i = 0; i < this._tableLayoutPanel_main.RowStyles.Count; i++)
            {
                // 第一列
                Label label_control = this._tableLayoutPanel_main.GetControlFromPosition(0, i) as Label;
                if (label_control == null)
                {
                    continue;
                }

                if (ref_line != null && label_control == ref_line._labelCaption)
                {
                    bOn = true;
                    continue;
                }

                if (bOn == true)
                {
                    // 第三列
                    Control edit_control = this._tableLayoutPanel_main.GetControlFromPosition(2, i);
                    if (edit_control != null &&
                        edit_control.Visible == true &&
                        edit_control.Enabled == true)
                    {
                        if (edit_control is TextBox)
                        {
                            if ((edit_control as TextBox).ReadOnly == true)
                            {
                                continue;
                            }
                        }
                        EditLine line = new EditLine(this, i);
                        return(line);
                    }
                }
            }
            return(null);
        }
예제 #4
0
        // 清除全部行的 Active 状态
        public bool ClearActiveState(EditLine exclude = null)
        {
            bool bSelectionChanged = false;

            for (int i = 0; i < this._tableLayoutPanel_main.RowStyles.Count; i++)
            {
                // 第一列
                Label label_control = this._tableLayoutPanel_main.GetControlFromPosition(0, i) as Label;
                if (label_control == null)
                {
                    continue;
                }
                if (exclude != null)
                {
                    if (label_control == exclude._labelCaption)
                    {
                        continue;   // 跳过要排除的一行
                    }
                }
#if NO
                // 第二列
                label_control = this._tableLayoutPanel_main.GetControlFromPosition(1, i) as Label;
                if (label_control == null)
                {
                    continue;
                }
#endif

                EditLineState state = GetLineState(i);
                if (state != null && state.Active == true)
                {
                    state.Active = false;
                    SetLineState(i, state);

                    bSelectionChanged = true;
                }
            }
            if (bSelectionChanged)
            {
                this.OnSelectionChanged(new EventArgs());
            }

            return(bSelectionChanged);
        }
예제 #5
0
 // 获得当前具有输入焦点的一行
 public virtual EditLine GetFocuedLine()
 {
     for (int i = 0; i < this._tableLayoutPanel_main.RowStyles.Count; i++)
     {
         // 第三列
         Control edit_control = this._tableLayoutPanel_main.GetControlFromPosition(2, i);
         if (edit_control != null &&
             edit_control.Visible == true &&
             edit_control.Enabled == true
             // && edit_control.Focused == true
             )
         {
             EditLineState state = GetLineState(i);
             if (state != null && state.Active == true)
             {
                 EditLine line = new EditLine(this, i);
                 return(line);
             }
         }
     }
     return(null);
 }
예제 #6
0
파일: KeyboardForm.cs 프로젝트: zszqwe/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);
        }
예제 #7
0
파일: KeyboardForm.cs 프로젝트: zszqwe/dp2
 EditLine GetNextEntityLine(EditLine start_line)
 {
     return(EntityRegisterWizard.GetNextEntityLine(this._currentEntityControl, start_line));
 }
예제 #8
0
파일: KeyboardForm.cs 프로젝트: zszqwe/dp2
 public void SetCurrentEntityLine(EntityEditControl control, EditLine line)
 {
     this._currentEntityControl = control;
     this._currentEntityLine    = line;
 }
예제 #9
0
 public void SetCurrentEntityLine(EntityEditControl control, EditLine line)
 {
     this._currentEntityControl = control;
     this._currentEntityLine = line;
 }
예제 #10
0
 // 设置一行的状态
 public void SetLineState(EditLine line, EditLineState new_state)
 {
     bool bNotified = false;
     // 需要把其他事项的 Active 状态全部设置为 false
     if (new_state.Active == true)
     {
         bNotified = ClearActiveState(line);
     }
     SetLineState(line.EditControl, new_state);
     if (bNotified == false)
         OnSelectionChanged(new EventArgs());
 }
예제 #11
0
        // 清除全部行的 Active 状态
        public bool ClearActiveState(EditLine exclude = null)
        {
            bool bSelectionChanged = false;

            for (int i = 0; i < this._tableLayoutPanel_main.RowStyles.Count; i++)
            {
                // 第一列
                Label label_control = this._tableLayoutPanel_main.GetControlFromPosition(0, i) as Label;
                if (label_control == null)
                    continue;
                if (exclude != null)
                {
                    if (label_control == exclude._labelCaption)
                        continue;   // 跳过要排除的一行
                }
#if NO
                // 第二列
                label_control = this._tableLayoutPanel_main.GetControlFromPosition(1, i) as Label;
                if (label_control == null)
                    continue;
#endif

                EditLineState state = GetLineState(i);
                if (state != null && state.Active == true)
                {
                    state.Active = false;
                    SetLineState(i, state);

                    bSelectionChanged = true;
                }
            }
            if (bSelectionChanged)
                this.OnSelectionChanged(new EventArgs());

            return bSelectionChanged;
        }
예제 #12
0
        // 得到下一个可以输入内容的行对象
        // parameters:
        //      ref_line    参考的对象。从它后面一个开始获取。如果为 null,表示获取第一个可编辑的对象
        public virtual EditLine GetNextEditableLine(EditLine ref_line)
        {
            bool bOn = false;
            if (ref_line == null)
                bOn = true;
            for (int i = 0; i < this._tableLayoutPanel_main.RowStyles.Count; i++)
            {
                // 第一列
                Label label_control = this._tableLayoutPanel_main.GetControlFromPosition(0, i) as Label;
                if (label_control == null)
                    continue;

                if (ref_line != null && label_control == ref_line._labelCaption)
                {
                    bOn = true;
                    continue;
                }

                if (bOn == true)
                {
                    // 第三列
                    Control edit_control = this._tableLayoutPanel_main.GetControlFromPosition(2, i);
                    if (edit_control != null 
                        && edit_control.Visible == true
                        && edit_control.Enabled == true)
                    {
                        if (edit_control is TextBox)
                        {
                            if ((edit_control as TextBox).ReadOnly == true)
                                continue;
                        }
                        EditLine line = new EditLine(this, i);
                        return line;
                    }
                }
            }
            return null;
        }
예제 #13
0
 // 获得当前具有输入焦点的一行
 public virtual EditLine GetFocuedLine()
 {
     for (int i = 0; i < this._tableLayoutPanel_main.RowStyles.Count; i++)
     {
         // 第三列
         Control edit_control = this._tableLayoutPanel_main.GetControlFromPosition(2, i);
         if (edit_control != null
             && edit_control.Visible == true
             && edit_control.Enabled == true
             // && edit_control.Focused == true
             )
         {
             EditLineState state = GetLineState(i);
             if (state != null && state.Active == true)
             {
                 EditLine line = new EditLine(this, i);
                 return line;
             }
         }
     }
     return null;
 }
예제 #14
0
        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);
        }
예제 #15
0
 EditLine GetNextEntityLine(EditLine start_line)
 {
     return EntityRegisterWizard.GetNextEntityLine(this._currentEntityControl, start_line);
 }
예제 #16
0
 public static EditLine GetNextEntityLine(EntityEditControl control, EditLine ref_line)
 {
     return control.GetNextEditableLine(ref_line);
 }
예제 #17
0
파일: KeyboardForm.cs 프로젝트: zszqwe/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);
        }
예제 #18
0
 // 获得一个行的下拉列表值
 public List<string> GetLineValueList(EditLine line)
 {
     List<string> results = new List<string>();
     if (line.EditControl == this.comboBox_location)
     {
         comboBox_location_DropDown(this.comboBox_location, new EventArgs());
         foreach (string s in comboBox_location.Items)
         {
             results.Add(s);
         }
         return results;
     }
     if (line.EditControl == this.checkedComboBox_state)
     {
         comboBox_state_DropDown(this.checkedComboBox_state, new EventArgs());
         foreach (string s in checkedComboBox_state.Items)
         {
             results.Add(s);
         }
         return results;
     }
     if (line.EditControl == this.comboBox_bookType)
     {
         comboBox_bookType_DropDown(this.comboBox_bookType, new EventArgs());
         foreach (string s in comboBox_bookType.Items)
         {
             results.Add(s);
         }
         return results;
     }
     return null;    // 表示根本没有下拉列表
 }
예제 #19
0
        void LinkEntityLine(EditLine line)
        {
            if (line == null)
                return;

            this.BaseForm.DisableWizardControl();
            {
                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;
                }
            }
            this.BaseForm.EnableWizardControl();

        }