/// <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> void timeTable_OnScheduleEdited (object sender, EScheduleEditedEventArgs e) { if (StartDate <= e.Schedule.Date.Date && e.Schedule.Date.Date <= EndDate) { // SetUpMember2Pattern(e.Schedule.Member); // BodyTable.Refresh(); // 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(); }
/// <summary>自動設定された /// </summary> /// <param name="sender">イベントの発生したオブジェクト</param> /// <param name="e">発生したイベント</param> void mainForm_OnTimeTableAutoEdited (object sender, TimeTableManager.UI.TimeTableAutoEditedEventArgs e) { SetUpValidMembers(); SetUpValidPatterns(); BodyTable.Refresh(); }