Esempio n. 1
0
        /// <summary>
        /// コンストラクター
        /// </summary>
        public dlgEditColumn(DBColumn col, DataGridView dgv, CtrlComponent.Database.ctlDatabaseEditor mgr)
        {
            this.InitializeComponent();
            this.dbList = mgr.DBList;
            this.uctlMyList.SetupList(new string[] { "項目名" }, null);

            //依存先データベースリストを生成
            var dblist = mgr.GetAllDBList();

            ComboBox[] tgt = { this.cmbDBsList, this.cmbDBsIDNames, this.cmbButtonSrcDB };
            foreach (var cmb in tgt)
            {
                Common.SetListControlKeyValuePairMode(cmb);
                foreach (var db in dblist)
                {
                    var name = mgr.GetDBName(db.Key);
                    if (string.IsNullOrEmpty(name) == false && db.Value.AllowUserToAddRows)
                    {
                        cmb.Items.Add(new DBListType(name, db.Key));
                    }
                }
            }

            //ComboBoxの項目を選択する処理の定義
            var restoreSrcDB = new Action <ComboBox, Database.DBAddress>((cmb, address) => {
                var i = 0;
                foreach (DBListType cmbList in cmb.Items)
                {
                    if (address == new Database.DBAddress(cmbList.Value.MainID, cmbList.Value.SubID))
                    {
                        cmb.SelectedIndex = i;
                        break;
                    }
                    i++;
                }
            });

            //既存データを復元する
            if (col == null)
            {
                return;     //新規作成の場合は処理しない
            }

            this.txtHeaderText.Text = col.HeaderText;

            //クラスの継承関係の都合上、末端の派生先から先に確認していく
            if (col is DBColumnTextNumbers)
            {
                //テキスト系
                this.tbcFormType.SelectedIndex = (int)DBColumnType.TextNumbers;
                this.numIntsMax.Value          = ((DBColumnTextOneNumber)col).MaxValue;
                this.numIntsMin.Value          = ((DBColumnTextOneNumber)col).MinValue;
            }
            else if (col is DBColumnTextOneNumber)
            {
                this.tbcFormType.SelectedIndex = (int)DBColumnType.TextOneNumber;
                this.numOneIntMax.Value        = ((DBColumnTextOneNumber)col).MaxValue;
                this.numOneIntMin.Value        = ((DBColumnTextOneNumber)col).MinValue;
            }
            else if (col is DBColumnTextIDNames)
            {
                this.tbcFormType.SelectedIndex  = (int)DBColumnType.TextIDNames;
                this.chkTextIDValueMode.Checked = false;
                restoreSrcDB(this.cmbDBsIDNames, ((DBColumnTextIDNames)col).SrcDBAddress);
            }
            else if (col is DBColumnTextIDValues)
            {
                this.tbcFormType.SelectedIndex  = (int)DBColumnType.TextIDNames;
                this.chkTextIDValueMode.Checked = true;
                restoreSrcDB(this.cmbDBsIDNames, ((DBColumnTextIDValues)col).SrcDBAddress);
            }
            else if (col is DBColumnListDB)
            {
                //リスト系
                this.tbcFormType.SelectedIndex = (int)DBColumnType.List;
                this.rdbFromDB.Checked         = true;
                restoreSrcDB(this.cmbDBsList, ((DBColumnListDB)col).SrcDBAddress);
            }
            else if (col is DBColumnListUser)
            {
                this.tbcFormType.SelectedIndex = (int)DBColumnType.List;
                this.rdbFromMyList.Checked     = true;
                var editList = new List <ListViewItem>();
                foreach (var item in ((DBColumnListUser)col).SrcMyList)
                {
                    editList.Add(new ListViewItem(item));
                }
                this.uctlMyList.SetupList(new string[] { "項目名" }, editList);
            }
            else if (col is DBColumnButtonInputIDNames)
            {
                //ボタン系
                this.tbcFormType.SelectedIndex    = (int)DBColumnType.Button;
                this.rdbButtonIDNames.Checked     = true;
                this.chkButtonIDValueMode.Checked = false;
                restoreSrcDB(this.cmbButtonSrcDB, ((DBColumnButtonInputIDNames)col).SrcDBAddress);
                this.numIDNameSetterDestColumnIndex.Value = ((DBColumnButtonInputIDNames)col).DestColumnIndex;
            }
            else if (col is DBColumnButtonInputIDValues)
            {
                this.tbcFormType.SelectedIndex    = (int)DBColumnType.Button;
                this.rdbButtonIDNames.Checked     = true;
                this.chkButtonIDValueMode.Checked = true;
                restoreSrcDB(this.cmbButtonSrcDB, ((DBColumnButtonInputIDValues)col).SrcDBAddress);
                this.numIDNameSetterDestColumnIndex.Value = ((DBColumnButtonInputIDValues)col).DestColumnIndex;
            }
            else if (col is DBColumnButtonSelectFile)
            {
                this.tbcFormType.SelectedIndex          = (int)DBColumnType.Button;
                this.rdbButtonFileSelect.Checked        = true;
                this.numFileSetterDestColumnIndex.Value = ((DBColumnButtonSelectFile)col).DestColumnIndex;
            }
            else if (col is DBColumnText)
            {
                //基本系
                this.tbcFormType.SelectedIndex = (int)DBColumnType.Text;
            }
            else if (col is DBColumnBool)
            {
                this.tbcFormType.SelectedIndex = (int)DBColumnType.Bool;
            }
            else if (col is DBColumnPictureFile)
            {
                this.tbcFormType.SelectedIndex = (int)DBColumnType.PictureFile;
            }
        }