File size: 2,389 Bytes
fab29d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (c) Dr. Dirk Lellinger. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SlobViewer.Common;
using SlobViewer.Slob;

namespace SlobViewer.Gui
{
  /// <summary>
  /// Interaction logic for MainWindow.xaml
  /// </summary>
  public partial class DictionaryControl : UserControl
  {
    public DictionaryController Controller { get; private set; } = new DictionaryController();


    public DictionaryControl()
    {
      InitializeComponent();
      this.DataContext = Controller;
    }

    /*
    private void EhSearchTextChanged(object sender, TextChangedEventArgs e)
    {
        var searchText = ((TextBox)sender).Text;
        Controller.ShowContentForKey(searchText);
        Controller.UpdateBestMatches(searchText);
    }
    */

    private void EhSearchSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
      if (0 == Controller.SearchListLock)
      {
        if (e.AddedItems.Count > 0)
        {
          var item = e.AddedItems[0];
          var s = (string)item;
          _guiSearchText.Text = s;
        }
      }

      if (null != _guiSearchList.SelectedItem)
        _guiSearchList.ScrollIntoView(_guiSearchList.SelectedItem);
    }

    private void EhBestMatchSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
      if (e.AddedItems.Count > 0)
      {
        var s = (string)e.AddedItems[0];
        Controller.ShowContentForKey(s);
      }
    }

    private void EhHide(object sender, RoutedEventArgs e)
    {
      this.Visibility = Visibility.Hidden;
    }

    private void EhDocumentMouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
      var selection = _guiFlowDocReader.Selection;
      if (!selection.IsEmpty)
      {
        Controller.Action_ShowSecondaryWord(selection.Text);
      }
    }
  }
}