Переглянути джерело

Chopped a bunch of things which don't exist anymore

Kenric Nugteren 2 роки тому
батько
коміт
e2c07414d9

+ 0 - 123
prs.classes/Entities/Manufacturing/ManufacturingItem.cs

@@ -1,123 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using InABox.Core;
-
-namespace Comal.Classes
-{
-    public class ManufacturingItem : BaseObject, IPackable
-    {
-        private BarcodeType _barcodetype = BarcodeType.Unspecified;
-
-        public ManufacturingItem()
-        {
-            ID = Guid.NewGuid();
-            Description = "Completed Item";
-            Code = "#";
-            Quantity = 1;
-            Due = DateTime.Today;
-            TemplateID = Guid.Empty;
-            Stages = new PackableList<SetoutStage>();
-            Attributes = new Dictionary<string, object>();
-            _barcodetype = BarcodeType.Unspecified;
-            Purchased = false;
-        }
-
-        [NullEditor]
-        public Guid ID { get; set; }
-
-        [NullEditor]
-        public string Code { get; set; }
-
-
-        public string Description { get; set; }
-
-        public string Group { get; set; }
-
-
-        public string Serial { get; set; }
-
-        public int Quantity { get; set; }
-
-        // Deprecated - replacing with BarcodeType
-        public bool GroupedBarcode { get; set; }
-
-        [EnumLookupEditor(typeof(BarcodeType))]
-        public BarcodeType BarcodeType
-        {
-            get => _barcodetype == BarcodeType.Unspecified ? GroupedBarcode ? BarcodeType.Grouped : BarcodeType.Individual : _barcodetype;
-            set => _barcodetype = value;
-        }
-
-        [CheckBoxEditor]
-        public bool Purchased { get; set; }
-
-        [DateEditor]
-        public DateTime Due { get; set; }
-
-        [LookupEditor(typeof(ManufacturingTemplate), "Name->Description")]
-        public Guid TemplateID { get; set; }
-
-        //static FactorySetup setup = null; 
-
-        //public static Dictionary<object,object> TemplateID_Lookups()
-        //{
-        //    Dictionary<object, object> result = new Dictionary<object, object>();
-        //    if (setup == null)
-        //        setup = new GlobalConfiguration<FactorySetup>().Load();
-        //    foreach (var template in setup.Templates)
-        //        result[template.ID] = template.Name;
-
-        //    return result;
-        //}
-
-        public PackableList<SetoutStage> Stages { get; set; }
-
-        public Dictionary<string, object> Attributes { get; set; }
-
-        public void Pack(FastBinaryWriter writer)
-        {
-            writer.Write(ID.ToByteArray());
-            writer.Write(Description);
-            writer.Write(Code);
-            writer.Write(Quantity);
-            writer.Write(Due.ToBinary());
-            writer.Write(TemplateID.ToByteArray());
-            Stages.Pack(writer);
-            var attributes = new List<string>();
-            foreach (var key in Attributes.Keys)
-                attributes.Add(string.Format("{0}={1}", key, Attributes[key]));
-            writer.Write(string.Join("\n", attributes));
-            writer.Write((int)BarcodeType);
-            writer.Write(Serial);
-            writer.Write(Purchased);
-        }
-
-        public void Unpack(FastBinaryReader reader)
-        {
-            ID = new Guid(reader.ReadBytes(16));
-            Description = reader.ReadString();
-            Code = reader.ReadString();
-            Quantity = reader.ReadInt32();
-            Due = DateTime.FromBinary(reader.ReadInt64());
-            TemplateID = new Guid(reader.ReadBytes(16));
-            Stages = new PackableList<SetoutStage>();
-            Stages.Unpack(reader);
-            var attributes = reader.ReadString().Split('\n');
-            foreach (var attribute in attributes.Where(x => x.Contains("=")))
-                try
-                {
-                    var comps = attribute.Split('=');
-                    Attributes[comps[0]] = comps[1];
-                }
-                catch (Exception e)
-                {
-                    Logger.Send(LogType.Error, "", string.Format("*** Unknown Error: {0}\n{1}", e.Message, e.StackTrace));
-                }
-
-            BarcodeType = (BarcodeType)reader.ReadInt32();
-            Serial = reader.ReadString();
-            Purchased = reader.ReadBoolean();
-        }
-    }
-}

+ 0 - 96
prs.classes/Entities/Setout/SetoutStage.cs

@@ -18,100 +18,4 @@ namespace Comal.Classes
         Skipped,
         Failed
     }
-
-    public interface IStageTemplate
-    {
-        Guid SectionID { get; set; }
-        int Minutes { get; set; }
-        SequenceType Sequence { get; set; }
-        string QualityChecks { get; set; }
-    }
-
-    public class StageTemplate : BaseObject, IStageTemplate, IPackable
-    {
-        public StageTemplate()
-        {
-            QualityChecks = "";
-        }
-
-        public void Pack(FastBinaryWriter writer)
-        {
-            writer.Write(SectionID.ToByteArray());
-            writer.Write(Minutes);
-            writer.Write((int)Sequence);
-            writer.Write(QualityChecks);
-        }
-
-        public void Unpack(FastBinaryReader reader)
-        {
-            SectionID = new Guid(reader.ReadBytes(16));
-            Minutes = reader.ReadInt32();
-            Sequence = (SequenceType)reader.ReadInt32();
-            QualityChecks = reader.ReadString();
-        }
-
-        public Guid SectionID { get; set; }
-        public int Minutes { get; set; }
-        public SequenceType Sequence { get; set; }
-
-        [MemoEditor]
-        public string QualityChecks { get; set; }
-    }
-
-    public class SetoutStage : BaseObject, IStageTemplate, IPackable
-    {
-        public SetoutStage()
-        {
-            Name = "";
-            QualityChecks = "";
-            QualityNotes = "";
-        }
-
-        public string Name { get; set; }
-
-        public DateTime Started { get; set; }
-        public DateTime Completed { get; set; }
-
-        public double PercentageComplete { get; set; }
-
-        public QualityStatus QualityStatus { get; set; }
-
-        [MemoEditor]
-        public string QualityNotes { get; set; }
-
-        public void Pack(FastBinaryWriter writer)
-        {
-            writer.Write(Completed.ToBinary());
-            writer.Write(Minutes);
-            writer.Write(Name);
-            writer.Write(PercentageComplete);
-            writer.Write(QualityChecks);
-            writer.Write(QualityNotes);
-            writer.Write((int)QualityStatus);
-            writer.Write(SectionID.ToByteArray());
-            writer.Write((int)Sequence);
-            writer.Write(Started.ToBinary());
-        }
-
-        public void Unpack(FastBinaryReader reader)
-        {
-            Completed = DateTime.FromBinary(reader.ReadInt64());
-            Minutes = reader.ReadInt32();
-            Name = reader.ReadString();
-            PercentageComplete = reader.ReadDouble();
-            QualityChecks = reader.ReadString();
-            QualityNotes = reader.ReadString();
-            QualityStatus = (QualityStatus)reader.ReadInt32();
-            SectionID = new Guid(reader.ReadBytes(16));
-            Sequence = (SequenceType)reader.ReadInt32();
-            Started = DateTime.FromBinary(reader.ReadInt64());
-        }
-
-        public Guid SectionID { get; set; }
-        public int Minutes { get; set; }
-        public SequenceType Sequence { get; set; }
-
-        [MemoEditor(Editable = Editable.Hidden)]
-        public string QualityChecks { get; set; }
-    }
 }

+ 0 - 37
prs.classes/Settings/FactoryGroup.cs

@@ -1,37 +0,0 @@
-using System;
-using InABox.Core;
-
-namespace Comal.Classes
-{
-    public class FactoryGroup : BaseObject, IPersistent, IPackable
-    {
-        public FactoryGroup()
-        {
-            Thumbnail = new ImageDocumentLink();
-        }
-
-        [TextBoxEditor]
-        public string Group { get; set; }
-
-        public ImageDocumentLink Thumbnail { get; set; }
-
-        [LookupEditor(typeof(Role))]
-        public Guid QAChecker { get; set; }
-
-        public void Pack(FastBinaryWriter writer)
-        {
-            writer.Write(Group);
-            writer.Write(Thumbnail.ID.ToByteArray());
-            writer.Write(Thumbnail.FileName);
-            writer.Write(QAChecker.ToByteArray());
-        }
-
-        public void Unpack(FastBinaryReader reader)
-        {
-            Group = reader.ReadString();
-            Thumbnail.ID = new Guid(reader.ReadBytes(16));
-            Thumbnail.FileName = reader.ReadString();
-            QAChecker = new Guid(reader.ReadBytes(16));
-        }
-    }
-}

+ 0 - 49
prs.classes/Settings/FactorySection.cs

@@ -1,49 +0,0 @@
-using System;
-using InABox.Core;
-
-namespace Comal.Classes
-{
-    public class FactorySection : BaseObject, IPersistent, IPackable
-    {
-        [NullEditor]
-        public Guid ID { get; set; }
-
-        [NullEditor]
-        public string Group { get; set; }
-
-        [TextBoxEditor]
-        public string Name { get; set; }
-
-        public int Stations { get; set; }
-
-        public bool Shared { get; set; }
-
-        [MemoEditor]
-        public string QualityChecks { get; set; }
-
-        [CheckBoxEditor]
-        public bool Hidden { get; set; }
-
-        public void Pack(FastBinaryWriter writer)
-        {
-            writer.Write(ID.ToByteArray());
-            writer.Write(Group);
-            writer.Write(Name);
-            writer.Write(Stations);
-            writer.Write(Shared);
-            writer.Write(QualityChecks);
-            writer.Write(Hidden);
-        }
-
-        public void Unpack(FastBinaryReader reader)
-        {
-            ID = new Guid(reader.ReadBytes(16));
-            Group = reader.ReadString();
-            Name = reader.ReadString();
-            Stations = reader.ReadInt32();
-            Shared = reader.ReadBoolean();
-            QualityChecks = reader.ReadString();
-            Hidden = reader.ReadBoolean();
-        }
-    }
-}

+ 0 - 24
prs.classes/Settings/FactorySetup.cs

@@ -1,24 +0,0 @@
-using InABox.Configuration;
-using InABox.Core;
-
-namespace Comal.Classes
-{
-    public class FactorySetup : GlobalConfigurationSettings
-    {
-        public FactorySetup()
-        {
-            Groups = new PackableList<FactoryGroup>();
-            Sections = new PackableList<FactorySection>();
-            Templates = new PackableList<FactoryTemplate>();
-            TemplateItems = new PackableList<FactoryTemplateItem>();
-        }
-
-        public PackableList<FactoryGroup> Groups { get; set; }
-
-        public PackableList<FactorySection> Sections { get; set; }
-
-        public PackableList<FactoryTemplateItem> TemplateItems { get; set; }
-
-        public PackableList<FactoryTemplate> Templates { get; set; }
-    }
-}

+ 0 - 52
prs.classes/Settings/FactoryTemplate.cs

@@ -1,52 +0,0 @@
-using System;
-using InABox.Core;
-
-namespace Comal.Classes
-{
-    public class FactoryTemplate : BaseObject, IPersistent, IPackable
-    {
-        public FactoryTemplate()
-        {
-            Stages = new PackableList<StageTemplate>();
-            Items = new PackableList<FactoryTemplateItem>();
-            //Attributes = new PackableList<FactoryTemplateAttribute>();
-        }
-
-        public Guid ID { get; set; }
-        public string Code { get; set; }
-        public string Name { get; set; }
-
-        public string Group { get; set; }
-
-        public PackableList<StageTemplate> Stages { get; set; }
-
-        //public PackableList<FactoryTemplateAttribute> Attributes { get; set; }
-
-        public PackableList<FactoryTemplateItem> Items { get; set; }
-
-        public void Pack(FastBinaryWriter writer)
-        {
-            writer.Write(ID.ToByteArray());
-            writer.Write(Code);
-            writer.Write(Name);
-            writer.Write(Group);
-            Stages.Pack(writer);
-            //Attributes.Pack(writer);
-            Items.Pack(writer);
-        }
-
-        public void Unpack(FastBinaryReader reader)
-        {
-            ID = new Guid(reader.ReadBytes(16));
-            Code = reader.ReadString();
-            Name = reader.ReadString();
-            Group = reader.ReadString();
-            Stages = new PackableList<StageTemplate>();
-            Stages.Unpack(reader);
-            //Attributes = new PackableList<FactoryTemplateAttribute>();
-            //Attributes.Unpack(reader);
-            Items = new PackableList<FactoryTemplateItem>();
-            Items.Unpack(reader);
-        }
-    }
-}

+ 0 - 25
prs.classes/Settings/FactoryTemplateItem.cs

@@ -1,25 +0,0 @@
-using InABox.Core;
-
-namespace Comal.Classes
-{
-    public class FactoryTemplateItem : BaseObject, IPackable
-    {
-        public string Code { get; set; }
-        public string Description { get; set; }
-        public int Qty { get; set; }
-
-        public void Pack(FastBinaryWriter writer)
-        {
-            writer.Write(Code);
-            writer.Write(Description);
-            writer.Write(Qty);
-        }
-
-        public void Unpack(FastBinaryReader reader)
-        {
-            Code = reader.ReadString();
-            Description = reader.ReadString();
-            Qty = reader.ReadInt32();
-        }
-    }
-}

+ 0 - 111
prs.desktop/Configuration/FactoryGroupsGrid.cs

@@ -1,111 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Comal.Classes;
-using InABox.Clients;
-using InABox.Core;
-using InABox.DynamicGrid;
-
-namespace PRSDesktop
-{
-    internal class FactoryGroupsGrid : DynamicGrid<FactoryGroup>
-    {
-        public FactoryGroupsGrid()
-        {
-            Options.AddRange(DynamicGridOption.RecordCount);
-        }
-
-        public List<FactoryGroup> Groups { get; set; }
-
-
-        //public DynamicGridColumns DefineColumns()
-        //{
-        //	return LoadColumns();
-        //}
-
-        protected override DynamicGridColumns LoadColumns()
-        {
-            ActionColumns.Clear();
-            ActionColumns.Add(new DynamicRowMovementColumn(DynamicRowMovement.Up, SwapRows));
-            ActionColumns.Add(new DynamicRowMovementColumn(DynamicRowMovement.Down, SwapRows));
-
-            var columns = new DynamicGridColumns
-            {
-                new() { ColumnName = "Group", Width = 0 },
-                new() { ColumnName = "QAChecker", Width = 0 }
-            };
-            return columns;
-        }
-
-        private bool SwapRows(int arg1, int arg2)
-        {
-            var item = Groups[arg1];
-            Groups.Remove(item);
-            Groups.Insert(arg2, item);
-            return true;
-        }
-
-        #region Save / Load
-
-        //protected override DataTable Reload(Dictionary<String, Object> criteria, List<String> columnnames, String sort)
-        //{
-        //	DataTable result = new DataTable();
-        //	result.LoadColumns(typeof(FactoryGroup));
-        //	result.LoadRows(Groups);
-        //	return result;
-        //}
-
-        protected override void Reload(Filters<FactoryGroup> criteria, Columns<FactoryGroup> columns, ref SortOrder<FactoryGroup> sort,
-            Action<CoreTable, Exception> action)
-        {
-            var result = new CoreTable();
-            result.LoadColumns(typeof(FactoryGroup));
-            result.LoadRows(Groups);
-            action.Invoke(result, null);
-        }
-
-        protected override FactoryGroup LoadItem(CoreRow row)
-        {
-            var index = Data.Rows.IndexOf(row);
-            return Groups[index];
-        }
-
-        public override void SaveItem(FactoryGroup item)
-        {
-            if (!Groups.Contains(item))
-                Groups.Add(item);
-        }
-
-
-        protected override void DeleteItems(params CoreRow[] rows)
-        {
-            foreach (var row in rows)
-            {
-                var index = Data.Rows.IndexOf(row);
-                Groups.RemoveAt(index);
-            }
-        }
-
-        protected override FactoryGroup CreateItem()
-        {
-            return base.CreateItem();
-        }
-
-        protected override Document LoadDocument(Guid id)
-        {
-            return new Client<Document>().Load(new Filter<Document>(x => x.ID).IsEqualTo(id)).FirstOrDefault();
-        }
-
-        protected override Document FindDocument(string filename)
-        {
-            return new Client<Document>().Load(new Filter<Document>(x => x.FileName).IsEqualTo(filename)).FirstOrDefault();
-        }
-
-        protected override void SaveDocument(Document document)
-        {
-            new Client<Document>().Save(document, "Added from Factory Groups Screen");
-        }
-
-        #endregion
-    }
-}

+ 0 - 155
prs.desktop/Configuration/FactorySectionsGrid.cs

@@ -1,155 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using System.Windows.Media.Imaging;
-using Comal.Classes;
-using InABox.Core;
-using InABox.DynamicGrid;
-using InABox.WPF;
-
-namespace PRSDesktop
-{
-    internal class FactorySectionsGrid : DynamicGrid<FactorySection>
-    {
-        private string _CurrentSection = "";
-
-        private readonly List<FactorySection> CurrentSections = new();
-
-        public BitmapImage QAColor = PRSDesktop.Resources.quality.AsBitmapImage(Color.White);
-        public BitmapImage QAGray = PRSDesktop.Resources.quality.AsGrayScale().AsBitmapImage(Color.White);
-
-        public FactorySectionsGrid()
-        {
-            Options.AddRange(DynamicGridOption.RecordCount);
-
-            ActionColumns.Add(new DynamicImageColumn(QualityImage, QualityAction));
-            HiddenColumns.Add(x => x.QualityChecks);
-
-            ActionColumns.Add(new DynamicRowMovementColumn(DynamicRowMovement.Up, SwapRows));
-            ActionColumns.Add(new DynamicRowMovementColumn(DynamicRowMovement.Down, SwapRows));
-        }
-
-        public string CurrentGroup
-        {
-            get => _CurrentSection;
-            set
-            {
-                if (!string.IsNullOrEmpty(_CurrentSection))
-                {
-                    Sections.RemoveAll(x => x.Group.Equals(_CurrentSection));
-                    Sections.AddRange(CurrentSections);
-                }
-
-                _CurrentSection = value;
-                CurrentSections.Clear();
-                if (!string.IsNullOrEmpty(_CurrentSection))
-                    CurrentSections.AddRange(Sections.Where(x => x.Group.Equals(_CurrentSection)));
-            }
-        }
-
-        public List<FactorySection> Sections { get; set; }
-
-        private bool QualityAction(CoreRow arg)
-        {
-            if (arg != null)
-            {
-                var form = new NotesForm
-                {
-                    Caption = "Please enter the Quality Checks to be performed before starting work on this stage",
-                    Text = CurrentSections[arg.Index].QualityChecks
-                };
-                if (form.ShowDialog() == true)
-                {
-                    CurrentSections[arg.Index].QualityChecks = form.Text;
-                    return true;
-                }
-            }
-
-            return false;
-        }
-
-        private BitmapImage QualityImage(CoreRow arg)
-        {
-            if (arg == null)
-                return QAColor;
-            if (string.IsNullOrWhiteSpace(arg.Get<FactorySection, string>(x => x.QualityChecks)))
-                return QAGray;
-            return QAColor;
-        }
-
-        private bool SwapRows(int arg1, int arg2)
-        {
-            var item = CurrentSections[arg1];
-            CurrentSections.Remove(item);
-            CurrentSections.Insert(arg2, item);
-            return true;
-        }
-
-
-        //public DynamicGridColumns DefineColumns()
-        //{
-        //	return LoadColumns();
-        //}
-
-        protected override DynamicGridColumns LoadColumns()
-        {
-            var columns = new DynamicGridColumns
-            {
-                new() { ColumnName = "Name", /* Type = typeof(String), */ Width = 0 },
-                new() { ColumnName = "Stations", Caption = "Stns", Width = 40, Alignment = Alignment.MiddleCenter },
-                new() { ColumnName = "Hidden", Caption = "Hide", Width = 30 }
-                //new DynamicGridColumn() { ColumnName = "Shared", Width = 30},
-            };
-            return columns;
-        }
-
-        #region Save / Load
-
-        //protected override DataTable Reload(Dictionary<String, Object> criteria, List<String> columnnames, String sort)
-        //{
-        //	DataTable result = new DataTable();
-        //	result.LoadColumns(typeof(FactorySection));
-        //	result.LoadRows(CurrentSections);
-        //	return result;
-        //}
-
-        protected override void Reload(Filters<FactorySection> criteria, Columns<FactorySection> columns, ref SortOrder<FactorySection> sort,
-            Action<CoreTable, Exception> action)
-        {
-            var result = new CoreTable();
-            result.LoadColumns(typeof(FactorySection));
-            result.LoadRows(CurrentSections);
-            action.Invoke(result, null);
-        }
-
-        protected override FactorySection LoadItem(CoreRow row)
-        {
-            var index = Data.Rows.IndexOf(row);
-            return CurrentSections[index];
-        }
-
-        public override void SaveItem(FactorySection item)
-        {
-            if (!CurrentSections.Contains(item))
-                CurrentSections.Add(item);
-        }
-
-
-        protected override void DeleteItems(params CoreRow[] rows)
-        {
-            foreach (var row in rows.OrderByDescending(x => x.Index))
-                CurrentSections.RemoveAt(row.Index);
-        }
-
-        protected override FactorySection CreateItem()
-        {
-            var section = base.CreateItem();
-            section.Group = CurrentGroup;
-            section.ID = Guid.NewGuid();
-            return section;
-        }
-
-        #endregion
-    }
-}

+ 0 - 43
prs.desktop/Configuration/FactorySettings.xaml

@@ -1,43 +0,0 @@
-<wpf:ThemableWindow x:Class="PRSDesktop.FactorySettings"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:PRSDesktop"
-		xmlns:wpf="clr-namespace:InABox.Wpf;assembly=InABox.Wpf"
-        mc:Ignorable="d"
-        Title="Factory Configuration" Height="500" Width="800" WindowStartupLocation="CenterScreen">
-    <Grid>
-
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="*" />
-            <ColumnDefinition Width="350" />
-        </Grid.ColumnDefinitions>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="*" />
-            <RowDefinition Height="40" />
-        </Grid.RowDefinitions>
-
-        <Border Grid.Row="0" Grid.Column="0" BorderThickness="1" Margin="5,5,0,0">
-            <local:FactoryGroupsGrid x:Name="Groups" />
-        </Border>
-
-        <Border Grid.Row="0" Grid.Column="1" BorderThickness="1" Margin="5,5,0,0">
-            <local:FactorySectionsGrid x:Name="Sections" />
-            <!--<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
-                <syncfusion:GridControl x:Name="Stages" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="722" QueryCellInfo="Stages_QueryCellInfo" CommitCellInfo="Stages_CommitCellInfo" SizeChanged="Stages_SizeChanged" CellClick="Stages_CellClick"/>
-            </ScrollViewer>-->
-        </Border>
-
-        <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="*" />
-                <ColumnDefinition Width="75" />
-                <ColumnDefinition Width="75" />
-            </Grid.ColumnDefinitions>
-            <Button x:Name="OKButton" Grid.Column="1" Content="OK" Margin="5,5,0,5" Click="Button_Click" />
-            <Button x:Name="CancelButton" Grid.Column="2" Content="Cancel" Margin="5" Click="CancelButton_Click" />
-        </Grid>
-
-    </Grid>
-</wpf:ThemableWindow>

+ 0 - 226
prs.desktop/Configuration/FactorySettings.xaml.cs

@@ -1,226 +0,0 @@
-using System.Linq;
-using System.Windows;
-using Comal.Classes;
-using InABox.Configuration;
-using InABox.DynamicGrid;
-using InABox.Wpf;
-
-namespace PRSDesktop
-{
-    /// <summary>
-    ///     Interaction logic for ScheduleSettings.xaml
-    /// </summary>
-    public partial class FactorySettings : ThemableWindow
-    {
-        private readonly GlobalConfiguration<FactorySetup> config = new();
-        private readonly FactorySetup settings;
-
-        public FactorySettings()
-        {
-            InitializeComponent();
-
-            settings = config.Load();
-
-            Groups.OnSelectItem += Groups_OnSelectItem;
-            Groups.Groups = settings.Groups;
-            Groups.Refresh(true, true);
-
-            Sections.Sections = settings.Sections;
-            Sections.Refresh(true, true);
-
-            //Stages.Model.RowHeights.DefaultLineSize = 20;
-            //Stages.Model.ColumnCount = 8;
-            //Stages.Model.ColumnWidths[0] = 20;
-            //Stages.Model.ColumnWidths[1] = 20;
-            //Stages.Model.ColumnWidths[2] = 0;
-            //Stages.Model.ColumnWidths[3] = 0;
-            //Stages.Model.ColumnWidths[4] = 0;
-            //Stages.Model.ColumnWidths[5] = 50;
-            //Stages.Model.ColumnWidths[6] = 20;
-            //Stages.Model.ColumnWidths[7] = 20;
-            //Stages.Model.HeaderColumns = 0;
-            //Stages.Model.RowCount = 0;
-            //Stages.Model.RowCount = settings.Sections.Count + 2;
-        }
-
-        private void Groups_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
-        {
-            Sections.CurrentGroup = e.Rows?.FirstOrDefault()?.Get<FactoryGroup, string>(x => x.Group) ?? "";
-            Sections.Refresh(false, true);
-        }
-
-        //private void Stages_SizeChanged(object sender, SizeChangedEventArgs e)
-        //{
-        //	Stages.Model.ColumnWidths[3] = (e.NewSize.Width - 130) / 3;
-        //	Stages.Model.ColumnWidths[4] = (e.NewSize.Width - 130) * 2 / 3;
-        //}
-
-
-        //private void Stages_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e)
-        //{
-        //	try
-        //	{
-        //		int row = e.Cell.RowIndex - 1;
-        //		int col = e.Cell.ColumnIndex;
-
-        //		switch (col)
-        //		{
-        //			case 0:
-        //				if ((row == -1) || ((row > 0) && (row < settings.Sections.Count)))
-        //					GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.uparrow, Stages.Model, col);
-        //				else
-        //					GridUtils.SetButtonImage(e.Style, null, Stages.Model, col);
-        //				break;
-        //			case 1:
-        //				if (row < settings.Sections.Count - 1)
-        //					GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.downarrow, Stages.Model, col);
-        //				else
-        //					GridUtils.SetButtonImage(e.Style, null, Stages.Model, col);
-        //				break;
-        //			case 2:
-        //				if (row == -1)
-        //					e.Style.CellValue = "Guid";
-        //				else if (row < settings.Sections.Count)
-        //					e.Style.CellValue = settings.Sections[row].ID.ToString();
-        //				else
-        //					e.Style.CellValue = "";
-        //				break;
-        //			case 3:
-        //				if (row == -1)
-        //					e.Style.CellValue = "Group";
-        //				else if (row < settings.Sections.Count)
-        //					e.Style.CellValue = settings.Sections[row].Group;
-        //				else
-        //					e.Style.CellValue = "";
-        //				e.Style.VerticalAlignment = VerticalAlignment.Center;
-        //				break;
-
-        //			case 4:
-        //				if (row == -1)
-        //					e.Style.CellValue = "Section Name";
-        //				else if (row < settings.Sections.Count)
-        //					e.Style.CellValue = settings.Sections[row].Name;
-        //				else
-        //					e.Style.CellValue = "";
-        //				e.Style.VerticalAlignment = VerticalAlignment.Center;
-        //				break;
-        //			case 5:
-        //				if (row == -1)
-        //					e.Style.CellValue = "Stations";
-        //				else if (row < settings.Sections.Count)
-        //					e.Style.CellValue = settings.Sections[row].Stations.ToString();
-        //				else
-        //					e.Style.CellValue = "";
-        //				e.Style.HorizontalAlignment = HorizontalAlignment.Center;
-        //				e.Style.VerticalAlignment = VerticalAlignment.Center;
-        //				break;
-        //			case 6:
-        //				if (row == -1)
-        //					GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.shared, Stages.Model, col);
-        //				else if (row < settings.Sections.Count)
-        //					GridUtils.SetButtonImage(e.Style, settings.Sections[row].Shared ? PRSDesktop.Resources.shared : null, Stages.Model, col);
-        //				else
-        //					GridUtils.SetButtonImage(e.Style, null, Stages.Model, col);
-        //				break;
-        //			case 7:
-        //				if (row < settings.Sections.Count)
-        //					GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.delete, Stages.Model, col);
-        //				else
-        //					GridUtils.SetButtonImage(e.Style, null, Stages.Model, col);
-        //				break;
-        //		}
-        //	} catch (Exception err)
-        //	{
-        //		MessageBox.Show(err.Message);
-        //	}
-        //}
-
-        //private void Stages_CommitCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridCommitCellInfoEventArgs e)
-        //{
-
-        //	FactorySection section;
-        //	if (e.Style.RowIndex > settings.Sections.Count)
-        //	{
-        //		section = new FactorySection() { ID = Guid.NewGuid(), Stations = 1 };
-        //		settings.Sections.Add(section);
-        //	}
-        //	else
-        //		section = settings.Sections[e.Style.RowIndex - 1];
-
-        //	switch (e.Cell.ColumnIndex)
-        //	{
-        //		case 3:
-        //			section.Group = e.Style.CellValue.ToString();
-        //			break;
-        //		case 4:
-        //			section.Name = e.Style.CellValue.ToString();
-        //			break;
-        //		case 5:
-        //			section.Stations = Convert.ToInt32(e.Style.CellValue.ToString());
-        //			break;
-        //	}
-        //	Stages.Model.RowCount = 0;
-        //	Stages.Model.RowCount = settings.Sections.Count + 2;
-        //}
-
-        //private void Stages_CellClick(object sender, GridCellClickEventArgs e)
-        //{
-
-        //	int index = e.RowIndex - 1;
-
-        //	if ((index < 0) || (index >= settings.Sections.Count))
-        //		return;
-
-        //	FactorySection section = settings.Sections[index];
-        //	switch (e.ColumnIndex)
-        //	{
-        //		case 0:
-        //			if (index > 0)
-        //			{
-        //				settings.Sections.Remove(section);
-        //				settings.Sections.Insert(index - 1, section);
-        //				e.Handled = true;
-        //			}
-        //			break;
-        //		case 1:
-        //			if (e.RowIndex < settings.Sections.Count - 1)
-        //			{
-        //				settings.Sections.Remove(section);
-        //				settings.Sections.Insert(index+1, section);
-        //				e.Handled = true;
-        //			}
-        //			break;
-        //		case 6:
-        //			if (index > -1)
-        //			{
-        //				section.Shared = !section.Shared;
-        //				e.Handled = true;
-        //			}
-        //			break;
-        //		case 7:
-        //			settings.Sections.Remove(section);
-        //			e.Handled = true;
-        //			break;
-        //	}
-        //	if (e.Handled)
-        //	{
-        //		Stages.Model.RowCount = 0;
-        //		Stages.Model.RowCount = settings.Sections.Count + 2;
-        //	}
-        //}
-
-        private void Button_Click(object sender, RoutedEventArgs e)
-        {
-            Sections.CurrentGroup = "";
-            config.Save(settings);
-            DialogResult = true;
-            Close();
-        }
-
-        private void CancelButton_Click(object sender, RoutedEventArgs e)
-        {
-            DialogResult = false;
-            Close();
-        }
-    }
-}

+ 0 - 26
prs.desktop/Configuration/FactoryTemplateItemsPanel.xaml

@@ -1,26 +0,0 @@
-<UserControl x:Class="PRSDesktop.FactoryTemplateItemsPanel"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
-             mc:Ignorable="d"
-             d:DesignHeight="300" d:DesignWidth="300">
-    <Grid>
-        <Border BorderThickness="1" BorderBrush="#FFABADB3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
-            <ScrollViewer>
-                <syncfusion:GridControl
-                    x:Name="Grid"
-                    HorizontalAlignment="Stretch"
-                    Margin="0,0,0,0"
-                    VerticalAlignment="Top"
-                    Height="1000"
-                    QueryCellInfo="Grid_QueryCellInfo"
-                    CommitCellInfo="Grid_CommitCellInfo"
-                    CellClick="Grid_CellClick"
-                    CurrentCellValidated="Grid_CurrentCellValidated"
-                    SizeChanged="Grid_SizeChanged" />
-            </ScrollViewer>
-        </Border>
-    </Grid>
-</UserControl>

+ 0 - 215
prs.desktop/Configuration/FactoryTemplateItemsPanel.xaml.cs

@@ -1,215 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using Comal.Classes;
-using InABox.Configuration;
-using InABox.Core;
-using PRSDesktop.Utils;
-using Syncfusion.Windows.ComponentModel;
-using Syncfusion.Windows.Controls.Grid;
-
-namespace PRSDesktop
-{
-    /// <summary>
-    ///     Interaction logic for FactoryTemplateItemsPanel.xaml
-    /// </summary>
-    public partial class FactoryTemplateItemsPanel : UserControl
-    {
-        private readonly List<FactoryTemplateItem> _items = new();
-        private Type _type = typeof(FactoryTemplateItem);
-        private FactorySetup settings;
-
-        public FactoryTemplateItemsPanel()
-        {
-            InitializeComponent();
-
-            Grid.Model.RowCount = 0;
-            Grid.Model.ColumnCount = 6;
-            Grid.Model.ColumnWidths[0] = 20;
-            Grid.Model.ColumnWidths[1] = 20;
-            Grid.Model.ColumnWidths[2] = Grid.ActualWidth - 160;
-            Grid.Model.ColumnWidths[3] = 50;
-            Grid.Model.ColumnWidths[4] = 50;
-            Grid.Model.ColumnWidths[5] = 20;
-            Grid.Model.HeaderColumns = 0;
-        }
-
-        public IList<T> GetItems<T>() where T : FactoryTemplateItem
-        {
-            var result = new List<T>();
-            foreach (var item in _items)
-                result.Add((T)item);
-            return result;
-        }
-
-        public void SetItems<T>(IList<T> items) where T : FactoryTemplateItem
-        {
-            settings = new GlobalConfiguration<FactorySetup>().Load();
-
-            _items.Clear();
-            _items.AddRange(items);
-
-            _type = typeof(T);
-
-            Grid.Model.RowCount = 0;
-            Grid.Model.RowCount = items.Count + 2;
-        }
-
-        private FactoryTemplateItem CreateItem()
-        {
-            return (FactoryTemplateItem)Activator.CreateInstance(_type);
-        }
-
-        private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
-        {
-            Grid.Model.ColumnWidths[2] = e.NewSize.Width - 160;
-        }
-
-        private void Grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
-        {
-            try
-            {
-                var row = e.Cell.RowIndex - 1;
-                var col = e.Cell.ColumnIndex;
-
-                switch (col)
-                {
-                    case 0:
-                        if (row != 0 && row < _items.Count)
-                            GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.uparrow, Grid.Model, col);
-                        else
-                            GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        break;
-                    case 1:
-                        if (row < _items.Count - 1)
-                            GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.downarrow, Grid.Model, col);
-                        else
-                            GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        break;
-                    case 2:
-                        if (row == -1)
-                        {
-                            e.Style.CellValue = "Item Type";
-                        }
-                        else
-                        {
-                            e.Style.CellType = "ComboBox";
-                            var items = new List<FactoryTemplateItem>();
-                            items.AddRange(settings.TemplateItems);
-                            if (row == _items.Count)
-                                items.Add(new FactoryTemplateItem { Code = "", Description = "Add new..", Qty = 1 });
-                            e.Style.ItemsSource = items.Select(x => new { x.Description }).ToList();
-                            e.Style.DropDownStyle = GridDropDownStyle.AutoComplete;
-                            e.Style.DisplayMember = "Description";
-                            e.Style.ValueMember = "Description";
-                            e.Style.CellValue = row < _items.Count ? _items[row].Description : "Add new..";
-                        }
-
-                        e.Style.VerticalAlignment = VerticalAlignment.Center;
-                        break;
-                    case 3:
-                        e.Style.CellValue = row == -1 ? "Code" : row < _items.Count ? _items[row].Code : "";
-                        e.Style.HorizontalAlignment = HorizontalAlignment.Center;
-                        e.Style.VerticalAlignment = VerticalAlignment.Center;
-                        break;
-                    case 4:
-                        e.Style.CellValue = row == -1 ? "Qty" : row < _items.Count ? _items[row].Qty.ToString() : "";
-                        e.Style.HorizontalAlignment = HorizontalAlignment.Center;
-                        e.Style.VerticalAlignment = VerticalAlignment.Center;
-                        break;
-                    case 5:
-                        if (row < _items.Count)
-                            GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.delete, Grid.Model, col);
-                        else
-                            GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        break;
-                }
-            }
-            catch (Exception err)
-            {
-                Logger.Send(LogType.Error, "", string.Format("*** Unknown Error: {0}\n{1}", err.Message, err.StackTrace));
-            }
-        }
-
-        private void Grid_CommitCellInfo(object sender, GridCommitCellInfoEventArgs e)
-        {
-            FactoryTemplateItem item;
-            if (e.Style.RowIndex > _items.Count)
-            {
-                item = CreateItem();
-                _items.Add(item);
-            }
-            else
-            {
-                item = _items[e.Style.RowIndex - 1];
-            }
-
-            switch (e.Cell.ColumnIndex)
-            {
-                case 2:
-                    item.Description = Convert.ToString(e.Style.CellValue);
-                    var lookup = settings.TemplateItems.Where(x => x.Description.Equals(item.Description)).FirstOrDefault();
-                    item.Code = lookup.Code;
-                    item.Qty = lookup.Qty;
-                    break;
-                case 3:
-                    item.Code = Convert.ToString(e.Style.CellValue);
-                    break;
-                case 4:
-                    item.Qty = Convert.ToInt32(e.Style.CellValue.ToString());
-                    break;
-            }
-
-            Grid.Model.RowCount = 0;
-            Grid.Model.RowCount = _items.Count + 2;
-        }
-
-        private void Grid_CellClick(object sender, GridCellClickEventArgs e)
-        {
-            var row = e.RowIndex - 1;
-
-            if (row > -1 && row < _items.Count)
-            {
-                var item = _items[row];
-
-                switch (e.ColumnIndex)
-                {
-                    case 0:
-                        if (row > 0)
-                        {
-                            _items.Remove(item);
-                            _items.Insert(row - 1, item);
-                            e.Handled = true;
-                        }
-
-                        break;
-                    case 1:
-                        if (e.RowIndex < settings.Sections.Count - 1)
-                        {
-                            _items.Remove(item);
-                            _items.Insert(row + 1, item);
-                            e.Handled = true;
-                        }
-
-                        break;
-                    case 5:
-                        _items.Remove(item);
-                        e.Handled = true;
-                        break;
-                }
-
-                if (e.Handled)
-                {
-                    Grid.Model.RowCount = 0;
-                    Grid.Model.RowCount = _items.Count + 2;
-                }
-            }
-        }
-
-        private void Grid_CurrentCellValidated(object sender, SyncfusionRoutedEventArgs args)
-        {
-        }
-    }
-}

+ 0 - 19
prs.desktop/Configuration/SetoutStagesPanel.xaml

@@ -1,19 +0,0 @@
-<UserControl x:Class="PRSDesktop.SetoutStagesPanel"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
-             mc:Ignorable="d"
-             d:DesignHeight="300" d:DesignWidth="300">
-    <Grid>
-        <Border BorderThickness="1" BorderBrush="#FFABADB3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
-            <ScrollViewer>
-                <syncfusion:GridControl x:Name="Grid" HorizontalAlignment="Stretch" Margin="0,0,0,0"
-                                        VerticalAlignment="Top" Height="1000" QueryCellInfo="Grid_QueryCellInfo"
-                                        CommitCellInfo="Grid_CommitCellInfo" CellClick="Grid_CellClick"
-                                        SizeChanged="Grid_SizeChanged" />
-            </ScrollViewer>
-        </Border>
-    </Grid>
-</UserControl>

+ 0 - 271
prs.desktop/Configuration/SetoutStagesPanel.xaml.cs

@@ -1,271 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using Comal.Classes;
-using InABox.Configuration;
-using InABox.Core;
-using InABox.DynamicGrid;
-using InABox.WPF;
-using PRSDesktop.Utils;
-using Syncfusion.Windows.Controls.Grid;
-
-namespace PRSDesktop
-{
-    /// <summary>
-    ///     Interaction logic for SetoutStagesPanel.xaml
-    /// </summary>
-    public partial class SetoutStagesPanel : UserControl
-    {
-        private readonly List<IStageTemplate> _stages = new();
-
-        private Type _type;
-
-        private FactorySetup settings;
-
-        public SetoutStagesPanel()
-        {
-            InitializeComponent();
-            Grid.Model.RowCount = 1;
-            Grid.Model.ColumnCount = 7;
-            Grid.Model.ColumnWidths[0] = 20;
-            Grid.Model.ColumnWidths[1] = 20;
-            Grid.Model.ColumnWidths[2] = Grid.ActualWidth - 150;
-            Grid.Model.ColumnWidths[3] = 50;
-            Grid.Model.ColumnWidths[4] = 20;
-            Grid.Model.ColumnWidths[5] = 20;
-            Grid.Model.ColumnWidths[6] = 20;
-            Grid.Model.HeaderColumns = 0;
-        }
-
-        private IStageTemplate CreateStage()
-        {
-            return (IStageTemplate)Activator.CreateInstance(_type);
-        }
-
-        public IList<T> GetStages<T>() where T : IStageTemplate
-        {
-            var result = new List<T>();
-            foreach (var stage in _stages)
-                result.Add((T)stage);
-            return result;
-        }
-
-        public void SetStages<T>(IList<T> stages) where T : IStageTemplate
-        {
-            settings = new GlobalConfiguration<FactorySetup>().Load();
-
-            _stages.Clear();
-            foreach (IStageTemplate stage in stages)
-                _stages.Add(stage);
-
-            _type = typeof(T);
-
-            Grid.Model.RowCount = 0;
-            Grid.Model.RowCount = _stages.Count + 2;
-        }
-
-        private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
-        {
-            Grid.Model.ColumnWidths[2] = e.NewSize.Width - 150;
-        }
-
-        private void Grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
-        {
-            try
-            {
-                var row = e.Cell.RowIndex - 1;
-                var col = e.Cell.ColumnIndex;
-
-                switch (col)
-                {
-                    case 0:
-                        if (row != 0 && row < _stages.Count)
-                            GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.uparrow, Grid.Model, col);
-                        else
-                            GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        break;
-                    case 1:
-                        if (row < _stages.Count - 1)
-                            GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.downarrow, Grid.Model, col);
-                        else
-                            GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        break;
-                    case 2:
-                        if (row == -1)
-                        {
-                            e.Style.CellValue = "Section Name";
-                        }
-                        else
-                        {
-                            e.Style.CellType = "ComboBox";
-                            var sections = new List<FactorySection>();
-                            sections.AddRange(settings.Sections);
-                            if (row == _stages.Count)
-                                sections.Add(new FactorySection { ID = Guid.Empty, Name = "Add new..", Stations = 0 });
-                            e.Style.ItemsSource = sections
-                                .Select(x => new { x.ID, Name = !string.IsNullOrEmpty(x.Group) ? x.Group + " : " + x.Name : x.Name }).ToList();
-                            e.Style.DropDownStyle = GridDropDownStyle.AutoComplete;
-                            e.Style.DisplayMember = "Name";
-                            e.Style.ValueMember = "ID";
-                            e.Style.CellValue = row < _stages.Count ? _stages[row].SectionID : Guid.Empty;
-                        }
-
-                        e.Style.VerticalAlignment = VerticalAlignment.Center;
-                        break;
-                    case 3:
-                        e.Style.CellValue = row == -1 ? "Time" : row < _stages.Count ? _stages[row].Minutes.ToString() : "";
-                        e.Style.HorizontalAlignment = HorizontalAlignment.Center;
-                        e.Style.VerticalAlignment = VerticalAlignment.Center;
-                        break;
-                    case 4:
-                        if (row == -1)
-                        {
-                            GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.quality, Grid.Model, col);
-                        }
-                        else if (row < _stages.Count)
-                        {
-                            if (!string.IsNullOrWhiteSpace(_stages[row].QualityChecks))
-                                GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.quality, Grid.Model, col);
-                            else
-                                GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.quality.AsGrayScale(), Grid.Model, col);
-                        }
-                        else
-                        {
-                            GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        }
-
-                        break;
-                    case 5:
-                        if (row == -1)
-                        {
-                            GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.link, Grid.Model, col);
-                        }
-                        else if (row < _stages.Count)
-                        {
-                            if (_stages[row].Sequence == SequenceType.Consolidate)
-                                GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.milestone, Grid.Model, col);
-                            else if (_stages[row].Sequence == SequenceType.Link)
-                                GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.link, Grid.Model, col);
-                            else
-                                GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        }
-                        else
-                        {
-                            GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        }
-
-                        break;
-                    case 6:
-                        if (row < _stages.Count)
-                            GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.delete, Grid.Model, col);
-                        else
-                            GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        break;
-                }
-            }
-            catch (Exception err)
-            {
-                Logger.Send(LogType.Error, "", string.Format("*** Unknown Error: {0}\n{1}", err.Message, err.StackTrace));
-            }
-        }
-
-        private void Grid_CommitCellInfo(object sender, GridCommitCellInfoEventArgs e)
-        {
-            IStageTemplate stage;
-            if (e.Style.RowIndex > _stages.Count)
-            {
-                stage = CreateStage();
-                stage.Sequence = SequenceType.Link;
-                _stages.Add(stage);
-            }
-            else
-            {
-                stage = _stages[e.Style.RowIndex - 1];
-            }
-
-            switch (e.Cell.ColumnIndex)
-            {
-                case 2:
-                    stage.SectionID = (Guid)e.Style.CellValue;
-                    break;
-                case 3:
-                    stage.Minutes = Convert.ToInt32(e.Style.CellValue.ToString());
-                    break;
-            }
-
-            Grid.Model.RowCount = 0;
-            Grid.Model.RowCount = _stages.Count + 2;
-        }
-
-        private void Grid_CellClick(object sender, GridCellClickEventArgs e)
-        {
-            var row = e.RowIndex - 1;
-
-
-            if (row > -1 && row < _stages.Count)
-            {
-                var stage = _stages[row];
-
-                switch (e.ColumnIndex)
-                {
-                    case 0:
-                        if (row > 0)
-                        {
-                            _stages.Remove(stage);
-                            _stages.Insert(row - 1, stage);
-                            e.Handled = true;
-                        }
-
-                        break;
-                    case 1:
-                        if (e.RowIndex < settings.Sections.Count - 1)
-                        {
-                            _stages.Remove(stage);
-                            _stages.Insert(row + 1, stage);
-                            e.Handled = true;
-                        }
-
-                        break;
-                    case 4:
-                        var form = new NotesForm
-                        {
-                            Caption = "Please enter the Quality Checks to be performed before starting work on this stage",
-                            Text = _stages[row].QualityChecks
-                        };
-                        if (form.ShowDialog() == true)
-                            _stages[row].QualityChecks = form.Text;
-                        e.Handled = true;
-                        break;
-                    case 5:
-                        switch (_stages[row].Sequence)
-                        {
-                            case SequenceType.None:
-                                _stages[row].Sequence = SequenceType.Link;
-                                break;
-                            case SequenceType.Link:
-                                _stages[row].Sequence = SequenceType.Consolidate;
-                                break;
-                            case SequenceType.Consolidate:
-                                _stages[row].Sequence = SequenceType.None;
-                                break;
-                        }
-
-                        e.Handled = true;
-                        break;
-                    case 6:
-                        _stages.Remove(stage);
-                        e.Handled = true;
-                        break;
-                }
-
-                if (e.Handled)
-                {
-                    Grid.Model.RowCount = 0;
-                    Grid.Model.RowCount = _stages.Count + 2;
-                }
-            }
-        }
-    }
-}

+ 0 - 43
prs.desktop/Configuration/SetoutTemplate.xaml

@@ -1,43 +0,0 @@
-<wpf:ThemableWindow x:Class="PRSDesktop.SetoutTemplate"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:PRSDesktop"
-		xmlns:wpf="clr-namespace:InABox.Wpf;assembly=InABox.Wpf"
-        mc:Ignorable="d"
-        Title="Manufacturing Templates" Height="800" Width="1000" WindowStartupLocation="CenterScreen">
-    <Grid Margin="5">
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="*" />
-            <ColumnDefinition Width="400" />
-        </Grid.ColumnDefinitions>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="30" />
-            <RowDefinition Height="*" />
-            <RowDefinition Height="30" />
-            <RowDefinition Height="*" />
-            <RowDefinition Height="40" />
-        </Grid.RowDefinitions>
-
-        <Label Content="Available Templates" Grid.Row="0" Grid.Column="0" />
-        <local:SetoutTemplateList Grid.Column="0" Grid.Row="1" Grid.RowSpan="3" x:Name="Templates" Margin="5,0,0,0"
-                                  TemplateSelected="Templates_TemplateSelected" />
-
-        <Label Content="Manufacturing Stages" Grid.Row="0" Grid.Column="1" />
-        <local:SetoutStagesPanel Grid.Column="1" Grid.Row="1" x:Name="Stages" />
-
-        <Label Content="Item Attributes" Grid.Row="2" Grid.Column="1" />
-        <!--<local:FactoryTemplateAttributesGrid x:Name="Attributes" Grid.Column="1" Grid.Row="3" Margin="5,5,0,0"/>-->
-
-        <Button x:Name="ExportButton" Grid.Column="0" Grid.Row="4" Content="Export" HorizontalAlignment="Left"
-                Width="75" Margin="0,5,0,0" Click="ExportButton_Click" />
-        <StackPanel Grid.Column="1" Grid.Row="4" HorizontalAlignment="Right" Orientation="Horizontal">
-            <Button x:Name="OKButton" Content="OK" HorizontalAlignment="Right" Width="75" Margin="0,5,0,0"
-                    Click="OKButton_Click" />
-            <Button x:Name="CancelButton" Content="Cancel" HorizontalAlignment="Right" Width="75" Margin="5,5,0,0"
-                    Click="CancelButton_Click" />
-        </StackPanel>
-
-    </Grid>
-</wpf:ThemableWindow>

+ 0 - 188
prs.desktop/Configuration/SetoutTemplate.xaml.cs

@@ -1,188 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Windows;
-using Comal.Classes;
-using InABox.Configuration;
-using InABox.Wpf;
-using Microsoft.Win32;
-using NPOI.SS.UserModel;
-using NPOI.SS.Util;
-using NPOI.XSSF.UserModel;
-
-namespace PRSDesktop
-{
-    /// <summary>
-    ///     Interaction logic for SetoutTemplate.xaml
-    /// </summary>
-    public partial class SetoutTemplate : ThemableWindow
-    {
-        private readonly GlobalConfiguration<FactorySetup> config = new();
-
-        private FactoryTemplate currentTemplate;
-        private readonly FactorySetup settings;
-
-        public SetoutTemplate()
-        {
-            InitializeComponent();
-            settings = config.Load();
-
-            Templates.Load(settings);
-
-            Stages.SetStages(new List<StageTemplate>());
-            //Attributes.Attributes = new List<FactoryTemplateAttribute>();
-            //Attributes.Refresh(true, false);
-            currentTemplate = null;
-        }
-
-        private void OKButton_Click(object sender, RoutedEventArgs e)
-        {
-            if (currentTemplate != null)
-            {
-                currentTemplate.Stages.Clear();
-                currentTemplate.Stages.AddRange(Stages.GetStages<StageTemplate>());
-
-                currentTemplate.Items.Clear();
-                //currentTemplate.Attributes.AddRange(Items.GetItems<FactoryTemplateItem>());
-            }
-
-            settings.Templates = Templates.Templates;
-            config.Save(settings);
-            Close();
-        }
-
-        private void CancelButton_Click(object sender, RoutedEventArgs e)
-        {
-            Close();
-        }
-
-        private void Templates_TemplateSelected(object sender, TempateSelectedArgs e)
-        {
-            if (currentTemplate != null)
-            {
-                currentTemplate.Stages.Clear();
-                currentTemplate.Stages.AddRange(Stages.GetStages<StageTemplate>());
-
-                currentTemplate.Items.Clear();
-                //currentTemplate.Items.AddRange(Items.GetItems<FactoryTemplateItem>());
-            }
-
-            currentTemplate = e.Template;
-
-            if (e.Template != null) Stages.SetStages(e.Template.Stages);
-            //Attributes.Attributes = e.Template.Attributes;
-            //Attributes.Refresh(false,true);
-        }
-
-        private ICell EnsureCell(ISheet sheet, int row, int col, ICellStyle style)
-        {
-            var _row = sheet.GetRow(row);
-            if (_row == null)
-                _row = sheet.CreateRow(row);
-
-            var _cell = _row.GetCell(col);
-            if (_cell == null)
-                _cell = _row.CreateCell(col);
-
-            _cell.CellStyle = style;
-
-            return _cell;
-        }
-
-        private ICellStyle CreateStyle(IWorkbook book, IndexedColors color)
-        {
-            var style = book.CreateCellStyle();
-            style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
-            style.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
-            style.BorderLeft = BorderStyle.Medium;
-            style.BorderRight = BorderStyle.Medium;
-            style.BorderTop = BorderStyle.Medium;
-            style.BorderBottom = BorderStyle.Medium;
-            style.FillForegroundColor = color.Index;
-            style.FillPattern = FillPattern.SolidForeground;
-            return style;
-        }
-
-        private void ExportButton_Click(object sender, RoutedEventArgs e)
-        {
-            if (currentTemplate != null)
-            {
-                currentTemplate.Stages.Clear();
-                currentTemplate.Stages.AddRange(Stages.GetStages<StageTemplate>());
-
-                currentTemplate.Items.Clear();
-                //currentTemplate.Items.AddRange(Items.GetItems<FactoryTemplateItem>());
-            }
-
-            var dlg = new SaveFileDialog();
-            dlg.DefaultExt = "xlsx";
-            dlg.Filter = "Excel Files|*.xlsx";
-            if (dlg.ShowDialog() != true)
-                return;
-
-            using (var stream = new FileStream(dlg.FileName, FileMode.Create, FileAccess.Write))
-            {
-                IWorkbook book = new XSSFWorkbook();
-                var sheet = book.CreateSheet("Sheet1");
-
-                var style = CreateStyle(book, IndexedColors.Grey50Percent);
-
-                EnsureCell(sheet, 0, 0, style).SetCellValue("Code");
-                EnsureCell(sheet, 0, 1, style).SetCellValue("Description");
-                EnsureCell(sheet, 1, 0, style).SetCellValue("");
-                EnsureCell(sheet, 1, 1, style).SetCellValue("");
-                sheet.AddMergedRegion(new CellRangeAddress(0, 1, 0, 0));
-                sheet.AddMergedRegion(new CellRangeAddress(0, 1, 1, 1));
-
-                var sections = new List<Guid>();
-                var config = new GlobalConfiguration<FactorySetup>();
-                var settings = config.Load();
-                var iGrp = 0;
-                var sGrp = "";
-                for (var i = 0; i < settings.Sections.Count; i++)
-                {
-                    var section = settings.Sections[i];
-                    sections.Add(section.ID);
-                    if (!section.Group.Equals(sGrp))
-                    {
-                        if (!string.IsNullOrEmpty(sGrp))
-                            sheet.AddMergedRegion(new CellRangeAddress(0, 0, iGrp, i + 1));
-                        iGrp = i + 2;
-                        sGrp = section.Group;
-                    }
-
-                    EnsureCell(sheet, 0, i + 2, style).SetCellValue(section.Group);
-                    EnsureCell(sheet, 1, i + 2, style).SetCellValue(section.Name);
-                }
-
-                if (iGrp < settings.Sections.Count + 2)
-                    sheet.AddMergedRegion(new CellRangeAddress(0, 0, iGrp, settings.Sections.Count + 1));
-                style = CreateStyle(book, IndexedColors.White);
-
-                for (var j = 0; j < settings.Templates.Count; j++)
-                {
-                    var template = settings.Templates[j];
-                    EnsureCell(sheet, j + 2, 0, style).SetCellValue(template.Code);
-                    EnsureCell(sheet, j + 2, 1, style).SetCellValue(template.Name);
-
-                    for (var k = 0; k < sections.Count; k++)
-                        EnsureCell(sheet, j + 2, k + 2, style).SetCellValue(" ");
-
-                    foreach (var stage in template.Stages)
-                    {
-                        var col = sections.IndexOf(stage.SectionID);
-                        EnsureCell(sheet, j + 2, col + 2, style).SetCellValue(stage.Minutes);
-                    }
-                }
-
-                for (var i = 0; i < settings.Sections.Count + 2; i++)
-                    sheet.AutoSizeColumn(i);
-
-                book.Write(stream);
-            }
-
-            Process.Start(dlg.FileName);
-        }
-    }
-}

+ 0 - 19
prs.desktop/Configuration/SetoutTemplateList.xaml

@@ -1,19 +0,0 @@
-<UserControl x:Class="PRSDesktop.SetoutTemplateList"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
-             mc:Ignorable="d"
-             d:DesignHeight="300" d:DesignWidth="300">
-    <Grid>
-        <Border BorderThickness="1" BorderBrush="#FFABADB3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
-            <ScrollViewer>
-                <syncfusion:GridControl x:Name="Grid" HorizontalAlignment="Stretch" Margin="0,0,0,0"
-                                        VerticalAlignment="Top" Height="1000" QueryCellInfo="Grid_QueryCellInfo"
-                                        CommitCellInfo="Grid_CommitCellInfo" CellClick="Grid_CellClick"
-                                        SizeChanged="Grid_SizeChanged" />
-            </ScrollViewer>
-        </Border>
-    </Grid>
-</UserControl>

+ 0 - 197
prs.desktop/Configuration/SetoutTemplateList.xaml.cs

@@ -1,197 +0,0 @@
-using System;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using Comal.Classes;
-using InABox.Core;
-using PRSDesktop.Utils;
-using Syncfusion.Windows.Controls.Grid;
-
-namespace PRSDesktop
-{
-    public class TempateSelectedArgs : EventArgs
-    {
-        public FactoryTemplate Template { get; set; }
-    }
-
-    public delegate void TemplateSelectedHandler(object sender, TempateSelectedArgs e);
-
-    /// <summary>
-    ///     Interaction logic for SetoutTemplateList.xaml
-    /// </summary>
-    public partial class SetoutTemplateList : UserControl
-    {
-        private FactorySetup _settings;
-
-        public SetoutTemplateList()
-        {
-            InitializeComponent();
-            Templates = new PackableList<FactoryTemplate>();
-
-            Grid.Model.ColumnCount = 5;
-            Grid.Model.ColumnWidths[0] = 0;
-            Grid.Model.ColumnWidths[1] = 40;
-            Grid.Model.ColumnWidths[2] = 0;
-            Grid.Model.ColumnWidths[3] = 100;
-            Grid.Model.ColumnWidths[4] = 20;
-            Grid.Model.HeaderColumns = 0;
-        }
-
-        public PackableList<FactoryTemplate> Templates { get; }
-
-        public event TemplateSelectedHandler TemplateSelected;
-
-        private void SelectTemplate(FactoryTemplate template)
-        {
-            //Null check makes sure the main page is attached to the event
-            if (TemplateSelected != null)
-                TemplateSelected(this, new TempateSelectedArgs { Template = template });
-        }
-
-        public void Load(FactorySetup settings)
-        {
-            _settings = settings;
-            Templates.Clear();
-            Templates.AddRange(_settings.Templates.OrderBy(x => x.Code));
-            Grid.Model.RowCount = 0;
-            Grid.Model.RowCount = Templates.Count + 2;
-        }
-
-        private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
-        {
-            Grid.Model.ColumnWidths[2] = e.NewSize.Width - 160;
-        }
-
-        private void Grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
-        {
-            try
-            {
-                var row = e.Cell.RowIndex - 1;
-                var col = e.Cell.ColumnIndex;
-
-                switch (col)
-                {
-                    case 0:
-                        if (row == -1)
-                        {
-                            e.Style.CellValue = "ID";
-                        }
-                        else
-                        {
-                            e.Style.CellType = "Static";
-                            e.Style.CellValue = row < Templates.Count ? Templates[row].ID : Guid.Empty;
-                        }
-
-                        e.Style.VerticalAlignment = VerticalAlignment.Center;
-                        break;
-                    case 1:
-                        if (row == -1)
-                            e.Style.CellValue = "Code";
-                        else
-                            e.Style.CellValue = row < Templates.Count ? Templates[row].Code : "";
-                        e.Style.VerticalAlignment = VerticalAlignment.Center;
-                        break;
-                    case 2:
-                        if (row == -1)
-                            e.Style.CellValue = "Template Name";
-                        else
-                            e.Style.CellValue = row < Templates.Count ? Templates[row].Name : "Add new..";
-                        e.Style.VerticalAlignment = VerticalAlignment.Center;
-                        break;
-                    case 3:
-                        if (row == -1)
-                        {
-                            e.Style.CellValue = "Group";
-                        }
-                        else
-                        {
-                            e.Style.CellType = "ComboBox";
-                            e.Style.ItemsSource = _settings.Groups.Select(x => new { ID = x.Group, Name = x.Group }).ToList();
-                            e.Style.DropDownStyle = GridDropDownStyle.AutoComplete;
-                            e.Style.DisplayMember = "Name";
-                            e.Style.ValueMember = "ID";
-                            e.Style.CellValue = row < Templates.Count ? Templates[row].Group : "Add new..";
-                        }
-
-                        e.Style.VerticalAlignment = VerticalAlignment.Center;
-                        break;
-
-                    case 4:
-                        if (row < Templates.Count)
-                            GridUtils.SetButtonImage(e.Style, PRSDesktop.Resources.delete, Grid.Model, col);
-                        else
-                            GridUtils.SetButtonImage(e.Style, null, Grid.Model, col);
-                        break;
-                }
-            }
-            catch (Exception err)
-            {
-                Logger.Send(LogType.Error, "", string.Format("*** Unknown Error: {0}\n{1}", err.Message, err.StackTrace));
-            }
-        }
-
-        private void Grid_CommitCellInfo(object sender, GridCommitCellInfoEventArgs e)
-        {
-            if (e.Cell.ColumnIndex == 1 || e.Cell.ColumnIndex == 2 || e.Cell.ColumnIndex == 3)
-            {
-                FactoryTemplate template = null;
-                if (e.Style.RowIndex > Templates.Count)
-                {
-                    template = new FactoryTemplate { ID = Guid.NewGuid() };
-                    foreach (var section in _settings.Sections)
-                        template.Stages.Add(
-                            new StageTemplate
-                            {
-                                SectionID = section.ID,
-                                Sequence = SequenceType.Link,
-                                Minutes = 0,
-                                QualityChecks = section.QualityChecks
-                            }
-                        );
-                    Templates.Add(template);
-                }
-                else
-                {
-                    template = Templates[e.Style.RowIndex - 1];
-                }
-
-                if (e.Cell.ColumnIndex == 1)
-                    template.Code = e.Style.CellValue.ToString();
-                else if (e.Cell.ColumnIndex == 2)
-                    template.Name = e.Style.CellValue.ToString();
-                else if (e.Cell.ColumnIndex == 3)
-                    template.Group = e.Style.CellValue.ToString();
-
-                Grid.Model.RowCount = 0;
-                Grid.Model.RowCount = Templates.Count + 2;
-            }
-        }
-
-        private void Grid_CellClick(object sender, GridCellClickEventArgs e)
-        {
-            var row = e.RowIndex - 1;
-
-            if (row > -1 && row < Templates.Count)
-            {
-                var document = Templates[row];
-
-                if (e.ColumnIndex == 4)
-                {
-                    Templates.Remove(document);
-                    e.Handled = true;
-                }
-            }
-
-            if (e.Handled)
-            {
-                Grid.Model.RowCount = 0;
-                Grid.Model.RowCount = Templates.Count + 2;
-            }
-
-            if (row > -1 && row < Templates.Count)
-                SelectTemplate(Templates[row]);
-            else
-                SelectTemplate(null);
-        }
-    }
-}

+ 0 - 28
prs.desktop/Forms/Optimisation.xaml

@@ -1,28 +0,0 @@
-<wpf:ThemableWindow x:Class="PRSDesktop.Optimisation"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-		xmlns:wpf="clr-namespace:InABox.Wpf;assembly=InABox.Wpf"
-        mc:Ignorable="d"
-        Title="Optimisation" Height="600" Width="450">
-    <Grid x:Name="layout">
-        <Grid.RowDefinitions>
-            <RowDefinition Height="30" />
-            <RowDefinition Height="*" />
-            <RowDefinition Height="40" />
-        </Grid.RowDefinitions>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="Auto" />
-            <ColumnDefinition Width="*" />
-            <ColumnDefinition Width="100" />
-            <ColumnDefinition Width="100" />
-        </Grid.ColumnDefinitions>
-        <Label Grid.Row="0" Grid.Column="0" Content="Select Glass Type" Margin="5,5,5,0" />
-        <ComboBox x:Name="Specifications" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,5,5,0"
-                  SelectionChanged="Specifications_SelectionChanged" />
-        <Button x:Name="OKButton" Grid.Row="2" Grid.Column="2" Content="OK" Margin="0,0,5,5" Click="OKButton_Click" />
-        <Button x:Name="CancelButton" Grid.Row="2" Grid.Column="3" Content="Cancel" Margin="0,0,5,5"
-                Click="CancelButton_Click" />
-    </Grid>
-</wpf:ThemableWindow>

+ 0 - 211
prs.desktop/Forms/Optimisation.xaml.cs

@@ -1,211 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media.Imaging;
-using Comal.Classes;
-using InABox.Clients;
-using InABox.Core;
-using InABox.DynamicGrid;
-using InABox.Wpf;
-using InABox.WPF;
-
-namespace PRSDesktop
-{
-    public class OptimisationItem : BaseObject
-    {
-        public OptimisationItem()
-        {
-            Packets = new List<Guid>();
-        }
-
-        public string Specification { get; set; }
-        public string Setout { get; set; }
-        public double Area { get; set; }
-        public int Quantity { get; set; }
-        public List<Guid> Packets { get; }
-        public bool Selected { get; set; }
-    }
-
-    public class OptimisationGrid : DynamicGrid<OptimisationItem>
-    {
-        private readonly BitmapImage disabled = PRSDesktop.Resources.disabled.AsBitmapImage();
-
-        private readonly BitmapImage tick = PRSDesktop.Resources.tick.AsBitmapImage();
-
-        public OptimisationGrid()
-        {
-            Items = new List<OptimisationItem>();
-
-            ActionColumns.Add(new DynamicTickColumn<OptimisationItem, bool>(x => x.Selected, tick, tick, disabled, CheckClick));
-
-            HiddenColumns.Add(x => x.Selected);
-        }
-
-        public List<OptimisationItem> Items { get; }
-
-        protected override void DeleteItems(params CoreRow[] row)
-        {
-        }
-
-        public override void SaveItem(OptimisationItem item)
-        {
-        }
-
-        protected override OptimisationItem LoadItem(CoreRow row)
-        {
-            return Items[row.Index];
-        }
-
-        protected override void Reload(Filters<OptimisationItem> criteria, Columns<OptimisationItem> columns, ref SortOrder<OptimisationItem> sort,
-            Action<CoreTable, Exception> action)
-        {
-            var table = new CoreTable();
-            table.LoadColumns(typeof(OptimisationItem));
-            table.LoadRows(Items);
-            action.Invoke(table, null);
-        }
-
-        private bool CheckClick(CoreRow row)
-        {
-            var item = Items[row.Index];
-            item.Selected = !item.Selected;
-            return true;
-        }
-
-        protected override DynamicGridColumns LoadColumns()
-        {
-            var columns = new DynamicGridColumns();
-            columns.Add(new DynamicGridColumn { ColumnName = "Setout", Caption = "Setout", Width = 0, Alignment = Alignment.MiddleLeft });
-            columns.Add(new DynamicGridColumn { ColumnName = "Area", Caption = "m2", Format = "N4", Width = 70, Alignment = Alignment.MiddleCenter });
-            columns.Add(new DynamicGridColumn { ColumnName = "Quantity", Caption = "#", Width = 50, Alignment = Alignment.MiddleCenter });
-            return columns;
-        }
-    }
-
-    /// <summary>
-    ///     Interaction logic for Optimisation.xaml
-    /// </summary>
-    public partial class Optimisation : ThemableWindow
-    {
-        private readonly OptimisationGrid grid = new();
-        private readonly List<OptimisationItem> Items = new();
-
-        private string SelectedSpecification = "";
-
-        public Optimisation()
-        {
-            InitializeComponent();
-            grid.SetValue(Grid.RowProperty, 1);
-            grid.SetValue(Grid.ColumnProperty, 0);
-            grid.SetValue(Grid.ColumnSpanProperty, 4);
-            grid.Margin = new Thickness(5);
-            layout.Children.Add(grid);
-
-            LoadData();
-
-            grid.Refresh(true, true);
-        }
-
-        private T GetAttribute<T>(ManufacturingItem item, string name)
-        {
-            if (item.Attributes.ContainsKey(name))
-                return (T)Convert.ChangeType(item.Attributes[name], typeof(T));
-            return default;
-        }
-
-        private void LoadData()
-        {
-            Specifications.Items.Clear();
-            Specifications.Items.Add("");
-            grid.Items.Clear();
-
-            var setouts = new Dictionary<Guid, Setout>();
-
-            var mcli = new Client<ManufacturingPacket>();
-            var packets = mcli.Query(
-                new Filter<ManufacturingPacket>(x => x.StageLink).NotLinkValid(),
-                new Columns<ManufacturingPacket>(x => x.ID, x => x.ManufacturingItemID, x => x.SetoutLink.ID, x => x.ManufacturingTemplateLink.Code)
-            );
-            foreach (var row in packets.Rows)
-            {
-                var packetid = row.Get<ManufacturingPacket, Guid>(r => r.ID);
-                var setoutid = row.Get<ManufacturingPacket, Guid>(r => r.SetoutLink.ID);
-                var code = row.Get<ManufacturingPacket, string>(x => x.ManufacturingTemplateLink.Code);
-                if (code.StartsWith("GMO"))
-                {
-                    Setout setout = null;
-                    if (setouts.ContainsKey(setoutid))
-                    {
-                        setout = setouts[setoutid];
-                    }
-                    else
-                    {
-                        var scli = new Client<Setout>();
-                        setout = scli.Load(new Filter<Setout>(x => x.ID).IsEqualTo(setoutid)).FirstOrDefault();
-                    }
-
-                    if (setout != null)
-                    {
-                        setouts[setoutid] = setout;
-                        ManufacturingItem item = null; //setout.Manufacturing.FirstOrDefault(x => x.Code.Equals(code));
-                        if (item != null)
-                        {
-                            var spec = GetAttribute<string>(item, "Glass Specifications");
-                            if (!string.IsNullOrEmpty(spec))
-                            {
-                                if (!Specifications.Items.Contains(spec))
-                                    Specifications.Items.Add(spec);
-
-                                var height = GetAttribute<double>(item, "Height");
-                                var width = GetAttribute<double>(item, "Width");
-                                var edge = GetAttribute<string>(item, "Edgework");
-                                var opt = Items.FirstOrDefault(x =>
-                                    !string.IsNullOrEmpty(x.Specification) && x.Specification.Equals(spec) && x.Setout.Equals(setout.Number));
-                                if (opt == null)
-                                {
-                                    opt = new OptimisationItem { Specification = spec, Setout = setout.Number };
-                                    Items.Add(opt);
-                                }
-
-                                opt.Area += height / 1000F * (width / 1000F);
-                                opt.Quantity += item.Quantity;
-                                opt.Packets.Add(packetid);
-                            }
-                        }
-                    }
-                }
-            }
-
-            Specifications.SelectedValue = "";
-        }
-
-        private void Specifications_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            SelectedSpecification = Specifications.SelectedValue.ToString();
-            grid.Items.Clear();
-            grid.Items.AddRange(Items.Where(x => x.Specification.Equals(SelectedSpecification)));
-            grid.Items.ForEach(opt => opt.Selected = true);
-            grid.Refresh(false, true);
-        }
-
-        private void OKButton_Click(object sender, RoutedEventArgs e)
-        {
-            MessageBox.Show("Not Implemented!");
-            // Prompt for location of new MO sheet
-            // Copy blank into location
-            // Open sheet / find "Data" page
-            // Iterate over OptimisationItems
-            // Set Fields
-            // Open for User to perform followup work
-
-            Close();
-        }
-
-        private void CancelButton_Click(object sender, RoutedEventArgs e)
-        {
-            Close();
-        }
-    }
-}

+ 0 - 343
prs.desktop/Panels/Jobs/ManufacturingItemGrid.cs

@@ -1,343 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media.Imaging;
-using Comal.Classes;
-using InABox.Configuration;
-using InABox.Core;
-using InABox.DynamicGrid;
-using InABox.WPF;
-
-namespace PRSDesktop
-{
-    public class ManufacturingItemGrid : DynamicGrid<ManufacturingItem>
-    {
-        private List<ManufacturingItem> _items;
-        private readonly BitmapImage barcode = PRSDesktop.Resources.barcode.AsBitmapImage();
-
-        private readonly BitmapImage grouped = PRSDesktop.Resources.grouped.AsBitmapImage();
-
-        private readonly FactorySetup settings = new GlobalConfiguration<FactorySetup>().Load();
-
-        public ManufacturingItemGrid()
-        {
-            Options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.AddRows, DynamicGridOption.DeleteRows);
-
-            //ActionColumns.Add(new DynamicImageColumn() { Action = BarcodeTypeClick, Image = BarcodeTypeImage });
-            //HiddenColumns.Add(x => x.GroupedBarcode);
-            SplitButton = AddButton("Split", PRSDesktop.Resources.split.AsBitmapImage(), SplitItems);
-        }
-
-        public Button SplitButton { get; }
-
-        public List<ManufacturingItem> Items
-        {
-            get => _items;
-            set
-            {
-                _items = value;
-                Refresh(true, true);
-            }
-        }
-
-        private bool SplitItems(Button sender, CoreRow[] rows)
-        {
-            if (rows.Length != 1)
-            {
-                MessageBox.Show("Please select an item to split!");
-                return false;
-            }
-
-            var row = rows.First();
-
-            var item = Items[row.Index];
-            if (item.Quantity <= 1)
-            {
-                MessageBox.Show("Quantity must be >1 before splitting!");
-                return false;
-            }
-
-            var Quantity = 1;
-            if (NumberEdit.Execute("Quantity to Separate", 1, item.Quantity - 1, ref Quantity))
-            {
-                var newitem = new ManufacturingItem();
-                CoreUtils.Clone(item, newitem);
-                newitem.Quantity = newitem.Quantity - Quantity;
-                item.Description = item.Description + " - copy";
-                item.Quantity = Quantity;
-                item.ID = Guid.NewGuid();
-                Items.Insert(row.Index, newitem);
-                return true;
-            }
-
-            return false;
-        }
-
-        protected override void SelectItems(CoreRow[] rows)
-        {
-            base.SelectItems(rows);
-            var bQty = true;
-            if (rows != null)
-                foreach (var row in rows)
-                    if (row.Get<ManufacturingItem, int>(x => x.Quantity) <= 1)
-                        bQty = false;
-            if (!bQty)
-                SplitButton.IsEnabled = false;
-        }
-
-        //private bool ImportItems(Button arg1, CoreRow arg2)
-        //{
-        //    Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
-        //    ofd.Filter = "Excel Files (*.xls,*.xlsx)|*.xlsx";
-        //    if (ofd.ShowDialog() == true)
-        //    {
-        //        try
-        //        {
-        //            using (FileStream file = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
-        //            {
-        //                IWorkbook xls = WorkbookFactory.Create(file);
-        //                ISheet sheet = xls.GetSheet("MASTERLIST");
-        //                IEnumerator rows = sheet.GetRowEnumerator();
-        //                //            rows.MoveNext();
-        //                //            rows.MoveNext(); 
-        //                while (rows.MoveNext())
-
-
-        //                //            IRow headerrow = (IRow)rows.Current;
-        //                //            int LocationColumn = GetColumn(headerrow, "LOCATION");
-        //                //            int WindowColumn = GetColumn(headerrow, "WINDOW MARK");
-        //                //            int SetoutColumn = GetColumn(headerrow, "FRAME - SETOUT");
-        //                //            int IDColumn = GetColumn(headerrow, "MARK");
-        //                //            int QtyColumn = GetColumn(headerrow, "QTY");
-
-        //                //            int SpecificationColumn = GetColumn(headerrow, "GLASS SPECIFICATIONS");
-        //                //            int HeightColumn = GetColumn(headerrow, "HEIGHT");
-        //                //            int WidthColumn = GetColumn(headerrow, "WIDTH");
-        //                //            int EdgeColumn = GetColumn(headerrow, "EDGEWORK");
-        //                //            int SupplierColumn = GetColumn(headerrow, "SUPPLIER");
-
-
-        //                //            while (rows.MoveNext())
-        //                //            {
-        //                //                IRow row = (IRow)rows.Current;
-
-        //                //                String SetoutNumber = row.GetCell(SetoutColumn, MissingCellPolicy.CREATE_NULL_AS_BLANK).StringCellValue;
-
-        //                //                if (!String.IsNullOrEmpty(SetoutNumber))
-        //                //                {
-
-        //                //                    String ID = row.GetCell(IDColumn, MissingCellPolicy.CREATE_NULL_AS_BLANK).StringCellValue;
-        //                //                    if (String.IsNullOrWhiteSpace(ID))
-        //                //                        throw new Exception(String.Format("Row [{0}]: MARK Column is blank!", row.RowNum + 1));
-
-        //                //                    String Supplier = row.GetCell(SupplierColumn, MissingCellPolicy.CREATE_NULL_AS_BLANK).StringCellValue;
-        //                //                    if (String.IsNullOrWhiteSpace(Supplier))
-        //                //                        throw new Exception(String.Format("Row [{0}]: SUPPLIER Column is blank!", row.RowNum + 1));
-
-        //                //                    Progress.SetMessage(String.Format("Row [{0}]: Updating {1} ({2})", row.RowNum + 1, SetoutNumber, ID));
-
-        //                //                    Setout setout = new Client<Setout>().Load(new Filter<Setout>(x => x.Number).IsEqualTo(SetoutNumber)).FirstOrDefault();
-        //                //                    if (setout == null)
-        //                //                    {
-        //                //                        int JobNumber = int.Parse(SetoutNumber.Split('-')[0].Trim());
-        //                //                        Job job = new Client<Job>().Load(new Filter<Job>(x => x.Number).IsEqualTo(JobNumber)).FirstOrDefault();
-        //                //                        setout = new Setout();
-        //                //                        setout.Job = job ?? throw new Exception(String.Format("Row [{0}]: Job does not exist for setout [{1}]!", row.RowNum + 1, SetoutNumber));
-        //                //                        setout.Number = SetoutNumber;
-        //                //                        setout.Title = row.GetCell(WindowColumn, MissingCellPolicy.CREATE_NULL_AS_BLANK).StringCellValue;
-        //                //                        setout.WindowNumber = row.GetCell(LocationColumn, MissingCellPolicy.CREATE_NULL_AS_BLANK).StringCellValue;
-        //                //                        setout.Description = String.Format("Glasswork for {0}", SetoutNumber);
-        //                //                    }
-
-        //                //                    DataTable packets = new Client<ManufacturingPacket>().Query(
-        //                //                        new Filter<ManufacturingPacket>(x => x.SetoutID).IsEqualTo(setout.ID),
-        //                //                        new Columns<ManufacturingPacket>(x => x.ManufacturingItemID, x => x.Issued),
-        //                //                         null
-        //                //                    );
-
-        //                //                    String Template = (Supplier.Equals("INHOUSE") || Supplier.Equals("IN HOUSE")) ? "GMO" : "GPO";
-        //                //                    String ItemID = String.Format("{0}/{1}", Template, ID);
-
-        //                //                    ManufacturingItem item = setout.Manufacturing.FirstOrDefault(x => x.Code.Equals(ItemID));
-        //                //                    if (item == null)
-        //                //                    {
-        //                //                        item = new ManufacturingItem();
-        //                //                        setout.Manufacturing.Add(item);
-        //                //                    }
-
-        //                //                    DataRow pktrow = packets.Rows.FirstOrDefault(x => x.Get<ManufacturingPacket, Guid>(r => r.ManufacturingItemID).Equals(item.ID));
-        //                //                    bool bIssued = ((pktrow != null) && (!pktrow.Get<ManufacturingPacket, DateTime>(x => x.Issued).IsEmpty()));
-
-        //                //                    if (!item.Code.StartsWith(Template))
-        //                //                    {
-        //                //                        if (bIssued)
-        //                //                            throw new Exception(String.Format("Row [{0}]: Cannot Change Supplier / In House after packet has been issued!", row.RowNum + 1));
-
-        //                //                        FactoryTemplate template = settings.Templates.Where(x => x.Code.Equals(Template)).FirstOrDefault();
-        //                //                        if (template == null)
-        //                //                            throw new Exception(String.Format("Row [{0}]: {1} Manufacturing Template does not exist!", row.RowNum + 1, Template));
-
-        //                //                        item.TemplateID = template.ID;
-        //                //                        item.Stages.Clear();
-        //                //                        foreach (StageTemplate stage in template.Stages)
-        //                //                        {
-        //                //                            FactorySection section = settings.Sections.Where(x => x.ID.Equals(stage.SectionID)).FirstOrDefault();
-        //                //                            item.Stages.Add(new SetoutStage() { SectionID = stage.SectionID, Name = section != null ? section.Name : "", Minutes = stage.Minutes, Sequence = stage.Sequence });
-        //                //                        }
-
-        //                //                        foreach (var attr in template.Attributes)
-        //                //                            item.Attributes[attr.Name] = "";
-
-        //                //                        item.Group = template.Group;
-        //                //                    }
-
-        //                //                    item.Code = ItemID;
-        //                //                    item.Purchased = Template == "GPO";
-        //                //                    item.Description = String.Format("{0} ({1} x {2})",
-        //                //                        row.GetCell(SpecificationColumn, MissingCellPolicy.CREATE_NULL_AS_BLANK).StringCellValue,
-        //                //                        row.GetCell(WidthColumn, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString(),
-        //                //                        row.GetCell(HeightColumn, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString()
-        //                //                    );
-        //                //                    int Qty = (int)row.GetCell(QtyColumn, MissingCellPolicy.CREATE_NULL_AS_BLANK).NumericCellValue;
-        //                //                    item.Quantity = Qty;
-        //                //                    String[] keys = item.Attributes.Keys.ToArray();
-        //                //                    foreach (String key in keys)
-        //                //                    {
-        //                //                        try
-        //                //                        {
-        //                //                            int col = GetColumn(headerrow, key);
-        //                //                            item.Attributes[key] = row.GetCell(col, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString();
-        //                //                        }
-        //                //                        catch
-        //                //                        {
-        //                //                        }
-        //                //                    }
-        //                //                    new Client<Setout>().Save(setout, "Imported from Master Glass Schedule");
-
-        //                //                }
-
-        //                //            }
-        //                //        }
-        //                Progress.Close();
-        //        MessageBox.Show("Import Completed!");
-        //        Refresh();
-        //    }
-        //            catch (Exception e)
-        //    {
-        //        Progress.Close();
-        //        MessageBox.Show("Error while Importing File!\n\n" + e.Message);
-        //    }
-
-        //}
-        //}
-
-        private BitmapImage BarcodeTypeImage(CoreRow row)
-        {
-            if (row == null)
-                return barcode;
-            return row.Get<ManufacturingItem, bool>(x => x.GroupedBarcode) ? grouped : null;
-        }
-
-        private bool BarcodeTypeClick(CoreRow row)
-        {
-            var item = _items[row.Index];
-            item.GroupedBarcode = !item.GroupedBarcode;
-            return true;
-        }
-
-        public override void ConfigureColumns(DynamicGridColumns columns /*, bool dolookups = true */)
-        {
-            var templates = new Dictionary<object, object>();
-            foreach (var template in settings.Templates)
-                templates[template.ID] = template.Name;
-
-            columns.Clear();
-            columns.AddRange(
-                new[]
-                {
-                    new() { ColumnName = "TemplateID", Caption = "Template", Lookups = templates, Width = 1, Alignment = Alignment.MiddleLeft },
-                    //new DynamicGridColumn(){ ColumnName = "Code", Caption="#", Width = 30, Alignment = DynamicGridColumnAlignment.MiddleCenter },
-                    new DynamicGridColumn { ColumnName = "Serial", Caption = "Serial", Width = 100, Alignment = Alignment.MiddleLeft },
-                    new DynamicGridColumn { ColumnName = "Description", Caption = "Description", Alignment = Alignment.MiddleLeft },
-                    new DynamicGridColumn { ColumnName = "Quantity", Width = 30, Caption = "Qty", Alignment = Alignment.MiddleCenter }
-                }
-            );
-        }
-
-        protected override void Reload(Filters<ManufacturingItem> criteria, Columns<ManufacturingItem> columns, ref SortOrder<ManufacturingItem> sort,
-            Action<CoreTable, Exception> action)
-        {
-            var result = new CoreTable();
-
-            result.Columns.Add(new CoreColumn { ColumnName = "TemplateID", DataType = typeof(Guid) });
-            result.Columns.Add(new CoreColumn { ColumnName = "Serial", DataType = typeof(string) });
-            result.Columns.Add(new CoreColumn { ColumnName = "Description", DataType = typeof(string) });
-            result.Columns.Add(new CoreColumn { ColumnName = "Quantity", DataType = typeof(int) });
-
-            result.LoadColumns(typeof(ManufacturingItem));
-            result.LoadRows(Items);
-            action.Invoke(result, null);
-        }
-
-        protected override ManufacturingItem LoadItem(CoreRow row)
-        {
-            return Items[row.Index];
-        }
-
-        public override void SaveItem(ManufacturingItem item)
-        {
-            if (!Items.Contains(item))
-                Items.Add(item);
-        }
-
-        protected override void DeleteItems(params CoreRow[] rows)
-        {
-            foreach (var index in rows.Select(x => x.Index).OrderByDescending(i => i))
-                Items.RemoveAt(index);
-        }
-
-        public override bool EditItems(ManufacturingItem[] items, Func<Type, CoreTable> PageDataHandler, bool PreloadPages = false)
-        {
-            var templates = new Dictionary<Guid, Guid>();
-            foreach (var item in items)
-                templates[item.ID] = item.TemplateID;
-
-            if (base.EditItems(items, PageDataHandler, PreloadPages))
-            {
-                foreach (var item in items)
-                    if (item.TemplateID != templates[item.ID])
-                    {
-                        item.Stages.Clear();
-
-                        var template = settings.Templates.Where(x => x.ID.Equals(item.TemplateID)).FirstOrDefault();
-                        if (template != null)
-                        {
-                            item.Group = template.Group;
-                            item.Code = template.Code;
-                            item.Stages.Clear();
-                            foreach (var stage in template.Stages)
-                            {
-                                var section = settings.Sections.Where(x => x.ID.Equals(stage.SectionID)).FirstOrDefault();
-                                item.Stages.Add(
-                                    new SetoutStage
-                                    {
-                                        SectionID = stage.SectionID,
-                                        Name = section != null ? section.Name : "",
-                                        Minutes = stage.Minutes,
-                                        Sequence = stage.Sequence,
-                                        QualityChecks = stage.QualityChecks
-                                    }
-                                );
-                            }
-                        }
-                    }
-
-                return true;
-            }
-
-            return false;
-        }
-    }
-}