コード例 #1
0
        /// <summary>
        /// スポイラーライクな編集を行う
        /// </summary>
        /// <param name="item_index">リストビューのアイテムインデックス</param>
        protected override void SpoilerLikeItemEdit( int item_index )
        {
            var item = this.ListView1.Items[ item_index ];
            var horse_num = (UInt32)((int)item.SubItems["horse_num"].Tag);

            var data = new KOEI.WP7_2012.Datastruct.HDamData();

            var blood_data = new HBloodData();
            var abl_data = new HAblData();
            var father_blood_data = new HBloodData();
            var mother_blood_data = new HBloodData();
            var family_line_data = new HFamilyLineData();

            this.WP7.HDamTable.GetData( horse_num, ref data );
            this.WP7.HAblTable.GetData( data.abl_num, ref abl_data );
            this.WP7.HBloodTable.GetData( data.blood_num, ref blood_data );
            this.WP7.HBloodTable.GetData( blood_data.father_num, ref father_blood_data );
            this.WP7.HBloodTable.GetData( blood_data.mother_num, ref mother_blood_data );
            this.WP7.HFamilyLineTable.GetData( blood_data.family_line_num, ref family_line_data );

            var father_name = String.Empty;
            var mother_name = String.Empty;
            var name = this.GetDispName( this.WP7, out mother_name, out father_name, ref blood_data, ref abl_data, ref father_blood_data, ref mother_blood_data );

            var form = new SpoilerLikeEditForm() {
                Text = String.Format( "{0} 編集中 - SpoilerALライク編集(β)", name ),
                Size = new System.Drawing.Size( 700, 800 ),
            };

            // 繁殖牝馬データの編集コントロール
            var data_editor = new SpoilerLikeControls.BitCheckList( this.WP7, HDamData.Properties, data.Decode() ){
                Dock = DockStyle.Fill,
                ControlsFont = this.ListView1.Font,
                DataChanged = ( new_data )=> {
                    if( this.WP7.TransactionWeekNumber != this.WP7.GetCurrentWeekNumber() ) {
                        var message = String.Format(
                            "データ取得時から週が変わっています({0}→{1})\r\n安全のため書き込みは行いません、再取得してください",
                            this.WP7.TransactionWeekNumber,
                            this.WP7.GetCurrentWeekNumber()
                        );
                        MessageBox.Show( message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
                        form.DialogResult = DialogResult.Ignore;
                        return;
                    }
                    var temp_data = new HDamData();
                    temp_data.Encode( new_data );
                    this.WP7.HDamTable.SetData( horse_num, ref temp_data );
                    this.WP7.HDamTable.Commit( horse_num );
                    this.DataUpdateAndRefresh( item_index, horse_num, ref temp_data );
                },
            };

            // 能力データの編集コントロール
            var abl_data_editor = new SpoilerLikeControls.BitCheckList( this.WP7, HAblData.Properties, abl_data.Decode() ) {
                Dock = DockStyle.Fill,
                ControlsFont = this.ListView1.Font,
                DataChanged = ( new_abl_data )=> {
                    if( this.WP7.TransactionWeekNumber != this.WP7.GetCurrentWeekNumber() ) {
                        var message = String.Format(
                            "データ取得時から週が変わっています({0}→{1})\r\n安全のため書き込みは行いません、再取得してください",
                            this.WP7.TransactionWeekNumber,
                            this.WP7.GetCurrentWeekNumber()
                        );
                        MessageBox.Show( message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
                        form.DialogResult = DialogResult.Ignore;
                        return;
                    }
                    var temp_data = new HAblData();
                    temp_data.Encode( new_abl_data );
                    this.WP7.HAblTable.SetData( data.abl_num, ref temp_data );
                    this.WP7.HAblTable.Commit( data.abl_num );
                    this.DataUpdateAndRefresh( item_index, horse_num, ref data );
                },
            };

            // 血統データの編集コントロール
            var blood_data_editor = new SpoilerLikeControls.BitCheckList( this.WP7, HBloodData.Properties, blood_data.Decode() ) {
                Dock = DockStyle.Fill,
                ControlsFont = this.ListView1.Font,
                DataChanged = ( new_blood_data )=> {
                    if( this.WP7.TransactionWeekNumber != this.WP7.GetCurrentWeekNumber() ) {
                        var message = String.Format(
                            "データ取得時から週が変わっています({0}→{1})\r\n安全のため書き込みは行いません、再取得してください",
                            this.WP7.TransactionWeekNumber,
                            this.WP7.GetCurrentWeekNumber()
                        );
                        MessageBox.Show( message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
                        form.DialogResult = DialogResult.Ignore;
                        return;
                    }
                    var temp_data = new HBloodData();
                    temp_data.Encode( new_blood_data );
                    this.WP7.HBloodTable.SetData( data.blood_num, ref temp_data );
                    this.WP7.HBloodTable.Commit( data.blood_num );
                    this.DataUpdateAndRefresh( item_index, horse_num, ref data );
                },
            };

            // 系統データの編集コントロール
            var family_line_data_editor = new SpoilerLikeControls.BitCheckList( this.WP7, HFamilyLineData.Properties, family_line_data.Decode() ) {
                Dock = DockStyle.Fill,
                ControlsFont = this.ListView1.Font,
                DataChanged = ( new_family_line_data )=> {
                    if( this.WP7.TransactionWeekNumber != this.WP7.GetCurrentWeekNumber() ) {
                        var message = String.Format(
                            "データ取得時から週が変わっています({0}→{1})\r\n安全のため書き込みは行いません、再取得してください",
                            this.WP7.TransactionWeekNumber,
                            this.WP7.GetCurrentWeekNumber()
                        );
                        MessageBox.Show( message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
                        form.DialogResult = DialogResult.Ignore;
                        return;
                    }
                    var temp_data = new HFamilyLineData();
                    temp_data.Encode( new_family_line_data );
                    this.WP7.HFamilyLineTable.SetData( blood_data.family_line_num, ref temp_data );
                    this.WP7.HFamilyLineTable.Commit( blood_data.family_line_num );
                    this.DataUpdateAndRefresh( item_index, horse_num, ref data );
                },
            };

            form.TabPageAdd( "能力データ", new Control[]{ abl_data_editor } );
            form.TabPageAdd( "繁殖牝馬データ", new Control[]{ data_editor } );
            form.TabPageAdd( "血統データ", new Control[]{ blood_data_editor } );
            form.TabPageAdd( String.Format( "{0}系データ", family_line_data.系統名() ), new Control[]{ family_line_data_editor } );

            if( form.ShowDialog() == DialogResult.Cancel ) {
                if( this.WP7.TransactionWeekNumber == this.WP7.GetCurrentWeekNumber() ) {
                    this.WP7.HDamTable.SetData( horse_num, ref data );
                    this.WP7.HDamTable.Commit( horse_num );
                    this.WP7.HAblTable.SetData( data.abl_num, ref abl_data );
                    this.WP7.HAblTable.Commit( data.abl_num );
                    this.WP7.HBloodTable.SetData( data.blood_num, ref blood_data );
                    this.WP7.HBloodTable.Commit( data.blood_num );
                    this.WP7.HFamilyLineTable.SetData( blood_data.family_line_num, ref family_line_data );
                    this.WP7.HFamilyLineTable.Commit( blood_data.family_line_num );
                    this.DataUpdateAndRefresh( item_index, horse_num, ref data );
                }
            }
        }