Exemplo n.º 1
0
        private async void OnFileListViewSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (FileListView.SelectedItem is FileItem f)
            {
                if (HitListView.SelectedItem == null || HitListView.SelectedItem is HitItem h && h.Fid != f.Fid)
                {
                    if (f.HitRows > 0 && HitListView.ItemsSource is ObservableCollection <HitItem> hh)
                    {
                        HitListView.SelectedItem = hh.Where(x => x.Fid == f.Fid).FirstOrDefault();
                    }
                    else
                    {
                        HitListView.SelectedItem = null;
                    }
                    if (HitListView.SelectedItem == null)
                    {
                        await client.OnSelectionChanged(f);

                        ContentListView.SelectedIndex = 0;
                        ContentListView.ScrollIntoView(ContentListView.SelectedItem);
                        ContentListView.SelectedIndex = -1;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private async void JumpToButton_Click(object sender, RoutedEventArgs e)
        {
            int lineNo;
            var keyword = JumpToInputBox.Text.Trim();
            var succ    = int.TryParse(keyword, out lineNo);

            if (succ)
            {
                if (lineNo >= 1 && lineNo <= ViewModel.Contents.Count)
                {
                    ContentListView.ScrollIntoView(ContentListView.Items[lineNo - 1], ScrollIntoViewAlignment.Leading);
                }
                else
                {
                    MessageDialog dialog = new MessageDialog("Line No out of range", "Jump Failed");
                    await dialog.ShowAsync();
                }
            }
            else
            {
                lineNo = GetCurrentLineNo();
                var list = ViewModel.ChapterData.Lines as List <Service.Line>;
                lineNo = list.FindIndex(lineNo, l => (l.ContentType == LineContentType.TextContent && l.Content.Contains(keyword)));
                if (lineNo >= 0)
                {
                    ContentListView.ScrollIntoView(ContentListView.Items[lineNo], ScrollIntoViewAlignment.Leading);
                }
                else
                {
                    MessageDialog dialog = new MessageDialog("Cannot find specified keyword", "Jump Failed");
                    await dialog.ShowAsync();
                }
            }
        }
        void ContentListView_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            int index = (int)ContentListView.GetValue(ContentListViewChangeViewRequestProperty);

            if (index >= 0 && e.NewSize.Height > 10 && ContentListView.Items.Count > 0 && index < ContentListView.Items.Count)
            {
                ContentListView.UpdateLayout();
                ContentListView.ScrollIntoView(ViewModel.Contents[index], ScrollIntoViewAlignment.Leading);
                index = -1;
                ContentListView.SizeChanged -= ContentListView_SizeChanged;
            }
        }
Exemplo n.º 4
0
        private async void OnHitListViewSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (HitListView.SelectedItem is HitItem h)
            {
                await client.OnSelectionChanged(h);

                int v = h.Line - 1;
                ContentListView.SelectedIndex = v;
                ContentListView.ScrollIntoView(ContentListView.SelectedItem);
            }
            else
            {
                ContentListView.SelectedIndex = -1;
            }
        }
 void ChangeView(int page, int line = -1)
 {
     if (line >= 0)
     {
         ContentListView.UpdateLayout();
         if (ContentListView.Items.Count == 0)
         {
             ContentListView.SetValue(ContentListViewChangeViewRequestProperty, line);
             ContentListView.SizeChanged += ContentListView_SizeChanged;
         }
         else if (line < ContentListView.Items.Count)
         {
             ContentListView.ScrollIntoView(ViewModel.Contents[line], ScrollIntoViewAlignment.Leading);
         }
     }
 }