diff --git a/VECTO3GUI2020/App.config b/VECTO3GUI2020/App.config index a19dee83ebc8f82210bba163a5e1addf19cd0d25..55c4aebced4c762c50554c2a2d6d987e30f2f4a8 100644 --- a/VECTO3GUI2020/App.config +++ b/VECTO3GUI2020/App.config @@ -42,6 +42,14 @@ <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> </assemblyBinding> </runtime> </configuration> \ No newline at end of file diff --git a/VECTO3GUI2020/Ninject/DocumentModule.cs b/VECTO3GUI2020/Ninject/DocumentModule.cs index b989696e777d65d62950502aee7ac1d4c742470f..8e2f284c2f865e218d820bbef3cef9a0cfdbedcd 100644 --- a/VECTO3GUI2020/Ninject/DocumentModule.cs +++ b/VECTO3GUI2020/Ninject/DocumentModule.cs @@ -16,6 +16,8 @@ namespace VECTO3GUI2020.Ninject { Bind<IDocumentViewModel>().To<DeclarationJobViewModel>().Named(XmlDocumentType.DeclarationJobData.ToString()); + Bind<IDocumentViewModel>().To<MultiStageJobViewModel_v0_1>() + .Named(XmlDocumentType.MultistageOutputData.ToString()); //Bind<IDocumentViewModel>().To<MultistageJobViewModel>().Named(XmlDocumentType.MultistageOutputData.ToString()); //Bind<IDocumentViewModel>().To<DeclarationTrailerJobDocumentViewModel>().Named(XmlDocumentType.DeclarationTrailerJobData.ToString()); diff --git a/VECTO3GUI2020/VECTO3GUI2020.csproj b/VECTO3GUI2020/VECTO3GUI2020.csproj index 68c4221d5862a07679ee2355f34180f75a1c6019..321c88a8015f02aba3aed622612bae3e397480e2 100644 --- a/VECTO3GUI2020/VECTO3GUI2020.csproj +++ b/VECTO3GUI2020/VECTO3GUI2020.csproj @@ -59,11 +59,17 @@ <Reference Include="InteractiveDataDisplay.WPF, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\InteractiveDataDisplay.WPF.1.0.0\lib\net452\InteractiveDataDisplay.WPF.dll</HintPath> </Reference> + <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath> + </Reference> <Reference Include="Microsoft.Build.Framework" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.Maps.MapControl.WPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\packages\Microsoft.Maps.MapControl.WPF.1.0.0.3\lib\net40-Client\Microsoft.Maps.MapControl.WPF.dll</HintPath> </Reference> + <Reference Include="Microsoft.Toolkit.Mvvm, Version=7.0.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Toolkit.Mvvm.7.0.2\lib\netstandard2.0\Microsoft.Toolkit.Mvvm.dll</HintPath> + </Reference> <Reference Include="Microsoft.VisualStudio.DebuggerVisualizers, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll</HintPath> @@ -82,8 +88,22 @@ </Reference> <Reference Include="PresentationFramework.Aero2" /> <Reference Include="System" /> + <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath> + </Reference> + <Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath> + </Reference> + <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> + <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath> + </Reference> + <Reference Include="System.Numerics" /> + <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> + </Reference> <Reference Include="System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> <HintPath>..\packages\System.Reactive.5.0.0\lib\net472\System.Reactive.dll</HintPath> </Reference> diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index 014b95dc66735ba0c4d905237ddba2ac2db8dd0e..7e22eb3e0204d773bbe4a1104cb5cf72c9115175 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -4,13 +4,19 @@ using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; +using System.Threading.Tasks; +using System.Windows; using System.Windows.Input; +using Microsoft.Toolkit.Mvvm.Input; +using Microsoft.WindowsAPICodePack.Shell.PropertySystem; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.Utils; +using VECTO3GUI2020.Annotations; using VECTO3GUI2020.Helper; using VECTO3GUI2020.Model.Interfaces; using VECTO3GUI2020.Properties; -using VECTO3GUI2020.Util; using VECTO3GUI2020.ViewModel.Implementation.Common; using VECTO3GUI2020.ViewModel.Interfaces; using VECTO3GUI2020.ViewModel.Interfaces.Document; @@ -18,6 +24,7 @@ using VECTO3GUI2020.ViewModel.MultiStage.Implementation; using VECTO3GUI2020.ViewModel.MultiStage.Interfaces; using VECTO3GUI2020.Views; using IDocumentViewModel = VECTO3GUI2020.ViewModel.Interfaces.Document.IDocumentViewModel; +using RelayCommand = VECTO3GUI2020.Util.RelayCommand; namespace VECTO3GUI2020.ViewModel.Implementation { @@ -43,6 +50,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation private BackgroundWorker fileReadingBackgroundWorker; + private ObservableCollection<IDocumentViewModel> _jobs = new ObservableCollection<IDocumentViewModel>(); public ObservableCollection<IDocumentViewModel> Jobs{ get => _jobs; set => SetProperty(ref _jobs, value);} @@ -51,17 +59,24 @@ namespace VECTO3GUI2020.ViewModel.Implementation private IDocumentViewModelFactory _documentViewModelFactory; private ICommand _newMultiStageFileCommand; private IMultiStageViewModelFactory _multiStageViewModelFactory; + private IAsyncRelayCommand _addJobAsync; + private readonly IXMLInputDataReader _inputDataReader; #endregion + + public JobListViewModel() { + InitFileBackGroundWorker(); + } public JobListViewModel(IDocumentViewModelFactory documentViewModelFactory, + IXMLInputDataReader inputDataReader, IDialogHelper dialogHelper, IWindowHelper windowHelper, IMultiStageViewModelFactory multiStageViewModelFactory) : this() @@ -69,6 +84,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation _documentViewModelFactory = documentViewModelFactory; _dialogHelper = dialogHelper; _windowHelper = windowHelper; + _inputDataReader = inputDataReader; _multiStageViewModelFactory = multiStageViewModelFactory; } @@ -78,20 +94,29 @@ namespace VECTO3GUI2020.ViewModel.Implementation { fileReadingBackgroundWorker = new BackgroundWorker { - WorkerReportsProgress = false + WorkerReportsProgress = true }; fileReadingBackgroundWorker.DoWork += fileworker_DoWork; fileReadingBackgroundWorker.ProgressChanged += fileworker_ProgressChanged; fileReadingBackgroundWorker.RunWorkerCompleted += fileworker_RunWorkerCompleted; } + private void fileworker_ProgressChanged(object sender, ProgressChangedEventArgs e) + { + Debug.WriteLine(e.ProgressPercentage); + } + + public void JobDataGrid_OnDrop(object sender, DragEventArgs e) + { + throw new System.NotImplementedException(); + } #region Commands - public ICommand NewManufacturingStageFile + public ICommand NewManufacturingStageFile { get { @@ -104,6 +129,62 @@ namespace VECTO3GUI2020.ViewModel.Implementation _windowHelper.ShowWindow(_multiStageViewModelFactory.GetNewMultistageJobViewModel()); } + public IAsyncRelayCommand AddJobAsyncCommand + { + get + { + return _addJobAsync ?? new AsyncRelayCommand(AddJobExecuteAsync + , () => true); + } + } + + private async Task<IDocumentViewModel> AddJobExecuteAsync() + { + var fileName = _dialogHelper.OpenXMLFileDialog(); + if (fileName != null) { + return await AddJobAsync(fileName); + } + + return null; + + } + + public async Task<IDocumentViewModel> AddJobAsync(string fileName) + { + if (fileName != null) { + try { + var result = await LoadFileAsync(fileName); + Jobs.Add(result); + return result; + } catch (Exception e) { + var errorString = ""; + errorString = $"{fileName}\n"; + errorString += e.Message; + _dialogHelper.ShowMessageBox(errorString, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + } + + + return null; + } + + private Task<IDocumentViewModel> LoadFileAsync([NotNull] string fileName) + { + var xElement = new System.Xml.XmlDocument(); + xElement.Load(fileName); + + var documentType = XMLHelper.GetDocumentType(xElement?.DocumentElement?.LocalName); + if (documentType == XmlDocumentType.MultistageOutputData) { + var inputDataProvider = _inputDataReader.Create(fileName) as IMultistageBusInputDataProvider; + return Task.FromResult(_multiStageViewModelFactory.GetMultiStageJobViewModel(inputDataProvider) as IDocumentViewModel); + } else { + throw new VectoXMLException($"{documentType.ToString()} not supported"); + } + + return null; + } + + public ICommand AddJob { @@ -121,11 +202,12 @@ namespace VECTO3GUI2020.ViewModel.Implementation private void AddJobExecute() { + //Another possibility is to use IsAsync true property of Binding. IsLoading = true; var filename = _dialogHelper.OpenXMLFileDialog(); if (filename != null) { - fileReadingBackgroundWorker.RunWorkerAsync(filename); + LoadJob(filename); } else { @@ -133,12 +215,17 @@ namespace VECTO3GUI2020.ViewModel.Implementation } } + public void LoadJob([NotNull] string fileName) + { + fileReadingBackgroundWorker.RunWorkerAsync(fileName); + } + public ICommand EditJob { get { - return _editJobCommand ?? new RelayCommand<IJobViewModel>(EditJobExecute, + return _editJobCommand ?? new Util.RelayCommand<IJobViewModel>(EditJobExecute, (IJobViewModel jobentry) => { return (jobentry != null); @@ -163,7 +250,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation { get { - return _viewXMLCommand ?? new RelayCommand<IJobViewModel>(ViewXMLFileExecute, + return _viewXMLCommand ?? new Util.RelayCommand<IJobViewModel>(ViewXMLFileExecute, (IJobViewModel jobentry) => { return (jobentry != null); @@ -192,7 +279,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation { get { - return _removeJobCommand ?? new RelayCommand<IDocumentViewModel>(RemoveJobExecute, (IDocumentViewModel jobentry) => + return _removeJobCommand ?? new Util.RelayCommand<IDocumentViewModel>(RemoveJobExecute, (IDocumentViewModel jobentry) => { return (jobentry != null); }); @@ -217,7 +304,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation { get { - return _moveJobUpCommand ?? new RelayCommand<IDocumentViewModel>(MoveJobUpExecute, (IDocumentViewModel jobentry) => + return _moveJobUpCommand ?? new Util.RelayCommand<IDocumentViewModel>(MoveJobUpExecute, (IDocumentViewModel jobentry) => { return (jobentry != null && Jobs.Count > 1 && Jobs.IndexOf(jobentry) != 0); }); @@ -243,7 +330,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation { get { - return _moveJobDownCommand ?? new RelayCommand<IDocumentViewModel>(MoveJobDownExecute, (IDocumentViewModel jobentry) => + return _moveJobDownCommand ?? new Util.RelayCommand<IDocumentViewModel>(MoveJobDownExecute, (IDocumentViewModel jobentry) => { return (jobentry != null && Jobs.Count > 1 && Jobs.IndexOf(jobentry) != Jobs.Count - 1); }); @@ -276,34 +363,32 @@ namespace VECTO3GUI2020.ViewModel.Implementation string filename = e.Argument as string; Debug.Assert(filename != null); - //TODO: update usage of GetDocumentType; - //Loading the file try { var xElement = new System.Xml.XmlDocument(); xElement.Load(filename); + var documentType = XMLHelper.GetDocumentType(xElement?.DocumentElement?.LocalName); if (documentType == null) { - Debug.WriteLine("Unknown Document Type"); + Debug.WriteLine("Unknown Document Type"); e.Cancel = true; return; } - var result = _documentViewModelFactory.CreateDocumentViewModel((XmlDocumentType)documentType, filename); + + + + var result = _documentViewModelFactory.CreateDocumentViewModel((XmlDocumentType)documentType, filename); e.Result = result; } catch (Exception) { - e.Cancel = true; + e.Cancel = true; throw; } } - void fileworker_ProgressChanged(object sender, ProgressChangedEventArgs e) - { - - } void fileworker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { diff --git a/VECTO3GUI2020/ViewModel/Interfaces/IJobListViewModel.cs b/VECTO3GUI2020/ViewModel/Interfaces/IJobListViewModel.cs index 03e44d2df9553fa167311b8c6c9554a74b32a778..6b09b8717c8fab496c4bae1091a04c2640d9cbce 100644 --- a/VECTO3GUI2020/ViewModel/Interfaces/IJobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Interfaces/IJobListViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using System.Threading.Tasks; using System.Windows.Input; using VECTO3GUI2020.Model.Interfaces; using VECTO3GUI2020.ViewModel.Interfaces.Document; @@ -11,5 +12,6 @@ namespace VECTO3GUI2020.ViewModel.Interfaces ICommand EditJob { get; } ObservableCollection<IDocumentViewModel> Jobs { get; } ICommand NewManufacturingStageFile { get; } + Task<IDocumentViewModel> AddJobAsync(string fileName); } } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs index 13599c6d0dec5cbda17de537e6810b7cc31caf75..29768682d4cbb9fe4badade2725211b329c39ee3 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs @@ -34,7 +34,7 @@ using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation { - public interface IMultiStageJobViewModel : IDeclarationMultistageJobInputData, IMultistageVIFInputData, IMultistageBusInputDataProvider + public interface IMultiStageJobViewModel : IDeclarationMultistageJobInputData, IMultistageVIFInputData, IMultistageBusInputDataProvider, IJobViewModel, IEditViewModel { IManufacturingStageViewModel ManufacturingStageViewModel { get; } } @@ -63,6 +63,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation _dataSource = inputData.DataSource; _jobInputData = inputData.JobInputData; + _inputData = inputData; _vmFactory = vmFactory; _consolidateManufacturingStage = _jobInputData.ConsolidateManufacturingStage; _manufacturingStages = _jobInputData.ManufacturingStages; @@ -221,6 +222,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation private string _vehicleInputDataFilePath = null; private readonly IMultistageDependencies _multistageDependencies; private readonly DataSource _dataSource; + private readonly IMultistageBusInputDataProvider _inputData; public ICommand LoadVehicleDataCommand { @@ -270,8 +272,14 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation #region Implementation of IInputDataProvider + public string DocumentName => Path.GetFileNameWithoutExtension(_inputData.DataSource.SourceFile); + + public XmlDocumentType DocumentType => XmlDocumentType.MultistageOutputData; + public DataSource DataSource => _dataSource; + public IEditViewModel EditViewModel => this; + #endregion #region Implementation of IMultistageVIFInputData @@ -329,6 +337,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } + #endregion + + #region Implementation of IEditViewModel + + public string Name => "Multistage"; + #endregion } diff --git a/VECTO3GUI2020/Views/JoblistView.xaml b/VECTO3GUI2020/Views/JoblistView.xaml index 1498fe07bc94389bbf6ebb408054aa68a823e5fd..113e947d74dc5c992cefc3f9eed6561fdd06fdec 100644 --- a/VECTO3GUI2020/Views/JoblistView.xaml +++ b/VECTO3GUI2020/Views/JoblistView.xaml @@ -32,32 +32,33 @@ </Grid> </Border> <Grid Grid.Column="1"> - <Border BorderBrush="{StaticResource AccentColorButton}" BorderThickness="1"> - <StackPanel VerticalAlignment="Stretch"> - <DataGrid ItemsSource="{Binding Jobs}" - Name="JobDataGrid" - HorizontalAlignment="Stretch" - IsReadOnly="True" - CanUserReorderColumns="False" - AutoGenerateColumns="False" - SelectionMode="Single" - GridLinesVisibility="None" - HorizontalScrollBarVisibility="Disabled" - RowHeaderWidth="0" - ColumnHeaderHeight="30" - VerticalAlignment="Stretch" - VerticalContentAlignment="Stretch" - BorderThickness="0" - ColumnHeaderStyle="{StaticResource JobListDataGridHeaderStyle}" - Height="Auto" - RowHeight="30" - AlternatingRowBackground="LightGray" CellStyle="{DynamicResource DataGridCellStyle1}" - > + <Border BorderBrush="{StaticResource AccentColorButton}" BorderThickness="0" > + <DataGrid ItemsSource="{Binding Jobs}" + BorderBrush ="{StaticResource AccentColorButton}" BorderThickness="1" + Name="JobDataGrid" + HorizontalAlignment="Stretch" + IsReadOnly="True" + CanUserReorderColumns="False" + AutoGenerateColumns="False" + SelectionMode="Single" + GridLinesVisibility="None" + HorizontalScrollBarVisibility="Disabled" + RowHeaderWidth="0" + ColumnHeaderHeight="30" + VerticalAlignment="Stretch" + VerticalContentAlignment="Stretch" + AllowDrop="True" Drop="JobDataGrid_OnDrop" + PreviewDrop = "JobDataGrid_OnPreviewDrop" + ColumnHeaderStyle="{StaticResource JobListDataGridHeaderStyle}" + + RowHeight="30" + AlternatingRowBackground="LightGray" CellStyle="{DynamicResource DataGridCellStyle1}" + > <DataGrid.Columns> <DataGridTextColumn Header="Name" Binding="{Binding DocumentName}" Width="1*"></DataGridTextColumn> <DataGridTextColumn Header="Type" Binding="{Binding DocumentType}" Width="1*"></DataGridTextColumn> </DataGrid.Columns> - <DataGrid.RowDetailsTemplate> + <DataGrid.RowDetailsTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <Label x:Name="label" Content="Filename"/> @@ -65,15 +66,14 @@ </StackPanel> </DataTemplate> </DataGrid.RowDetailsTemplate> - <DataGrid.InputBindings> + <DataGrid.InputBindings> <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding EditJob}" CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}"></MouseBinding> </DataGrid.InputBindings> </DataGrid> - <Label x:Name="label" Content="Loading . . ." Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}"/> - </StackPanel> + <!--<Label x:Name="label" Content="Loading . . ." Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}"/>--> </Border> </Grid> <Grid Grid.Column="2"> @@ -81,7 +81,7 @@ <StackPanel > <Button x:Name="button3" Margin="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" - Command="{Binding AddJob}" Background="#FFDDDDDD"> + Command="{Binding AddJobAsyncCommand}" Background="#FFDDDDDD"> OpenFile</Button> <Button x:Name="button4" Margin ="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" diff --git a/VECTO3GUI2020/Views/JoblistView.xaml.cs b/VECTO3GUI2020/Views/JoblistView.xaml.cs index 0016ff85ba47f5089869cdf6ce8f3e868e028a38..b64cacf114f17b87aeb375903b41251c696ad156 100644 --- a/VECTO3GUI2020/Views/JoblistView.xaml.cs +++ b/VECTO3GUI2020/Views/JoblistView.xaml.cs @@ -1,4 +1,7 @@ -using System.Windows.Controls; +using System.Windows; +using System.Windows.Controls; +using VECTO3GUI2020.ViewModel.Implementation; +using VECTO3GUI2020.ViewModel.Interfaces; namespace VECTO3GUI2020.Views { @@ -7,9 +10,41 @@ namespace VECTO3GUI2020.Views /// </summary> public partial class JobListView : UserControl { - public JobListView() - { - InitializeComponent(); - } - } + + public JobListView() + { + InitializeComponent(); + + } + + + private void JobDataGrid_OnDrop(object sender, DragEventArgs e) + { + var success = true; + if (e.Data.GetDataPresent(DataFormats.FileDrop)) { + + + var fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[]; + if (fileNames != null) { + foreach (var fileName in fileNames) { + ((JobListViewModel)this.DataContext).AddJobAsync(fileName); + } + } + + } else { + success = false; + } + + if (!success) { + e.Effects = DragDropEffects.None; //DO NOT ACCEPT THE DROP + } + } + + private void JobDataGrid_OnPreviewDrop(object sender, DragEventArgs e) + { + if (!e.Data.GetDataPresent(DataFormats.FileDrop)) { + e.Effects = DragDropEffects.None; + } + } + } } diff --git a/VECTO3GUI2020/packages.config b/VECTO3GUI2020/packages.config index 0276e5449b4acc356224fcf078f00f9c1f866c08..858916a3f79f42e0406d5119d5d69b34c14416a4 100644 --- a/VECTO3GUI2020/packages.config +++ b/VECTO3GUI2020/packages.config @@ -2,10 +2,16 @@ <packages> <package id="Castle.Core" version="4.4.1" targetFramework="net48" /> <package id="InteractiveDataDisplay.WPF" version="1.0.0" targetFramework="net48" /> + <package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net48" /> <package id="Microsoft.Maps.MapControl.WPF" version="1.0.0.3" targetFramework="net48" /> + <package id="Microsoft.Toolkit.Mvvm" version="7.0.2" targetFramework="net48" /> <package id="Ninject" version="3.3.4" targetFramework="net48" /> <package id="Ninject.Extensions.ChildKernel" version="3.3.0" targetFramework="net48" /> <package id="Ninject.Extensions.Factory" version="3.3.3" targetFramework="net48" /> + <package id="System.Buffers" version="4.5.1" targetFramework="net48" /> + <package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net48" /> + <package id="System.Memory" version="4.5.4" targetFramework="net48" /> + <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" /> <package id="System.Reactive" version="5.0.0" targetFramework="net48" /> <package id="System.Reactive.Core" version="5.0.0" targetFramework="net48" /> <package id="System.Reactive.Linq" version="5.0.0" targetFramework="net48" />