using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
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 Aitex.Core.Account;
using Aitex.Triton160.UI.ViewModel;
using ExcelLibrary.SpreadSheet;
using Triton160.UI.ViewModel;
using Aitex.Core.RT.Log;
using Aitex.Core.UI.View.Common;
using Aitex.UI.RecipeEditor.View;
using Aitex.Triton160.Common;
namespace Aitex.Triton160.UI.Views
{
///
/// Interaction logic for RecipeEditorView.xaml
///
public partial class RecipeEditorView : UserControl
{
private string _culture;
private string tragetFilePath = "";
private object OriginalItem;
RecipeEditorViewModel _viewModel;
private Point _lastMouseDown;
private ViewPermission _permission;
public RecipeEditorView()
{
InitializeComponent();
this.DataContext = _viewModel = new RecipeEditorViewModel(new UiRecipeManager(), ModuleName.System.ToString());
this.Loaded += new RoutedEventHandler(RecipeEditorView_Loaded);
this.Unloaded += new RoutedEventHandler(RecipeEditorView_Unloaded);
Triton160UiSystem.Instance.CultureChanged += CultureChanged;
}
private void CultureChanged(string s)
{
_culture = s;
this.tableRecipeGrid.UpdateCultureResource(s);
}
static DependencyObject VisualUpwardSearch(DependencyObject source)
{
while (source != null && source.GetType() != typeof(T))
source = VisualTreeHelper.GetParent(source);
return source;
}
void RecipeEditorView_Unloaded(object sender, RoutedEventArgs e)
{
}
void RecipeEditorView_Loaded(object sender, RoutedEventArgs e)
{
if (_culture!=Thread.CurrentThread.CurrentCulture.Name)
{
_culture = Thread.CurrentThread.CurrentCulture.Name;
this.tableRecipeGrid.UpdateCultureResource(_culture);
}
_viewModel.UpdateAllConfig();
tableRecipeGrid.SetEnableBarcode(_viewModel.IsBarcodeEnabled);
tableRecipeGrid.SetUser(Triton160UiSystem.Instance.CurrentUserName);
UpdateRecipeFileList();
this.Name = "recipeEditor";
_permission = this.GetPermission();
switch (_permission)
{
case ViewPermission.Readonly:
buttonReloadTableRecipe.IsEnabled = false;
tableRecipeGrid.IsEnabled = false;
buttonSaveTableRecipe.IsEnabled = false;
break;
default:
break;
}
}
private void treeViewRcpList_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs