Ejemplo n.º 1
0
        private static int StateIdShadowSorterVisioPageGroupHelper(Shadow a, Shadow b)
        {
            if (a == b)
            {
                return(0);
            }

            StateShadow stateA = a as StateShadow;
            StateShadow stateB = b as StateShadow;

            if (stateA == null)
            {
                return(1);
            }
            if (stateB == null)
            {
                return(-1);
            }

            string stateAPrefix, stateANumber, stateAName;
            string stateBPrefix, stateBNumber, stateBName;

            StateShadow.DisectStateIdIntoParts(stateA.GetStateId(), out stateAPrefix, out stateANumber, out stateAName);
            StateShadow.DisectStateIdIntoParts(stateB.GetStateId(), out stateBPrefix, out stateBNumber, out stateBName);

            int earliestPageA = stateToPageReference[stateAPrefix + stateANumber];
            int earliestPageB = stateToPageReference[stateBPrefix + stateBNumber];

            if (earliestPageA != earliestPageB)
            {
                return(earliestPageA - earliestPageB);
            }

            return(stateA.GetStateId().CompareTo(stateB.GetStateId()));
        }
        internal void SetSubDialogUID(string subDialogUID)
        {
            Common.SetCellString(shape, ShapeProperties.CallSubDialog.SubDialogUID, subDialogUID);
            StateShadow shadow = PathMaker.LookupShadowByUID(subDialogUID) as StateShadow;

            if (shadow != null)
            {
                Common.ForcedSetShapeText(shape, StateShadow.StateIdForDisplay(shadow.GetStateId()));
            }
        }
        private void highlightStateForRow(int rowIndex)
        {
            string tmpline   = UISpecResultsGridView[0, rowIndex].Value.ToString();
            string matchName = string.Empty;

            Regex r1    = new Regex(Strings.StartTargetName);
            Match match = r1.Match(tmpline);

            //check to see if it's is a Start shape or something like it without ID Number.
            if (match.Success)
            {
                matchName = match.Groups[0].Value;
            }
            else
            {
                r1    = new Regex("[A-Z]{2}[0-9]{4}");
                match = r1.Match(tmpline);
                if (match.Success)
                {
                    matchName = match.Groups[0].Value;
                }
                else
                {
                    return;
                }
            }

            List <Shadow> shadowList = PathMaker.LookupAllShadows();

            foreach (Shadow shadow in shadowList)
            {
                StateShadow stateShadow = shadow as StateShadow;
                if (stateShadow != null)
                {
                    string stateName = stateShadow.GetStateId();

                    if (stateName.Contains(matchName))
                    {
                        visioControl.Document.Application.ActiveWindow.Page = visioControl.Document.Application.ActivePage;
                        shadow.SelectShape();
                        break;
                    }
                }
                else
                {
                    //if stateShadow is null then if it is a start shape
                    if (shadow.GetShapeType().ToString().Contains(matchName))
                    {
                        visioControl.Document.Application.ActiveWindow.Page = visioControl.Document.Application.ActivePage;
                        shadow.SelectShape();
                        break;
                    }
                }
            }
        }
 /**
  * Called when the stateId of the SubDialog associated with this CallSubDialog is changed
  * Needed to update the shape text of this shape
  */
 internal void OnSubDialogStateIdChanged(string subDialogUID)
 {
     if (GetSubDialogUID().Equals(subDialogUID))
     {
         StateShadow shadow = PathMaker.LookupShadowByUID(subDialogUID) as StateShadow;
         if (shadow != null)
         {
             Common.ForcedSetShapeText(shape, StateShadow.StateIdForDisplay(shadow.GetStateId()));
         }
     }
 }
Ejemplo n.º 5
0
        public static void StateIdShadowSorterVisioHeuristic(List <Shadow> shadowList, Document doc, StartShadow startShadow)
        {
            // group by alpha prefix, then by number within that
            // then sort groups by first visio page reference
            // if both on same page, startPrefix is first, the sort alphanumerically

            string firstPrefix = String.Empty;
            Shadow firstShadow = startShadow.GetFirstStateGotoTarget();

            if (firstShadow != null)
            {
                StateShadow firstState = firstShadow as StateShadow;
                string      firstNumber, firstName;
                StateShadow.DisectStateIdIntoParts(firstState.GetStateId(), out firstPrefix, out firstNumber, out firstName);
            }

            // make a list of first page references of each alpha prefix
            earliestPageReference = new Dictionary <string, int>();
            foreach (Shadow s in shadowList)
            {
                StateShadow sState = s as StateShadow;
                if (sState == null)
                {
                    continue;
                }
                int    pageNumber = s.GetPageNumber();
                string statePrefix, stateNumber, stateName;
                StateShadow.DisectStateIdIntoParts(sState.GetStateId(), out statePrefix, out stateNumber, out stateName);

                // always make this highest priority
                if (statePrefix.Equals(firstPrefix))
                {
                    pageNumber = -1;
                }

                int earliest;
                if (earliestPageReference.TryGetValue(statePrefix, out earliest))
                {
                    if (pageNumber < earliest)
                    {
                        earliestPageReference[statePrefix] = pageNumber;
                    }
                }
                else
                {
                    earliestPageReference.Add(statePrefix, pageNumber);
                }
            }

            shadowList.Sort(StateIdShadowSorterVisioHeuristicHelper);
        }
        public static void Remove(StateShadow stateShadow)
        {
            string prefix, number, name;

            StateShadow.DisectStateIdIntoParts(stateShadow.GetStateId(), out prefix, out number, out name);
            int backupToNumber = currentStateNumber;

            // let's make sure this isn't an undo of a paste of a duplicate
            string      prefixPlusNumber;
            StateShadow shadow;

            if (prefixNumberToShadow.TryGetValue(prefix + number, out shadow))
            {
                if (shadow == stateShadow)
                {
                    // good match - remove
                    prefixNumberToShadow.Remove(prefix + number);
                    shadowToPrefixNumber.Remove(shadow);

                    int numberInt;
                    if (int.TryParse(number, out numberInt))
                    {
                        backupToNumber = numberInt;
                    }
                }
                else
                {
                    if (shadowToPrefixNumber.TryGetValue(stateShadow, out prefixPlusNumber))
                    {
                        // so we are registered with a different prefix + number, remove that one
                        prefixNumberToShadow.Remove(prefixPlusNumber);
                        shadowToPrefixNumber.Remove(stateShadow);

                        int numberInt;
                        if (int.TryParse(number, out numberInt))
                        {
                            backupToNumber = numberInt;
                        }
                    }
                    else
                    {
                        // should never get here...
                        Common.ErrorMessage("Removing a state which isn't in the State Id Map");
                    }
                }
                if (backupToNumber < currentStateNumber)
                {
                    currentStateNumber = backupToNumber;
                }
            }
        }
Ejemplo n.º 7
0
        public static void StateIdShadowSorterVisioPageGrouping(List <Shadow> shadowList, Document doc, StartShadow startShadow)
        {
            // Try to create a group of states per Visio page then
            // sort alphanumerically so the printing order matches the pages

            //string firstPrefix = String.Empty;
            //Shadow firstShadow = startShadow.GetFirstStateGotoTarget();
            //if (firstShadow != null)
            //{
            //StateShadow firstState = firstShadow as StateShadow;
            //string firstNumber, firstName;
            //StateShadow.DisectStateIdIntoParts(firstState.GetStateId(), out firstPrefix, out firstNumber, out firstName);
            //}

            // make a list of first page references of each alpha prefix
            stateToPageReference = new Dictionary <string, int>();
            foreach (Shadow s in shadowList)
            {
                StateShadow sState = s as StateShadow;
                if (sState == null)
                {
                    continue;
                }
                //int firstPageNumber;
                int    pageNumber = s.GetPageNumber();
                string statePrefix, stateNumber, stateName;
                StateShadow.DisectStateIdIntoParts(sState.GetStateId(), out statePrefix, out stateNumber, out stateName);

                // always make this highest priority
                //if (sState.GetStateId().Equals(firstState.GetStateId()))
                //firstPageNumber = pageNumber;

                int earliest;
                if (stateToPageReference.TryGetValue(statePrefix + stateNumber, out earliest))
                {
                    if (pageNumber < earliest)
                    {
                        stateToPageReference[statePrefix + stateNumber] = pageNumber;
                    }
                }
                else
                {
                    stateToPageReference.Add(statePrefix + stateNumber, pageNumber);
                }
            }

            shadowList.Sort(StateIdShadowSorterVisioPageGroupHelper);
        }
Ejemplo n.º 8
0
        public static int StateIdShadowSorterAlphaNumerical(Shadow a, Shadow b)
        {
            if (a == b)
            {
                return(0);
            }

            StateShadow stateA = a as StateShadow;
            StateShadow stateB = b as StateShadow;

            if (stateA == null)
            {
                return(1);
            }
            if (stateB == null)
            {
                return(-1);
            }

            return(stateA.GetStateId().CompareTo(stateB.GetStateId()));
        }
Ejemplo n.º 9
0
        public static int StateIdShadowSorterNumericalAlpha(Shadow a, Shadow b)
        {
            if (a == b)
            {
                return(0);
            }

            StateShadow stateA = a as StateShadow;
            StateShadow stateB = b as StateShadow;

            if (stateA == null)
            {
                return(1);
            }
            if (stateB == null)
            {
                return(-1);
            }

            string stateAPrefix, stateANumber, stateAName;
            string stateBPrefix, stateBNumber, stateBName;

            StateShadow.DisectStateIdIntoParts(stateA.GetStateId(), out stateAPrefix, out stateANumber, out stateAName);
            StateShadow.DisectStateIdIntoParts(stateB.GetStateId(), out stateBPrefix, out stateBNumber, out stateBName);

            int result = stateANumber.CompareTo(stateBNumber);

            if (result == 0)
            {
                return(stateAPrefix.CompareTo(stateBPrefix));
            }
            else
            {
                return(result);
            }
        }
        public static void Remove(StateShadow stateShadow)
        {
            string prefix, number, name;
            StateShadow.DisectStateIdIntoParts(stateShadow.GetStateId(), out prefix, out number, out name);
            int backupToNumber = currentStateNumber;

            // let's make sure this isn't an undo of a paste of a duplicate
            string prefixPlusNumber;
            StateShadow shadow;
            if (prefixNumberToShadow.TryGetValue(prefix + number, out shadow)) {
                if (shadow == stateShadow) {
                    // good match - remove
                    prefixNumberToShadow.Remove(prefix + number);
                    shadowToPrefixNumber.Remove(shadow);

                    int numberInt;
                    if (int.TryParse(number, out numberInt))
                        backupToNumber = numberInt;
                }
                else {
                    if (shadowToPrefixNumber.TryGetValue(stateShadow, out prefixPlusNumber)) {
                        // so we are registered with a different prefix + number, remove that one
                        prefixNumberToShadow.Remove(prefixPlusNumber);
                        shadowToPrefixNumber.Remove(stateShadow);

                        int numberInt;
                        if (int.TryParse(number, out numberInt))
                            backupToNumber = numberInt;
                    }
                    else {
                        // should never get here...
                        Common.ErrorMessage("Removing a state which isn't in the State Id Map");
                    }
                }
                if (backupToNumber < currentStateNumber)
                    currentStateNumber = backupToNumber;
            }
        }
Ejemplo n.º 11
0
        private static void FillEnteringFrom(Cell cell, StateShadow shadow)
        {
            List<string> list = shadow.GetEnteringFromTargetNames();
            List<string> maxList;

            HashSet<string> uniqueList = new HashSet<string>();
            foreach (string s in list)
                uniqueList.Add(s);
            if (gotoMaxHandlerCache.TryGetValue(shadow.GetStateId(), out maxList))
                foreach (string s in maxList)
                    uniqueList.Add(s);

            list = uniqueList.ToList();

            bool first = true;
            cell.Range.InsertAfter(" ");
            foreach (string enteringFrom in list) {
                if (!first)
                    cell.Range.InsertAfter(", ");
                first = false;

                Selection sel = cell.Application.Selection;
                sel.InsertAfter(enteringFrom);
                sel.set_Style("HyperLink");
                string link = "bm" + Left(AlphaNumericCharsOnly(enteringFrom), 38);
                sel.Document.Hyperlinks.Add(Anchor: sel.Range, SubAddress: link);
                int count = cell.Range.Characters.Count;
                sel.set_Style("TableNormalCell");
                sel.MoveStart(WdUnits.wdWord, -1);
                sel.Cut();
                Range range = cell.Range.Characters[count - 1];
                range.Paste();

            }
        }