作成日: 2020/06/25 最終更新日: 2020/06/25
文書種別
使用方法
詳細
コードを用いてカスタムカレンダーを追加するには、CustomCalendarオブジェクトを使用します。WorkWeekクラスの各曜日のInterval_1、Interval_2などのプロパティを用いて稼働日の開始時刻/終了時刻を指定し、このカスタムカレンダーのWorkWeeksコレクションに追加することで、稼働日を設定できます。さらに、CalendarExceptionクラスのInterval_1、Interval_2などを用いて例外を設定することも可能です。
また、設計時に追加したカスタムカレンダー※は、IDを指定してCustomCalendarsコレクションから取得可能で、そのWorkWeekプロパティを用いて稼働日を変更する等のことが可能です。
※C1GanttView コントロールを右クリック > コンテキストメニューから「カレンダーの編集」を選択
> C1GanttView.CustomCalendars コレクションエディタで追加。
なお、これらのカスタムカレンダーの設定結果は、実行時に次の場所で確認することができます。
・チャートビューのコンテキストメニュー > 「稼働時間の変更」をクリック
> 稼働時間の変更ダイアログ > カレンダー一覧
◎サンプルコード(VB)
また、設計時に追加したカスタムカレンダー※は、IDを指定してCustomCalendarsコレクションから取得可能で、そのWorkWeekプロパティを用いて稼働日を変更する等のことが可能です。
※C1GanttView コントロールを右クリック > コンテキストメニューから「カレンダーの編集」を選択
> C1GanttView.CustomCalendars コレクションエディタで追加。
なお、これらのカスタムカレンダーの設定結果は、実行時に次の場所で確認することができます。
・チャートビューのコンテキストメニュー > 「稼働時間の変更」をクリック
> 稼働時間の変更ダイアログ > カレンダー一覧
◎サンプルコード(VB)
Imports C1.Win.C1GanttView
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' 新しいカスタムカレンダーの追加
Dim CustomCalendar1 As CustomCalendar = New CustomCalendar
CustomCalendar1.Name = "カレンダーA"
CustomCalendar1.HonorDefaultExceptions = True
' 稼働時間の設定
Dim ww As WorkWeek = New WorkWeek
ww.SaturdayTimes.DayTimesKind = DayTimesKind.SpecificTimes
ww.SaturdayTimes.Interval_1.Empty = False
ww.SaturdayTimes.Interval_1.From = New DateTime(1, 1, 1, 8, 0, 0, 0)
ww.SaturdayTimes.Interval_1.To = New DateTime(1, 1, 1, 12, 0, 0, 0)
CustomCalendar1.WorkWeeks.Add(ww)
' 例外の追加
Dim CalendarException1 As CalendarException = New CalendarException()
CalendarException1.Name = "ステイホーム月間"
CalendarException1.Workday = True
CalendarException1.StartDate = New DateTime(2020, 5, 1)
CalendarException1.FinishDate = New DateTime(2020, 5, 31)
CalendarException1.Interval_1.Empty = False
CalendarException1.Interval_1.From = New DateTime(1, 1, 1, 9, 30, 0, 0)
CalendarException1.Interval_1.To = New DateTime(1, 1, 1, 12, 0, 0, 0)
CalendarException1.Interval_2.Empty = False
CalendarException1.Interval_2.From = New DateTime(1, 1, 13, 0, 0, 0, 0)
CalendarException1.Interval_2.To = New DateTime(1, 1, 1, 16, 30, 0, 0)
CalendarException1.LimitedBy = ExceptionLimitedBy.FinishDate
CustomCalendar1.CalendarExceptions.Add(CalendarException1)
' カスタムカレンダー コレクションに追加
C1GanttView1.CustomCalendars.Add(CustomCalendar1)
' デザイン時に追加したカスタムカレンダーの設定変更
Dim CustomCalendar2 As CustomCalendar = C1GanttView1.CustomCalendars(0)
CustomCalendar2.Name = "カレンダーB"
CustomCalendar2.WorkWeeks(0).SaturdayTimes.DayTimesKind = DayTimesKind.SpecificTimes
CustomCalendar2.WorkWeeks(0).SaturdayTimes.Interval_1.Empty = False
CustomCalendar2.WorkWeeks(0).SaturdayTimes.Interval_1.From = New DateTime(1, 1, 1, 8, 0, 0, 0)
CustomCalendar2.WorkWeeks(0).SaturdayTimes.Interval_1.To = New DateTime(1, 1, 1, 12, 0, 0, 0)
End Sub
End Class
◎サンプルコード(C#)using C1.Win.C1GanttView;
namespace GanttViewDemoJP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// 新しいカスタムカレンダーの設定
CustomCalendar customCalendar1 = new CustomCalendar();
customCalendar1.Name = "カレンダーA"; //名前の設定
customCalendar1.HonorDefaultExceptions = true;
// 稼働時間の設定
WorkWeek ww = new WorkWeek();
ww.SundayTimes.DayTimesKind = DayTimesKind.SpecificTimes;
ww.SundayTimes.Interval_1.Empty = false;
ww.SundayTimes.Interval_1.From = new DateTime(1, 1, 1, 8, 0, 0, 0);
ww.SundayTimes.Interval_1.To = new DateTime(1, 1, 1, 12, 0, 0, 0);
customCalendar1.WorkWeeks.Add(ww);
// 例外の追加
CalendarException calendarException1 = new CalendarException();
calendarException1.Name = "ステイホーム月間";
calendarException1.Workday = true;
calendarException1.StartDate = new DateTime(2020, 05, 01);
calendarException1.FinishDate = new DateTime(2020, 05, 31);
calendarException1.Interval_1.Empty = false;
calendarException1.Interval_1.From = new DateTime(1, 1, 1, 9, 30, 0, 0);
calendarException1.Interval_1.To = new DateTime(1, 1, 1, 12, 0, 0, 0);
calendarException1.Interval_2.Empty = false;
calendarException1.Interval_2.From = new DateTime(1, 1, 13, 0, 0, 0, 0);
calendarException1.Interval_2.To = new DateTime(1, 1, 1, 16, 30, 0, 0);
calendarException1.LimitedBy = ExceptionLimitedBy.FinishDate;
customCalendar1.CalendarExceptions.Add(calendarException1);
// カスタムカレンダー コレクションに追加
c1GanttView1.CustomCalendars.Add(customCalendar1);
// デザイン時に追加したカスタムカレンダーの設定変更
CustomCalendar customCalendar2 = c1GanttView1.CustomCalendars[0];
customCalendar2.Name = "カレンダーB"; //名前の変更
customCalendar2.WorkWeeks[0].SaturdayTimes.DayTimesKind = DayTimesKind.SpecificTimes;
customCalendar2.WorkWeeks[0].SaturdayTimes.Interval_1.Empty = false;
customCalendar2.WorkWeeks[0].SaturdayTimes.Interval_1.From = new DateTime(1, 1, 1, 8, 0, 0, 0);
customCalendar2.WorkWeeks[0].SaturdayTimes.Interval_1.To = new DateTime(1, 1, 1, 12, 0, 0, 0);
}
}
}
旧文書番号
85755