Ejemplo n.º 1
0
 private static bool IsArrowClickable(TagArrowInfo tag)
 {
     if (tag != null)
     {
         if (tag.refObj is ParserObject &&
             (tag.refObj.NextContinuedObj != null || tag.refObj.PrevInterruptedObj != null))
         {
             int idx = tag.stateObj.Parent.StateCollection.IndexOf(tag.stateObj);
             if (idx > 0 && idx < tag.stateObj.Parent.StateCollection.Count)
             {
                 var nextState = idx < tag.stateObj.Parent.StateCollection.Count - 1 ?
                                 tag.stateObj.Parent.StateCollection[idx + 1] : null;
                 var prevState = tag.stateObj.Parent.StateCollection[idx - 1];
                 if (nextState == null || nextState.ObjectClass == ObjectClass.Blank || prevState.ObjectClass == ObjectClass.Blank)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        private static void CreateArrowImageCell(StateObject stateObj, DataGridViewRow row, int cellIndex, ParserObject nextContinuedObj, ParserObject prevInterruptedObj)
        {
            var cell = new DataGridViewImageCell();

            if (stateObj == null)
            {
                row.Cells[cellIndex] = cell;
                return;
            }

            if (prevInterruptedObj != null)
            {
                var tag = new TagArrowInfo {
                    refObj = prevInterruptedObj, stateObj = stateObj
                };
                if (IsArrowClickable(tag))
                {
                    cell.Value      = ImageExt.ColorReplace(Properties.Resources.forward_arrow, Color.White, ColorTranslator.FromHtml(prevInterruptedObj.BaseColor));
                    tag.IsClickable = true;
                    tag.ToolTipText = "To PREVIOUS state...";
                    cell.Tag        = tag;
                }
                else
                {
                    cell.Value      = Properties.Resources.forward_arrow;
                    tag.IsClickable = false;
                    cell.Tag        = new TagArrowInfo {
                        refObj = null, stateObj = stateObj
                    };
                }
            }
            else if (nextContinuedObj != null)
            {
                var tag = new TagArrowInfo {
                    refObj = nextContinuedObj, stateObj = stateObj
                };
                if (IsArrowClickable(tag))
                {
                    cell.Value      = ImageExt.ColorReplace(Properties.Resources.forward_arrow, Color.White, ColorTranslator.FromHtml(nextContinuedObj.BaseColor));
                    tag.IsClickable = true;
                    tag.ToolTipText = "To NEXT state...";
                    cell.Tag        = tag;
                }
                else
                {
                    cell.Value      = Properties.Resources.forward_arrow;
                    tag.IsClickable = false;
                    cell.Tag        = new TagArrowInfo {
                        refObj = null, stateObj = stateObj
                    };
                }
            }
            else
            {
                cell.Value = Properties.Resources.forward_arrow;
                cell.Tag   = new TagArrowInfo {
                    refObj = null, stateObj = stateObj
                };
            }

            row.Cells[cellIndex] = cell;
        }