Selaa lähdekoodia

Removed DynamicIssuesColumn and DynamicIssuesEditor implementations

frankvandenbos 7 kuukautta sitten
vanhempi
commit
f0b52d6b9d

+ 0 - 180
inabox.wpf/DynamicGrid/Columns/DynamicIssuesColumn.cs

@@ -1,180 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media.Imaging;
-using InABox.Clients;
-using InABox.Core;
-using InABox.WPF;
-
-namespace InABox.DynamicGrid;
-
-// public interface IDynamicIssuesColumn
-// {
-//     Func<IIssues[], FrameworkElement?>? CustomiseEditor { get; set; }
-//     Action<IIssues[], FrameworkElement?>? IssuesUpdated { get; set; }
-// }
-//
-// public class DynamicIssuesColumn<TIssues> : DynamicImageColumn, IDynamicIssuesColumn
-//     where TIssues : Entity, IRemotable, IPersistent, IIssues, new()
-// {
-//     private static readonly BitmapImage _warning = Wpf.Resources.warning.AsBitmapImage();
-//     private static readonly BitmapImage _graywarning = Wpf.Resources.warning.AsGrayScale().AsBitmapImage();
-//
-//     private readonly IDynamicGrid _parent;
-//
-//     public string IssuesProperty;
-//     public string IssuesResolvedProperty;
-//     public Func<CoreRow[], TIssues[]> LoadIssues;
-//
-//     public Func<IIssues[], FrameworkElement?>? CustomiseEditor { get; set; }
-//     
-//     public Action<IIssues[], FrameworkElement?>? IssuesUpdated { get; set; }
-//
-//     public DynamicIssuesColumn(IDynamicGrid parent, string issuesProperty, string issuesResolvedProperty, Func<CoreRow[], TIssues[]> loadIssues)
-//     {
-//         Image = IssuesImage;
-//         Filters = new[] { "Active Issues", "No Issues" };
-//         FilterRecord = DoFilterIssues;
-//         ContextMenu = CreateIssuesMenu;
-//         ToolTip = CreateIssuesToolTip;
-//         _parent = parent;
-//         Position = DynamicActionColumnPosition.Start;
-//
-//         IssuesProperty = issuesProperty;
-//         IssuesResolvedProperty = issuesResolvedProperty;
-//         LoadIssues = loadIssues;
-//     }
-//
-//     public DynamicIssuesColumn(IDynamicGrid parent):
-//         this(parent, CoreUtils.GetFullPropertyName<TIssues, string>(x => x.Issues, ""), CoreUtils.GetFullPropertyName<TIssues, DateTime>(x => x.IssuesResolved, ""), (rows) => rows.ToObjects<TIssues>().ToArray())
-//     {
-//     }
-//
-//     private string? GetIssues(CoreRow? row)
-//     {
-//         return row?.Get<string>(IssuesProperty);
-//     }
-//     
-//     private DateTime GetIssuesResolved(CoreRow? row)
-//     {
-//         return row?.Get<DateTime>(IssuesResolvedProperty) ?? DateTime.MinValue;
-//     }
-//
-//     private BitmapImage? IssuesImage(CoreRow? row)
-//     {
-//         if (GetIssues(row).IsNullOrWhiteSpace())
-//             return null;
-//         return GetIssuesResolved(row).IsEmpty()
-//             ? _warning
-//             : _graywarning;
-//     }
-//
-//     private FrameworkElement? CreateIssuesToolTip(DynamicActionColumn column, CoreRow? row)
-//     {
-//         var text = GetIssues(row);
-//         if (text.IsNullOrWhiteSpace())
-//             text = "No Issues Found";
-//         return TextToolTip(text);
-//     }
-//
-//     private bool DoFilterIssues(CoreRow row, string[] filter)
-//     {
-//         var noissues = GetIssues(row).IsNullOrWhiteSpace();
-//         if (filter.Contains("No Issues") && noissues)
-//             return true;
-//         if (filter.Contains("Active Issues") && !noissues)
-//             return true;
-//         return false;
-//     }
-//
-//     private MenuItem CreateMenu(string caption, RoutedEventHandler click)
-//     {
-//         var item = new MenuItem();
-//         item.Header = caption;
-//         item.Click += click;
-//         return item;
-//     }
-//
-//     private ContextMenu? CreateIssuesMenu(CoreRow[]? rows)
-//     {
-//         if (!Security.CanManageIssues<TIssues>())
-//             return null;
-//
-//         var issues = rows?.Select(GetIssues).Where(x => !string.IsNullOrWhiteSpace(x)).Any();
-//         var result = new ContextMenu();
-//
-//         if (issues != true)
-//         {
-//             result.Items.Add(CreateMenu("Create Issue", (o, e) => EditIssues(rows)));
-//         }
-//         else
-//         {
-//             result.Items.Add(CreateMenu("Update Issues", (o, e) => EditIssues(rows)));
-//             result.Items.Add(CreateMenu("Clear Issues", (o, e) => ClearIssues(rows)));
-//         }
-//
-//         return result;
-//     }
-//
-//     private void ClearIssues(CoreRow[]? rows)
-//     {
-//         if (rows is null)
-//         {
-//             return;
-//         }
-//         if (MessageBox.Show("This will clear the flagged issues for these items!\n\nAre you sure you wish to continue?", "Confirm",
-//                 MessageBoxButton.YesNo) == MessageBoxResult.Yes)
-//         {
-//             var _updates = LoadIssues(rows).ToArray();
-//             foreach (var update in _updates)
-//             {
-//                 update.Issues = "";
-//             }
-//             using (new WaitCursor())
-//             {
-//                 Client.Save(_updates, "Clearing Issues", (o, e) => { });
-//             }
-//
-//             // False here to prevent Refreshing and losing the selected row record
-//             foreach (var row in rows)
-//                 _parent.UpdateRow(row, IssuesProperty, "");
-//         }
-//     }
-//
-//     private void EditIssues(CoreRow[]? rows)
-//     {
-//         var _objects = LoadIssues(rows ?? Array.Empty<CoreRow>());
-//
-//         var _map = new Dictionary<CoreRow, TIssues>();
-//         if (rows is not null)
-//         {
-//             var i = 0;
-//             foreach (var row in rows)
-//             {
-//                 _map[row] = _objects[i];
-//                 ++i;
-//             }
-//         }
-//
-//         var _values = _map.Values.OfType<IIssues>().ToArray();
-//         var _editor = new DynamicIssuesEditor(_values);
-//         var _custom = CustomiseEditor?.Invoke(_values);
-//         if (_custom != null)
-//             _editor.SetCustom(_custom);
-//         if (_editor.ShowDialog() == true)
-//         {
-//             using (new WaitCursor())
-//             {
-//                 if (_custom != null)
-//                     IssuesUpdated?.Invoke(_values, _custom);
-//                 Client.Save(_map.Values, "Updating Issues", (o, e) => { });
-//             }
-//
-//             foreach (var _row in _map.Keys)
-//                 _parent.UpdateRow(_row, IssuesProperty, _map[_row].Issues);
-//         }
-//     }
-// }

+ 0 - 37
inabox.wpf/DynamicGrid/DynamicIssuesEditor.xaml

@@ -1,37 +0,0 @@
-<wpf:ThemableWindow x:Class="InABox.DynamicGrid.DynamicIssuesEditor"
-        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"
-        mc:Ignorable="d"
-        Title="Update Issues" Height="450" Width="800" Margin="5">
-    <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="Auto" />
-            <ColumnDefinition Width="*" />
-            <ColumnDefinition Width="Auto" />
-            <ColumnDefinition Width="Auto" />
-        </Grid.ColumnDefinitions>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="*" />
-            <RowDefinition Height="100" />
-            <RowDefinition Height="Auto" />
-        </Grid.RowDefinitions>
-        <TextBox x:Name="History" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Margin="5" IsReadOnly="True"
-                 TextWrapping="Wrap" Background="WhiteSmoke" Foreground="DimGray" />
-        <DockPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Margin="5,0,5,5">
-            <Button x:Name="AddNote" DockPanel.Dock="Right" Width="100" Content="Add Note" Click="AddNote_Click"
-                    Margin="5,0,0,0" PreviewKeyDown="AddNote_PreviewKeyDown" TabIndex="2" />
-            <TextBox x:Name="NewNote" DockPanel.Dock="Left" TextChanged="NewNote_TextChanged" Background="LightYellow"
-                     TextWrapping="Wrap" AcceptsReturn="True" TabIndex="1" />
-        </DockPanel>
-        <Button x:Name="ClearIssues" Grid.Row="2" Grid.Column="0" Width="80" Padding="5" Margin="5,0,0,5"
-                Content="Clear" Click="ClearIssues_Click" TabIndex="3" Visibility="Collapsed" />
-        <DockPanel x:Name="Custom" Grid.Row="2" Grid.Column="1" Margin="5,0,5,5" />
-        <Button x:Name="OK" Grid.Row="2" Grid.Column="2" Width="80" Padding="5" Margin="0,0,5,5" Content="OK"
-                Click="OK_Click" TabIndex="4" />
-        <Button x:Name="Cancel" Grid.Row="2" Grid.Column="3" Width="80" Padding="5" Margin="0,0,5,5" Content="Cancel"
-                Click="Cancel_Click" TabIndex="5" />
-    </Grid>
-</wpf:ThemableWindow>

+ 0 - 108
inabox.wpf/DynamicGrid/DynamicIssuesEditor.xaml.cs

@@ -1,108 +0,0 @@
-using InABox.Wpf;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using InABox.Clients;
-using InABox.Core;
-
-namespace InABox.DynamicGrid
-{
-    /// <summary>
-    ///     Interaction logic for ProductIssuesWindow.xaml
-    /// </summary>
-    public partial class DynamicIssuesEditor : ThemableWindow
-    {
-        private readonly IIssues[] _items;
-
-        private readonly List<string> notes = new();
-
-        public DynamicIssuesEditor(IIssues[] issues, bool allowclear = false)
-        {
-            _items = issues;
-            InitializeComponent();
-            ReloadHistory();
-            ClearIssues.Visibility = allowclear ? Visibility.Visible : Visibility.Collapsed;
-        }
-
-        public void SetCustom(FrameworkElement custom)
-        {
-            Custom.Children.Clear();
-            Custom.Children.Add(custom);
-        }
-
-        private void ReloadHistory()
-        {
-            var issues = _items.Select(x => x.Issues).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToArray();
-
-            var history = new List<string>();
-            if (issues.Length == 1)
-                history.Add(issues[0]);
-            else if (issues.Length > 1)
-                history.Add("(Multiple Issues Noted)");
-
-            if (issues.Length > 0 && notes.Any())
-                history.Add("=========================================");
-            if (notes.Any())
-                history.AddRange(notes);
-
-            History.Text = string.Join("\n", history);
-        }
-
-        private void ClearIssues_Click(object sender, RoutedEventArgs e)
-        {
-            if (MessageBox.Show("Are you sure you wish to clear these notes?", "Confirm Clear", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
-                return;
-            foreach (var item in _items)
-                item.Issues = "";
-            DialogResult = true;
-        }
-
-        private void OK_Click(object sender, RoutedEventArgs e)
-        {
-            if (!notes.Any())
-            {
-                DialogResult = false;
-            }
-            else
-            {
-                foreach (var item in _items)
-                    item.Issues = (string.IsNullOrWhiteSpace(item.Issues) ? "" : item.Issues + "\n") + string.Format(
-                        "{0:dd MMM yy hh\\:mm\\:ss} {1} {2}",
-                        DateTime.Now, ClientFactory.UserID, string.Join("\n", notes));
-                DialogResult = true;
-            }
-        }
-
-        private void Cancel_Click(object sender, RoutedEventArgs e)
-        {
-            DialogResult = false;
-        }
-
-        private void AddNote_Click(object sender, RoutedEventArgs e)
-        {
-            DoAddNote();
-        }
-
-        private void DoAddNote()
-        {
-            notes.Add(NewNote.Text);
-            NewNote.Text = "";
-            NewNote.Focus();
-            ReloadHistory();
-        }
-
-        private void NewNote_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            AddNote.IsEnabled = !string.IsNullOrWhiteSpace(NewNote.Text);
-        }
-
-        private void AddNote_PreviewKeyDown(object sender, KeyEventArgs e)
-        {
-            if (e.Key == Key.Enter || e.Key == Key.Return)
-                DoAddNote();
-        }
-    }
-}

+ 0 - 3
inabox.wpf/InABox.Wpf.csproj

@@ -521,9 +521,6 @@
       <Page Update="DynamicGrid\DynamicImportList.xaml">
         <XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
       </Page>
-      <Page Update="DynamicGrid\DynamicIssuesEditor.xaml">
-        <XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
-      </Page>
       <Page Update="DynamicGrid\DynamicKanbanColumn.xaml">
         <XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
       </Page>