/// <summary> /// Chooses a new raster file /// </summary> /// <remarks> /// Just store the filename. For now, no path required. In the future may want to support absolute path, differentiated by x:\\ /// </remarks> private void ChooseRasterFile(int rowIndex, int colIndex) { string FileName = RasterUtilities.ChooseRasterFileName("Initial Conditions Raster File", this); if (FileName == null) { return; } Application.DoEvents(); using (HourGlass h = new HourGlass()) { try { StochasticTimeRaster rast = new StochasticTimeRaster(FileName, RasterDataType.DTInteger); if (colIndex == PRIMARY_STRATUM_FILE_NAME_COLUMN_INDEX && rast.Projection == null) { const string msg = "There is no projection associated with this raster file. The model will still run but outputs will also have no projection."; FormsUtilities.InformationMessageBox(msg); } SetICSpatialFile(rowIndex, colIndex, FileName); } catch (Exception e) { FormsUtilities.ErrorMessageBox(e.Message); return; } } }
internal void InternalExport(string location, ExportType exportType, bool showMessage) { string AmountLabel = null; TerminologyUnit TermUnit = 0; DataSheet dsterm = this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME); ExportColumnCollection columns = this.CreateColumnCollection(); TerminologyUtilities.GetAmountLabelTerminology(dsterm, ref AmountLabel, ref TermUnit); string WorksheetName = string.Format(CultureInfo.InvariantCulture, "{0} by Transition and State", AmountLabel); if (exportType == ExportType.ExcelFile) { this.ExcelExport(location, columns, this.CreateReportQuery(false), WorksheetName); } else { columns.Remove("ScenarioName"); this.CSVExport(location, columns, this.CreateReportQuery(true)); if (showMessage) { FormsUtilities.InformationMessageBox("Data saved to '{0}'.", location); } } }
private bool ConfirmPasteOverwrite(TransitionDiagramClipData cd) { bool OverwriteRequired = false; foreach (TransitionDiagramClipDataEntry Entry in cd.Entries) { if (this.m_ExplicitClasses.ContainsKey(Entry.ShapeData.StateClassIdSource)) { OverwriteRequired = true; break; } else if (this.m_WildcardClasses.ContainsKey(Entry.ShapeData.StateClassIdSource)) { if (!this.m_StratumId.HasValue) { OverwriteRequired = true; break; } } } if (OverwriteRequired) { if (FormsUtilities.ApplicationMessageBox(MessageStrings.CONFIRM_DIAGRAM_PASTE_OVERWRITE, MessageBoxButtons.YesNo) != DialogResult.Yes) { return(false); } } return(true); }
private void ButtonOK_Click(object sender, System.EventArgs e) { this.m_ChosenStateLabelX = (BaseValueDisplayListItem)this.ComboBoxStateLabelX.Items[this.ComboBoxStateLabelX.SelectedIndex]; this.m_ChosenStateLabelY = (BaseValueDisplayListItem)this.ComboBoxStateLabelY.Items[this.ComboBoxStateLabelY.SelectedIndex]; if (this.StateClassInDiagram(this.m_ChosenStateLabelX.Value, this.m_ChosenStateLabelY.Value)) { FormsUtilities.ErrorMessageBox(MessageStrings.ERROR_DIAGRAM_STATE_CLASS_EXISTS); return; } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
internal void InternalExport(string location, ExportType exportType, bool showMessage) { if (exportType == ExportType.ExcelFile) { this.CreateExcelReport(location); } else { this.CreateCSVReport(location); if (showMessage) { FormsUtilities.InformationMessageBox("Data saved to '{0}'.", location); } } }
private void InternalAddStateClass() { ChooseStateClassForm dlg = new ChooseStateClassForm(); if (!dlg.Initialize(this, this.m_DataFeed, false)) { return; } if (dlg.ShowDialog(this) != DialogResult.OK) { return; } string Location = this.GetNextStateClassLocation(); if (Location == null) { FormsUtilities.ErrorMessageBox(MessageStrings.ERROR_DIAGRAM_NO_MORE_LOCATIONS); return; } int StateClassId = this.GetStateClassId(dlg.ChosenStateLabelX.Value, dlg.ChosenStateLabelY.Value); if (StateClassId == -1) { StateClassId = this.InternalCreateNewStateClass(dlg.ChosenStateLabelX, dlg.ChosenStateLabelY); } this.m_DTDataSheet.BeginAddRows(); DataRow dr = this.m_DTDataSheet.GetData().NewRow(); dr[Strings.DATASHEET_DT_STRATUMIDSOURCE_COLUMN_NAME] = DataTableUtilities.GetNullableDatabaseValue(this.m_StratumId); dr[Strings.DATASHEET_DT_STATECLASSIDSOURCE_COLUMN_NAME] = StateClassId; dr[Strings.DATASHEET_DT_STRATUMIDDEST_COLUMN_NAME] = DBNull.Value; dr[Strings.DATASHEET_DT_STATECLASSIDDEST_COLUMN_NAME] = DBNull.Value; dr[Strings.DATASHEET_AGE_MIN_COLUMN_NAME] = DBNull.Value; dr[Strings.DATASHEET_AGE_MAX_COLUMN_NAME] = DBNull.Value; dr[Strings.DATASHEET_DT_LOCATION_COLUMN_NAME] = Location; this.m_DTDataSheet.GetData().Rows.Add(dr); this.m_DTDataSheet.EndAddRows(); this.RefreshDiagram(); this.SelectStateClass(StateClassId); }
internal void InternalExport(string location, ExportType exportType, bool showMessage) { ExportColumnCollection columns = this.CreateColumnCollection(); if (exportType == ExportType.ExcelFile) { this.ExcelExport(location, columns, this.CreateReportQuery(false), "Transition Based Attributes"); } else { columns.Remove("ScenarioName"); this.CSVExport(location, columns, this.CreateReportQuery(true)); if (showMessage) { FormsUtilities.InformationMessageBox("Data saved to '{0}'.", location); } } }
public bool Initialize(TransitionDiagram diagram, DataFeed dataFeed, bool editMode) { this.m_Diagram = diagram; this.m_TerminologyDataSheet = dataFeed.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME); this.m_StateLabelXDataSheet = dataFeed.Project.GetDataSheet(Strings.DATASHEET_STATE_LABEL_X_NAME); this.m_StateLabelYDataSheet = dataFeed.Project.GetDataSheet(Strings.DATASHEET_STATE_LABEL_Y_NAME); this.FillComboBoxes(); if (this.ComboBoxStateLabelX.Items.Count == 0) { FormsUtilities.ErrorMessageBox(MessageStrings.ERROR_DIAGRAM_NO_STATE_LABEL_X_VALUES); return(false); } else if (this.ComboBoxStateLabelY.Items.Count == 0) { FormsUtilities.ErrorMessageBox(MessageStrings.ERROR_DIAGRAM_NO_STATE_LABEL_Y_VALUES); return(false); } this.ResetSlxAndSlyLabels(); this.m_EditMode = editMode; if (this.m_EditMode) { this.Text = "Edit State Class"; StateClassShape EditShape = (StateClassShape)diagram.SelectedShapes.First(); this.SelectComboValues(EditShape.StateLabelXId, EditShape.StateLabelYId); } else { this.Text = "Add State Class"; } return(true); }
private static bool ValidatePTClipData(ProbabilisticTransitionClipData pt, DataSheet stratumSheet, DataSheet stateClassSheet, DataSheet transitionTypeSheet) { Debug.Assert(stratumSheet.Name == Strings.DATASHEET_STRATA_NAME); Debug.Assert(stateClassSheet.Name == Strings.DATASHEET_STATECLASS_NAME); Debug.Assert(transitionTypeSheet.Name == Strings.DATASHEET_TRANSITION_TYPE_NAME); if (pt.StratumSource != null) { if (!stratumSheet.ValidationTable.ContainsValue(pt.StratumSource)) { FormsUtilities.ErrorMessageBox("The stratum '{0}' does not exist in this project.", pt.StratumSource); return(false); } } if (!stateClassSheet.ValidationTable.ContainsValue(pt.StateClassSource)) { FormsUtilities.ErrorMessageBox("The state class '{0}' does not exist in this project.", pt.StateClassSource); return(false); } if (pt.StratumDest != null) { if (!stratumSheet.ValidationTable.ContainsValue(pt.StratumDest)) { FormsUtilities.ErrorMessageBox("The stratum '{0}' does not exist in this project.", pt.StratumDest); return(false); } } if (pt.StateClassDest != null) { if (!stateClassSheet.ValidationTable.ContainsValue(pt.StateClassDest)) { FormsUtilities.ErrorMessageBox("The state class '{0}' does not exist in this project.", pt.StateClassDest); return(false); } } if (!transitionTypeSheet.ValidationTable.ContainsValue(pt.TransitionType)) { FormsUtilities.ErrorMessageBox("The transition type '{0}' does not exist in this project.", pt.TransitionType); return(false); } if (pt.StratumSource != null) { pt.StratumIdSource = stratumSheet.ValidationTable.GetValue(pt.StratumSource); } pt.StateClassIdSource = stateClassSheet.ValidationTable.GetValue(pt.StateClassSource); if (pt.StratumDest != null) { pt.StratumIdDest = stratumSheet.ValidationTable.GetValue(pt.StratumDest); } if (pt.StateClassDest != null) { pt.StateClassIdDest = stateClassSheet.ValidationTable.GetValue(pt.StateClassDest); } pt.TransitionTypeId = transitionTypeSheet.ValidationTable.GetValue(pt.TransitionType); #if DEBUG if (pt.StratumIdSource.HasValue) { Debug.Assert(pt.StratumIdSource.Value > 0); } Debug.Assert(pt.StateClassIdSource > 0); if (pt.StratumDest != null) { Debug.Assert(pt.StratumIdDest.Value > 0); } if (pt.StateClassDest != null) { Debug.Assert(pt.StateClassIdDest.Value > 0); } Debug.Assert(pt.TransitionTypeId > 0); #endif return(true); }
private static bool ValidateDTClipData(DeterministicTransitionClipData dt, DataSheet stratumSheet, DataSheet stateClassSheet) { Debug.Assert(stratumSheet.Name == Strings.DATASHEET_STRATA_NAME); Debug.Assert(stateClassSheet.Name == Strings.DATASHEET_STATECLASS_NAME); if (dt.StratumSource != null) { if (!stratumSheet.ValidationTable.ContainsValue(dt.StratumSource)) { FormsUtilities.ErrorMessageBox("The stratum '{0}' does not exist in this project.", dt.StratumSource); return(false); } } if (!stateClassSheet.ValidationTable.ContainsValue(dt.StateClassSource)) { FormsUtilities.ErrorMessageBox("The state class '{0}' does not exist in this project.", dt.StateClassSource); return(false); } if (dt.StratumDest != null) { if (!stratumSheet.ValidationTable.ContainsValue(dt.StratumDest)) { FormsUtilities.ErrorMessageBox("The stratum '{0}' does not exist in this project.", dt.StratumDest); return(false); } } if (dt.StateClassDest != null) { if (!stateClassSheet.ValidationTable.ContainsValue(dt.StateClassDest)) { FormsUtilities.ErrorMessageBox("The state class '{0}' does not exist in this project.", dt.StateClassDest); return(false); } } if (dt.StratumSource != null) { dt.StratumIdSource = stratumSheet.ValidationTable.GetValue(dt.StratumSource); } dt.StateClassIdSource = stateClassSheet.ValidationTable.GetValue(dt.StateClassSource); if (dt.StratumDest != null) { dt.StratumIdDest = stratumSheet.ValidationTable.GetValue(dt.StratumDest); } if (dt.StateClassDest != null) { dt.StateClassIdDest = stateClassSheet.ValidationTable.GetValue(dt.StateClassDest); } #if DEBUG if (dt.StratumIdSource.HasValue) { Debug.Assert(dt.StratumIdSource.Value > 0); } Debug.Assert(dt.StateClassIdSource > 0); if (dt.StratumDest != null) { Debug.Assert(dt.StratumIdDest.Value > 0); } if (dt.StateClassDest != null) { Debug.Assert(dt.StateClassIdDest.Value > 0); } #endif return(true); }
private void InternalPasteSpecial(bool pasteAll, bool pasteBetween, bool pasteNone, bool pasteDeterministic, bool pasteProbabilistic, bool isTargeted) { //Get the clipboard data and verify that all items can be pasted. Note that //once it has been validated it will contain the correct Ids for those items. TransitionDiagramClipData cd = (TransitionDiagramClipData)Clipboard.GetData(Strings.CLIPBOARD_FORMAT_TRANSITION_DIAGRAM); DataSheet StratumSheet = this.m_DataFeed.Project.GetDataSheet(Strings.DATASHEET_STRATA_NAME); DataSheet StateClassSheet = this.m_DataFeed.Project.GetDataSheet(Strings.DATASHEET_STATECLASS_NAME); DataSheet TransitionTypeSheet = this.m_DataFeed.Project.GetDataSheet(Strings.DATASHEET_TRANSITION_TYPE_NAME); if (!ValidateClipData(cd, StratumSheet, StateClassSheet, TransitionTypeSheet)) { return; } //Make sure the user is Ok with overwriting any existing data if (!this.ConfirmPasteOverwrite(cd)) { return; } //Get the paste location deltas for the current paste shapes int dx = 0; int dy = 0; if (!this.GetPasteLocationDeltas(ref dx, ref dy, isTargeted)) { if (isTargeted) { FormsUtilities.ErrorMessageBox(MessageStrings.ERROR_DIAGRAM_CANNOT_PASTE_SPECIFIC_LOCATION); } else { FormsUtilities.ErrorMessageBox(MessageStrings.ERROR_DIAGRAM_CANNOT_PASTE_ANY_LOCATION); } return; } //Paste all state classes and transitions this.m_DTDataSheet.BeginAddRows(); this.m_PTDataSheet.BeginAddRows(); DTAnalyzer Analyzer = new DTAnalyzer(this.m_DTDataSheet.GetData(), this.m_DataFeed.Project); this.InternalPasteStateClasses(cd, dx, dy, pasteNone, Analyzer); this.PasteTransitions(cd, pasteAll, pasteBetween, pasteDeterministic, pasteProbabilistic, Analyzer); this.m_DTDataSheet.EndAddRows(); this.m_PTDataSheet.EndAddRows(); this.DeselectAllShapes(); foreach (TransitionDiagramClipDataEntry Entry in cd.Entries) { if (this.m_ExplicitClasses.ContainsKey(Entry.ShapeData.StateClassIdSource)) { this.SelectShape(this.m_ExplicitClasses[Entry.ShapeData.StateClassIdSource]); } else if (this.m_WildcardClasses.ContainsKey(Entry.ShapeData.StateClassIdSource)) { this.SelectShape(this.m_WildcardClasses[Entry.ShapeData.StateClassIdSource]); } } this.Focus(); }