private void CreateOutgoingDTOffStratumCues(StateClassShape shape, DTAnalyzer analyzer) { //If there is no destination state class then it is a transition-to-self if (!shape.StateClassIdDest.HasValue) { return; } int?StratumIdActual = null; analyzer.ResolveStateClassStratum(shape.StratumIdSource, shape.StratumIdDest, shape.StateClassIdDest.Value, ref StratumIdActual); //If the class was found in the current stratum then it is not an off-stratum transition if (NullableUtilities.NullableIdsEqual(StratumIdActual, this.m_StratumId)) { return; } //If the class was found in the wild card stratum then it is not an off-stratum transition if (!StratumIdActual.HasValue) { return; } this.AddLine(CreateOutgoingDTOffStratumCue(shape)); }
private DataTable GetDataTableForIncomingDT(StateClassShape shape, Dictionary <int, DataTable> seenBefore) { int Key = shape.StratumIdSource.HasValue ? shape.StratumIdSource.Value : 0; if (!seenBefore.ContainsKey(Key)) { string Query = null; if (shape.StratumIdSource.HasValue) { Query = string.Format(CultureInfo.InvariantCulture, "((StratumIDDest={0}) OR (StratumIDDest IS NULL AND StratumIDSource={0}))", shape.StratumIdSource.Value); } else { Query = "StratumIDSource IS NULL"; } DataTable Source = this.m_DTDataSheet.GetData(); DataTable Target = Source.Clone(); DataRow[] Rows = Source.Select(Query, null); Rows.CopyToDataTable(Target, LoadOption.OverwriteChanges); seenBefore.Add(Key, Target); } return(seenBefore[Key]); }
private void RecordStateClassLocation(StateClassShape shape, DTAnalyzer analyzer) { Debug.Assert(this.WorkspaceRectangle.Contains(shape.Bounds)); DataRow row = analyzer.GetStateClassRow(this.m_StratumId, shape.StateClassIdSource); row[Strings.DATASHEET_DT_LOCATION_COLUMN_NAME] = RowColToLocation(shape.Row, shape.Column); }
private void InternalSelectStateClass(int stateClassId) { if (this.m_ExplicitClasses.ContainsKey(stateClassId)) { StateClassShape Shape = this.m_ExplicitClasses[stateClassId]; this.SelectShape(Shape); } }
private void CreateIncomingPTOffStratumCues(StateClassShape shape) { foreach (Transition t in shape.IncomingPT) { if (!NullableUtilities.NullableIdsEqual(t.StratumIdSource, shape.StratumIdSource)) { this.AddLine(this.CreateIncomingPTOffStratumCue(shape, t)); } } }
private void CreateOutgoingDTLines(StateClassShape fromShape, DTAnalyzer analyzer) { //If there is no destination state class then it is a transition-to-self if (!fromShape.StateClassIdDest.HasValue) { return; } StateClassShape ToShape = null; int? StratumIdActual = null; analyzer.ResolveStateClassStratum(fromShape.StratumIdSource, fromShape.StratumIdDest, fromShape.StateClassIdDest.Value, ref StratumIdActual); if (NullableUtilities.NullableIdsEqual(StratumIdActual, this.m_StratumId)) { //If the class was found in the current stratum then it will be in the //explicit lookups if the current stratum is explicit and the wildcard //lookups if it is not. if (this.m_StratumId.HasValue) { ToShape = this.m_ExplicitClasses[fromShape.StateClassIdDest.Value]; } else { ToShape = this.m_WildcardClasses[fromShape.StateClassIdDest.Value]; } } else { //If the class was not found in the current stratum it will be in the //wild card lookups if its stratum is wild. if (this.m_StratumId.HasValue && (!StratumIdActual.HasValue)) { ToShape = this.m_WildcardClasses[fromShape.StateClassIdDest.Value]; } } //If the class was not found or it is a transition-to-self then it is an //off stratum transition. Otherwise, add an outgoing line. if ((ToShape != null) && (ToShape != fromShape)) { DeterministicTransitionLine Line = new DeterministicTransitionLine(Constants.DETERMINISTIC_TRANSITION_LINE_COLOR); this.FillLineSegments(fromShape, ToShape, Line, BoxArrowDiagramConnectorMode.Horizontal); this.AddLine(Line); fromShape.OutgoingDTLines.Add(Line); ToShape.IncomingDTLines.Add(Line); } }
private static DeterministicTransitionLine CreateIncomingDTOffStratumCue(StateClassShape shape) { int X1 = shape.Bounds.X - Constants.TRANSITION_DIAGRAM_OFF_STRATUM_CUE_SIZE; int Y1 = shape.Bounds.Y + shape.Bounds.Height + Constants.TRANSITION_DIAGRAM_OFF_STRATUM_CUE_SIZE; int X2 = shape.Bounds.X; int Y2 = shape.Bounds.Y + shape.Bounds.Height; DeterministicTransitionLine Line = new DeterministicTransitionLine(Constants.DETERMINISTIC_TRANSITION_LINE_COLOR); Line.AddLineSegment(X1, Y1, X2, Y2); Line.AddArrowSegments(X2, Y2, BoxArrowDiagramArrowDirection.Northeast); return(Line); }
private void CreateIncomingDTOffStratumCues(StateClassShape shape) { foreach (DeterministicTransition t in shape.IncomingDT) { if (!NullableUtilities.NullableIdsEqual(t.StratumIdSource, shape.StratumIdSource)) { if (t.StratumIdSource.HasValue) { DeterministicTransitionLine l = CreateIncomingDTOffStratumCue(shape); this.AddLine(l); } } } }
private static ProbabilisticTransitionLine CreatePTLineToSelf(StateClassShape shape, int transitionTypeId) { ProbabilisticTransitionLine Line = new ProbabilisticTransitionLine( transitionTypeId, Constants.PROBABILISTIC_TRANSITION_LINE_COLOR); const int PT_CIRCLE_RADIUS = 10; int lrx = shape.Bounds.X + shape.Bounds.Width - PT_CIRCLE_RADIUS; int lry = shape.Bounds.Y + shape.Bounds.Height - PT_CIRCLE_RADIUS; Rectangle rc = new Rectangle(lrx, lry, 2 * PT_CIRCLE_RADIUS, 2 * PT_CIRCLE_RADIUS); Line.AddEllipse(rc); return(Line); }
private void FillIncomingDT(StateClassShape shape, Dictionary <int, DataTable> seenBefore) { string Query = string.Format(CultureInfo.InvariantCulture, "StateClassIDDest={0}", shape.StateClassIdSource); DataTable dt = this.GetDataTableForIncomingDT(shape, seenBefore); DataRow[] rows = dt.Select(Query, null); foreach (DataRow dr in rows) { shape.IncomingDT.Add(CreateDT(dr)); } }
private ProbabilisticTransitionLine CreateIncomingPTOffStratumCue(StateClassShape shape, Transition t) { int X1 = shape.Bounds.X - Constants.TRANSITION_DIAGRAM_OFF_STRATUM_CUE_SIZE; int Y1 = shape.Bounds.Y - Constants.TRANSITION_DIAGRAM_OFF_STRATUM_CUE_SIZE; int X2 = shape.Bounds.X; int Y2 = shape.Bounds.Y; ProbabilisticTransitionLine Line = new ProbabilisticTransitionLine( t.TransitionTypeId, Constants.PROBABILISTIC_TRANSITION_LINE_COLOR); this.FillPTLineTransitionGroups(Line); Line.AddLineSegment(X1, Y1, X2, Y2); Line.AddArrowSegments(X2, Y2, BoxArrowDiagramArrowDirection.Southeast); return(Line); }
private void FillIncomingPT(StateClassShape shape, Dictionary <int, DataTable> seenBefore) { string Query = string.Format(CultureInfo.InvariantCulture, "StateClassIDDest={0}", shape.StateClassIdSource); DataTable dt = this.GetDataTableForIncomingPT(shape, seenBefore); DataRow[] rows = dt.Select(Query, null); foreach (DataRow dr in rows) { Debug.Assert(Convert.ToInt32(dr[Strings.DATASHEET_PT_STATECLASSIDDEST_COLUMN_NAME], CultureInfo.InvariantCulture) == shape.StateClassIdSource); Transition pt = CreatePT(dr); shape.IncomingPT.Add(pt); } }
private void InternalEditStateClass() { Debug.Assert(this.SelectedShapes.Count() == 1); ChooseStateClassForm dlg = new ChooseStateClassForm(); dlg.Initialize(this, this.m_DataFeed, true); if (dlg.ShowDialog(this) != DialogResult.OK) { return; } StateClassShape EditShape = (StateClassShape)this.SelectedShapes.First(); int OldStateClassId = this.GetStateClassId(EditShape.StateLabelXId, EditShape.StateLabelYId); int NewStateClassId = this.GetStateClassId(dlg.ChosenStateLabelX.Value, dlg.ChosenStateLabelY.Value); if (OldStateClassId == NewStateClassId) { return; } if (NewStateClassId == -1) { NewStateClassId = this.InternalCreateNewStateClass(dlg.ChosenStateLabelX, dlg.ChosenStateLabelY); } this.m_DTDataSheet.BeginModifyRows(); this.m_PTDataSheet.BeginModifyRows(); InternalChangeStateClassId(this.m_DTDataSheet, Strings.DATASHEET_DT_STRATUMIDSOURCE_COLUMN_NAME, Strings.DATASHEET_DT_STATECLASSIDSOURCE_COLUMN_NAME, Strings.DATASHEET_DT_STRATUMIDDEST_COLUMN_NAME, Strings.DATASHEET_DT_STATECLASSIDDEST_COLUMN_NAME, OldStateClassId, NewStateClassId, this.m_StratumId); InternalChangeStateClassId(this.m_PTDataSheet, Strings.DATASHEET_PT_STRATUMIDSOURCE_COLUMN_NAME, Strings.DATASHEET_PT_STATECLASSIDSOURCE_COLUMN_NAME, Strings.DATASHEET_PT_STRATUMIDDEST_COLUMN_NAME, Strings.DATASHEET_PT_STATECLASSIDDEST_COLUMN_NAME, OldStateClassId, NewStateClassId, this.m_StratumId); this.m_DTDataSheet.EndModifyRows(); this.m_PTDataSheet.EndModifyRows(); this.RefreshDiagram(); this.SelectStateClass(NewStateClassId); }
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 void CreateOutgoingPTOffStratumCues(StateClassShape shape, DTAnalyzer analyzer) { foreach (Transition t in shape.OutgoingPT) { //If it is a transition-to-self then it is not an off-stratum transition if (!t.StateClassIdDestination.HasValue) { continue; } int?StratumIdActual = null; analyzer.ResolveStateClassStratum( t.StratumIdSource, t.StratumIdDestination, t.StateClassIdDestination.Value, ref StratumIdActual); //If the class was found in the current stratum then it is not an off-stratum transition if (NullableUtilities.NullableIdsEqual(StratumIdActual, this.m_StratumId)) { continue; } //If the class was found in the wild card stratum then it is not an off-stratum transition if (!StratumIdActual.HasValue) { continue; } this.AddLine(this.CreateOutgoingPTOffStratumCue(shape, t)); } }
private List <StateClassShape> InternalGetStateClassShapes() { List <StateClassShape> lst = new List <StateClassShape>(); DataRow[] rows = this.GetDTRows(); foreach (DataRow dr in rows) { int ShapeRow = -1; int ShapeColumn = -1; string Location = Convert.ToString(dr[Strings.DATASHEET_DT_LOCATION_COLUMN_NAME], CultureInfo.InvariantCulture); LocationToRowCol(Location, ref ShapeRow, ref ShapeColumn); int?StratumIdSource = null; int StateClassIdSource = Convert.ToInt32(dr[Strings.DATASHEET_DT_STATECLASSIDSOURCE_COLUMN_NAME], CultureInfo.InvariantCulture); int?StratumIdDestination = null; int?StateClassIdDestination = null; int?MinimumAge = null; int?MaximumAge = null; int StateLabelXId = Convert.ToInt32(DataTableUtilities.GetTableValue(this.m_SCDataSheet.GetData(), this.m_SCDataSheet.ValueMember, StateClassIdSource, Strings.DATASHEET_STATECLASS_STATE_LABEL_X_ID_COLUMN_NAME), CultureInfo.InvariantCulture); string StateLabelXName = Convert.ToString(DataTableUtilities.GetTableValue(this.m_SLXDataSheet.GetData(), this.m_SLXDataSheet.ValueMember, StateLabelXId, Strings.DATASHEET_NAME_COLUMN_NAME), CultureInfo.InvariantCulture); int StateLabelYId = Convert.ToInt32(DataTableUtilities.GetTableValue(this.m_SCDataSheet.GetData(), this.m_SCDataSheet.ValueMember, StateClassIdSource, Strings.DATASHEET_STATECLASS_STATE_LABEL_Y_ID_COLUMN_NAME), CultureInfo.InvariantCulture); string StateLabelYName = Convert.ToString(DataTableUtilities.GetTableValue(this.m_SLYDataSheet.GetData(), this.m_SLYDataSheet.ValueMember, StateLabelYId, Strings.DATASHEET_NAME_COLUMN_NAME), CultureInfo.InvariantCulture); if (dr[Strings.DATASHEET_DT_STRATUMIDSOURCE_COLUMN_NAME] != DBNull.Value) { StratumIdSource = Convert.ToInt32(dr[Strings.DATASHEET_DT_STRATUMIDSOURCE_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Strings.DATASHEET_DT_STRATUMIDDEST_COLUMN_NAME] != DBNull.Value) { StratumIdDestination = Convert.ToInt32(dr[Strings.DATASHEET_DT_STRATUMIDDEST_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Strings.DATASHEET_DT_STATECLASSIDDEST_COLUMN_NAME] != DBNull.Value) { StateClassIdDestination = Convert.ToInt32(dr[Strings.DATASHEET_DT_STATECLASSIDDEST_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Strings.DATASHEET_AGE_MIN_COLUMN_NAME] != DBNull.Value) { MinimumAge = Convert.ToInt32(dr[Strings.DATASHEET_AGE_MIN_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Strings.DATASHEET_AGE_MAX_COLUMN_NAME] != DBNull.Value) { MaximumAge = Convert.ToInt32(dr[Strings.DATASHEET_AGE_MAX_COLUMN_NAME], CultureInfo.InvariantCulture); } string slxdesc = StateLabelXName; string slydesc = StateLabelYName; object o1 = DataTableUtilities.GetTableValue(this.m_SLXDataSheet.GetData(), this.m_SLXDataSheet.ValueMember, StateLabelXId, Strings.DATASHEET_DESCRIPTION_COLUMN_NAME); object o2 = DataTableUtilities.GetTableValue(this.m_SLYDataSheet.GetData(), this.m_SLYDataSheet.ValueMember, StateLabelYId, Strings.DATASHEET_DESCRIPTION_COLUMN_NAME); if (o1 != DBNull.Value) { slxdesc = Convert.ToString(o1, CultureInfo.InvariantCulture); } if (o2 != DBNull.Value) { slydesc = Convert.ToString(o2, CultureInfo.InvariantCulture); } StateClassShape Shape = new StateClassShape(this.m_DataFeed.Project, StratumIdSource, StateClassIdSource, StratumIdDestination, StateClassIdDestination, MinimumAge, MaximumAge, StateLabelXId, StateLabelXName, slxdesc, StateLabelYId, slydesc); Shape.Row = ShapeRow; Shape.Column = ShapeColumn; DiagramShapeItem SlyItem = new DiagramShapeItem(StateLabelYName); SlyItem.Alignment = DiagramAlignment.Center; Shape.AddDiagramItem(SlyItem); int MinAge = 0; if (MinimumAge.HasValue) { MinAge = MinimumAge.Value; } string AgeText = null; if (MaximumAge.HasValue) { AgeText = string.Format(CultureInfo.InvariantCulture, "{0} - {1}", MinAge, MaximumAge.Value); } else { AgeText = string.Format(CultureInfo.InvariantCulture, "{0}+", MinAge); } DiagramShapeItem item = new DiagramShapeItem(AgeText); item.Alignment = DiagramAlignment.Center; Shape.AddDiagramItem(item); bool IsWild = (this.m_StratumId.HasValue && !Shape.StratumIdSource.HasValue); if (IsWild) { Shape.IsStatic = true; Shape.TitleTextColor = Constants.TRANSITION_DIAGRAM_READONLY_TEXT_COLOR; Shape.BorderColor = Constants.TRANSITION_DIAGRAM_SHAPE_READONLY_BORDER_COLOR; foreach (DiagramShapeItem i in Shape.DiagramShapeItems) { i.ForegroundColor = Constants.TRANSITION_DIAGRAM_READONLY_TEXT_COLOR; } } lst.Add(Shape); } return(lst); }
private void CreateOutgoingPTLines(StateClassShape fromShape, DTAnalyzer analyzer) { foreach (Transition t in fromShape.OutgoingPT) { StateClassShape ToShape = null; //If there is no destination state class then it is a transition-to-self if (!t.StateClassIdDestination.HasValue) { ToShape = fromShape; } else { int?StratumIdActual = null; analyzer.ResolveStateClassStratum( t.StratumIdSource, t.StratumIdDestination, t.StateClassIdDestination.Value, ref StratumIdActual); if (NullableUtilities.NullableIdsEqual(StratumIdActual, this.m_StratumId)) { //If the class was found in the current stratum then it will be in the //explicit lookups if the current stratum is explicit and the wildcard //lookups if it is not. if (this.m_StratumId.HasValue) { ToShape = this.m_ExplicitClasses[t.StateClassIdDestination.Value]; } else { ToShape = this.m_WildcardClasses[t.StateClassIdDestination.Value]; } } else { //If the class was not found in the current stratum it will be in the //wild card lookups if its stratum is wild. if (this.m_StratumId.HasValue && (!StratumIdActual.HasValue)) { ToShape = this.m_WildcardClasses[t.StateClassIdDestination.Value]; } } } //If a shape was not found then it is an off-stratum transition. //Otherwise, create the approprate line and add it to the diagram. if (ToShape != null) { ProbabilisticTransitionLine Line = null; if (fromShape == ToShape) { Line = CreatePTLineToSelf(fromShape, t.TransitionTypeId); } else { Line = new ProbabilisticTransitionLine(t.TransitionTypeId, Constants.PROBABILISTIC_TRANSITION_LINE_COLOR); this.FillLineSegments(fromShape, ToShape, Line, BoxArrowDiagramConnectorMode.Vertical); } this.FillPTLineTransitionGroups(Line); this.AddLine(Line); fromShape.OutgoingPTLines.Add(Line); ToShape.IncomingPTLines.Add(Line); } } }