Kaynağa Gözat

Added shading brush for non-working days

Kenric Nugteren 3 hafta önce
ebeveyn
işleme
b1f2c880a6

+ 52 - 10
prs.desktop/Panels/JobPlanner/JobResourcePlanner.xaml.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Data;
-using System.Drawing;
 using System.Globalization;
 using System.Linq;
 using System.Windows;
@@ -15,24 +14,16 @@ using InABox.Configuration;
 using InABox.Core;
 using InABox.DynamicGrid;
 using InABox.WPF;
-using NPOI.SS.Formula.Functions;
-using PRSDesktop.WidgetGroups;
 using System.ComponentModel;
-using Syncfusion.UI.Xaml.Grid;
-using Syncfusion.Windows.Tools.Controls;
 using SelectionChangedEventArgs = System.Windows.Controls.SelectionChangedEventArgs;
 using PRS.Shared;
 using Columns = InABox.Core.Columns;
 using InABox.Wpf;
-using MYOB.AccountRight.SDK.Extensions;
 using Syncfusion.Data.Extensions;
-using NPOI.OpenXmlFormats.Spreadsheet;
 using Syncfusion.UI.Xaml.Scheduler;
 using Color = System.Drawing.Color;
 using System.Diagnostics.CodeAnalysis;
-using NPOI.OpenXmlFormats.Dml;
 using System.Windows.Shapes;
-using Syncfusion.Pdf.Parsing;
 
 namespace PRSDesktop;
 
@@ -94,6 +85,8 @@ public class JobResourcePlannerGridItem : BaseObject
 
     public Dictionary<DateTime, double> Required { get; set; } = new();
 
+    public List<WorkingDayHours>? WorkingHours { get; set; }
+
     public bool IsEnabled(DateTime date)
     {
         if(JobStage is not null
@@ -297,6 +290,51 @@ public class JobResourcePlannerGrid : DynamicItemsListGrid<JobResourcePlannerGri
                     };
                     return brush;
                 }
+                else if(item.WorkingHours is not null
+                    && !item.WorkingHours[(int)date.DayOfWeek].IsWorkingDay
+                    && colour == Colors.LightYellow)
+                {
+                    var brush = new DrawingBrush();
+
+                    var group = new DrawingGroup();
+
+                    var size = 30;
+                    var thickness = 3;
+
+                    var backgroundSquare = new GeometryDrawing(Brushes.LightYellow, null, new RectangleGeometry(new(0, 0, size, size)));
+
+                    var lines = new GeometryGroup();
+                    for(var x = thickness; x < size; x += thickness * 2)
+                    {
+                        lines.Children.Add(new LineGeometry
+                        {
+                            StartPoint = new(0, x),
+                            EndPoint = new(x, 0)
+                        });
+                    }
+                    for(var x = thickness; x < size; x += thickness * 2)
+                    {
+                        lines.Children.Add(new LineGeometry
+                        {
+                            StartPoint = new(x, size),
+                            EndPoint = new(size, x)
+                        });
+                    }
+
+                    var linesDrawing = new GeometryDrawing(null, new Pen(Brushes.LightGray, 2), lines);
+
+                    group.Children.Add(backgroundSquare);
+                    group.Children.Add(linesDrawing);
+
+                    brush.Drawing = group;
+                    brush.Viewport = new(0, 0, size, size);
+                    brush.ViewportUnits = BrushMappingMode.Absolute;
+                    brush.Viewbox = new(0, 0, size, size);
+                    brush.ViewboxUnits = BrushMappingMode.Absolute;
+                    brush.TileMode = TileMode.Tile;
+
+                    return brush;
+                }
             }
 
             return colour?.ToBrush(0.8);
@@ -722,9 +760,12 @@ public partial class JobResourcePlanner : UserControl
 
                 foreach (var (jobIdx, job) in _jobs.WithIndex())
                 {
+                    var workingHours = _jobWorkingHours.GetValueOrDefault(job.ID) ?? _defaultWorkingHours;
+
                     var item = new JobResourcePlannerGridItem
                     {
-                        Job = job
+                        Job = job,
+                        WorkingHours = workingHours
                     };
 
                     foreach(var (dateIdx, date) in dates.WithIndex())
@@ -741,6 +782,7 @@ public partial class JobResourcePlanner : UserControl
                             {
                                 Job = job,
                                 JobStage = stage,
+                                WorkingHours = workingHours
                             };
 
                             foreach(var (dateIdx, date) in dates.WithIndex())