예제 #1
0
        public ISegment GetBeforeReplaceableActiveElement(bool stopWhenReachOut = true)
        {
            if (Context != null && IsSnippetActivated)
            {
                ReplaceableActiveElement beforeElement = null;
                foreach (IActiveElement element in Context.ActiveElements)
                {
                    ReplaceableActiveElement re = element as ReplaceableActiveElement;

                    if (re != null)
                    {
                        if (_activeElement.Equals(re))
                        {
                            if (beforeElement == null)//이번 것이 첫 snippet이고, 이전에 선택된 것과 같을 경우..
                            {
                                if (stopWhenReachOut)
                                {
                                    return(re.Segment);                  //더이상 움직이지 않는다.
                                }
                                else//끝낸다.
                                {
                                    IsSnippetActivated = false;
                                    _activeElement     = null;
                                    return(null);
                                }
                            }
                            else
                            {
                                _activeElement     = beforeElement;
                                IsSnippetActivated = true;
                                return(beforeElement.Segment);
                            }
                        }
                        else
                        {
                            beforeElement = re;//계속 저장하면서 나간다.
                        }
                    }
                }
                if (beforeElement != null)//제일 마지막까지 왔다면 뒤에서부터 처음 시작했다는 의미이다.
                {
                    _activeElement     = beforeElement;
                    IsSnippetActivated = true;
                    return(beforeElement.Segment);
                }
            }

            return(null);//제일 마지막까지 갔는데 없다면 ActiveSnippet이 하나도 없는 것이다.
        }
예제 #2
0
        public ISegment GetFirstReplaceableActiveElement()
        {
            if (Context != null && IsSnippetActivated)
            {
                foreach (IActiveElement element in Context.ActiveElements)
                {
                    ReplaceableActiveElement re = element as ReplaceableActiveElement;
                    if (re != null)
                    {
                        return(re.Segment);
                    }
                }
            }

            return(null);//제일 마지막까지 갔는데 없다면 모든 Active snippet을 돈 것이다.
        }
예제 #3
0
 public int GetCountOfReplaceableActiveElement()
 {
     if (Context != null && IsSnippetActivated)
     {
         int count = 0;
         foreach (IActiveElement element in Context.ActiveElements)
         {
             ReplaceableActiveElement re = element as ReplaceableActiveElement;
             if (re != null)
             {
                 count++;
             }
         }
         return(count);
     }
     return(0);
 }
예제 #4
0
 public ISegment GetLastReplaceableActiveElement()
 {
     if (Context != null && IsSnippetActivated)
     {
         ReplaceableActiveElement last = null;
         foreach (IActiveElement element in Context.ActiveElements)
         {
             ReplaceableActiveElement re = element as ReplaceableActiveElement;
             if (re != null)
             {
                 last = re;
             }
         }
         return(last.Segment);
     }
     return(null);
 }
예제 #5
0
        public ISegment GetNextReplaceableActiveElement(bool stopWhenReachOut = true)
        {
            if (Context != null && IsSnippetActivated)
            {
                bool isCurrent = false;
                foreach (IActiveElement element in Context.ActiveElements)
                {
                    ReplaceableActiveElement re = element as ReplaceableActiveElement;
                    if (re != null)
                    {
                        if (_activeElement == null)
                        {
                            _activeElement     = re;
                            IsSnippetActivated = true;
                            return(re.Segment);
                        }
                        else
                        {
                            if (_activeElement.Equals(re))
                            {
                                isCurrent = true;
                            }
                            else if (isCurrent)
                            {
                                _activeElement = re;

                                IsSnippetActivated = true;
                                return(re.Segment);
                            }
                        }
                    }
                }
            }
            if (stopWhenReachOut)
            {
                return(_activeElement.Segment);
            }
            else
            {
                _activeElement     = null;
                IsSnippetActivated = false;
                return(null);//제일 마지막까지 갔는데 없다면 모든 Active snippet을 돈 것이다.
            }
        }
예제 #6
0
 public int GetIndexOfActivatedReplaceableActiveElement()
 {
     if (Context != null && IsSnippetActivated)
     {
         int count = 0;
         foreach (IActiveElement element in Context.ActiveElements)
         {
             ReplaceableActiveElement re = element as ReplaceableActiveElement;
             if (re != null)
             {
                 if (re.Equals(_activeElement))
                 {
                     return(count);
                 }
                 count++;
             }
         }
         return(count);
     }
     return(0);
 }
예제 #7
0
 public ISegment GetReplaceableActiveElement(int index)
 {
     if (Context != null && IsSnippetActivated)
     {
         int count = 0;
         foreach (IActiveElement element in Context.ActiveElements)
         {
             ReplaceableActiveElement re = element as ReplaceableActiveElement;
             if (re != null)
             {
                 if (count == index)
                 {
                     return(re.Segment);
                 }
                 else
                 {
                     count++;
                 }
             }
         }
     }
     return(null);
 }