예제 #1
0
        /// <summary>
        /// Pastes any incoming deterministic transitions
        /// </summary>
        /// <param name="cd"></param>
        /// <param name="entry"></param>
        /// <remarks>
        /// Create all incoming deterministic transitions described in the specified clipboard entry as follows:
        ///
        /// (1.) We are not going to look at any state classes that are in the clipboard since the transitions for these state
        ///      classes were established when the state classes paste was performed.
        ///
        /// (2.) If the transition is coming from a state class in the same diagram (but that state class is not found in the clipboard) then we
        ///      can create that transition.  But we can only do this if the source state class does not have a transition to another state class.
        ///
        /// (3.) If it is a transition coming from an off-stratum state class, make sure the state class still exists in the source stratum.  And,
        ///      as with a state class in this diagram, only do this if the source state class does not have a transition to another state class.
        /// </remarks>
        private void PasteDTIncoming(TransitionDiagramClipData cd, TransitionDiagramClipDataEntry entry, DTAnalyzer analyzer)
        {
            foreach (DeterministicTransitionClipData t in entry.IncomingDT)
            {
                if (!ClipContainsStateClass(cd, t.StateClassIdSource))
                {
                    if (this.m_ExplicitClasses.ContainsKey(t.StateClassIdSource))
                    {
                        DataRow dr = analyzer.GetStateClassRow(this.m_StratumId, t.StateClassIdSource);

                        if (IsDTToSelf(dr))
                        {
                            dr[Strings.DATASHEET_DT_STATECLASSIDDEST_COLUMN_NAME] = entry.ShapeData.StateClassIdSource;
                        }
                    }
                    else
                    {
                        DataRow dr = analyzer.GetStateClassRow(t.StratumIdSource, t.StateClassIdSource);

                        if (dr != null && IsDTToSelf(dr))
                        {
                            dr[Strings.DATASHEET_DT_STATECLASSIDDEST_COLUMN_NAME] = entry.ShapeData.StateClassIdSource;
                            dr[Strings.DATASHEET_DT_STRATUMIDDEST_COLUMN_NAME]    = this.m_StratumId;
                        }
                    }
                }
            }
        }
예제 #2
0
        private void InternalCopyToClip()
        {
            DataObject dobj = new DataObject();
            TransitionDiagramClipData data           = new TransitionDiagramClipData();
            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);
            List <StateClassShape> PrioritizedShapes = this.GetPrioritizedShapeList();

            foreach (StateClassShape Shape in PrioritizedShapes)
            {
                TransitionDiagramClipDataEntry Entry = new TransitionDiagramClipDataEntry();

                if (Shape.StratumIdSource.HasValue)
                {
                    Entry.ShapeData.StratumSource = StratumSheet.ValidationTable.GetDisplayName(Shape.StratumIdSource.Value);
                }

                Entry.ShapeData.StateClassSource = StateClassSheet.ValidationTable.GetDisplayName(Shape.StateClassIdSource);

                if (Shape.StratumIdDest.HasValue)
                {
                    Entry.ShapeData.StratumDest = StratumSheet.ValidationTable.GetDisplayName(Shape.StratumIdDest.Value);
                }

                if (Shape.StateClassIdDest.HasValue)
                {
                    Entry.ShapeData.StateClassDest = StateClassSheet.ValidationTable.GetDisplayName(Shape.StateClassIdDest.Value);
                }

                Entry.ShapeData.AgeMin = Shape.AgeMinimum;
                Entry.ShapeData.AgeMax = Shape.AgeMaximum;
                Entry.Row    = Shape.Row;
                Entry.Column = Shape.Column;
                Entry.Bounds = Shape.Bounds;

                foreach (DeterministicTransition t in Shape.IncomingDT)
                {
                    Entry.IncomingDT.Add(DTToClipFormat(t, StratumSheet, StateClassSheet));
                }

                foreach (Transition t in Shape.IncomingPT)
                {
                    Entry.IncomingPT.Add(PTToClipFormat(t, StratumSheet, StateClassSheet, TransitionTypeSheet));
                }

                foreach (Transition t in Shape.OutgoingPT)
                {
                    Entry.OutgoingPT.Add(PTToClipFormat(t, StratumSheet, StateClassSheet, TransitionTypeSheet));
                }

                data.Entries.Add(Entry);
            }

            dobj.SetData(Strings.CLIPBOARD_FORMAT_TRANSITION_DIAGRAM, data);
            Clipboard.SetDataObject(dobj);
        }
예제 #3
0
        private void PastePTOutgoing(TransitionDiagramClipDataEntry entry, List <ProbabilisticTransitionClipData> alreadyPasted, DTAnalyzer analyzer)
        {
            foreach (ProbabilisticTransitionClipData t in entry.OutgoingPT)
            {
                if (AlreadyPastedPT(t, alreadyPasted))
                {
                    continue;
                }

                int?StratumIdDest = null;

                if (t.StateClassIdDest.HasValue)
                {
                    analyzer.ResolveStateClassStratum(t.StratumIdSource, t.StratumIdDest, t.StateClassIdDest.Value, ref StratumIdDest);
                }

                this.CreatePTRecord(this.m_StratumId, entry.ShapeData.StateClassIdSource, StratumIdDest, t.StateClassIdDest, t.TransitionTypeId, t.Probability, t.Proportion, t.AgeMin, t.AgeMax, t.AgeRelative, t.AgeReset, t.TstMin, t.TstMax, t.TstRelative);

                alreadyPasted.Add(t);
            }
        }
예제 #4
0
        private void PasteStateClassesCreateNew(TransitionDiagramClipData cd, TransitionDiagramClipDataEntry entry, int dx, int dy, bool pasteNone, DTAnalyzer analyzer)
        {
            int TargetRow    = entry.Row + dy;
            int TargetColumn = entry.Column + dx;

            //If 'PasteNone" or there is no destination state class then
            //create a transition-to-self in this stratum.

            if (pasteNone || (!entry.ShapeData.StateClassIdDest.HasValue))
            {
                this.CreateDTRecord(entry.ShapeData.StateClassIdSource, null, null, entry.ShapeData.AgeMin, entry.ShapeData.AgeMax, TargetRow, TargetColumn);

                return;
            }

            //If the destination state class is in the clipboard then create a transition
            //to that state class in this stratum.

            if (ClipContainsStateClass(cd, entry.ShapeData.StateClassIdDest.Value))
            {
                this.CreateDTRecord(entry.ShapeData.StateClassIdSource, null, entry.ShapeData.StateClassIdDest.Value, entry.ShapeData.AgeMin, entry.ShapeData.AgeMax, TargetRow, TargetColumn);

                return;
            }

            //Resolve the destination stratum and create a transition to that stratum.  Note that the resolution
            //will fail if the destination state class no longer exists and is not in the wild card stratum.  In
            //this case, create a transition-to-self.

            int?StratumIdActual = null;

            if (analyzer.ResolveStateClassStratum(entry.ShapeData.StratumIdSource, entry.ShapeData.StratumIdDest, entry.ShapeData.StateClassIdDest.Value, ref StratumIdActual))
            {
                this.CreateDTRecord(entry.ShapeData.StateClassIdSource, StratumIdActual, entry.ShapeData.StateClassIdDest.Value, entry.ShapeData.AgeMin, entry.ShapeData.AgeMax, TargetRow, TargetColumn);
            }
            else
            {
                this.CreateDTRecord(entry.ShapeData.StateClassIdSource, null, null, entry.ShapeData.AgeMin, entry.ShapeData.AgeMax, TargetRow, TargetColumn);
            }
        }
예제 #5
0
        private void PastePTOutgoingBetween(TransitionDiagramClipData cd, TransitionDiagramClipDataEntry entry, List <ProbabilisticTransitionClipData> alreadyPasted)
        {
            foreach (ProbabilisticTransitionClipData t in entry.OutgoingPT)
            {
                if (AlreadyPastedPT(t, alreadyPasted))
                {
                    continue;
                }

                if (!t.StateClassIdDest.HasValue)
                {
                    continue;
                }

                if (ClipContainsStateClass(cd, t.StateClassIdDest.Value))
                {
                    this.CreatePTRecord(this.m_StratumId, entry.ShapeData.StateClassIdSource, null, t.StateClassIdDest, t.TransitionTypeId, t.Probability, t.Proportion, t.AgeMin, t.AgeMax, t.AgeRelative, t.AgeReset, t.TstMin, t.TstMax, t.TstRelative);

                    alreadyPasted.Add(t);
                }
            }
        }
예제 #6
0
        private void PasteStateClassesReplace(TransitionDiagramClipDataEntry entry, DTAnalyzer analyzer)
        {
            DataRow dr = analyzer.GetStateClassRow(this.m_StratumId, entry.ShapeData.StateClassIdSource);

            if (entry.ShapeData.AgeMin.HasValue)
            {
                dr[Strings.DATASHEET_AGE_MIN_COLUMN_NAME] = entry.ShapeData.AgeMin.Value;
            }
            else
            {
                dr[Strings.DATASHEET_AGE_MIN_COLUMN_NAME] = DBNull.Value;
            }

            if (entry.ShapeData.AgeMax.HasValue)
            {
                dr[Strings.DATASHEET_AGE_MAX_COLUMN_NAME] = entry.ShapeData.AgeMax.Value;
            }
            else
            {
                dr[Strings.DATASHEET_AGE_MAX_COLUMN_NAME] = DBNull.Value;
            }
        }
예제 #7
0
        /// <summary>
        /// Gets the paste location delta values for the state classes on the clipboard
        /// </summary>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="targeted"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        private bool GetPasteLocationDeltas(ref int dx, ref int dy, bool targeted)
        {
            TransitionDiagramClipDataEntry UpperLeftEntry = GetUpperLeftClipEntry();

            //If the paste is targeted (using the context menu), then we only attempt to paste into the
            //cell that was current when the right mouse button was clicked.  But if it is a non-targeted
            //pasted then we need to search the diagram for a paste location.

            if (targeted)
            {
                dx = this.GetColumnDelta(this.CurrentMousePoint.X, UpperLeftEntry.Bounds.X);
                dy = this.GetRowDelta(this.CurrentMousePoint.Y, UpperLeftEntry.Bounds.Y);

                return(this.IsValidPasteLocation(dx, dy));
            }

            //First, try the original location

            dx = 0;
            dy = 0;

            if (this.IsValidPasteLocation(dx, dy))
            {
                return(true);
            }

            //Search all rows in the current column

            dx = 0;
            dy = 0;

            while (dy < Constants.TRANSITION_DIAGRAM_MAX_ROWS)
            {
                if (this.IsValidPasteLocation(dx, dy))
                {
                    return(true);
                }

                dy += 1;
            }

            //Search all columns and rows

            dx = this.GetColumnDelta(0, UpperLeftEntry.Bounds.X);

            while (dx < Constants.TRANSITION_DIAGRAM_MAX_COLUMNS)
            {
                dy = this.GetRowDelta(0, UpperLeftEntry.Bounds.Y);

                while (dy < Constants.TRANSITION_DIAGRAM_MAX_ROWS)
                {
                    if (this.IsValidPasteLocation(dx, dy))
                    {
                        return(true);
                    }

                    dy += 1;
                }

                dx += 1;
            }

            //No location found anywhere!
            return(false);
        }