@syncfusion/ej2-gantt
Version:
Essential JS 2 Gantt Component
599 lines • 154 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { PointF, PdfColor, PdfStringLayouter, PdfPen, PdfSolidBrush, RectangleF, SizeF, PdfStandardFont, PdfFontStyle, PdfFontFamily, PdfStringFormat, PdfVerticalAlignment, PdfTextAlignment, PdfWordWrapType, PdfDashStyle, PdfPath, PdfBitmap, PdfBrushes, PdfLinearGradientBrush } from '@syncfusion/ej2-pdf-export';
import { pixelToPoint, pointToPixel } from '../base/utils';
import { isNullOrUndefined } from '@syncfusion/ej2-base';
/**
* @hidden
*/
var PdfGanttTaskbarCollection = /** @class */ (function () {
function PdfGanttTaskbarCollection(parent) {
/** Defines the task baselineHeight . */
this.baselineHeight = 8;
this.segment = [];
this.segmentCollection = [];
/**
* @private
*/
this.leftTaskLabel = {};
/**
* @private
*/
this.rightTaskLabel = {};
this.startPage = -1;
this.endPage = -1;
this.pageDetailedWidth = 0;
this.defaultFontSize = 9;
this.spaceBetweenImageAndValue = 8;
this.parent = parent;
}
PdfGanttTaskbarCollection.prototype.add = function () {
return new PdfGanttTaskbarCollection(this.parent);
};
/**
* @param {PdfPage} page .
* @returns {PdfPage} .
* Get the next PDF page
*/
PdfGanttTaskbarCollection.prototype.GetNextPage = function (page) {
var section = page.section;
var index = section.indexOf(page);
var nextPage = null;
if (index === section.count - 1) {
nextPage = section.add();
}
else {
nextPage = section.getPages()[index + 1];
}
return nextPage;
};
PdfGanttTaskbarCollection.prototype.isAutoFit = function () {
return ((this.parent.pdfExportModule && this.parent.pdfExportModule.helper.exportProps &&
this.parent.pdfExportModule.helper.exportProps.fitToWidthSettings &&
this.parent.pdfExportModule.helper.exportProps.fitToWidthSettings.isFitToWidth) ||
this.parent.timelineModule.isZoomedToFit) ? true : false;
};
/**
* Draw the taskbar, chart back ground
*
* @private
*/
/* eslint-disable */
PdfGanttTaskbarCollection.prototype.drawTaskbar = function (page, startPoint, detail, cumulativeWidth, rowHeight, taskbar, lineWidth, currentPageIndex) {
var _this = this;
var taskGraphics = page.graphics;
var isNextPage = false;
var pageSize = page.getClientSize();
var yPoint = startPoint.y + rowHeight;
var count = currentPageIndex;
//code for while current pdf page is exceed
if (yPoint > pageSize.height) {
page = this.GetNextPage(page);
page['contentWidth'] = (this.isAutoFit()) ? pointToPixel(detail.endPoint - detail.startPoint) : detail.endPoint - detail.startPoint;
taskGraphics = page.graphics;
startPoint.y = 0;
this.parent.pdfExportModule.gantt.currentPage = this.parent.pdfExportModule.gantt.currentPage + 1;
this.parent.pdfExportModule.gantt.eventMarker.renderHeight = this.parent.pdfExportModule.gantt.layouter.pageHeightCollection[this.parent.pdfExportModule.gantt.currentPage].totalHeight;
if (this.parent.pdfExportModule.gantt.enableHeader) {
this.parent.pdfExportModule.gantt.chartHeader.drawPageTimeline(page, startPoint, detail, this.parent.pdfExportModule.gantt.currentPage);
startPoint.y = pixelToPoint(this.parent.timelineModule.isSingleTier ? 45 : 60);
}
isNextPage = true;
}
this.drawLeftLabel(page, startPoint, detail, cumulativeWidth, taskbar);
//Draw Taskbar
var font = new PdfStandardFont(this.fontFamily, this.defaultFontSize, PdfFontStyle.Regular);
var fontColor = null;
var fontBrush = new PdfSolidBrush(this.progressFontColor);
var customizedFont;
var customizedFontBrush;
var customizedFontColor;
customizedFont = font;
if (!isNullOrUndefined(taskbar.taskbarTemplate.value) && taskbar.taskbarTemplate.fontStyle && taskbar.taskbarTemplate.fontStyle.fontFamily && taskbar.taskbarTemplate.fontStyle.fontSize) {
customizedFont = new PdfStandardFont(taskbar.taskbarTemplate.fontStyle.fontFamily, taskbar.taskbarTemplate.fontStyle.fontSize, taskbar.taskbarTemplate.fontStyle.fontStyle);
}
customizedFontBrush = !isNullOrUndefined(taskbar.taskbarTemplate.value) && taskbar.taskbarTemplate.fontStyle && taskbar.taskbarTemplate.fontStyle.fontColor
? new PdfSolidBrush(taskbar.taskbarTemplate.fontStyle.fontColor)
: fontBrush;
customizedFontColor = !isNullOrUndefined(taskbar.taskbarTemplate.value) && taskbar.taskbarTemplate.fontStyle && taskbar.taskbarTemplate.fontStyle.fontBrush
? new PdfPen(taskbar.taskbarTemplate.fontStyle.fontBrush)
: fontColor;
if (!isNullOrUndefined(this.parent.pdfExportModule['helper']['exportProps'].ganttStyle) &&
this.parent.pdfExportModule['helper']['exportProps'].ganttStyle.font) {
font = this.parent.pdfExportModule['helper']['exportProps'].ganttStyle.font;
}
var taskLabelFont;
var taskLabelFontBrush;
var ganttStyle = this.parent.pdfExportModule['helper']['exportProps'].ganttStyle;
var taskLabelSettings = this.labelSettings.taskLabel;
if (taskLabelSettings.fontStyle.fontSize || taskLabelSettings.fontStyle.fontFamily || taskLabelSettings.fontStyle.fontStyle) {
var fontFamily = (taskLabelSettings.fontStyle && taskLabelSettings.fontStyle.fontFamily) ?
taskLabelSettings.fontStyle.fontFamily : (this.fontFamily || PdfFontFamily.Helvetica);
var fontSize = (taskLabelSettings.fontStyle && taskLabelSettings.fontStyle.fontSize) ? taskLabelSettings.fontStyle.fontSize : this.defaultFontSize;
var fontStyle = (taskLabelSettings.fontStyle &&
typeof taskLabelSettings.fontStyle.fontStyle === 'string')
? this.parent.pdfExportModule.helper['getFontStyle'](taskLabelSettings.fontStyle.fontStyle)
: (taskLabelSettings.fontStyle && taskLabelSettings.fontStyle.fontStyle)
? taskLabelSettings.fontStyle.fontStyle
: PdfFontStyle.Regular;
var taskFont = new PdfStandardFont(fontFamily, fontSize, fontStyle);
taskLabelFont = taskFont;
}
else if (ganttStyle && ganttStyle.label && ganttStyle.label.fontBrush) {
taskLabelFontBrush = new PdfSolidBrush(ganttStyle.label.fontBrush);
}
else {
taskLabelFont = font;
}
taskLabelFontBrush = taskbar.labelSettings.taskLabel.fontStyle.fontColor
? new PdfSolidBrush(taskbar.labelSettings.taskLabel.fontStyle.fontColor)
: (ganttStyle && ganttStyle.label && ganttStyle.label.fontColor
? new PdfSolidBrush(ganttStyle.label.fontColor)
: fontBrush);
if (!isNullOrUndefined(ganttStyle) && !isNullOrUndefined(ganttStyle.label) && (!isNullOrUndefined(ganttStyle.label.fontBrush))) {
fontColor = new PdfPen(ganttStyle.label.fontBrush);
}
if (!isNullOrUndefined(ganttStyle) && !isNullOrUndefined(ganttStyle.label) && (!isNullOrUndefined(ganttStyle.label.fontSize)
|| !isNullOrUndefined(ganttStyle.label.fontStyle) ||
!isNullOrUndefined(ganttStyle.label.fontFamily))) {
taskLabelFont = this.getPdfFont(ganttStyle);
}
var progressFormat = new PdfStringFormat();
progressFormat.lineAlignment = PdfVerticalAlignment.Middle;
progressFormat.alignment = PdfTextAlignment.Right;
var isLabelString = false;
var updatedWidth;
if (!isNullOrUndefined(this.taskLabel) && (/^[a-zA-Z0-9]/.test(this.taskLabel))) {
if (this.taskLabel === '0' || this.taskLabel === '0%') {
updatedWidth = this.width;
progressFormat.alignment = PdfTextAlignment.Left;
}
}
if ((!isNullOrUndefined(this.taskLabel) && (/^[a-zA-Z]/.test(this.taskLabel))) || (!isNullOrUndefined(taskbar.taskbarTemplate.value))) {
isLabelString = true;
progressFormat.alignment = PdfTextAlignment.Left;
}
if (!isNullOrUndefined(ganttStyle) && !isNullOrUndefined(ganttStyle.label) && !isNullOrUndefined(ganttStyle.label.format)) {
progressFormat = ganttStyle.label.format;
}
var taskLabelPadding = { left: 0, right: 0, top: 0, bottom: 0 };
if (!isNullOrUndefined(ganttStyle) && !isNullOrUndefined(ganttStyle.label) &&
!isNullOrUndefined(ganttStyle.label.padding)) {
taskLabelPadding = ganttStyle.label.padding;
}
var pageIndex = -1;
var baselinePen = new PdfPen(taskbar.baselineBorderColor);
var baselineBrush = new PdfSolidBrush(taskbar.baselineColor);
var template = taskbar.taskbarTemplate;
var renderedBaseline = false;
if (!taskbar.isMilestone) {
var taskbarPen_1 = new PdfPen(taskbar.taskBorderColor);
var taskBrush_1 = new PdfSolidBrush(taskbar.taskColor);
var manualParentBorderPen = new PdfPen(taskbar.manualParentBorder);
var manualChildBorderPen = new PdfPen(taskbar.manualChildBorder);
var manualTaskbarPen = new PdfPen(taskbar.manuallineColor);
var manualParentPen = new PdfPen(taskbar.manualParentProgress);
var manualline = new PdfPen(taskbar.manuallineColor);
var manuallineBrush = new PdfSolidBrush(taskbar.manuallineColor);
var splitline = new PdfPen(taskbar.splitLineBackground);
var manualBrush = new PdfSolidBrush(taskbar.manualParentBackground);
var manualChildBrush = new PdfSolidBrush(taskbar.manualChildBackground);
var manualChildProgressBrush = new PdfSolidBrush(taskbar.manualChildProgress);
var manualProgressBrush = new PdfSolidBrush(taskbar.manualParentProgress);
var progressPen_1 = new PdfPen(taskbar.progressColor);
var progressBrush_1 = new PdfSolidBrush(taskbar.progressColor);
var adjustHeightforTaskbar = pixelToPoint((this.parent.rowHeight - this.height) / 2.0);
var adjustHeightforBaseline = pixelToPoint((this.parent.rowHeight - this.height) / 4.5);
var adjustHeight_1 = this.parent.renderBaseline ? adjustHeightforBaseline : adjustHeightforTaskbar;
pageIndex = page.section.indexOf(page);
var startDate = isNullOrUndefined(this.unscheduleStarteDate) ? this.startDate : this.unscheduleStarteDate;
var endDate = isNullOrUndefined(this.unscheduleEndDate) ? this.endDate : this.unscheduleEndDate;
var imageSize_1 = 10;
//Task start and end date both are in the range of header split up start and end date
if (detail.startDate <= startDate && endDate <= detail.endDate) {
if (!this.isStartPoint) {
this.taskStartPoint = __assign({}, startPoint);
this.isStartPoint = true;
}
if (!this.isScheduledTask && this.unscheduledTaskBy === 'duration') {
var brush1 = void 0;
var brush2 = void 0;
if (this.isAutoFit()) {
brush1 = new PdfLinearGradientBrush(new PointF(startPoint.x + (this.left - cumulativeWidth) + 0.5 + (taskbar.width) / 2, 0), new PointF(startPoint.x + (this.left - cumulativeWidth), 0), new PdfColor(taskbar.unscheduledTaskBarColor), new PdfColor(255, 255, 255));
taskGraphics.drawRectangle(brush1, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (taskbar.width), pixelToPoint(taskbar.height));
brush2 = new PdfLinearGradientBrush(new PointF(startPoint.x + (this.left - cumulativeWidth) + 0.5 + (taskbar.width), 0), new PointF(startPoint.x + (this.left - cumulativeWidth) + (taskbar.width) / 2, 0), new PdfColor(255, 255, 255), new PdfColor(taskbar.unscheduledTaskBarColor));
//Draw rectangle to fill linear gradient color
taskGraphics.drawRectangle(brush2, startPoint.x + (this.left - cumulativeWidth) + 0.5 + (taskbar.width) / 2, startPoint.y + adjustHeight_1, (taskbar.width) / 2, pixelToPoint(taskbar.height));
if (template.image || template.value) {
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.taskbarTemplate.image[0].width), pixelToPoint(taskbar.taskbarTemplate.image[0].height));
}
else {
imageWidth = 0;
}
!isNullOrUndefined(taskbar.taskbarTemplate.value) ? taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + (this.left - cumulativeWidth) + 0.5 + imageWidth, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.width), pixelToPoint(this.height), progressFormat) : '';
}
}
else {
brush1 = new PdfLinearGradientBrush(new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5 + pixelToPoint(taskbar.width) / 2, 0), new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth), 0), new PdfColor(taskbar.unscheduledTaskBarColor), new PdfColor(255, 255, 255));
taskGraphics.drawRectangle(brush1, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.width), pixelToPoint(taskbar.height));
brush2 = new PdfLinearGradientBrush(new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5 + pixelToPoint(taskbar.width), 0), new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + pixelToPoint(taskbar.width) / 2, 0), new PdfColor(255, 255, 255), new PdfColor(taskbar.unscheduledTaskBarColor));
//Draw rectangle to fill linear gradient color
taskGraphics.drawRectangle(brush2, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5 + pixelToPoint(taskbar.width) / 2, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.width) / 2, pixelToPoint(taskbar.height));
if (template.image || template.value) {
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.taskbarTemplate.image[0].width), pixelToPoint(taskbar.taskbarTemplate.image[0].height));
}
else {
imageWidth = 0;
}
!isNullOrUndefined(taskbar.taskbarTemplate.value) ? taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5 + imageWidth, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.width), pixelToPoint(this.height), progressFormat) : '';
}
}
}
else if (!this.isScheduledTask && this.unscheduledTaskBy === "endDate") {
this.drawUnscheduledTask(taskGraphics, startPoint, cumulativeWidth, adjustHeight_1);
}
else if (!this.isScheduledTask && this.unscheduledTaskBy !== 'duration') {
this.drawUnscheduledTask(taskGraphics, startPoint, cumulativeWidth, adjustHeight_1);
}
else {
if (taskbar.isSpliterTask) {
splitline.dashStyle = PdfDashStyle.Dot;
if (this.isAutoFit()) {
taskGraphics.drawLine(splitline, new PointF(startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 + pixelToPoint(taskbar.height / 2)), new PointF((taskbar.width) + startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 + pixelToPoint(taskbar.height / 2)));
}
else {
taskGraphics.drawLine(splitline, new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 + pixelToPoint(taskbar.height / 2)), new PointF(pixelToPoint(taskbar.width) + startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 + pixelToPoint(taskbar.height / 2)));
}
taskbar.segmentCollection.map(function (data, index) {
var segmenttaskbarPen = !isNullOrUndefined(_this.taskSegmentStyles) ? new PdfPen(_this.taskSegmentStyles[index].taskBorderColor) : taskbarPen_1;
var segmenttaskBrush = !isNullOrUndefined(_this.taskSegmentStyles) ? new PdfSolidBrush(_this.taskSegmentStyles[index].taskColor) : taskBrush_1;
if (_this.isAutoFit()) {
taskGraphics.drawRectangle(segmenttaskbarPen, segmenttaskBrush, startPoint.x + (_this.left + data.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (data.width), pixelToPoint(taskbar.height));
if (template.image || template.value) {
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + (_this.left + data.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.taskbarTemplate.image[0].width), pixelToPoint(taskbar.taskbarTemplate.image[0].height));
}
else {
imageWidth = 0;
}
!isNullOrUndefined(taskbar.taskbarTemplate.value) ? taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + (_this.left + data.left - cumulativeWidth) + 0.5 + imageWidth, startPoint.y + adjustHeight_1, pixelToPoint(data.width), pixelToPoint(taskbar.height), progressFormat) : '';
}
}
else {
taskGraphics.drawRectangle(segmenttaskbarPen, segmenttaskBrush, startPoint.x + pixelToPoint(_this.left + data.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(data.width), pixelToPoint(taskbar.height));
if (template.image || template.value) {
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + pixelToPoint(_this.left + data.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.taskbarTemplate.image[0].width), pixelToPoint(taskbar.taskbarTemplate.image[0].height));
}
else {
imageWidth = 0;
}
!isNullOrUndefined(taskbar.taskbarTemplate.value) ? taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + pixelToPoint(_this.left + data.left - cumulativeWidth) + 0.5 + imageWidth, startPoint.y + adjustHeight_1, pixelToPoint(data.width), pixelToPoint(taskbar.height), progressFormat) : '';
}
}
});
}
else if (!taskbar.isAutoSchedule && taskbar.isParentTask) {
taskGraphics.save();
var path = new PdfPath();
path.addEllipse(0, 0, 5, 5);
if (this.isAutoFit()) {
taskGraphics.translateTransform(startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 - 2);
}
else {
taskGraphics.translateTransform(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 - 2);
}
taskGraphics.drawPath(manualTaskbarPen, manuallineBrush, path);
taskGraphics.restore();
var path1 = new PdfPath();
path1.addEllipse(0, 0, 5, 5);
taskGraphics.save();
if (this.isAutoFit()) {
taskGraphics.translateTransform(startPoint.x + (this.left - cumulativeWidth) + 0.5 + (this.width), startPoint.y + adjustHeight_1 - 2);
}
else {
taskGraphics.translateTransform(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5 + pixelToPoint(this.width), startPoint.y + adjustHeight_1 - 2);
}
taskGraphics.drawPath(manualTaskbarPen, manuallineBrush, path1);
taskGraphics.restore();
manualline.dashStyle = PdfDashStyle.Solid;
if (this.isAutoFit()) {
taskGraphics.drawLine(manualline, new PointF(startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1), new PointF((taskbar.width) + startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1));
}
else {
taskGraphics.drawLine(manualline, new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1), new PointF(pixelToPoint(taskbar.width) + startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1));
}
}
else if (!taskbar.isAutoSchedule && !taskbar.isParentTask) {
taskGraphics.save();
taskGraphics.setTransparency(0.87);
if (this.isAutoFit()) {
taskGraphics.drawRectangle(manualChildBorderPen, manualChildBrush, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (taskbar.width), pixelToPoint(taskbar.height));
}
else {
taskGraphics.drawRectangle(manualChildBorderPen, manualChildBrush, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.width), pixelToPoint(taskbar.height));
}
taskGraphics.restore();
if (this.isAutoFit()) {
taskGraphics.drawRectangle(null, manualChildProgressBrush, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (taskbar.progressWidth), pixelToPoint(this.height));
}
else {
taskGraphics.drawRectangle(null, manualChildProgressBrush, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.progressWidth), pixelToPoint(this.height));
}
}
else {
if (this.isAutoFit()) {
if (isNullOrUndefined(template.value) && isNullOrUndefined(template.image)) {
taskGraphics.drawRectangle(taskbarPen_1, taskBrush_1, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (taskbar.width), pixelToPoint(taskbar.height));
}
else {
taskGraphics.drawRectangle(taskbarPen_1, taskBrush_1, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (taskbar.width), pixelToPoint(taskbar.height));
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width / 2.0;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 + (taskbar.height - taskbar.taskbarTemplate.image[0].height) / 2.0, (taskbar.taskbarTemplate.image[0].width) / 2.0, (taskbar.taskbarTemplate.image[0].height) / 2.0);
}
else {
imageWidth = 0;
}
if (taskbar.taskbarTemplate.value) {
if (isLabelString) {
updatedWidth = this.width;
}
taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + (this.left - cumulativeWidth) + imageWidth, startPoint.y + adjustHeight_1, (updatedWidth), pixelToPoint(this.height), progressFormat);
}
}
}
else {
if (isNullOrUndefined(template.value) && isNullOrUndefined(template.image)) {
taskGraphics.drawRectangle(taskbarPen_1, taskBrush_1, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.width), pixelToPoint(taskbar.height));
}
else {
taskGraphics.drawRectangle(taskbarPen_1, taskBrush_1, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.width), pixelToPoint(taskbar.height));
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 1, startPoint.y + adjustHeight_1 + 1 + pixelToPoint((taskbar.height - taskbar.taskbarTemplate.image[0].height) / 2.0), pixelToPoint(taskbar.taskbarTemplate.image[0].width), pixelToPoint(taskbar.taskbarTemplate.image[0].height));
}
else {
imageWidth = 0;
}
!isNullOrUndefined(taskbar.taskbarTemplate.value) ? taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + imageWidth, startPoint.y + adjustHeight_1, pixelToPoint(updatedWidth), pixelToPoint(this.height), progressFormat) : '';
}
}
}
if (this.isScheduledTask && !taskbar.isSpliterTask) {
if (isNullOrUndefined(template.image) && isNullOrUndefined(template.value)) {
if (this.isAutoFit() && taskbar.isAutoSchedule) {
taskGraphics.drawRectangle(progressPen_1, progressBrush_1, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (taskbar.progressWidth), pixelToPoint(taskbar.height));
}
else if (taskbar.isAutoSchedule) {
taskGraphics.drawRectangle(progressPen_1, progressBrush_1, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.progressWidth), pixelToPoint(taskbar.height));
}
if (!isNullOrUndefined(this.parent.labelSettings.taskLabel) && !isNullOrUndefined(this.taskLabel)) {
if (this.taskLabel !== '0' && this.taskLabel !== '0%') {
updatedWidth = this.progressWidth;
}
if (isLabelString) {
updatedWidth = this.width;
}
if (this.isAutoFit()) {
taskGraphics.drawString(this.taskLabel.toString(), taskLabelFont, fontColor, taskLabelFontBrush, startPoint.x + (this.left - cumulativeWidth) - (taskLabelPadding.left + taskLabelPadding.right), startPoint.y + adjustHeight_1 - (taskLabelPadding.top + taskLabelPadding.bottom), (updatedWidth), pixelToPoint(this.height), progressFormat);
}
else {
taskGraphics.drawString(this.taskLabel.toString(), taskLabelFont, fontColor, taskLabelFontBrush, startPoint.x + pixelToPoint(this.left - cumulativeWidth) - (taskLabelPadding.left + taskLabelPadding.right), startPoint.y + adjustHeight_1 - (taskLabelPadding.top + taskLabelPadding.bottom), pixelToPoint(updatedWidth), pixelToPoint(this.height), progressFormat);
}
}
}
}
else if (taskbar.isSpliterTask) {
taskbar.segment.map(function (data, index) {
var segmentprogressPen = !isNullOrUndefined(_this.taskSegmentStyles) ? new PdfPen(_this.taskSegmentStyles[index].progressColor) : progressPen_1;
var segmentprogressBrush = !isNullOrUndefined(_this.taskSegmentStyles) ? new PdfSolidBrush(_this.taskSegmentStyles[index].progressColor) : progressBrush_1;
if (_this.isAutoFit()) {
taskGraphics.drawRectangle(segmentprogressPen, segmentprogressBrush, startPoint.x + (_this.left + data.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (data.progressWidth), pixelToPoint(taskbar.height));
}
else {
taskGraphics.drawRectangle(segmentprogressPen, segmentprogressBrush, startPoint.x + pixelToPoint(_this.left + data.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(data.progressWidth), pixelToPoint(taskbar.height));
}
});
}
}
this.isCompleted = true;
this.startPage = pageIndex;
this.endPage = pageIndex;
}
//Task start date is in the range of header split up start and end date
else if (detail.startDate <= startDate && detail.endDate >= startDate && (endDate >= detail.endDate)) {
if (!this.isStartPoint) {
this.taskStartPoint = __assign({}, startPoint);
this.isStartPoint = true;
}
var width = this.width;
var renderWidth_1 = 0;
var progressWidth = 0;
this.width = this.width - (detail.totalWidth - (this.left - cumulativeWidth));
renderWidth_1 = (detail.totalWidth - (this.left - cumulativeWidth));
progressWidth = (detail.totalWidth - (this.left - cumulativeWidth));
if (width < renderWidth_1) {
renderWidth_1 = width;
}
if (!this.isScheduledTask && this.unscheduledTaskBy === 'duration') {
var brush1 = void 0;
var brush2 = void 0;
if (this.isAutoFit()) {
brush1 = new PdfLinearGradientBrush(new PointF(startPoint.x + (this.left - cumulativeWidth) + 0.5 + (renderWidth_1) / 2, 0), new PointF(startPoint.x + (this.left - cumulativeWidth), 0), new PdfColor(taskbar.unscheduledTaskBarColor), new PdfColor(255, 255, 255));
taskGraphics.drawRectangle(brush1, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (renderWidth_1), pixelToPoint(taskbar.height));
brush2 = new PdfLinearGradientBrush(new PointF(startPoint.x + (this.left - cumulativeWidth) + 0.5 + (renderWidth_1), 0), new PointF(startPoint.x + (this.left - cumulativeWidth) + (renderWidth_1) / 2, 0), new PdfColor(255, 255, 255), new PdfColor(taskbar.unscheduledTaskBarColor));
taskGraphics.drawRectangle(brush2, startPoint.x + (this.left - cumulativeWidth) + 0.5 + (renderWidth_1) / 2, startPoint.y + adjustHeight_1, (renderWidth_1) / 2, pixelToPoint(taskbar.height));
if (template.image || template.value) {
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.taskbarTemplate.image[0].width), pixelToPoint(taskbar.taskbarTemplate.image[0].height));
}
else {
imageWidth = 0;
}
!isNullOrUndefined(taskbar.taskbarTemplate.value) ? taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + (this.left - cumulativeWidth) + 0.5 + imageWidth, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.width), pixelToPoint(this.height), progressFormat) : '';
}
}
else {
brush1 = new PdfLinearGradientBrush(new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5 + pixelToPoint(renderWidth_1) / 2, 0), new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth), 0), new PdfColor(taskbar.unscheduledTaskBarColor), new PdfColor(255, 255, 255));
taskGraphics.drawRectangle(brush1, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(renderWidth_1), pixelToPoint(taskbar.height));
brush2 = new PdfLinearGradientBrush(new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5 + pixelToPoint(renderWidth_1), 0), new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + pixelToPoint(renderWidth_1) / 2, 0), new PdfColor(255, 255, 255), new PdfColor(taskbar.unscheduledTaskBarColor));
taskGraphics.drawRectangle(brush2, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5 + pixelToPoint(renderWidth_1) / 2, startPoint.y + adjustHeight_1, pixelToPoint(renderWidth_1) / 2, pixelToPoint(taskbar.height));
if (template.image || template.value) {
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.taskbarTemplate.image[0].width), pixelToPoint(taskbar.taskbarTemplate.image[0].height));
}
else {
imageWidth = 0;
}
!isNullOrUndefined(taskbar.taskbarTemplate.value) ? taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5 + imageWidth, startPoint.y + adjustHeight_1, pixelToPoint(taskbar.width), pixelToPoint(this.height), progressFormat) : '';
}
}
}
else if (!this.isScheduledTask && this.unscheduledTaskBy !== 'duration') {
this.drawUnscheduledTask(taskGraphics, startPoint, cumulativeWidth, adjustHeight_1);
}
else if (!taskbar.isAutoSchedule && taskbar.isParentTask) {
taskGraphics.save();
var path = new PdfPath();
path.addEllipse(0, 0, 5, 5);
if (this.isAutoFit()) {
taskGraphics.translateTransform(startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 - 2);
}
else {
taskGraphics.translateTransform(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 - 2);
}
taskGraphics.drawPath(manualTaskbarPen, manuallineBrush, path);
taskGraphics.restore();
manualline.dashStyle = PdfDashStyle.Solid;
if (this.isAutoFit()) {
taskGraphics.drawLine(manualline, new PointF(startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1), new PointF((renderWidth_1) + startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1));
}
else {
taskGraphics.drawLine(manualline, new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1), new PointF(pixelToPoint(renderWidth_1) + startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1));
}
}
else if (!taskbar.isAutoSchedule && !taskbar.isParentTask) {
if (this.isAutoFit()) {
taskGraphics.drawRectangle(manualChildBorderPen, null, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (renderWidth_1), pixelToPoint(taskbar.height));
}
else {
taskGraphics.drawRectangle(manualChildBorderPen, null, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(renderWidth_1), pixelToPoint(taskbar.height));
}
taskGraphics.save();
taskGraphics.setTransparency(0.87);
if (this.isAutoFit()) {
taskGraphics.drawRectangle(null, manualChildBrush, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (renderWidth_1), pixelToPoint(taskbar.height));
}
else {
taskGraphics.drawRectangle(null, manualChildBrush, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(renderWidth_1), pixelToPoint(taskbar.height));
}
taskGraphics.restore();
if (this.isAutoFit()) {
taskGraphics.drawRectangle(null, manualChildProgressBrush, startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (progressWidth), pixelToPoint(taskbar.height));
}
else {
taskGraphics.drawRectangle(null, manualChildProgressBrush, startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(progressWidth), pixelToPoint(taskbar.height));
}
taskbar.progressWidth = taskbar.progressWidth - progressWidth;
}
else if (!this.isScheduledTask && this.unscheduledTaskBy !== 'duration') {
this.drawUnscheduledTask(taskGraphics, startPoint, cumulativeWidth, adjustHeight_1);
}
else if (!this.isScheduledTask && this.unscheduledTaskBy === "endDate") {
this.drawUnscheduledTask(taskGraphics, startPoint, cumulativeWidth, adjustHeight_1);
}
else {
if (taskbar.isSpliterTask) {
var pervwidth_1 = 0;
splitline.dashStyle = PdfDashStyle.Dot;
if (this.isAutoFit()) {
taskGraphics.drawLine(splitline, new PointF(startPoint.x + (this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 + pixelToPoint(taskbar.height / 2)), new PointF((renderWidth_1) + (this.left - cumulativeWidth) + startPoint.x, startPoint.y + adjustHeight_1 + pixelToPoint(taskbar.height / 2)));
}
else {
taskGraphics.drawLine(splitline, new PointF(startPoint.x + pixelToPoint(this.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1 + pixelToPoint(taskbar.height / 2)), new PointF(pixelToPoint(renderWidth_1) + pixelToPoint(this.left - cumulativeWidth) + startPoint.x, startPoint.y + adjustHeight_1 + pixelToPoint(taskbar.height / 2)));
}
taskbar.segmentCollection.map(function (data, index) {
if (data.startDate < detail.endDate && data.endDate > detail.startDate) {
var segmenttaskbarPen = !isNullOrUndefined(_this.taskSegmentStyles) ? new PdfPen(_this.taskSegmentStyles[index].taskBorderColor) : taskbarPen_1;
var segmenttaskBrush = !isNullOrUndefined(_this.taskSegmentStyles) ? new PdfSolidBrush(_this.taskSegmentStyles[index].taskColor) : taskBrush_1;
var segmentprogressPen = !isNullOrUndefined(_this.taskSegmentStyles) ? new PdfPen(_this.taskSegmentStyles[index].progressColor) : progressPen_1;
var segmentprogressBrush = !isNullOrUndefined(_this.taskSegmentStyles) ? new PdfSolidBrush(_this.taskSegmentStyles[index].progressColor) : progressBrush_1;
var currentRenderWidth = (renderWidth_1 - data.left);
if (data.width < currentRenderWidth) {
currentRenderWidth = data.width;
}
var currentWidthProgress = currentRenderWidth;
if (data.progressWidth < currentWidthProgress) {
currentWidthProgress = data.progressWidth;
}
if (_this.isAutoFit()) {
taskGraphics.drawRectangle(segmenttaskbarPen, segmenttaskBrush, startPoint.x + (_this.left - cumulativeWidth) + 0.5 + (data.left), startPoint.y + adjustHeight_1, (data.width), pixelToPoint(taskbar.height));
taskGraphics.drawRectangle(segmentprogressPen, segmentprogressBrush, startPoint.x + (_this.left + data.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, (data.progressWidth), pixelToPoint(taskbar.height));
if (template.image || template.value) {
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + (_this.left - cumulativeWidth) + 0.5 + (data.left), startPoint.y + adjustHeight_1, (taskbar.taskbarTemplate.image[0].width), (taskbar.taskbarTemplate.image[0].height));
}
else {
imageWidth = 0;
}
!isNullOrUndefined(taskbar.taskbarTemplate.value) ? taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + (_this.left - cumulativeWidth) + 0.5 + (data.left) + imageWidth, startPoint.y + adjustHeight_1, (data.width), (taskbar.height), progressFormat) : '';
}
}
else {
taskGraphics.drawRectangle(segmenttaskbarPen, segmenttaskBrush, startPoint.x + pixelToPoint(_this.left - cumulativeWidth) + 0.5 + pixelToPoint(data.left), startPoint.y + adjustHeight_1, pixelToPoint(currentRenderWidth), pixelToPoint(taskbar.height));
taskGraphics.drawRectangle(segmentprogressPen, segmentprogressBrush, startPoint.x + pixelToPoint(_this.left + data.left - cumulativeWidth) + 0.5, startPoint.y + adjustHeight_1, pixelToPoint(currentWidthProgress), pixelToPoint(taskbar.height));
if (template.image || template.value) {
var imageWidth = void 0;
if (!isNullOrUndefined(taskbar.taskbarTemplate.image)) {
imageWidth = taskbar.taskbarTemplate.image[0].width;
var image = new PdfBitmap(taskbar.taskbarTemplate.image[0].base64);
taskGraphics.drawImage(image, startPoint.x + pixelToPoint(_this.left - cumulativeWidth) + 0.5 + pixelToPoint(data.left), startPoint.y + adjustHeight_1, pixelToPoint(taskbar.taskbarTemplate.image[0].width), pixelToPoint(taskbar.taskbarTemplate.image[0].height));
}
else {
imageWidth = 0;
}
!isNullOrUndefined(taskbar.taskbarTemplate.value) ? taskGraphics.drawString(taskbar.taskbarTemplate.value, customizedFont, customizedFontColor, customizedFontBrush, startPoint.x + pixelToPoint(_this.left - cumulativeWidth) + 0.5 + pixelToPoint(data.left) + imageWidth, startPoint.y + adjustHeight_1, pixelToPoint(data.width), pixelToPoint(taskbar.height), progressFormat) : '';
}
}
if (_this.segmentCollection[parseInt(index.toString(), 10)].width === 0) {
_this.segmentCollection[parseInt(index.toString(), 10)].progressWidth = 0;
}
else {
if