Beispiel #1
0
 public void select(Select target)
 {
     if (target == null)
     {
         selected = false;
         if (now != null) now.Background = Brushes.LightGray;
         return;
     }
     else selected = true;
     if (now != null) now.Background = new SolidColorBrush(Color.FromArgb(255, 200, 200, 200));
     now = target;
     now.Background = Brushes.Blue;
     explain.Text = now.explain;
     scroll.ScrollToVerticalOffset(18.0 * selects.IndexOf(now));
 }
Beispiel #2
0
 public void clear()
 {
     selects.Clear();
     now = null;
 }
Beispiel #3
0
 public void add(Select select)
 {
     selects.Add(select);
     select.parent = this;
 }
Beispiel #4
0
 public void check_word(Text text)
 {
     if (selects.Count == 0) return;
     Word start, end;
     start = end = text.from.word;
     if (Word.In_call(start))
     {
         for (; ; start = start.before)
         {
             if (Word.In_call(start.before) == false) break;
         }
         for (; ; end = end.next)
         {
             if (Word.In_call(end.next) == false) break;
         }
         String str = "";
         for (Word now = start; ; now = now.next)
         {
             str += now.str;
             if (now == end) break;
         }
         foreach (Select s in selects)
         {
             if (s.str.StartsWith(str))
             {
                 select(s);
                 return;
             }
         }
         select(null);
     }
     else select(selects[0]);
 }
Beispiel #5
0
 public static int compare(Select s1, Select s2)
 {
     String str1 = s1.str, str2 = s2.str;
     for (int i = 0; ; i++) {
         if (i == str1.Length || i == str2.Length) return 0;
         else if (i >= str1.Length) return -1;
         else if (i >= str2.Length) return 1;
         char c1 = str1[i], c2 = str2[i];
         if (char.ToLower(c1) > char.ToLower(c2)) return 1;
         else if (char.ToLower(c2) > char.ToLower(c1)) return -1;
         else if (c1 > c2) return -1;
     }
 }