using DataLoader.CS;
|
using DataLoader.Model;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.ComponentModel;
|
using System.IO;
|
using System.Linq;
|
using System.Threading;
|
using System.Windows;
|
using System.Windows.Controls;
|
using System.Windows.Data;
|
|
namespace DataLoader
|
{
|
public partial class MainWindow : Window
|
{
|
public ResWin resWin;
|
|
private LoginWin loginWin;
|
|
private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>();
|
|
public MainWindow()
|
{
|
InitializeComponent();
|
this.DataContext = this;
|
}
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
{
|
CommonProp.Owner = this;
|
CommonProp.Init();
|
|
//this.cbMetaType.ItemsSource= GetMetaTypes();
|
//this.cbMetaType.SelectedIndex= 0;
|
this.btnLoad.IsEnabled = false;
|
this.btnImport.IsEnabled = false;
|
|
lvView.DataContext = viewDatas;
|
lvView.SetBinding(ListView.ItemsSourceProperty, new Binding());
|
|
// string md5 = MD5Helper.GetMD5Hash("E:\\data\\mpt\\A4mpt20131125.mpt");
|
LogOut.Info("************ 应用程序启动成功! ************");
|
}
|
|
private List<MetaType> GetMetaTypes()
|
{
|
List<MetaType> list = new List<MetaType>();
|
list.Add(new MetaType("默认"));
|
list.Add(new MetaType("数字正射影像图"));
|
list.Add(new MetaType("数字高程模型"));
|
list.Add(new MetaType("单波段栅格数据"));
|
list.Add(new MetaType("多光谱栅格数据"));
|
list.Add(new MetaType("高光谱栅格数据"));
|
list.Add(new MetaType("矢量图层"));
|
list.Add(new MetaType("三维模型"));
|
|
return list;
|
}
|
|
// 设置
|
private void Login_MouseLeftButtonDown(object sender, RoutedEventArgs e)
|
{
|
loginWin = new LoginWin();
|
this.Hide();
|
loginWin.Show();
|
}
|
|
public void SetLoginInfo()
|
{
|
if (loginWin != null) loginWin.Close();
|
this.Show();
|
|
this.tbUid.Text = CommonProp.UserId.ToString();
|
this.tbUname.Text = CommonProp.Uname;
|
this.tbToken.Text = CommonProp.Token;
|
|
this.btnLoad.IsEnabled = true;
|
this.btnImport.IsEnabled = true;
|
}
|
|
// 资源目录
|
private void Dir_MouseLeftButtonDown(object sender, RoutedEventArgs e)
|
{
|
if (null == resWin) resWin = new ResWin();
|
this.Hide();
|
this.resWin.Show();
|
}
|
|
public void SetRes(string dircode, string fullName)
|
{
|
this.Show();
|
|
if (!string.IsNullOrEmpty(dircode))
|
{
|
CommonProp.Dircode = dircode;
|
this.tbDir.Text = fullName;
|
}
|
}
|
|
// 数据目录
|
private void Source_MouseLeftButtonDown(object sender, RoutedEventArgs e)
|
{
|
System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
|
if (!String.IsNullOrEmpty(CommonProp.SourcePath) && Directory.Exists(CommonProp.SourcePath)) dialog.SelectedPath = CommonProp.SourcePath;
|
|
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
|
if (result == System.Windows.Forms.DialogResult.Cancel) return;
|
|
this.tbSource.Text = CommonProp.SourcePath = dialog.SelectedPath.Trim();
|
}
|
|
// 目标目录
|
private void Target_MouseLeftButtonDown(object sender, RoutedEventArgs e)
|
{
|
System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
|
if (!String.IsNullOrEmpty(CommonProp.TargetPath) && Directory.Exists(CommonProp.TargetPath)) dialog.SelectedPath = CommonProp.TargetPath;
|
|
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
|
if (result == System.Windows.Forms.DialogResult.Cancel) return;
|
|
this.tbTarget.Text = CommonProp.TargetPath = dialog.SelectedPath.Trim();
|
}
|
|
// 加载
|
private void Load_MouseLeftButtonDown(object sender, RoutedEventArgs e)
|
{
|
//if (string.IsNullOrEmpty(SourcePath) || !Directory.Exists(SourcePath))
|
//{
|
// MessageBox.Show("请选择数据目录!", "提示");
|
// return;
|
//}
|
//if (string.IsNullOrEmpty(TargetPath) || !Directory.Exists(TargetPath))
|
//{
|
// MessageBox.Show("请选择入库目录!", "提示");
|
// return;
|
//}
|
|
//string[] files = Directory.GetFiles(SourcePath);
|
//if (null == files || files.Length == 0)
|
//{
|
// MessageBox.Show("数据目录下没有文件!", "提示");
|
// return;
|
//}
|
|
//this.viewDatas.Clear();
|
//Importor.GetFiles(viewDatas, SourcePath);
|
}
|
|
// 导入
|
private void Import_MouseLeftButtonDown(object sender, RoutedEventArgs e)
|
{
|
if (viewDatas.Count == 0) return;
|
|
//string str = this.tbStart.Text.Trim();
|
//int start = 1;
|
//int.TryParse(str, out start);
|
|
Thread thread = new Thread(new ThreadStart(() =>
|
{
|
//Importor.ImportFiles(viewDatas, TargetPath, start);
|
|
lvView.Dispatcher.BeginInvoke((ThreadStart)delegate
|
{
|
ICollectionView view = CollectionViewSource.GetDefaultView(viewDatas);
|
view.Refresh();
|
});
|
|
MessageBox.Show("数据导入完成!", "提示");
|
}));
|
thread.Start();
|
}
|
}
|
}
|