示例#1
0
 //品詞用コンボボックス類設定
 private void setHinshiComboBoxes(ComboBox comboBox, List <MHinshi> srcList, List <MHinshi> destList, int parentId, int level)
 {
     destList.Clear();
     comboBox.Items.Clear();
     comboBox.Items.Add(String.Empty);
     srcList.ForEach(delegate(MHinshi mHinshiWork)
     {
         if (mHinshiWork.ParentId == parentId)
         {
             destList.Add(mHinshiWork);
             comboBox.Items.Add(mHinshiWork.Name);
         }
     });
     // 該当データがない場合
     if (destList.Count == 0 && comboBox.Items.Count == 1)
     {
         MHinshi wrkHinshi = new MHinshi();
         wrkHinshi.ParentId  = parentId;
         wrkHinshi.Id        = wrkHinshi.ParentId * 100 + destList.Count + 1;
         wrkHinshi.Level     = level;
         wrkHinshi.Name      = "*";
         wrkHinshi.CreatedAt = DateTime.Now;
         wrkHinshi.UpdatedAt = DateTime.Now;
         wrkHinshi.DeleteFlg = "0";
         destList.Add(wrkHinshi);
         srcList.Add(wrkHinshi);
         comboBox.Items.Add(wrkHinshi.Name);
     }
     comboBox.DropDownStyle = ComboBoxStyle.DropDown;
     comboBox.SelectedIndex = 0;
 }
示例#2
0
        // 品詞リストとコンボボックスのチェック。なければ品詞リストとコンボボックスに追加する
        private int checkHinshiListWithCombo(ComboBox comboBox, List <MHinshi> lstSrc, int hinshiLevel, int parentId, String hinshiName, List <MHinshi> lstDest = null)
        {
            // 以下で "indexHinshi = lstDest.Count;"となっているのは、lstDestにはComboBoxにある空白がないため
            int indexHinshi = -1;

            if (lstDest != null)
            {
                indexHinshi = lstDest.FindIndex(x => x.Name.Equals(hinshiName));
            }
            else
            {
                indexHinshi = lstSrc.FindIndex(x => x.Name.Equals(hinshiName));
            }

            if (indexHinshi > -1)
            {
                comboBox.SelectedIndex = indexHinshi + 1;
            }
            else
            {
                if (!hinshiName.Equals(String.Empty))
                {
                    MHinshi mNewHinshi = new MHinshi();
                    mNewHinshi.ParentId = parentId;
                    if (hinshiLevel == 0)
                    {
                        mNewHinshi.Id = lstSrc.Count;
                    }
                    else
                    {
                        mNewHinshi.Id = (mNewHinshi.ParentId * 100) + lstDest.Count + 1;
                    }
                    mNewHinshi.Name      = hinshiName;
                    mNewHinshi.Level     = hinshiLevel;
                    mNewHinshi.CreatedAt = DateTime.Now;
                    mNewHinshi.UpdatedAt = DateTime.Now;
                    mNewHinshi.DeleteFlg = "0";

                    lstSrc.Add(mNewHinshi);
                    comboBox.Items.Add(hinshiName);
                    indexHinshi = lstSrc.Count;
                    if (lstDest != null)
                    {
                        lstDest.Add(mNewHinshi);
                        indexHinshi = lstDest.Count;
                    }
                    comboBox.SelectedIndex = indexHinshi;
                }
            }

            return(indexHinshi);
        }
示例#3
0
        // 品詞リストのチェック。なければ追加する
        // lstSrc:品詞リスト
        // hinshiLevel:品詞レベル
        // parentId:親ID
        // hinshiName:品詞名
        // noSpace:空白許可
        public static int checkHinshiList(List <MHinshi> lstSrc, int hinshiLevel, int parentId, String hinshiName, Boolean noSpace)
        {
            String  strName = "*";
            Boolean bEdit   = false;

            if (hinshiName.Equals(String.Empty))
            {
                if (noSpace)
                {
                    bEdit = true;
                }
            }
            else
            {
                strName = hinshiName;
                bEdit   = true;
            }

            int indexHinshi = lstSrc.FindIndex(x => x.Name.Equals(strName) && x.Level == hinshiLevel && x.ParentId == parentId);

            if (bEdit)
            {
                if (indexHinshi < 0)
                {
                    MHinshi mNewHinshi = new MHinshi();
                    mNewHinshi.ParentId = parentId;
                    if (hinshiLevel == 0)
                    {
                        mNewHinshi.Id = lstSrc.Count + 1;
                    }
                    else
                    {
                        List <MHinshi> lstWrk = lstSrc.FindAll(x => x.Level == hinshiLevel && x.ParentId == parentId);
                        mNewHinshi.Id = (mNewHinshi.ParentId * 100) + lstWrk.Count + 1;
                    }
                    mNewHinshi.Name      = strName;
                    mNewHinshi.Level     = hinshiLevel;
                    mNewHinshi.DeleteFlg = "0";

                    lstSrc.Add(mNewHinshi);
                }
            }

            return(indexHinshi);
        }