private void fillingFields(PartialReportSettingsDlgType eType) { if (reportData == null) { return; } List <PressureLossParameter> avaliableParams = new List <PressureLossParameter>(); if (eType == PartialReportSettingsDlgType.Segment) { avaliableParams = reportData.StraightSegFields; } else { avaliableParams = reportData.FittingFields; } UIHelperFunctions.fillingListBoxFields(avaliableParams, listBoxAvailableFields, listBoxReportFields); listBoxAvailableFields.Focus(); if (listBoxAvailableFields.Items.Count > 0) { listBoxAvailableFields.SetSelected(0, true); } }
private void Btn_Yes_Click(object sender, EventArgs e) { reportFormatName = textBox1.Text; //check if the name is valid if (reportFormatName.Length < 1) { UIHelperFunctions.postWarning(ReportResource.plrSettings, ReportResource.formatNameMsg); } else { //check if the name exists PressureLossReportDataManager reportDataMgr = PressureLossReportDataManager.Instance; PressureLossReportData reportData = reportDataMgr.getData(reportFormatName); if (reportData != null) //post task dialog { TaskDialog tdlg = new TaskDialog(ReportResource.plrSettings); tdlg.MainInstruction = ReportResource.formatNameDuplicateMsg; tdlg.AllowCancellation = true; tdlg.CommonButtons = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No; tdlg.DefaultButton = TaskDialogResult.No; tdlg.TitleAutoPrefix = false; // suppress the prefix of title. if (tdlg.Show() != TaskDialogResult.Yes) { textBox1.Focus(); return; } } DialogResult = DialogResult.OK; } }
private void doWork(object fileName) { try { System.Diagnostics.Process.Start(fileName.ToString()); } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); UIHelperFunctions.ShowMsgWarning(ReportResource.CanotOpen, ReportResource.warningTitle); } }
private void readSettingsDataFromDlg() { //current settings if (settings == null) { settings = new PressureLossReportData(); } settings.DisplayCriticalPath = checkBoxCriticalPath.Checked; settings.DisplayDetailInfoForStraightSeg = checkBoxSegmentInfo.Checked; settings.DisplayFittingLCSum = checkBoxFittingInfo.Checked; settings.DisplaySysInfo = checkBoxDisplaySystemInfo.Checked; settings.OpenAfterCreated = checkBoxOpenAfterCreated.Checked; UIHelperFunctions.getFieldsFromSelectedListBox(settings.AvailableFields, listBoxReportFields); }
private void buttonFormatDelete_Click(object sender, EventArgs e) { PressureLossReportDataManager reportDataMgr = PressureLossReportDataManager.Instance; PressureLossReportFormats allFormats = reportDataMgr.getAllFormats(); if (allFormats == null || allFormats.Count < 1 || this.comboBoxFormat.Items.Count < 1) { return; } if (allFormats.Count == 1 || (allFormats.Count == 2 && reportDataMgr.getLastUsedReportData() != null)) { UIHelperFunctions.postWarning(ReportResource.deleteFormatTitle, ReportResource.deleteLastFormatMsg, ReportResource.deleteLastFormatSubMsg); return; } TaskDialog tdlg = new TaskDialog(ReportResource.deleteFormatTitle); tdlg.MainInstruction = ReportResource.deleteFormatMsg; tdlg.AllowCancellation = true; tdlg.CommonButtons = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No; tdlg.DefaultButton = TaskDialogResult.No; tdlg.TitleAutoPrefix = false; // suppress the prefix of title. if (tdlg.Show() == TaskDialogResult.Yes) { // delete the report format, and update the combo list, set the next one as current string name = this.comboBoxFormat.SelectedItem.ToString(); if (name == reportDataMgr.getLastUsedReportName()) { PressureLossReportData lastData = reportDataMgr.getLastUsedReportData(); if (lastData != null) { reportDataMgr.remove(lastData.Name); } } reportDataMgr.remove(name); this.comboBoxFormat.Items.Remove(name); if (this.comboBoxFormat.Items.Count > 0) { this.comboBoxFormat.SelectedIndex = 0; } } }
private void fillSettingsControlsFromFormat(PressureLossReportData data) { if (data == null) { return; } checkBoxDisplaySystemInfo.Checked = data.DisplaySysInfo; checkBoxCriticalPath.Checked = data.DisplayCriticalPath; checkBoxFittingInfo.Checked = data.DisplayFittingLCSum; checkBoxSegmentInfo.Checked = data.DisplayDetailInfoForStraightSeg; checkBoxOpenAfterCreated.Checked = data.OpenAfterCreated; listBoxAvailableFields.Items.Clear(); listBoxReportFields.Items.Clear(); //fill in the fields UIHelperFunctions.fillingListBoxFields(data.AvailableFields, listBoxAvailableFields, listBoxReportFields); }
private void buttonOK_Click(object sender, EventArgs e) { if (reportData == null) { return; } List <PressureLossParameter> avaliableParams = null; if (eType == PartialReportSettingsDlgType.Segment) { avaliableParams = reportData.StraightSegFields; } else { avaliableParams = reportData.FittingFields; } UIHelperFunctions.getFieldsFromSelectedListBox(avaliableParams, listBoxReportFields); DialogResult = DialogResult.OK; }
private void listBoxReportFields_SelectedIndexChanged(object sender, EventArgs e) { UIHelperFunctions.updateUpDownButtonEnable(listBoxReportFields, buttonUp, buttonDown); }
private void listBoxReportFields_DoubleClick(object sender, EventArgs e) { UIHelperFunctions.addRemoveFields(listBoxReportFields, listBoxAvailableFields); }
private void buttonDown_Click(object sender, EventArgs e) { UIHelperFunctions.moveSelectedField(listBoxReportFields, false); }
public override bool save(string fileName, PressureLossReportData reportData) { HtmlStreamWriter writer = new HtmlStreamWriter(); try { // Check if the xslt file exists if (!File.Exists(writer.XsltFileName)) { string subMsg = ReportResource.xsltFileSubMsg .Replace("%FULLPATH%", writer.XsltFileName); UIHelperFunctions.postWarning( ReportResource.htmlGenerateTitle, ReportResource.xsltFileMsg, subMsg); return(false); } PressureLossReportHelper helper = PressureLossReportHelper.instance; if (helper == null) { return(false); } //xml head writer.WriteStartDocument(false); //root node string transXML = "UserPressureLossReport"; writer.WriteStartElement(transXML); //title writer.WriteElementString("Title", ReportResource.reportName); //domain if (helper.Domain == ReportResource.pipeDomain) { writer.WriteElementString("DomainName", ReportResource.pipeReportName); } else { writer.WriteElementString("DomainName", ReportResource.ductReportName); } //write project info ReportProjectInfo proInfo = new ReportProjectInfo(); proInfo.writeToHTML(writer); //each system List <MEPSystem> systems = helper.getSortedSystems(); if (systems == null || systems.Count < 1) { return(false); } foreach (MEPSystem sysElem in systems) { if (sysElem == null) { continue; } //system node string xmlString = "System"; writer.WriteStartElement(xmlString); //system info: name and info MEPSystemInfo systemInfo = new MEPSystemInfo(sysElem); systemInfo.writeToHTML(writer); //critical path if (helper.ReportData.DisplayCriticalPath) { string criticalInfo = ReportResource.criticalPath + " : " + MEPSystemInfo.getCriticalPath(sysElem); criticalInfo += " ; " + ReportResource.totalPressureLoss + " : " + MEPSystemInfo.getCriticalPathPressureLoss(sysElem); writer.WriteElementString("CriticalPath", criticalInfo); } List <MEPSection> sections = new List <MEPSection>(); MEPSystemInfo.getSectionsFromSystem(sysElem, sections); //sections: title and info SectionsInfo sectionInfo = new SectionsInfo(sections); sectionInfo.writeToHTML(writer); //segments: title and info SegmentsInfo segmentsInfo = new SegmentsInfo(sections); segmentsInfo.writeToHTML(writer); //fittings: title and info FittingsInfo fittingsInfo = new FittingsInfo(sections); fittingsInfo.writeToHTML(writer); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Save(fileName); return(true); } catch { writer.Close(); //delete xml File.Delete(writer.XmlFileName); UIHelperFunctions.postWarning(ReportResource.htmlGenerateTitle, ReportResource.htmlMsg); return(false); } }
// TODO public override bool save(string fileName, PressureLossReportData reportData) { try { PressureLossReportHelper helper = PressureLossReportHelper.instance; CsvStreamWriter writer = new CsvStreamWriter(); //title string strTitle = ReportResource.reportName; if (helper.Domain == ReportResource.pipeDomain) { strTitle = ReportResource.pipeReportName; } else { strTitle = ReportResource.ductReportName; } DataTable titleTB = new DataTable(); titleTB.Columns.Add(); titleTB.Rows.Add(strTitle); writer.AddData(titleTB, 1); writer.addOneEmptyRow(); DataTable tbTitle = new DataTable(); DataTable tb = new DataTable(); //Project info ReportProjectInfo proInfo = new ReportProjectInfo(); proInfo.writeToCsv(writer); writer.addOneEmptyRow(); //each system List <MEPSystem> systems = helper.getSortedSystems(); if (systems == null || systems.Count < 1) { return(false); } foreach (MEPSystem sysElem in systems) { if (sysElem == null) { continue; } //system name and info MEPSystemInfo systemInfo = new MEPSystemInfo(sysElem); systemInfo.writeToCsv(writer); if (systemInfo.needToWrite()) { writer.addOneEmptyRow(); } List <MEPSection> sections = new List <MEPSection>(); MEPSystemInfo.getSectionsFromSystem(sysElem, sections); //sections: title and info SectionsInfo sectionInfo = new SectionsInfo(sections); sectionInfo.writeToCsv(writer); if (reportData.DisplayCriticalPath) { string criticalInfo = ReportResource.criticalPath + " : " + MEPSystemInfo.getCriticalPath(sysElem); criticalInfo += " ; " + ReportResource.totalPressureLoss + " : " + MEPSystemInfo.getCriticalPathPressureLoss(sysElem); writer.addTitleRow(criticalInfo); } writer.addOneEmptyRow(); //segments: title and info SegmentsInfo segmentsInfo = new SegmentsInfo(sections); segmentsInfo.writeToCsv(writer); if (segmentsInfo.needToWrite()) { writer.addOneEmptyRow(); } //fittings: title and info FittingsInfo fittingsInfo = new FittingsInfo(sections); fittingsInfo.writeToCsv(writer); if (fittingsInfo.needToWrite()) { writer.addOneEmptyRow(); } } writer.Save(fileName); return(true); } catch (Exception e) { if (e.Message == ReportConstants.failed_to_delete) { string subMsg = ReportResource.csvSubMsg.Replace("%FULLPATH%", fileName); UIHelperFunctions.postWarning(ReportResource.csvGenerateTitle, ReportResource.csvMsg, subMsg); } else { UIHelperFunctions.postWarning(ReportResource.csvGenerateTitle, ReportResource.csvMsg); } return(false); } }