|
|
@@ -16,6 +16,7 @@ using InABox.WPF;
|
|
|
using InABox.Wpf;
|
|
|
using System.ComponentModel;
|
|
|
using System.Runtime.CompilerServices;
|
|
|
+using BooleanToVisibilityConverter = InABox.WPF.BooleanToVisibilityConverter;
|
|
|
|
|
|
namespace PRSDesktop;
|
|
|
|
|
|
@@ -385,6 +386,7 @@ public partial class ManufacturingAllocationPanel : UserControl, IPanel<Manufact
|
|
|
set
|
|
|
{
|
|
|
_items = value;
|
|
|
+ IsVisible = value.Length > 0;
|
|
|
OnPropertyChanged();
|
|
|
}
|
|
|
}
|
|
|
@@ -411,6 +413,17 @@ public partial class ManufacturingAllocationPanel : UserControl, IPanel<Manufact
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private bool _isVisible;
|
|
|
+ public bool IsVisible
|
|
|
+ {
|
|
|
+ get => _isVisible;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _isVisible = value;
|
|
|
+ OnPropertyChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public ManufacturingAllocationKanban? SelectedKanban { get; set; }
|
|
|
|
|
|
public required int Station { get; set; }
|
|
|
@@ -465,9 +478,7 @@ public partial class ManufacturingAllocationPanel : UserControl, IPanel<Manufact
|
|
|
|
|
|
var grid = new Grid();
|
|
|
grid.AddColumn(GridUnitType.Auto);
|
|
|
- grid.AddColumn(iStation == nStations - 1 && Security.IsAllowed<CanViewFactorySettings>() ? 30 : 0);
|
|
|
grid.AddColumn(GridUnitType.Star);
|
|
|
- grid.AddColumn(iStation == nStations - 1 && Security.IsAllowed<CanViewFactorySettings>() ? 30 : 0);
|
|
|
grid.AddColumn(GridUnitType.Auto);
|
|
|
border.Child = grid;
|
|
|
|
|
|
@@ -490,14 +501,6 @@ public partial class ManufacturingAllocationPanel : UserControl, IPanel<Manufact
|
|
|
|
|
|
grid.AddChild(checkborder, 0, 0);
|
|
|
|
|
|
- var remove = new Button
|
|
|
- {
|
|
|
- Margin = new Thickness(0, 0, 2, 0),
|
|
|
- Content = "-"
|
|
|
- };
|
|
|
- remove.Click += Remove_Click;
|
|
|
- grid.AddChild(remove, 0, 1);
|
|
|
-
|
|
|
var labelborder = new Border
|
|
|
{
|
|
|
BorderBrush = new SolidColorBrush(Colors.Gray),
|
|
|
@@ -514,15 +517,7 @@ public partial class ManufacturingAllocationPanel : UserControl, IPanel<Manufact
|
|
|
};
|
|
|
|
|
|
labelborder.Child = label;
|
|
|
- grid.AddChild(labelborder, 0, 2);
|
|
|
-
|
|
|
- var add = new Button
|
|
|
- {
|
|
|
- Margin = new Thickness(0, 0, 2, 0),
|
|
|
- Content = "+"
|
|
|
- };
|
|
|
- add.Click += Add_Click;
|
|
|
- grid.AddChild(add, 0, 3);
|
|
|
+ grid.AddChild(labelborder, 0, 1);
|
|
|
|
|
|
var hoursborder = new Border
|
|
|
{
|
|
|
@@ -539,7 +534,7 @@ public partial class ManufacturingAllocationPanel : UserControl, IPanel<Manufact
|
|
|
VerticalContentAlignment = VerticalAlignment.Center
|
|
|
};
|
|
|
hoursborder.Child = hours;
|
|
|
- grid.AddChild(hoursborder, 0, 4);
|
|
|
+ grid.AddChild(hoursborder, 0, 2);
|
|
|
|
|
|
var Items = new ListBox
|
|
|
{
|
|
|
@@ -564,9 +559,13 @@ public partial class ManufacturingAllocationPanel : UserControl, IPanel<Manufact
|
|
|
Items.Bind(ListBox.ItemsSourceProperty, col, x => x.Items);
|
|
|
check.Bind(CheckBox.IsCheckedProperty, col, x => x.IsChecked);
|
|
|
hours.Bind(Label.ContentProperty, col, x => x.Hours, format: "{0:F2} hrs");
|
|
|
+ border.Bind(Border.VisibilityProperty, col, x => x.IsVisible,
|
|
|
+ converter: new BooleanToVisibilityConverter(Visibility.Visible, Visibility.Collapsed));
|
|
|
+ gridColumn.SetBinding(ColumnDefinition.WidthProperty,
|
|
|
+ WPFUtils.CreateBinding(col, x => x.IsVisible,
|
|
|
+ converter: new FuncConverter<bool, GridLength>(x => x ? new GridLength(1, GridUnitType.Star) : new GridLength(0))));
|
|
|
|
|
|
check.Tag = col;
|
|
|
- remove.Tag = col;
|
|
|
Items.Tag = col;
|
|
|
|
|
|
_columns.Add(col);
|
|
|
@@ -594,61 +593,6 @@ public partial class ManufacturingAllocationPanel : UserControl, IPanel<Manufact
|
|
|
_currentColumn = ((sender as FrameworkElement)!.Tag as ManufacturingAllocationColumn)!;
|
|
|
}
|
|
|
|
|
|
- private void Add_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- var sectionid = (Guid)Sections.SelectedValue;
|
|
|
-
|
|
|
- var section = _sections.FirstOrDefault(x => x.ID == _settings.Section);
|
|
|
- if (section != null)
|
|
|
- {
|
|
|
- section.Stations += 1;
|
|
|
- Client.Save(section, "Added Station");
|
|
|
- UpdateSections();
|
|
|
- ReloadColumns();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void Remove_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- var sectionid = (Guid)Sections.SelectedValue;
|
|
|
-
|
|
|
- var section = _sections.FirstOrDefault(x => x.ID == _settings.Section);
|
|
|
- if (section != null)
|
|
|
- {
|
|
|
- if (section.Stations < 2)
|
|
|
- {
|
|
|
- MessageWindow.ShowMessage("There must be at least one station available in each section!", "Invalid operation");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- var button = (sender as Button)!;
|
|
|
- var listbox = button.Tag as ListBox;
|
|
|
- var kanbans = ((sender as Button)?.Tag as ManufacturingAllocationColumn)?.Items ?? [];
|
|
|
- if (kanbans.Any(x => !x.Assignee.Equals("-1")))
|
|
|
- {
|
|
|
- MessageWindow.ShowMessage("Please clear out all packets before removing this station!", "Station incomplete");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- section.Stations -= 1;
|
|
|
- Client.Save(section, "Removed Station");
|
|
|
- UpdateSections();
|
|
|
- ReloadColumns();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void CardSelected(object sender, MouseButtonEventArgs e)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
- private void CardPreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
- private void CardChecked(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
private void Border_ContextMenuOpening(object sender, ContextMenuEventArgs e)
|
|
|
{
|
|
|
e.Handled = true;
|