|
@@ -6,6 +6,7 @@ using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media;
|
|
using InABox.Core;
|
|
using InABox.Core;
|
|
|
|
+using InABox.WPF;
|
|
using Microsoft.Win32;
|
|
using Microsoft.Win32;
|
|
|
|
|
|
namespace InABox.DynamicGrid
|
|
namespace InABox.DynamicGrid
|
|
@@ -127,86 +128,13 @@ namespace InABox.DynamicGrid
|
|
dlg.Filter = Filter;
|
|
dlg.Filter = Filter;
|
|
if (dlg.ShowDialog() == true)
|
|
if (dlg.ShowDialog() == true)
|
|
{
|
|
{
|
|
|
|
+ byte[] data = null;
|
|
var filename = Path.GetFileName(dlg.FileName).ToLower();
|
|
var filename = Path.GetFileName(dlg.FileName).ToLower();
|
|
var timestamp = new FileInfo(dlg.FileName).LastWriteTime;
|
|
var timestamp = new FileInfo(dlg.FileName).LastWriteTime;
|
|
- var data = File.ReadAllBytes(dlg.FileName);
|
|
|
|
|
|
+ using (new WaitCursor())
|
|
|
|
+ data = File.ReadAllBytes(dlg.FileName);
|
|
var crc = CoreUtils.CalculateCRC(data);
|
|
var crc = CoreUtils.CalculateCRC(data);
|
|
-
|
|
|
|
- //var existing = OnFindDocument?.Invoke(filename);
|
|
|
|
- //if (existing != null)
|
|
|
|
- //{
|
|
|
|
- // if ((existing.TimeStamp == DateTime.MinValue || existing.TimeStamp.ToString("yyyy-MM-ddThh:mm.ss.fff")
|
|
|
|
- // .Equals(timestamp.ToString("yyyy-MM-ddThh:mm.ss.fff"))) && existing.CRC.Equals(crc))
|
|
|
|
- // {
|
|
|
|
- // if (existing.TimeStamp == DateTime.MinValue)
|
|
|
|
- // {
|
|
|
|
- // existing.TimeStamp = timestamp;
|
|
|
|
- // OnSaveDocument?.Invoke(existing);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // _document = existing;
|
|
|
|
- // }
|
|
|
|
- // else
|
|
|
|
- // {
|
|
|
|
- // var confirm = new DocumentConfirm
|
|
|
|
- // {
|
|
|
|
- // FileName = filename,
|
|
|
|
- // LocalSize = data.Length,
|
|
|
|
- // RemoteSize = existing.Data.Length,
|
|
|
|
- // LocalTimeStamp = timestamp,
|
|
|
|
- // RemoteTimeStamp = existing.TimeStamp
|
|
|
|
- // };
|
|
|
|
- // if (confirm.ShowDialog() == true)
|
|
|
|
- // {
|
|
|
|
- // if (confirm.Result == DocumentAction.Replace)
|
|
|
|
- // {
|
|
|
|
- // existing.Data = data;
|
|
|
|
- // existing.TimeStamp = timestamp;
|
|
|
|
- // existing.CRC = crc;
|
|
|
|
- // OnSaveDocument?.Invoke(existing);
|
|
|
|
- // _document = existing;
|
|
|
|
- // }
|
|
|
|
- // else if (confirm.Result == DocumentAction.UseExisting)
|
|
|
|
- // {
|
|
|
|
- // _document = existing;
|
|
|
|
- // }
|
|
|
|
- // else if (confirm.Result == DocumentAction.MakeCopy)
|
|
|
|
- // {
|
|
|
|
- // var basefilename = Path.GetFileNameWithoutExtension(filename);
|
|
|
|
- // var ext = Path.GetExtension(filename);
|
|
|
|
- // var i = 0;
|
|
|
|
- // while (existing is not null)
|
|
|
|
- // {
|
|
|
|
- // i++;
|
|
|
|
- // filename = Path.ChangeExtension(string.Format("{0} ({1})", basefilename, i), ext);
|
|
|
|
- // existing = OnFindDocument?.Invoke(filename);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // var document = new Document
|
|
|
|
- // {
|
|
|
|
- // FileName = filename,
|
|
|
|
- // Data = data,
|
|
|
|
- // TimeStamp = timestamp,
|
|
|
|
- // CRC = crc
|
|
|
|
- // };
|
|
|
|
- // OnSaveDocument?.Invoke(document);
|
|
|
|
- // _document = document;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- //}
|
|
|
|
- //else
|
|
|
|
- //{
|
|
|
|
- // _document = new Document
|
|
|
|
- // {
|
|
|
|
- // FileName = filename,
|
|
|
|
- // Data = data,
|
|
|
|
- // TimeStamp = timestamp,
|
|
|
|
- // CRC = crc
|
|
|
|
- // };
|
|
|
|
- // OnSaveDocument?.Invoke(_document);
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
|
|
+
|
|
var newDocument = DocumentConfirm.CheckDocument(new Document
|
|
var newDocument = DocumentConfirm.CheckDocument(new Document
|
|
{
|
|
{
|
|
FileName = filename,
|
|
FileName = filename,
|
|
@@ -214,12 +142,14 @@ namespace InABox.DynamicGrid
|
|
Data = data,
|
|
Data = data,
|
|
CRC = crc
|
|
CRC = crc
|
|
}, Host.FindDocument, out var shouldSave);
|
|
}, Host.FindDocument, out var shouldSave);
|
|
|
|
+
|
|
if(newDocument != null)
|
|
if(newDocument != null)
|
|
{
|
|
{
|
|
_document = newDocument;
|
|
_document = newDocument;
|
|
if (shouldSave)
|
|
if (shouldSave)
|
|
{
|
|
{
|
|
- Host.SaveDocument(newDocument);
|
|
|
|
|
|
+ using (new WaitCursor())
|
|
|
|
+ Host.SaveDocument(newDocument);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|