using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Linq;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
using DevExpress.XtraEditors;
|
using DevExpress.XtraEditors.Filtering;
|
using DevExpress.Utils;
|
using DevExpress.XtraGrid.Views.Grid;
|
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
|
using DevExpress.XtraGrid.Columns;
|
|
namespace IStation.WinFormUI.Project
|
{
|
public partial class LoadProjectOverviewDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public LoadProjectOverviewDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Properties.Resource.app;
|
this.layoutControl1.SetupLayoutControl();
|
this.projectTileViewCtrl1.ReloadDataEvent += ProjectTileViewListCtrl1_ReloadDataEvent;
|
}
|
|
public Model.Project Project;
|
|
//加载项目
|
private void ProjectTileViewListCtrl1_ReloadDataEvent(Model.Project obj)
|
{
|
if (GlobalParas.ProjectId == obj.Id)
|
{
|
XtraMessageBox.Show("项目正在使用,无法加载!");
|
return;
|
}
|
var result = ProjectHelper.LoadProject(obj.Id);
|
if (!result)
|
return;
|
Project = new BLL.Project().GetById(obj.Id);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData()
|
{
|
var allPrj = new BLL.Project().GetAll();
|
if (allPrj == null)
|
allPrj = new List<Model.Project>();
|
this.projectTileViewCtrl1.SetBindingData(allPrj);
|
}
|
|
//打开项目
|
private void tileOpenPrj_ItemClick(object sender, TileItemEventArgs e)
|
{
|
var filePath = ProjectHelper.GetOpenProjectPath();
|
if (string.IsNullOrEmpty(filePath))
|
return;
|
var projecId = ProjectHelper.ImportProject(filePath);
|
if (projecId<1)
|
return;
|
GlobalParas.ProjectId=projecId;
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
//创建项目
|
private void tileCreatePrj_ItemClick(object sender, TileItemEventArgs e)
|
{
|
this.Visible = false;
|
var dlg = new CreateProjectDlg();
|
dlg.SetBindingData();
|
dlg.ReloadDataEvent += (projectId) =>
|
{
|
var result = ProjectHelper.LoadProject(projectId);
|
if (!result)
|
return;
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
};
|
if (dlg.ShowDialog() != DialogResult.OK)
|
{
|
this.Visible = true;
|
}
|
}
|
|
|
}
|
}
|