/// <summary>マウスダウン時ステータスを更新する
 /// </summary>
 /// <param name="sender">イベントの発生したオブジェクト</param>
 /// <param name="e">発生したイベント</param>
 private void BodyTable_CellMouseDown (object sender, DataGridViewCellMouseEventArgs e) {
     this.BarLabelStatus = EnumBarLabelStatus.None;
     CurrentRowIndex = e.RowIndex;
     if (this.TimeTable != null && CurrentRowIndex >= 0 && e.ColumnIndex == 2 && Editable) {
         CMember member = this.Members[CurrentRowIndex];
         PatternWrapper wrapper = Member2PatternWrapper[member];
         Rectangle CellBounds1 = BodyTable.GetCellDisplayRectangle(e.ColumnIndex, CurrentRowIndex, false);
         if (wrapper.Pattern != null && (!wrapper.Pattern.BuiltIn || wrapper.Pattern == CPattern.MULTI)) {
             Rectangle CellBounds2 = new Rectangle(new Point(0, 0), CellBounds1.Size);
             RectangleF rect = GetPattern2Rect(CellBounds2, wrapper);
             if (rect.Top < e.Y && e.Y < rect.Bottom) {
                 if (rect.X - SplitBuffer < e.X && e.X < rect.X + SplitBuffer) {
                     // 左端
                     this.BarLabelStatus = EnumBarLabelStatus.StartMoving;
                 } else if (rect.Right - SplitBuffer < e.X && e.X < rect.Right + SplitBuffer) {
                     // 右端
                     this.BarLabelStatus = EnumBarLabelStatus.EndMoving;
                 } else if (rect.X < e.X && e.X < rect.Right) {
                     // 内部
                     this.BarLabelStatus = EnumBarLabelStatus.AllMoving;
                 }
             }
         } else {
             this.BarLabelStatus = EnumBarLabelStatus.Creating;
         }
         StartPoint = e.Location;
         MovingPoint = e.Location;
     }
 }
 /// <summary>マウスカーソルをどうする?
 /// </summary>
 /// <param name="sender">イベントの発生したオブジェクト</param>
 /// <param name="e">発生したイベント</param>
 private void BodyTable_CellMouseMove (object sender, DataGridViewCellMouseEventArgs e) {
     if (this.TimeTable != null && e.RowIndex >= 0 && e.ColumnIndex == 2 && Editable) {
         CMember member = this.Members[e.RowIndex];
         PatternWrapper wrapper = Member2PatternWrapper[member];
         if (wrapper.Pattern != null && (!wrapper.Pattern.BuiltIn || wrapper.Pattern == CPattern.MULTI) && BarLabelStatus == EnumBarLabelStatus.None) {
             Rectangle CellBounds1 = BodyTable.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
             Rectangle CellBounds2 = new Rectangle(new Point(0, 0), CellBounds1.Size);
             RectangleF rect = GetPattern2Rect(CellBounds2, wrapper);
             if (rect.Top < e.Y && e.Y < rect.Bottom) {
                 if (rect.X - SplitBuffer < e.X && e.X < rect.X + SplitBuffer) {
                     // 左端
                     this.Cursor = Cursors.VSplit;
                 } else if (rect.Right - SplitBuffer < e.X && e.X < rect.Right + SplitBuffer) {
                     // 右端
                     this.Cursor = Cursors.VSplit;
                 } else if (rect.X < e.X && e.X < rect.Right) {
                     // 内部
                     this.Cursor = Cursors.Hand;
                 } else {
                     this.Cursor = Cursors.Default;
                 }
             }
         }
         if (BarLabelStatus != EnumBarLabelStatus.None) {
             MovingPoint = e.Location;
             BodyTable.Refresh();
         }
     }
 }
        /// <summary>マウスがあがったとき、バーチャートを更新する
        /// </summary>
        /// <param name="sender">イベントの発生したオブジェクト</param>
        /// <param name="e">発生したイベント</param>
        private void BodyTable_CellMouseUp (object sender, DataGridViewCellMouseEventArgs e) {
            EnumBarLabelStatus CurrentStatus = BarLabelStatus;
            BarLabelStatus = EnumBarLabelStatus.None;
            if (CurrentStatus != EnumBarLabelStatus.None && e.RowIndex >= 0) {

                //
                Rectangle CellBounds1 = BodyTable.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
                //
                float MovingSpan0 = e.X - StartPoint.X;
                float MovingSpan1 = (e.X > StartPoint.X ? MovingSpan0 : -MovingSpan0);
                TimeSpan Span = GetXSpan2TimeSpan(CellBounds1.Width, StartPoint.X, e.X);
                if ((Span > TimeSpan.Zero ? Span.TotalHours > Half : Span.TotalHours < -Half)) {
                    Rectangle CellBounds2 = new Rectangle(new Point(0, 0), CellBounds1.Size);
                    CMember member = this.Members[e.RowIndex];
                    PatternWrapper wrapper;
                    TimeSpan SpanStart = TimeSpan.Zero, SpanEnd = TimeSpan.Zero, SpanRest = TimeSpan.Zero;
                    switch (CurrentStatus) {
                        case EnumBarLabelStatus.StartMoving:
                            wrapper = this.Member2PatternWrapper[member];
                            SpanStart = GetX2TimeSpan(CellBounds1.Width, e.X, TableStart);
                            SpanEnd = wrapper.EndTime;
                            SpanRest = wrapper.Pattern.Rest;
                            break;
                        case EnumBarLabelStatus.EndMoving:
                            wrapper = this.Member2PatternWrapper[member];
                            SpanStart = wrapper.StartTime;
                            SpanEnd = GetX2TimeSpan(CellBounds1.Width, e.X, TableStart);
                            SpanRest = wrapper.Pattern.Rest;
                            break;
                        case EnumBarLabelStatus.AllMoving:
                            wrapper = this.Member2PatternWrapper[member];
                            SpanStart = wrapper.StartTime + Span;
                            SpanEnd = wrapper.EndTime + Span;
                            SpanRest = wrapper.Pattern.Rest;
                            break;
                        case EnumBarLabelStatus.Creating:
                            SpanStart = GetX2TimeSpan(CellBounds1.Width, StartPoint.X, TableStart);
                            SpanEnd = GetX2TimeSpan(CellBounds1.Width, e.X, TableStart);
                            break;
                    }
                    if (SpanStart > SpanEnd) {
                        // スワップ
                        TimeSpan Swap = SpanStart;
                        SpanStart = SpanEnd;
                        SpanEnd = Swap;
                    }
                    //
                    CreatePattern(member, SpanStart, SpanEnd, TimeSpan.Zero);
                }
            }
            BodyTable.Refresh();
        }