private void InitHeigthWidth(int width, int height, int bandcount, ref DataSetMosaicInfo dsi) { txtHeight.Text = height == -1 ? "" : height.ToString(); txtWidth.Text = width == -1 ? "" : width.ToString(); dsi.Height = height; dsi.Width = width; dsi.BandCount = bandcount; }
private bool CheckEnv() { _currMosaicInfos = new MosaicInfos(); _currMosaicInfos.Project = lbProject.Text; _currMosaicInfos.ProjectArgs = lbProjectAgrs.Text; _currMosaicInfos.ProjectAttrName = cbProject.Text; _currMosaicInfos.ProjectArgsAttrName = cbProjectAgrs.Text; if (!string.IsNullOrEmpty(lbProject.Text) && lbProject.Text.IndexOf("GLL") == -1 && string.IsNullOrEmpty(lbProjectAgrs.Text)) { MessageBox.Show("未设定投影参数!"); return(false); } if (string.IsNullOrEmpty(lbLeftUpPoint.Text) || string.IsNullOrEmpty(lbRightDownPoint.Text)) { MessageBox.Show("四角坐标未设定完整!"); return(false); } else { _currMosaicInfos.LeftUpAttrName = cbLeftUpPoint.Text; _currMosaicInfos.RightDownAttrName = cbRightDownPoint.Text; } if (lstDataSets.CheckedItems.Count == 0) { MessageBox.Show("未选择任何拼接数据集!"); return(false); } if (string.IsNullOrEmpty(txtFileDir.Text) && !Directory.Exists(txtFileDir.Text) && string.IsNullOrEmpty(txtOutDir.Text) && !Directory.Exists(txtOutDir.Text)) { MessageBox.Show("请设置输出路径或路径不存在!"); return(false); } List <DataSetMosaicInfo> mosaicInfoList = new List <DataSetMosaicInfo>(); _currMosaicDatasets = new Dictionary <string, H5T.H5Type>(); foreach (ListViewItem item in lstDataSets.CheckedItems) { if (item.Tag == null) { MessageBox.Show("数据集[" + item + "]未定义行列等信息!"); return(false); } DataSetMosaicInfo dmi = item.Tag as DataSetMosaicInfo; if (dmi != null) { mosaicInfoList.Add(dmi); _currMosaicDatasets.Add(dmi.DataSetName, Utility.GetH5Type(dmi.HDF4DataType)); } } _currMosaicInfos.DataSetMosaicInfos = mosaicInfoList.Count == 0 ? null : mosaicInfoList.ToArray(); return(true); }
private void lstDataSets_SelectedIndexChanged(object sender, EventArgs e) { ClearDataSetCombox(); if (lstDataSets.SelectedItems.Count == 0 || lstDataSets.SelectedItems[0].Tag == null || lstFileInfoList.SelectedItems.Count == 0 || (lstFileInfoList.SelectedItems[0]).Tag == null) { return; } FileListItem fli = (lstFileInfoList.SelectedItems[0]).Tag as FileListItem; DataSetMosaicInfo dsi = lstDataSets.SelectedItems[0].Tag as DataSetMosaicInfo; if (fli == null) { return; } if (HDF4Helper.IsHdf4(fli.FileName)) { Hdf4Operator oper = new Hdf4Operator(fli.FileName); try { Dictionary <string, string> datasetAtrr = new Dictionary <string, string>(); if (oper != null) { datasetAtrr = oper.GetAttributes(dsi.DataSetName); if (datasetAtrr != null) { InitDataSetAttr(datasetAtrr, ref dsi); } Size size = Size.Empty; int bandCount = 0; Type datatype; int datatypeSize = 0; HDF4Helper.DataTypeDefinitions hdf4DataType = HDF4Helper.DataTypeDefinitions.DFNT_NUINT16; if (GetDataSetSize(dsi.DataSetName, oper, out size, out bandCount, out hdf4DataType, out datatype, out datatypeSize)) { InitHeigthWidth(size.Width, size.Height, bandCount, ref dsi); if (dsi != null) { dsi.HDF4DataType = hdf4DataType; } } } } finally { if (oper != null) { oper.Dispose(); } } } }
private void InitDataSetAttr(Dictionary <string, string> datasetAtrr, ref DataSetMosaicInfo dsi) { gbDataSetAttr.Enabled = true; string[] dataSetAttrs = GetAttrStr(datasetAtrr); if (dataSetAttrs == null) { return; } gbFileAttr.Tag = datasetAtrr; ClearDataSetCombox(); cbBandName.Items.AddRange(dataSetAttrs); SetAttr(datasetAtrr, _bandNames, cbBandName, lbBandName); if (!string.IsNullOrEmpty(lbBandName.Text)) { dsi.BandNames = lbBandName.Text; } cbValidRegion.Items.AddRange(dataSetAttrs); SetAttr(datasetAtrr, _validRegionNames, cbValidRegion, lbValidRegion); if (!string.IsNullOrEmpty(lbValidRegion.Text)) { string[] splitMinMax = lbValidRegion.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); dsi.MinValue = float.Parse(splitMinMax[0]); dsi.MaxValue = float.Parse(splitMinMax[1]); } cbScaleValue.Items.AddRange(dataSetAttrs); SetAttr(datasetAtrr, _sacleNames, cbScaleValue, lbScaleValue); if (!string.IsNullOrEmpty(lbScaleValue.Text)) { dsi.Scale = float.Parse(lbScaleValue.Text); } cbOffsetValue.Items.AddRange(dataSetAttrs); SetAttr(datasetAtrr, _offsetNames, cbOffsetValue, lbOffsetValue); if (!string.IsNullOrEmpty(lbOffsetValue.Text)) { dsi.Offset = float.Parse(lbOffsetValue.Text); } }