Fix save and restore state
This commit is contained in:
parent
fa460ec8e4
commit
012cbc4d6d
@ -4,23 +4,13 @@
|
|||||||
|
|
||||||
using bsmd.database.EasyPeasy;
|
using bsmd.database.EasyPeasy;
|
||||||
using ENI2.Util;
|
using ENI2.Util;
|
||||||
using Microsoft.Office.Interop.Excel;
|
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
@ -39,18 +29,16 @@ namespace ENI2.Controls
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
|
public void SaveState()
|
||||||
{
|
{
|
||||||
if (e.Key == Key.V && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
|
try
|
||||||
{
|
{
|
||||||
if (Clipboard.ContainsText())
|
EasyPeasyState.Save(_vm);
|
||||||
{
|
|
||||||
var text = Clipboard.GetText();
|
|
||||||
PasteGoodsItems(text);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
#region button event handler
|
||||||
|
|
||||||
private void buttonClear_Click(object sender, RoutedEventArgs e)
|
private void buttonClear_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
@ -98,6 +86,28 @@ namespace ENI2.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonImport_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog ofd = new OpenFileDialog();
|
||||||
|
ofd.Filter = "XML file|*.xml";
|
||||||
|
ofd.RestoreDirectory = true;
|
||||||
|
ofd.Multiselect = false;
|
||||||
|
|
||||||
|
if (ofd.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
using (var fs = File.OpenRead(ofd.FileName))
|
||||||
|
{
|
||||||
|
var ser = new XmlSerializer(typeof(ProofRequest));
|
||||||
|
_vm = (ProofRequest)ser.Deserialize(fs);
|
||||||
|
this.DataContext = _vm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region loaded/unloaded event handler
|
||||||
|
|
||||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_vm = EasyPeasyState.LoadOrCreate();
|
_vm = EasyPeasyState.LoadOrCreate();
|
||||||
@ -121,6 +131,23 @@ namespace ENI2.Controls
|
|||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region cut & paste logic
|
||||||
|
|
||||||
|
private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.V && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
|
||||||
|
{
|
||||||
|
if (Clipboard.ContainsText())
|
||||||
|
{
|
||||||
|
var text = Clipboard.GetText();
|
||||||
|
PasteGoodsItems(text);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void PasteGoodsItems(string text)
|
private void PasteGoodsItems(string text)
|
||||||
{
|
{
|
||||||
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF == null) return;
|
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF == null) return;
|
||||||
@ -173,23 +200,8 @@ namespace ENI2.Controls
|
|||||||
return res.ToArray();
|
return res.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonImport_Click(object sender, RoutedEventArgs e)
|
#endregion
|
||||||
{
|
|
||||||
OpenFileDialog ofd = new OpenFileDialog();
|
|
||||||
ofd.Filter = "XML file|*.xml";
|
|
||||||
ofd.RestoreDirectory = true;
|
|
||||||
ofd.Multiselect = false;
|
|
||||||
|
|
||||||
if (ofd.ShowDialog() == true)
|
|
||||||
{
|
|
||||||
using (var fs = File.OpenRead(ofd.FileName))
|
|
||||||
{
|
|
||||||
var ser = new XmlSerializer(typeof(ProofRequest));
|
|
||||||
_vm = (ProofRequest)ser.Deserialize(fs);
|
|
||||||
this.DataContext = _vm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -386,6 +386,8 @@ namespace ENI2
|
|||||||
Properties.Settings.Default.MainWindowPlacement = this.GetPlacement();
|
Properties.Settings.Default.MainWindowPlacement = this.GetPlacement();
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
Microsoft.Win32.SystemEvents.SessionEnded -= SystemEvents_SessionEnded;
|
Microsoft.Win32.SystemEvents.SessionEnded -= SystemEvents_SessionEnded;
|
||||||
|
if (easyPeasyControl != null)
|
||||||
|
easyPeasyControl.SaveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_SourceInitialized(object sender, EventArgs e)
|
private void Window_SourceInitialized(object sender, EventArgs e)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user