Selaa lähdekoodia

Drag drop for data entry on the documents window as well.

Kenric Nugteren 1 vuosi sitten
vanhempi
commit
49bd876189

+ 1 - 1
prs.desktop/Panels/DataEntry/DataEntryGrid.cs

@@ -360,7 +360,7 @@ public class DataEntryGrid : DynamicDataGrid<DataEntryDocument>
 
         DataEntryCache.Cache.Add(new DataEntryCachedDocument(document));
 
-        Dispatcher.Invoke(() =>
+        Dispatcher.BeginInvoke(() =>
         {
             Refresh(false, true);
         });

+ 4 - 1
prs.desktop/Panels/DataEntry/DataEntryList.xaml

@@ -54,7 +54,10 @@
                                        PreviewStyle="{StaticResource HorizontalSplitterPreview}"/>
 
                     <Border Grid.Row="2"
-                            BorderBrush="Gray" Background="DimGray">
+                            BorderBrush="Gray" Background="DimGray"
+                            AllowDrop="True"
+                            DragOver="DynamicTabItem_DragOver"
+                            Drop="DynamicTabItem_Drop">
                         <ScrollViewer VerticalScrollBarVisibility="Auto">
                             <StackPanel x:Name="ViewListPanel" Orientation="Vertical" Margin="10">
                                 <StackPanel.ContextMenu>

+ 26 - 23
prs.desktop/Panels/DataEntry/DataEntryList.xaml.cs

@@ -292,38 +292,41 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
     {
         Task.Run(() =>
         {
-            try
+            Dispatcher.Invoke(() =>
             {
-                var result = DocumentUtils.HandleFileDrop(e);
-                if (result is not null)
+                Progress.Show("Uploading documents");
+                try
                 {
-                    foreach (var (filename, stream) in result)
+                    var result = DocumentUtils.HandleFileDrop(e);
+                    if (result is not null)
                     {
-                        var newFilename = filename;
-                        byte[] data;
-                        if (stream is null)
-                        {
-                            data = File.ReadAllBytes(newFilename);
-                        }
-                        else
+                        foreach (var (filename, stream) in result)
                         {
-                            using var memStream = new MemoryStream();
-                            stream.CopyTo(memStream);
-                            data = memStream.ToArray();
+                            var newFilename = filename;
+                            byte[] data;
+                            if (stream is null)
+                            {
+                                data = File.ReadAllBytes(newFilename);
+                            }
+                            else
+                            {
+                                using var memStream = new MemoryStream();
+                                stream.CopyTo(memStream);
+                                data = memStream.ToArray();
+                            }
+                            data = RenderData(ref newFilename, data);
+
+                            _dataEntryGrid.UploadDocument(newFilename, data, Guid.Empty);
                         }
-                        data = RenderData(ref newFilename, data);
-
-                        _dataEntryGrid.UploadDocument(newFilename, data, Guid.Empty);
                     }
+                    Progress.Close();
                 }
-            }
-            catch(Exception e)
-            {
-                Dispatcher.BeginInvoke(() =>
+                catch (Exception e)
                 {
+                    Progress.Close();
                     MessageWindow.ShowError("Could not upload documents.", e);
-                });
-            }
+                }
+            });
         });
     }