using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AppReleaseCheckTool.BL;
using AppReleaseCheckTool.Models;
using System.Configuration;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win.UltraWinDataSource;
using Infragistics.Win;
using Infragistics.Win.CalcEngine;
namespace AppReleaseCheckTool
{
public partial class FrmMain : Form
{
public SetCheckConfigModel _setCheckConfigModel;
List<FolderInfoModel> dataList = null;
public FrmMain()
{
InitializeComponent();
}
private void btnSet_Click(object sender, EventArgs e)
{
OpenConfigShowDialog();
}
/// <summary>
/// 打开配置窗口
/// </summary>
private void OpenConfigShowDialog()
{
using (FrmSetCheckConfig config = new FrmSetCheckConfig())
{
if (config.ShowDialog(this) == DialogResult.OK)
{
MessageBox.Show("设置生效,需要重新启动应用程序!");
}
}
}
private void btnCheck_Click(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
CheckFolderFileBO bo = CheckFolderFileBO.Instance();
bo.CurrSetCheckConfigModel = _setCheckConfigModel;
bo.GetFolderFileMessage = new FolderFileMessage { DirCount=0,FileCount=0};
dataList = bo.SearchFileAll(cbDisplayFilter.Checked);
BindGrid(dataList);
appStatusStrip.Items[0].Text = bo.GetFolderFileMessage.ToString();
}
catch (Exception ex)
{
// log.Error(ex.Message);
throw ex;
}
}
private void UpdateDisplay()
{
Infragistics.Win.UltraWinGrid.UltraGridLayout dl = this.dgView.DisplayLayout;
dl.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.MultiBand;
dl.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
}
private void BindGrid(List<FolderInfoModel> list)
{
try
{
if (null != list && list.Count > 0)
{
this.dgView.SetDataBinding(list, null);
foreach (var item in this.dgView.DisplayLayout.Bands)
{
item.RowLayoutStyle = RowLayoutStyle.GroupLayout;
item.Columns["ParentFolder"].Hidden = true;
}
}
}
catch (Exception ex)
{
//log.Error(ex.Message);
throw ex;
}
}
private void FrmMain_Load(object sender, EventArgs e)
{
this.Text = " 通用应用程序发布检查工具 " + " Ver "+this.ProductVersion.Substring(0,this.ProductVersion.IndexOf('.',2));
UpdateDisplay();
Config_Load();
}
void dgView_InitializeGroupByRow(object sender, InitializeGroupByRowEventArgs e)
{
if (e.Row.ListObject.ToString() == "AppReleaseCheckTool.Models.FileInfoModel")
{
if (e.Row.Cells["Company"].Value != null &&
e.Row.Cells["Company"].Value.ToString().ToUpper() == "SUREKAM")
{
if (e.Row.Cells["ProductMajorPart"].Value != null
&& Convert.ToInt32(e.Row.Cells["ProductMajorPart"].Value) >= 4)
{
// Create an appearance that sets the ForeColor to blue.
Infragistics.Win.Appearance evenAppearance = new Infragistics.Win.Appearance("Even");
evenAppearance.ForeColor = Color.Blue;
e.Row.Cells["ProductMajorPart"].Appearance = evenAppearance;
}
else
{
Infragistics.Win.Appearance oddAppearance = new Infragistics.Win.Appearance("Odd");
oddAppearance.ForeColor = Color.Red;
e.Row.Cells["ProductMajorPart"].Appearance = oddAppearance;
}
}
}
}
void dgView_InitializeRow(object sender, InitializeRowEventArgs e)
{
//if (e.Row.ListObject.ToString() == "AppReleaseCheckTool.Models.FileInfoModel")
//{
// if (e.Row.Cells["Company"].Value != null &&
// e.Row.Cells["Company"].Value.ToString().ToUpper() == "SUREKAM")
// {
// if (e.Row.Cells["ProductMajorPart"].Value != null
// && Convert.ToInt32(e.Row.Cells["ProductMajorPart"].Value) >= 4)
// {
// // Create an appearance that sets the ForeColor to blue.
// Infragistics.Win.Appearance evenAppearance = new Infragistics.Win.Appearance("Even");
// evenAppearance.ForeColor = Color.Blue;
// e.Row.Cells["ProductMajorPart"].Appearance = evenAppearance;
// }
// else
// {
// Infragistics.Win.Appearance oddAppearance = new Infragistics.Win.Appearance("Odd");
// oddAppearance.ForeColor = Color.Red;
// e.Row.Cells["ProductMajorPart"].Appearance = oddAppearance;
// }
// }
//}
}
void dgView_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{
//UltraGridLayout layout = e.Layout;
//UltraGridBand rootBand = layout.Bands[0];
//UltraGridColumn conditionGroupColumn = rootBand.Columns["ProductMajorPart"];
//ConditionValueAppearance conditionGroupConditionValueAppearance = this.CreateConditionGroupConditionValueAppearance(conditionGroupColumn);
//conditionGroupColumn.ValueBasedAppearance = conditionGroupConditionValueAppearance;
}
private ConditionValueAppearance CreateConditionGroupConditionValueAppearance(IFormulaProvider formulaProvider)
{
// This method will create a ConditionValueAppearance using ConditionGroups. ConditionGroups
// are conditions that group other conditions together. This is useful for combining multiple
// OperatorConditions, FormulaConditions, or ComplementConditions into one condition.
// For this example, we will use a ConditionGroup to make all value between -2 and +2
// show up with a green BackColor and a white ForeColor.
// Create a new ConditionValueAppearance
ConditionValueAppearance conditionValueAppearance = new ConditionValueAppearance();
// Create a ConditionGroup
ConditionGroup conditionGroup = new ConditionGroup();
// The ConditionGroup can contain any other type of condition, or even another
// ConditionGroup. Just to demonstrate this, we will use two different types of
// conditions.
// Create a OperatorCondition that checks for numbers that are greater than or
// equal to -2.
OperatorCondition operatorCondition = new OperatorCondition(ConditionOperator.GreaterThanOrEqualTo, -2);
// Create a FormulaCondition that checks for numbers that are less than or
// equal to 2.
// FormulaCondition formulaCondition = new FormulaCondition(formulaProvider, "[ConditionValue] == SUREKAM");
// Add the two conditions to the conditionGroup
conditionGroup.Add(operatorCondition);
// conditionGroup.Add(formulaCondition);
// We only want the color to apply to cells that meet both conditions. So we
// will set the Logical Operator to 'And'.
// conditionGroup.CombineOperator = LogicalOperator.And;
// Create an appearance that sets the ForeColor to green.
Infragistics.Win.Appearance greenAppearance = new Infragistics.Win.Appearance("Between -2 and +2");
greenAppearance.BackColor = Color.Green;
greenAppearance.ForeColor = Color.White;
// Now that we have the condition and appearance we need, add them to the
// conditionValueAppearance.
conditionValueAppearance.Add(conditionGroup, greenAppearance);
return conditionValueAppearance;
}
private void Config_Load()
{
try
{
_setCheckConfigModel = new SetCheckConfigModel();
_setCheckConfigModel.CheckRootDir = ConfigurationManager.AppSettings["CheckRootDir"];
_setCheckConfigModel.FilterDir = ConfigurationManager.AppSettings["FilterDir"];
_setCheckConfigModel.FilterExt = ConfigurationManager.AppSettings["FilterExt"];
_setCheckConfigModel.FilterFile = ConfigurationManager.AppSettings["FilterFile"];
_setCheckConfigModel.CheckAll = Boolean.Parse(ConfigurationManager.AppSettings["CheckAll"].ToString());
_setCheckConfigModel.OutputDir = ConfigurationManager.AppSettings["OutputDir"];
_setCheckConfigModel.OutputFile = ConfigurationManager.AppSettings["OutputFile"];
}
catch (ConfigurationException ex)
{
throw (ex);
}
}
private void btnGenerate_Click(object sender, EventArgs e)
{
if (dataList == null || dataList.Count <= 0)
{
MessageBox.Show("请先检测文件");
return;
}
CheckFolderFileBO bo = CheckFolderFileBO.Instance();
bo.SaveXml(dataList);
MessageBox.Show("生成成功!");
}
private void tbAbout_Click(object sender, EventArgs e)
{
using (FrmAbout frm = new FrmAbout())
{
frm.ShowDialog(this);
}
}
}
}