The Axmor Gantt Chart is Silverlight component. The main purpose of the component is data representation. It has no own communication with e.g. server side. It just shows data provided by application that uses Axmor Gantt Chart.

 

 

The architecture of Axmor Gantt Chart control conforms to MVP pattern:

 

·         Model – data to show can be loaded using DataModel class.

 

·         View – data renderers are in

Axmor.GanttControl.Controls.Views.GanttView,

Axmor.GanttControl.Controls.Views.TableView

namespaces.

The main classes that implement logic of rendering are TableViewManager and GanttViewManager.

 

·         Presenter – user actions are processed at PresenterManager class.

 

 

The sample below illustrates how to create Axmor Gantt Chart control.

 

Content of the .xaml page:

 

<UserControl x:Class="AX_GNT.Page"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

    <Canvas x:Name="LayoutRoot" Background="White">

    </Canvas>

</UserControl>

 

Code of the “Code Behind” file:

 

“using”:

 

using System;

using System.Windows.Controls;

 

using Axmor.GanttControl.Controls.Views;

using Axmor.GanttControl.Data;

using Axmor.GanttControl.Data.Calendar;

using Axmor.GanttControl.Data.Constraint;

using Axmor.GanttControl.Data.Task;

using Axmor.GanttControl.Presenter;

 

code:

 

// =====================================================================

// Create Tasks

 

// Create the empty collection of the tasks

TasksList tList = new TasksList();

 

// Create main "Summary" task

// start - June 01, 2009

DateTime start = new DateTime(2009, 6, 1);

// finish - June 26, 2009

DateTime finish = new DateTime(2009, 6, 26);

// name - Project

string name = "Project";

// Create the task object

SummaryTask st = new SummaryTask("summ", start, finish, name);

st.ParentId = "";

st.Level = 0;

// add the task to the collection

tList.Add(st);

 

// Create the first "Regular" task

// start - June 01, 2009

start = new DateTime(2009, 6, 1);

// finish - June 14, 2009

finish = new DateTime(2009, 6, 14);

// name - Task 1

name = "Task 1";

// Create the task object

RegularTask rt1 = new RegularTask("rt1", start, finish, name);

rt1.ParentId = "summ";

rt1.Level = 1;

rt1.Duration = 10 * Axmor.GanttControl.Data.Calendar.Calendar.SecondsInWorkingDay;

rt1.PercentsDone = 50;

// add the task to the collection

tList.Add(rt1);

 

// Create the second "Regular" task

// start - June 14, 2009

start = new DateTime(2009, 6, 14);

// finish - June 26, 2009

finish = new DateTime(2009, 6, 26);

// name - Task 2

name = "Task 2";

// Create the task object

RegularTask rt2 = new RegularTask("rt2", start, finish, name);

rt2.ParentId = "summ";

rt2.Level = 1;

rt2.Duration = 9 * Axmor.GanttControl.Data.Calendar.Calendar.SecondsInWorkingDay;

// add the task to the collection

tList.Add(rt2);

 

// Create the "Milestone" task

// date - June 14, 2009

DateTime date = new DateTime(2009, 6, 26);

// name - End of the Project

name = "End of the Project";

// Create the task object

MilestoneTask mt = new MilestoneTask("mt", date, name);

mt.ParentId = "summ";

mt.Level = 1;

// add the task to the collection

tList.Add(mt);

 

// =====================================================================

// Create Constraints

 

// Create the empty collection of the constraints

ConstraintList cList = new ConstraintList();

 

// Create the "Finish-to-Start" Constraint between "Task 1" and "Task 2" tasks

Constraint constraint1 = new Constraint(ConstraintType.FS, rt1, rt2);

// add the Constraint to the collection

cList.Add(constraint1);

 

// Create the "Finish-to-Finish" Constraint between "Task 2" and "End of the Project" tasks

Constraint constraint2 = new Constraint(ConstraintType.FF, rt2, mt);

// add the Constraint to the collection

cList.Add(constraint2);

 

// =====================================================================

// Create DataModel

 

// Create DataModel object with collections of tasks and constraints

DataModel model = new DataModel(cList, tList);

 

// Create Style for the Ax-GNT control

Axmor.GanttControl.Style.Style style = new Axmor.GanttControl.Style.Style();

// loading the default style

style.LoadDefaultStyle();

 

// set the style

model.Style = style;

 

// =====================================================================

// Create Calendar

 

// Create the Calendar object with the "Day" mode

Axmor.GanttControl.Data.Calendar.Calendar c1 = new Axmor.GanttControl.Data.Calendar.Calendar(Mode.Day);

// Set the Saturday as the weekend

c1.Weekend.Add(DayOfWeek.Saturday);

// Set the Sunday as the weekend

c1.Weekend.Add(DayOfWeek.Sunday);

// Set the "Calendar" property of the DataModel

model.Calendar = c1;

 

// =====================================================================

// Create Instance of AX-GNT control

PresenterManager pm = new PresenterManager(model);

PresenterControl axgntcontrol = pm.GetStandardGanttChart();

// Add control into the Container

LayoutRoot.Children.Add(axgntcontrol);